1 ;;; gnus.el --- GNUS: an NNTP-based News Reader for GNU Emacs
3 ;; Copyright (C) 1987, 1988, 1989, 1990 Free Software Foundation, Inc.
5 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
8 ;; $Header: gnus.el,v 3.13 90/03/23 13:24:27 umerin Locked $
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to
24 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
29 ;; There are two mailing lists for GNUS lovers in the world:
31 ;; info-gnus@flab.fujitsu.co.jp, and
32 ;; info-gnus-english@tut.cis.ohio-state.edu.
34 ;; They are intended to exchange useful information about GNUS, such
35 ;; as bug fixes, useful hooks, and extensions. The major difference
36 ;; between the lists is what the official language is. Both Japanese
37 ;; and English are available in info-gnus, while English is only
38 ;; available in info-gnus-english. There is no need to subscribe to
39 ;; info-gnus if you cannot read Japanese messages, because most of the
40 ;; discussion and important announcements will be sent to
41 ;; info-gnus-english. Moreover, if you can read gnu.emacs.gnus
42 ;; newsgroup of USENET, you need not, either. info-gnus-english and
43 ;; gnu.emacs.gnus are linked each other.
45 ;; Please send subscription request to:
47 ;; info-gnus-request@flab.fujitsu.co.jp, or
48 ;; info-gnus-english-request@cis.ohio-state.edu
51 ;; (1) Incremental update of active info.
52 ;; (2) GNUS own poster.
53 ;; (3) Multi-GNUS (Talking to many hosts same time).
54 ;; (4) Asynchronous transmission of large messages.
61 (defvar gnus-nntp-server
(or (getenv "NNTPSERVER")
62 (and (boundp 'gnus-default-nntp-server
)
63 gnus-default-nntp-server
))
64 "The name of the host running NNTP server.
65 If it is a string such as `:DIRECTORY', the user's private DIRECTORY
66 is used as a news spool.
67 Initialized from the NNTPSERVER environment variable.")
69 (defvar gnus-nntp-service
"nntp"
70 "The name of the network service for GNUS to use. Usually \"nntp\".")
72 (defvar gnus-signature-file
"~/.signature"
73 "*Your .signature file. Use `.signature-DISTRIBUTION' instead if exists.")
75 (defvar gnus-use-cross-reference t
76 "Specifies what to do with cross references (Xref: field).
77 If nil, ignore cross references. If t, mark articles as read in subscribed
78 newsgroups. Otherwise, mark articles as read in all newsgroups.")
80 (defvar gnus-use-followup-to t
81 "*Specifies what to do with Followup-To: field.
82 If nil, ignore followup-to: field. If t, use its value execpt for
83 `poster'. Otherewise, if not nil nor t, always use its value.")
85 (defvar gnus-large-newsgroup
50
86 "*The number of articles which indicates a large newsgroup.
87 If the number of articles in a newsgroup is greater than the value,
88 confirmation is required for selecting the newsgroup.")
90 (defvar gnus-author-copy
(getenv "AUTHORCOPY")
91 "*Filename for saving a copy of an article posted using FCC: field.
92 Initialized from the AUTHORCOPY environment variable.
94 Articles are saved using a function specified by the the variable
95 `gnus-author-copy-saver' (`rmail-output' is the default) if a file name
96 is given. Instead, if the first character of the name is `|', the
97 contents of the article is piped out to the named program. It is
98 possible to save an article in an MH folder as follows:
100 (setq gnus-author-copy \"|/usr/local/lib/mh/rcvstore +Article\")")
102 (defvar gnus-author-copy-saver
(function rmail-output
)
103 "*A function called with a file name to save an author copy to.
104 The default function is `rmail-output' which saves in Unix mailbox format.")
106 (defvar gnus-use-long-file-name
107 (not (memq system-type
'(usg-unix-v xenix
)))
108 "Non-nil means that a newsgroup name is used as a default file name
109 to save articles to. If nil, the directory form of a newsgroup is
112 (defvar gnus-article-save-directory
(getenv "SAVEDIR")
113 "*The directory in which to save articles; defaults to ~/News.
114 Initialized from the SAVEDIR environment variable.")
116 (defvar gnus-default-article-saver
(function gnus-Subject-save-in-rmail
)
117 "A function used to save articles in your favorite format.
118 The function must be interactively callable (in other words, it must
119 be an Emacs command).
121 GNUS provides the following functions:
122 gnus-Subject-save-in-rmail (in Rmail format)
123 gnus-Subject-save-in-mail (in Unix mail format)
124 gnus-Subject-save-in-folder (in an MH folder)
125 gnus-Subject-save-in-file (in article format).")
127 (defvar gnus-rmail-save-name
(function gnus-plain-save-name
)
128 "A function generating a file name to save articles in Rmail format.
129 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
131 (defvar gnus-mail-save-name
(function gnus-plain-save-name
)
132 "A function generating a file name to save articles in Unix mail format.
133 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
135 (defvar gnus-folder-save-name
(function gnus-folder-save-name
)
136 "A function generating a file name to save articles in MH folder.
137 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER.")
139 (defvar gnus-file-save-name
(function gnus-numeric-save-name
)
140 "A function generating a file name to save articles in article format.
141 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
143 (defvar gnus-kill-file-name
"KILL"
144 "File name of a KILL file.")
146 (defvar gnus-default-distribution
"local"
147 "*Use this value as distribution if no distribution is specified.")
149 (defvar gnus-novice-user t
150 "*Non-nil means that you are a novice to USENET.
151 If non-nil, verbose messages may be displayed or your confirmation
154 (defvar gnus-interactive-post t
155 "*Newsgroup, subject, and distribution will be asked for if non-nil.")
157 (defvar gnus-user-login-name nil
158 "*The login name of the user.
159 Uses USER and LOGNAME environment variables if undefined.")
161 (defvar gnus-user-full-name nil
162 "*The full name of the user.
163 Uses from the NAME environment variable if undefined.")
165 (defvar gnus-show-threads t
166 "*Show conversation threads in Subject Mode if non-nil.")
168 (defvar gnus-thread-hide-subject t
169 "*Non-nil means hide subjects for thread subtrees.")
171 (defvar gnus-thread-hide-subtree nil
172 "*Non-nil means hide thread subtrees initially.
173 If non-nil, you have to run the command `gnus-Subject-show-thread' by
174 hand or by using `gnus-Select-article-hook' to show hidden threads.")
176 (defvar gnus-thread-hide-killed t
177 "*Non-nil means hide killed thread subtrees automatically.")
179 (defvar gnus-thread-ignore-subject nil
180 "*Don't take care of subject differences, but only references if non-nil.
181 If it is non-nil, some commands work with subjects do not work properly.")
183 (defvar gnus-thread-indent-level
4
184 "Indentation of thread subtrees.")
186 (defvar gnus-ignored-headers
187 "^Path:\\|^Posting-Version:\\|^Article-I.D.:\\|^Expires:\\|^Date-Received:\\|^References:\\|^Control:\\|^Xref:\\|^Lines:\\|^Posted:\\|^Relay-Version:\\|^Message-ID:\\|^Nf-ID:\\|^Nf-From:\\|^Approved:\\|^Sender:\\|^In-Reply-To:"
188 "Regexp matching headers not to display in messages.")
190 (defvar gnus-show-all-headers nil
191 "*Show all headers of an article if non-nil.")
193 (defvar gnus-save-all-headers nil
194 "*Save all headers of an article if non-nil.")
196 (defvar gnus-optional-headers
(function gnus-optional-lines-and-from
)
197 "A function generating a optional string displayed in GNUS Subject
198 mode buffer. The function is called with an article HEADER. The
199 result must be a string excluding `[' and `]'.")
201 (defvar gnus-auto-extend-newsgroup t
202 "*Extend visible articles to forward and backward if non-nil.")
204 (defvar gnus-auto-select-first t
205 "*Select the first unread article automagically if non-nil.
206 If you want to prevent automatic selection of the first unread article
207 in some newsgroups, set the variable to nil in `gnus-Select-group-hook'
208 or `gnus-Apply-kill-hook'.")
210 (defvar gnus-auto-select-next t
211 "*Select the next newsgroup automagically if non-nil.
212 If the value is t and the next newsgroup is empty, GNUS will exit
213 Subject mode and go back to Group mode. If the value is neither nil
214 nor t, GNUS will select the following unread newsgroup. Especially, if
215 the value is the symbol `quietly', the next unread newsgroup will be
216 selected without any confirmations.")
218 (defvar gnus-auto-select-same nil
219 "*Select the next article with the same subject automagically if non-nil.")
221 (defvar gnus-auto-center-subject t
222 "*Always center the current subject in GNUS Subject mode window if non-nil.")
224 (defvar gnus-break-pages t
225 "*Break an article into pages if non-nil.
226 Page delimiter is specified by the variable `gnus-page-delimiter'.")
228 (defvar gnus-page-delimiter
"^\^L"
229 "*Regexp describing line-beginnings that separate pages of news article.")
231 (defvar gnus-digest-show-summary t
232 "*Show a summary of undigestified messages if non-nil.")
234 (defvar gnus-digest-separator
"^Subject:[ \t]"
235 "*Regexp that separates messages in a digest article.")
237 (defvar gnus-use-full-window t
238 "*Non-nil means to take up the entire screen of Emacs.")
240 (defvar gnus-window-configuration
241 '((SelectNewsgroup (0 1 0))
242 (ExitNewsgroup (1 0 0))
243 (SelectArticle (0 3 10))
244 (ExpandSubject (0 1 0)))
245 "Specify window configurations for each action.
246 The format of the variable is a list of (ACTION (G S A)), where
247 G, S, and A are the relative height of Group, Subject, and Article
248 windows, respectively. ACTION is `SelectNewsgroup', `ExitNewsgroup',
249 `SelectArticle', or `ExpandSubject'.")
251 (defvar gnus-mail-reply-method
252 (function gnus-mail-reply-using-mail
)
253 "A function to compose reply mail.
254 The function `gnus-mail-reply-using-mail' uses usual the sendmail mail
255 program. The function `gnus-mail-reply-using-mhe' uses the mh-e mail
256 program. You can use yet another program by customizing this variable.")
258 (defvar gnus-mail-other-window-method
259 (function gnus-mail-other-window-using-mail
)
260 "A function to compose mail in other window.
261 The function `gnus-mail-other-window-using-mail' uses usual sendmail
262 mail program. The function `gnus-mail-other-window-using-mhe' uses mh-e
263 mail program. You can use yet another program by customizing this variable.")
265 (defvar gnus-subscribe-newsgroup-method
268 (gnus-subscribe-newsgroup newsgroup
269 (car (car gnus-newsrc-assoc
)))))
270 "A function called with a newsgroup name when it is created.")
272 (defvar gnus-Group-mode-hook nil
273 "A hook for GNUS Group Mode.")
275 (defvar gnus-Subject-mode-hook nil
276 "A hook for GNUS Subject Mode.")
278 (defvar gnus-Article-mode-hook nil
279 "A hook for GNUS Article Mode.")
281 (defvar gnus-Kill-file-mode-hook nil
282 "A hook for GNUS KILL File Mode.")
284 (defvar gnus-Open-server-hook nil
285 "A hook called just before opening connection to news server.")
287 (defvar gnus-Startup-hook nil
288 "A hook called at start up time.
289 This hook is called after GNUS is connected to the NNTP server.
290 So, it is possible to change the behavior of GNUS according to the
291 selected NNTP server.")
293 (defvar gnus-Group-prepare-hook nil
294 "A hook called after newsgroup list is created in the Newsgroup buffer.
295 If you want to modify the Newsgroup buffer, you can use this hook.")
297 (defvar gnus-Subject-prepare-hook nil
298 "A hook called after subject list is created in the Subject buffer.
299 If you want to modify the Subject buffer, you can use this hook.")
301 (defvar gnus-Article-prepare-hook nil
302 "A hook called after an article is prepared in the Article buffer.
303 If you want to run a special decoding program like nkf, use this hook.")
305 (defvar gnus-Select-group-hook nil
306 "A hook called when a newsgroup is selected.
307 If you want to sort Subject buffer by date and then by subject, you
308 can use the following hook:
310 (setq gnus-Select-group-hook
312 ;; First of all, sort by date.
315 (gnus-date-lessp (gnus-header-date a)
316 (gnus-header-date b))))
317 ;; Then sort by subject string ignoring `Re:'.
318 ;; If case-fold-search is non-nil, case of letters is ignored.
322 (gnus-simplify-subject (gnus-header-subject a) 're)
323 (gnus-simplify-subject (gnus-header-subject b) 're)
326 If you'd like to simplify subjects like the `gnus-Subject-next-same-subject'
327 command does, you can use the following hook:
329 (setq gnus-Select-group-hook
333 (nntp-set-header-subject
335 (gnus-simplify-subject
336 (gnus-header-subject header) 're-only))))
337 gnus-newsgroup-headers)))
339 In some newsgroups author name is meaningless. It is possible to
340 prevent listing author names in the GNUS Subject buffer as follows:
342 (setq gnus-Select-group-hook
344 (cond ((string-equal \"comp.sources.unix\" gnus-newsgroup-name)
345 (setq gnus-optional-headers
346 (function gnus-optional-lines)))
348 (setq gnus-optional-headers
349 (function gnus-optional-lines-and-from))))))")
351 (defvar gnus-Select-article-hook
352 (function (lambda () (gnus-Subject-show-thread)))
353 "Hook called when an article is selected.
354 The default hook automatically shows conversation thread subtrees
355 of the selected article as follows:
357 (setq gnus-Select-article-hook
359 (gnus-Subject-show-thread)))
361 If you'd like to run RMAIL on a digest article automagically, you can
362 use the following hook:
364 (setq gnus-Select-article-hook
366 (gnus-Subject-show-thread)
367 (cond ((string-equal \"comp.sys.sun\" gnus-newsgroup-name)
368 (gnus-Subject-rmail-digest))
369 ((and (string-equal \"comp.text\" gnus-newsgroup-name)
370 (string-match \"^TeXhax Digest\"
371 (gnus-header-subject gnus-current-headers)))
372 (gnus-Subject-rmail-digest)
375 (defvar gnus-Select-digest-hook
378 ;; Reply-To: is required by `undigestify-rmail-message'.
379 (or (mail-position-on-field "Reply-to" t
)
381 (mail-position-on-field "Reply-to")
382 (insert (gnus-fetch-field "From"))))))
383 "A hook called when reading digest messages using Rmail.
384 This hook can be used to modify incomplete digest articles as follows
385 (this is the default):
387 (setq gnus-Select-digest-hook
389 ;; Reply-To: is required by `undigestify-rmail-message'.
390 (or (mail-position-on-field \"Reply-to\" t)
392 (mail-position-on-field \"Reply-to\")
393 (insert (gnus-fetch-field \"From\"))))))")
395 (defvar gnus-Rmail-digest-hook nil
396 "A hook called when reading digest messages using Rmail.
397 This hook is intended to customize Rmail mode for reading digest articles.")
399 (defvar gnus-Apply-kill-hook
(function gnus-apply-kill-file
)
400 "A hook called when a newsgroup is selected and subject list is prepared.
401 This hook is intended to apply a KILL file to the selected newsgroup.
402 The function `gnus-apply-kill-file' is called defaultly.
404 Since a general KILL file is too heavy to use for only a few
405 newsgroups, we recommend you use a lighter hook function. For
406 example, if you'd like to apply a KILL file to articles which contains
407 a string `rmgroup' in subject in newsgroup `control', you can use the
410 (setq gnus-Apply-kill-hook
412 (cond ((string-match \"control\" gnus-newsgroup-name)
413 (gnus-kill \"Subject\" \"rmgroup\")
414 (gnus-expunge \"X\")))))")
416 (defvar gnus-Mark-article-hook
419 (or (memq gnus-current-article gnus-newsgroup-marked
)
420 (gnus-Subject-mark-as-read gnus-current-article
))
421 (gnus-Subject-set-current-mark "+")))
422 "A hook called when an article is selected for the first time.
423 The hook is intended to mark an article as read when it is selected.
424 If you'd like to mark as unread (-) instead, use the following hook:
426 (setq gnus-Mark-article-hook
428 (gnus-Subject-mark-as-unread gnus-current-article)
429 (gnus-Subject-set-current-mark \"+\")))")
431 (defvar gnus-Inews-article-hook nil
432 "A hook called before posting an article.
433 If you'd like to run a special encoding program, use this hook.")
435 (defvar gnus-Exit-group-hook nil
436 "A hook called when exiting (not quitting) Subject mode.
437 If your machine is so slow that exiting from Subject mode takes a
438 long time, set the variable `gnus-newsgroup-headers' to nil. This
439 inhibits marking articles as read using cross-reference information.")
441 (defvar gnus-Suspend-gnus-hook nil
442 "A hook called when suspending (not exiting) GNUS.")
444 (defvar gnus-Exit-gnus-hook nil
445 "A hook called when exiting (not suspending) GNUS.")
447 (defvar gnus-Save-newsrc-hook nil
448 "A hook called when saving the newsrc file.
449 This hook is called before saving .newsrc file.")
451 (defvar gnus-your-domain nil
452 "*Your domain name without your host name like: \"stars.flab.Fujitsu.CO.JP\"
453 The environment variable DOMAINNAME is used instead if defined. If
454 the function `system-name' returns the full internet name, there is no
455 need to define this variable.")
457 (defvar gnus-your-organization nil
458 "*Your organization like: \"Fujitsu Laboratories Ltd., Kawasaki, Japan.\"
459 The `ORGANIZATION' environment variable is used instead if defined.")
461 (defvar gnus-use-generic-from nil
462 "*If nil, prepend local host name to the defined domain in the From:
463 field; if stringp, use this; if non-nil, strip of the local host name.")
465 (defvar gnus-use-generic-path nil
466 "*If nil, use the NNTP server name in the Path: field; if stringp,
467 use this; if non-nil, use no host name (user name only)")
469 ;; Internal variables.
471 (defconst gnus-version
"GNUS 3.13"
472 "Version numbers of this version of GNUS.")
474 (defvar gnus-Info-nodes
475 '((gnus-Group-mode .
"(gnus)Newsgroup Commands")
476 (gnus-Subject-mode .
"(gnus)Subject Commands")
477 (gnus-Article-mode .
"(gnus)Article Commands")
478 (gnus-Kill-file-mode .
"(gnus)KILL File")
479 (gnus-Browse-killed-mode .
"(gnus)Maintenance"))
480 "Assoc list of major modes and related Info nodes.")
482 (defvar gnus-access-methods
484 (gnus-retrieve-headers . nntp-retrieve-headers
)
485 (gnus-open-server . nntp-open-server
)
486 (gnus-close-server . nntp-close-server
)
487 (gnus-server-opened . nntp-server-opened
)
488 (gnus-status-message . nntp-status-message
)
489 (gnus-request-article . nntp-request-article
)
490 (gnus-request-group . nntp-request-group
)
491 (gnus-request-list . nntp-request-list
)
492 (gnus-request-post . nntp-request-post
))
494 (gnus-retrieve-headers . nnspool-retrieve-headers
)
495 (gnus-open-server . nnspool-open-server
)
496 (gnus-close-server . nnspool-close-server
)
497 (gnus-server-opened . nnspool-server-opened
)
498 (gnus-status-message . nnspool-status-message
)
499 (gnus-request-article . nnspool-request-article
)
500 (gnus-request-group . nnspool-request-group
)
501 (gnus-request-list . nnspool-request-list
)
502 (gnus-request-post . nnspool-request-post
))
504 (gnus-retrieve-headers . mhspool-retrieve-headers
)
505 (gnus-open-server . mhspool-open-server
)
506 (gnus-close-server . mhspool-close-server
)
507 (gnus-server-opened . mhspool-server-opened
)
508 (gnus-status-message . mhspool-status-message
)
509 (gnus-request-article . mhspool-request-article
)
510 (gnus-request-group . mhspool-request-group
)
511 (gnus-request-list . mhspool-request-list
)
512 (gnus-request-post . mhspool-request-post
)))
513 "Access method for NNTP, nnspool, and mhspool.")
515 (defvar gnus-Group-buffer
"*Newsgroup*")
516 (defvar gnus-Subject-buffer
"*Subject*")
517 (defvar gnus-Article-buffer
"*Article*")
518 (defvar gnus-Digest-buffer
"GNUS Digest")
519 (defvar gnus-Digest-summary-buffer
"GNUS Digest-summary")
521 (defvar gnus-buffer-list
522 (list gnus-Group-buffer gnus-Subject-buffer gnus-Article-buffer
523 gnus-Digest-buffer gnus-Digest-summary-buffer
)
524 "GNUS buffer names which should be killed when exiting.")
526 (defvar gnus-variable-list
527 '(gnus-newsrc-options
528 gnus-newsrc-options-n-yes gnus-newsrc-options-n-no
529 gnus-newsrc-assoc gnus-killed-assoc gnus-marked-assoc
)
530 "GNUS variables saved in the quick startup file.")
532 (defvar gnus-overload-functions
533 '((news-inews gnus-inews-news
"rnewspost")
534 (caesar-region gnus-caesar-region
"rnews"))
535 "Functions overloaded by gnus.
536 It is a list of `(original overload &optional file)'.")
538 (defvar gnus-newsrc-options nil
539 "Options line in the .newsrc file.")
541 (defvar gnus-newsrc-options-n-yes nil
542 "Regexp representing subscribed newsgroups.")
544 (defvar gnus-newsrc-options-n-no nil
545 "Regexp representing unsubscribed newsgroups.")
547 (defvar gnus-newsrc-assoc nil
548 "Assoc list of read articles.")
550 (defvar gnus-killed-assoc nil
551 "Assoc list of newsgroups removed from `gnus-newsrc-assoc'.")
553 (defvar gnus-marked-assoc nil
554 "Assoc list of articles marked as unread.")
556 (defvar gnus-unread-hashtb nil
557 "Hashtable of unread articles.")
559 (defvar gnus-active-hashtb nil
560 "Hashtable of active articles.")
562 (defvar gnus-octive-hashtb nil
563 "Hashtable of OLD active articles.")
565 (defvar gnus-current-startup-file nil
566 "Startup file for the current host.")
568 (defvar gnus-last-search-regexp nil
569 "Default regexp for article search command.")
571 (defvar gnus-last-shell-command nil
572 "Default shell command on article.")
574 (defvar gnus-have-all-newsgroups nil
)
576 (defvar gnus-newsgroup-name nil
)
577 (defvar gnus-newsgroup-begin nil
)
578 (defvar gnus-newsgroup-end nil
)
579 (defvar gnus-newsgroup-last-rmail nil
)
580 (defvar gnus-newsgroup-last-mail nil
)
581 (defvar gnus-newsgroup-last-folder nil
)
582 (defvar gnus-newsgroup-last-file nil
)
584 (defvar gnus-newsgroup-unreads nil
585 "List of unread articles in the current newsgroup.")
587 (defvar gnus-newsgroup-unselected nil
588 "List of unselected unread articles in the current newsgroup.")
590 (defvar gnus-newsgroup-marked nil
591 "List of marked articles in the current newsgroup (a subset of unread art).")
593 (defvar gnus-newsgroup-headers nil
594 "List of article headers in the current newsgroup.")
596 (defvar gnus-current-article nil
)
597 (defvar gnus-current-headers nil
)
598 (defvar gnus-current-history nil
)
599 (defvar gnus-have-all-headers nil
)
600 (defvar gnus-last-article nil
)
601 (defvar gnus-current-kill-article nil
)
603 ;; Save window configuration.
604 (defvar gnus-winconf-kill-file nil
)
606 (defvar gnus-Group-mode-map nil
)
607 (defvar gnus-Subject-mode-map nil
)
608 (defvar gnus-Article-mode-map nil
)
609 (defvar gnus-Kill-file-mode-map nil
)
611 (defvar rmail-last-file
(expand-file-name "~/XMBOX"))
612 (defvar rmail-last-rmail-file
(expand-file-name "~/XNEWS"))
614 ;; Define GNUS Subsystems.
615 (autoload 'gnus-Group-post-news
"gnuspost"
616 "Post an article." t
)
617 (autoload 'gnus-Subject-post-news
"gnuspost"
618 "Post an article." t
)
619 (autoload 'gnus-Subject-post-reply
"gnuspost"
620 "Post a reply article." t
)
621 (autoload 'gnus-Subject-post-reply-with-original
"gnuspost"
622 "Post a reply article with original article." t
)
623 (autoload 'gnus-Subject-cancel-article
"gnuspost"
624 "Cancel an article you posted." t
)
626 (autoload 'gnus-Subject-mail-reply
"gnusmail"
627 "Reply mail to news author." t
)
628 (autoload 'gnus-Subject-mail-reply-with-original
"gnusmail"
629 "Reply mail to news author with original article." t
)
630 (autoload 'gnus-Subject-mail-other-window
"gnusmail"
631 "Compose mail in other window." t
)
633 (autoload 'gnus-Group-kill-group
"gnusmisc"
634 "Kill newsgroup on current line." t
)
635 (autoload 'gnus-Group-yank-group
"gnusmisc"
636 "Yank the last killed newsgroup on current line." t
)
637 (autoload 'gnus-Browse-killed-groups
"gnusmisc"
638 "Browse the killed newsgroups." t
)
640 (autoload 'rmail-output
"rmailout"
641 "Append this message to Unix mail file named FILE-NAME." t
)
642 (autoload 'mail-position-on-field
"sendmail")
643 (autoload 'mh-find-path
"mh-e")
644 (autoload 'mh-prompt-for-folder
"mh-e")
646 (put 'gnus-Group-mode
'mode-class
'special
)
647 (put 'gnus-Subject-mode
'mode-class
'special
)
648 (put 'gnus-Article-mode
'mode-class
'special
)
651 ;;(put 'gnus-eval-in-buffer-window 'lisp-indent-function 1)
653 (defmacro gnus-eval-in-buffer-window
(buffer &rest forms
)
654 "Pop to BUFFER, evaluate FORMS, and then returns to original window."
655 (` (let ((GNUSStartBufferWindow (selected-window)))
658 (pop-to-buffer (, buffer
))
660 (select-window GNUSStartBufferWindow
)))))
662 (defmacro gnus-make-hashtable
()
663 '(make-abbrev-table))
665 (defmacro gnus-gethash
(string hashtable
)
666 "Get hash value of STRING in HASHTABLE."
667 ;;(` (symbol-value (abbrev-symbol (, string) (, hashtable))))
668 (` (abbrev-expansion (, string
) (, hashtable
))))
670 (defmacro gnus-sethash
(string value hashtable
)
671 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
672 ;; We cannot use define-abbrev since it only accepts string as value.
673 (` (set (intern (, string
) (, hashtable
)) (, value
))))
675 ;; Note: Macros defined here are also defined in nntp.el. I don't like
676 ;; to put them here, but many users got troubled with the old
677 ;; definitions in nntp.elc. These codes are NNTP 3.10 version.
679 (defmacro nntp-header-number
(header)
680 "Return article number in HEADER."
681 (` (aref (, header
) 0)))
683 (defmacro nntp-set-header-number
(header number
)
684 "Set article number of HEADER to NUMBER."
685 (` (aset (, header
) 0 (, number
))))
687 (defmacro nntp-header-subject
(header)
688 "Return subject string in HEADER."
689 (` (aref (, header
) 1)))
691 (defmacro nntp-set-header-subject
(header subject
)
692 "Set article subject of HEADER to SUBJECT."
693 (` (aset (, header
) 1 (, subject
))))
695 (defmacro nntp-header-from
(header)
696 "Return author string in HEADER."
697 (` (aref (, header
) 2)))
699 (defmacro nntp-set-header-from
(header from
)
700 "Set article author of HEADER to FROM."
701 (` (aset (, header
) 2 (, from
))))
703 (defmacro nntp-header-xref
(header)
704 "Return xref string in HEADER."
705 (` (aref (, header
) 3)))
707 (defmacro nntp-set-header-xref
(header xref
)
708 "Set article xref of HEADER to xref."
709 (` (aset (, header
) 3 (, xref
))))
711 (defmacro nntp-header-lines
(header)
712 "Return lines in HEADER."
713 (` (aref (, header
) 4)))
715 (defmacro nntp-set-header-lines
(header lines
)
716 "Set article lines of HEADER to LINES."
717 (` (aset (, header
) 4 (, lines
))))
719 (defmacro nntp-header-date
(header)
720 "Return date in HEADER."
721 (` (aref (, header
) 5)))
723 (defmacro nntp-set-header-date
(header date
)
724 "Set article date of HEADER to DATE."
725 (` (aset (, header
) 5 (, date
))))
727 (defmacro nntp-header-id
(header)
728 "Return Id in HEADER."
729 (` (aref (, header
) 6)))
731 (defmacro nntp-set-header-id
(header id
)
732 "Set article Id of HEADER to ID."
733 (` (aset (, header
) 6 (, id
))))
735 (defmacro nntp-header-references
(header)
736 "Return references in HEADER."
737 (` (aref (, header
) 7)))
739 (defmacro nntp-set-header-references
(header ref
)
740 "Set article references of HEADER to REF."
741 (` (aset (, header
) 7 (, ref
))))
748 (if gnus-Group-mode-map
750 (setq gnus-Group-mode-map
(make-keymap))
751 (suppress-keymap gnus-Group-mode-map
)
752 (define-key gnus-Group-mode-map
" " 'gnus-Group-read-group
)
753 (define-key gnus-Group-mode-map
"=" 'gnus-Group-select-group
)
754 (define-key gnus-Group-mode-map
"j" 'gnus-Group-jump-to-group
)
755 (define-key gnus-Group-mode-map
"n" 'gnus-Group-next-unread-group
)
756 (define-key gnus-Group-mode-map
"p" 'gnus-Group-prev-unread-group
)
757 (define-key gnus-Group-mode-map
"\177" 'gnus-Group-prev-unread-group
)
758 (define-key gnus-Group-mode-map
"N" 'gnus-Group-next-group
)
759 (define-key gnus-Group-mode-map
"P" 'gnus-Group-prev-group
)
760 (define-key gnus-Group-mode-map
"\C-n" 'gnus-Group-next-group
)
761 (define-key gnus-Group-mode-map
"\C-p" 'gnus-Group-prev-group
)
762 (define-key gnus-Group-mode-map
"\r" 'next-line
)
763 (define-key gnus-Group-mode-map
"/" 'isearch-forward
)
764 (define-key gnus-Group-mode-map
"<" 'beginning-of-buffer
)
765 (define-key gnus-Group-mode-map
">" 'end-of-buffer
)
766 (define-key gnus-Group-mode-map
"u" 'gnus-Group-unsubscribe-current-group
)
767 (define-key gnus-Group-mode-map
"U" 'gnus-Group-unsubscribe-group
)
768 (define-key gnus-Group-mode-map
"c" 'gnus-Group-catch-up
)
769 (define-key gnus-Group-mode-map
"C" 'gnus-Group-catch-up-all
)
770 (define-key gnus-Group-mode-map
"l" 'gnus-Group-list-groups
)
771 (define-key gnus-Group-mode-map
"L" 'gnus-Group-list-all-groups
)
772 (define-key gnus-Group-mode-map
"g" 'gnus-Group-get-new-news
)
773 (define-key gnus-Group-mode-map
"R" 'gnus-Group-restart
)
774 (define-key gnus-Group-mode-map
"b" 'gnus-Group-check-bogus-groups
)
775 (define-key gnus-Group-mode-map
"r" 'gnus-Group-restrict-groups
)
776 (define-key gnus-Group-mode-map
"a" 'gnus-Group-post-news
)
777 (define-key gnus-Group-mode-map
"\ek" 'gnus-Group-edit-local-kill
)
778 (define-key gnus-Group-mode-map
"\eK" 'gnus-Group-edit-global-kill
)
779 (define-key gnus-Group-mode-map
"\C-k" 'gnus-Group-kill-group
)
780 (define-key gnus-Group-mode-map
"\C-y" 'gnus-Group-yank-group
)
781 (define-key gnus-Group-mode-map
"\C-c\C-y" 'gnus-Browse-killed-groups
)
782 (define-key gnus-Group-mode-map
"V" 'gnus-version
)
783 (define-key gnus-Group-mode-map
"x" 'gnus-Group-force-update
)
784 (define-key gnus-Group-mode-map
"s" 'gnus-Group-force-update
)
785 (define-key gnus-Group-mode-map
"z" 'gnus-Group-suspend
)
786 (define-key gnus-Group-mode-map
"q" 'gnus-Group-exit
)
787 (define-key gnus-Group-mode-map
"Q" 'gnus-Group-quit
)
788 (define-key gnus-Group-mode-map
"?" 'gnus-Group-describe-briefly
)
789 (define-key gnus-Group-mode-map
"\C-c\C-i" 'gnus-Info-find-node
))
791 (defun gnus-Group-mode ()
792 "Major mode for reading network news.
793 All normal editing commands are turned off.
794 Instead, these commands are available:
795 \\{gnus-Group-mode-map}
797 The name of the host running NNTP server is asked for if no default
798 host is specified. It is also possible to choose another NNTP server
799 even when the default server is defined by giving a prefix argument to
800 the command `\\[gnus]'.
802 If an NNTP server is preceded by a colon such as `:Mail', the user's
803 private directory `~/Mail' is used as a news spool. This makes it
804 possible to read mail stored in MH folders or articles saved by GNUS.
805 File names of mail or articles must consist of only numeric
806 characters. Otherwise, they are ignored.
808 If there is a file named `~/.newsrc-SERVER', it is used as the
809 startup file instead of standard one when talking to SERVER. It is
810 possible to talk to many hosts by using different startup files for
813 Option `-n' of the options line in the startup file is recognized
814 properly the same as the Bnews system. For example, if the options
815 line is `options -n !talk talk.rumors', newsgroups under the `talk'
816 hierarchy except for `talk.rumors' are ignored while checking new
819 If there is a file named `~/.signature-DISTRIBUTION', it is used as
820 signature file instead of standard one when posting a news in
823 If an Info file generated from `gnus.texinfo' is installed, you can
824 read an appropriate Info node of the Info file according to the
825 current major mode of GNUS by \\[gnus-Info-find-node].
827 The variable `gnus-version', `nntp-version', `nnspool-version', and
828 `mhspool-version' have the version numbers of this version of gnus.el,
829 nntp.el, nnspool.el, and mhspoo.el, respectively.
831 User customizable variables:
833 Specifies the name of the host running the NNTP server. If its
834 value is a string such as `:DIRECTORY', the user's private
835 DIRECTORY is used as a news spool. If its value is `::', then
836 the local news spool on the current machine is used directly.
837 The `NNTPSERVER' environment variable specifies the initial value
841 Specifies a NNTP service name. It is usually \"nntp\".
844 Specifies a startup file (.newsrc). If there is a file named
845 `.newsrc-SERVER', it's used instead when talking to SERVER. I
846 recommend you to use the server specific file, if you'd like to
847 talk to many servers. Especially if you'd like to read your
848 private directory, the name of the file must be
849 `.newsrc-:DIRECTORY'.
852 Specifies a signature file (.signature). If there is a file named
853 `.signature-DISTRIBUTION', it's used instead when posting an
854 article in DISTRIBUTION. Set the variable to nil to prevent
855 appending the file automatically. If you use an NNTP inews which
856 comes with the NNTP package, you may have to set the variable to
859 gnus-use-cross-reference
860 Specifies what to do with cross references (Xref: field). If it
861 is nil, cross references are ignored. If it is t, articles in
862 subscribed newsgroups are only marked as read. Otherwise, if it
863 is not nil nor t, articles in all newsgroups are marked as read.
866 Specifies what to do with followup-to: field. If it is nil, its
867 value is ignored. If it is non-nil, its value is used as followup
868 newsgroups. Especially, if it is t and field value is `poster',
869 your confirmation is required.
872 Specifies a file name to save a copy of article you posted using
873 FCC: field. If the first character of the value is `|', the
874 contents of the article is piped out to a program specified by the
875 rest of the value. The variable is initialized from the
876 AUTHORCOPY environment variable.
878 gnus-author-copy-saver
879 Specifies a function to save an author copy. The function is
880 called with a file name. The default function `rmail-output'
881 saves in Unix mail format.
884 Use specified file name as a KILL file (default to `KILL').
887 Non-nil means that you are a novice to USENET. If non-nil,
888 verbose messages may be displayed or your confirmations may be
891 gnus-interactive-post
892 Non-nil means that newsgroup, subject and distribution are asked
893 for interactively when posting a new article.
896 Non-nil means to take up the entire screen of Emacs.
898 gnus-window-configuration
899 Specifies the configuration of Group, Subject, and Article
900 windows. It is a list of (ACTION (G S A)), where G, S, and A are
901 the relative height of Group, Subject, and Article windows,
902 respectively. ACTION is `SelectNewsgroup', `ExitNewsgroup',
903 `SelectArticle', or `ExpandSubject'.
905 gnus-subscribe-newsgroup-method
906 Specifies a function called with a newsgroup name when new
907 newsgroup is found. The default definition adds new newsgroup at
908 the beginning of other newsgroups.
910 Various hooks for customization:
912 Entry to this mode calls the value with no arguments, if that
913 value is non-nil. This hook is called before GNUS is connected to
914 the NNTP server. So, you can change or define the NNTP server in
918 Called with no arguments after the NNTP server is selected. It is
919 possible to change the behavior of GNUS or initialize the
920 variables according to the selected NNTP server.
922 gnus-Group-prepare-hook
923 Called with no arguments after a newsgroup list is created in the
924 Newsgroup buffer, if that value is non-nil.
926 gnus-Save-newsrc-hook
927 Called with no arguments when saving newsrc file if that value is
930 gnus-Inews-article-hook
931 Called with no arguments when posting an article if that value is
932 non-nil. This hook is called just before posting an article, while
933 `news-inews-hook' is called before preparing article headers. If
934 you'd like to convert kanji code of the article, this hook is recommended.
936 gnus-Suspend-gnus-hook
937 Called with no arguments when suspending (not exiting) GNUS, if
938 that value is non-nil.
941 Called with no arguments when exiting (not suspending) GNUS, if
942 that value is non-nil."
944 (kill-all-local-variables)
945 ;; Gee. Why don't you upgrade?
946 (cond ((boundp 'mode-line-modified
)
947 (setq mode-line-modified
"--- "))
948 ((listp (default-value 'mode-line-format
))
949 (setq mode-line-format
950 (cons "--- " (cdr (default-value 'mode-line-format
)))))
952 (setq mode-line-format
953 "--- GNUS: List of Newsgroups %[(%m)%]----%3p-%-")))
954 (setq major-mode
'gnus-Group-mode
)
955 (setq mode-name
"Newsgroup")
956 (setq mode-line-buffer-identification
"GNUS: List of Newsgroups")
957 (setq mode-line-process nil
)
958 (use-local-map gnus-Group-mode-map
)
959 (buffer-flush-undo (current-buffer))
960 (setq buffer-read-only t
) ;Disable modification
961 (run-hooks 'gnus-Group-mode-hook
))
964 (defun gnus (&optional confirm
)
966 If optional argument CONFIRM is non-nil, ask NNTP server."
970 (switch-to-buffer (get-buffer-create gnus-Group-buffer
))
972 (gnus-start-news-server confirm
))
973 (if (not (gnus-server-opened))
975 ;; NNTP server is successfully open.
976 (setq mode-line-process
(format " {%s}" gnus-nntp-server
))
977 (let ((buffer-read-only nil
))
979 (gnus-Group-startup-message)
981 (run-hooks 'gnus-Startup-hook
)
982 (gnus-setup-news-info)
984 (gnus-Group-describe-briefly)) ;Show brief help message.
985 (gnus-Group-list-groups nil
)
988 (defun gnus-Group-startup-message ()
989 "Insert startup message in current buffer."
990 ;; Insert the message.
994 NNTP-based News Reader for GNU Emacs
997 If you have any trouble with this software, please let me
998 know. I will fix your problems in the next release.
1000 Comments, suggestions, and bug fixes are welcome.
1003 umerin@tc.Nagasaki.GO.JP")
1004 ;; And then hack it.
1005 ;; 57 is the longest line.
1006 (indent-rigidly (point-min) (point-max) (/ (max (- (window-width) 57) 0) 2))
1007 (goto-char (point-min))
1008 ;; +4 is fuzzy factor.
1009 (insert-char ?
\n (/ (max (- (window-height) 18) 0) 2)))
1011 (defun gnus-Group-list-groups (show-all)
1012 "List newsgroups in the Newsgroup buffer.
1013 If argument SHOW-ALL is non-nil, unsubscribed groups are also listed."
1015 (let ((last-group ;Current newsgroup.
1016 (gnus-Group-group-name))
1017 (next-group ;Next possible newsgroup.
1019 (gnus-Group-search-forward nil nil
)
1020 (gnus-Group-group-name)))
1021 (prev-group ;Previous possible newsgroup.
1023 (gnus-Group-search-forward t nil
)
1024 (gnus-Group-group-name))))
1025 (gnus-Group-prepare show-all
)
1026 (if (zerop (buffer-size))
1027 (message "No news is good news")
1028 ;; Go to last newsgroup if possible. If cannot, try next and
1029 ;; previous. If all fail, go to first unread newsgroup.
1030 (goto-char (point-min))
1033 (concat "^.+: " (regexp-quote last-group
) "$") nil t
))
1036 (concat "^.+: " (regexp-quote next-group
) "$") nil t
))
1039 (concat "^.+: " (regexp-quote prev-group
) "$") nil t
))
1040 (re-search-forward "^[ \t]+[1-9][0-9]*:" nil t
))
1041 ;; Adjust cursor point.
1043 (search-forward ":" nil t
)
1046 (defun gnus-Group-prepare (&optional all
)
1047 "Prepare list of newsgroups in current buffer.
1048 If optional argument ALL is non-nil, unsubscribed groups are also listed."
1049 (let ((buffer-read-only nil
)
1050 (newsrc gnus-newsrc-assoc
)
1054 ;; This specifies the format of Group buffer.
1055 (cntl "%s%s%5d: %s\n"))
1059 (setq group-info
(car newsrc
))
1060 (setq group-name
(car group-info
))
1061 (setq unread-count
(nth 1 (gnus-gethash group-name gnus-unread-hashtb
)))
1063 (and (nth 1 group-info
) ;Subscribed.
1064 (> unread-count
0))) ;There are unread articles.
1065 ;; Yes, I can use gnus-Group-prepare-line, but this is faster.
1068 ;; Subscribed or not.
1069 (if (nth 1 group-info
) " " "U")
1071 (if (and (> unread-count
0)
1075 (cdr (assoc group-name
1076 gnus-marked-assoc
))))))
1078 ;; Number of unread articles.
1083 (setq newsrc
(cdr newsrc
))
1085 (setq gnus-have-all-newsgroups all
)
1086 (goto-char (point-min))
1087 (run-hooks 'gnus-Group-prepare-hook
)
1090 (defun gnus-Group-prepare-line (info)
1091 "Return a string for the Newsgroup buffer from INFO.
1092 INFO is an element of gnus-newsrc-assoc or gnus-killed-assoc."
1093 (let* ((group-name (car info
))
1095 (or (nth 1 (gnus-gethash group-name gnus-unread-hashtb
))
1096 ;; Not in hash table, so compute it now.
1097 (gnus-number-of-articles
1098 (gnus-difference-of-range
1099 (nth 2 (gnus-gethash group-name gnus-active-hashtb
))
1101 ;; This specifies the format of Group buffer.
1102 (cntl "%s%s%5d: %s\n"))
1104 ;; Subscribed or not.
1105 (if (nth 1 info
) " " "U")
1107 (if (and (> unread-count
0)
1111 (cdr (assoc group-name gnus-marked-assoc
))))))
1113 ;; Number of unread articles.
1119 (defun gnus-Group-update-group (group &optional visible-only
)
1120 "Update newsgroup info of GROUP.
1121 If optional argument VISIBLE-ONLY is non-nil, non displayed group is ignored."
1122 (let ((buffer-read-only nil
)
1124 ;; Buffer may be narrowed.
1127 ;; Search point to modify.
1128 (goto-char (point-min))
1129 (if (re-search-forward (concat "^.+: " (regexp-quote group
) "$") nil t
)
1130 ;; GROUP is listed in current buffer. So, delete old line.
1134 (delete-region (point) (progn (forward-line 1) (point)))
1136 (if (or visible
(not visible-only
))
1138 (insert (gnus-Group-prepare-line (assoc group gnus-newsrc-assoc
)))
1139 (forward-line -
1) ;Move point on that line.
1143 ;; GNUS Group mode command
1145 (defun gnus-Group-group-name ()
1146 "Get newsgroup name around point."
1149 (if (looking-at ".[* \t]*[0-9]+:[ \t]+\\([^ \t\n]+\\)$")
1150 (buffer-substring (match-beginning 1) (match-end 1))
1153 (defun gnus-Group-read-group (all &optional no-article
)
1154 "Read news in this newsgroup.
1155 If argument ALL is non-nil, already read articles become readable.
1156 If optional argument NO-ARTICLE is non-nil, no article body is displayed."
1158 (let ((group (gnus-Group-group-name))) ;Newsgroup name to read.
1160 (gnus-Subject-read-group
1163 ;;(not (nth 1 (assoc group gnus-newsrc-assoc))) ;Unsubscribed
1165 (nth 1 (gnus-gethash group gnus-unread-hashtb
)))) ;No unread
1170 (defun gnus-Group-select-group (all)
1171 "Select this newsgroup.
1172 No article is selected automatically.
1173 If argument ALL is non-nil, already read articles become readable."
1175 (gnus-Group-read-group all t
))
1177 (defun gnus-Group-jump-to-group (group)
1178 "Jump to newsgroup GROUP."
1180 (list (completing-read "Newsgroup: " gnus-newsrc-assoc nil
'require-match
)))
1181 (goto-char (point-min))
1182 (or (re-search-forward (concat "^.+: " (regexp-quote group
) "$") nil t
)
1183 (if (assoc group gnus-newsrc-assoc
)
1184 ;; Add GROUP entry, then seach again.
1185 (gnus-Group-update-group group
)))
1186 ;; Adjust cursor point.
1188 (search-forward ":" nil t
))
1190 (defun gnus-Group-search-forward (backward any-group
)
1191 "Search for newsgroup forward.
1192 If first argument BACKWARD is non-nil, search backward instead.
1193 If second argument ANY-GROUP is non-nil, unsubscribed or empty
1194 group may be selected."
1195 (let ((func (if backward
're-search-backward
're-search-forward
))
1197 (format "^%s[ \t]*\\(%s\\):"
1198 (if any-group
".." " [ \t]")
1199 (if any-group
"[0-9]+" "[1-9][0-9]*")))
1204 (setq found
(funcall func regexp nil t
))
1205 ;; Adjust cursor point.
1207 (search-forward ":" nil t
)
1208 ;; Return T if found.
1212 (defun gnus-Group-next-group (n)
1213 "Go to next N'th newsgroup."
1216 (gnus-Group-search-forward nil t
))
1218 (or (gnus-Group-search-forward nil t
)
1219 (message "No more newsgroups")))
1221 (defun gnus-Group-next-unread-group (n)
1222 "Go to next N'th unread newsgroup."
1225 (gnus-Group-search-forward nil nil
))
1227 (or (gnus-Group-search-forward nil nil
)
1228 (message "No more unread newsgroups")))
1230 (defun gnus-Group-prev-group (n)
1231 "Go to previous N'th newsgroup."
1234 (gnus-Group-search-forward t t
))
1236 (or (gnus-Group-search-forward t t
)
1237 (message "No more newsgroups")))
1239 (defun gnus-Group-prev-unread-group (n)
1240 "Go to previous N'th unread newsgroup."
1243 (gnus-Group-search-forward t nil
))
1245 (or (gnus-Group-search-forward t nil
)
1246 (message "No more unread newsgroups")))
1248 (defun gnus-Group-catch-up (all &optional quietly
)
1249 "Mark all articles not marked as unread in current newsgroup as read.
1250 If prefix argument ALL is non-nil, all articles are marked as read.
1251 Cross references (Xref: field) of articles are ignored."
1253 (let* ((group (gnus-Group-group-name))
1254 (marked (if (not all
)
1255 (cdr (assoc group gnus-marked-assoc
)))))
1260 "Do you really want to mark everything as read? "
1261 "Delete all articles not marked as read? ")))
1263 (message "") ;Erase "Yes or No" question.
1264 ;; Any marked articles will be preserved.
1265 (gnus-update-unread-articles group marked marked
)
1266 (gnus-Group-update-group group
)
1267 (gnus-Group-next-group 1)))
1270 (defun gnus-Group-catch-up-all (&optional quietly
)
1271 "Mark all articles in current newsgroup as read.
1272 Cross references (Xref: field) of articles are ignored."
1274 (gnus-Group-catch-up t quietly
))
1276 (defun gnus-Group-unsubscribe-current-group ()
1277 "Toggle subscribe from/to unsubscribe current group."
1279 (gnus-Group-unsubscribe-group (gnus-Group-group-name))
1280 (gnus-Group-next-group 1))
1282 (defun gnus-Group-unsubscribe-group (group)
1283 "Toggle subscribe from/to unsubscribe GROUP.
1284 New newsgroup is added to .newsrc automatically."
1286 (list (completing-read "Newsgroup: "
1287 gnus-active-hashtb nil
'require-match
)))
1288 (let ((newsrc (assoc group gnus-newsrc-assoc
)))
1289 (cond ((not (null newsrc
))
1290 ;; Toggle subscription flag.
1291 (setcar (nthcdr 1 newsrc
) (not (nth 1 newsrc
)))
1292 (gnus-update-newsrc-buffer group
)
1293 (gnus-Group-update-group group
)
1294 ;; Adjust cursor point.
1296 (search-forward ":" nil t
))
1297 ((and (stringp group
)
1298 (gnus-gethash group gnus-active-hashtb
))
1299 ;; Add new newsgroup.
1300 (gnus-add-newsgroup group
)
1301 (gnus-Group-update-group group
)
1302 ;; Adjust cursor point.
1304 (search-forward ":" nil t
))
1305 (t (error "No such newsgroup: %s" group
)))
1308 (defun gnus-Group-list-all-groups ()
1309 "List all of newsgroups in the Newsgroup buffer."
1311 (gnus-Group-list-groups t
))
1313 (defun gnus-Group-get-new-news ()
1314 "Get newly arrived articles. In fact, read the active file again."
1316 (gnus-setup-news-info)
1317 (gnus-Group-list-groups gnus-have-all-newsgroups
))
1319 (defun gnus-Group-restart ()
1320 "Force GNUS to read the raw startup file."
1322 (gnus-save-newsrc-file)
1323 (gnus-setup-news-info t
) ;Force to read the raw startup file.
1324 (gnus-Group-list-groups gnus-have-all-newsgroups
))
1326 (defun gnus-Group-check-bogus-groups ()
1327 "Check bogus newsgroups."
1329 (gnus-check-bogus-newsgroups t
) ;Require confirmation.
1330 (gnus-Group-list-groups gnus-have-all-newsgroups
))
1332 (defun gnus-Group-restrict-groups (start end
)
1333 "Restrict visible newsgroups to the current region (START and END).
1334 Type \\[widen] to remove restriction."
1337 (narrow-to-region (progn
1345 (message (substitute-command-keys "Type \\[widen] to remove restriction")))
1347 (defun gnus-Group-edit-global-kill ()
1348 "Edit a global KILL file."
1350 (setq gnus-current-kill-article nil
) ;No articles selected.
1351 (gnus-Kill-file-edit-file nil
) ;Nil stands for global KILL file.
1353 (substitute-command-keys
1354 "Editing a global KILL file (Type \\[gnus-Kill-file-exit] to exit)")))
1356 (defun gnus-Group-edit-local-kill ()
1357 "Edit a local KILL file."
1359 (setq gnus-current-kill-article nil
) ;No articles selected.
1360 (gnus-Kill-file-edit-file (gnus-Group-group-name))
1362 (substitute-command-keys
1363 "Editing a local KILL file (Type \\[gnus-Kill-file-exit] to exit)")))
1365 (defun gnus-Group-force-update ()
1366 "Update .newsrc file."
1368 (gnus-save-newsrc-file))
1370 (defun gnus-Group-suspend ()
1371 "Suspend the current GNUS session.
1372 In fact, cleanup buffers except for Group Mode buffer.
1373 The hook `gnus-Suspend-gnus-hook' is called before actually suspending."
1375 (run-hooks 'gnus-Suspend-gnus-hook
)
1376 ;; Kill GNUS buffers except for Group Mode buffer.
1377 (let ((buffers gnus-buffer-list
))
1379 (and (not (eq (car buffers
) gnus-Group-buffer
))
1380 (get-buffer (car buffers
))
1381 (kill-buffer (car buffers
)))
1382 (setq buffers
(cdr buffers
))
1386 (defun gnus-Group-exit ()
1387 "Quit reading news after updating .newsrc.
1388 The hook `gnus-Exit-gnus-hook' is called before actually quitting."
1390 (if (or noninteractive
;For gnus-batch-kill
1391 (zerop (buffer-size)) ;No news is good news.
1392 (not (gnus-server-opened)) ;NNTP connection closed.
1393 (y-or-n-p "Are you sure you want to quit reading news? "))
1395 (message "") ;Erase "Yes or No" question.
1396 (run-hooks 'gnus-Exit-gnus-hook
)
1397 (gnus-save-newsrc-file)
1399 (gnus-close-server))
1402 (defun gnus-Group-quit ()
1403 "Quit reading news without updating .newsrc.
1404 The hook `gnus-Exit-gnus-hook' is called before actually quitting."
1406 (if (or (zerop (buffer-size))
1407 (not (gnus-server-opened))
1409 (format "Quit reading news without saving %s? "
1410 (file-name-nondirectory gnus-current-startup-file
))))
1412 (message "") ;Erase "Yes or No" question.
1413 (run-hooks 'gnus-Exit-gnus-hook
)
1415 (gnus-close-server))
1418 (defun gnus-Group-describe-briefly ()
1419 "Describe Group mode commands briefly."
1423 (substitute-command-keys "\\[gnus-Group-read-group]:Select ")
1424 (substitute-command-keys "\\[gnus-Group-next-unread-group]:Forward ")
1425 (substitute-command-keys "\\[gnus-Group-prev-unread-group]:Backward ")
1426 (substitute-command-keys "\\[gnus-Group-exit]:Exit ")
1427 (substitute-command-keys "\\[gnus-Info-find-node]:Run Info ")
1428 (substitute-command-keys "\\[gnus-Group-describe-briefly]:This help")
1433 ;;; GNUS Subject Mode
1436 (if gnus-Subject-mode-map
1438 (setq gnus-Subject-mode-map
(make-keymap))
1439 (suppress-keymap gnus-Subject-mode-map
)
1440 (define-key gnus-Subject-mode-map
" " 'gnus-Subject-next-page
)
1441 (define-key gnus-Subject-mode-map
"\177" 'gnus-Subject-prev-page
)
1442 (define-key gnus-Subject-mode-map
"\r" 'gnus-Subject-scroll-up
)
1443 (define-key gnus-Subject-mode-map
"n" 'gnus-Subject-next-unread-article
)
1444 (define-key gnus-Subject-mode-map
"p" 'gnus-Subject-prev-unread-article
)
1445 (define-key gnus-Subject-mode-map
"N" 'gnus-Subject-next-article
)
1446 (define-key gnus-Subject-mode-map
"P" 'gnus-Subject-prev-article
)
1447 (define-key gnus-Subject-mode-map
"\e\C-n" 'gnus-Subject-next-same-subject
)
1448 (define-key gnus-Subject-mode-map
"\e\C-p" 'gnus-Subject-prev-same-subject
)
1449 ;;(define-key gnus-Subject-mode-map "\e\C-n" 'gnus-Subject-next-unread-same-subject)
1450 ;;(define-key gnus-Subject-mode-map "\e\C-p" 'gnus-Subject-prev-unread-same-subject)
1451 (define-key gnus-Subject-mode-map
"\C-c\C-n" 'gnus-Subject-next-digest
)
1452 (define-key gnus-Subject-mode-map
"\C-c\C-p" 'gnus-Subject-prev-digest
)
1453 (define-key gnus-Subject-mode-map
"\C-n" 'gnus-Subject-next-subject
)
1454 (define-key gnus-Subject-mode-map
"\C-p" 'gnus-Subject-prev-subject
)
1455 (define-key gnus-Subject-mode-map
"\en" 'gnus-Subject-next-unread-subject
)
1456 (define-key gnus-Subject-mode-map
"\ep" 'gnus-Subject-prev-unread-subject
)
1457 ;;(define-key gnus-Subject-mode-map "\C-cn" 'gnus-Subject-next-group)
1458 ;;(define-key gnus-Subject-mode-map "\C-cp" 'gnus-Subject-prev-group)
1459 (define-key gnus-Subject-mode-map
"." 'gnus-Subject-first-unread-article
)
1460 (define-key gnus-Subject-mode-map
"/" 'isearch-forward
)
1461 (define-key gnus-Subject-mode-map
"s" 'gnus-Subject-isearch-article
)
1462 (define-key gnus-Subject-mode-map
"\es" 'gnus-Subject-search-article-forward
)
1463 (define-key gnus-Subject-mode-map
"\eS" 'gnus-Subject-search-article-backward
)
1464 (define-key gnus-Subject-mode-map
"<" 'gnus-Subject-beginning-of-article
)
1465 (define-key gnus-Subject-mode-map
">" 'gnus-Subject-end-of-article
)
1466 (define-key gnus-Subject-mode-map
"j" 'gnus-Subject-goto-subject
)
1467 (define-key gnus-Subject-mode-map
"J" 'gnus-Subject-goto-article
)
1468 (define-key gnus-Subject-mode-map
"l" 'gnus-Subject-goto-last-article
)
1469 (define-key gnus-Subject-mode-map
"^" 'gnus-Subject-refer-parent-article
)
1470 (define-key gnus-Subject-mode-map
"\er" 'gnus-Subject-refer-article
)
1471 (define-key gnus-Subject-mode-map
"u" 'gnus-Subject-mark-as-unread-forward
)
1472 (define-key gnus-Subject-mode-map
"U" 'gnus-Subject-mark-as-unread-backward
)
1473 (define-key gnus-Subject-mode-map
"d" 'gnus-Subject-mark-as-read-forward
)
1474 (define-key gnus-Subject-mode-map
"D" 'gnus-Subject-mark-as-read-backward
)
1475 (define-key gnus-Subject-mode-map
"\eu" 'gnus-Subject-clear-mark-forward
)
1476 (define-key gnus-Subject-mode-map
"\eU" 'gnus-Subject-clear-mark-backward
)
1477 (define-key gnus-Subject-mode-map
"k" 'gnus-Subject-kill-same-subject-and-select
)
1478 (define-key gnus-Subject-mode-map
"\C-k" 'gnus-Subject-kill-same-subject
)
1479 (define-key gnus-Subject-mode-map
"\e\C-t" 'gnus-Subject-toggle-threads
)
1480 (define-key gnus-Subject-mode-map
"\e\C-s" 'gnus-Subject-show-thread
)
1481 (define-key gnus-Subject-mode-map
"\e\C-h" 'gnus-Subject-hide-thread
)
1482 (define-key gnus-Subject-mode-map
"\e\C-f" 'gnus-Subject-next-thread
)
1483 (define-key gnus-Subject-mode-map
"\e\C-b" 'gnus-Subject-prev-thread
)
1484 (define-key gnus-Subject-mode-map
"\e\C-u" 'gnus-Subject-up-thread
)
1485 (define-key gnus-Subject-mode-map
"\e\C-d" 'gnus-Subject-down-thread
)
1486 (define-key gnus-Subject-mode-map
"\e\C-k" 'gnus-Subject-kill-thread
)
1487 (define-key gnus-Subject-mode-map
"&" 'gnus-Subject-execute-command
)
1488 ;;(define-key gnus-Subject-mode-map "c" 'gnus-Subject-catch-up)
1489 ;;(define-key gnus-Subject-mode-map "c" 'gnus-Subject-catch-up-all)
1490 (define-key gnus-Subject-mode-map
"c" 'gnus-Subject-catch-up-and-exit
)
1491 ;;(define-key gnus-Subject-mode-map "c" 'gnus-Subject-catch-up-all-and-exit)
1492 (define-key gnus-Subject-mode-map
"\C-t" 'gnus-Subject-toggle-truncation
)
1493 (define-key gnus-Subject-mode-map
"x" 'gnus-Subject-delete-marked-as-read
)
1494 (define-key gnus-Subject-mode-map
"X" 'gnus-Subject-delete-marked-with
)
1495 (define-key gnus-Subject-mode-map
"\C-c\C-sn" 'gnus-Subject-sort-by-number
)
1496 (define-key gnus-Subject-mode-map
"\C-c\C-sa" 'gnus-Subject-sort-by-author
)
1497 (define-key gnus-Subject-mode-map
"\C-c\C-ss" 'gnus-Subject-sort-by-subject
)
1498 (define-key gnus-Subject-mode-map
"\C-c\C-sd" 'gnus-Subject-sort-by-date
)
1499 (define-key gnus-Subject-mode-map
"\C-c\C-s\C-n" 'gnus-Subject-sort-by-number
)
1500 (define-key gnus-Subject-mode-map
"\C-c\C-s\C-a" 'gnus-Subject-sort-by-author
)
1501 (define-key gnus-Subject-mode-map
"\C-c\C-s\C-s" 'gnus-Subject-sort-by-subject
)
1502 (define-key gnus-Subject-mode-map
"\C-c\C-s\C-d" 'gnus-Subject-sort-by-date
)
1503 (define-key gnus-Subject-mode-map
"=" 'gnus-Subject-expand-window
)
1504 (define-key gnus-Subject-mode-map
"G" 'gnus-Subject-reselect-current-group
)
1505 (define-key gnus-Subject-mode-map
"w" 'gnus-Subject-stop-page-breaking
)
1506 (define-key gnus-Subject-mode-map
"\C-c\C-r" 'gnus-Subject-caesar-message
)
1507 (define-key gnus-Subject-mode-map
"g" 'gnus-Subject-show-article
)
1508 (define-key gnus-Subject-mode-map
"t" 'gnus-Subject-toggle-header
)
1509 (define-key gnus-Subject-mode-map
"v" 'gnus-Subject-show-all-headers
)
1510 (define-key gnus-Subject-mode-map
"\C-d" 'gnus-Subject-rmail-digest
)
1511 (define-key gnus-Subject-mode-map
"a" 'gnus-Subject-post-news
)
1512 (define-key gnus-Subject-mode-map
"f" 'gnus-Subject-post-reply
)
1513 (define-key gnus-Subject-mode-map
"F" 'gnus-Subject-post-reply-with-original
)
1514 (define-key gnus-Subject-mode-map
"C" 'gnus-Subject-cancel-article
)
1515 (define-key gnus-Subject-mode-map
"r" 'gnus-Subject-mail-reply
)
1516 (define-key gnus-Subject-mode-map
"R" 'gnus-Subject-mail-reply-with-original
)
1517 (define-key gnus-Subject-mode-map
"m" 'gnus-Subject-mail-other-window
)
1518 (define-key gnus-Subject-mode-map
"o" 'gnus-Subject-save-article
)
1519 (define-key gnus-Subject-mode-map
"\C-o" 'gnus-Subject-save-in-mail
)
1520 (define-key gnus-Subject-mode-map
"|" 'gnus-Subject-pipe-output
)
1521 (define-key gnus-Subject-mode-map
"\ek" 'gnus-Subject-edit-local-kill
)
1522 (define-key gnus-Subject-mode-map
"\eK" 'gnus-Subject-edit-global-kill
)
1523 (define-key gnus-Subject-mode-map
"V" 'gnus-version
)
1524 (define-key gnus-Subject-mode-map
"q" 'gnus-Subject-exit
)
1525 (define-key gnus-Subject-mode-map
"Q" 'gnus-Subject-quit
)
1526 (define-key gnus-Subject-mode-map
"?" 'gnus-Subject-describe-briefly
)
1527 (define-key gnus-Subject-mode-map
"\C-c\C-i" 'gnus-Info-find-node
))
1529 (defun gnus-Subject-mode ()
1530 "Major mode for reading articles in this newsgroup.
1531 All normal editing commands are turned off.
1532 Instead, these commands are available:
1533 \\{gnus-Subject-mode-map}
1535 User customizable variables:
1536 gnus-large-newsgroup
1537 The number of articles which indicates a large newsgroup. If the
1538 number of articles in a newsgroup is greater than the value, the
1539 number of articles to be selected is asked for. If the given value
1540 N is positive, the last N articles is selected. If N is negative,
1541 the first N articles are selected. An empty string means to select
1544 gnus-use-long-file-name
1545 Non-nil means that a newsgroup name is used as a default file name
1546 to save articles to. If it's nil, the directory form of a
1547 newsgroup is used instead.
1549 gnus-default-article-saver
1550 Specifies your favorite article saver which is interactively
1551 funcallable. Following functions are available:
1553 gnus-Subject-save-in-rmail (in Rmail format)
1554 gnus-Subject-save-in-mail (in Unix mail format)
1555 gnus-Subject-save-in-folder (in MH folder)
1556 gnus-Subject-save-in-file (in article format).
1558 gnus-rmail-save-name
1560 gnus-folder-save-name
1562 Specifies a function generating a file name to save articles in
1563 specified format. The function is called with NEWSGROUP, HEADERS,
1564 and optional LAST-FILE. Access macros to the headers are defined
1565 as nntp-header-FIELD, and functions are defined as `gnus-header-FIELD'.
1567 gnus-article-save-directory
1568 Specifies a directory name to save articles to using the commands
1569 `gnus-Subject-save-in-rmail', `gnus-Subject-save-in-mail' and
1570 `gnus-Subject-save-in-file'. The variable is initialized from the
1571 SAVEDIR environment variable.
1573 gnus-show-all-headers
1574 Non-nil means that all headers of an article are shown.
1576 gnus-save-all-headers
1577 Non-nil means that all headers of an article are saved in a file.
1580 Non-nil means that conversation threads are shown in tree structure.
1582 gnus-thread-hide-subject
1583 Non-nil means that subjects for thread subtrees are hidden.
1585 gnus-thread-hide-subtree
1586 Non-nil means that thread subtrees are hidden initially.
1588 gnus-thread-hide-killed
1589 Non-nil means that killed thread subtrees are hidden automatically.
1591 gnus-thread-ignore-subject
1592 Non-nil means that subject differences are ignored in constructing
1595 gnus-thread-indent-level
1596 Indentation of thread subtrees.
1598 gnus-optional-headers
1599 Specifies a function which generates an optional string displayed
1600 in the Subject buffer. The function is called with an article
1601 HEADERS. The result must be a string excluding `[' and `]'. The
1602 default function returns a string like NNN:AUTHOR, where NNN is
1603 the number of lines in an article and AUTHOR is the name of the
1606 gnus-auto-extend-newsgroup
1607 Non-nil means visible articles are extended to forward and
1608 backward automatically if possible.
1610 gnus-auto-select-first
1611 Non-nil means the first unread article is selected automagically
1612 when a newsgroup is selected normally (by gnus-Group-read-group).
1613 If you'd like to prevent automatic selection of the first unread
1614 article in some newsgroups, set the variable to nil in
1615 gnus-Select-group-hook or gnus-Apply-kill-hook.
1617 gnus-auto-select-next
1618 Non-nil means the next newsgroup is selected automagically at the
1619 end of the newsgroup. If the value is t and the next newsgroup is
1620 empty (no unread articles), GNUS will exit Subject mode and go
1621 back to Group mode. If the value is neither nil nor t, GNUS won't
1622 exit Subject mode but select the following unread newsgroup.
1623 Especially, if the value is the symbol `quietly', the next unread
1624 newsgroup will be selected without any confirmations.
1626 gnus-auto-select-same
1627 Non-nil means an article with the same subject as the current
1628 article is selected automagically like `rn -S'.
1630 gnus-auto-center-subject
1631 Non-nil means the point of Subject Mode window is always kept
1635 Non-nil means an article is broken into pages at page delimiters.
1636 This may not work with some versions of GNU Emacs earlier than
1640 Specifies a regexp describing line-beginnings that separate pages
1643 [gnus-more-message is obsolete. overlay-arrow-string interfares
1644 with other subsystems, such as dbx mode.]
1646 gnus-digest-show-summary
1647 Non-nil means that a summary of digest messages is shown when
1648 reading a digest article using `gnus-Subject-rmail-digest' command.
1650 gnus-digest-separator
1651 Specifies a regexp separating messages in a digest article.
1653 gnus-mail-reply-method
1654 gnus-mail-other-window-method
1655 Specifies a function to begin composing mail message using
1656 commands gnus-Subject-mail-reply and
1657 gnus-Subject-mail-other-window. Functions
1658 gnus-mail-reply-using-mail and gnus-mail-reply-using-mhe are
1659 available for the value of gnus-mail-reply-method. And functions
1660 gnus-mail-other-window-using-mail and
1661 gnus-mail-other-window-using-mhe are available for the value of
1662 gnus-mail-other-window-method.
1664 Various hooks for customization:
1665 gnus-Subject-mode-hook
1666 Entry to this mode calls the value with no arguments, if that
1669 gnus-Select-group-hook
1670 Called with no arguments when newsgroup is selected, if that value
1671 is non-nil. It is possible to sort subjects in this hook. See the
1672 documentation of this variable for more information.
1674 gnus-Subject-prepare-hook
1675 Called with no arguments after a subject list is created in the
1676 Subject buffer, if that value is non-nil. If you'd like to modify
1677 the buffer, you can use this hook.
1679 gnus-Select-article-hook
1680 Called with no arguments when an article is selected, if that
1681 value is non-nil. See the documentation of this variable for
1684 gnus-Select-digest-hook
1685 Called with no arguments when reading digest messages using Rmail,
1686 if that value is non-nil. This hook can be used to modify an
1687 article so that Rmail can work with it. See the documentation of
1688 the variable for more information.
1690 gnus-Rmail-digest-hook
1691 Called with no arguments when reading digest messages using Rmail,
1692 if that value is non-nil. This hook is intended to customize Rmail
1695 gnus-Apply-kill-hook
1696 Called with no arguments when a newsgroup is selected and the
1697 Subject buffer is prepared. This hook is intended to apply a KILL
1698 file to the selected newsgroup. The format of KILL file is
1699 completely different from that of version 3.8. You have to rewrite
1700 them in the new format. See the documentation of Kill file mode
1701 for more information.
1703 gnus-Mark-article-hook
1704 Called with no arguments when an article is selected at the first
1705 time. The hook is intended to mark an article as read (or unread)
1706 automatically when it is selected. See the documentation of the
1707 variable for more information.
1709 gnus-Exit-group-hook
1710 Called with no arguments when exiting the current newsgroup, if
1711 that value is non-nil. If your machine is so slow that exiting
1712 from Subject mode takes very long time, inhibit marking articles
1713 as read using cross-references by setting the variable
1714 `gnus-newsgroup-headers' to nil in this hook."
1716 (kill-all-local-variables)
1717 ;; Gee. Why don't you upgrade?
1718 (cond ((boundp 'mode-line-modified
)
1719 (setq mode-line-modified
"--- "))
1720 ((listp (default-value 'mode-line-format
))
1721 (setq mode-line-format
1722 (cons "--- " (cdr (default-value 'mode-line-format
))))))
1723 (make-local-variable 'global-mode-string
)
1724 (setq global-mode-string nil
)
1725 (setq major-mode
'gnus-Subject-mode
)
1726 (setq mode-name
"Subject")
1727 ;;(setq mode-line-process '(" " gnus-newsgroup-name))
1728 (make-local-variable 'minor-mode-alist
)
1729 (or (assq 'gnus-show-threads minor-mode-alist
)
1730 (setq minor-mode-alist
1731 (cons (list 'gnus-show-threads
" Thread") minor-mode-alist
)))
1732 (gnus-Subject-set-mode-line)
1733 (use-local-map gnus-Subject-mode-map
)
1734 (buffer-flush-undo (current-buffer))
1735 (setq buffer-read-only t
) ;Disable modification
1736 (setq truncate-lines t
) ;Stop line folding
1737 (setq selective-display t
)
1738 (setq selective-display-ellipses t
) ;Display `...'
1739 ;;(setq case-fold-search t)
1740 (run-hooks 'gnus-Subject-mode-hook
))
1742 (defun gnus-Subject-setup-buffer ()
1743 "Initialize subject display buffer."
1744 (if (get-buffer gnus-Subject-buffer
)
1745 (set-buffer gnus-Subject-buffer
)
1746 (set-buffer (get-buffer-create gnus-Subject-buffer
))
1750 (defun gnus-Subject-read-group (group &optional show-all no-article
)
1751 "Start reading news in newsgroup GROUP.
1752 If optional first argument SHOW-ALL is non-nil, already read articles are
1754 If optional second argument NO-ARTICLE is non-nil, no article is selected
1756 (message "Retrieving newsgroup: %s..." group
)
1757 (if (gnus-select-newsgroup group show-all
)
1759 ;; Don't switch-to-buffer to prevent displaying old contents
1760 ;; of the buffer until new subjects list is created.
1761 ;; Suggested by Juha Heinanen <jh@tut.fi>
1762 (gnus-Subject-setup-buffer)
1763 ;; You can change the order of subjects in this hook.
1764 (run-hooks 'gnus-Select-group-hook
)
1765 (gnus-Subject-prepare)
1766 ;; Function `gnus-apply-kill-file' must be called in this hook.
1767 (run-hooks 'gnus-Apply-kill-hook
)
1768 (if (zerop (buffer-size))
1769 ;; This newsgroup is empty.
1771 (gnus-Subject-catch-up-and-exit nil t
) ;Without confirmations.
1772 (message "No unread news"))
1773 ;; Hide conversation thread subtrees. We cannot do this in
1774 ;; gnus-Subject-prepare-hook since kill processing may not
1775 ;; work with hidden articles.
1776 (and gnus-show-threads
1777 gnus-thread-hide-subtree
1778 (gnus-Subject-hide-all-threads))
1779 ;; Show first unread article if requested.
1780 (goto-char (point-min))
1781 (if (and (not no-article
)
1782 gnus-auto-select-first
1783 (gnus-Subject-first-unread-article))
1784 ;; Window is configured automatically.
1785 ;; Current buffer may be changed as a result of hook
1786 ;; evaluation, especially by gnus-Subject-rmail-digest
1787 ;; command, so we should adjust cursor point carefully.
1788 (if (eq (current-buffer) (get-buffer gnus-Subject-buffer
))
1790 ;; Adjust cursor point.
1792 (search-forward ":" nil t
)))
1793 (gnus-configure-windows 'SelectNewsgroup
)
1794 (pop-to-buffer gnus-Subject-buffer
)
1795 (gnus-Subject-set-mode-line)
1796 ;; I sometime get confused with the old Article buffer.
1797 (if (get-buffer gnus-Article-buffer
)
1798 (if (get-buffer-window gnus-Article-buffer
)
1800 (set-buffer gnus-Article-buffer
)
1801 (let ((buffer-read-only nil
))
1803 (kill-buffer gnus-Article-buffer
)))
1804 ;; Adjust cursor point.
1806 (search-forward ":" nil t
))
1808 ;; Cannot select newsgroup GROUP.
1809 (if (gnus-gethash group gnus-active-hashtb
)
1811 ;; If NNTP is used, nntp_access file may not be installed
1812 ;; properly. Otherwise, may be active file problem.
1814 (message "Cannot select %s. May be security or active file problem." group
)
1816 ;; Check bogus newsgroups.
1817 ;; We must be in Group Mode buffer.
1818 (gnus-Group-check-bogus-groups))
1821 (defun gnus-Subject-prepare ()
1822 "Prepare subject list of current newsgroup in Subject mode buffer."
1823 (let ((buffer-read-only nil
))
1824 ;; Note: The next codes are not actually used because the user who
1825 ;; want it can define them in gnus-Select-group-hook.
1826 ;; Print verbose messages if too many articles are selected.
1827 ;; (and (numberp gnus-large-newsgroup)
1828 ;; (> (length gnus-newsgroup-headers) gnus-large-newsgroup)
1829 ;; (message "Preparing headers..."))
1831 (gnus-Subject-prepare-threads
1832 (if gnus-show-threads
1833 (gnus-make-threads gnus-newsgroup-headers
)
1834 gnus-newsgroup-headers
) 0)
1835 ;; Erase header retrieval message.
1837 ;; Call hooks for modifying Subject mode buffer.
1838 ;; Suggested by sven@tde.LTH.Se (Sven Mattisson).
1839 (goto-char (point-min))
1840 (run-hooks 'gnus-Subject-prepare-hook
)
1843 ;; Basic ideas by Paul Dworkin <paul@media-lab.media.mit.edu>
1845 (defun gnus-Subject-prepare-threads (threads level
)
1846 "Prepare Subject buffer from THREADS and indentation LEVEL.
1847 THREADS is a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...]).'"
1851 ;; `M Indent NUM: [OPT] SUBJECT'
1852 (cntl (format "%%s %%s%%%dd: [%%s] %%s\n"
1853 (length (prin1-to-string gnus-newsgroup-end
)))))
1855 (setq thread
(car threads
))
1856 (setq threads
(cdr threads
))
1857 ;; If thread is a cons, hierarchical threads is given.
1858 ;; Otherwise, thread itself is header.
1860 (setq header
(car thread
))
1861 (setq header thread
))
1862 ;; Print valid header only.
1863 (if (vectorp header
) ;Depends on nntp.el.
1865 (setq number
(nntp-header-number header
))
1869 (cond ((memq number gnus-newsgroup-marked
) "-")
1870 ((memq number gnus-newsgroup-unreads
) " ")
1873 (make-string (* level gnus-thread-indent-level
) ?
)
1876 ;; Optional headers.
1877 (or (and gnus-optional-headers
1878 (funcall gnus-optional-headers header
)) "")
1879 ;; Its subject string.
1880 (concat (if (or (zerop level
)
1881 (not gnus-thread-hide-subject
))
1883 (make-string (window-width) ?
))
1884 (nntp-header-subject header
))
1887 ;; Print subthreads.
1890 (gnus-Subject-prepare-threads (cdr thread
) (1+ level
)))
1893 (defun gnus-Subject-set-mode-line ()
1894 "Set Subject mode line string."
1895 ;; The value must be a string to escape %-constructs.
1897 (if gnus-current-headers
1898 (nntp-header-subject gnus-current-headers
) gnus-newsgroup-name
)))
1899 (setq mode-line-buffer-identification
1902 ;; Enough spaces to pad subject to 17 positions.
1903 (make-string (max 0 (- 17 (length subject
))) ?
))))
1904 (set-buffer-modified-p t
))
1906 ;; GNUS Subject mode command.
1908 (defun gnus-Subject-search-group (&optional backward
)
1909 "Search for next unread newsgroup.
1910 If optional argument BACKWARD is non-nil, search backward instead."
1912 (set-buffer gnus-Group-buffer
)
1914 ;; We don't want to alter current point of Group mode buffer.
1915 (if (gnus-Group-search-forward backward nil
)
1916 (gnus-Group-group-name))
1919 (defun gnus-Subject-search-subject (backward unread subject
)
1920 "Search for article forward.
1921 If first argument BACKWARD is non-nil, search backward.
1922 If second argument UNREAD is non-nil, only unread article is selected.
1923 If third argument SUBJECT is non-nil, the article which has
1924 the same subject will be searched for."
1925 (let ((func (if backward
're-search-backward
're-search-forward
))
1927 ;; We have to take care of hidden lines.
1929 (format "^%s[ \t]+\\([0-9]+\\):.\\[[^]\r\n]*\\][ \t]+%s"
1930 ;;(if unread " " ".")
1931 (cond ((eq unread t
) " ") (unread "[ ---]") (t "."))
1933 (concat "\\([Rr][Ee]:[ \t]+\\)*"
1934 (regexp-quote (gnus-simplify-subject subject
))
1935 ;; Ignore words in parentheses.
1936 "\\([ \t]*([^\r\n]*)\\)*[ \t]*\\(\r\\|$\\)")
1942 (if (funcall func regexp nil t
)
1945 (buffer-substring (match-beginning 1) (match-end 1)))))
1946 ;; Adjust cursor point.
1948 (search-forward ":" nil t
)
1949 ;; This is the result.
1953 (defun gnus-Subject-search-forward (&optional unread subject
)
1954 "Search for article forward.
1955 If first optional argument UNREAD is non-nil, only unread article is selected.
1956 If second optional argument SUBJECT is non-nil, the article which has
1957 the same subject will be searched for."
1958 (gnus-Subject-search-subject nil unread subject
))
1960 (defun gnus-Subject-search-backward (&optional unread subject
)
1961 "Search for article backward.
1962 If first optional argument UNREAD is non-nil, only unread article is selected.
1963 If second optional argument SUBJECT is non-nil, the article which has
1964 the same subject will be searched for."
1965 (gnus-Subject-search-subject t unread subject
))
1967 (defun gnus-Subject-article-number ()
1968 "Article number around point. If nothing, return current number."
1971 (if (looking-at ".[ \t]+\\([0-9]+\\):")
1973 (buffer-substring (match-beginning 1) (match-end 1)))
1974 ;; If search fail, return current article number.
1975 gnus-current-article
1978 (defun gnus-Subject-subject-string ()
1979 "Return current subject string or nil if nothing."
1981 ;; It is possible to implement this function using
1982 ;; `gnus-Subject-article-number' and `gnus-newsgroup-headers'.
1984 ;; We have to take care of hidden lines.
1985 (if (looking-at ".[ \t]+[0-9]+:.\\[[^]\r\n]*\\][ \t]+\\([^\r\n]*\\)[\r\n]")
1986 (buffer-substring (match-beginning 1) (match-end 1)))
1989 (defun gnus-Subject-goto-subject (article)
1990 "Move point to ARTICLE's subject."
1994 (completing-read "Article number: "
1999 (int-to-string (nntp-header-number headers
)))))
2000 gnus-newsgroup-headers
)
2001 nil
'require-match
))))
2002 (let ((current (point)))
2003 (goto-char (point-min))
2004 (or (and article
(re-search-forward (format "^.[ \t]+%d:" article
) nil t
))
2005 (progn (goto-char current
) nil
))
2008 (defun gnus-Subject-recenter ()
2009 "Center point in Subject mode window."
2010 ;; Scroll window so as to cursor comes center of Subject mode window
2011 ;; only when article is displayed.
2012 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
2013 ;; Recenter only when requested.
2014 ;; Suggested by popovich@park.cs.columbia.edu
2015 (and gnus-auto-center-subject
2016 (get-buffer-window gnus-Article-buffer
)
2017 (< (/ (- (window-height) 1) 2)
2018 (count-lines (point) (point-max)))
2019 (recenter (/ (- (window-height) 2) 2))))
2021 ;; Walking around Group mode buffer.
2023 (defun gnus-Subject-jump-to-group (newsgroup)
2024 "Move point to NEWSGROUP in Group mode buffer."
2025 ;; Keep update point of Group mode buffer if visible.
2026 (if (eq (current-buffer)
2027 (get-buffer gnus-Group-buffer
))
2028 (save-window-excursion
2029 ;; Take care of tree window mode.
2030 (if (get-buffer-window gnus-Group-buffer
)
2031 (pop-to-buffer gnus-Group-buffer
))
2032 (gnus-Group-jump-to-group newsgroup
))
2034 ;; Take care of tree window mode.
2035 (if (get-buffer-window gnus-Group-buffer
)
2036 (pop-to-buffer gnus-Group-buffer
)
2037 (set-buffer gnus-Group-buffer
))
2038 (gnus-Group-jump-to-group newsgroup
))))
2040 (defun gnus-Subject-next-group (no-article)
2041 "Exit current newsgroup and then select next unread newsgroup.
2042 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
2044 ;; Make sure Group mode buffer point is on current newsgroup.
2045 (gnus-Subject-jump-to-group gnus-newsgroup-name
)
2046 (let ((group (gnus-Subject-search-group)))
2049 (message "Exiting %s..." gnus-newsgroup-name
)
2052 (message "Selecting %s..." group
)
2053 (gnus-Subject-exit t
) ;Exit Subject mode temporary.
2054 ;; We are now in Group mode buffer.
2055 ;; Make sure Group mode buffer point is on GROUP.
2056 (gnus-Subject-jump-to-group group
)
2057 (gnus-Subject-read-group group nil no-article
)
2058 (or (eq (current-buffer)
2059 (get-buffer gnus-Subject-buffer
))
2060 (eq gnus-auto-select-next t
)
2061 ;; Expected newsgroup has nothing to read since the articles
2062 ;; are marked as read by cross-referencing. So, try next
2063 ;; newsgroup. (Make sure we are in Group mode buffer now.)
2064 (and (eq (current-buffer)
2065 (get-buffer gnus-Group-buffer
))
2066 (gnus-Group-group-name)
2067 (gnus-Subject-read-group
2068 (gnus-Group-group-name) nil no-article
))
2072 (defun gnus-Subject-prev-group (no-article)
2073 "Exit current newsgroup and then select previous unread newsgroup.
2074 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
2076 ;; Make sure Group mode buffer point is on current newsgroup.
2077 (gnus-Subject-jump-to-group gnus-newsgroup-name
)
2078 (let ((group (gnus-Subject-search-group t
)))
2081 (message "Exiting %s..." gnus-newsgroup-name
)
2084 (message "Selecting %s..." group
)
2085 (gnus-Subject-exit t
) ;Exit Subject mode temporary.
2086 ;; We are now in Group mode buffer.
2087 ;; We have to adjust point of Group mode buffer because current
2088 ;; point is moved to next unread newsgroup by exiting.
2089 (gnus-Subject-jump-to-group group
)
2090 (gnus-Subject-read-group group nil no-article
)
2091 (or (eq (current-buffer)
2092 (get-buffer gnus-Subject-buffer
))
2093 (eq gnus-auto-select-next t
)
2094 ;; Expected newsgroup has nothing to read since the articles
2095 ;; are marked as read by cross-referencing. So, try next
2096 ;; newsgroup. (Make sure we are in Group mode buffer now.)
2097 (and (eq (current-buffer)
2098 (get-buffer gnus-Group-buffer
))
2099 (gnus-Subject-search-group t
)
2100 (gnus-Subject-read-group
2101 (gnus-Subject-search-group t
) nil no-article
))
2105 ;; Walking around subject lines.
2107 (defun gnus-Subject-next-subject (n &optional unread
)
2108 "Go to next N'th subject line.
2109 If optional argument UNREAD is non-nil, only unread article is selected."
2112 (gnus-Subject-search-forward unread
))
2114 (cond ((gnus-Subject-search-forward unread
)
2115 (gnus-Subject-recenter))
2117 (message "No more unread articles"))
2119 (message "No more articles"))
2122 (defun gnus-Subject-next-unread-subject (n)
2123 "Go to next N'th unread subject line."
2125 (gnus-Subject-next-subject n t
))
2127 (defun gnus-Subject-prev-subject (n &optional unread
)
2128 "Go to previous N'th subject line.
2129 If optional argument UNREAD is non-nil, only unread article is selected."
2132 (gnus-Subject-search-backward unread
))
2134 (cond ((gnus-Subject-search-backward unread
)
2135 (gnus-Subject-recenter))
2137 (message "No more unread articles"))
2139 (message "No more articles"))
2142 (defun gnus-Subject-prev-unread-subject (n)
2143 "Go to previous N'th unread subject line."
2145 (gnus-Subject-prev-subject n t
))
2147 ;; Walking around subject lines with displaying articles.
2149 (defun gnus-Subject-expand-window ()
2150 "Expand Subject window to show headers full window."
2152 (gnus-configure-windows 'ExpandSubject
)
2153 (pop-to-buffer gnus-Subject-buffer
))
2155 (defun gnus-Subject-display-article (article &optional all-header
)
2156 "Display ARTICLE in Article buffer."
2159 (gnus-configure-windows 'SelectArticle
)
2160 (pop-to-buffer gnus-Subject-buffer
)
2161 (gnus-Article-prepare article all-header
)
2162 (gnus-Subject-recenter)
2163 (gnus-Subject-set-mode-line)
2164 (run-hooks 'gnus-Select-article-hook
)
2165 ;; Successfully display article.
2169 (defun gnus-Subject-select-article (&optional all-headers force
)
2170 "Select the current article.
2171 Optional argument ALL-HEADERS is non-nil, show all headers."
2172 (let ((article (gnus-Subject-article-number)))
2173 (if (or (null gnus-current-article
)
2174 (/= article gnus-current-article
)
2175 (and force
(not (eq all-headers gnus-have-all-headers
))))
2176 ;; The selected subject is different from that of the current article.
2177 (gnus-Subject-display-article article all-headers
)
2178 (gnus-configure-windows 'SelectArticle
)
2179 (pop-to-buffer gnus-Subject-buffer
))
2182 (defun gnus-Subject-set-current-mark (&optional current-mark
)
2183 "Put `+' at the current article.
2184 Optional argument specifies CURRENT-MARK instead of `+'."
2186 (set-buffer gnus-Subject-buffer
)
2187 (let ((buffer-read-only nil
))
2188 (goto-char (point-min))
2189 ;; First of all clear mark at last article.
2190 (if (re-search-forward "^.[ \t]+[0-9]+:[^ \t]" nil t
)
2194 (goto-char (point-min))))
2195 (if (re-search-forward (format "^.[ \t]+%d:" gnus-current-article
) nil t
)
2198 (insert (or current-mark
"+"))))
2201 (defun gnus-Subject-next-article (unread &optional subject
)
2202 "Select article after current one.
2203 If argument UNREAD is non-nil, only unread article is selected."
2206 (cond ((gnus-Subject-display-article
2207 (gnus-Subject-search-forward unread subject
)))
2209 gnus-auto-select-same
2210 (gnus-set-difference gnus-newsgroup-unreads
2211 gnus-newsgroup-marked
)
2213 '(gnus-Subject-next-unread-article
2214 gnus-Subject-next-page
2215 gnus-Subject-kill-same-subject-and-select
2216 ;;gnus-Subject-next-article
2217 ;;gnus-Subject-next-same-subject
2218 ;;gnus-Subject-next-unread-same-subject
2220 ;; Wrap article pointer if there are unread articles.
2221 ;; Hook function, such as gnus-Subject-rmail-digest, may
2222 ;; change current buffer, so need check.
2223 (let ((buffer (current-buffer))
2224 (last-point (point)))
2225 ;; No more articles with same subject, so jump to the first
2227 (gnus-Subject-first-unread-article)
2228 ;;(and (eq buffer (current-buffer))
2229 ;; (= (point) last-point)
2230 ;; ;; Ignore given SUBJECT, and try again.
2231 ;; (gnus-Subject-next-article unread nil))
2232 (and (eq buffer
(current-buffer))
2233 (< (point) last-point
)
2234 (message "Wrapped"))
2237 gnus-auto-extend-newsgroup
2238 (setq header
(gnus-more-header-forward)))
2239 ;; Extend to next article if possible.
2240 ;; Basic ideas by himacdonald@watdragon.waterloo.edu
2241 (gnus-extend-newsgroup header nil
)
2242 ;; Threads feature must be turned off.
2243 (let ((buffer-read-only nil
))
2244 (goto-char (point-max))
2245 (gnus-Subject-prepare-threads (list header
) 0))
2246 (gnus-Subject-goto-article gnus-newsgroup-end
))
2248 ;; Select next newsgroup automatically if requested.
2249 (let ((cmd (string-to-char (this-command-keys)))
2250 (group (gnus-Subject-search-group))
2252 (and gnus-auto-select-next
2253 ;;(null (gnus-set-difference gnus-newsgroup-unreads
2254 ;; gnus-newsgroup-marked))
2256 '(gnus-Subject-next-unread-article
2257 gnus-Subject-next-article
2258 gnus-Subject-next-page
2259 gnus-Subject-next-same-subject
2260 gnus-Subject-next-unread-same-subject
2261 gnus-Subject-kill-same-subject
2262 gnus-Subject-kill-same-subject-and-select
2264 ;; Ignore characters typed ahead.
2265 (not (input-pending-p))
2267 (message "No more%s articles%s"
2268 (if unread
" unread" "")
2269 (if (and auto-select
2270 (not (eq gnus-auto-select-next
'quietly
)))
2272 (format " (Type %s to %s [%d])"
2273 (key-description (char-to-string cmd
))
2275 (nth 1 (gnus-gethash group
2276 gnus-unread-hashtb
)))
2277 (format " (Type %s to exit %s)"
2278 (key-description (char-to-string cmd
))
2282 ;; Select next unread newsgroup automagically.
2283 (cond ((and auto-select
2284 (eq gnus-auto-select-next
'quietly
))
2286 (gnus-Subject-next-group nil
))
2288 ;; Confirm auto selection.
2289 (let ((char (read-char)))
2291 (gnus-Subject-next-group nil
)
2292 (setq unread-command-char char
))))
2297 (defun gnus-Subject-next-unread-article ()
2298 "Select unread article after current one."
2300 (gnus-Subject-next-article t
(and gnus-auto-select-same
2301 (gnus-Subject-subject-string))))
2303 (defun gnus-Subject-prev-article (unread &optional subject
)
2304 "Select article before current one.
2305 If argument UNREAD is non-nil, only unread article is selected."
2308 (cond ((gnus-Subject-display-article
2309 (gnus-Subject-search-backward unread subject
)))
2311 gnus-auto-select-same
2312 (gnus-set-difference gnus-newsgroup-unreads
2313 gnus-newsgroup-marked
)
2315 '(gnus-Subject-prev-unread-article
2316 ;;gnus-Subject-prev-page
2317 ;;gnus-Subject-prev-article
2318 ;;gnus-Subject-prev-same-subject
2319 ;;gnus-Subject-prev-unread-same-subject
2321 ;; Ignore given SUBJECT, and try again.
2322 (gnus-Subject-prev-article unread nil
))
2324 (message "No more unread articles"))
2325 ((and gnus-auto-extend-newsgroup
2326 (setq header
(gnus-more-header-backward)))
2327 ;; Extend to previous article if possible.
2328 ;; Basic ideas by himacdonald@watdragon.waterloo.edu
2329 (gnus-extend-newsgroup header t
)
2330 (let ((buffer-read-only nil
))
2331 (goto-char (point-min))
2332 (gnus-Subject-prepare-threads (list header
) 0))
2333 (gnus-Subject-goto-article gnus-newsgroup-begin
))
2335 (message "No more articles"))
2338 (defun gnus-Subject-prev-unread-article ()
2339 "Select unred article before current one."
2341 (gnus-Subject-prev-article t
(and gnus-auto-select-same
2342 (gnus-Subject-subject-string))))
2344 (defun gnus-Subject-next-page (lines)
2345 "Show next page of selected article.
2346 If end of artile, select next article.
2347 Argument LINES specifies lines to be scrolled up."
2349 (let ((article (gnus-Subject-article-number))
2351 (if (or (null gnus-current-article
)
2352 (/= article gnus-current-article
))
2353 ;; Selected subject is different from current article's.
2354 (gnus-Subject-display-article article
)
2355 (gnus-configure-windows 'SelectArticle
)
2356 (pop-to-buffer gnus-Subject-buffer
)
2357 (gnus-eval-in-buffer-window gnus-Article-buffer
2358 (setq endp
(gnus-Article-next-page lines
)))
2359 (cond ((and endp lines
)
2360 (message "End of message"))
2361 ((and endp
(null lines
))
2362 (gnus-Subject-next-unread-article)))
2365 (defun gnus-Subject-prev-page (lines)
2366 "Show previous page of selected article.
2367 Argument LINES specifies lines to be scrolled down."
2369 (let ((article (gnus-Subject-article-number)))
2370 (if (or (null gnus-current-article
)
2371 (/= article gnus-current-article
))
2372 ;; Selected subject is different from current article's.
2373 (gnus-Subject-display-article article
)
2374 (gnus-configure-windows 'SelectArticle
)
2375 (pop-to-buffer gnus-Subject-buffer
)
2376 (gnus-eval-in-buffer-window gnus-Article-buffer
2377 (gnus-Article-prev-page lines
))
2380 (defun gnus-Subject-scroll-up (lines)
2381 "Scroll up (or down) one line current article.
2382 Argument LINES specifies lines to be scrolled up (or down if negative)."
2384 (gnus-Subject-select-article)
2385 (gnus-eval-in-buffer-window gnus-Article-buffer
2387 (if (gnus-Article-next-page lines
)
2388 (message "End of message")))
2390 (gnus-Article-prev-page (- 0 lines
))))
2393 (defun gnus-Subject-next-same-subject ()
2394 "Select next article which has the same subject as current one."
2396 (gnus-Subject-next-article nil
(gnus-Subject-subject-string)))
2398 (defun gnus-Subject-prev-same-subject ()
2399 "Select previous article which has the same subject as current one."
2401 (gnus-Subject-prev-article nil
(gnus-Subject-subject-string)))
2403 (defun gnus-Subject-next-unread-same-subject ()
2404 "Select next unread article which has the same subject as current one."
2406 (gnus-Subject-next-article t
(gnus-Subject-subject-string)))
2408 (defun gnus-Subject-prev-unread-same-subject ()
2409 "Select previous unread article which has the same subject as current one."
2411 (gnus-Subject-prev-article t
(gnus-Subject-subject-string)))
2413 (defun gnus-Subject-refer-parent-article (child)
2414 "Refer parent article of current article.
2415 If a prefix argument CHILD is non-nil, go back to the child article
2416 using internally maintained articles history.
2417 NOTE: This command may not work with nnspool.el."
2419 (gnus-Subject-select-article t t
) ;Request all headers.
2420 (let ((referenced-id nil
)) ;Message-id of parent or child article.
2422 ;; Go back to child article using history.
2423 (gnus-Subject-refer-article nil
)
2424 (gnus-eval-in-buffer-window gnus-Article-buffer
2425 ;; Look for parent Message-ID.
2426 ;; We cannot use gnus-current-headers to get references
2427 ;; because we may be looking at parent or refered article.
2428 (let ((references (gnus-fetch-field "References")))
2429 ;; Get the last message-id in the references.
2431 (string-match "\\(<[^<>]+>\\)[^>]*\\'" references
)
2433 (substring references
2434 (match-beginning 1) (match-end 1))))
2436 (if (stringp referenced-id
)
2437 (gnus-Subject-refer-article referenced-id
)
2438 (error "No more parents"))
2441 (defun gnus-Subject-refer-article (message-id)
2442 "Refer article specified by MESSAGE-ID.
2443 If MESSAGE-ID is nil or an empty string, it is popped from an
2444 internally maintained articles history.
2445 NOTE: This command may not work with nnspool.el."
2446 (interactive "sMessage-ID: ")
2447 ;; Make sure that this command depends on the fact that article
2448 ;; related information is not updated when an article is retrieved
2450 (gnus-Subject-select-article t t
) ;Request all headers.
2451 (if (and (stringp message-id
)
2452 (> (length message-id
) 0))
2453 (gnus-eval-in-buffer-window gnus-Article-buffer
2454 ;; Construct the correct Message-ID if necessary.
2455 ;; Suggested by tale@pawl.rpi.edu.
2456 (or (string-match "^<" message-id
)
2457 (setq message-id
(concat "<" message-id
)))
2458 (or (string-match ">$" message-id
)
2459 (setq message-id
(concat message-id
">")))
2460 ;; Push current message-id on history.
2461 ;; We cannot use gnus-current-headers to get current
2462 ;; message-id because we may be looking at parent or refered
2464 (let ((current (gnus-fetch-field "Message-ID")))
2465 (or (equal current message-id
) ;Nothing to do.
2466 (equal current
(car gnus-current-history
))
2467 (setq gnus-current-history
2468 (cons current gnus-current-history
)))
2470 ;; Pop message-id from history.
2471 (setq message-id
(car gnus-current-history
))
2472 (setq gnus-current-history
(cdr gnus-current-history
)))
2473 (if (stringp message-id
)
2474 ;; Retrieve article by message-id. This may not work with nnspool.
2475 (gnus-Article-prepare message-id t
)
2476 (error "No such references"))
2479 (defun gnus-Subject-next-digest (nth)
2480 "Move to head of NTH next digested message."
2482 (gnus-Subject-select-article)
2483 (gnus-eval-in-buffer-window gnus-Article-buffer
2484 (gnus-Article-next-digest (or nth
1))
2487 (defun gnus-Subject-prev-digest (nth)
2488 "Move to head of NTH previous digested message."
2490 (gnus-Subject-select-article)
2491 (gnus-eval-in-buffer-window gnus-Article-buffer
2492 (gnus-Article-prev-digest (or nth
1))
2495 (defun gnus-Subject-first-unread-article ()
2496 "Select first unread article. Return non-nil if successfully selected."
2498 (let ((begin (point)))
2499 (goto-char (point-min))
2500 (if (re-search-forward "^ [ \t]+[0-9]+:" nil t
)
2501 (gnus-Subject-display-article (gnus-Subject-article-number))
2502 ;; If there is no unread articles, stay there.
2504 ;;(gnus-Subject-display-article (gnus-Subject-article-number))
2505 (message "No more unread articles")
2510 (defun gnus-Subject-isearch-article ()
2511 "Do incremental search forward on current article."
2513 (gnus-Subject-select-article)
2514 (gnus-eval-in-buffer-window gnus-Article-buffer
2515 (call-interactively 'isearch-forward
)
2518 (defun gnus-Subject-search-article-forward (regexp)
2519 "Search for an article containing REGEXP forward.
2520 `gnus-Select-article-hook' is not called during the search."
2523 (concat "Search forward (regexp): "
2524 (if gnus-last-search-regexp
2525 (concat "(default " gnus-last-search-regexp
") "))))))
2526 (if (string-equal regexp
"")
2527 (setq regexp
(or gnus-last-search-regexp
""))
2528 (setq gnus-last-search-regexp regexp
))
2529 (if (gnus-Subject-search-article regexp nil
)
2530 (gnus-eval-in-buffer-window gnus-Article-buffer
2534 (error "Search failed: \"%s\"" regexp
)
2537 (defun gnus-Subject-search-article-backward (regexp)
2538 "Search for an article containing REGEXP backward.
2539 `gnus-Select-article-hook' is not called during the search."
2542 (concat "Search backward (regexp): "
2543 (if gnus-last-search-regexp
2544 (concat "(default " gnus-last-search-regexp
") "))))))
2545 (if (string-equal regexp
"")
2546 (setq regexp
(or gnus-last-search-regexp
""))
2547 (setq gnus-last-search-regexp regexp
))
2548 (if (gnus-Subject-search-article regexp t
)
2549 (gnus-eval-in-buffer-window gnus-Article-buffer
2553 (error "Search failed: \"%s\"" regexp
)
2556 (defun gnus-Subject-search-article (regexp &optional backward
)
2557 "Search for an article containing REGEXP.
2558 Optional argument BACKWARD means do search for backward.
2559 `gnus-Select-article-hook' is not called during the search."
2560 (let ((gnus-Select-article-hook nil
) ;Disable hook.
2561 (gnus-Mark-article-hook nil
) ;Inhibit marking as read.
2564 (function re-search-backward
) (function re-search-forward
)))
2567 ;; Hidden thread subtrees must be searched for ,too.
2568 (gnus-Subject-show-all-threads)
2569 ;; First of all, search current article.
2570 ;; We don't want to read article again from NNTP server nor reset
2572 (gnus-Subject-select-article)
2573 (message "Searching article: %d..." gnus-current-article
)
2574 (setq last gnus-current-article
)
2575 (gnus-eval-in-buffer-window gnus-Article-buffer
2578 ;; Begin search from current point.
2579 (setq found
(funcall re-search regexp nil t
))))
2580 ;; Then search next articles.
2581 (while (and (not found
)
2582 (gnus-Subject-display-article
2583 (gnus-Subject-search-subject backward nil nil
)))
2584 (message "Searching article: %d..." gnus-current-article
)
2585 (gnus-eval-in-buffer-window gnus-Article-buffer
2588 (goto-char (if backward
(point-max) (point-min)))
2589 (setq found
(funcall re-search regexp nil t
)))
2592 ;; Adjust article pointer.
2593 (or (eq last gnus-current-article
)
2594 (setq gnus-last-article last
))
2595 ;; Return T if found such article.
2599 (defun gnus-Subject-execute-command (field regexp command
&optional backward
)
2600 "If FIELD of article header matches REGEXP, execute COMMAND string.
2601 If FIELD is an empty string (or nil), entire article body is searched for.
2602 If optional (prefix) argument BACKWARD is non-nil, do backward instead."
2604 (list (let ((completion-ignore-case t
))
2605 (completing-read "Field name: "
2606 '(("Number")("Subject")("From")
2607 ("Lines")("Date")("Id")
2608 ("Xref")("References"))
2609 nil
'require-match
))
2610 (read-string "Regexp: ")
2611 (read-key-sequence "Command: ")
2612 current-prefix-arg
))
2613 ;; Hidden thread subtrees must be searched for ,too.
2614 (gnus-Subject-show-all-threads)
2615 ;; We don't want to change current point nor window configuration.
2617 (save-window-excursion
2618 (message "Executing %s..." (key-description command
))
2619 ;; We'd like to execute COMMAND interactively so as to give arguments.
2620 (gnus-execute field regexp
2622 (call-interactively '(, (key-binding command
)))))
2624 (message "Executing %s... done" (key-description command
)))))
2626 (defun gnus-Subject-beginning-of-article ()
2627 "Go to beginning of article body"
2629 (gnus-Subject-select-article)
2630 (gnus-eval-in-buffer-window gnus-Article-buffer
2632 (beginning-of-buffer)
2633 (if gnus-break-pages
2634 (gnus-narrow-to-page))
2637 (defun gnus-Subject-end-of-article ()
2638 "Go to end of article body"
2640 (gnus-Subject-select-article)
2641 (gnus-eval-in-buffer-window gnus-Article-buffer
2644 (if gnus-break-pages
2645 (gnus-narrow-to-page))
2648 (defun gnus-Subject-goto-article (article &optional all-headers
)
2649 "Read ARTICLE if exists.
2650 Optional argument ALL-HEADERS means all headers are shown."
2654 (completing-read "Article number: "
2659 (int-to-string (nntp-header-number headers
)))))
2660 gnus-newsgroup-headers
)
2661 nil
'require-match
))))
2662 (if (gnus-Subject-goto-subject article
)
2663 (gnus-Subject-display-article article all-headers
)))
2665 (defun gnus-Subject-goto-last-article ()
2666 "Go to last subject line."
2668 (if gnus-last-article
2669 (gnus-Subject-goto-article gnus-last-article
)))
2671 (defun gnus-Subject-show-article ()
2672 "Force to show current article."
2674 ;; The following is a trick to force to read the current article again.
2675 (setq gnus-have-all-headers
(not gnus-have-all-headers
))
2676 (gnus-Subject-select-article (not gnus-have-all-headers
) t
))
2678 (defun gnus-Subject-toggle-header (arg)
2679 "Show original header if pruned header currently shown, or vice versa.
2680 With arg, show original header iff arg is positive."
2682 ;; Variable gnus-show-all-headers must be NIL to toggle really.
2683 (let ((gnus-show-all-headers nil
)
2685 (if (null arg
) (not gnus-have-all-headers
)
2686 (> (prefix-numeric-value arg
) 0))))
2687 (gnus-Subject-select-article all-headers t
)))
2689 (defun gnus-Subject-show-all-headers ()
2690 "Show original article header."
2692 (gnus-Subject-select-article t t
))
2694 (defun gnus-Subject-stop-page-breaking ()
2695 "Stop page breaking by linefeed temporary (Widen article buffer)."
2697 (gnus-Subject-select-article)
2698 (gnus-eval-in-buffer-window gnus-Article-buffer
2701 (defun gnus-Subject-kill-same-subject-and-select (unmark)
2702 "Mark articles which has the same subject as read, and then select next.
2703 If argument UNMARK is positive, remove any kinds of marks.
2704 If argument UNMARK is negative, mark articles as unread instead."
2707 (setq unmark
(prefix-numeric-value unmark
)))
2709 (gnus-Subject-mark-same-subject
2710 (gnus-Subject-subject-string) unmark
)))
2711 ;; Select next unread article. If auto-select-same mode, should
2712 ;; select the first unread article.
2713 (gnus-Subject-next-article t
(and gnus-auto-select-same
2714 (gnus-Subject-subject-string)))
2715 (message "%d articles are marked as %s"
2716 count
(if unmark
"unread" "read"))
2719 (defun gnus-Subject-kill-same-subject (unmark)
2720 "Mark articles which has the same subject as read.
2721 If argument UNMARK is positive, remove any kinds of marks.
2722 If argument UNMARK is negative, mark articles as unread instead."
2725 (setq unmark
(prefix-numeric-value unmark
)))
2727 (gnus-Subject-mark-same-subject
2728 (gnus-Subject-subject-string) unmark
)))
2729 ;; If marked as read, go to next unread subject.
2731 ;; Go to next unread subject.
2732 (gnus-Subject-next-subject 1 t
))
2733 (message "%d articles are marked as %s"
2734 count
(if unmark
"unread" "read"))
2737 (defun gnus-Subject-mark-same-subject (subject &optional unmark
)
2738 "Mark articles with same SUBJECT as read, and return marked number.
2739 If optional argument UNMARK is positive, remove any kinds of marks.
2740 If optional argument UNMARK is negative, mark articles as unread instead."
2743 (cond ((null unmark
)
2744 (gnus-Subject-mark-as-read nil
"K"))
2746 (gnus-Subject-mark-as-unread nil t
))
2748 (gnus-Subject-mark-as-unread)))
2750 (gnus-Subject-search-forward nil subject
))
2751 (cond ((null unmark
)
2752 (gnus-Subject-mark-as-read nil
"K"))
2754 (gnus-Subject-mark-as-unread nil t
))
2756 (gnus-Subject-mark-as-unread)))
2757 (setq count
(1+ count
))
2759 ;; Hide killed thread subtrees. Does not work properly always.
2760 ;;(and (null unmark)
2761 ;; gnus-thread-hide-killed
2762 ;; (gnus-Subject-hide-thread))
2763 ;; Return number of articles marked as read.
2767 (defun gnus-Subject-mark-as-unread-forward (count)
2768 "Mark current article as unread, and then go forward.
2769 Argument COUNT specifies number of articles marked as unread."
2772 (gnus-Subject-mark-as-unread nil nil
)
2773 (gnus-Subject-next-subject 1 nil
)
2774 (setq count
(1- count
))))
2776 (defun gnus-Subject-mark-as-unread-backward (count)
2777 "Mark current article as unread, and then go backward.
2778 Argument COUNT specifies number of articles marked as unread."
2781 (gnus-Subject-mark-as-unread nil nil
)
2782 (gnus-Subject-prev-subject 1 nil
)
2783 (setq count
(1- count
))))
2785 (defun gnus-Subject-mark-as-unread (&optional article clear-mark
)
2786 "Mark current article as unread.
2787 Optional first argument ARTICLE specifies article number to be
2788 marked as unread. Optional second argument CLEAR-MARK removes
2791 (set-buffer gnus-Subject-buffer
)
2792 ;; First of all, show hidden thread subtrees.
2793 (gnus-Subject-show-thread)
2794 (let* ((buffer-read-only nil
)
2795 (current (gnus-Subject-article-number))
2796 (article (or article current
)))
2797 (gnus-mark-article-as-unread article clear-mark
)
2798 (if (or (eq article current
)
2799 (gnus-Subject-goto-subject article
))
2803 (insert (if clear-mark
" " "-"))))
2806 (defun gnus-Subject-mark-as-read-forward (count)
2807 "Mark current article as read, and then go forward.
2808 Argument COUNT specifies number of articles marked as read"
2811 (gnus-Subject-mark-as-read)
2812 (gnus-Subject-next-subject 1 'unread-only
)
2813 (setq count
(1- count
))))
2815 (defun gnus-Subject-mark-as-read-backward (count)
2816 "Mark current article as read, and then go backward.
2817 Argument COUNT specifies number of articles marked as read"
2820 (gnus-Subject-mark-as-read)
2821 (gnus-Subject-prev-subject 1 'unread-only
)
2822 (setq count
(1- count
))))
2824 (defun gnus-Subject-mark-as-read (&optional article mark
)
2825 "Mark current article as read.
2826 Optional first argument ARTICLE specifies article number to be marked as read.
2827 Optional second argument MARK specifies a string inserted at beginning of line.
2828 Any kind of string (length 1) except for a space and `-' is ok."
2830 (set-buffer gnus-Subject-buffer
)
2831 ;; First of all, show hidden thread subtrees.
2832 (gnus-Subject-show-thread)
2833 (let* ((buffer-read-only nil
)
2834 (mark (or mark
"D")) ;Default mark is `D'.
2835 (current (gnus-Subject-article-number))
2836 (article (or article current
)))
2837 (gnus-mark-article-as-read article
)
2838 (if (or (eq article current
)
2839 (gnus-Subject-goto-subject article
))
2846 (defun gnus-Subject-clear-mark-forward (count)
2847 "Remove current article's mark, and go forward.
2848 Argument COUNT specifies number of articles unmarked"
2851 (gnus-Subject-mark-as-unread nil t
)
2852 (gnus-Subject-next-subject 1 nil
)
2853 (setq count
(1- count
))))
2855 (defun gnus-Subject-clear-mark-backward (count)
2856 "Remove current article's mark, and go backward.
2857 Argument COUNT specifies number of articles unmarked"
2860 (gnus-Subject-mark-as-unread nil t
)
2861 (gnus-Subject-prev-subject 1 nil
)
2862 (setq count
(1- count
))))
2864 (defun gnus-Subject-delete-marked-as-read ()
2865 "Delete lines which are marked as read."
2867 (if gnus-newsgroup-unreads
2868 (let ((buffer-read-only nil
))
2870 (goto-char (point-min))
2871 (delete-non-matching-lines "^[ ---]"))
2874 (gnus-Subject-prev-subject 1)
2876 (search-forward ":" nil t
)))
2877 ;; It is not so good idea to make the buffer empty.
2878 (message "All articles are marked as read")
2881 (defun gnus-Subject-delete-marked-with (marks)
2882 "Delete lines which are marked with MARKS (e.g. \"DK\")."
2883 (interactive "sMarks: ")
2884 (let ((buffer-read-only nil
))
2886 (goto-char (point-min))
2887 (delete-matching-lines (concat "^[" marks
"]")))
2889 (or (zerop (buffer-size))
2891 (gnus-Subject-prev-subject 1)
2893 (search-forward ":" nil t
)))
2896 ;; Thread-based commands.
2898 (defun gnus-Subject-toggle-threads (arg)
2899 "Toggle showing conversation threads.
2900 With arg, turn showing conversation threads on iff arg is positive."
2902 (let ((current (gnus-Subject-article-number)))
2903 (setq gnus-show-threads
2904 (if (null arg
) (not gnus-show-threads
)
2905 (> (prefix-numeric-value arg
) 0)))
2906 (gnus-Subject-prepare)
2907 (gnus-Subject-goto-subject current
)
2910 (defun gnus-Subject-show-all-threads ()
2911 "Show all thread subtrees."
2913 (if gnus-show-threads
2915 (let ((buffer-read-only nil
))
2916 (subst-char-in-region (point-min) (point-max) ?\^M ?
\n t
)
2919 (defun gnus-Subject-show-thread ()
2920 "Show thread subtrees."
2922 (if gnus-show-threads
2924 (let ((buffer-read-only nil
))
2925 (subst-char-in-region (progn
2926 (beginning-of-line) (point))
2928 (end-of-line) (point))
2932 (defun gnus-Subject-hide-all-threads ()
2933 "Hide all thread subtrees."
2935 (if gnus-show-threads
2937 ;; Adjust cursor point.
2938 (goto-char (point-min))
2939 (search-forward ":" nil t
)
2940 (let ((level (current-column)))
2941 (gnus-Subject-hide-thread)
2942 (while (gnus-Subject-search-forward)
2943 (and (>= level
(current-column))
2944 (gnus-Subject-hide-thread)))
2947 (defun gnus-Subject-hide-thread ()
2948 "Hide thread subtrees."
2950 (if gnus-show-threads
2952 ;; Adjust cursor point.
2954 (search-forward ":" nil t
)
2955 (let ((buffer-read-only nil
)
2958 (level (current-column)))
2959 (while (and (gnus-Subject-search-forward)
2960 (< level
(current-column)))
2961 ;; Interested in lower levels.
2962 (if (< level
(current-column))
2967 (subst-char-in-region init last ?
\n ?\^M t
)
2970 (defun gnus-Subject-next-thread (n)
2971 "Go to the same level next thread.
2972 Argument N specifies the number of threads."
2974 ;; Adjust cursor point.
2976 (search-forward ":" nil t
)
2977 (let ((init (point))
2979 (level (current-column)))
2981 (gnus-Subject-search-forward)
2982 (<= level
(current-column)))
2983 ;; We have to skip lower levels.
2984 (if (= level
(current-column))
2990 ;; Return non-nil if successfully move to the next.
2991 (prog1 (not (= init last
))
2995 (defun gnus-Subject-prev-thread (n)
2996 "Go to the same level previous thread.
2997 Argument N specifies the number of threads."
2999 ;; Adjust cursor point.
3001 (search-forward ":" nil t
)
3002 (let ((init (point))
3004 (level (current-column)))
3006 (gnus-Subject-search-backward)
3007 (<= level
(current-column)))
3008 ;; We have to skip lower levels.
3009 (if (= level
(current-column))
3015 ;; Return non-nil if successfully move to the previous.
3016 (prog1 (not (= init last
))
3020 (defun gnus-Subject-down-thread (d)
3021 "Go downward current thread.
3022 Argument D specifies the depth goes down."
3024 ;; Adjust cursor point.
3026 (search-forward ":" nil t
)
3027 (let ((last (point))
3028 (level (current-column)))
3030 (gnus-Subject-search-forward)
3031 (<= level
(current-column))) ;<= can be <. Which do you like?
3032 ;; We have to skip the same levels.
3033 (if (< level
(current-column))
3036 (setq level
(current-column))
3043 (defun gnus-Subject-up-thread (d)
3044 "Go upward current thread.
3045 Argument D specifies the depth goes up."
3047 ;; Adjust cursor point.
3049 (search-forward ":" nil t
)
3050 (let ((last (point))
3051 (level (current-column)))
3053 (gnus-Subject-search-backward))
3054 ;; We have to skip the same levels.
3055 (if (> level
(current-column))
3058 (setq level
(current-column))
3065 (defun gnus-Subject-kill-thread (unmark)
3066 "Mark articles under current thread as read.
3067 If argument UNMARK is positive, remove any kinds of marks.
3068 If argument UNMARK is negative, mark articles as unread instead."
3071 (setq unmark
(prefix-numeric-value unmark
)))
3072 ;; Adjust cursor point.
3074 (search-forward ":" nil t
)
3076 (let ((level (current-column)))
3077 ;; Mark current article.
3078 (cond ((null unmark
)
3079 (gnus-Subject-mark-as-read nil
"K"))
3081 (gnus-Subject-mark-as-unread nil t
))
3083 (gnus-Subject-mark-as-unread))
3085 ;; Mark following articles.
3086 (while (and (gnus-Subject-search-forward)
3087 (< level
(current-column)))
3088 (cond ((null unmark
)
3089 (gnus-Subject-mark-as-read nil
"K"))
3091 (gnus-Subject-mark-as-unread nil t
))
3093 (gnus-Subject-mark-as-unread))
3096 ;; Hide killed subtrees.
3098 gnus-thread-hide-killed
3099 (gnus-Subject-hide-thread))
3100 ;; If marked as read, go to next unread subject.
3102 ;; Go to next unread subject.
3103 (gnus-Subject-next-subject 1 t
))
3106 (defun gnus-Subject-toggle-truncation (arg)
3107 "Toggle truncation of subject lines.
3108 With ARG, turn line truncation on iff ARG is positive."
3110 (setq truncate-lines
3111 (if (null arg
) (not truncate-lines
)
3112 (> (prefix-numeric-value arg
) 0)))
3115 (defun gnus-Subject-sort-by-number (reverse)
3116 "Sort subject display buffer by article number.
3117 Argument REVERSE means reverse order."
3119 (gnus-Subject-sort-subjects
3122 (< (nntp-header-number a
) (nntp-header-number b
))))
3126 (defun gnus-Subject-sort-by-author (reverse)
3127 "Sort subject display buffer by author name alphabetically.
3128 If case-fold-search is non-nil, case of letters is ignored.
3129 Argument REVERSE means reverse order."
3131 (gnus-Subject-sort-subjects
3134 (gnus-string-lessp (nntp-header-from a
) (nntp-header-from b
))))
3138 (defun gnus-Subject-sort-by-subject (reverse)
3139 "Sort subject display buffer by subject alphabetically. `Re:'s are ignored.
3140 If case-fold-search is non-nil, case of letters is ignored.
3141 Argument REVERSE means reverse order."
3143 (gnus-Subject-sort-subjects
3147 (gnus-simplify-subject (nntp-header-subject a
) 're-only
)
3148 (gnus-simplify-subject (nntp-header-subject b
) 're-only
))))
3152 (defun gnus-Subject-sort-by-date (reverse)
3153 "Sort subject display buffer by posted date.
3154 Argument REVERSE means reverse order."
3156 (gnus-Subject-sort-subjects
3159 (gnus-date-lessp (nntp-header-date a
) (nntp-header-date b
))))
3163 (defun gnus-Subject-sort-subjects (predicate &optional reverse
)
3164 "Sort subject display buffer by PREDICATE.
3165 Optional argument REVERSE means reverse order."
3166 (let ((current (gnus-Subject-article-number)))
3167 (gnus-sort-headers predicate reverse
)
3168 (gnus-Subject-prepare)
3169 (gnus-Subject-goto-subject current
)
3172 (defun gnus-Subject-reselect-current-group (show-all)
3173 "Once exit and then reselect the current newsgroup.
3174 Prefix argument SHOW-ALL means to select all articles."
3176 (let ((current-subject (gnus-Subject-article-number)))
3177 (gnus-Subject-exit t
)
3178 ;; We have to adjust the point of Group mode buffer because the
3179 ;; current point was moved to the next unread newsgroup by
3181 (gnus-Subject-jump-to-group gnus-newsgroup-name
)
3182 (gnus-Group-read-group show-all t
)
3183 (gnus-Subject-goto-subject current-subject
)
3186 (defun gnus-Subject-caesar-message (rotnum)
3187 "Caesar rotates all letters of current message by 13/47 places.
3188 With prefix arg, specifies the number of places to rotate each letter forward.
3189 Caesar rotates Japanese letters by 47 places in any case."
3191 (gnus-Subject-select-article)
3192 (gnus-overload-functions)
3193 (gnus-eval-in-buffer-window gnus-Article-buffer
3196 ;; We don't want to jump to the beginning of the message.
3197 ;; `save-excursion' does not do its job.
3198 (move-to-window-line 0)
3199 (let ((last (point)))
3200 (news-caesar-buffer-body rotnum
)
3206 (defun gnus-Subject-rmail-digest ()
3207 "Run RMAIL on current digest article.
3208 `gnus-Select-digest-hook' will be called with no arguments, if that
3209 value is non-nil. It is possible to modify the article so that Rmail
3212 `gnus-Rmail-digest-hook' will be called with no arguments, if that value
3213 is non-nil. The hook is intended to customize Rmail mode."
3215 (gnus-Subject-select-article)
3217 (let ((artbuf gnus-Article-buffer
)
3218 (digbuf (get-buffer-create gnus-Digest-buffer
))
3219 (mail-header-separator ""))
3221 (buffer-flush-undo (current-buffer))
3222 (setq buffer-read-only nil
)
3224 (insert-buffer-substring artbuf
)
3225 (run-hooks 'gnus-Select-digest-hook
)
3226 (gnus-convert-article-to-rmail)
3227 (goto-char (point-min))
3228 ;; Rmail initializations.
3229 (rmail-insert-rmail-file-header)
3231 (rmail-set-message-counters)
3232 (rmail-show-message)
3235 (undigestify-rmail-message)
3236 (rmail-expunge) ;Delete original message.
3237 ;; File name is meaningless but `save-buffer' requires it.
3238 (setq buffer-file-name
"GNUS Digest")
3239 (setq mode-line-buffer-identification
3241 (nntp-header-subject gnus-current-headers
)))
3242 ;; There is no need to write this buffer to a file.
3243 (make-local-variable 'write-file-hooks
)
3244 (setq write-file-hooks
3247 (set-buffer-modified-p nil
)
3248 (message "(No changes need to be saved)")
3249 'no-need-to-write-this-buffer
))))
3250 ;; Default file name saving digest messages.
3251 (setq rmail-last-rmail-file
3252 (funcall gnus-rmail-save-name
3254 gnus-current-headers
3255 gnus-newsgroup-last-rmail
3257 (setq rmail-last-file
3258 (funcall gnus-mail-save-name
3260 gnus-current-headers
3261 gnus-newsgroup-last-mail
3263 ;; Prevent generating new buffer named ***<N> each time.
3264 (setq rmail-summary-buffer
3265 (get-buffer-create gnus-Digest-summary-buffer
))
3266 (run-hooks 'gnus-Rmail-digest-hook
)
3267 ;; Take all windows safely.
3268 (gnus-configure-windows '(1 0 0))
3269 (pop-to-buffer gnus-Group-buffer
)
3270 ;; Use Subject and Article windows for Digest summary and
3272 (if gnus-digest-show-summary
3273 (let ((gnus-Subject-buffer gnus-Digest-summary-buffer
)
3274 (gnus-Article-buffer gnus-Digest-buffer
))
3275 (gnus-configure-windows 'SelectArticle
)
3276 (pop-to-buffer gnus-Digest-buffer
)
3278 (pop-to-buffer gnus-Digest-summary-buffer
)
3279 (message (substitute-command-keys
3280 "Type \\[rmail-summary-quit] to return to GNUS")))
3281 (let ((gnus-Subject-buffer gnus-Digest-buffer
))
3282 (gnus-configure-windows 'ExpandSubject
)
3283 (pop-to-buffer gnus-Digest-buffer
)
3284 (message (substitute-command-keys
3285 "Type \\[rmail-quit] to return to GNUS")))
3287 ;; Move the buffers to the end of buffer list.
3288 (bury-buffer gnus-Article-buffer
)
3289 (bury-buffer gnus-Group-buffer
)
3290 (bury-buffer gnus-Digest-summary-buffer
)
3291 (bury-buffer gnus-Digest-buffer
))
3292 (error (set-buffer-modified-p nil
)
3293 (kill-buffer digbuf
)
3294 ;; This command should not signal an error because the
3295 ;; command is called from hooks.
3296 (ding) (message "Article is not a digest")))
3299 (defun gnus-Subject-save-article ()
3300 "Save this article using default saver function.
3301 Variable `gnus-default-article-saver' specifies the saver function."
3303 (gnus-Subject-select-article
3304 (not (null gnus-save-all-headers
)) gnus-save-all-headers
)
3305 (if gnus-default-article-saver
3306 (call-interactively gnus-default-article-saver
)
3307 (error "No default saver is defined.")))
3309 (defun gnus-Subject-save-in-rmail (&optional filename
)
3310 "Append this article to Rmail file.
3311 Optional argument FILENAME specifies file name.
3312 Directory to save to is default to `gnus-article-save-directory' which
3313 is initialized from the SAVEDIR environment variable."
3315 (gnus-Subject-select-article
3316 (not (null gnus-save-all-headers
)) gnus-save-all-headers
)
3317 (gnus-eval-in-buffer-window gnus-Article-buffer
3322 (funcall gnus-rmail-save-name
3324 gnus-current-headers
3325 gnus-newsgroup-last-rmail
3330 (concat "Save article in Rmail file: (default "
3331 (file-name-nondirectory default-name
)
3333 (file-name-directory default-name
)
3335 (gnus-make-directory (file-name-directory filename
))
3336 (gnus-output-to-rmail filename
)
3337 ;; Remember the directory name to save articles.
3338 (setq gnus-newsgroup-last-rmail filename
)
3342 (defun gnus-Subject-save-in-mail (&optional filename
)
3343 "Append this article to Unix mail file.
3344 Optional argument FILENAME specifies file name.
3345 Directory to save to is default to `gnus-article-save-directory' which
3346 is initialized from the SAVEDIR environment variable."
3348 (gnus-Subject-select-article
3349 (not (null gnus-save-all-headers
)) gnus-save-all-headers
)
3350 (gnus-eval-in-buffer-window gnus-Article-buffer
3355 (funcall gnus-mail-save-name
3357 gnus-current-headers
3358 gnus-newsgroup-last-mail
3363 (concat "Save article in Unix mail file: (default "
3364 (file-name-nondirectory default-name
)
3366 (file-name-directory default-name
)
3368 (gnus-make-directory (file-name-directory filename
))
3369 (rmail-output filename
)
3370 ;; Remember the directory name to save articles.
3371 (setq gnus-newsgroup-last-mail filename
)
3375 (defun gnus-Subject-save-in-file (&optional filename
)
3376 "Append this article to file.
3377 Optional argument FILENAME specifies file name.
3378 Directory to save to is default to `gnus-article-save-directory' which
3379 is initialized from the SAVEDIR environment variable."
3381 (gnus-Subject-select-article
3382 (not (null gnus-save-all-headers
)) gnus-save-all-headers
)
3383 (gnus-eval-in-buffer-window gnus-Article-buffer
3388 (funcall gnus-file-save-name
3390 gnus-current-headers
3391 gnus-newsgroup-last-file
3396 (concat "Save article in file: (default "
3397 (file-name-nondirectory default-name
)
3399 (file-name-directory default-name
)
3401 (gnus-make-directory (file-name-directory filename
))
3402 (gnus-output-to-file filename
)
3403 ;; Remember the directory name to save articles.
3404 (setq gnus-newsgroup-last-file filename
)
3408 (defun gnus-Subject-save-in-folder (&optional folder
)
3409 "Save this article to MH folder (using `rcvstore' in MH library).
3410 Optional argument FOLDER specifies folder name."
3412 (gnus-Subject-select-article
3413 (not (null gnus-save-all-headers
)) gnus-save-all-headers
)
3414 (gnus-eval-in-buffer-window gnus-Article-buffer
3417 ;; Thanks to yuki@flab.Fujitsu.JUNET and ohm@kaba.junet.
3421 (mh-prompt-for-folder "Save article in"
3422 (funcall gnus-folder-save-name
3424 gnus-current-headers
3425 gnus-newsgroup-last-folder
3429 (errbuf (get-buffer-create " *GNUS rcvstore*")))
3431 (call-process-region (point-min) (point-max)
3432 (expand-file-name "rcvstore" mh-lib
)
3433 nil errbuf nil folder
)
3435 (if (zerop (buffer-size))
3436 (message "Article saved in folder: %s" folder
)
3437 (message "%s" (buffer-string)))
3438 (kill-buffer errbuf
)
3439 (setq gnus-newsgroup-last-folder folder
))
3443 (defun gnus-Subject-pipe-output ()
3444 "Pipe this article to subprocess."
3446 ;; Ignore `gnus-save-all-headers' since this is not save command.
3447 (gnus-Subject-select-article)
3448 (gnus-eval-in-buffer-window gnus-Article-buffer
3451 (let ((command (read-string "Shell command on article: "
3452 gnus-last-shell-command
)))
3453 (if (string-equal command
"")
3454 (setq command gnus-last-shell-command
))
3455 (shell-command-on-region (point-min) (point-max) command nil
)
3456 (setq gnus-last-shell-command command
)
3460 (defun gnus-Subject-catch-up (all &optional quietly
)
3461 "Mark all articles not marked as unread in this newsgroup as read.
3462 If prefix argument ALL is non-nil, all articles are marked as read."
3467 "Do you really want to mark everything as read? "
3468 "Delete all articles not marked as unread? ")))
3470 (gnus-set-difference gnus-newsgroup-unreads
3471 (if (not all
) gnus-newsgroup-marked
))))
3472 (message "") ;Erase "Yes or No" question.
3474 (gnus-Subject-mark-as-read (car unmarked
) "C")
3475 (setq unmarked
(cdr unmarked
))
3479 (defun gnus-Subject-catch-up-all (&optional quietly
)
3480 "Mark all articles in this newsgroup as read."
3482 (gnus-Subject-catch-up t quietly
))
3484 (defun gnus-Subject-catch-up-and-exit (all &optional quietly
)
3485 "Mark all articles not marked as unread in this newsgroup as read, then exit.
3486 If prefix argument ALL is non-nil, all articles are marked as read."
3491 "Do you really want to mark everything as read? "
3492 "Delete all articles not marked as unread? ")))
3494 (gnus-set-difference gnus-newsgroup-unreads
3495 (if (not all
) gnus-newsgroup-marked
))))
3496 (message "") ;Erase "Yes or No" question.
3498 (gnus-mark-article-as-read (car unmarked
))
3499 (setq unmarked
(cdr unmarked
)))
3500 ;; Select next newsgroup or exit.
3501 (cond ((eq gnus-auto-select-next
'quietly
)
3502 ;; Select next newsgroup quietly.
3503 (gnus-Subject-next-group nil
))
3505 (gnus-Subject-exit)))
3508 (defun gnus-Subject-catch-up-all-and-exit (&optional quietly
)
3509 "Mark all articles in this newsgroup as read, and then exit."
3511 (gnus-Subject-catch-up-and-exit t quietly
))
3513 (defun gnus-Subject-edit-global-kill ()
3514 "Edit a global KILL file."
3516 (setq gnus-current-kill-article
(gnus-Subject-article-number))
3517 (gnus-Kill-file-edit-file nil
) ;Nil stands for global KILL file.
3519 (substitute-command-keys
3520 "Editing a global KILL file (Type \\[gnus-Kill-file-exit] to exit)")))
3522 (defun gnus-Subject-edit-local-kill ()
3523 "Edit a local KILL file applied to the current newsgroup."
3525 (setq gnus-current-kill-article
(gnus-Subject-article-number))
3526 (gnus-Kill-file-edit-file gnus-newsgroup-name
)
3528 (substitute-command-keys
3529 "Editing a local KILL file (Type \\[gnus-Kill-file-exit] to exit)")))
3531 (defun gnus-Subject-exit (&optional temporary
)
3532 "Exit reading current newsgroup, and then return to group selection mode.
3533 gnus-Exit-group-hook is called with no arguments if that value is non-nil."
3536 (gnus-newsgroup-headers gnus-newsgroup-headers
)
3537 (gnus-newsgroup-unreads gnus-newsgroup-unreads
)
3538 (gnus-newsgroup-unselected gnus-newsgroup-unselected
)
3539 (gnus-newsgroup-marked gnus-newsgroup-marked
))
3540 ;; Important internal variables are save, so we can reenter
3541 ;; Subject Mode buffer even if hook changes them.
3542 (run-hooks 'gnus-Exit-group-hook
)
3543 (gnus-update-unread-articles gnus-newsgroup-name
3544 (append gnus-newsgroup-unselected
3545 gnus-newsgroup-unreads
)
3546 gnus-newsgroup-marked
)
3547 ;; T means ignore unsubscribed newsgroups.
3548 (if gnus-use-cross-reference
3550 (gnus-mark-as-read-by-xref gnus-newsgroup-name
3551 gnus-newsgroup-headers
3552 gnus-newsgroup-unreads
3553 (eq gnus-use-cross-reference t
)
3555 ;; Do not switch windows but change the buffer to work.
3556 (set-buffer gnus-Group-buffer
)
3557 ;; Update cross referenced group info.
3559 (gnus-Group-update-group (car updated
) t
) ;Ignore invisible group.
3560 (setq updated
(cdr updated
)))
3561 (gnus-Group-update-group gnus-newsgroup-name
))
3562 ;; Make sure where I was, and go to next newsgroup.
3563 (gnus-Group-jump-to-group gnus-newsgroup-name
)
3564 (gnus-Group-next-unread-group 1)
3566 ;; If exiting temporary, caller should adjust Group mode
3567 ;; buffer point by itself.
3569 ;; Return to Group mode buffer.
3570 (if (get-buffer gnus-Subject-buffer
)
3571 (bury-buffer gnus-Subject-buffer
))
3572 (if (get-buffer gnus-Article-buffer
)
3573 (bury-buffer gnus-Article-buffer
))
3574 (gnus-configure-windows 'ExitNewsgroup
)
3575 (pop-to-buffer gnus-Group-buffer
)))
3577 (defun gnus-Subject-quit ()
3578 "Quit reading current newsgroup without updating read article info."
3580 (if (y-or-n-p "Do you really wanna quit reading this group? ")
3582 (message "") ;Erase "Yes or No" question.
3583 ;; Return to Group selection mode.
3584 (if (get-buffer gnus-Subject-buffer
)
3585 (bury-buffer gnus-Subject-buffer
))
3586 (if (get-buffer gnus-Article-buffer
)
3587 (bury-buffer gnus-Article-buffer
))
3588 (gnus-configure-windows 'ExitNewsgroup
)
3589 (pop-to-buffer gnus-Group-buffer
)
3590 (gnus-Group-jump-to-group gnus-newsgroup-name
) ;Make sure where I was.
3591 (gnus-Group-next-group 1) ;(gnus-Group-next-unread-group 1)
3594 (defun gnus-Subject-describe-briefly ()
3595 "Describe Subject mode commands briefly."
3599 (substitute-command-keys "\\[gnus-Subject-next-page]:Select ")
3600 (substitute-command-keys "\\[gnus-Subject-next-unread-article]:Forward ")
3601 (substitute-command-keys "\\[gnus-Subject-prev-unread-article]:Backward ")
3602 (substitute-command-keys "\\[gnus-Subject-exit]:Exit ")
3603 (substitute-command-keys "\\[gnus-Info-find-node]:Run Info ")
3604 (substitute-command-keys "\\[gnus-Subject-describe-briefly]:This help")
3609 ;;; GNUS Article Mode
3612 (if gnus-Article-mode-map
3614 (setq gnus-Article-mode-map
(make-keymap))
3615 (suppress-keymap gnus-Article-mode-map
)
3616 (define-key gnus-Article-mode-map
" " 'gnus-Article-next-page
)
3617 (define-key gnus-Article-mode-map
"\177" 'gnus-Article-prev-page
)
3618 (define-key gnus-Article-mode-map
"r" 'gnus-Article-refer-article
)
3619 (define-key gnus-Article-mode-map
"o" 'gnus-Article-pop-article
)
3620 (define-key gnus-Article-mode-map
"h" 'gnus-Article-show-subjects
)
3621 (define-key gnus-Article-mode-map
"s" 'gnus-Article-show-subjects
)
3622 (define-key gnus-Article-mode-map
"?" 'gnus-Article-describe-briefly
)
3623 (define-key gnus-Article-mode-map
"\C-c\C-i" 'gnus-Info-find-node
))
3625 (defun gnus-Article-mode ()
3626 "Major mode for browsing through an article.
3627 All normal editing commands are turned off.
3628 Instead, these commands are available:
3629 \\{gnus-Article-mode-map}
3631 Various hooks for customization:
3632 gnus-Article-mode-hook
3633 Entry to this mode calls the value with no arguments, if that
3636 gnus-Article-prepare-hook
3637 Called with no arguments after an article is prepared for reading,
3638 if that value is non-nil."
3640 (kill-all-local-variables)
3641 ;; Gee. Why don't you upgrade?
3642 (cond ((boundp 'mode-line-modified
)
3643 (setq mode-line-modified
"--- "))
3644 ((listp (default-value 'mode-line-format
))
3645 (setq mode-line-format
3646 (cons "--- " (cdr (default-value 'mode-line-format
))))))
3647 (make-local-variable 'global-mode-string
)
3648 (setq global-mode-string nil
)
3649 (setq major-mode
'gnus-Article-mode
)
3650 (setq mode-name
"Article")
3651 (gnus-Article-set-mode-line)
3652 (use-local-map gnus-Article-mode-map
)
3653 (make-local-variable 'page-delimiter
)
3654 (setq page-delimiter gnus-page-delimiter
)
3655 (make-local-variable 'mail-header-separator
)
3656 (setq mail-header-separator
"") ;For caesar function.
3657 (buffer-flush-undo (current-buffer))
3658 (setq buffer-read-only t
) ;Disable modification
3659 (run-hooks 'gnus-Article-mode-hook
))
3661 (defun gnus-Article-setup-buffer ()
3662 "Initialize Article mode buffer."
3663 (or (get-buffer gnus-Article-buffer
)
3665 (set-buffer (get-buffer-create gnus-Article-buffer
))
3666 (gnus-Article-mode))
3669 (defun gnus-Article-prepare (article &optional all-headers
)
3670 "Prepare ARTICLE in Article mode buffer.
3671 If optional argument ALL-HEADERS is non-nil, all headers are inserted."
3673 (set-buffer gnus-Article-buffer
)
3674 (let ((buffer-read-only nil
))
3676 (if (gnus-request-article article
)
3678 ;; Prepare article buffer
3679 (insert-buffer-substring nntp-server-buffer
)
3680 (setq gnus-have-all-headers
(or all-headers gnus-show-all-headers
))
3681 (if (and (numberp article
)
3682 (not (eq article gnus-current-article
)))
3683 ;; Seems me that a new article is selected.
3685 ;; gnus-current-article must be an article number.
3686 (setq gnus-last-article gnus-current-article
)
3687 (setq gnus-current-article article
)
3688 (setq gnus-current-headers
3689 (gnus-find-header-by-number gnus-newsgroup-headers
3690 gnus-current-article
))
3691 ;; Clear articles history only when articles are
3692 ;; retrieved by article numbers.
3693 (setq gnus-current-history nil
)
3694 (run-hooks 'gnus-Mark-article-hook
)
3696 ;; Hooks for modifying contents of the article. This hook
3697 ;; must be called before being narrowed.
3698 (run-hooks 'gnus-Article-prepare-hook
)
3699 ;; Delete unnecessary headers.
3700 (or gnus-have-all-headers
3701 (gnus-Article-delete-headers))
3703 (goto-char (point-min))
3704 (if gnus-break-pages
3705 (gnus-narrow-to-page))
3706 ;; Next function must be called after setting
3707 ;; `gnus-current-article' variable and narrowed to page.
3708 (gnus-Article-set-mode-line)
3710 (if (numberp article
)
3711 (gnus-Subject-mark-as-read article
))
3712 (ding) (message "No such article (may be canceled)"))
3715 (defun gnus-Article-show-all-headers ()
3716 "Show all article headers in Article mode buffer."
3717 (or gnus-have-all-headers
3718 (gnus-Article-prepare gnus-current-article t
)))
3720 ;;(defun gnus-Article-set-mode-line ()
3721 ;; "Set Article mode line string."
3722 ;; (setq mode-line-buffer-identification
3724 ;; (format "GNUS: %s {%d-%d} %d"
3725 ;; gnus-newsgroup-name
3726 ;; gnus-newsgroup-begin
3727 ;; gnus-newsgroup-end
3728 ;; gnus-current-article
3730 ;; (set-buffer-modified-p t))
3732 (defun gnus-Article-set-mode-line ()
3733 "Set Article mode line string."
3735 (- (length gnus-newsgroup-unreads
)
3736 (length (gnus-intersection
3737 gnus-newsgroup-unreads gnus-newsgroup-marked
))))
3739 (- (length gnus-newsgroup-unselected
)
3740 (length (gnus-intersection
3741 gnus-newsgroup-unselected gnus-newsgroup-marked
)))))
3742 (setq mode-line-buffer-identification
3744 (format "GNUS: %s{%d} %s"
3746 gnus-current-article
3747 ;; This is proposed by tale@pawl.rpi.edu.
3748 (cond ((and (zerop unmarked
)
3752 (format "%d more" unmarked
))
3754 (format "%d(+%d) more" unmarked unselected
)))
3756 (set-buffer-modified-p t
))
3758 (defun gnus-Article-delete-headers ()
3759 "Delete unnecessary headers."
3762 (goto-char (point-min))
3763 (narrow-to-region (point-min)
3764 (progn (search-forward "\n\n" nil
'move
) (point)))
3765 (goto-char (point-min))
3766 (and (stringp gnus-ignored-headers
)
3767 (while (re-search-forward gnus-ignored-headers nil t
)
3769 (delete-region (point)
3770 (progn (re-search-forward "\n[^ \t]")
3775 ;; Working on article's buffer
3777 (defun gnus-Article-next-page (lines)
3778 "Show next page of current article.
3779 If end of article, return non-nil. Otherwise return nil.
3780 Argument LINES specifies lines to be scrolled up."
3782 (move-to-window-line -
1)
3783 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
3786 (and (pos-visible-in-window-p) ;Not continuation line.
3788 ;; Nothing in this page.
3789 (if (or (not gnus-break-pages
)
3792 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
3794 (gnus-narrow-to-page 1) ;Go to next page.
3797 ;; More in this page.
3801 ;; Long lines may cause an end-of-buffer error.
3802 (goto-char (point-max))))
3806 (defun gnus-Article-prev-page (lines)
3807 "Show previous page of current article.
3808 Argument LINES specifies lines to be scrolled down."
3810 (move-to-window-line 0)
3811 (if (and gnus-break-pages
3813 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
3815 (gnus-narrow-to-page -
1) ;Go to previous page.
3816 (goto-char (point-max))
3818 (scroll-down lines
)))
3820 (defun gnus-Article-next-digest (nth)
3821 "Move to head of NTH next digested message.
3822 Set mark at end of digested message."
3823 ;; Stop page breaking in digest mode.
3826 ;; Skip NTH - 1 digest.
3827 ;; Suggested by Khalid Sattar <admin@cs.exeter.ac.uk>.
3828 ;; Digest separator is customizable.
3829 ;; Suggested by Skip Montanaro <montanaro@sprite.crd.ge.com>.
3830 (while (and (> nth
1)
3831 (re-search-forward gnus-digest-separator nil
'move
))
3832 (setq nth
(1- nth
)))
3833 (if (re-search-forward gnus-digest-separator nil t
)
3834 (let ((begin (point)))
3835 ;; Search for end of this message.
3837 (if (re-search-forward gnus-digest-separator nil t
)
3839 (search-backward "\n\n") ;This may be incorrect.
3841 (goto-char (point-max)))
3842 (push-mark) ;Set mark at end of digested message.
3845 ;; Show From: and Subject: fields.
3847 (message "End of message")
3850 (defun gnus-Article-prev-digest (nth)
3851 "Move to head of NTH previous digested message."
3852 ;; Stop page breaking in digest mode.
3855 ;; Skip NTH - 1 digest.
3856 ;; Suggested by Khalid Sattar <admin@cs.exeter.ac.uk>.
3857 ;; Digest separator is customizable.
3858 ;; Suggested by Skip Montanaro <montanaro@sprite.crd.ge.com>.
3859 (while (and (> nth
1)
3860 (re-search-backward gnus-digest-separator nil
'move
))
3861 (setq nth
(1- nth
)))
3862 (if (re-search-backward gnus-digest-separator nil t
)
3863 (let ((begin (point)))
3864 ;; Search for end of this message.
3866 (if (re-search-forward gnus-digest-separator nil t
)
3868 (search-backward "\n\n") ;This may be incorrect.
3870 (goto-char (point-max)))
3871 (push-mark) ;Set mark at end of digested message.
3873 ;; Show From: and Subject: fields.
3875 (goto-char (point-min))
3876 (message "Top of message")
3879 (defun gnus-Article-refer-article ()
3880 "Read article specified by message-id around point."
3882 (save-window-excursion
3884 (re-search-forward ">" nil t
) ;Move point to end of "<....>".
3885 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t
)
3887 (buffer-substring (match-beginning 1) (match-end 1))))
3888 (set-buffer gnus-Subject-buffer
)
3889 (gnus-Subject-refer-article message-id
))
3890 (error "No references around point"))
3893 (defun gnus-Article-pop-article ()
3894 "Pop up article history."
3896 (save-window-excursion
3897 (set-buffer gnus-Subject-buffer
)
3898 (gnus-Subject-refer-article nil
)))
3900 (defun gnus-Article-show-subjects ()
3901 "Reconfigure windows to show headers."
3903 (gnus-configure-windows 'SelectArticle
)
3904 (pop-to-buffer gnus-Subject-buffer
)
3905 (gnus-Subject-goto-subject gnus-current-article
))
3907 (defun gnus-Article-describe-briefly ()
3908 "Describe Article mode commands briefly."
3912 (substitute-command-keys "\\[gnus-Article-next-page]:Next page ")
3913 (substitute-command-keys "\\[gnus-Article-prev-page]:Prev page ")
3914 (substitute-command-keys "\\[gnus-Article-show-subjects]:Show headers ")
3915 (substitute-command-keys "\\[gnus-Info-find-node]:Run Info ")
3916 (substitute-command-keys "\\[gnus-Article-describe-briefly]:This help")
3921 ;;; GNUS KILL-File Mode
3924 (if gnus-Kill-file-mode-map
3926 (setq gnus-Kill-file-mode-map
(copy-keymap emacs-lisp-mode-map
))
3927 (define-key gnus-Kill-file-mode-map
"\C-c\C-k\C-s" 'gnus-Kill-file-kill-by-subject
)
3928 (define-key gnus-Kill-file-mode-map
"\C-c\C-k\C-a" 'gnus-Kill-file-kill-by-author
)
3929 (define-key gnus-Kill-file-mode-map
"\C-c\C-a" 'gnus-Kill-file-apply-buffer
)
3930 (define-key gnus-Kill-file-mode-map
"\C-c\C-e" 'gnus-Kill-file-apply-last-sexp
)
3931 (define-key gnus-Kill-file-mode-map
"\C-c\C-c" 'gnus-Kill-file-exit
)
3932 (define-key gnus-Kill-file-mode-map
"\C-c\C-i" 'gnus-Info-find-node
))
3934 (defun gnus-Kill-file-mode ()
3935 "Major mode for editing KILL file.
3937 In addition to Emacs-Lisp Mode, the following commands are available:
3939 \\[gnus-Kill-file-kill-by-subject] Insert KILL command for current subject.
3940 \\[gnus-Kill-file-kill-by-author] Insert KILL command for current author.
3941 \\[gnus-Kill-file-apply-buffer] Apply current buffer to selected newsgroup.
3942 \\[gnus-Kill-file-apply-last-sexp] Apply sexp before point to selected newsgroup.
3943 \\[gnus-Kill-file-exit] Save file and exit editing KILL file.
3944 \\[gnus-Info-find-node] Read Info about KILL file.
3946 A KILL file contains lisp expressions to be applied to a selected
3947 newsgroup. The purpose is to mark articles as read on the basis of
3948 some set of regexps. A global KILL file is applied to every newsgroup,
3949 and a local KILL file is applied to a specified newsgroup. Since a
3950 global KILL file is applied to every newsgroup, for better performance
3953 A KILL file can contain any kind of Emacs lisp expressions expected
3954 to be evaluated in the Subject buffer. Writing lisp programs for this
3955 purpose is not so easy because the internal working of GNUS must be
3956 well-known. For this reason, GNUS provides a general function which
3957 does this easily for non-Lisp programmers.
3959 The `gnus-kill' function executes commands available in Subject Mode
3960 by their key sequences. `gnus-kill' should be called with FIELD,
3961 REGEXP and optional COMMAND and ALL. FIELD is a string representing
3962 the header field or an empty string. If FIELD is an empty string, the
3963 entire article body is searched for. REGEXP is a string which is
3964 compared with FIELD value. COMMAND is a string representing a valid
3965 key sequence in Subject Mode or Lisp expression. COMMAND is default to
3966 '(gnus-Subject-mark-as-read nil \"X\"). Make sure that COMMAND is
3967 executed in the Subject buffer. If the second optional argument ALL
3968 is non-nil, the COMMAND is applied to articles which are already
3969 marked as read or unread. Articles which are marked are skipped over
3972 For example, if you want to mark articles of which subjects contain
3973 the string `AI' as read, a possible KILL file may look like:
3975 (gnus-kill \"Subject\" \"AI\")
3977 If you want to mark articles with `D' instead of `X', you can use
3978 the following expression:
3980 (gnus-kill \"Subject\" \"AI\" \"d\")
3982 In this example it is assumed that the command
3983 `gnus-Subject-mark-as-read-forward' is assigned to `d' in Subject Mode.
3985 It is possible to delete unnecessary headers which are marked with
3986 `X' in a KILL file as follows:
3988 (gnus-expunge \"X\")
3990 If the Subject buffer is empty after applying KILL files, GNUS will
3991 exit the selected newsgroup normally. If headers which are marked
3992 with `D' are deleted in a KILL file, it is impossible to read articles
3993 which are marked as read in the previous GNUS sessions. Marks other
3994 than `D' should be used for articles which should really be deleted.
3996 Entry to this mode calls emacs-lisp-mode-hook and
3997 gnus-Kill-file-mode-hook with no arguments, if that value is non-nil."
3999 (kill-all-local-variables)
4000 (use-local-map gnus-Kill-file-mode-map
)
4001 (set-syntax-table emacs-lisp-mode-syntax-table
)
4002 (setq major-mode
'gnus-Kill-file-mode
)
4003 (setq mode-name
"KILL-File")
4004 (lisp-mode-variables nil
)
4005 (run-hooks 'emacs-lisp-mode-hook
'gnus-Kill-file-mode-hook
))
4007 (defun gnus-Kill-file-edit-file (newsgroup)
4008 "Begin editing a KILL file of NEWSGROUP.
4009 If NEWSGROUP is nil, the global KILL file is selected."
4010 (interactive "sNewsgroup: ")
4011 (let ((file (gnus-newsgroup-kill-file newsgroup
)))
4012 (gnus-make-directory (file-name-directory file
))
4013 ;; Save current window configuration if this is first invocation.
4014 (or (and (get-file-buffer file
)
4015 (get-buffer-window (get-file-buffer file
)))
4016 (setq gnus-winconf-kill-file
(current-window-configuration)))
4018 (let ((buffer (find-file-noselect file
)))
4019 (cond ((get-buffer-window buffer
)
4020 (pop-to-buffer buffer
))
4021 ((eq major-mode
'gnus-Group-mode
)
4022 (gnus-configure-windows '(1 0 0)) ;Take all windows.
4023 (pop-to-buffer gnus-Group-buffer
)
4024 (let ((gnus-Subject-buffer buffer
))
4025 (gnus-configure-windows '(1 1 0)) ;Split into two.
4026 (pop-to-buffer buffer
)))
4027 ((eq major-mode
'gnus-Subject-mode
)
4028 (gnus-configure-windows 'SelectArticle
)
4029 (pop-to-buffer gnus-Article-buffer
)
4030 (bury-buffer gnus-Article-buffer
)
4031 (switch-to-buffer buffer
))
4033 (find-file-other-window file
))
4035 (gnus-Kill-file-mode)
4038 (defun gnus-Kill-file-kill-by-subject ()
4039 "Insert KILL command for current subject."
4042 (format "(gnus-kill \"Subject\" %s)\n"
4044 (if gnus-current-kill-article
4046 (nntp-header-subject
4047 (gnus-find-header-by-number gnus-newsgroup-headers
4048 gnus-current-kill-article
)))
4051 (defun gnus-Kill-file-kill-by-author ()
4052 "Insert KILL command for current author."
4055 (format "(gnus-kill \"From\" %s)\n"
4057 (if gnus-current-kill-article
4060 (gnus-find-header-by-number gnus-newsgroup-headers
4061 gnus-current-kill-article
)))
4064 (defun gnus-Kill-file-apply-buffer ()
4065 "Apply current buffer to current newsgroup."
4067 (if (and gnus-current-kill-article
4068 (get-buffer gnus-Subject-buffer
))
4069 ;; Assume newsgroup is selected.
4070 (let ((string (concat "(progn \n" (buffer-string) "\n)" )))
4072 (save-window-excursion
4073 (pop-to-buffer gnus-Subject-buffer
)
4074 (eval (car (read-from-string string
))))))
4075 (ding) (message "No newsgroup is selected.")))
4077 (defun gnus-Kill-file-apply-last-sexp ()
4078 "Apply sexp before point in current buffer to current newsgroup."
4080 (if (and gnus-current-kill-article
4081 (get-buffer gnus-Subject-buffer
))
4082 ;; Assume newsgroup is selected.
4085 (save-excursion (forward-sexp -
1) (point)) (point))))
4087 (save-window-excursion
4088 (pop-to-buffer gnus-Subject-buffer
)
4089 (eval (car (read-from-string string
))))))
4090 (ding) (message "No newsgroup is selected.")))
4092 (defun gnus-Kill-file-exit ()
4093 "Save a KILL file, then return to the previous buffer."
4096 (let ((killbuf (current-buffer)))
4097 ;; We don't want to return to Article buffer.
4098 (and (get-buffer gnus-Article-buffer
)
4099 (bury-buffer (get-buffer gnus-Article-buffer
)))
4100 ;; Delete the KILL file windows.
4101 (delete-windows-on killbuf
)
4102 ;; Restore last window configuration if available.
4103 (and gnus-winconf-kill-file
4104 (set-window-configuration gnus-winconf-kill-file
))
4105 (setq gnus-winconf-kill-file nil
)
4106 ;; Kill the KILL file buffer. Suggested by tale@pawl.rpi.edu.
4107 (kill-buffer killbuf
)))
4111 ;;; Utility functions
4114 ;; Basic ideas by emv@math.lsa.umich.edu (Edward Vielmetti)
4116 (defun gnus-batch-kill ()
4118 Usage: emacs -batch -l gnus -f gnus-batch-kill NEWSGROUP ..."
4119 (if (not noninteractive
)
4120 (error "gnus-batch-kill is to be used only with -batch"))
4125 (gnus-parse-n-options
4126 (apply (function concat
)
4127 (mapcar (function (lambda (g) (concat g
" ")))
4128 command-line-args-left
))))
4129 (yes (car yes-and-no
))
4130 (no (cdr yes-and-no
))
4131 ;; Disable verbose message.
4132 (gnus-novice-user nil
)
4133 (gnus-large-newsgroup nil
)
4134 (nntp-large-newsgroup nil
))
4135 ;; Eat all arguments.
4136 (setq command-line-args-left nil
)
4139 ;; Apply kills to specified newsgroups in command line arguments.
4140 (setq newsrc
(copy-sequence gnus-newsrc-assoc
))
4142 (setq group
(car (car newsrc
)))
4143 (setq subscribed
(nth 1 (car newsrc
)))
4144 (setq newsrc
(cdr newsrc
))
4146 (not (zerop (nth 1 (gnus-gethash group gnus-unread-hashtb
))))
4148 (string-match yes group
) t
)
4150 (not (string-match no group
))))
4152 (gnus-Subject-read-group group nil t
)
4153 (if (eq (current-buffer) (get-buffer gnus-Subject-buffer
))
4154 (gnus-Subject-exit t
))
4157 ;; Finally, exit Emacs.
4158 (set-buffer gnus-Group-buffer
)
4162 (defun gnus-Numeric-save-name (newsgroup headers
&optional last-file
)
4163 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4164 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
4165 Otherwise, it is like ~/News/news/group/num."
4168 (concat (if gnus-use-long-file-name
4169 (capitalize newsgroup
)
4170 (gnus-newsgroup-directory-form newsgroup
))
4171 "/" (int-to-string (nntp-header-number headers
)))
4172 (or gnus-article-save-directory
"~/News"))))
4174 (string-equal (file-name-directory default
)
4175 (file-name-directory last-file
))
4176 (string-match "^[0-9]+$" (file-name-nondirectory last-file
)))
4178 (or last-file default
))))
4180 (defun gnus-numeric-save-name (newsgroup headers
&optional last-file
)
4181 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4182 If variable `gnus-use-long-file-name' is nil, it is ~/News/news.group/num.
4183 Otherwise, it is like ~/News/news/group/num."
4186 (concat (if gnus-use-long-file-name
4188 (gnus-newsgroup-directory-form newsgroup
))
4189 "/" (int-to-string (nntp-header-number headers
)))
4190 (or gnus-article-save-directory
"~/News"))))
4192 (string-equal (file-name-directory default
)
4193 (file-name-directory last-file
))
4194 (string-match "^[0-9]+$" (file-name-nondirectory last-file
)))
4196 (or last-file default
))))
4198 (defun gnus-Plain-save-name (newsgroup headers
&optional last-file
)
4199 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4200 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group.
4201 Otherwise, it is like ~/News/news/group/news."
4204 (if gnus-use-long-file-name
4205 (capitalize newsgroup
)
4206 (concat (gnus-newsgroup-directory-form newsgroup
) "/news"))
4207 (or gnus-article-save-directory
"~/News"))))
4209 (defun gnus-plain-save-name (newsgroup headers
&optional last-file
)
4210 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4211 If variable `gnus-use-long-file-name' is nil, it is ~/News/news.group.
4212 Otherwise, it is like ~/News/news/group/news."
4215 (if gnus-use-long-file-name
4217 (concat (gnus-newsgroup-directory-form newsgroup
) "/news"))
4218 (or gnus-article-save-directory
"~/News"))))
4220 (defun gnus-Folder-save-name (newsgroup headers
&optional last-folder
)
4221 "Generate folder name from NEWSGROUP, HEADERS, and optional LAST-FOLDER.
4222 If variable `gnus-use-long-file-name' is nil, it is +News.group.
4223 Otherwise, it is like +news/group."
4226 (if gnus-use-long-file-name
4227 (capitalize newsgroup
)
4228 (gnus-newsgroup-directory-form newsgroup
)))))
4230 (defun gnus-folder-save-name (newsgroup headers
&optional last-folder
)
4231 "Generate folder name from NEWSGROUP, HEADERS, and optional LAST-FOLDER.
4232 If variable `gnus-use-long-file-name' is nil, it is +news.group.
4233 Otherwise, it is like +news/group."
4236 (if gnus-use-long-file-name
4238 (gnus-newsgroup-directory-form newsgroup
)))))
4240 (defun gnus-apply-kill-file ()
4241 "Apply KILL file to the current newsgroup."
4242 ;; Apply the global KILL file.
4243 (load (gnus-newsgroup-kill-file nil
) t nil t
)
4244 ;; And then apply the local KILL file.
4245 (load (gnus-newsgroup-kill-file gnus-newsgroup-name
) t nil t
))
4247 (defun gnus-Newsgroup-kill-file (newsgroup)
4248 "Return the name of a KILL file of NEWSGROUP.
4249 If NEWSGROUP is nil, return the global KILL file instead."
4250 (cond ((or (null newsgroup
)
4251 (string-equal newsgroup
""))
4252 ;; The global KILL file is placed at top of the directory.
4253 (expand-file-name gnus-kill-file-name
4254 (or gnus-article-save-directory
"~/News")))
4255 (gnus-use-long-file-name
4256 ;; Append ".KILL" to capitalized newsgroup name.
4257 (expand-file-name (concat (capitalize newsgroup
)
4258 "." gnus-kill-file-name
)
4259 (or gnus-article-save-directory
"~/News")))
4261 ;; Place "KILL" under the hierarchical directory.
4262 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup
)
4263 "/" gnus-kill-file-name
)
4264 (or gnus-article-save-directory
"~/News")))
4267 (defun gnus-newsgroup-kill-file (newsgroup)
4268 "Return the name of a KILL file of NEWSGROUP.
4269 If NEWSGROUP is nil, return the global KILL file instead."
4270 (cond ((or (null newsgroup
)
4271 (string-equal newsgroup
""))
4272 ;; The global KILL file is placed at top of the directory.
4273 (expand-file-name gnus-kill-file-name
4274 (or gnus-article-save-directory
"~/News")))
4275 (gnus-use-long-file-name
4276 ;; Append ".KILL" to newsgroup name.
4277 (expand-file-name (concat newsgroup
"." gnus-kill-file-name
)
4278 (or gnus-article-save-directory
"~/News")))
4280 ;; Place "KILL" under the hierarchical directory.
4281 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup
)
4282 "/" gnus-kill-file-name
)
4283 (or gnus-article-save-directory
"~/News")))
4286 (defun gnus-newsgroup-directory-form (newsgroup)
4287 "Make hierarchical directory name from NEWSGROUP name."
4288 (let ((newsgroup (substring newsgroup
0)) ;Copy string.
4289 (len (length newsgroup
))
4291 ;; Replace all occurence of `.' with `/'.
4293 (if (= (aref newsgroup idx
) ?.
)
4294 (aset newsgroup idx ?
/))
4295 (setq idx
(1+ idx
)))
4299 (defun gnus-make-directory (directory)
4300 "Make DIRECTORY recursively."
4301 (let ((directory (expand-file-name directory default-directory
)))
4302 (or (file-exists-p directory
)
4303 (gnus-make-directory-1 "" directory
))
4306 (defun gnus-make-directory-1 (head tail
)
4307 (cond ((string-match "^/\\([^/]+\\)" tail
)
4309 (concat (file-name-as-directory head
)
4310 (substring tail
(match-beginning 1) (match-end 1))))
4311 (or (file-exists-p head
)
4312 (call-process "mkdir" nil nil nil head
))
4313 (gnus-make-directory-1 head
(substring tail
(match-end 1))))
4314 ((string-equal tail
"") t
)
4317 (defun gnus-simplify-subject (subject &optional re-only
)
4318 "Remove `Re:' and words in parentheses.
4319 If optional argument RE-ONLY is non-nil, strip `Re:' only."
4320 (let ((case-fold-search t
)) ;Ignore case.
4321 ;; Remove `Re:' and `Re^N:'.
4322 (if (string-match "\\`\\(re\\(\\^[0-9]+\\)?:[ \t]+\\)+" subject
)
4323 (setq subject
(substring subject
(match-end 0))))
4324 ;; Remove words in parentheses from end.
4326 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject
)
4327 (setq subject
(substring subject
0 (match-beginning 0)))))
4328 ;; Return subject string.
4332 (defun gnus-optional-lines-and-from (header)
4333 "Return a string like `NNN:AUTHOR' from HEADER."
4334 (let ((name-length (length "umerin@photon")))
4335 (substring (format "%3d:%s"
4336 ;; Lines of the article.
4337 ;; Suggested by dana@bellcore.com.
4338 (nntp-header-lines header
)
4340 (concat (mail-strip-quoted-names
4341 (nntp-header-from header
))
4342 (make-string name-length ?
)))
4343 ;; 4 stands for length of `NNN:'.
4344 0 (+ 4 name-length
))))
4346 (defun gnus-optional-lines (header)
4347 "Return a string like `NNN' from HEADER."
4348 (format "%4d" (nntp-header-lines header
)))
4350 (defun gnus-sort-headers (predicate &optional reverse
)
4351 "Sort current group headers by PREDICATE safely.
4352 *Safely* means C-g quitting is disabled during sorting.
4353 Optional argument REVERSE means reverse order."
4354 (let ((inhibit-quit t
))
4355 (setq gnus-newsgroup-headers
4357 (nreverse (sort (nreverse gnus-newsgroup-headers
) predicate
))
4358 (sort gnus-newsgroup-headers predicate
)))
4361 (defun gnus-string-lessp (a b
)
4362 "Return T if first arg string is less than second in lexicographic order.
4363 If case-fold-search is non-nil, case of letters is ignored."
4364 (if case-fold-search
4365 (string-lessp (downcase a
) (downcase b
)) (string-lessp a b
)))
4367 (defun gnus-date-lessp (date1 date2
)
4368 "Return T if DATE1 is earlyer than DATE2."
4369 (string-lessp (gnus-comparable-date date1
)
4370 (gnus-comparable-date date2
)))
4372 (defun gnus-comparable-date (date)
4373 "Make comparable string by string-lessp from DATE."
4374 (let ((month '(("JAN" .
" 1")("FEB" .
" 2")("MAR" .
" 3")
4375 ("APR" .
" 4")("MAY" .
" 5")("JUN" .
" 6")
4376 ("JUL" .
" 7")("AUG" .
" 8")("SEP" .
" 9")
4377 ("OCT" .
"10")("NOV" .
"11")("DEC" .
"12")))
4378 (date (or date
"")))
4379 ;; Can understand the following styles:
4380 ;; (1) 14 Apr 89 03:20:12 GMT
4381 ;; (2) Fri, 17 Mar 89 4:01:33 GMT
4383 "\\([0-9]+\\) \\([^ ,]+\\) \\([0-9]+\\) \\([0-9:]+\\)" date
)
4386 (substring date
(match-beginning 3) (match-end 3))
4390 (upcase (substring date
(match-beginning 2) (match-end 2))) month
))
4392 (format "%2d" (string-to-int
4394 (match-beginning 1) (match-end 1))))
4396 (substring date
(match-beginning 4) (match-end 4)))
4397 ;; Cannot understand DATE string.
4402 (defun gnus-fetch-field (field)
4403 "Return the value of the header FIELD of current article."
4407 (goto-char (point-min))
4408 (narrow-to-region (point-min)
4409 (progn (search-forward "\n\n" nil
'move
) (point)))
4410 (mail-fetch-field field
))))
4412 (fset 'gnus-expunge
'gnus-Subject-delete-marked-with
)
4414 (defun gnus-kill (field regexp
&optional command all
)
4415 "If FIELD of an article matches REGEXP, execute COMMAND.
4416 Optional third argument COMMAND is default to
4417 (gnus-Subject-mark-as-read nil \"X\").
4418 If optional fourth argument ALL is non-nil, articles marked are also applied
4419 to. If FIELD is an empty string (or nil), entire article body is searched for.
4420 COMMAND must be a lisp expression or a string representing a key sequence."
4421 ;; We don't want to change current point nor window configuration.
4423 (save-window-excursion
4424 ;; Selected window must be Subject mode buffer to execute
4425 ;; keyboard macros correctly. See command_loop_1.
4426 (switch-to-buffer gnus-Subject-buffer
'norecord
)
4427 (goto-char (point-min)) ;From the beginning.
4429 (setq command
'(gnus-Subject-mark-as-read nil
"X")))
4430 (gnus-execute field regexp command nil
(not all
))
4433 (defun gnus-execute (field regexp form
&optional backward ignore-marked
)
4434 "If FIELD of article header matches REGEXP, execute lisp FORM (or a string).
4435 If FIELD is an empty string (or nil), entire article body is searched for.
4436 If optional fifth argument BACKWARD is non-nil, do backward instead.
4437 If optional sixth argument IGNORE-MARKED is non-nil, articles which are
4438 marked as read or unread are ignored."
4439 (let ((function nil
)
4442 (if (string-equal field
"")
4447 (setq field
(symbol-name field
)))
4448 ;; Get access function of header filed.
4449 (setq function
(intern-soft (concat "gnus-header-" (downcase field
))))
4450 (if (and function
(fboundp function
))
4451 (setq function
(symbol-function function
))
4452 (error "Unknown header field: \"%s\"" field
)))
4453 ;; Make FORM funcallable.
4454 (if (and (listp form
) (not (eq (car form
) 'lambda
)))
4455 (setq form
(list 'lambda nil form
)))
4456 ;; Starting from the current article.
4457 (or (and ignore-marked
4458 ;; Articles marked as read and unread should be ignored.
4459 (setq article
(gnus-Subject-article-number))
4460 (or (not (memq article gnus-newsgroup-unreads
)) ;Marked as read.
4461 (memq article gnus-newsgroup-marked
) ;Marked as unread.
4463 (gnus-execute-1 function regexp form
))
4464 (while (gnus-Subject-search-subject backward ignore-marked nil
)
4465 (gnus-execute-1 function regexp form
))
4468 (defun gnus-execute-1 (function regexp form
)
4470 ;; The point of Subject mode buffer must be saved during execution.
4471 (let ((article (gnus-Subject-article-number)))
4475 ;; Compare with header field.
4476 (let ((header (gnus-find-header-by-number
4477 gnus-newsgroup-headers article
))
4481 (setq value
(funcall function header
))
4482 ;; Number (Lines:) or symbol must be converted to string.
4484 (setq value
(prin1-to-string value
)))
4485 (string-match regexp value
))
4486 (if (stringp form
) ;Keyboard macro.
4487 (execute-kbd-macro form
)
4489 ;; Search article body.
4490 (let ((gnus-current-article nil
) ;Save article pointer.
4491 (gnus-last-article nil
)
4492 (gnus-break-pages nil
) ;No need to break pages.
4493 (gnus-Mark-article-hook nil
)) ;Inhibit marking as read.
4494 (message "Searching for article: %d..." article
)
4495 (gnus-Article-setup-buffer)
4496 (gnus-Article-prepare article t
)
4498 (set-buffer gnus-Article-buffer
)
4499 (goto-char (point-min))
4500 (re-search-forward regexp nil t
))
4501 (if (stringp form
) ;Keyboard macro.
4502 (execute-kbd-macro form
)
4507 ;;; caesar-region written by phr@prep.ai.mit.edu Nov 86
4508 ;;; modified by tower@prep Nov 86
4509 ;;; Modified by umerin@flab.flab.Fujitsu.JUNET for ROT47.
4511 (defun gnus-caesar-region (&optional n
)
4512 "Caesar rotation of region by N, default 13, for decrypting netnews.
4513 ROT47 will be performed for Japanese text in any case."
4514 (interactive (if current-prefix-arg
; Was there a prefix arg?
4515 (list (prefix-numeric-value current-prefix-arg
))
4517 (cond ((not (numberp n
)) (setq n
13))
4518 ((< n
0) (setq n
(- 26 (%
(- n
) 26))))
4519 (t (setq n
(% n
26)))) ;canonicalize N
4520 (if (not (zerop n
)) ; no action needed for a rot of 0
4522 (if (or (not (boundp 'caesar-translate-table
))
4523 (/= (aref caesar-translate-table ?a
) (+ ?a n
)))
4524 (let ((i 0) (lower "abcdefghijklmnopqrstuvwxyz") upper
)
4525 (message "Building caesar-translate-table...")
4526 (setq caesar-translate-table
(make-vector 256 0))
4528 (aset caesar-translate-table i i
)
4530 (setq lower
(concat lower lower
) upper
(upcase lower
) i
0)
4532 (aset caesar-translate-table
(+ ?a i
) (aref lower
(+ i n
)))
4533 (aset caesar-translate-table
(+ ?A i
) (aref upper
(+ i n
)))
4535 ;; ROT47 for Japanese text.
4536 ;; Thanks to ichikawa@flab.fujitsu.junet.
4538 (let ((t1 (logior ?O
128))
4539 (t2 (logior ?
! 128))
4540 (t3 (logior ?~
128)))
4542 (aset caesar-translate-table i
4543 (let ((v (aref caesar-translate-table i
)))
4544 (if (<= v t1
) (if (< v t2
) v
(+ v
47))
4545 (if (<= v t3
) (- v
47) v
))))
4547 (message "Building caesar-translate-table... done")))
4548 (let ((from (region-beginning))
4551 (setq str
(buffer-substring from to
))
4552 (setq len
(length str
))
4554 (aset str i
(aref caesar-translate-table
(aref str i
)))
4557 (delete-region from to
)
4560 ;; Functions accessing headers.
4561 ;; Functions are more convenient than macros in some case.
4563 (defun gnus-header-number (header)
4564 "Return article number in HEADER."
4565 (nntp-header-number header
))
4567 (defun gnus-header-subject (header)
4568 "Return subject string in HEADER."
4569 (nntp-header-subject header
))
4571 (defun gnus-header-from (header)
4572 "Return author string in HEADER."
4573 (nntp-header-from header
))
4575 (defun gnus-header-xref (header)
4576 "Return xref string in HEADER."
4577 (nntp-header-xref header
))
4579 (defun gnus-header-lines (header)
4580 "Return lines in HEADER."
4581 (nntp-header-lines header
))
4583 (defun gnus-header-date (header)
4584 "Return date in HEADER."
4585 (nntp-header-date header
))
4587 (defun gnus-header-id (header)
4588 "Return Id in HEADER."
4589 (nntp-header-id header
))
4591 (defun gnus-header-references (header)
4592 "Return references in HEADER."
4593 (nntp-header-references header
))
4600 (defun gnus-output-to-rmail (file-name)
4601 "Append the current article to an Rmail file named FILE-NAME."
4603 ;; Most of these codes are borrowed from rmailout.el.
4604 (setq file-name
(expand-file-name file-name
))
4605 (setq rmail-last-rmail-file file-name
)
4606 (let ((artbuf (current-buffer))
4607 (tmpbuf (get-buffer-create " *GNUS-output*")))
4609 (or (get-file-buffer file-name
)
4610 (file-exists-p file-name
)
4612 (concat "\"" file-name
"\" does not exist, create it? "))
4613 (let ((file-buffer (create-file-buffer file-name
)))
4615 (set-buffer file-buffer
)
4616 (rmail-insert-rmail-file-header)
4617 (let ((require-final-newline nil
))
4618 (write-region (point-min) (point-max) file-name t
1)))
4619 (kill-buffer file-buffer
))
4620 (error "Output file does not exist")))
4622 (buffer-flush-undo (current-buffer))
4624 (insert-buffer-substring artbuf
)
4625 (gnus-convert-article-to-rmail)
4626 ;; Decide whether to append to a file or to an Emacs buffer.
4627 (let ((outbuf (get-file-buffer file-name
)))
4629 (append-to-file (point-min) (point-max) file-name
)
4630 ;; File has been visited, in buffer OUTBUF.
4632 (let ((buffer-read-only nil
)
4633 (msg (and (boundp 'rmail-current-message
)
4634 rmail-current-message
)))
4635 ;; If MSG is non-nil, buffer is in RMAIL mode.
4638 (narrow-to-region (point-max) (point-max))))
4639 (insert-buffer-substring tmpbuf
)
4642 (goto-char (point-min))
4644 (search-backward "\^_")
4645 (narrow-to-region (point) (point-max))
4646 (goto-char (1+ (point-min)))
4647 (rmail-count-new-messages t
)
4648 (rmail-show-message msg
))))))
4650 (kill-buffer tmpbuf
)
4653 (defun gnus-output-to-file (file-name)
4654 "Append the current article to a file named FILE-NAME."
4655 (setq file-name
(expand-file-name file-name
))
4656 (let ((artbuf (current-buffer))
4657 (tmpbuf (get-buffer-create " *GNUS-output*")))
4660 (buffer-flush-undo (current-buffer))
4662 (insert-buffer-substring artbuf
)
4663 ;; Append newline at end of the buffer as separator, and then
4665 (goto-char (point-max))
4667 (append-to-file (point-min) (point-max) file-name
))
4668 (kill-buffer tmpbuf
)
4671 (defun gnus-convert-article-to-rmail ()
4672 "Convert article in current buffer to Rmail message format."
4673 (let ((buffer-read-only nil
))
4674 ;; Convert article directly into Babyl format.
4675 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
4676 (goto-char (point-min))
4677 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
4678 (while (search-forward "\n\^_" nil t
) ;single char
4679 (replace-match "\n^_")) ;2 chars: "^" and "_"
4680 (goto-char (point-max))
4683 ;;(defun gnus-convert-article-to-rmail ()
4684 ;; "Convert article in current buffer to Rmail message format."
4685 ;; (let ((buffer-read-only nil))
4686 ;; ;; Insert special header of Unix mail.
4687 ;; (goto-char (point-min))
4689 ;; (or (mail-strip-quoted-names (mail-fetch-field "from"))
4691 ;; " " (current-time-string) "\n")
4692 ;; ;; Stop quoting `From' since this seems unnecessary in most cases.
4693 ;; ;; ``Quote'' "\nFrom " as "\n>From "
4694 ;; ;;(while (search-forward "\nFrom " nil t)
4695 ;; ;; (forward-char -5)
4697 ;; ;; Convert article to babyl format.
4698 ;; (rmail-convert-to-babyl-format)
4703 ;;; Internal functions.
4706 (defun gnus-start-news-server (&optional confirm
)
4707 "Open network stream to remote NNTP server.
4708 If optional argument CONFIRM is non-nil, ask you host that NNTP server
4709 is running even if it is defined.
4710 Run gnus-Open-server-hook just before opening news server."
4711 (if (gnus-server-opened)
4712 ;; Stream is already opened.
4714 ;; Open NNTP server.
4716 (null gnus-nntp-server
))
4717 (if (and (boundp 'gnus-secondary-servers
) gnus-secondary-servers
)
4718 ;; Read server name with completion.
4719 (setq gnus-nntp-server
4720 (completing-read "NNTP server: "
4721 (cons (list gnus-nntp-server
)
4722 gnus-secondary-servers
)
4723 nil nil gnus-nntp-server
))
4724 (setq gnus-nntp-server
4725 (read-string "NNTP server: " gnus-nntp-server
))))
4726 ;; If no server name is given, local host is assumed.
4727 (if (string-equal gnus-nntp-server
"")
4728 (setq gnus-nntp-server
(system-name)))
4729 (cond ((string= gnus-nntp-server
) "::")
4731 (gnus-define-access-method 'nnspool
)
4732 (message "Looking up local news spool..."))
4733 ((string-match ":" gnus-nntp-server
)
4736 (gnus-define-access-method 'mhspool
)
4737 (message "Looking up private directory..."))
4739 (gnus-define-access-method 'nntp
)
4740 (message "Connecting to NNTP server on %s..." gnus-nntp-server
)))
4741 (run-hooks 'gnus-Open-server-hook
)
4742 (cond ((gnus-open-server gnus-nntp-server gnus-nntp-service
))
4743 ((and (stringp (gnus-status-message))
4744 (> (length (gnus-status-message)) 0))
4745 ;; Show valuable message if available.
4746 (error (gnus-status-message)))
4747 (t (error "Cannot open NNTP server on %s" gnus-nntp-server
)))
4750 ;; Dummy functions used only once. Should return nil.
4751 (defun gnus-server-opened () nil
)
4752 (defun gnus-close-server () nil
)
4754 (defun gnus-define-access-method (method &optional access-methods
)
4755 "Define access functions for the access METHOD.
4756 Methods defintion is taken from optional argument ACCESS-METHODS or
4757 the variable gnus-access-methods."
4759 (cdr (assoc method
(or access-methods gnus-access-methods
)))))
4761 (error "Unknown access method: %s" method
)
4762 ;; Should not use symbol-function here since overload does not work.
4764 (fset (car (car bindings
)) (cdr (car bindings
)))
4765 (setq bindings
(cdr bindings
)))
4768 (defun gnus-select-newsgroup (group &optional show-all
)
4769 "Select newsgroup GROUP.
4770 If optional argument SHOW-ALL is non-nil, all of articles in the group
4772 (if (gnus-request-group group
)
4773 (let ((articles nil
))
4774 (setq gnus-newsgroup-name group
)
4775 (setq gnus-newsgroup-unreads
4776 (gnus-uncompress-sequence
4777 (nthcdr 2 (gnus-gethash group gnus-unread-hashtb
))))
4779 ;; Select all active articles.
4781 (gnus-uncompress-sequence
4782 (nthcdr 2 (gnus-gethash group gnus-active-hashtb
)))))
4784 ;; Select unread articles only.
4785 (setq articles gnus-newsgroup-unreads
)))
4786 ;; Require confirmation if selecting large newsgroup.
4787 (setq gnus-newsgroup-unselected nil
)
4788 (if (not (numberp gnus-large-newsgroup
))
4790 (let ((selected nil
)
4791 (number (length articles
)))
4792 (if (> number gnus-large-newsgroup
)
4798 "How many articles from %s (default %d): "
4799 gnus-newsgroup-name number
))))
4801 (if (string-equal input
"")
4802 number
(string-to-int input
))))
4805 (cond ((and (> selected
0)
4806 (< selected number
))
4807 ;; Select last N articles.
4808 (setq articles
(nthcdr (- number selected
) articles
)))
4809 ((and (< selected
0)
4810 (< (- 0 selected
) number
))
4811 ;; Select first N articles.
4812 (setq selected
(- 0 selected
))
4813 (setq articles
(copy-sequence articles
))
4814 (setcdr (nthcdr (1- selected
) articles
) nil
))
4816 (setq articles nil
))
4817 ;; Otherwise select all.
4819 ;; Get unselected unread articles.
4820 (setq gnus-newsgroup-unselected
4821 (gnus-set-difference gnus-newsgroup-unreads articles
))
4824 ;; Get headers list.
4825 (setq gnus-newsgroup-headers
(gnus-retrieve-headers articles
))
4826 ;; UNREADS may contain expired articles, so we have to remove
4827 ;; them from the list.
4828 (setq gnus-newsgroup-unreads
4829 (gnus-intersection gnus-newsgroup-unreads
4833 (nntp-header-number header
)))
4834 gnus-newsgroup-headers
)))
4835 ;; Marked article must be a subset of unread articles.
4836 (setq gnus-newsgroup-marked
4837 (gnus-intersection (append gnus-newsgroup-unselected
4838 gnus-newsgroup-unreads
)
4839 (cdr (assoc group gnus-marked-assoc
))))
4840 ;; First and last article in this newsgroup.
4841 (setq gnus-newsgroup-begin
4842 (if gnus-newsgroup-headers
4843 (nntp-header-number (car gnus-newsgroup-headers
))
4846 (setq gnus-newsgroup-end
4847 (if gnus-newsgroup-headers
4849 (gnus-last-element gnus-newsgroup-headers
))
4852 ;; File name that an article was saved last.
4853 (setq gnus-newsgroup-last-rmail nil
)
4854 (setq gnus-newsgroup-last-mail nil
)
4855 (setq gnus-newsgroup-last-folder nil
)
4856 (setq gnus-newsgroup-last-file nil
)
4857 ;; Reset article pointer etc.
4858 (setq gnus-current-article nil
)
4859 (setq gnus-current-headers nil
)
4860 (setq gnus-current-history nil
)
4861 (setq gnus-have-all-headers nil
)
4862 (setq gnus-last-article nil
)
4863 ;; GROUP is successfully selected.
4868 (defun gnus-more-header-backward ()
4869 "Find new header backward."
4871 (car (nth 2 (gnus-gethash gnus-newsgroup-name gnus-active-hashtb
))))
4872 (artnum gnus-newsgroup-begin
)
4874 (while (and (not header
)
4876 (setq artnum
(1- artnum
))
4877 (setq header
(car (gnus-retrieve-headers (list artnum
)))))
4881 (defun gnus-more-header-forward ()
4882 "Find new header forward."
4884 (cdr (nth 2 (gnus-gethash gnus-newsgroup-name gnus-active-hashtb
))))
4885 (artnum gnus-newsgroup-end
)
4887 (while (and (not header
)
4889 (setq artnum
(1+ artnum
))
4890 (setq header
(car (gnus-retrieve-headers (list artnum
)))))
4894 (defun gnus-extend-newsgroup (header &optional backward
)
4895 "Extend newsgroup selection with HEADER.
4896 Optional argument BACKWARD means extend toward backward."
4898 (let ((artnum (nntp-header-number header
)))
4899 (setq gnus-newsgroup-headers
4901 (cons header gnus-newsgroup-headers
)
4902 (append gnus-newsgroup-headers
(list header
))))
4903 ;; We have to update unreads and unselected, but don't have to
4904 ;; care about gnus-newsgroup-marked.
4905 (if (memq artnum gnus-newsgroup-unselected
)
4906 (setq gnus-newsgroup-unreads
4907 (cons artnum gnus-newsgroup-unreads
)))
4908 (setq gnus-newsgroup-unselected
4909 (delq artnum gnus-newsgroup-unselected
))
4910 (setq gnus-newsgroup-begin
(min gnus-newsgroup-begin artnum
))
4911 (setq gnus-newsgroup-end
(max gnus-newsgroup-end artnum
))
4914 (defun gnus-mark-article-as-read (article)
4915 "Remember that ARTICLE is marked as read."
4916 ;; Remove from unread and marked list.
4917 (setq gnus-newsgroup-unreads
4918 (delq article gnus-newsgroup-unreads
))
4919 (setq gnus-newsgroup-marked
4920 (delq article gnus-newsgroup-marked
)))
4922 (defun gnus-mark-article-as-unread (article &optional clear-mark
)
4923 "Remember that ARTICLE is marked as unread.
4924 Optional argument CLEAR-MARK means ARTICLE should not be remembered
4925 that it was marked as read once."
4926 ;; Add to unread list.
4927 (or (memq article gnus-newsgroup-unreads
)
4928 (setq gnus-newsgroup-unreads
4929 (cons article gnus-newsgroup-unreads
)))
4930 ;; If CLEAR-MARK is non-nil, the article must be removed from marked
4931 ;; list. Otherwise, it must be added to the list.
4933 (setq gnus-newsgroup-marked
4934 (delq article gnus-newsgroup-marked
))
4935 (or (memq article gnus-newsgroup-marked
)
4936 (setq gnus-newsgroup-marked
4937 (cons article gnus-newsgroup-marked
)))))
4939 (defun gnus-clear-system ()
4940 "Clear all variables and buffer."
4941 ;; Clear GNUS variables.
4942 (let ((variables gnus-variable-list
))
4944 (set (car variables
) nil
)
4945 (setq variables
(cdr variables
))))
4946 ;; Clear other internal variables.
4947 (setq gnus-active-hashtb nil
)
4948 (setq gnus-unread-hashtb nil
)
4949 ;; Kill the startup file.
4950 (and gnus-current-startup-file
4951 (get-file-buffer gnus-current-startup-file
)
4952 (kill-buffer (get-file-buffer gnus-current-startup-file
)))
4953 (setq gnus-current-startup-file nil
)
4954 ;; Kill GNUS buffers.
4955 (let ((buffers gnus-buffer-list
))
4957 (if (get-buffer (car buffers
))
4958 (kill-buffer (car buffers
)))
4959 (setq buffers
(cdr buffers
))
4962 (defun gnus-configure-windows (action)
4963 "Configure GNUS windows according to the next ACTION.
4964 The ACTION is either a symbol, such as `SelectNewsgroup', or a
4965 configuration list such as `(1 1 2)'. If ACTION is not a list,
4966 configuration list is got from the variable gnus-window-configuration."
4969 action
(car (cdr (assq action gnus-window-configuration
)))))
4970 (grpwin (get-buffer-window gnus-Group-buffer
))
4971 (subwin (get-buffer-window gnus-Subject-buffer
))
4972 (artwin (get-buffer-window gnus-Article-buffer
))
4978 (if (or (null windows
) ;No configuration is specified.
4979 (and (eq (null grpwin
)
4980 (zerop (nth 0 windows
)))
4982 (zerop (nth 1 windows
)))
4984 (zerop (nth 2 windows
)))))
4985 ;; No need to change window configuration.
4987 (select-window (or grpwin subwin artwin
(selected-window)))
4988 ;; First of all, compute the height of each window.
4989 (cond (gnus-use-full-window
4990 ;; Take up the entire screen.
4991 (delete-other-windows)
4992 (setq height
(window-height (selected-window))))
4994 (setq height
(+ (if grpwin
(window-height grpwin
) 0)
4995 (if subwin
(window-height subwin
) 0)
4996 (if artwin
(window-height artwin
) 0)))))
4997 ;; The Newsgroup buffer exits always. So, use it to extend the
4998 ;; Group window so as to get enough window space.
4999 (switch-to-buffer gnus-Group-buffer
'norecord
)
5000 (and (get-buffer gnus-Subject-buffer
)
5001 (delete-windows-on gnus-Subject-buffer
))
5002 (and (get-buffer gnus-Article-buffer
)
5003 (delete-windows-on gnus-Article-buffer
))
5004 ;; Compute expected window height.
5005 (setq winsum
(apply (function +) windows
))
5006 (if (not (zerop (nth 0 windows
)))
5007 (setq grpheight
(max window-min-height
5008 (/ (* height
(nth 0 windows
)) winsum
))))
5009 (if (not (zerop (nth 1 windows
)))
5010 (setq subheight
(max window-min-height
5011 (/ (* height
(nth 1 windows
)) winsum
))))
5012 (if (not (zerop (nth 2 windows
)))
5013 (setq artheight
(max window-min-height
5014 (/ (* height
(nth 2 windows
)) winsum
))))
5015 (setq height
(+ grpheight subheight artheight
))
5016 (enlarge-window (max 0 (- height
(window-height (selected-window)))))
5017 ;; Then split the window.
5018 (and (not (zerop artheight
))
5019 (or (not (zerop grpheight
))
5020 (not (zerop subheight
)))
5021 (split-window-vertically (+ grpheight subheight
)))
5022 (and (not (zerop grpheight
))
5023 (not (zerop subheight
))
5024 (split-window-vertically grpheight
))
5025 ;; Then select buffers in each window.
5026 (and (not (zerop grpheight
))
5028 (switch-to-buffer gnus-Group-buffer
'norecord
)
5030 (and (not (zerop subheight
))
5032 (switch-to-buffer gnus-Subject-buffer
'norecord
)
5034 (and (not (zerop artheight
))
5036 ;; If Article buffer does not exist, it will be created
5038 (gnus-Article-setup-buffer)
5039 (switch-to-buffer gnus-Article-buffer
'norecord
)))
5043 (defun gnus-find-header-by-number (headers number
)
5044 "Return a header which is a element of HEADERS and has NUMBER."
5046 (while (and headers
(not found
))
5047 ;; We cannot use `=' to accept non-numeric NUMBER.
5048 (if (eq number
(nntp-header-number (car headers
)))
5049 (setq found
(car headers
)))
5050 (setq headers
(cdr headers
)))
5054 (defun gnus-find-header-by-id (headers id
)
5055 "Return a header which is a element of HEADERS and has Message-ID."
5057 (while (and headers
(not found
))
5058 (if (string-equal id
(nntp-header-id (car headers
)))
5059 (setq found
(car headers
)))
5060 (setq headers
(cdr headers
)))
5064 (defun gnus-version ()
5065 "Version numbers of this version of GNUS."
5067 (cond ((and (boundp 'mhspool-version
) (boundp 'nnspool-version
))
5068 (message "%s; %s; %s; %s"
5069 gnus-version nntp-version nnspool-version mhspool-version
))
5070 ((boundp 'mhspool-version
)
5071 (message "%s; %s; %s"
5072 gnus-version nntp-version mhspool-version
))
5073 ((boundp 'nnspool-version
)
5074 (message "%s; %s; %s"
5075 gnus-version nntp-version nnspool-version
))
5077 (message "%s; %s" gnus-version nntp-version
))))
5079 (defun gnus-Info-find-node ()
5080 "Find Info documentation of GNUS."
5083 ;; Enlarge info window if needed.
5084 (cond ((eq major-mode
'gnus-Group-mode
)
5085 (gnus-configure-windows '(1 0 0)) ;Take all windows.
5086 (pop-to-buffer gnus-Group-buffer
))
5087 ((eq major-mode
'gnus-Subject-mode
)
5088 (gnus-configure-windows '(0 1 0)) ;Take all windows.
5089 (pop-to-buffer gnus-Subject-buffer
)))
5090 (Info-goto-node (cdr (assq major-mode gnus-Info-nodes
))))
5092 (defun gnus-overload-functions (&optional overloads
)
5093 "Overload functions specified by optional argument OVERLOADS.
5094 If nothing is specified, use the variable gnus-overload-functions."
5096 (overloads (or overloads gnus-overload-functions
)))
5098 (setq defs
(car overloads
))
5099 (setq overloads
(cdr overloads
))
5100 ;; Load file before overloading function if necessary. Make
5101 ;; sure we cannot use `requre' always.
5102 (and (not (fboundp (car defs
)))
5103 (car (cdr (cdr defs
)))
5104 (load (car (cdr (cdr defs
))) nil
'nomessage
))
5105 (fset (car defs
) (car (cdr defs
)))
5108 (defun gnus-make-threads (newsgroup-headers)
5109 "Make conversation threads tree from NEWSGROUP-HEADERS."
5110 (let ((headers newsgroup-headers
)
5115 ;; Make message dependency alist.
5117 (setq h
(car headers
))
5118 (setq headers
(cdr headers
))
5119 ;; Ignore invalid headers.
5120 (if (vectorp h
) ;Depends on nntp.el.
5122 ;; Ignore broken references, e.g "<123@a.b.c".
5123 (setq d
(and (nntp-header-references h
)
5124 (string-match "\\(<[^<>]+>\\)[^>]*$"
5125 (nntp-header-references h
))
5126 (gnus-find-header-by-id
5128 (substring (nntp-header-references h
)
5129 (match-beginning 1) (match-end 1)))))
5130 ;; Check subject equality.
5131 (or gnus-thread-ignore-subject
5133 (string-equal (gnus-simplify-subject
5134 (nntp-header-subject h
) 're
)
5135 (gnus-simplify-subject
5136 (nntp-header-subject d
) 're
))
5137 ;; H should be a thread root.
5141 (cons (cons h d
) dependencies
))
5142 ;; H is a thread root.
5144 (setq roots
(cons h roots
)))
5147 ;; Make complete threads from the roots.
5148 ;; Note: dependencies are in reverse order, but
5149 ;; gnus-make-threads-1 processes it in reverse order again. So,
5150 ;; we don't have to worry about it.
5154 (gnus-make-threads-1 root dependencies
))) (nreverse roots
))
5157 (defun gnus-make-threads-1 (parent dependencies
)
5158 (let ((children nil
)
5160 (depends dependencies
))
5163 (setq d
(car depends
))
5164 (setq depends
(cdr depends
))
5166 (eq (nntp-header-id parent
) (nntp-header-id (cdr d
)))
5167 (setq children
(cons (car d
) children
))))
5173 (gnus-make-threads-1 child dependencies
))) children
))
5176 (defun gnus-narrow-to-page (&optional arg
)
5177 "Make text outside current page invisible except for page delimiter.
5178 A numeric arg specifies to move forward or backward by that many pages,
5179 thus showing a page other than the one point was originally in."
5181 (setq arg
(if arg
(prefix-numeric-value arg
) 0))
5183 (forward-page -
1) ;Beginning of current page.
5188 (forward-page (1- arg
))))
5189 ;; Find the end of the page.
5191 ;; If we stopped due to end of buffer, stay there.
5192 ;; If we stopped after a page delimiter, put end of restriction
5193 ;; at the beginning of that line.
5194 ;; These are commented out.
5195 ;; (if (save-excursion (beginning-of-line)
5196 ;; (looking-at page-delimiter))
5197 ;; (beginning-of-line))
5198 (narrow-to-region (point)
5200 ;; Find the top of the page.
5202 ;; If we found beginning of buffer, stay there.
5203 ;; If extra text follows page delimiter on same line,
5205 ;; Otherwise, show text starting with following line.
5206 (if (and (eolp) (not (bobp)))
5211 (defun gnus-last-element (list)
5212 "Return last element of LIST."
5215 (if (null (cdr list
))
5216 (setq last
(car list
)))
5217 (setq list
(cdr list
)))
5221 (defun gnus-set-difference (list1 list2
)
5222 "Return a list of elements of LIST1 that do not appear in LIST2."
5223 (let ((list1 (copy-sequence list1
)))
5225 (setq list1
(delq (car list2
) list1
))
5226 (setq list2
(cdr list2
)))
5230 (defun gnus-intersection (list1 list2
)
5231 "Return a list of elements that appear in both LIST1 and LIST2."
5234 (if (memq (car list2
) list1
)
5235 (setq result
(cons (car list2
) result
)))
5236 (setq list2
(cdr list2
)))
5242 ;;; Get information about active articles, already read articles, and
5243 ;;; still unread articles.
5246 ;; GNUS internal format of gnus-newsrc-assoc and gnus-killed-assoc:
5247 ;; (("general" t (1 . 1))
5248 ;; ("misc" t (1 . 10) (12 . 15))
5249 ;; ("test" nil (1 . 99)) ...)
5250 ;; GNUS internal format of gnus-marked-assoc:
5251 ;; (("general" 1 2 3)
5253 ;; GNUS internal format of gnus-active-hashtb:
5254 ;; (("general" t (1 . 1))
5255 ;; ("misc" t (1 . 10))
5256 ;; ("test" nil (1 . 99)) ...)
5257 ;; GNUS internal format of gnus-unread-hashtb:
5258 ;; (("general" 1 (1 . 1))
5259 ;; ("misc" 14 (1 . 10) (12 . 15))
5260 ;; ("test" 99 (1 . 99)) ...)
5262 (defun gnus-setup-news-info (&optional rawfile
)
5263 "Setup news information.
5264 If optional argument RAWFILE is non-nil, force to read raw startup file."
5265 (let ((init (not (and gnus-newsrc-assoc
5270 ;; We have to clear some variables to re-initialize news info.
5272 (setq gnus-newsrc-assoc nil
5273 gnus-active-hashtb nil
5274 gnus-unread-hashtb nil
))
5276 (gnus-read-newsrc-file rawfile
))
5277 (gnus-read-active-file)
5278 (gnus-expire-marked-articles)
5279 (gnus-get-unread-articles)
5280 ;; Check new newsgroups and subscribe them.
5282 (let ((new-newsgroups (gnus-find-new-newsgroups)))
5283 (while new-newsgroups
5284 (funcall gnus-subscribe-newsgroup-method
(car new-newsgroups
))
5285 (setq new-newsgroups
(cdr new-newsgroups
))
5289 (defun gnus-subscribe-newsgroup (newsgroup &optional next
)
5290 "Subscribe new NEWSGROUP.
5291 If optional argument NEXT is non-nil, it is inserted before NEXT."
5292 (gnus-insert-newsgroup (list newsgroup t
) next
)
5293 (message "Newsgroup %s is subscribed" newsgroup
))
5295 (defun gnus-add-newsgroup (newsgroup)
5296 "Subscribe new NEWSGROUP safely and put it at top."
5297 (and (null (assoc newsgroup gnus-newsrc-assoc
)) ;Really new?
5298 (gnus-gethash newsgroup gnus-active-hashtb
) ;Really exist?
5299 (gnus-insert-newsgroup (or (assoc newsgroup gnus-killed-assoc
)
5301 (car (car gnus-newsrc-assoc
)))))
5303 (defun gnus-find-new-newsgroups ()
5304 "Looking for new newsgroups and return names.
5305 `-n' option of options line in .newsrc file is recognized."
5307 (new-newsgroups nil
))
5311 (setq group
(symbol-name sym
))
5312 ;; Taking account of `-n' option.
5313 (and (or (null gnus-newsrc-options-n-no
)
5314 (not (string-match gnus-newsrc-options-n-no group
))
5315 (and gnus-newsrc-options-n-yes
5316 (string-match gnus-newsrc-options-n-yes group
)))
5317 (null (assoc group gnus-killed-assoc
)) ;Ignore killed.
5318 (null (assoc group gnus-newsrc-assoc
)) ;Really new.
5319 ;; Find new newsgroup.
5320 (setq new-newsgroups
5321 (cons group new-newsgroups
)))
5324 ;; Return new newsgroups.
5328 (defun gnus-kill-newsgroup (group)
5329 "Kill GROUP from gnus-newsrc-assoc, .newsrc and gnus-unread-hashtb."
5330 (let ((info (assoc group gnus-newsrc-assoc
)))
5333 ;; Delete from gnus-newsrc-assoc
5334 (setq gnus-newsrc-assoc
(delq info gnus-newsrc-assoc
))
5335 ;; Add to gnus-killed-assoc.
5336 (setq gnus-killed-assoc
5338 (delq (assoc group gnus-killed-assoc
) gnus-killed-assoc
)))
5339 ;; Clear unread hashtable.
5340 ;; Thanks cwitty@csli.Stanford.EDU (Carl Witty).
5341 (gnus-sethash group nil gnus-unread-hashtb
)
5342 ;; Then delete from .newsrc
5343 (gnus-update-newsrc-buffer group
'delete
)
5344 ;; Return the deleted newsrc entry.
5348 (defun gnus-insert-newsgroup (info &optional next
)
5349 "Insert newsrc INFO entry before NEXT.
5350 If optional argument NEXT is nil, appended to the last."
5352 (error "Invalid argument: %s" info
))
5353 (let* ((group (car info
)) ;Newsgroup name.
5355 (gnus-difference-of-range
5356 (nth 2 (gnus-gethash group gnus-active-hashtb
)) (nthcdr 2 info
))))
5357 ;; Check duplication.
5358 (if (assoc group gnus-newsrc-assoc
)
5359 (error "Duplicated: %s" group
))
5360 ;; Insert to gnus-newsrc-assoc.
5361 (if (string-equal next
(car (car gnus-newsrc-assoc
)))
5362 (setq gnus-newsrc-assoc
5363 (cons info gnus-newsrc-assoc
))
5365 (rest gnus-newsrc-assoc
)
5366 (tail (cons nil gnus-newsrc-assoc
)))
5367 ;; Seach insertion point.
5368 (while (and (not found
) rest
)
5369 (if (string-equal next
(car (car rest
)))
5371 (setq rest
(cdr rest
))
5372 (setq tail
(cdr tail
))
5376 (setq gnus-newsrc-assoc
5377 (append gnus-newsrc-assoc
(cons info rest
)))
5379 ;; Delete from gnus-killed-assoc.
5380 (setq gnus-killed-assoc
5381 (delq (assoc group gnus-killed-assoc
) gnus-killed-assoc
))
5382 ;; Then insert to .newsrc.
5383 (gnus-update-newsrc-buffer group nil next
)
5384 ;; Add to gnus-unread-hashtb.
5386 (cons group
;Newsgroup name.
5387 (cons (gnus-number-of-articles range
) range
))
5391 (defun gnus-check-killed-newsgroups ()
5392 "Check consistency between gnus-newsrc-assoc and gnus-killed-assoc."
5395 (old-killed gnus-killed-assoc
))
5397 (setq group
(car (car old-killed
)))
5398 (and (or (null gnus-newsrc-options-n-no
)
5399 (not (string-match gnus-newsrc-options-n-no group
))
5400 (and gnus-newsrc-options-n-yes
5401 (string-match gnus-newsrc-options-n-yes group
)))
5402 (null (assoc group gnus-newsrc-assoc
)) ;No duplication.
5403 ;; Subscribed in options line and not in gnus-newsrc-assoc.
5405 (cons (car old-killed
) new-killed
)))
5406 (setq old-killed
(cdr old-killed
))
5408 (setq gnus-killed-assoc
(nreverse new-killed
))
5411 (defun gnus-check-bogus-newsgroups (&optional confirm
)
5412 "Delete bogus newsgroups.
5413 If optional argument CONFIRM is non-nil, confirm deletion of newsgroups."
5414 (let ((group nil
) ;Newsgroup name temporary used.
5415 (old-newsrc gnus-newsrc-assoc
)
5417 (bogus nil
) ;List of bogus newsgroups.
5418 (old-killed gnus-killed-assoc
)
5420 (old-marked gnus-marked-assoc
)
5422 (message "Checking bogus newsgroups...")
5423 ;; Update gnus-newsrc-assoc.
5425 (setq group
(car (car old-newsrc
)))
5426 (if (or (gnus-gethash group gnus-active-hashtb
)
5429 (format "Delete bogus newsgroup: %s " group
)))))
5430 ;; Active newsgroup.
5431 (setq new-newsrc
(cons (car old-newsrc
) new-newsrc
))
5432 ;; Found a bogus newsgroup.
5433 (setq bogus
(cons group bogus
)))
5434 (setq old-newsrc
(cdr old-newsrc
))
5436 (setq gnus-newsrc-assoc
(nreverse new-newsrc
))
5437 ;; Update gnus-killed-assoc.
5438 ;; The killed newsgroups are deleted without any confirmations.
5440 (setq group
(car (car old-killed
)))
5441 (and (gnus-gethash group gnus-active-hashtb
)
5442 (null (assoc group gnus-newsrc-assoc
))
5443 ;; Active and really killed newsgroup.
5444 (setq new-killed
(cons (car old-killed
) new-killed
)))
5445 (setq old-killed
(cdr old-killed
))
5447 (setq gnus-killed-assoc
(nreverse new-killed
))
5448 ;; Remove BOGUS from .newsrc file.
5450 (gnus-update-newsrc-buffer (car bogus
) 'delete
)
5451 (setq bogus
(cdr bogus
)))
5452 ;; Update gnus-marked-assoc.
5454 (setq group
(car (car old-marked
)))
5455 (if (and (cdr (car old-marked
)) ;Non-empty?
5456 (assoc group gnus-newsrc-assoc
)) ;Not bogus?
5457 (setq new-marked
(cons (car old-marked
) new-marked
)))
5458 (setq old-marked
(cdr old-marked
)))
5459 (setq gnus-marked-assoc new-marked
)
5460 (message "Checking bogus newsgroups... done")
5463 (defun gnus-get-unread-articles ()
5464 "Compute diffs between active and read articles."
5465 (let ((read gnus-newsrc-assoc
)
5470 (message "Checking new news...")
5471 (or gnus-unread-hashtb
5472 (setq gnus-unread-hashtb
(gnus-make-hashtable)))
5474 (setq group-info
(car read
)) ;About one newsgroup
5475 (setq group-name
(car group-info
))
5476 (setq active
(nth 2 (gnus-gethash group-name gnus-active-hashtb
)))
5477 (if (and gnus-octive-hashtb
5478 ;; Is nothing changed?
5480 (nth 2 (gnus-gethash group-name gnus-octive-hashtb
)))
5481 ;; Is this newsgroup in the unread hash table?
5482 (gnus-gethash group-name gnus-unread-hashtb
)
5485 (setq range
(gnus-difference-of-range active
(nthcdr 2 group-info
)))
5486 (gnus-sethash group-name
5487 (cons group-name
;Group name
5488 (cons (gnus-number-of-articles range
)
5489 range
)) ;Range of unread articles
5492 (setq read
(cdr read
))
5494 (message "Checking new news... done")
5497 (defun gnus-expire-marked-articles ()
5498 "Check expired article which is marked as unread."
5499 (let ((marked-assoc gnus-marked-assoc
)
5501 (marked nil
) ;Current marked info.
5502 (articles nil
) ;List of marked articles.
5503 (updated nil
) ;List of real marked.
5506 (setq marked
(car marked-assoc
))
5507 (setq articles
(cdr marked
))
5510 (car (nth 2 (gnus-gethash (car marked
) gnus-active-hashtb
))))
5511 (while (and begin articles
)
5512 (if (>= (car articles
) begin
)
5513 ;; This article is still active.
5514 (setq updated
(cons (car articles
) updated
)))
5515 (setq articles
(cdr articles
)))
5518 (cons (cons (car marked
) updated
) updated-assoc
)))
5519 (setq marked-assoc
(cdr marked-assoc
)))
5520 (setq gnus-marked-assoc updated-assoc
)
5523 (defun gnus-mark-as-read-by-xref
5524 (group headers unreads
&optional subscribed-only
)
5525 "Mark articles as read using cross references and return updated newsgroups.
5526 Arguments are GROUP, HEADERS, UNREADS, and optional SUBSCRIBED-ONLY."
5527 (let ((xref-list nil
)
5529 (xrefs nil
) ;One Xref: field info.
5530 (xref nil
) ;(NEWSGROUP . ARTICLE)
5531 (gname nil
) ;Newsgroup name
5532 (article nil
)) ;Article number
5534 (setq header
(car headers
))
5535 (if (memq (nntp-header-number header
) unreads
)
5536 ;; This article is not yet marked as read.
5538 (setq xrefs
(gnus-parse-xref-field (nntp-header-xref header
)))
5539 ;; For each cross reference info. in one Xref: field.
5541 (setq xref
(car xrefs
))
5542 (setq gname
(car xref
)) ;Newsgroup name
5543 (setq article
(cdr xref
)) ;Article number
5544 (or (string-equal group gname
) ;Ignore current newsgroup.
5545 ;; Ignore unsubscribed newsgroup if requested.
5546 (and subscribed-only
5547 (not (nth 1 (assoc gname gnus-newsrc-assoc
))))
5548 ;; Ignore article marked as unread.
5549 (memq article
(cdr (assoc gname gnus-marked-assoc
)))
5550 (let ((group-xref (assoc gname xref-list
)))
5552 (if (memq article
(cdr group-xref
))
5554 (setcdr group-xref
(cons article
(cdr group-xref
))))
5555 ;; Create new assoc entry for GROUP.
5556 (setq xref-list
(cons (list gname article
) xref-list
)))
5558 (setq xrefs
(cdr xrefs
))
5560 (setq headers
(cdr headers
)))
5561 ;; Mark cross referenced articles as read.
5562 (gnus-mark-xrefed-as-read xref-list
)
5563 ;;(message "%s %s" (prin1-to-string unreads) (prin1-to-string xref-list))
5564 ;; Return list of updated group name.
5565 (mapcar (function car
) xref-list
)
5568 (defun gnus-parse-xref-field (xref-value)
5569 "Parse Xref: field value, and return list of `(group . article-id)'."
5570 (let ((xref-list nil
)
5571 (xref-value (or xref-value
"")))
5572 ;; Remove server host name.
5573 (if (string-match "^[ \t]*[^ \t,]+[ \t,]+\\(.*\\)$" xref-value
)
5574 (setq xref-value
(substring xref-value
(match-beginning 1)))
5575 (setq xref-value nil
))
5576 ;; Process each xref info.
5579 "^[ \t,]*\\([^ \t,]+\\):\\([0-9]+\\)[^0-9]*" xref-value
)
5585 (substring xref-value
(match-beginning 1) (match-end 1))
5588 (substring xref-value
(match-beginning 2) (match-end 2))))
5590 (setq xref-value
(substring xref-value
(match-end 2))))
5591 (setq xref-value nil
)))
5596 (defun gnus-mark-xrefed-as-read (xrefs)
5597 "Update unread article information using XREFS alist."
5602 (setq group
(car (car xrefs
)))
5603 (setq idlist
(cdr (car xrefs
)))
5604 (setq unread
(gnus-uncompress-sequence
5605 (nthcdr 2 (gnus-gethash group gnus-unread-hashtb
))))
5607 (setq unread
(delq (car idlist
) unread
))
5608 (setq idlist
(cdr idlist
)))
5609 (gnus-update-unread-articles group unread
'ignore
)
5610 (setq xrefs
(cdr xrefs
))
5613 (defun gnus-update-unread-articles (group unread-list marked-list
)
5614 "Update unread articles of GROUP using UNREAD-LIST and MARKED-LIST."
5615 (let ((active (nth 2 (gnus-gethash group gnus-active-hashtb
)))
5616 (unread (gnus-gethash group gnus-unread-hashtb
)))
5617 (if (or (null active
) (null unread
))
5618 ;; Ignore unknown newsgroup.
5620 ;; Update gnus-unread-hashtb.
5622 (setcdr (cdr unread
)
5623 (gnus-compress-sequence unread-list
))
5624 ;; All of the articles are read.
5625 (setcdr (cdr unread
) '((0 .
0))))
5626 ;; Number of unread articles.
5627 (setcar (cdr unread
)
5628 (gnus-number-of-articles (nthcdr 2 unread
)))
5629 ;; Update gnus-newsrc-assoc.
5630 (if (> (car active
) 0)
5631 ;; Articles from 1 to N are not active.
5632 (setq active
(cons 1 (cdr active
))))
5633 (setcdr (cdr (assoc group gnus-newsrc-assoc
))
5634 (gnus-difference-of-range active
(nthcdr 2 unread
)))
5635 ;; Update .newsrc buffer.
5636 (gnus-update-newsrc-buffer group
)
5637 ;; Update gnus-marked-assoc.
5638 (if (listp marked-list
) ;Includes NIL.
5639 (let ((marked (assoc group gnus-marked-assoc
)))
5641 (setcdr marked marked-list
))
5642 (marked-list ;Non-NIL.
5643 (setq gnus-marked-assoc
5644 (cons (cons group marked-list
)
5645 gnus-marked-assoc
)))
5649 (defun gnus-read-active-file ()
5650 "Get active file from NNTP server."
5651 (message "Reading active file...")
5652 (if (gnus-request-list) ;Get active file from server
5654 (set-buffer nntp-server-buffer
)
5655 ;; Save OLD active info.
5656 (setq gnus-octive-hashtb gnus-active-hashtb
)
5657 (setq gnus-active-hashtb
(gnus-make-hashtable))
5658 (gnus-active-to-gnus-format)
5659 (message "Reading active file... done"))
5660 (error "Cannot read active file from NNTP server.")))
5662 (defun gnus-active-to-gnus-format ()
5663 "Convert active file format to internal format."
5664 ;; Delete unnecessary lines.
5665 (goto-char (point-min))
5666 (delete-matching-lines "^to\\..*$")
5667 ;; Store active file in hashtable.
5668 (goto-char (point-min))
5671 "^\\([^ \t]+\\)[ \t]+\\([0-9]+\\)[ \t]+\\([0-9]+\\)[ \t]+\\([ymn]\\).*$"
5674 (buffer-substring (match-beginning 1) (match-end 1))
5675 (list (buffer-substring (match-beginning 1) (match-end 1))
5677 "y" (buffer-substring (match-beginning 4) (match-end 4)))
5678 (cons (string-to-int
5679 (buffer-substring (match-beginning 3) (match-end 3)))
5681 (buffer-substring (match-beginning 2) (match-end 2)))))
5682 gnus-active-hashtb
)))
5684 (defun gnus-read-newsrc-file (&optional rawfile
)
5686 If optional argument RAWFILE is non-nil, the raw startup file is read."
5687 (setq gnus-current-startup-file
5688 (let* ((file (expand-file-name gnus-startup-file nil
))
5689 (real-file (concat file
"-" gnus-nntp-server
)))
5690 (if (file-exists-p real-file
)
5692 ;; Reset variables which may be included in the quick startup file.
5693 (let ((variables gnus-variable-list
))
5695 (set (car variables
) nil
)
5696 (setq variables
(cdr variables
))))
5697 (let* ((newsrc-file gnus-current-startup-file
)
5698 (quick-file (concat newsrc-file
".el"))
5700 (newsrc-mod (nth 5 (file-attributes newsrc-file
)))
5701 (quick-mod (nth 5 (file-attributes quick-file
))))
5703 ;; Prepare .newsrc buffer.
5704 (set-buffer (find-file-noselect newsrc-file
))
5705 ;; It is not so good idea turning off undo.
5706 ;;(buffer-flush-undo (current-buffer))
5707 ;; Load quick .newsrc to restore gnus-marked-assoc and
5708 ;; gnus-killed-assoc even if gnus-newsrc-assoc is out of date.
5710 (setq quick-loaded
(load quick-file t t t
))
5712 (cond ((and (not rawfile
) ;Not forced to read the raw file.
5713 (or (and (fboundp 'file-newer-than-file-p
)
5714 (file-newer-than-file-p quick-file newsrc-file
))
5715 (and newsrc-mod quick-mod
5716 ;; .newsrc.el is newer than .newsrc.
5717 ;; Some older version does not support function
5718 ;; `file-newer-than-file-p'.
5719 (or (< (car newsrc-mod
) (car quick-mod
))
5720 (and (= (car newsrc-mod
) (car quick-mod
))
5721 (<= (nth 1 newsrc-mod
) (nth 1 quick-mod
))))
5724 gnus-newsrc-assoc
;Really loaded?
5726 ;; We don't have to read the raw startup file.
5729 ;; Since .newsrc file is newer than quick file, read it.
5730 (message "Reading %s..." newsrc-file
)
5731 (gnus-newsrc-to-gnus-format)
5732 (gnus-check-killed-newsgroups)
5733 (message "Reading %s... Done" newsrc-file
)))
5736 (defun gnus-make-newsrc-file (file)
5737 "Make server dependent file name by catenating FILE and server host name."
5738 (let* ((file (expand-file-name file nil
))
5739 (real-file (concat file
"-" gnus-nntp-server
)))
5740 (if (file-exists-p real-file
)
5744 (defun gnus-newsrc-to-gnus-format ()
5745 "Parse current buffer as .newsrc file."
5746 (let ((newsgroup nil
)
5751 ;; We have to re-initialize these variable (except for
5752 ;; gnus-marked-assoc and gnus-killed-assoc) because quick startup
5753 ;; file may contain bogus values.
5754 (setq gnus-newsrc-options nil
)
5755 (setq gnus-newsrc-options-n-yes nil
)
5756 (setq gnus-newsrc-options-n-no nil
)
5757 (setq gnus-newsrc-assoc nil
)
5758 ;; Save options line to variable.
5759 ;; Lines beginning with white spaces are treated as continuation
5760 ;; line. Refer man page of newsrc(5).
5761 (goto-char (point-min))
5762 (if (re-search-forward
5763 "^[ \t]*options[ \t]*\\(.*\\(\n[ \t]+.*\\)*\\)[ \t]*$" nil t
)
5765 ;; Save entire options line.
5766 (setq gnus-newsrc-options
5767 (buffer-substring (match-beginning 1) (match-end 1)))
5768 ;; Compile "-n" option.
5769 (if (string-match "\\(^\\|[ \t\n]\\)-n" gnus-newsrc-options
)
5771 (gnus-parse-n-options
5772 (substring gnus-newsrc-options
(match-end 0)))))
5773 (setq gnus-newsrc-options-n-yes
(car yes-and-no
))
5774 (setq gnus-newsrc-options-n-no
(cdr yes-and-no
))
5777 ;; Parse body of .newsrc file
5778 ;; Options line continuation lines must be also considered here.
5779 ;; Before supporting continuation lines, " newsgroup ! 1-5" was
5780 ;; okay, but now it is invalid. It should be "newsgroup! 1-5".
5781 (goto-char (point-min))
5782 ;; Due to overflows in regex.c, change the following regexp:
5783 ;; "^\\([^:! \t\n]+\\)\\([:!]\\)[ \t]*\\(.*\\)$"
5784 ;; Suggested by composer@bucsf.bu.edu (Jeff Kellem).
5785 (while (re-search-forward
5786 "^\\([^:! \t\n]+\\)\\([:!]\\)[ \t]*\\(\\(...\\)*.*\\)$" nil t
)
5787 (setq newsgroup
(buffer-substring (match-beginning 1) (match-end 1)))
5788 ;; Check duplications of newsgroups.
5789 ;; Note: Checking the duplications takes very long time.
5790 (if (assoc newsgroup gnus-newsrc-assoc
)
5791 (message "Ignore duplicated newsgroup: %s" newsgroup
)
5794 ":" (buffer-substring (match-beginning 2) (match-end 2))))
5795 (setq ranges
(buffer-substring (match-beginning 3) (match-end 3)))
5796 (setq read-list nil
)
5797 (while (string-match "^[, \t]*\\([0-9-]+\\)" ranges
)
5798 (setq subrange
(substring ranges
(match-beginning 1) (match-end 1)))
5799 (setq ranges
(substring ranges
(match-end 1)))
5800 (cond ((string-match "^\\([0-9]+\\)-\\([0-9]+\\)$" subrange
)
5803 (cons (string-to-int
5805 (match-beginning 1) (match-end 1)))
5808 (match-beginning 2) (match-end 2))))
5810 ((string-match "^[0-9]+$" subrange
)
5812 (cons (cons (string-to-int subrange
)
5813 (string-to-int subrange
))
5816 (ding) (message "Ignoring bogus lines of %s" newsgroup
)
5819 (setq gnus-newsrc-assoc
5820 (cons (cons newsgroup
(cons subscribe
(nreverse read-list
)))
5823 (setq gnus-newsrc-assoc
5824 (nreverse gnus-newsrc-assoc
))
5827 (defun gnus-parse-n-options (options)
5828 "Parse -n NEWSGROUPS options and return a cons of YES and NO regexps."
5831 (yes-or-no nil
) ;`!' or not.
5833 ;; Parse each newsgroup description such as "comp.all". Commas
5834 ;; and white spaces can be a newsgroup separator.
5836 (string-match "^[ \t\n,]*\\(!?\\)\\([^--- \t\n,][^ \t\n,]*\\)" options
)
5838 (substring options
(match-beginning 1) (match-end 1)))
5842 (match-beginning 2) (match-end 2))))
5843 (setq options
(substring options
(match-end 2)))
5844 ;; Rewrite "all" to ".+" not ".*". ".+" requires at least one
5846 (while (string-match "\\(^\\|\\\\[.]\\)all\\(\\\\[.]\\|$\\)" newsgroup
)
5848 (concat (substring newsgroup
0 (match-end 1))
5850 (substring newsgroup
(match-beginning 2)))))
5851 (cond ((string-equal yes-or-no
"!")
5852 (setq no
(cons newsgroup no
)))
5853 ((string-equal newsgroup
".+")) ;Ignore `all'.
5855 (setq yes
(cons newsgroup yes
)))
5857 ;; Make a cons of regexps from parsing result.
5860 (apply (function concat
)
5864 (concat newsgroup
"\\|")))
5869 (apply (function concat
)
5873 (concat newsgroup
"\\|")))
5878 (defun gnus-save-newsrc-file ()
5879 "Save to .newsrc FILE."
5880 ;; Note: We cannot save .newsrc file if all newsgroups are removed
5881 ;; from the variable gnus-newsrc-assoc.
5882 (and (or gnus-newsrc-assoc gnus-killed-assoc
)
5883 gnus-current-startup-file
5885 ;; A buffer containing .newsrc file may be deleted.
5886 (set-buffer (find-file-noselect gnus-current-startup-file
))
5887 (if (not (buffer-modified-p))
5888 (message "(No changes need to be saved)")
5889 (message "Saving %s..." gnus-current-startup-file
)
5890 (let ((make-backup-files t
)
5891 (version-control nil
)
5892 (require-final-newline t
)) ;Don't ask even if requested.
5893 ;; Make backup file of master newsrc.
5894 ;; You can stop or change version control of backup file.
5895 ;; Suggested by jason@violet.berkeley.edu.
5896 (run-hooks 'gnus-Save-newsrc-hook
)
5898 ;; Quickly loadable .newsrc.
5899 (set-buffer (get-buffer-create " *GNUS-newsrc*"))
5900 (buffer-flush-undo (current-buffer))
5902 (gnus-gnus-to-quick-newsrc-format)
5903 (let ((make-backup-files nil
)
5904 (version-control nil
)
5905 (require-final-newline t
)) ;Don't ask even if requested.
5906 (write-file (concat gnus-current-startup-file
".el")))
5907 (kill-buffer (current-buffer))
5908 (message "Saving %s... Done" gnus-current-startup-file
)
5912 (defun gnus-update-newsrc-buffer (group &optional delete next
)
5913 "Incrementally update .newsrc buffer about GROUP.
5914 If optional second argument DELETE is non-nil, delete the group.
5915 If optional third argument NEXT is non-nil, inserted before it."
5917 ;; Taking account of the killed startup file.
5918 ;; Suggested by tale@pawl.rpi.edu.
5919 (set-buffer (or (get-file-buffer gnus-current-startup-file
)
5920 (find-file-noselect gnus-current-startup-file
)))
5921 ;; Options line continuation lines must be also considered here.
5922 ;; Before supporting continuation lines, " newsgroup ! 1-5" was
5923 ;; okay, but now it is invalid. It should be "newsgroup! 1-5".
5925 (buffer-read-only nil
)) ;May be not modifiable.
5926 ;; Delete ALL entries which match for GROUP.
5927 (goto-char (point-min))
5928 (while (re-search-forward
5929 (concat "^" (regexp-quote group
) "[:!]") nil t
)
5931 (delete-region (point) (progn (forward-line 1) (point)))
5932 (setq deleted t
) ;Old entry is deleted.
5936 ;; Insert group entry.
5937 (let ((newsrc (assoc group gnus-newsrc-assoc
)))
5940 ;; Find insertion point.
5941 (cond (deleted nil
) ;Insert here.
5942 ((and (stringp next
)
5944 (goto-char (point-min))
5946 (concat "^" (regexp-quote next
) "[:!]") nil t
)))
5947 (beginning-of-line))
5949 (goto-char (point-max))
5952 ;; Insert after options line.
5953 (if (looking-at "^[ \t]*options\\([ \t]\\|$\\)")
5956 ;; Skip continuation lines.
5957 (while (and (not (eobp))
5958 (looking-at "^[ \t]+"))
5960 (insert group
;Group name
5961 (if (nth 1 newsrc
) ": " "! ")) ;Subscribed?
5962 (gnus-ranges-to-newsrc-format (nthcdr 2 newsrc
)) ;Read articles
5967 (defun gnus-gnus-to-quick-newsrc-format ()
5968 "Insert GNUS variables such as `gnus-newsrc-assoc' in Lisp format."
5969 (insert ";; GNUS internal format of .newsrc.\n")
5970 (insert ";; Touch .newsrc instead if you think to remove this file.\n")
5971 (let ((variable nil
)
5972 (variables gnus-variable-list
)
5973 ;; Temporary rebind to make changes invisible.
5974 (gnus-killed-assoc gnus-killed-assoc
))
5975 ;; Remove duplicated or unsubscribed newsgroups in gnus-killed-assoc.
5976 (gnus-check-killed-newsgroups)
5977 ;; Then, insert lisp expressions.
5979 (setq variable
(car variables
))
5980 (and (boundp variable
)
5981 (symbol-value variable
)
5982 (insert "(setq " (symbol-name variable
) " '"
5983 (prin1-to-string (symbol-value variable
))
5985 (setq variables
(cdr variables
)))
5988 (defun gnus-ranges-to-newsrc-format (ranges)
5989 "Insert ranges of read articles."
5990 (let ((range nil
)) ;Range is a pair of BEGIN and END.
5992 (setq range
(car ranges
))
5993 (setq ranges
(cdr ranges
))
5994 (cond ((= (car range
) (cdr range
))
5995 (if (= (car range
) 0)
5996 (setq ranges nil
) ;No unread articles.
5997 (insert (int-to-string (car range
)))
5998 (if ranges
(insert ","))
6001 (insert (int-to-string (car range
))
6003 (int-to-string (cdr range
)))
6004 (if ranges
(insert ","))
6008 (defun gnus-compress-sequence (numbers)
6009 "Convert list of sorted numbers to ranges."
6010 (let* ((numbers (sort (copy-sequence numbers
) (function <)))
6011 (first (car numbers
))
6012 (last (car numbers
))
6015 (cond ((= last
(car numbers
)) nil
) ;Omit duplicated number
6016 ((= (1+ last
) (car numbers
)) ;Still in sequence
6017 (setq last
(car numbers
)))
6018 (t ;End of one sequence
6019 (setq result
(cons (cons first last
) result
))
6020 (setq first
(car numbers
))
6021 (setq last
(car numbers
)))
6023 (setq numbers
(cdr numbers
))
6025 (nreverse (cons (cons first last
) result
))
6028 (defun gnus-uncompress-sequence (ranges)
6029 "Expand compressed format of sequence."
6034 (setq first
(car (car ranges
)))
6035 (setq last
(cdr (car ranges
)))
6036 (while (< first last
)
6037 (setq result
(cons first result
))
6038 (setq first
(1+ first
)))
6039 (setq result
(cons first result
))
6040 (setq ranges
(cdr ranges
))
6045 (defun gnus-number-of-articles (range)
6046 "Compute number of articles from RANGE `((beg1 . end1) (beg2 . end2) ...)'."
6049 (if (/= (cdr (car range
)) 0)
6050 ;; If end1 is 0, it must be skipped. Usually no articles in
6052 (setq count
(+ count
1 (- (cdr (car range
)) (car (car range
))))))
6053 (setq range
(cdr range
))
6058 (defun gnus-difference-of-range (src obj
)
6059 "Compute (SRC - OBJ) on range.
6060 Range of SRC is expressed as `(beg . end)'.
6061 Range of OBJ is expressed as `((beg1 . end1) (beg2 . end2) ...)."
6062 (let ((beg (car src
))
6064 (range nil
)) ;This is result.
6066 (while (and src obj
)
6067 (let ((beg1 (car (car obj
)))
6068 (end1 (cdr (car obj
))))
6070 (setq obj nil
)) ;Terminate loop
6072 (setq range
(cons (cons beg
(min (1- beg1
) end
)) range
))
6073 (setq beg
(1+ end1
)))
6075 (setq beg
(max beg
(1+ end1
))))
6077 (setq obj
(cdr obj
)) ;Next OBJ
6080 (if (and src
(<= beg end
))
6081 (setq range
(cons (cons beg end
) range
)))
6090 ;;eval: (put 'gnus-eval-in-buffer-window 'lisp-indent-function 1)
6095 ;;; gnus.el ends here