annotate lisp/mail/rnews.el @ 34373:93a6ef17b7f3

(texinfo-chapter-level-regexp) (texinfo-filter): Removed (moved to texinfo.el).
author Stefan Monnier <monnier@iro.umontreal.ca>
date Fri, 08 Dec 2000 16:35:04 +0000
parents 03d8424273d3
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
658
7cbd4fcd8b0f *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 584
diff changeset
1 ;;; rnews.el --- USENET news reader for gnu emacs
7cbd4fcd8b0f *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 584
diff changeset
2
845
213978acbc1e entered into RCS
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 814
diff changeset
3 ;; Copyright (C) 1985, 1986, 1987 Free Software Foundation, Inc.
213978acbc1e entered into RCS
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 814
diff changeset
4
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 658
diff changeset
5 ;; Maintainer: FSF
814
38b2499cb3e9 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 807
diff changeset
6 ;; Keywords: news
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 658
diff changeset
7
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
9
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 658
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
13 ;; any later version.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
14
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
18 ;; GNU General Public License for more details.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
19
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
23 ;; Boston, MA 02111-1307, USA.
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
24
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 658
diff changeset
25 ;;; Change Log:
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 658
diff changeset
26
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
27 ;; Created Sun Mar 10,1985 at 21:35:01 ads and sundar@hernes.ai.mit.edu
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
28 ;; Should do the point pdl stuff sometime
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
29 ;; finito except pdl.... Sat Mar 16,1985 at 06:43:44
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
30 ;; lets keep the summary stuff out until we get it working ..
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
31 ;; sundar@hermes.ai.mit.edu Wed Apr 10,1985 at 16:32:06
25276
a0a1a3da1af4 Fix maintainer address.
Karl Heuer <kwzh@gnu.org>
parents: 21863
diff changeset
32 ;; hack slash maim. mly@gnu.org Thu 18 Apr, 1985 06:11:14
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
33 ;; modified to correct reentrance bug, to not bother with groups that
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
34 ;; received no new traffic since last read completely, to find out
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
35 ;; what traffic a group has available much more quickly when
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
36 ;; possible, to do some completing reads for group names - should
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
37 ;; be much faster...
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
38 ;; KING@KESTREL.arpa, Thu Mar 13 09:03:28 1986
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
39 ;; made news-{next,previous}-group skip groups with no new messages; and
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
40 ;; added checking for unsubscribed groups to news-add-news-group
25276
a0a1a3da1af4 Fix maintainer address.
Karl Heuer <kwzh@gnu.org>
parents: 21863
diff changeset
41 ;; tower@gnu.org Jul 18 1986
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
42 ;; bound rmail-output to C-o; and changed header-field commands binding to
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
43 ;; agree with the new C-c C-f usage in sendmail
25278
cbe304a26771 Fix maintainer address.
Karl Heuer <kwzh@gnu.org>
parents: 25276
diff changeset
44 ;; tower@gnu.org Sep 3 1986
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
45 ;; added news-rotate-buffer-body
25278
cbe304a26771 Fix maintainer address.
Karl Heuer <kwzh@gnu.org>
parents: 25276
diff changeset
46 ;; tower@gnu.org Oct 17 1986
14040
187735b53d52 Comment fixes.
Karl Heuer <kwzh@gnu.org>
parents: 8576
diff changeset
47 ;; made messages more user friendly, cleaned up news-inews
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
48 ;; move posting and mail code to new file rnewpost.el
25278
cbe304a26771 Fix maintainer address.
Karl Heuer <kwzh@gnu.org>
parents: 25276
diff changeset
49 ;; tower@gnu.org Oct 29 1986
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
50 ;; added caesar-region, rename news-caesar-buffer-body, hacked accordingly
25278
cbe304a26771 Fix maintainer address.
Karl Heuer <kwzh@gnu.org>
parents: 25276
diff changeset
51 ;; tower@gnu.org Nov 21 1986
cbe304a26771 Fix maintainer address.
Karl Heuer <kwzh@gnu.org>
parents: 25276
diff changeset
52 ;; added tower@gnu.org 22 Apr 87
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 658
diff changeset
53
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 658
diff changeset
54 ;;; Code:
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 658
diff changeset
55
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
56 (require 'mail-utils)
21863
d84de2f4c38d Require sendmail.
Richard M. Stallman <rms@gnu.org>
parents: 21099
diff changeset
57 (require 'sendmail)
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
58
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
59 (autoload 'rmail-output "rmailout"
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
60 "Append this message to Unix mail file named FILE-NAME."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
61 t)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
62
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
63 (autoload 'news-reply "rnewspost"
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
64 "Compose and post a reply to the current article on USENET.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
65 While composing the reply, use \\[mail-yank-original] to yank the original
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
66 message into it."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
67 t)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
68
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
69 (autoload 'news-mail-other-window "rnewspost"
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
70 "Send mail in another window.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
71 While composing the message, use \\[mail-yank-original] to yank the
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
72 original message into it."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
73 t)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
74
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
75 (autoload 'news-post-news "rnewspost"
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
76 "Begin editing a new USENET news article to be posted."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
77 t)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
78
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
79 (autoload 'news-mail-reply "rnewspost"
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
80 "Mail a reply to the author of the current article.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
81 While composing the reply, use \\[mail-yank-original] to yank the original
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
82 message into it."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
83 t)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
84
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
85 (defvar news-group-hook-alist nil
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
86 "Alist of (GROUP-REGEXP . HOOK) pairs.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
87 Just before displaying a message, each HOOK is called
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
88 if its GROUP-REGEXP matches the current newsgroup name.")
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
89
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
90 (defvar rmail-last-file (expand-file-name "~/mbox.news"))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
91
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
92 ;Now in paths.el.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
93 ;(defvar news-path "/usr/spool/news/"
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
94 ; "The root directory below which all news files are stored.")
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
95
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
96 (defvar news-startup-file "$HOME/.newsrc" "Contains ~/.newsrc")
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
97 (defvar news-certification-file "$HOME/.news-dates" "Contains ~/.news-dates")
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
98
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
99 ;; random headers that we decide to ignore.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
100 (defvar news-ignored-headers
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
101 "^Path:\\|^Posting-Version:\\|^Article-I.D.:\\|^Expires:\\|^Date-Received:\\|^References:\\|^Control:\\|^Xref:\\|^Lines:\\|^Posted:\\|^Relay-Version:\\|^Message-ID:\\|^Nf-ID:\\|^Nf-From:\\|^Approved:\\|^Sender:"
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
102 "All random fields within the header of a message.")
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
103
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
104 (defvar news-mode-map nil)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
105 (defvar news-read-first-time-p t)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
106 ;; Contains the (dotified) news groups of which you are a member.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
107 (defvar news-user-group-list nil)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
108
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
109 (defvar news-current-news-group nil)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
110 (defvar news-current-group-begin nil)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
111 (defvar news-current-group-end nil)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
112 (defvar news-current-certifications nil
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
113 "An assoc list of a group name and the time at which it is
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
114 known that the group had no new traffic")
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
115 (defvar news-current-certifiable nil
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
116 "The time when the directory we are now working on was written")
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
117
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
118 (defvar news-message-filter nil
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
119 "User specifiable filter function that will be called during
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
120 formatting of the news file")
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
121
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
122 ;(defvar news-mode-group-string "Starting-Up"
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
123 ; "Mode line group name info is held in this variable")
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
124 (defvar news-list-of-files nil
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
125 "Global variable in which we store the list of files
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
126 associated with the current newsgroup")
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
127 (defvar news-list-of-files-possibly-bogus nil
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
128 "variable indicating we only are guessing at which files are available.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
129 Not currently used.")
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
130
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
131 ;; association list in which we store lists of the form
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
132 ;; (pointified-group-name (first last old-last))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
133 (defvar news-group-article-assoc nil)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
134
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
135 (defvar news-current-message-number 0 "Displayed Article Number")
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
136 (defvar news-total-current-group 0 "Total no of messages in group")
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
137
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
138 (defvar news-unsubscribe-groups ())
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
139 (defvar news-point-pdl () "List of visited news messages.")
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
140 (defvar news-no-jumps-p t)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
141 (defvar news-buffer () "Buffer into which news files are read.")
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
142
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
143 (defmacro news-push (item ref)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
144 (list 'setq ref (list 'cons item ref)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
145
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
146 (defmacro news-cadr (x) (list 'car (list 'cdr x)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
147 (defmacro news-cdar (x) (list 'cdr (list 'car x)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
148 (defmacro news-caddr (x) (list 'car (list 'cdr (list 'cdr x))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
149 (defmacro news-cadar (x) (list 'car (list 'cdr (list 'car x))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
150 (defmacro news-caadr (x) (list 'car (list 'car (list 'cdr x))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
151 (defmacro news-cdadr (x) (list 'cdr (list 'car (list 'cdr x))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
152
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
153 (defmacro news-wins (pfx index)
26455
03d8424273d3 Use new backquote syntax.
Gerd Moellmann <gerd@gnu.org>
parents: 25278
diff changeset
154 `(file-exists-p (concat ,pfx "/" (int-to-string ,index))))
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
155
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
156 (defvar news-max-plausible-gap 2
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
157 "* In an rnews directory, the maximum possible gap size.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
158 A gap is a sequence of missing messages between two messages that exist.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
159 An empty file does not contribute to a gap -- it ends one.")
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
160
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
161 (defun news-find-first-and-last (prefix base)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
162 (and (news-wins prefix base)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
163 (cons (news-find-first-or-last prefix base -1)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
164 (news-find-first-or-last prefix base 1))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
165
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
166 (defmacro news-/ (a1 a2)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
167 ;; a form of / that guarantees that (/ -1 2) = 0
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
168 (if (zerop (/ -1 2))
26455
03d8424273d3 Use new backquote syntax.
Gerd Moellmann <gerd@gnu.org>
parents: 25278
diff changeset
169 `(/ ,a1 ,a2)
03d8424273d3 Use new backquote syntax.
Gerd Moellmann <gerd@gnu.org>
parents: 25278
diff changeset
170 `(if (< ,a1 0)
03d8424273d3 Use new backquote syntax.
Gerd Moellmann <gerd@gnu.org>
parents: 25278
diff changeset
171 (- (/ (- ,a1) ,a2))
03d8424273d3 Use new backquote syntax.
Gerd Moellmann <gerd@gnu.org>
parents: 25278
diff changeset
172 (/ ,a1 ,a2))))
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
173
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
174 (defun news-find-first-or-last (pfx base dirn)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
175 ;; first use powers of two to find a plausible ceiling
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
176 (let ((original-dir dirn))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
177 (while (news-wins pfx (+ base dirn))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
178 (setq dirn (* dirn 2)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
179 (setq dirn (news-/ dirn 2))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
180 ;; Then use a binary search to find the high water mark
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
181 (let ((offset (news-/ dirn 2)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
182 (while (/= offset 0)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
183 (if (news-wins pfx (+ base dirn offset))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
184 (setq dirn (+ dirn offset)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
185 (setq offset (news-/ offset 2))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
186 ;; If this high-water mark is bogus, recurse.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
187 (let ((offset (* news-max-plausible-gap original-dir)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
188 (while (and (/= offset 0) (not (news-wins pfx (+ base dirn offset))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
189 (setq offset (- offset original-dir)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
190 (if (= offset 0)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
191 (+ base dirn)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
192 (news-find-first-or-last pfx (+ base dirn offset) original-dir)))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
193
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
194 (defun rnews ()
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
195 "Read USENET news for groups for which you are a member and add or
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
196 delete groups.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
197 You can reply to articles posted and send articles to any group.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
198
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
199 Type \\[describe-mode] once reading news to get a list of rnews commands."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
200 (interactive)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
201 (let ((last-buffer (buffer-name)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
202 (make-local-variable 'rmail-last-file)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
203 (switch-to-buffer (setq news-buffer (get-buffer-create "*news*")))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
204 (news-mode)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
205 (setq news-buffer-save last-buffer)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
206 (setq buffer-read-only nil)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
207 (erase-buffer)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
208 (setq buffer-read-only t)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
209 (set-buffer-modified-p t)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
210 (sit-for 0)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
211 (message "Getting new USENET news...")
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
212 (news-set-mode-line)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
213 (news-get-certifications)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
214 (news-get-new-news)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
215
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
216 (defun news-group-certification (group)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
217 (cdr-safe (assoc group news-current-certifications)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
218
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
219
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
220 (defun news-set-current-certifiable ()
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
221 ;; Record the date that corresponds to the directory you are about to check
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
222 (let ((file (concat news-path
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
223 (string-subst-char ?/ ?. news-current-news-group))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
224 (setq news-current-certifiable
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
225 (nth 5 (file-attributes
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
226 (or (file-symlink-p file) file))))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
227
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
228 (defun news-get-certifications ()
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
229 ;; Read the certified-read file from last session
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
230 (save-excursion
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
231 (save-window-excursion
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
232 (setq news-current-certifications
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
233 (car-safe
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
234 (condition-case var
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
235 (let*
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
236 ((file (substitute-in-file-name news-certification-file))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
237 (buf (find-file-noselect file)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
238 (and (file-exists-p file)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
239 (progn
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
240 (switch-to-buffer buf 'norecord)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
241 (unwind-protect
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
242 (read-from-string (buffer-string))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
243 (kill-buffer buf)))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
244 (error nil)))))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
245
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
246 (defun news-write-certifications ()
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
247 ;; Write a certification file.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
248 ;; This is an assoc list of group names with doubletons that represent
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
249 ;; mod times of the directory when group is read completely.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
250 (save-excursion
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
251 (save-window-excursion
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
252 (with-output-to-temp-buffer
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
253 "*CeRtIfIcAtIoNs*"
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
254 (print news-current-certifications))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
255 (let ((buf (get-buffer "*CeRtIfIcAtIoNs*")))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
256 (switch-to-buffer buf)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
257 (write-file (substitute-in-file-name news-certification-file))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
258 (kill-buffer buf)))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
259
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
260 (defun news-set-current-group-certification ()
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
261 (let ((cgc (assoc news-current-news-group news-current-certifications)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
262 (if cgc (setcdr cgc news-current-certifiable)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
263 (news-push (cons news-current-news-group news-current-certifiable)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
264 news-current-certifications))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
265
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
266 (defun news-set-minor-modes ()
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
267 "Creates a minor mode list that has group name, total articles,
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
268 and attribute for current article."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
269 (setq news-minor-modes (list (cons 'foo
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
270 (concat news-current-message-number
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
271 "/"
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
272 news-total-current-group
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
273 (news-get-attribute-string)))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
274 ;; Detect Emacs versions 18.16 and up, which display
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
275 ;; directly from news-minor-modes by using a list for mode-name.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
276 (or (boundp 'minor-mode-alist)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
277 (setq minor-modes news-minor-modes)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
278
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
279 (defun news-set-message-counters ()
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
280 "Scan through current news-groups filelist to figure out how many messages
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
281 are there. Set counters for use with minor mode display."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
282 (if (null news-list-of-files)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
283 (setq news-current-message-number 0)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
284
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
285 (if news-mode-map
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
286 nil
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
287 (setq news-mode-map (make-keymap))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
288 (suppress-keymap news-mode-map)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
289 (define-key news-mode-map "." 'beginning-of-buffer)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
290 (define-key news-mode-map " " 'scroll-up)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
291 (define-key news-mode-map "\177" 'scroll-down)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
292 (define-key news-mode-map "n" 'news-next-message)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
293 (define-key news-mode-map "c" 'news-make-link-to-message)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
294 (define-key news-mode-map "p" 'news-previous-message)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
295 (define-key news-mode-map "j" 'news-goto-message)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
296 (define-key news-mode-map "q" 'news-exit)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
297 (define-key news-mode-map "e" 'news-exit)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
298 (define-key news-mode-map "\ej" 'news-goto-news-group)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
299 (define-key news-mode-map "\en" 'news-next-group)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
300 (define-key news-mode-map "\ep" 'news-previous-group)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
301 (define-key news-mode-map "l" 'news-list-news-groups)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
302 (define-key news-mode-map "?" 'describe-mode)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
303 (define-key news-mode-map "g" 'news-get-new-news)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
304 (define-key news-mode-map "f" 'news-reply)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
305 (define-key news-mode-map "m" 'news-mail-other-window)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
306 (define-key news-mode-map "a" 'news-post-news)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
307 (define-key news-mode-map "r" 'news-mail-reply)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
308 (define-key news-mode-map "o" 'news-save-item-in-file)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
309 (define-key news-mode-map "\C-o" 'rmail-output)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
310 (define-key news-mode-map "t" 'news-show-all-headers)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
311 (define-key news-mode-map "x" 'news-force-update)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
312 (define-key news-mode-map "A" 'news-add-news-group)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
313 (define-key news-mode-map "u" 'news-unsubscribe-current-group)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
314 (define-key news-mode-map "U" 'news-unsubscribe-group)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
315 (define-key news-mode-map "\C-c\C-r" 'news-caesar-buffer-body))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
316
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
317 (defun news-mode ()
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
318 "News Mode is used by M-x rnews for reading USENET Newsgroups articles.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
319 New readers can find additional help in newsgroup: news.announce.newusers .
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
320 All normal editing commands are turned off.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
321 Instead, these commands are available:
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
322
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
323 . move point to front of this news article (same as Meta-<).
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
324 Space scroll to next screen of this news article.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
325 Delete scroll down previous page of this news article.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
326 n move to next news article, possibly next group.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
327 p move to previous news article, possibly previous group.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
328 j jump to news article specified by numeric position.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
329 M-j jump to news group.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
330 M-n goto next news group.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
331 M-p goto previous news group.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
332 l list all the news groups with current status.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
333 ? print this help message.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
334 C-c C-r caesar rotate all letters by 13 places in the article's body (rot13).
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
335 g get new USENET news.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
336 f post a reply article to USENET.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
337 a post an original news article.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
338 A add a newsgroup.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
339 o save the current article in the named file (append if file exists).
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
340 C-o output this message to a Unix-format mail file (append it).
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
341 c \"copy\" (actually link) current or prefix-arg msg to file.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
342 warning: target directory and message file must be on same device
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
343 (UNIX magic)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
344 t show all the headers this news article originally had.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
345 q quit reading news after updating .newsrc file.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
346 e exit updating .newsrc file.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
347 m mail a news article. Same as C-x 4 m.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
348 x update last message seen to be the current message.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
349 r mail a reply to this news article. Like m but initializes some fields.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
350 u unsubscribe from current newsgroup.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
351 U unsubscribe from specified newsgroup."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
352 (interactive)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
353 (kill-all-local-variables)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
354 (make-local-variable 'news-read-first-time-p)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
355 (setq news-read-first-time-p t)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
356 (make-local-variable 'news-current-news-group)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
357 ; (setq news-current-news-group "??")
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
358 (make-local-variable 'news-current-group-begin)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
359 (setq news-current-group-begin 0)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
360 (make-local-variable 'news-current-message-number)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
361 (setq news-current-message-number 0)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
362 (make-local-variable 'news-total-current-group)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
363 (make-local-variable 'news-buffer-save)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
364 (make-local-variable 'version-control)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
365 (setq version-control 'never)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
366 (make-local-variable 'news-point-pdl)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
367 ; This breaks it. I don't have time to figure out why. -- RMS
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
368 ; (make-local-variable 'news-group-article-assoc)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
369 (setq major-mode 'news-mode)
8571
ec740be1ce7b (news-mode): Don't set mode-name to a list.
Richard M. Stallman <rms@gnu.org>
parents: 4515
diff changeset
370 (setq mode-line-process '(news-minor-modes))
ec740be1ce7b (news-mode): Don't set mode-name to a list.
Richard M. Stallman <rms@gnu.org>
parents: 4515
diff changeset
371 (setq mode-name "NEWS")
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
372 (news-set-mode-line)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
373 (set-syntax-table text-mode-syntax-table)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
374 (use-local-map news-mode-map)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
375 (setq local-abbrev-table text-mode-abbrev-table)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
376 (run-hooks 'news-mode-hook))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
377
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
378 (defun string-subst-char (new old string)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
379 (let (index)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
380 (setq old (regexp-quote (char-to-string old))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
381 string (substring string 0))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
382 (while (setq index (string-match old string))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
383 (aset string index new)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
384 string)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
385
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
386 ;; update read message number
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
387 (defmacro news-update-message-read (ngroup nno)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
388 (list 'setcar
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
389 (list 'news-cdadr
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
390 (list 'assoc ngroup 'news-group-article-assoc))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
391 nno))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
392
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
393 (defun news-parse-range (number-string)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
394 "Parse string representing range of numbers of he form <a>-<b>
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
395 to a list (a . b)"
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
396 (let ((n (string-match "-" number-string)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
397 (if n
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
398 (cons (string-to-int (substring number-string 0 n))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
399 (string-to-int (substring number-string (1+ n))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
400 (setq n (string-to-int number-string))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
401 (cons n n))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
402
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
403 ;(defun is-in (elt lis)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
404 ; (catch 'foo
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
405 ; (while lis
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
406 ; (if (equal (car lis) elt)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
407 ; (throw 'foo t)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
408 ; (setq lis (cdr lis))))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
409
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
410 (defun news-get-new-news ()
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
411 "Get new USENET news, if there is any for the current user."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
412 (interactive)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
413 (if (not (null news-user-group-list))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
414 (news-update-newsrc-file))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
415 (setq news-group-article-assoc ())
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
416 (setq news-user-group-list ())
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
417 (message "Looking up %s file..." news-startup-file)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
418 (let ((file (substitute-in-file-name news-startup-file))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
419 (temp-user-groups ()))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
420 (save-excursion
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
421 (let ((newsrcbuf (find-file-noselect file))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
422 start end endofline tem)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
423 (set-buffer newsrcbuf)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
424 (goto-char 0)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
425 (while (search-forward ": " nil t)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
426 (setq end (point))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
427 (beginning-of-line)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
428 (setq start (point))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
429 (end-of-line)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
430 (setq endofline (point))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
431 (setq tem (buffer-substring start (- end 2)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
432 (let ((range (news-parse-range
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
433 (buffer-substring end endofline))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
434 (if (assoc tem news-group-article-assoc)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
435 (message "You are subscribed twice to %s; I ignore second"
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
436 tem)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
437 (setq temp-user-groups (cons tem temp-user-groups)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
438 news-group-article-assoc
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
439 (cons (list tem (list (car range)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
440 (cdr range)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
441 (cdr range)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
442 news-group-article-assoc)))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
443 (kill-buffer newsrcbuf)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
444 (setq temp-user-groups (nreverse temp-user-groups))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
445 (message "Prefrobnicating...")
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
446 (switch-to-buffer news-buffer)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
447 (setq news-user-group-list temp-user-groups)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
448 (while (and temp-user-groups
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
449 (not (news-read-files-into-buffer
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
450 (car temp-user-groups) nil)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
451 (setq temp-user-groups (cdr temp-user-groups)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
452 (if (null temp-user-groups)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
453 (message "No news is good news.")
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
454 (message ""))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
455
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
456 (defun news-list-news-groups ()
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
457 "Display all the news groups to which you belong."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
458 (interactive)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
459 (with-output-to-temp-buffer "*Newsgroups*"
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
460 (save-excursion
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
461 (set-buffer standard-output)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
462 (insert
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
463 "News Group Msg No. News Group Msg No.\n")
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
464 (insert
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
465 "------------------------- -------------------------\n")
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
466 (let ((temp news-user-group-list)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
467 (flag nil))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
468 (while temp
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
469 (let ((item (assoc (car temp) news-group-article-assoc)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
470 (insert (car item))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
471 (indent-to (if flag 52 20))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
472 (insert (int-to-string (news-cadr (news-cadr item))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
473 (if flag
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
474 (insert "\n")
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
475 (indent-to 33))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
476 (setq temp (cdr temp) flag (not flag))))))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
477
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
478 ;; Mode line hack
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
479 (defun news-set-mode-line ()
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
480 "Set mode line string to something useful."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
481 (setq mode-line-process
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
482 (concat " "
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
483 (if (integerp news-current-message-number)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
484 (int-to-string news-current-message-number)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
485 "??")
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
486 "/"
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
487 (if (integerp news-current-group-end)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
488 (int-to-string news-current-group-end)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
489 news-current-group-end)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
490 (setq mode-line-buffer-identification
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
491 (concat "NEWS: "
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
492 news-current-news-group
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
493 ;; Enough spaces to pad group name to 17 positions.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
494 (substring " "
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
495 0 (max 0 (- 17 (length news-current-news-group))))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
496 (set-buffer-modified-p t)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
497 (sit-for 0))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
498
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
499 (defun news-goto-news-group (gp)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
500 "Takes a string and goes to that news group."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
501 (interactive (list (completing-read "NewsGroup: "
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
502 news-group-article-assoc)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
503 (message "Jumping to news group %s..." gp)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
504 (news-select-news-group gp)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
505 (message "Jumping to news group %s... done." gp))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
506
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
507 (defun news-select-news-group (gp)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
508 (let ((grp (assoc gp news-group-article-assoc)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
509 (if (null grp)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
510 (error "Group %s not subscribed to" gp)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
511 (progn
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
512 (news-update-message-read news-current-news-group
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
513 (news-cdar news-point-pdl))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
514 (news-read-files-into-buffer (car grp) nil)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
515 (news-set-mode-line)))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
516
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
517 (defun news-goto-message (arg)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
518 "Goes to the article ARG in current newsgroup."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
519 (interactive "p")
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
520 (if (null current-prefix-arg)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
521 (setq arg (read-no-blanks-input "Go to article: " "")))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
522 (news-select-message arg))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
523
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
524 (defun news-select-message (arg)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
525 (if (stringp arg) (setq arg (string-to-int arg)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
526 (let ((file (concat news-path
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
527 (string-subst-char ?/ ?. news-current-news-group)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
528 "/" arg)))
8576
3e97c809ace1 (news-select-message): Do most of the work
Richard M. Stallman <rms@gnu.org>
parents: 8571
diff changeset
529 (if (= arg
3e97c809ace1 (news-select-message): Do most of the work
Richard M. Stallman <rms@gnu.org>
parents: 8571
diff changeset
530 (or (news-cadr (memq (news-cdar news-point-pdl) news-list-of-files))
3e97c809ace1 (news-select-message): Do most of the work
Richard M. Stallman <rms@gnu.org>
parents: 8571
diff changeset
531 0))
3e97c809ace1 (news-select-message): Do most of the work
Richard M. Stallman <rms@gnu.org>
parents: 8571
diff changeset
532 (setcdr (car news-point-pdl) arg))
3e97c809ace1 (news-select-message): Do most of the work
Richard M. Stallman <rms@gnu.org>
parents: 8571
diff changeset
533 (setq news-current-message-number arg)
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
534 (if (file-exists-p file)
8576
3e97c809ace1 (news-select-message): Do most of the work
Richard M. Stallman <rms@gnu.org>
parents: 8571
diff changeset
535 (let ((buffer-read-only nil))
3e97c809ace1 (news-select-message): Do most of the work
Richard M. Stallman <rms@gnu.org>
parents: 8571
diff changeset
536 (news-read-in-file file)
3e97c809ace1 (news-select-message): Do most of the work
Richard M. Stallman <rms@gnu.org>
parents: 8571
diff changeset
537 (news-set-mode-line))
3e97c809ace1 (news-select-message): Do most of the work
Richard M. Stallman <rms@gnu.org>
parents: 8571
diff changeset
538 (news-set-mode-line)
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
539 (error "Article %d nonexistent" arg))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
540
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
541 (defun news-force-update ()
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
542 "updates the position of last article read in the current news group"
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
543 (interactive)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
544 (setcdr (car news-point-pdl) news-current-message-number)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
545 (message "Updated to %d" news-current-message-number))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
546
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
547 (defun news-next-message (arg)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
548 "Move ARG messages forward within one newsgroup.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
549 Negative ARG moves backward.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
550 If ARG is 1 or -1, moves to next or previous newsgroup if at end."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
551 (interactive "p")
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
552 (let ((no (+ arg news-current-message-number)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
553 (if (or (< no news-current-group-begin)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
554 (> no news-current-group-end))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
555 (cond ((= arg 1)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
556 (news-set-current-group-certification)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
557 (news-next-group))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
558 ((= arg -1)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
559 (news-previous-group))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
560 (t (error "Article out of range")))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
561 (let ((plist (news-get-motion-lists
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
562 news-current-message-number
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
563 news-list-of-files)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
564 (if (< arg 0)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
565 (news-select-message (nth (1- (- arg)) (car (cdr plist))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
566 (news-select-message (nth (1- arg) (car plist))))))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
567
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
568 (defun news-previous-message (arg)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
569 "Move ARG messages backward in current newsgroup.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
570 With no arg or arg of 1, move one message
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
571 and move to previous newsgroup if at beginning.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
572 A negative ARG means move forward."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
573 (interactive "p")
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
574 (news-next-message (- arg)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
575
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
576 (defun news-move-to-group (arg)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
577 "Given arg move forward or backward to a new newsgroup."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
578 (let ((cg news-current-news-group))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
579 (let ((plist (news-get-motion-lists cg news-user-group-list))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
580 ngrp)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
581 (if (< arg 0)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
582 (or (setq ngrp (nth (1- (- arg)) (news-cadr plist)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
583 (error "No previous news groups"))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
584 (or (setq ngrp (nth arg (car plist)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
585 (error "No more news groups")))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
586 (news-select-news-group ngrp))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
587
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
588 (defun news-next-group ()
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
589 "Moves to the next user group."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
590 (interactive)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
591 ; (message "Moving to next group...")
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
592 (news-move-to-group 0)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
593 (while (null news-list-of-files)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
594 (news-move-to-group 0)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
595 ; (message "Moving to next group... done.")
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
596
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
597 (defun news-previous-group ()
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
598 "Moves to the previous user group."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
599 (interactive)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
600 ; (message "Moving to previous group...")
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
601 (news-move-to-group -1)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
602 (while (null news-list-of-files)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
603 (news-move-to-group -1)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
604 ; (message "Moving to previous group... done.")
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
605
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
606 (defun news-get-motion-lists (arg listy)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
607 "Given a msgnumber/group this will return a list of two lists;
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
608 one for moving forward and one for moving backward."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
609 (let ((temp listy)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
610 (result ()))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
611 (catch 'out
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
612 (while temp
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
613 (if (equal (car temp) arg)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
614 (throw 'out (cons (cdr temp) (list result)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
615 (setq result (nconc (list (car temp)) result))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
616 (setq temp (cdr temp)))))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
617
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
618 ;; miscellaneous io routines
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
619 (defun news-read-in-file (filename)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
620 (erase-buffer)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
621 (let ((start (point)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
622 (insert-file-contents filename)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
623 (news-convert-format)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
624 ;; Run each hook that applies to the current newsgroup.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
625 (let ((hooks news-group-hook-alist))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
626 (while hooks
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
627 (goto-char start)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
628 (if (string-match (car (car hooks)) news-group-name)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
629 (funcall (cdr (car hooks))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
630 (setq hooks (cdr hooks))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
631 (goto-char start)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
632 (forward-line 1)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
633 (if (eobp)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
634 (message "(Empty file?)")
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
635 (goto-char start))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
636
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
637 (defun news-convert-format ()
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
638 (save-excursion
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
639 (save-restriction
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
640 (let* ((start (point))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
641 (end (condition-case ()
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
642 (progn (search-forward "\n\n") (point))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
643 (error nil)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
644 has-from has-date)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
645 (cond (end
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
646 (narrow-to-region start end)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
647 (goto-char start)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
648 (setq has-from (search-forward "\nFrom:" nil t))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
649 (cond ((and (not has-from) has-date)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
650 (goto-char start)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
651 (search-forward "\nDate:")
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
652 (beginning-of-line)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
653 (kill-line) (kill-line)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
654 (news-delete-headers start)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
655 (goto-char start)))))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
656
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
657 (defun news-show-all-headers ()
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
658 "Redisplay current news item with all original headers"
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
659 (interactive)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
660 (let (news-ignored-headers
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
661 (buffer-read-only ()))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
662 (erase-buffer)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
663 (news-set-mode-line)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
664 (news-read-in-file
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
665 (concat news-path
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
666 (string-subst-char ?/ ?. news-current-news-group)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
667 "/" (int-to-string news-current-message-number)))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
668
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
669 (defun news-delete-headers (pos)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
670 (goto-char pos)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
671 (and (stringp news-ignored-headers)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
672 (while (re-search-forward news-ignored-headers nil t)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
673 (beginning-of-line)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
674 (delete-region (point)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
675 (progn (re-search-forward "\n[^ \t]")
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
676 (forward-char -1)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
677 (point))))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
678
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
679 (defun news-exit ()
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
680 "Quit news reading session and update the .newsrc file."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
681 (interactive)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
682 (if (y-or-n-p "Do you really wanna quit reading news ? ")
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
683 (progn (message "Updating %s..." news-startup-file)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
684 (news-update-newsrc-file)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
685 (news-write-certifications)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
686 (message "Updating %s... done" news-startup-file)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
687 (message "Now do some real work")
21099
440d5927ef18 (news-exit): Use quit-window.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
688 (quit-window)
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
689 (switch-to-buffer news-buffer-save)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
690 (setq news-user-group-list ()))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
691 (message "")))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
692
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
693 (defun news-update-newsrc-file ()
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
694 "Updates the .newsrc file in the users home dir."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
695 (let ((newsrcbuf (find-file-noselect
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
696 (substitute-in-file-name news-startup-file)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
697 (tem news-user-group-list)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
698 group)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
699 (save-excursion
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
700 (if (not (null news-current-news-group))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
701 (news-update-message-read news-current-news-group
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
702 (news-cdar news-point-pdl)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
703 (set-buffer newsrcbuf)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
704 (while tem
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
705 (setq group (assoc (car tem) news-group-article-assoc))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
706 (if (= (news-cadr (news-cadr group)) (news-caddr (news-cadr group)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
707 nil
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
708 (goto-char 0)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
709 (if (search-forward (concat (car group) ": ") nil t)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
710 (kill-line nil)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
711 (insert (car group) ": \n") (backward-char 1))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
712 (insert (int-to-string (car (news-cadr group))) "-"
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
713 (int-to-string (news-cadr (news-cadr group)))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
714 (setq tem (cdr tem)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
715 (while news-unsubscribe-groups
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
716 (setq group (assoc (car news-unsubscribe-groups)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
717 news-group-article-assoc))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
718 (goto-char 0)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
719 (if (search-forward (concat (car group) ": ") nil t)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
720 (progn
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
721 (backward-char 2)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
722 (kill-line nil)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
723 (insert "! " (int-to-string (car (news-cadr group)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
724 "-" (int-to-string (news-cadr (news-cadr group))))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
725 (setq news-unsubscribe-groups (cdr news-unsubscribe-groups)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
726 (save-buffer)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
727 (kill-buffer (current-buffer)))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
728
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
729
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
730 (defun news-unsubscribe-group (group)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
731 "Removes you from newgroup GROUP."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
732 (interactive (list (completing-read "Unsubscribe from group: "
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
733 news-group-article-assoc)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
734 (news-unsubscribe-internal group))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
735
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
736 (defun news-unsubscribe-current-group ()
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
737 "Removes you from the newsgroup you are now reading."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
738 (interactive)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
739 (if (y-or-n-p "Do you really want to unsubscribe from this group ? ")
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
740 (news-unsubscribe-internal news-current-news-group)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
741
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
742 (defun news-unsubscribe-internal (group)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
743 (let ((tem (assoc group news-group-article-assoc)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
744 (if tem
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
745 (progn
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
746 (setq news-unsubscribe-groups (cons group news-unsubscribe-groups))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
747 (news-update-message-read group (news-cdar news-point-pdl))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
748 (if (equal group news-current-news-group)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
749 (news-next-group))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
750 (message ""))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
751 (error "Not subscribed to group: %s" group))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
752
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
753 (defun news-save-item-in-file (file)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
754 "Save the current article that is being read by appending to a file."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
755 (interactive "FSave item in file: ")
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
756 (append-to-file (point-min) (point-max) file))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
757
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
758 (defun news-get-pruned-list-of-files (gp-list end-file-no)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
759 "Given a news group it finds all files in the news group.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
760 The arg must be in slashified format.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
761 Using ls was found to be too slow in a previous version."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
762 (let
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
763 ((answer
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
764 (and
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
765 (not (and end-file-no
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
766 (equal (news-set-current-certifiable)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
767 (news-group-certification gp-list))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
768 (setq news-list-of-files nil
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
769 news-list-of-files-possibly-bogus t)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
770 (let* ((file-directory (concat news-path
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
771 (string-subst-char ?/ ?. gp-list)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
772 tem
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
773 (last-winner
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
774 (and end-file-no
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
775 (news-wins file-directory end-file-no)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
776 (news-find-first-or-last file-directory end-file-no 1))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
777 (setq news-list-of-files-possibly-bogus t news-list-of-files nil)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
778 (if last-winner
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
779 (progn
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
780 (setq news-list-of-files-possibly-bogus t
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
781 news-current-group-end last-winner)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
782 (while (> last-winner end-file-no)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
783 (news-push last-winner news-list-of-files)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
784 (setq last-winner (1- last-winner)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
785 news-list-of-files)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
786 (if (or (not (file-directory-p file-directory))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
787 (not (file-readable-p file-directory)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
788 nil
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
789 (setq news-list-of-files
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
790 (condition-case error
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
791 (directory-files file-directory)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
792 (file-error
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
793 (if (string= (nth 2 error) "permission denied")
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
794 (message "Newsgroup %s is read-protected"
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
795 gp-list)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
796 (signal 'file-error (cdr error)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
797 nil)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
798 (setq tem news-list-of-files)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
799 (while tem
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
800 (if (or (not (string-match "^[0-9]*$" (car tem)))
14040
187735b53d52 Comment fixes.
Karl Heuer <kwzh@gnu.org>
parents: 8576
diff changeset
801 ;; don't get confused by directories that look like numbers
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
802 (file-directory-p
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
803 (concat file-directory "/" (car tem)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
804 (<= (string-to-int (car tem)) end-file-no))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
805 (setq news-list-of-files
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
806 (delq (car tem) news-list-of-files)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
807 (setq tem (cdr tem)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
808 (if (null news-list-of-files)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
809 (progn (setq news-current-group-end 0)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
810 nil)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
811 (setq news-list-of-files
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
812 (mapcar 'string-to-int news-list-of-files))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
813 (setq news-list-of-files (sort news-list-of-files '<))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
814 (setq news-current-group-end
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
815 (elt news-list-of-files
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
816 (1- (length news-list-of-files))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
817 news-list-of-files)))))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
818 (or answer (progn (news-set-current-group-certification) nil))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
819
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
820 (defun news-read-files-into-buffer (group reversep)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
821 (let* ((files-start-end (news-cadr (assoc group news-group-article-assoc)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
822 (start-file-no (car files-start-end))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
823 (end-file-no (news-cadr files-start-end))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
824 (buffer-read-only nil))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
825 (setq news-current-news-group group)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
826 (setq news-current-message-number nil)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
827 (setq news-current-group-end nil)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
828 (news-set-mode-line)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
829 (news-get-pruned-list-of-files group end-file-no)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
830 (news-set-mode-line)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
831 ;; @@ should be a lot smarter than this if we have to move
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
832 ;; @@ around correctly.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
833 (setq news-point-pdl (list (cons (car files-start-end)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
834 (news-cadr files-start-end))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
835 (if (null news-list-of-files)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
836 (progn (erase-buffer)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
837 (setq news-current-group-end end-file-no)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
838 (setq news-current-group-begin end-file-no)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
839 (setq news-current-message-number end-file-no)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
840 (news-set-mode-line)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
841 ; (message "No new articles in " group " group.")
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
842 nil)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
843 (setq news-current-group-begin (car news-list-of-files))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
844 (if reversep
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
845 (setq news-current-message-number news-current-group-end)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
846 (if (> (car news-list-of-files) end-file-no)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
847 (setcdr (car news-point-pdl) (car news-list-of-files)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
848 (setq news-current-message-number news-current-group-begin))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
849 (news-set-message-counters)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
850 (news-set-mode-line)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
851 (news-read-in-file (concat news-path
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
852 (string-subst-char ?/ ?. group)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
853 "/"
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
854 (int-to-string
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
855 news-current-message-number)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
856 (news-set-message-counters)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
857 (news-set-mode-line)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
858 t)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
859
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
860 (defun news-add-news-group (gp)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
861 "Resubscribe to or add a USENET news group named GROUP (a string)."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
862 ; @@ (completing-read ...)
14040
187735b53d52 Comment fixes.
Karl Heuer <kwzh@gnu.org>
parents: 8576
diff changeset
863 ; @@ could be based on news library file ../active (slightly fascist)
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
864 ; @@ or (expensive to compute) all directories under the news spool directory
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
865 (interactive "sAdd news group: ")
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
866 (let ((file-dir (concat news-path (string-subst-char ?/ ?. gp))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
867 (save-excursion
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
868 (if (null (assoc gp news-group-article-assoc))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
869 (let ((newsrcbuf (find-file-noselect
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
870 (substitute-in-file-name news-startup-file))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
871 (if (file-directory-p file-dir)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
872 (progn
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
873 (switch-to-buffer newsrcbuf)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
874 (goto-char 0)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
875 (if (search-forward (concat gp "! ") nil t)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
876 (progn
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
877 (message "Re-subscribing to group %s." gp)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
878 ;;@@ news-unsubscribe-groups isn't being used
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
879 ;;(setq news-unsubscribe-groups
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
880 ;; (delq gp news-unsubscribe-groups))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
881 (backward-char 2)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
882 (delete-char 1)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
883 (insert ":"))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
884 (progn
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
885 (message
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
886 "Added %s to your list of newsgroups." gp)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
887 (end-of-buffer)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
888 (insert gp ": 1-1\n")))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
889 (search-backward gp nil t)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
890 (let (start end endofline tem)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
891 (search-forward ": " nil t)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
892 (setq end (point))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
893 (beginning-of-line)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
894 (setq start (point))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
895 (end-of-line)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
896 (setq endofline (point))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
897 (setq tem (buffer-substring start (- end 2)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
898 (let ((range (news-parse-range
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
899 (buffer-substring end endofline))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
900 (setq news-group-article-assoc
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
901 (cons (list tem (list (car range)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
902 (cdr range)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
903 (cdr range)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
904 news-group-article-assoc))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
905 (save-buffer)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
906 (kill-buffer (current-buffer)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
907 (message "Newsgroup %s doesn't exist." gp)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
908 (message "Already subscribed to group %s." gp)))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
909
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
910 (defun news-make-link-to-message (number newname)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
911 "Forges a link to an rnews message numbered number (current if no arg)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
912 Good for hanging on to a message that might or might not be
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
913 automatically deleted."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
914 (interactive "P
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
915 FName to link to message: ")
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
916 (add-name-to-file
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
917 (concat news-path
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
918 (string-subst-char ?/ ?. news-current-news-group)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
919 "/" (if number
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
920 (prefix-numeric-value number)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
921 news-current-message-number))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
922 newname))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
923
25276
a0a1a3da1af4 Fix maintainer address.
Karl Heuer <kwzh@gnu.org>
parents: 21863
diff changeset
924 ;;; caesar-region written by phr@gnu.org Nov 86
25278
cbe304a26771 Fix maintainer address.
Karl Heuer <kwzh@gnu.org>
parents: 25276
diff changeset
925 ;;; modified by tower@gnu.org Nov 86
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
926 (defun caesar-region (&optional n)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
927 "Caesar rotation of region by N, default 13, for decrypting netnews."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
928 (interactive (if current-prefix-arg ; Was there a prefix arg?
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
929 (list (prefix-numeric-value current-prefix-arg))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
930 (list nil)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
931 (cond ((not (numberp n)) (setq n 13))
4515
85426a9911c0 Remove, since floor and mod
Paul Eggert <eggert@twinsun.com>
parents: 845
diff changeset
932 (t (setq n (mod n 26)))) ;canonicalize N
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
933 (if (not (zerop n)) ; no action needed for a rot of 0
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
934 (progn
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
935 (if (or (not (boundp 'caesar-translate-table))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
936 (/= (aref caesar-translate-table ?a) (+ ?a n)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
937 (let ((i 0) (lower "abcdefghijklmnopqrstuvwxyz") upper)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
938 (message "Building caesar-translate-table...")
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
939 (setq caesar-translate-table (make-vector 256 0))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
940 (while (< i 256)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
941 (aset caesar-translate-table i i)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
942 (setq i (1+ i)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
943 (setq lower (concat lower lower) upper (upcase lower) i 0)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
944 (while (< i 26)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
945 (aset caesar-translate-table (+ ?a i) (aref lower (+ i n)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
946 (aset caesar-translate-table (+ ?A i) (aref upper (+ i n)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
947 (setq i (1+ i)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
948 (message "Building caesar-translate-table... done")))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
949 (let ((from (region-beginning))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
950 (to (region-end))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
951 (i 0) str len)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
952 (setq str (buffer-substring from to))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
953 (setq len (length str))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
954 (while (< i len)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
955 (aset str i (aref caesar-translate-table (aref str i)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
956 (setq i (1+ i)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
957 (goto-char from)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
958 (kill-region from to)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
959 (insert str)))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
960
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
961 ;;; news-caesar-buffer-body written by paul@media-lab.mit.edu Wed Oct 1, 1986
25276
a0a1a3da1af4 Fix maintainer address.
Karl Heuer <kwzh@gnu.org>
parents: 21863
diff changeset
962 ;;; hacked further by tower@gnu.org
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
963 (defun news-caesar-buffer-body (&optional rotnum)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
964 "Caesar rotates all letters in the current buffer by 13 places.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
965 Used to encode/decode possibly offensive messages (commonly in net.jokes).
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
966 With prefix arg, specifies the number of places to rotate each letter forward.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
967 Mail and USENET news headers are not rotated."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
968 (interactive (if current-prefix-arg ; Was there a prefix arg?
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
969 (list (prefix-numeric-value current-prefix-arg))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
970 (list nil)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
971 (save-excursion
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
972 (let ((buffer-status buffer-read-only))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
973 (setq buffer-read-only nil)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
974 ;; setup the region
21863
d84de2f4c38d Require sendmail.
Richard M. Stallman <rms@gnu.org>
parents: 21099
diff changeset
975 (set-mark (if (equal major-mode 'news-mode)
d84de2f4c38d Require sendmail.
Richard M. Stallman <rms@gnu.org>
parents: 21099
diff changeset
976 (progn (goto-char (point-min))
d84de2f4c38d Require sendmail.
Richard M. Stallman <rms@gnu.org>
parents: 21099
diff changeset
977 (search-forward "\n\n" nil t))
d84de2f4c38d Require sendmail.
Richard M. Stallman <rms@gnu.org>
parents: 21099
diff changeset
978 (mail-text-start)))
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
979 (goto-char (point-max))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
980 (caesar-region rotnum)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
981 (setq buffer-read-only buffer-status))))
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 35
diff changeset
982
658
7cbd4fcd8b0f *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 584
diff changeset
983 (provide 'rnews)
7cbd4fcd8b0f *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 584
diff changeset
984
7cbd4fcd8b0f *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 584
diff changeset
985 ;;; rnews.el ends here