4.4BSD/usr/src/contrib/emacs-18.57/lisp/rnews.elc


(provide (quote rnews))

(require (quote mail-utils))

(autoload (quote rmail-output) "rmailout" "\
Append this message to Unix mail file named FILE-NAME." t)

(autoload (quote news-reply) "rnewspost" "\
Compose and post a reply to the current article on USENET.
While composing the reply, use \\[mail-yank-original] to yank the original
message into it." t)

(autoload (quote news-mail-other-window) "rnewspost" "\
Send mail in another window.
While composing the message, use \\[mail-yank-original] to yank the
original message into it." t)

(autoload (quote news-post-news) "rnewspost" "\
Begin editing a new USENET news article to be posted." t)

(autoload (quote news-mail-reply) "rnewspost" "\
Mail a reply to the author of the current article.
While composing the reply, use \\[mail-yank-original] to yank the original
message into it." t)

(defvar rmail-last-file (expand-file-name "~/mbox.news"))

(defvar news-startup-file "$HOME/.newsrc" "\
Contains ~/.newsrc")

(defvar news-certification-file "$HOME/.news-dates" "\
Contains ~/.news-dates")

(defvar news-ignored-headers "^Path:\\|^Posting-Version:\\|^Article-I.D.:\\|^Expires:\\|^Date-Received:\\|^References:\\|^Control:\\|^Xref:\\|^Lines:\\|^Posted:\\|^Relay-Version:\\|^Message-ID:\\|^Nf-ID:\\|^Nf-From:\\|^Approved:\\|^Sender:" "\
All random fields within the header of a message.")

(defvar news-mode-map nil)

(defvar news-read-first-time-p t)

(defvar news-user-group-list nil)

(defvar news-current-news-group nil)

(defvar news-current-group-begin nil)

(defvar news-current-group-end nil)

(defvar news-current-certifications nil "\
An assoc list of a group name and the time at which it is
known that the group had no new traffic")

(defvar news-current-certifiable nil "\
The time when the directory we are now working on was written")

(defvar news-message-filter nil "\
User specifiable filter function that will be called during
formatting of the news file")

(defvar news-list-of-files nil "\
Global variable in which we store the list of files
associated with the current newsgroup")

(defvar news-list-of-files-possibly-bogus nil "\
variable indicating we only are guessing at which files are available.
Not currently used.")

(defvar news-group-article-assoc nil)

(defvar news-current-message-number 0 "\
Displayed Article Number")

(defvar news-total-current-group 0 "\
Total no of messages in group")

(defvar news-unsubscribe-groups nil)

(defvar news-point-pdl nil "\
List of visited news messages.")

(defvar news-no-jumps-p t)

(defvar news-buffer nil "\
Buffer into which news files are read.")

(defmacro news-push (item ref) (byte-code "	EE" [ref item setq cons] 5))

(defmacro news-cadr (x) (byte-code "DD" [x car cdr] 3))

(defmacro news-cdar (x) (byte-code "DD" [x cdr car] 3))

(defmacro news-caddr (x) (byte-code "DDD" [x car cdr] 4))

(defmacro news-cadar (x) (byte-code "DDD" [x car cdr] 4))

(defmacro news-caadr (x) (byte-code "DDD" [x car cdr] 4))

(defmacro news-cdadr (x) (byte-code "DDD" [x cdr car] 4))

(defmacro news-wins (pfx index) (byte-code "	DFD" [pfx index file-exists-p concat "/" int-to-string] 6))

(defvar news-max-plausible-gap 2 "\
* In an rnews directory, the maximum possible gap size.
A gap is a sequence of missing messages between two messages that exist.
An empty file does not contribute to a gap -- it ends one.")

(defun news-find-first-and-last (prefix base) (byte-code "	!Q!	#	#B" [prefix base file-exists-p "/" int-to-string news-find-first-or-last -1 1] 8))

(defmacro news-/ (a1 a2) (byte-code "\"!	E\"ED	ED	EF" [a1 a2 zerop / -1 2 if < 0 -] 8))

(defun news-find-first-or-last (pfx base dirn) (byte-code "	
	\\!Q!	\"	\"	\"\"L
	#!Q!A	\\\"&)
\"\"g
	#!Q!?sZSU	\\
	##))" [original-dir dirn pfx base offset news-max-plausible-gap file-exists-p "/" int-to-string * 2 / /= 0 + news-find-first-or-last] 21))

(defun rnews nil "\
Read USENET news for groups for which you are a member and add or
delete groups.
You can reply to articles posted and send articles to any group.

Type \\[describe-mode] once reading news to get a list of rnews commands." (interactive) (byte-code "Ĉ !!! ĉ ʼn!!!   )" [last-buffer news-buffer news-buffer-save buffer-read-only nil t buffer-name make-local-variable rmail-last-file switch-to-buffer get-buffer-create "*news*" news-mode erase-buffer set-buffer-modified-p sit-for 0 message "Getting new USENET news..." news-set-mode-line news-get-certifications news-get-new-news] 13))

(defun news-group-certification (group) (byte-code "	\"!" [group news-current-certifications cdr-safe assoc] 4))

(defun news-set-current-certifiable nil (byte-code "	
#P!!8)" [file news-path news-current-news-group news-current-certifiable string-subst-char 47 46 5 file-attributes file-symlink-p] 5))

(defun news-get-certifications nil (byte-code ")" [news-current-certifications ((byte-code "ď!" [news-current-certifications car-safe var (byte-code "	!!!
\"Ȏ !)*" [file news-certification-file buf substitute-in-file-name find-file-noselect file-exists-p switch-to-buffer norecord ((byte-code "!" [buf kill-buffer] 2)) read-from-string buffer-string] 7) ((error (byte-code "" [nil] 1)))] 4))] 1))

(defun news-write-certifications nil (byte-code "Ë)" [news-current-certifications buf news-certification-file ((byte-code "Ð!!	!
!!	!)" [news-current-certifications buf news-certification-file "*CeRtIfIcAtIoNs*" print get-buffer switch-to-buffer write-file substitute-in-file-name kill-buffer] 7))] 1))

(defun news-set-current-group-certification nil (byte-code "	
\"\"	B
B)" [cgc news-current-news-group news-current-certifications news-current-certifiable assoc setcdr] 4))

(defun news-set-minor-modes nil "\
Creates a minor mode list that has group name, total articles,
and attribute for current article." (byte-code "	
 RBC!" [news-minor-modes news-current-message-number news-total-current-group minor-modes foo "/" news-get-attribute-string boundp minor-mode-alist] 6))

(defun news-set-message-counters nil "\
Scan through current news-groups filelist to figure out how many messages
are there. Set counters for use with minor mode display." (byte-code "?‰" [news-list-of-files news-current-message-number 0] 2))

(if news-mode-map nil (setq news-mode-map (make-keymap)) (suppress-keymap news-mode-map) (define-key news-mode-map "." (quote beginning-of-buffer)) (define-key news-mode-map " " (quote scroll-up)) (define-key news-mode-map "" (quote scroll-down)) (define-key news-mode-map "n" (quote news-next-message)) (define-key news-mode-map "c" (quote news-make-link-to-message)) (define-key news-mode-map "p" (quote news-previous-message)) (define-key news-mode-map "j" (quote news-goto-message)) (define-key news-mode-map "q" (quote news-exit)) (define-key news-mode-map "e" (quote news-exit)) (define-key news-mode-map "j" (quote news-goto-news-group)) (define-key news-mode-map "n" (quote news-next-group)) (define-key news-mode-map "p" (quote news-previous-group)) (define-key news-mode-map "l" (quote news-list-news-groups)) (define-key news-mode-map "?" (quote describe-mode)) (define-key news-mode-map "g" (quote news-get-new-news)) (define-key news-mode-map "f" (quote news-reply)) (define-key news-mode-map "m" (quote news-mail-other-window)) (define-key news-mode-map "a" (quote news-post-news)) (define-key news-mode-map "r" (quote news-mail-reply)) (define-key news-mode-map "o" (quote news-save-item-in-file)) (define-key news-mode-map "" (quote rmail-output)) (define-key news-mode-map "t" (quote news-show-all-headers)) (define-key news-mode-map "x" (quote news-force-update)) (define-key news-mode-map "A" (quote news-add-news-group)) (define-key news-mode-map "u" (quote news-unsubscribe-current-group)) (define-key news-mode-map "U" (quote news-unsubscribe-group)) (define-key news-mode-map "" (quote news-caesar-buffer-body)))

(defun news-mode nil "\
News Mode is used by M-x rnews for reading USENET Newsgroups articles.
New readers can find additional help in newsgroup: news.announce.newusers .
All normal editing commands are turned off.
Instead, these commands are available:

.	move point to front of this news article (same as Meta-<).
Space	scroll to next screen of this news article.
Delete  scroll down previous page of this news article.
n	move to next news article, possibly next group.
p	move to previous news article, possibly previous group.
j	jump to news article specified by numeric position.
M-j     jump to news group.
M-n     goto next news group.
M-p     goto previous news group.
l       list all the news groups with current status.
?       print this help message.
C-c C-r caesar rotate all letters by 13 places in the article's body (rot13).
g       get new USENET news.
f       post a reply article to USENET.
a       post an original news article.
A       add a newsgroup. 
o	save the current article in the named file (append if file exists).
C-o	output this message to a Unix-format mail file (append it).
c       \"copy\" (actually link) current or prefix-arg msg to file.
	warning: target directory and message file must be on same device
		(UNIX magic)
t       show all the headers this news article originally had.
q	quit reading news after updating .newsrc file.
e	exit updating .newsrc file.
m	mail a news article.  Same as C-x 4 m.
x       update last message seen to be the current message.
r	mail a reply to this news article.  Like m but initializes some fields.
u       unsubscribe from current newsgroup.
U       unsubscribe from specified newsgroup." (interactive) (byte-code "ˈ !!!ω!ω!!!҉!ԉ!F׉J؉ !!
	!" [news-read-first-time-p t news-current-group-begin news-current-message-number version-control major-mode mode-name text-mode-syntax-table news-mode-map local-abbrev-table text-mode-abbrev-table nil kill-all-local-variables make-local-variable news-current-news-group 0 news-total-current-group news-buffer-save never news-point-pdl news-mode boundp minor-mode-alist ("NEWS" news-minor-modes) "NEWS" news-set-mode-line set-syntax-table use-local-map run-hooks news-mode-hook] 15))

(defun string-subst-char (new old string) (byte-code "	!!
O	
\" 
I)
" [index old string new nil regexp-quote char-to-string 0 string-match] 7))

(defmacro news-update-message-read (ngroup nno) (byte-code "ED	E" [ngroup nno setcar news-cdadr assoc news-group-article-assoc] 5))

(defun news-parse-range (number-string) "\
Parse string representing range of numbers of he form <a>-<b>
to a list (a . b)" (byte-code "	\"	O!	TO!B#	!B)" [n number-string string-match "-" string-to-int 0 nil] 7))

(defun news-get-new-news nil "\
Get new USENET news, if there is any for the current user." (interactive) (byte-code "ˆ??
 ‰‰\"!!
	qb#` ` `	Z\"
	\"!
	\"z
\"

B
@AAED	B)7!-)
!!
!


@\"?
A
?!!*" [news-user-group-list news-group-article-assoc nil news-startup-file file temp-user-groups newsrcbuf start end endofline tem t range news-buffer news-update-newsrc-file message "Looking up %s file..." substitute-in-file-name find-file-noselect 0 search-forward ": " beginning-of-line end-of-line buffer-substring 2 news-parse-range assoc "You are subscribed twice to %s; I ignore second" kill-buffer nreverse "Prefrobnicating..." switch-to-buffer news-read-files-into-buffer "No news is good news." ""] 20))

(defun news-list-news-groups nil "\
Display all the news groups to which you belong." (interactive) (byte-code "Ĉǐqcc
	M	@\"
@c)˂*j
A@A@!c>c@j	A?)*)" [standard-output temp news-user-group-list flag nil item news-group-article-assoc "*Newsgroups*" "News Group        Msg No.       News Group        Msg No.
" "-------------------------       -------------------------
" assoc 52 20 int-to-string "
" 33] 6))

(defun news-set-mode-line nil "\
Set mode line string to something useful." (byte-code "	!
	!
!
!
RGZ]OQ!!" [mode-line-process news-current-message-number news-current-group-end mode-line-buffer-identification news-current-news-group t " " integerp int-to-string "??" "/" "NEWS: " "                 " 0 17 set-buffer-modified-p sit-for] 11))

(defun news-goto-news-group (gp) "\
Takes a string and goes to that news group." (interactive (byte-code "\"C" [news-group-article-assoc completing-read "NewsGroup: "] 3)) (byte-code "ˆ	\"	!	\"" [news-group-article-assoc gp nil message "Jumping to news group %s..." news-select-news-group "Jumping to news group %s... done."] 5))

(defun news-select-news-group (gp) (byte-code "	
\"?\"&
\"A@A
@A\"@\" )" [grp gp news-group-article-assoc news-startup-file news-current-news-group news-point-pdl nil assoc error "Group not subscribed to in file %s." setcar news-read-files-into-buffer news-set-mode-line] 7))

(defun news-goto-message (arg) "\
Goes to the article ARG in current newsgroup." (interactive "p") (byte-code "ˆ?
\"	!" [current-prefix-arg arg nil read-no-blanks-input "Go to article: " "" news-select-message] 3))

(defun news-select-message (arg) (byte-code ";
!
#R	!E@A>A@+U5@\"	! )I\")" [arg file news-path news-current-news-group buffer-read-only nil news-point-pdl news-list-of-files news-current-message-number string-to-int string-subst-char 47 46 "/" file-exists-p 0 setcdr news-read-in-file news-set-mode-line error "Article %d nonexistent"] 9))

(defun news-force-update nil "\
updates the position of last article read in the current news group" (interactive) (byte-code "ˆ@	\"	\"" [news-point-pdl news-current-message-number nil setcdr message "Updated to %d"] 4))

(defun news-next-message (arg) "\
Move ARG messages forward within one newsgroup.
Negative ARG moves backward.
If ARG is 1 or -1, moves to next or previous newsgroup if at end." (interactive "p") (byte-code "Ȉ	
\\WV1	U   .	U+ .!T
\"	WK	[SA@8!S	S@8!))" [no arg news-current-message-number news-current-group-begin news-current-group-end t plist news-list-of-files nil 1 news-set-current-group-certification news-next-group -1 news-previous-group error "Article out of range" news-get-motion-lists 0 news-select-message] 9))

(defun news-previous-message (arg) "\
Move ARG messages backward in current newsgroup.
With no arg or arg of 1, move one message
and move to previous newsgroup if at beginning.
A negative ARG means move forward." (interactive "p") (byte-code "[!" [arg nil news-next-message] 2))

(defun news-move-to-group (arg) "\
Given arg move forward or backward to a new newsgroup." (byte-code "	\"
W!
[S
A@8!-
@8-!!*)" [cg news-current-news-group plist news-user-group-list ngrp arg news-get-motion-lists nil 0 error "No previous news groups" "No more news groups" news-select-news-group] 5))

(defun news-next-group nil "\
Moves to the next user group." (interactive) (byte-code "!?!" [news-list-of-files nil news-move-to-group 0] 4))

(defun news-previous-group nil "\
Moves to the previous user group." (interactive) (byte-code "!?!" [news-list-of-files nil news-move-to-group -1] 4))

(defun news-get-motion-lists (arg listy) "\
Given a msgnumber/group this will return a list of two lists;
one for moving forward and one for moving backward." (byte-code "	ō*" [temp listy result nil out (byte-code "(@	\"A
CB\"$@C
\"A" [temp arg result equal throw out nconc] 6)] 2))

(defun news-read-in-file (filename) (byte-code " `	! b!m!b)" [start filename erase-buffer insert-file-contents news-convert-format forward-line 1 message "(Empty file?)"] 6))

(defun news-convert-format nil (byte-code "`Ǐ	@	\"b#
?'9b!   !b,))" [start end has-from has-date nil t (byte-code "!`" [search-forward "

"] 2) ((error (byte-code "" [nil] 1))) narrow-to-region search-forward "
From:" "
Date:" beginning-of-line kill-line news-delete-headers] 8))

(defun news-show-all-headers nil "\
Redisplay current news item with all original headers" (interactive) (byte-code "ˆ  #
!R!*" [news-ignored-headers buffer-read-only nil news-path news-current-news-group news-current-message-number erase-buffer news-set-mode-line news-read-in-file string-subst-char 47 46 "/" int-to-string] 9))

(defun news-delete-headers (pos) (byte-code "b	;#	## `!!`\"" [pos news-ignored-headers nil t re-search-forward beginning-of-line delete-region "
[^ 	]" forward-char -1] 8))

(defun news-exit nil "\
Quit news reading session and update the .newsrc file." (interactive) (byte-code "È!0\"  \"!!%p!	!É3!" [news-startup-file news-buffer-save news-user-group-list nil y-or-n-p "Do you really wanna quit reading news ? " message "Updating %s..." news-update-newsrc-file news-write-certifications "Updating %s... done" "Now do some real work" fboundp bury-buffer switch-to-buffer ""] 11))

(defun news-update-newsrc-file nil "\
Updates the .newsrc file in the users home dir." (byte-code "	!!
??
\"A@A@A\"!
{
@\"A@A@A@AA@UDȂrb@P#X!a@\"!A@@!A@A@!#
A$

@\"b@P#!!A@@!A@A@!$
A
| p!)+" [newsrcbuf news-startup-file tem news-user-group-list group news-current-news-group news-group-article-assoc news-point-pdl nil t news-unsubscribe-groups find-file-noselect substitute-in-file-name setcar assoc switch-to-buffer 0 search-forward ": " kill-line insert ": 
" backward-char 1 int-to-string "-" 2 "! " save-buffer kill-buffer] 25))

(defun news-unsubscribe-group (group) "\
Removes you from newgroup GROUP." (interactive (byte-code "\"C" [news-group-article-assoc completing-read "Unsubscribe from group: "] 3)) (byte-code "ˆ	!" [news-group-article-assoc group nil news-unsubscribe-internal] 2))

(defun news-unsubscribe-current-group nil "\
Removes you from the newsgroup you are now reading." (interactive) (byte-code "!!" [news-current-news-group nil y-or-n-p "Do you really want to unsubscribe from this group ? " news-unsubscribe-internal] 3))

(defun news-unsubscribe-internal (group) (byte-code "	
\",	B	
\"A@A@A\"	
\"% !0	\")" [tem group news-group-article-assoc news-unsubscribe-groups news-point-pdl news-current-news-group assoc setcar equal news-next-group message "" error "Not subscribed to group: %s"] 9))

(defun news-save-item-in-file (file) "\
Save the current article that is being read by appending to a file." (interactive "FSave item in file: ") (byte-code "ed#" [file nil append-to-file] 4))

(defun news-get-pruned-list-of-files (gp-list end-file-no) "\
Given a news group it finds all files in the news group.
The arg must be in slashified format.
Using ls was found to be too slow in a previous version." (byte-code "	 
!\"Ɖ?
#P		:	!Q!:	#
ĉ
l

	Vg
B
S
O!?y!?Ăۏ			@\"?	@Q!	@!	X	@\"	A	?Ă\"\"GS\"+ )" [answer end-file-no gp-list news-list-of-files nil news-list-of-files-possibly-bogus t file-directory news-path tem last-winner news-current-group-end equal news-set-current-certifiable news-group-certification string-subst-char 47 46 file-exists-p "/" int-to-string news-find-first-or-last 1 file-directory-p file-readable-p error (byte-code "!" [file-directory directory-files] 2) ((file-error (byte-code "8\"	\"A\"‡" [error gp-list nil string= 2 "permission denied" message "Newsgroup %s is read-protected" signal file-error] 5))) string-match "^[0-9]*$" string-to-int delq 0 mapcar sort < elt news-set-current-group-certification] 18))

(defun news-read-files-into-buffer (group reversep) (byte-code "	
\"A@@A@	ƉƉ	 	\" @A@BC
?T 	 Ƃ@
h	~@Vx
@@\"  	#!R!  ," [files-start-end group news-group-article-assoc start-file-no end-file-no buffer-read-only nil news-current-news-group news-current-message-number news-current-group-end news-point-pdl news-list-of-files news-current-group-begin reversep news-path t assoc news-set-mode-line news-get-pruned-list-of-files erase-buffer setcdr news-set-message-counters news-read-in-file string-subst-char 47 46 "/" int-to-string] 16))

(defun news-add-news-group (gp) "\
Resubscribe to or add a USENET news group named GROUP (a string)." (interactive "sAdd news group: ") (byte-code "ƈ	
#P
\"?
!!!!b
P#B
\"!!cN
\" 
\"
#
	#`	 ` `
	Z\"	
\"!@AAEDB), p!
\")
\"))" [file-dir news-path gp news-group-article-assoc newsrcbuf news-startup-file nil t start end endofline tem range string-subst-char 47 46 assoc find-file-noselect substitute-in-file-name file-directory-p switch-to-buffer 0 search-forward "! " message "Re-subscribing to group %s." backward-char 2 delete-char 1 ":" "Added %s to your list of newsgroups." end-of-buffer insert ": 1-1
" search-backward ": " beginning-of-line end-of-line buffer-substring news-parse-range save-buffer kill-buffer "Newsgroup %s doesn't exist." "Already subscribed to group %s."] 26))

(defun news-make-link-to-message (number newname) "\
Forges a link to an rnews message numbered number (current if no arg)
Good for hanging on to a message that might or might not be
automatically deleted." (interactive "P
FName to link to message: ") (byte-code "ň	#

!R\"" [news-path news-current-news-group number news-current-message-number newname nil add-name-to-file string-subst-char 47 46 "/" prefix-numeric-value] 7))

(defun caesar-region (&optional n) "\
Caesar rotation of region by N, default 13, for decrypting netnews." (interactive (byte-code "!C
C" [current-prefix-arg nil prefix-numeric-value] 2)) (byte-code "
!?͉'
W!
[\"Z'
\"
!?!?>H
\\\"!\"
Wg

I
TTP!Ή
W
\\
\\HI
\\
\\HI
Ty!+  
		\"

G
W



HHI
Tb	\"
c-" [current-prefix-arg nil n t caesar-translate-table i lower upper from to str len numberp 13 0 26 % zerop boundp /= 97 "abcdefghijklmnopqrstuvwxyz" message "Building caesar-translate-table..." make-vector 256 upcase 65 "Building caesar-translate-table... done" region-beginning region-end buffer-substring kill-region] 19))

(defun news-caesar-buffer-body (&optional rotnum) "\
Caesar rotates all letters in the current buffer by 13 places.
Used to encode/decode possibly offensive messages (commonly in net.jokes).
With prefix arg, specifies the number of places to rotate each letter forward.
Mail and USENET news headers are not rotated." (interactive (byte-code "!C
C" [current-prefix-arg nil prefix-numeric-value] 2)) (byte-code "eb\"͂
Q#'`(e!db!
))" [current-prefix-arg nil buffer-status buffer-read-only major-mode mail-header-separator t rotnum set-mark search-forward "
" equal news-mode "" caesar-region] 6))