4.3BSD/usr/contrib/emacs/lisp/rnews.elc


(require (quote mail-utils))

(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.:\\|^Followup-To:\\|^Expires:\\|^Date-Received:\\|^Organization:\\|^References:\\|^Control:\\|^Xref:\\|^Lines:\\|^Posted:\\|^Relay-Version:\\|^Message-ID:\\|^Nf-ID:" "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 grop 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 caar (x) (byte-code "DD" [x car] 3))

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

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

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

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

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

(defmacro 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 // (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!	\"	\"	\"\"P
	#!Q!D	\\Eψ\"&)
\"\"k
	#!Q!?wZWU	\\
	##))" [original-dir dirn pfx base offset news-max-plausible-gap file-exists-p "/" int-to-string * 2 / /= 0 + nil news-find-first-or-last] 21))

(defun rnews nil "\
Read netnews 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 Help m once reading news to get a list of rnews commands." (interactive) (byte-code "Ĉ !!  

!!!   )" [last-buffer news-buffer news-buffer-save buffer-read-only nil t buffer-name switch-to-buffer get-buffer-create "*news*" news-mode erase-buffer set-buffer-modified-p sit-for 0 message "Getting new net news..." news-set-mode-line news-get-certifications news-get-new-news] 12))

(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 var file news-certification-file buf nil ((byte-code "ȏ!" [news-current-certifications var file news-certification-file buf nil car-safe (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" [minor-modes news-current-message-number news-total-current-group foo "/" news-get-attribute-string] 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 nil] 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 "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)))

(defun news-mode nil "\
News Mode is used by M-x rnews for editing News files.
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.
g       get new net news.
f       post follow-up article to the net.
a       post a news article.
A       add a newsgroup. 
o	save the current article in the named file (append if file exists).
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	reply to this news article.  Like m but initializes some fields.
u       unsubscribe from current newsgroup.
U       unsubscribe from specified newsgroup." (interactive) (byte-code "ˈ !	!!ω!ω!!!҉!ԉՉ !!
	!" [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 "NEWS" news-set-mode-line set-syntax-table use-local-map run-hooks news-mode-hook] 14))

(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 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 netnews if there is any for the current user." (interactive) (byte-code "ˆ??
 ˆ

!!
!
	qb
#` ` `	Z\"
	\"!

B
@AAED	B):!-)
!!
!


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

(defun news-list-news-groups nil "\
Display all the news groups to which you belong." (interactive) (byte-code "ˆ?
!t
ʉ\"\"\"b cc
q@\"@c
LׂMjA@A@!c
bcdjA
?)3*))" [news-user-group-list buffer-read-only nil mode-line-format temp flag item news-group-article-assoc message "No user groups read yet!" "--%%--[q: to goback, space: scroll-forward, delete:scroll-backward] %M --%--" local-set-key " " scroll-up "" scroll-down "q" news-get-back 0 erase-buffer "News Group        Msg No.       News Group        Msg No.
" "-------------------------       -------------------------
" assoc 52 20 int-to-string "
" 33] 10))

(defun news-get-back nil "\
Called when you quit from seeing the news groups list." (interactive) (byte-code "	 \" 
#!R!)" [buffer-read-only nil news-path news-current-news-group news-current-message-number erase-buffer local-set-key "q" news-exit news-set-mode-line news-read-in-file string-subst-char 47 46 "/" int-to-string] 10))

(defun strcpyn (str1 str2 len) (byte-code "\"	\"
Y 	

HI
S	" [str2 str1 len string= "" 0] 6))

(defun news-set-mode-line nil "\
Set mode line string to something useful." (byte-code "	GSV	8\"ʉ
X4
	
HI
T)!G!H!W!Y&	!!+" [tem news-current-news-group idx buffer-modified-p nil mode-line-format string news-current-message-number news-current-group-end t 0 concat "--%1*%1*-NEWS: " 15 make-string 16 32 " [" integerp int-to-string "??" "/" "] %M ----%3p-%-" set-buffer-modified-p sit-for] 13))

(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-current-news-group news-point-pdl nil assoc error "No more news groups" 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	!M
@A>A@/U<@\"=ň	! )Q\")" [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VN	U,  
?) K	UC 
?@ 5KK!p

\"	Wg	[SA@8!o	S@8!))" [no arg news-current-message-number news-current-group-begin news-current-group-end news-list-of-files t plist 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] 11))

(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 more news groups" "No previous news groups" news-select-news-group] 5))

(defun news-next-group nil "\
Moves to the next user group." (interactive) (byte-code "!" [nil news-move-to-group 0] 2))

(defun news-previous-group nil "\
Moves to the previous user group." (interactive) (byte-code "!" [nil news-move-to-group -1] 2))

(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 arg 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 nil has-from has-date 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 " )" [news-ignored-headers nil news-get-back] 2))

(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 "ˆ!.!  !!!#p!!
1!" [news-buffer-save news-user-group-list nil y-or-n-p "Do you really wanna quit reading news ? " message "Updating .newsrc..." news-update-newsrc-file news-write-certifications "Updating .newsrc... 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@UIzb@P	#`!i@\"!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 "	
\"1	B	
\"A@A@A\"	
\"( )ʈ	\"5	\")" [tem group news-group-article-assoc news-unsubscribe-groups news-point-pdl news-current-news-group assoc setcar equal news-next-group nil message "Member-p of %s ==> nil" error "No such 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 does an ls to give all files in the news group.
The arg must be in slashified format." (byte-code "	 
!\"?
#P		;	!Q!;	#

o

	Vj
B
S
R!?{!			@\"?	@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 directory-files 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
?X 	 @
l	@V
@@\"ƈ  	#!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))

(defvar news-reply-mode-map nil "Mode map used by news-reply.")

(or news-reply-mode-map (progn (setq news-reply-mode-map (make-keymap)) (define-key news-reply-mode-map "?" (quote describe-mode)) (define-key news-reply-mode-map "t" (quote mail-to)) (define-key news-reply-mode-map "b" (quote mail-bcc)) (define-key news-reply-mode-map "c" (quote mail-cc)) (define-key news-reply-mode-map "s" (quote mail-subject)) (define-key news-reply-mode-map "y" (quote mail-yank-original)) (define-key news-reply-mode-map "" (quote news-inews)) (define-key news-reply-mode-map "" (quote news-inews))))

(defun news-reply-mode nil "\
Major mode for editing news to be posted on netnews.
Like Text Mode but with these additional commands:
\\{news-reply-mode-map}" (interactive) (byte-code "!! !	
!!
Ӊԉ!!	R	
R
\"" [mail-reply-buffer nil text-mode-syntax-table news-reply-mode-map local-abbrev-table text-mode-abbrev-table major-mode mode-name paragraph-start mail-header-separator paragraph-separate fboundp mail-setup load "sendmail" kill-all-local-variables make-local-variable set-syntax-table use-local-map news-reply-mode "News" "^" "$\\|" run-hooks text-mode-hook news-reply-mode-hook] 12))

(defun news-setup (to subject in-reply-to newsgroups replybuffer) (byte-code "	?'	% !db*0	%db
	e
#)a M#?\\!^dbbÈ!)" [mail-reply-buffer replybuffer mail-setup-hook nil to mail-self-blind mail-archive-file-name subject in-reply-to case-fold-search t newsgroups mail-setup beginning-of-line kill-line 1 re-search-backward "^Subject:" insert "Newsgroups: " "" "
" backward-char run-hooks news-setup-hook] 10))

(defun news-inews nil "\
Send a news message using inews." (interactive) (byte-code "ÈebQ!e`\"!!) ebQ!!`d
	&
!!p!!Wp!+" [newsgroups subject case-fold-search nil mail-header-separator news-inews-program search-forward "
" narrow-to-region mail-fetch-field "newsgroups" "subject" widen message "Posting to the net..." call-process-region 0 "-t" "-n" "Posting to the net... done" set-buffer-modified-p delete-windows-on fboundp bury-buffer] 18))

(defun news-mail-reply nil "\
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." (interactive) (byte-code "Ljpee!!`Z\"!!!!!
F
G
\"[O\\Q)&)." [from cc subject date to reply-to buffer nil stop-pos narrow-to-region goto-line search-forward "

" 2 mail-fetch-field "from" "subject" "reply-to" "date" pop-to-buffer "*mail*" mail string-match "  *at \\|  *@ \\| *(\\| *<" 0 "'s message of "] 16))

(defun news-reply nil "\
Compose and send a reply to the current article to the net.
While composing the reply, use \\[mail-yank-original] to yank the original message into it." (interactive) (byte-code "Lj!epe!`Z\"!!!!!  
\"VOWQ)
%).h!" [from cc subject date to newsgroups buffer nil stop-pos y-or-n-p "Are you sure you want to reply to the net? " narrow-to-region search-forward "

" 2 mail-fetch-field "from" "subject" "date" "newsgroups" pop-to-buffer "*post-news*" news-reply-mode erase-buffer news-setup string-match "  *at \\|  *@ \\| *(\\| *<" 0 "'s message of " message ""] 17))

(defun news-post-news nil "\
Begin editing a news article to be posted." (interactive) (byte-code "!  %" [nil pop-to-buffer "*post-news*" news-reply-mode erase-buffer news-setup] 9))

(defun news-add-news-group (gp) "\
Add you to news group named GROUP (a string)." (interactive "sAdd news group: ") (byte-code "ƈ	
#P
\"?E
!!!=! 
#\" p!
\"A
\")I
\"))" [file-dir news-path gp news-group-article-assoc newsrcbuf news-startup-file nil string-subst-char 47 46 assoc find-file-noselect substitute-in-file-name file-directory-p switch-to-buffer end-of-buffer insert 32 ": 1-1
" save-buffer kill-buffer message "Added %s to your current list of newsgroups." "Newsgroup %s doesn't exist." "Already subscribed to group %s."] 16))

(defun news-mail-other-window nil "\
Send mail in another window.
While composing the message, use \\[mail-yank-original] to yank the
original message into it." (interactive) (byte-code "p&" [nil mail-other-window] 7))

(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))