1 ;;; (ding) Gnus --- a newsreader for GNU Emacs
2 ;; Copyright (C) 1987,88,89,90,93,94,95 Free Software Foundation, Inc.
4 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
5 ;; Lars Ingebrigtsen <larsi@ifi.uio.no>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
26 ;; Although (ding) Gnus looks suspiciously like GNUS, it isn't quite
27 ;; the same beast. Most internal structures have been changed. If you
28 ;; have written packages that depend on any of the hash tables,
29 ;; `gnus-newsrc-assoc', `gnus-killed-assoc', marked lists, the .newsrc
30 ;; buffer, or internal knowledge of the `nntp-header-' macros, or
31 ;; dependence on the buffers having a certain format, your code will
43 ;; Customization variables
45 (defvar gnus-select-method
46 (list 'nntp (or (getenv "NNTPSERVER")
47 (if (and gnus-default-nntp-server
48 (not (string= gnus-default-nntp-server "")))
49 gnus-default-nntp-server)
52 "Default method for selecting a newsgroup.
53 This variable should be a list, where the first element is how the
54 news is to be fetched, the second is the address, and the optional
55 third element is the \"port number\", if nntp is used.
57 For instance, if you want to get your news via NNTP from
58 \"flab.flab.edu\" on port 23, you could say:
60 (setq gnus-select-method '(nntp \"flab.flab.edu\" 23))
62 If you want to use your local spool, say:
64 (setq gnus-select-method (list 'nnspool (system-name)))
66 If you use this variable, you must set `gnus-nntp-server' to nil.")
68 ;; Added by Sudish Joseph <joseph@cis.ohio-state.edu>.
69 (defvar gnus-post-method nil
70 "Preferred method for posting USENET news.
71 If this variable is nil, GNUS will use the current method to decide
72 which method to use when posting. If it is non-nil, it will override
73 the current method. This method will not be used in mail groups and
74 the like, only in \"real\" newsgroups.
76 The value must be a valid method as discussed in the documentation of
77 `gnus-select-method'.")
79 (defvar gnus-secondary-select-methods nil
80 "A list of secondary methods that will be used for reading news.")
82 (defvar gnus-default-nntp-server nil
83 "Specify a default NNTP server.
84 This variable should be defined in paths.el, and should never be set
86 If you want to change servers, you should use `gnus-select-method'.
87 See the documentation to that variable.")
89 (defvar gnus-secondary-servers nil
90 "List of NNTP servers that the user can choose between interactively.
91 To make Gnus query you for a server, you have to give `gnus' a
92 non-numeric prefix - `C-u M-x gnus', in short.")
94 (defvar gnus-nntp-server nil
95 "*The name of the host running the NNTP server.
96 This variable is semi-obsolete. Use the `gnus-select-method'
99 (defvar gnus-nntp-service "nntp"
100 "NNTP service name (\"nntp\" or 119).
101 This is an obsolete variable, which is scarcely used. If you use an
102 nntp server for your newsgroup and want to change the port number
103 used to 899, you would say something along these lines:
105 (setq gnus-select-method '(nntp \"my.nntp.server\" 899))")
107 (defvar gnus-startup-file "~/.newsrc"
108 "Your `.newsrc' file. Use `.newsrc-SERVER' instead if it exists.")
110 (defvar gnus-signature-file "~/.signature"
111 "Your signature file.
112 If the variable is a string that doesn't correspond to a file, the
113 string itself is inserted.")
115 (defvar gnus-signature-function nil
116 "A function that should return a signature file name.
117 The function will be called with the name of the newsgroup being
119 If the function returns a string that doesn't correspond to a file, the
120 string itself is inserted.
121 If the function returns nil, the `gnus-signature-file' variable will
124 (defvar gnus-init-file "~/.gnus"
125 "Your Gnus elisp startup file.
126 If a file with the .el or .elc suffixes exist, they will be read
129 (defvar gnus-default-subscribed-newsgroups nil
130 "This variable lists what newsgroups should be susbcribed the first time Gnus is used.
131 It should be a list of strings.
132 If it is `t', Gnus will not do anything special the first time it is
133 started; it'll just use the normal newsgroups subscription methods.")
135 (defconst gnus-backup-default-subscribed-newsgroups
136 '("news.announce.newusers" "news.groups.questions" "gnu.emacs.gnus")
137 "Default default new newsgroups the first time Gnus is run.")
139 (defvar gnus-post-prepare-function nil
140 "Function that is run after a post buffer has been prepared.
141 It is called with the name of the newsgroup that is posted to. It
142 might be use, for instance, for inserting signatures based on the
143 newsgroup name. (In that case, `gnus-signature-file' and
144 `mail-signature' should both be set to nil).")
146 (defvar gnus-use-cross-reference t
147 "Non-nil means that cross referenced articles will be marked as read.
148 If nil, ignore cross references. If t, mark articles as read in
149 subscribed newsgroups. If neither t nor nil, mark as read in all
152 (defvar gnus-use-dribble-file t
153 "Non-nil means that Gnus will use a dribble file to store user updates.
154 If Emacs should crash without saving the .newsrc files, complete
155 information can be restored from the dribble file.")
157 (defvar gnus-use-followup-to 'use
158 "Specifies what to do with Followup-To header.
159 If nil, ignore the header. If it is t, use its value, but ignore
160 `poster'. If it is neither nil nor t, always use the value.")
162 (defvar gnus-followup-to-function nil
163 "A variable that contains a function that returns a followup address.
164 The function will be called in the buffer of the article that is being
165 followed up. The buffer will be narrowed to the headers of the
166 article. To pick header headers, one might use `mail-fetch-field'. The
167 function will be called with the name of the current newsgroup as the
170 Here's an example `gnus-followup-to-function':
172 (setq gnus-followup-to-function
174 (cond ((string= group \"mail.list\")
175 (or (mail-fetch-field \"sender\")
176 (mail-fetch-field \"from\")))
178 (or (mail-fetch-field \"reply-to\")
179 (mail-fetch-field \"from\"))))))")
181 (defvar gnus-reply-to-function nil
182 "A variable that contains a function that returns a reply address.
183 See the `gnus-followup-to-function' variable for an explanation of how
184 this variable is used.")
186 (defvar gnus-large-newsgroup 200
187 "The number of articles which indicates a large newsgroup.
188 If the number of articles in a newsgroup is greater than the value,
189 confirmation is required for selecting the newsgroup.")
191 (defvar gnus-author-copy (getenv "AUTHORCOPY")
192 "Name of the file the article will be saved before it is posted using the FCC header.
193 Initialized from the AUTHORCOPY environment variable.
195 Articles are saved using a function specified by the the variable
196 `gnus-author-copy-saver' (`rmail-output' is default) if a file name is
197 given. Instead, if the first character of the name is `|', the
198 contents of the article is piped out to the named program. It is
199 possible to save an article in an MH folder as follows:
201 \(setq gnus-author-copy \"|/usr/local/lib/mh/rcvstore +Article\")")
203 (defvar gnus-mail-self-blind nil
204 "Non-nil means insert BCC to self in messages to be sent.
205 This is done when the message is initialized,
206 so you can remove or alter the BCC header to override the default.")
208 (defvar gnus-author-copy-saver (function rmail-output)
209 "A function called with a file name to save an author copy to.
210 The default function is `rmail-output' which saves in Unix mailbox format.")
212 (defvar gnus-use-long-file-name (not (memq system-type '(usg-unix-v xenix)))
213 "Non-nil means that the default name of a file to save articles in is the newsgroup name.
214 If it's nil, the directory form of the newsgroup name is used instead.")
216 (defvar gnus-article-save-directory (or (getenv "SAVEDIR") "~/News/")
217 "Name of the directory articles will be saved in (default \"~/News\").
218 Initialized from the SAVEDIR environment variable.")
220 (defvar gnus-kill-files-directory (or (getenv "SAVEDIR") "~/News/")
221 "Name of the directory where kill files will be stored (default \"~/News\").
222 Initialized from the SAVEDIR environment variable.")
224 (defvar gnus-kill-expiry-days 7
225 "*Number of days before unused kill file entries are expired.")
227 (defvar gnus-default-article-saver (function gnus-summary-save-in-rmail)
228 "A function to save articles in your favorite format.
229 The function must be interactively callable (in other words, it must
230 be an Emacs command).
232 Gnus provides the following functions:
234 * gnus-summary-save-in-rmail (Rmail format)
235 * gnus-summary-save-in-mail (Unix mail format)
236 * gnus-summary-save-in-folder (MH folder)
237 * gnus-summary-save-in-file (article format).")
239 (defvar gnus-rmail-save-name (function gnus-plain-save-name)
240 "A function generating a file name to save articles in Rmail format.
241 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
243 (defvar gnus-mail-save-name (function gnus-plain-save-name)
244 "A function generating a file name to save articles in Unix mail format.
245 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
247 (defvar gnus-folder-save-name (function gnus-folder-save-name)
248 "A function generating a file name to save articles in MH folder.
249 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER.")
251 (defvar gnus-file-save-name (function gnus-numeric-save-name)
252 "A function generating a file name to save articles in article format.
253 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
255 (defvar gnus-kill-file-name "KILL"
256 "Suffix of the kill files.")
258 (defvar gnus-fetch-old-headers nil
259 "Non-nil means that Gnus will try to build threads by grabbing old headers.
260 If an unread article in the group refers to an older, already read (or
261 just marked as read) article, the old article will not normally be
262 displayed in the Summary buffer. If this variable is non-nil, Gnus
263 will attempt to grab the headers to the old articles, and thereby
264 build complete threads. `gnus-nov-is-evil' has to be nil if this is
265 to work. If it has the value `some', only enough headers to connect
266 otherwise loose threads will be displayed.")
268 (defvar gnus-visual t
269 "*If non-nil, will do various highlighting.
270 If nil, no mouse highlight (or any other) will be performed. This
271 might speed up Gnus some when generating large group and summary
274 (defvar gnus-novice-user t
275 "*Non-nil means that you are a usenet novice.
276 If non-nil, verbose messages may be displayed and confirmations may be
279 (defvar gnus-expert-user nil
280 "*Non-nil means that you will never be asked for confirmation about anything.
281 And that means *anything*.")
283 (defvar gnus-keep-same-level nil
284 "Non-nil means that the next newsgroup after the current will be on the same level.
285 When you type, for instance, `n' after reading the last article in the
286 current newsgroup, you will go to the next newsgroup. If this variable
287 is nil, the next newsgroup will be the next from the group
289 If this variable is non-nil, Gnus will either put you in the
290 next newsgroup with the same level, or, if no such newsgroup is
291 available, the next newsgroup with the lowest possible level higher
292 than the current level.
293 If this variable is `best', Gnus will make the next newsgroup the one
294 with the best level.")
296 (defvar gnus-summary-make-false-root 'adopt
297 "nil means that Gnus won't gather loose threads.
298 If the root of a thread has expired or been read in a previous
299 session, the information necessary to build a complete thread has been
300 lost. Instead of having many small sub-threads from this original thread
301 scattered all over the summary buffer, Gnus can gather them.
303 If non-nil, Gnus will try to gather all loose sub-threads from an
304 original thread into one large thread.
306 If this variable is non-nil, it should be one of `none', `adopt',
309 If this variable is `none', Gnus will not make a false root, but just
310 present the sub-threads after another.
311 If this variable is `dummy', Gnus will create a dummy root that will
312 have all the sub-threads as children.
313 If this variable is `adopt', Gnus will make one of the \"children\"
314 the parent and mark all the step-children as such.
315 If this variable is `empty', the \"children\" are printed with empty
318 (defvar gnus-summary-gather-subject-limit nil
319 "*Maximum length of subject to compare when gathering loose threads.
320 Use nil to compare the whole subject.")
322 (defvar gnus-check-new-newsgroups t
323 "Non-nil means that Gnus will add new newsgroups at startup.
324 If this variable is `ask-server', Gnus will ask the server for new
325 groups since the last time it checked. This means that the killed list
326 is no longer necessary, so you could set `gnus-save-killed-list' to
328 A variant is to have this variable be a list of select methods. Then
329 Gnus will use the `ask-server' method on all these select methods to
330 query for new groups from all those servers.
333 (setq gnus-check-new-newsgroups
334 '((nntp \"some.server\") (nntp \"other.server\")))
336 If this variable is nil, then you have to tell Gnus explicitly to
337 check for new newsgroups with \\<gnus-group-mode-map>\\[gnus-find-new-newsgroups].")
339 (defvar gnus-check-bogus-newsgroups nil
340 "Non-nil means that Gnus will check and remove bogus newsgroup at startup.
341 If this variable is nil, then you have to tell Gnus explicitly to
342 check for bogus newsgroups with \\<gnus-group-mode-map>\\[gnus-group-check-bogus-groups].")
344 (defvar gnus-read-active-file t
345 "Non-nil means that Gnus will read the entire active file at startup.
346 If this variable is nil, Gnus will only read parts of the active file.")
348 (defvar gnus-activate-foreign-newsgroups nil
349 "If nil, Gnus will not check foreign newsgroups at startup.
350 If it is non-nil, it should be a number between one and nine. Foreign
351 newsgroups that have a level lower or equal to this number will be
352 activated on startup. For instance, if you want to active all
353 subscribed newsgroups, but not the rest, you'd set this variable to 5.
355 If you subscribe to lots of newsgroups from different servers, startup
356 might take a while. By setting this variable to nil, you'll save time,
357 but you won't be told how many unread articles there are in the
360 (defvar gnus-save-newsrc-file t
361 "Non-nil means that Gnus will save a .newsrc file.
362 Gnus always saves its own startup file, which is called \".newsrc.el\".
363 The file called \".newsrc\" is in a format that can be readily
364 understood by other newsreaders. If you don't plan on using other
365 newsreaders, set this variable to nil to save some time on exit.")
367 (defvar gnus-save-killed-list t
368 "If non-nil, save the list of killed groups to the startup file.
369 This will save both time (when starting and quitting) and space (on
370 disk), but it will also mean that Gnus has no record of what
371 newsgroups are new or old, so the automatic new newsgroups
372 subscription methods become meaningless. You should always set
373 `gnus-check-new-newsgroups' to nil if you set this variable to nil.")
375 (defvar gnus-interactive-catchup t
376 "Require your confirmation when catching up a newsgroup if non-nil.")
378 (defvar gnus-interactive-post t
379 "Group and subject will be asked for if non-nil.")
381 (defvar gnus-interactive-exit t
382 "Require your confirmation when exiting Gnus if non-nil.")
384 (defvar gnus-kill-killed nil
385 "If non-nil, Gnus will apply kill files to already killd articles.
386 If it is nil, Gnus will never apply kill files to articles that have
387 already been through the scoring process, which might very well save lots
390 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
391 (defvar gnus-summary-same-subject ""
392 "String indicating that the current article has the same subject as the previous.")
394 (defvar gnus-score-interactive-default-score 1000
395 "Scoring commands will raise/lower with this number as the default.")
397 (defvar gnus-summary-default-score 0
398 "Default article score level.
399 If this variable is nil, score levels will not be used.")
401 (defvar gnus-user-login-name nil
402 "The login name of the user.
403 Got from the function `user-login-name' if undefined.")
405 (defvar gnus-user-full-name nil
406 "The full name of the user.
407 Got from the NAME environment variable if undefined.")
409 (defvar gnus-show-mime nil
410 "*Show MIME message if non-nil.")
412 (defvar gnus-show-threads t
413 "*Show conversation threads in summary mode if non-nil.")
415 (defvar gnus-thread-hide-subtree nil
416 "Non-nil means hide thread subtrees initially.
417 If non-nil, you have to run the command `gnus-summary-show-thread' by
418 hand or by using `gnus-select-article-hook' to show hidden threads.")
420 (defvar gnus-thread-hide-killed t
421 "Non-nil means hide killed thread subtrees automatically.")
423 (defvar gnus-thread-ignore-subject nil
424 "Don't take care of subject differences, but only references if non-nil.
425 If it is non-nil, some commands work with subjects do not work properly.")
427 (defvar gnus-thread-indent-level 4
428 "Indentation of thread subtrees.")
430 ;; jwz: nuke newsgroups whose name is all digits - that means that
431 ;; some loser has let articles get into the root of the news spool,
432 ;; which is toxic. Lines beginning with whitespace also tend to be
434 (defvar gnus-ignored-newsgroups
435 (purecopy (mapconcat 'identity
436 '("^to\\." ; not "real" groups
437 "^[0-9. \t]+ " ; all digits in name
438 "[][\"#'() ;\\]" ; bogus characters
441 "A regexp to match uninteresting newsgroups in the active file.
442 Any lines in the active file matching this regular expression are
443 removed from the newsgroup list before anything else is done to it,
444 thus making them effectively non-existant.")
446 (defvar gnus-ignored-headers
447 "^Path:\\|^Posting-Version:\\|^Article-I.D.:\\|^Expires:\\|^Date-Received:\\|^References:\\|^Control:\\|^Xref:\\|^Lines:\\|^Posted:\\|^Relay-Version:\\|^Message-ID:\\|^Nf-ID:\\|^Nf-From:\\|^Approved:\\|^Sender:\\|^Received:\\|^Mail-from:"
448 "All headers that match this regexp will be hidden.
449 Also see `gnus-visible-headers'.")
451 (defvar gnus-visible-headers "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^Cc:"
452 "All headers that do not match this regexp will be hidden.
453 Also see `gnus-ignored-headers'.")
455 (defvar gnus-sorted-header-list
456 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^To:"
457 "^Cc:" "^Date:" "^Organization:")
458 "This variable is a list of regular expressions.
459 If it is non-nil, headers that match the regular expressions will
460 be placed first in the article buffer in the sequence specified by
463 (defvar gnus-required-headers
464 '(From Date Newsgroups Subject Message-ID Organization Lines X-Newsreader)
465 ;; changed by jwz because it's not so nice to do "Lines: 0" by default.
466 ;; and to remove Path, since it's incorrect for Gnus to try
467 ;; and generate that - it is the responsibility of inews or nntpd.
468 "All required headers for articles you post.
469 RFC977 and RFC1036 require From, Date, Newsgroups, Subject, Message-ID
470 and Path headers. Organization, Lines and X-Newsreader are optional.
471 If you want Gnus not to insert some header, remove it from this
474 (defvar gnus-show-all-headers nil
475 "*Show all headers of an article if non-nil.")
477 (defvar gnus-save-all-headers t
478 "*Save all headers of an article if non-nil.")
480 (defvar gnus-inhibit-startup-message nil
481 "The startup message will not be displayed if this function is non-nil.")
483 (defvar gnus-auto-extend-newsgroup t
484 "Extend visible articles to forward and backward if non-nil.")
486 (defvar gnus-auto-select-first t
487 "Select the first unread article automagically if non-nil.
488 If you want to prevent automatic selection of the first unread article
489 in some newsgroups, set the variable to nil in `gnus-select-group-hook'
490 or `gnus-apply-kill-hook'.")
492 (defvar gnus-auto-select-next t
493 "Select the next newsgroup automagically if non-nil.
494 If the value is t and the next newsgroup is empty, Gnus will exit
495 summary mode and go back to group mode. If the value is neither nil
496 nor t, Gnus will select the following unread newsgroup. Especially, if
497 the value is the symbol `quietly', the next unread newsgroup will be
498 selected without any confirmations.")
500 (defvar gnus-auto-select-same nil
501 "Select the next article with the same subject automagically if non-nil.")
503 (defvar gnus-auto-center-summary t
504 "*Always center the current summary in Gnus summary window if non-nil.")
506 (defvar gnus-auto-mail-to-author nil
507 "Insert `To: author' of the article when following up if non-nil.
508 If this variable is `ask', the user will be prompted.
509 Mail is sent using the function specified by the variable
510 `gnus-mail-send-method'.")
512 (defvar gnus-break-pages t
513 "*Break an article into pages if non-nil.
514 Page delimiter is specified by the variable `gnus-page-delimiter'.")
516 (defvar gnus-page-delimiter "^\^L"
517 "Regexp describing line-beginnings that separate pages of news article.")
519 (defvar gnus-use-full-window t
520 "*Non-nil means to take up the entire screen of Emacs.")
522 (defvar gnus-window-configuration
526 "Specify window configurations for each action.
527 The format of the variable is either a list of (ACTION (G S A)), where
528 G, S, and A are the relative height of group, summary, and article
529 windows, respectively, or a list of (ACTION FUNCTION), where FUNCTION
530 is a function that will be called with ACTION as an argument. ACTION
531 can be `summary', `newsgroups', or `article'.")
533 (defvar gnus-show-mime-method (function metamail-buffer)
534 "Function to process a MIME message.
535 The function is expected to process current buffer as a MIME message.")
537 (defvar gnus-mail-reply-method
538 (function gnus-mail-reply-using-mail)
539 "Function to compose reply mail.
540 The function `gnus-mail-reply-using-mail' uses usual sendmail mail
541 program. The function `gnus-mail-reply-using-mhe' uses the MH-E mail
542 program. You can use yet another program by customizing this variable.")
544 (defvar gnus-mail-forward-method
545 (function gnus-mail-forward-using-mail)
546 "Function to forward current message to another user.
547 The function `gnus-mail-reply-using-mail' uses usual sendmail mail
548 program. You can use yet another program by customizing this variable.")
550 (defvar gnus-mail-other-window-method
551 (function gnus-mail-other-window-using-mail)
552 "Function to compose mail in other window.
553 The function `gnus-mail-other-window-using-mail' uses the usual sendmail
554 mail program. The function `gnus-mail-other-window-using-mhe' uses the MH-E
555 mail program. You can use yet another program by customizing this variable.")
557 (defvar gnus-mail-send-method send-mail-function
558 "Function to mail a message too which is being posted as an article.
559 The message must have To or Cc header. The default is copied from
560 the variable `send-mail-function'.")
562 (defvar gnus-subscribe-newsgroup-method
563 (function gnus-subscribe-zombies)
564 "Function called with a newsgroup name when new newsgroup is found.
565 The function `gnus-subscribe-randomly' inserts a new newsgroup a the
566 beginning of newsgroups. The function `gnus-subscribe-alphabetically'
567 inserts it in strict alphabetic order. The function
568 `gnus-subscribe-hierarchically' inserts it in hierarchical newsgroup
569 order. The function `gnus-subscribe-interactively' asks for your decision.")
571 ;; Suggested by a bug report by Hallvard B Furuseth
572 ;; <h.b.furuseth@usit.uio.no>.
573 (defvar gnus-subscribe-options-newsgroup-method
574 (function gnus-subscribe-alphabetically)
575 "This function is called to subscribe newsgroups mentioned on \"options -n\" lines.
576 If, for instance, you want to subscribe to all newsgroups in the
577 \"no\" and \"alt\" hierarchies, you'd put the following in your
580 options -n no.all alt.all
582 Gnus will the subscribe all new newsgroups in these hierarchies with
583 the subscription method in this variable.")
585 ;; Mark variables suggested by Thomas Michanek
586 ;; <Thomas.Michanek@telelogic.se>.
587 (defvar gnus-unread-mark ?
588 "Mark used for unread articles.")
589 (defvar gnus-ticked-mark ?!
590 "Mark used for ticked articles.")
591 (defvar gnus-dormant-mark ??
592 "Mark used for dormant articles.")
593 (defvar gnus-dread-mark ?D
594 "Mark used for read articles.")
595 (defvar gnus-read-mark ?d
596 "Mark used for read articles.")
597 (defvar gnus-expirable-mark ?E
598 "Mark used for expirable articles.")
599 (defvar gnus-killed-mark ?K
600 "Mark used for killed articles.")
601 (defvar gnus-kill-file-mark ?X
602 "Mark used for articles killed by kill files.")
603 (defvar gnus-low-score-mark ?Y
604 "Mark used for articles with a low score.")
605 (defvar gnus-catchup-mark ?C
606 "Mark used for articles that are caught up.")
607 (defvar gnus-replied-mark ?R
608 "Mark used for articles that have been replied to.")
609 (defvar gnus-process-mark ?#
610 "Mark used for marking articles as processable.")
611 (defvar gnus-ancient-mark ?A
612 "Mark used for ancient articles.")
613 (defvar gnus-canceled-mark ?G
614 "Mark used for cancelled articles.")
615 (defvar gnus-score-over-mark ?+
616 "Score mark used for articles with high scores.")
617 (defvar gnus-score-below-mark ?-
618 "Score mark used for articles with low scores.")
620 (defvar gnus-view-pseudo-asynchronously nil
621 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
623 (defvar gnus-view-pseudos nil
624 "If `automatic', pseudo-articles will be viewed automatically.
625 If `not-confirm', pseudos will be viewed automatically, and the user
626 will not be asked to confirm the command.")
628 (defvar gnus-group-mode-hook nil
629 "A hook for Gnus group mode.")
631 (defvar gnus-summary-mode-hook nil
632 "A hook for Gnus summary mode.")
634 (defvar gnus-article-mode-hook nil
635 "A hook for Gnus article mode.")
637 (defvar gnus-kill-file-mode-hook nil
638 "A hook for Gnus KILL File mode.")
640 (defvar gnus-open-server-hook nil
641 "A hook called just before opening connection to news server.")
643 (defvar gnus-startup-hook nil
644 "A hook called at startup time.
645 This hook is called after Gnus is connected to the NNTP server. So, it
646 is possible to change the behavior of Gnus according to the selected
649 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat
650 "A function that is called to set up the group buffer.
651 The function is called with three arguments: The first is a number;
652 all group with a level less or equal to that number should be listed,
653 if the second is non-nil, empty groups should also be displayed. If
654 the third is non-nil, it is a number. No groups with a level lower
655 than this number should be displayed.")
657 (defvar gnus-group-prepare-hook nil
658 "A hook called after the newsgroup list is created in the group buffer.
659 If you want to modify the group buffer, you can use this hook.")
661 (defvar gnus-summary-prepare-hook nil
662 "A hook called after summary list is created in the summary buffer.
663 If you want to modify the summary buffer, you can use this hook.")
665 (defvar gnus-article-prepare-hook nil
666 "A hook called after an article is prepared in the article buffer.
667 If you want to run a special decoding program like nkf, use this hook.")
669 (defvar gnus-article-display-hook nil
670 "A hook called after the article is displayed in the article buffer.
671 The hook is designed to change the contents of the article
672 buffer. Typical functions that this hook may contain are
673 `gnus-article-hide-headers' (hide selected headers),
674 `gnus-article-hide-signature' (hide signature) and
675 `gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).")
676 (add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted)
677 (add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike)
679 (defvar gnus-select-group-hook nil
680 "A hook called when a newsgroup is selected.
682 If you'd like to simplify subjects like the
683 `gnus-summary-next-same-subject' command does, you can use the
686 (setq gnus-select-group-hook
689 (mapcar (lambda (header)
692 (gnus-simplify-subject
693 (header-subject header) 're-only)))
694 gnus-newsgroup-headers))))
697 (defvar gnus-select-article-hook
698 '(gnus-summary-show-thread)
699 "A hook called when an article is selected.
700 The default hook shows conversation thread subtrees of the selected
701 article automatically using `gnus-summary-show-thread'.")
703 (defvar gnus-apply-kill-hook '(gnus-apply-kill-file)
704 "A hook called when a newsgroup is selected and summary list is prepared.
705 This hook is intended to apply a kill file to the selected newsgroup.
706 The function `gnus-apply-kill-file' is called by default.
708 Since a general kill file is too heavy to use only for a few
709 newsgroups, I recommend you to use a lighter hook function. For
710 example, if you'd like to apply a kill file to articles which contains
711 a string `rmgroup' in subject in newsgroup `control', you can use the
714 \(setq gnus-apply-kill-hook
717 (cond ((string-match \"control\" gnus-newsgroup-name)
718 (gnus-kill \"Subject\" \"rmgroup\")
719 (gnus-expunge \"X\"))))))")
721 (defvar gnus-visual-mark-article-hook
722 (list 'gnus-visual-highlight-selected-summary)
723 "Hook run after selecting an article in the summary buffer.
724 It is meant to be used for highlighting the article in some way. It is
725 not run if `gnus-visual' is nil.")
727 (defvar gnus-prepare-article-hook (list (function gnus-inews-insert-signature))
728 "A hook called after preparing body, but before preparing header headers.
729 The default hook (`gnus-inews-insert-signature') inserts a signature
730 file specified by the variable `gnus-signature-file'.")
732 (defvar gnus-inews-article-hook (list (function gnus-inews-do-fcc))
733 "A hook called before finally posting an article.
734 The default hook (`gnus-inews-do-fcc') does FCC processing (save article
737 (defvar gnus-inews-article-header-hook nil
738 "A hook called after inserting the headers in an article to be posted.
739 The hook is called from the *post-news* buffer, narrowed to the
742 (defvar gnus-exit-group-hook nil
743 "A hook called when exiting (not quitting) summary mode.
744 If your machine is so slow that exiting from summary mode takes very
745 long time, set the variable `gnus-use-cross-reference' to nil. This
746 inhibits marking articles as read using cross-reference information.")
748 (defvar gnus-suspend-gnus-hook nil
749 "A hook called when suspending (not exiting) Gnus.")
751 (defvar gnus-exit-gnus-hook (list 'nntp-request-close)
752 "A hook called when exiting Gnus.")
754 (defvar gnus-save-newsrc-hook nil
755 "A hook called when saving the newsrc file.
756 This hook is called before saving the `.newsrc' file.")
758 (defvar gnus-auto-expirable-newsgroups nil
759 "All newsgroups that match this regexp will have all read articles automatically marked as expirable.")
761 (defvar gnus-subscribe-hierarchical-interactive nil
762 "If non-nil, Gnus will offer to subscribe hierarchically.
763 When a new hierarchy appears, Gnus will ask the user:
765 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
767 If the user pressed `d', Gnus will descend the hierarchy, `y' will
768 subscribe to all newsgroups in the hierarchy and `s' will skip this
769 hierarchy in its entirety.")
771 (defvar gnus-group-line-format "%M%S%5y: %(%g%)\n"
772 "Format of groups lines.
773 It works along the same lines as a normal formatting string,
774 with some simple extrensions.
776 %M Only marked articles (character, \"*\" or \" \")
777 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
778 %L Level of subscribedness (integer, 1-9)
779 %N Number of unread articles (integer)
780 %I Number of dormant articles (integer)
781 %i Number of ticked and dormant (integer)
782 %T Number of ticked articles (integer)
783 %R Number of read articles (integer)
784 %t Total number of articles (integer)
785 %y Number of unread, unticked articles (integer)
786 %G Group name (string)
787 %g Qualified group name (string)
788 %D Group description (string)
789 %s Select method (string)
790 %o Moderated group (char, \"m\")
791 %O Moderated group (string, \"(m)\" or \"\")
792 %n Select from where (string)
793 %z A string that look like `<%s:%n>' if a foreign select method is used
794 %u User defined specifier. The next character in the format string should
795 be a letter. GNUS will call the function gnus-user-format-function-X,
796 where X is the letter following %u. The function will be passed the
797 current header as argument. The function should return a string, which
798 will be inserted into the summary just like information from any other
801 Text between %( and %) will be highlighted with `gnus-mouse-face' when
802 the mouse point move inside the area. There can only be one such area.
804 Note that this format specification is not always respected. For
805 reasons of efficiency, when listing killed groups, this specification
806 is ignored altogether. If the spec is changed considerably, your
807 output may end up looking strange when listing both alive and killed
810 If you use %o or %O, reading the active file will be slower and quite
811 a bit of extra memory will be used. %D will also worsen performance.
812 Also note that if you change the format specification to include any
813 of these specs, you must probably re-start Gnus to see them go into
816 (defvar gnus-summary-line-format "%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n"
817 "The format specification of the lines in the summary buffer.
819 It works along the same lines as a normal formatting string,
820 with some simple extensions.
822 %N Article number, left padded with spaces (string)
824 %s Subject if it is at the root of a thread, and \"\" otherwise (string)
825 %n Name of the poster (string)
826 %A Address of the poster (string)
827 %L Number of lines in the article (integer)
828 %c Number of characters in the article (integer)
829 %D Date of the article (string)
830 %I Indentation based on thread level (a string of spaces)
831 %T A string with two possible values: 80 spaces if the article
832 is on thread level two or larger and 0 spaces on level one
833 %U Status of this article (character, \"D\", \"K\", \"-\" or \" \")
834 %[ Opening bracket (character, \"[\" or \"<\")
835 %] Closing bracket (character, \"]\" or \">\")
836 %> Spaces of length thread-level (string)
837 %< Spaces of length (- 20 thread-level) (string)
838 %i Article score (number)
839 %z Article zcore (character)
840 %u User defined specifier. The next character in the format string should
841 be a letter. GNUS will call the function gnus-user-format-function-X,
842 where X is the letter following %u. The function will be passed the
843 current header as argument. The function should return a string, which
844 will be inserted into the summary just like information from any other
847 Text between %( and %) will be highlighted with `gnus-mouse-face'
848 when the mouse point is placed inside the area. There can only be one
851 The %U (status), %R (replied) and %z (zcore) specs have to be handled
852 with care. For reasons of efficiency, Gnus will compute what column
853 these characters will end up in, and "hard-code" that. This means that
854 it is illegal to have these specs after a variable-length spec. Well,
855 you might not be arrested, but your summary buffer will look strange,
858 The smart choice is to have these specs as for to the left as
861 This restriction may disappear in later versions of Gnus.")
863 (defconst gnus-summary-dummy-line-format "* : : %S\n"
864 "The format specification for the dummy roots in the summary buffer.
865 It works along the same lines as a normal formatting string,
866 with some simple extensions.
870 (defvar gnus-summary-mode-line-format "(ding) %G/%A %Z"
871 "The format specification for the summary mode line.")
873 (defvar gnus-article-mode-line-format "(ding) %G/%A %S"
874 "The format specification for the article mode line.")
876 (defconst gnus-group-mode-line-format "(ding) List of groups {%M:%S}"
877 "The format specification for the group mode line.")
881 ;; Site dependent variables. You have to define these variables in
882 ;; site-init.el, default.el or your .emacs.
884 (defvar gnus-local-timezone nil
886 This value is used only if `current-time-zone' does not work in your Emacs.
887 It specifies the GMT offset, i.e. a decimal integer
888 of the form +-HHMM giving the hours and minutes ahead of (i.e. east of) GMT.
889 For example, +0900 should be used in Japan, since it is 9 hours ahead of GMT.
891 For backwards compatibility, it may also be a string like \"JST\",
892 but strings are obsolescent: you should use numeric offsets instead.")
894 (defvar gnus-local-domain nil
895 "Local domain name without a host name.
896 The DOMAINNAME environment variable is used instead if it is defined.
897 If the `system-name' function returns the full Internet name, there is
898 no need to set this variable.")
900 (defvar gnus-local-organization nil
901 "String with a description of what organization (if any) the user belongs to.
902 The ORGANIZATION environment variable is used instead if it is defined.
903 If this variable contains a function, this function will be called
904 with the current newsgroup name as the argument. The function should
906 In any case, if the string (either in the variable, in the environment
907 variable, or returned by the function) is a file name, the contents of
908 this file will be used as the organization.")
910 (defvar gnus-use-generic-from nil
911 "If nil, the full host name will be the system name prepended to the domain name.
912 If this is a string, the full host name will be this string.
913 If this is non-nil, non-string, the domain name will be used as the
916 (defvar gnus-use-generic-path nil
917 "If nil, use the NNTP server name in the Path header.
918 If stringp, use this; if non-nil, use no host name (user name only).")
920 (defvar gnus-valid-select-methods
921 '(("nntp" post address) ("nnspool" post) ("nnvirtual" none virtual)
922 ("nnmbox" mail respool) ("nnml" mail respool)
923 ("nnmh" mail respool) ("nndir" none) ("nndigest" none)
924 ("nndoc" none) ("nnbabyl" mail respool)
925 ("nnkiboze" none virtual))
926 "A list of valid select methods.
927 Each element in this list should be a list. The first element of these
928 lists should be a string with the name of the select method. The
929 other elements may be be the category of this method (ie. `post',
930 `mail', `none' or whatever) or other properties that this method has
931 (like being respoolable).
932 If you implement a new select method, all you should have to change is
933 this variable. I think.")
935 (defvar gnus-updated-mode-lines '(group article summary)
936 "This variable is a list of buffers that should keep their mode lines updated.
937 The list may contain the symbols `group', `article' and `summary'. If
938 the corresponding symbol is present, Gnus will keep that mode line
939 updated with information that may be pertinent.
940 If this variable is nil, screen refresh may be quicker.")
942 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
943 (defvar gnus-mouse-face 'highlight
944 "Face used for mouse highlighting in Gnus.
945 No mouse highlights will be done if `gnus-visual' is nil.")
947 (defvar gnus-visual-summary-update-hook
948 (list 'gnus-visual-summary-highlight-line)
949 "A hook called when a summary line is changed.
950 The hook will not be called if `gnus-visual' is nil.
952 Point will be at the beginning of the line, and the following free
953 variables can be used for convenience:
955 score: (gnus-summary-article-score)
956 default: gnus-summary-default-score
957 below: gnus-summary-mark-below
959 The default hook `gnus-visual-summary-highlight-line' will highlight the line
960 according to the `gnus-visual-summary-highlight' variable.")
962 (defvar gnus-summary-mark-below nil
963 "Score below which articles automatically become marked.
964 This variable is local to each summary buffer and usually set in the
967 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number)
968 "List of functions used for thread roots in the summary buffer.
970 Each function takes two threads and return non-nil if the first thread
971 should be sorted before the other. If you use more than one function,
972 list the function you want to act as the primary sort key last.
974 Functions you can use are:
975 - gnus-thread-sort-by-number
976 - gnus-thread-sort-by-author
977 - gnus-thread-sort-by-subject
978 - gnus-thread-sort-by-date
979 - gnus-thread-sort-by-score
980 - gnus-thread-sort-by-total-score (see `gnus-thread-score-function').
982 The two later only works on articles that have already been scored prior
983 to entering the newsgroup.")
985 (defvar gnus-thread-score-function '+
986 "Function used for calculating the total score of a thread.
988 The function is called with the scores of the article and each
989 subthread and should then return the score of the thread.
991 Some functions you can use are `+', `max', or `min'.")
993 (defvar gnus-score-find-score-files-function 'gnus-score-find-bnews
994 "Function used to find SCORE files.
995 The value should be a function that takes a group name as an argument,
996 and return a list of SCORE files that applies to that group.
998 Predefined values are:
1000 gnus-score-find-single: Only apply the groups own SCORE file.
1001 gnus-score-find-hierarchical: Also apply SCORE files from parent groups.
1002 gnus-score-find-bnews: Apply SCORE files whose names matches.
1004 See the definition of the individual functions for more information.")
1006 (defvar gnus-options-subscribe nil
1007 "All new groups matching this regexp will be subscribed.
1008 Note that this variable deals only with new newsgroups. This variable
1009 does not affect old newsgroups.")
1011 (defvar gnus-options-not-subscribe nil
1012 "All new groups matching this regexp will be ignored.
1013 Note that this variable deals only with new newsgroups. This variable
1014 does not affect old (already subscribed) newsgroups.")
1017 ;; Internal variables
1019 ;; Avoid highlighting in kill files.
1020 (defvar gnus-summary-inhibit-highlight nil)
1022 (defvar caesar-translate-table nil)
1024 (defvar gnus-dribble-buffer nil)
1025 (defvar gnus-headers-retrieved-by nil)
1027 (defvar gnus-article-reply nil)
1028 (defvar gnus-article-check-size nil)
1030 (defvar gnus-score-file-list nil)
1031 (defvar gnus-score-alist nil
1032 "Alist containing score information.
1033 The keys can be symbols or strings. The following symbols are defined.
1035 touched: If this alist has been modified.
1036 mark: Automatically mark articles below this.
1037 expunge: Automatically expunge articles below this.
1038 files: List of other SCORE files to load when loading this one.
1039 eval: Sexp to be evaluated when the score file is loaded.
1041 String entries have the form (HEADER (MATCH TYPE SCORE DATE) ...)
1042 where HEADER is the header being scored, MATCH is the string we are
1043 looking for, TYPE is a flag indicating whether it should use regexp or
1044 substring matching, SCORE is the score to add and DATE is the date
1045 of the last succesful match.")
1047 (defvar gnus-score-cache nil)
1048 ;; Alist containing the content of all loaded SCORE files.
1049 (defvar gnus-scores-lists nil)
1050 (defvar gnus-scores-articles nil)
1051 (defvar gnus-header-index nil)
1052 (defvar gnus-score-index nil)
1054 (defvar gnus-newsgroup-dependencies nil)
1056 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*")
1058 (defvar gnus-default-subscribe-level 2
1059 "Default subscription level.")
1061 (defvar gnus-default-unsubscribe-level 6
1062 "Default unsubscription level.")
1064 (defvar gnus-default-kill-level 9
1065 "Default kill level.")
1067 (defconst gnus-group-line-format-alist
1068 (list (list ?M 'marked ?c)
1069 (list ?S 'subscribed ?c)
1071 (list ?N 'number ?s)
1072 (list ?I 'number-of-dormant ?d)
1073 (list ?T 'number-of-ticked ?d)
1074 (list ?R 'number-of-read ?s)
1075 (list ?t 'number-total ?d)
1076 (list ?y 'number-of-unread-unticked ?s)
1077 (list ?i 'number-of-ticked-and-dormant ?d)
1079 (list ?G 'qualified-group ?s)
1080 (list ?D 'newsgroup-description ?s)
1081 (list ?o 'moderated ?c)
1082 (list ?O 'moderated-string ?s)
1083 (list ?s 'news-server ?s)
1084 (list ?n 'news-method ?s)
1085 (list ?z 'news-method-string ?s)
1086 (list ?u 'user-defined ?s)))
1088 (defconst gnus-summary-line-format-alist
1089 (list (list ?N 'number ?s)
1090 (list ?S 'subject ?s)
1091 (list ?s 'subject-or-nil ?s)
1093 (list ?A 'address ?s)
1095 (list ?x (macroexpand '(header-xref header)) ?s)
1096 (list ?D (macroexpand '(header-date header)) ?s)
1097 (list ?M (macroexpand '(header-id header)) ?s)
1098 (list ?r (macroexpand '(header-references header)) ?s)
1099 (list ?c (macroexpand '(header-chars header)) ?d)
1101 (list ?I 'indentation ?s)
1102 (list ?T '(if (< level 1) "" (make-string (frame-width) ? )) ?s)
1103 (list ?R 'replied ?c)
1104 (list ?\[ 'opening-bracket ?c)
1105 (list ?\] 'closing-bracket ?c)
1106 (list ?\> '(make-string level ? ) ?s)
1107 (list ?\< '(make-string (max 0 (- 20 level)) ? ) ?s)
1109 (list ?z 'score-char ?c)
1110 (list ?U 'unread ?c)
1111 (list ?u 'user-defined ?s))
1112 "An alist of format specifications that can appear in summary lines,
1113 and what variables they correspond with, along with the type of the
1114 variable (string, integer, character, etc).")
1116 (defconst gnus-summary-dummy-line-format-alist
1117 (list (list ?S 'subject ?s)
1118 (list ?N 'number ?d)))
1120 (defconst gnus-summary-mode-line-format-alist
1121 (list (list ?G 'group-name ?s)
1122 (list ?A 'article-number ?d)
1123 (list ?Z 'unread-and-unselected ?s)
1124 (list ?V 'gnus-version ?s)
1125 (list ?U 'unread ?d)
1126 (list ?S 'subject ?s)
1127 (list ?u 'unselected ?d)))
1129 (defconst gnus-group-mode-line-format-alist
1130 (list (list ?S 'news-server ?s)
1131 (list ?M 'news-method ?s)))
1133 (defvar gnus-have-read-active-file nil)
1135 (defconst gnus-maintainer "Lars Magne Ingebrigtsen <larsi@ifi.uio.no>"
1136 "The mail address of the Gnus maintainer.")
1138 (defconst gnus-version "(ding) Gnus v0.30"
1139 "Version number for this version of Gnus.")
1141 (defvar gnus-info-nodes
1142 '((gnus-group-mode "(gnus)Group Commands")
1143 (gnus-summary-mode "(gnus)Summary Commands")
1144 (gnus-article-mode "(gnus)Article Commands")
1145 (gnus-kill-file-mode "(gnus)Kill File"))
1146 "Assoc list of major modes and related Info nodes.")
1148 (defvar gnus-documentation-group-file "~/dgnus/lisp/doc.txt"
1149 "The location of the (ding) Gnus documentation group.")
1151 (defvar gnus-group-buffer "*Group*")
1152 (defvar gnus-summary-buffer "*Summary*")
1153 (defvar gnus-article-buffer "*Article*")
1155 (defvar gnus-buffer-list nil
1156 "Gnus buffers that should be killed when exiting.")
1158 (defvar gnus-variable-list
1159 '(gnus-newsrc-options
1160 gnus-newsrc-options-n-yes gnus-newsrc-options-n-no
1161 gnus-newsrc-last-checked-date
1162 gnus-newsrc-assoc gnus-killed-list gnus-zombie-list)
1163 "Gnus variables saved in the quick startup file.")
1165 (defvar gnus-overload-functions
1166 '((news-inews gnus-inews-news "rnewspost")
1167 (caesar-region gnus-caesar-region "rnews"))
1168 "Functions overloaded by gnus.
1169 It is a list of `(original overload &optional file)'.")
1171 (defvar gnus-newsrc-options nil
1172 "Options line in the .newsrc file.")
1174 (defvar gnus-newsrc-options-n-yes nil
1175 "Regexp representing groups to be subscribed to unconditionally.")
1177 (defvar gnus-newsrc-options-n-no nil
1178 "Regexp representing group to be ignored unconditionally.")
1180 (defvar gnus-newsrc-last-checked-date nil
1181 "Date Gnus last asked server for new newsgroups.")
1183 (defvar gnus-newsrc-assoc nil
1184 "Assoc list of read articles.
1185 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1187 (defvar gnus-newsrc-hashtb nil
1188 "Hashtable of gnus-newsrc-assoc.")
1190 (defvar gnus-killed-list nil
1191 "List of killed newsgroups.")
1193 (defvar gnus-killed-hashtb nil
1194 "Hash table equivalent of gnus-killed-list.")
1196 (defvar gnus-zombie-list nil
1197 "List of almost dead newsgroups.")
1199 (defvar gnus-description-hashtb nil
1200 "Descriptions of newsgroups.")
1202 (defvar gnus-list-of-killed-groups nil
1203 "List of newsgroups that have recently been killed by the user.")
1205 (defvar gnus-active-hashtb nil
1206 "Hashtable of active articles.")
1208 (defvar gnus-moderated-list nil
1209 "List of moderated newsgroups.")
1211 (defvar gnus-current-startup-file nil
1212 "Startup file for the current host.")
1214 (defvar gnus-last-search-regexp nil
1215 "Default regexp for article search command.")
1217 (defvar gnus-last-shell-command nil
1218 "Default shell command on article.")
1220 (defvar gnus-current-select-method nil
1221 "The current method for selecting a newsgroup.")
1223 (defvar gnus-have-all-newsgroups nil)
1225 (defvar gnus-article-internal-prepare-hook nil)
1227 (defvar gnus-newsgroup-name nil)
1228 (defvar gnus-newsgroup-begin nil)
1229 (defvar gnus-newsgroup-end nil)
1230 (defvar gnus-newsgroup-last-rmail nil)
1231 (defvar gnus-newsgroup-last-mail nil)
1232 (defvar gnus-newsgroup-last-folder nil)
1233 (defvar gnus-newsgroup-last-file nil)
1234 (defvar gnus-newsgroup-auto-expire nil
1235 "If non-nil, all read articles will be marked as expirable.")
1237 (defvar gnus-newsgroup-selected-overlay nil)
1239 (defvar gnus-newsgroup-unreads nil
1240 "List of unread articles in the current newsgroup.")
1242 (defvar gnus-newsgroup-unselected nil
1243 "List of unselected unread articles in the current newsgroup.")
1245 (defvar gnus-newsgroup-marked nil
1246 "List of ticked articles in the current newsgroup (a subset of unread art).")
1248 (defvar gnus-newsgroup-killed nil
1249 "List of ranges of articles that have been through the scoring process.")
1251 (defvar gnus-newsgroup-kill-headers nil)
1253 (defvar gnus-newsgroup-replied nil
1254 "List of articles that have been replied to in the current newsgroup.")
1256 (defvar gnus-newsgroup-expirable nil
1257 "List of articles in the current newsgroup that can be expired.")
1259 (defvar gnus-newsgroup-processable nil
1260 "List of articles in the current newsgroup that can be processed.")
1262 (defvar gnus-newsgroup-bookmarks nil
1263 "List of articles in the current newsgroup that have bookmarks.")
1265 (defvar gnus-newsgroup-dormant nil
1266 "List of dormant articles in the current newsgroup.")
1268 (defvar gnus-newsgroup-scored nil
1269 "List of scored articles in the current newsgroup.")
1271 (defvar gnus-newsgroup-headers nil
1272 "List of article headers in the current newsgroup.")
1273 (defvar gnus-newsgroup-headers-hashtb-by-number nil)
1275 (defvar gnus-newsgroup-ancient nil
1276 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1278 (defvar gnus-current-article nil)
1279 (defvar gnus-article-current nil)
1280 (defvar gnus-current-headers nil)
1281 (defvar gnus-have-all-headers nil "Must be either T or NIL.")
1282 (defvar gnus-last-article nil)
1283 (defvar gnus-current-kill-article nil)
1284 (defvar gnus-newsgroup-dormant-subjects nil)
1285 (defvar gnus-newsgroup-expunged-buffer nil)
1287 ;; Save window configuration.
1288 (defvar gnus-winconf-kill-file nil)
1290 (defconst gnus-group-mode-map nil)
1291 (defvar gnus-article-mode-map nil)
1292 (defvar gnus-kill-file-mode-map nil)
1295 (defvar gnus-summary-line-format-spec nil)
1296 (defvar gnus-summary-dummy-line-format-spec nil)
1297 (defvar gnus-group-line-format-spec nil)
1298 (defvar gnus-summary-mode-line-format-spec nil)
1299 (defvar gnus-article-mode-line-format-spec nil)
1300 (defvar gnus-group-mode-line-format-spec nil)
1301 (defvar gnus-summary-expunge-below nil)
1302 (defvar gnus-reffed-article-number nil)
1304 (defvar gnus-summary-mark-positions nil)
1306 (defvar rmail-default-file (expand-file-name "~/XMBOX"))
1307 (defvar rmail-default-rmail-file (expand-file-name "~/XNEWS"))
1309 (defconst gnus-summary-local-variables
1310 '(gnus-newsgroup-name
1311 gnus-newsgroup-begin gnus-newsgroup-end
1312 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1313 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1314 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1315 gnus-newsgroup-unselected gnus-newsgroup-marked
1316 gnus-newsgroup-replied gnus-newsgroup-expirable
1317 gnus-newsgroup-processable gnus-newsgroup-killed
1318 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1319 gnus-newsgroup-dormant-subjects gnus-newsgroup-expunged-buffer
1320 gnus-newsgroup-headers gnus-newsgroup-headers-hashtb-by-number
1321 gnus-current-article gnus-current-headers gnus-have-all-headers
1322 gnus-last-article gnus-article-internal-prepare-hook
1323 gnus-newsgroup-selected-overlay gnus-newsgroup-dependencies
1324 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1325 gnus-score-alist gnus-summary-expunge-below
1326 gnus-summary-mark-below gnus-newsgroup-ancient)
1327 "Variables that are buffer-local to the summary buffers.")
1329 (defvar gnus-mark-article-hook
1332 (or (memq gnus-current-article gnus-newsgroup-marked)
1333 (memq gnus-current-article gnus-newsgroup-dormant)
1334 (memq gnus-current-article gnus-newsgroup-expirable)
1335 (gnus-summary-mark-as-read gnus-current-article gnus-read-mark))))
1336 "A hook called when an article is selected at the first time.
1337 The hook is intended to mark an article as read (or unread)
1338 automatically when it is selected.
1340 If you'd like to tick articles instead, use the following hook:
1342 \(setq gnus-mark-article-hook
1345 (gnus-summary-tick-article gnus-current-article))))")
1347 ;; Define some autoload functions Gnus may use.
1349 (autoload 'metamail-buffer "metamail")
1350 (autoload 'Info-goto-node "info")
1352 (autoload 'timezone-make-date-arpa-standard "timezone")
1353 (autoload 'timezone-fix-time "timezone")
1354 (autoload 'timezone-make-sortable-date "timezone")
1355 (autoload 'timezone-make-time-string "timezone")
1357 (autoload 'rmail-output "rmailout"
1358 "Append this message to Unix mail file named FILE-NAME." t)
1359 (autoload 'mail-position-on-field "sendmail")
1360 (autoload 'mail-setup "sendmail")
1362 (autoload 'gnus-mail-reply-using-mhe "gnus-mh")
1363 (autoload 'gnus-mail-forward-using-mhe "gnus-mh")
1364 (autoload 'gnus-mail-other-window-using-mhe "gnus-mh")
1365 (autoload 'gnus-summary-save-in-folder "gnus-mh")
1366 (autoload 'gnus-Folder-save-name "gnus-mh")
1367 (autoload 'gnus-folder-save-name "gnus-mh")
1369 (autoload 'gnus-group-make-menu-bar "gnus-visual")
1370 (autoload 'gnus-summary-make-menu-bar "gnus-visual")
1371 (autoload 'gnus-article-make-menu-bar "gnus-visual")
1372 (autoload 'gnus-visual-highlight-selected-summary "gnus-visual")
1373 (autoload 'gnus-visual-summary-highlight-line "gnus-visual")
1375 (autoload 'gnus-uu-decode-map "gnus-uu" nil nil 'keymap)
1376 (autoload 'gnus-uu-mark-by-regexp "gnus-uu")
1377 (autoload 'gnus-uu-mark-region "gnus-uu")
1378 (autoload 'gnus-uu-mark-thread "gnus-uu")
1379 (autoload 'gnus-uu-mark-sparse "gnus-uu")
1380 (autoload 'gnus-uu-mark-series "gnus-uu")
1381 (autoload 'gnus-uu-mark-all "gnus-uu")
1382 (autoload 'gnus-uu-post-news "gnus-uu")
1383 (autoload 'gnus-uu-digest-and-forward "gnus-uu")
1385 (autoload 'gnus-uu-decode-uu "gnus-uu")
1386 (autoload 'gnus-uu-decode-uu-and-save "gnus-uu")
1387 (autoload 'gnus-uu-decode-unshar "gnus-uu")
1388 (autoload 'gnus-uu-decode-unshar-and-save "gnus-uu")
1389 (autoload 'gnus-uu-decode-save "gnus-uu")
1390 (autoload 'gnus-uu-decode-binhex "gnus-uu")
1391 (autoload 'gnus-uu-decode-uu-view "gnus-uu")
1392 (autoload 'gnus-uu-decode-uu-and-save-view "gnus-uu")
1393 (autoload 'gnus-uu-decode-unshar-view "gnus-uu")
1394 (autoload 'gnus-uu-decode-unshar-and-save-view "gnus-uu")
1395 (autoload 'gnus-uu-decode-save-view "gnus-uu")
1396 (autoload 'gnus-uu-decode-binhex-view "gnus-uu")
1401 (put 'gnus-group-mode 'mode-class 'special)
1402 (put 'gnus-summary-mode 'mode-class 'special)
1403 (put 'gnus-article-mode 'mode-class 'special)
1407 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
1408 (defun gnus-summary-position-cursor () nil)
1409 (defun gnus-group-position-cursor () nil)
1410 (fset 'gnus-summary-position-cursor 'gnus-goto-colon)
1411 (fset 'gnus-group-position-cursor 'gnus-goto-colon)
1413 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
1414 "Pop to BUFFER, evaluate FORMS, and then returns to original window."
1415 (` (let ((GnusStartBufferWindow (selected-window)))
1418 (pop-to-buffer (, buffer))
1420 (select-window GnusStartBufferWindow)))))
1422 (defun gnus-make-hashtable (&optional hashsize)
1423 "Make a hash table (default and minimum size is 255).
1424 Optional argument HASHSIZE specifies the table size."
1425 (make-vector (if hashsize
1426 (max (gnus-create-hash-size hashsize) 255)
1429 (defmacro gnus-gethash (string hashtable)
1430 "Get hash value of STRING in HASHTABLE."
1431 ;;(` (symbol-value (abbrev-symbol (, string) (, hashtable))))
1432 ;;(` (abbrev-expansion (, string) (, hashtable)))
1433 (` (symbol-value (intern-soft (, string) (, hashtable)))))
1435 (defmacro gnus-sethash (string value hashtable)
1436 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
1437 ;; We cannot use define-abbrev since it only accepts string as value.
1438 ; (set (intern string hashtable) value))
1439 (` (set (intern (, string) (, hashtable)) (, value))))
1441 (defsubst gnus-buffer-substring (beg end)
1442 (buffer-substring (match-beginning beg) (match-end end)))
1444 (defsubst gnus-simplify-subject-re (subject)
1445 "Remove \"Re:\" from subject lines."
1446 (let ((case-fold-search t))
1447 (if (string-match "^re: *" subject)
1448 (substring subject (match-end 0))
1451 (defsubst gnus-goto-char (point)
1452 (and point (goto-char point)))
1456 ;;; Gnus Utility Functions
1459 (defun gnus-extract-address-components (from)
1461 (if (string-match "([^)]+)" from)
1462 (setq name (substring from (1+ (match-beginning 0))
1463 (1- (match-end 0)))))
1464 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
1465 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
1466 (setq address (substring from (match-beginning 0) (match-end 0))))
1467 (if (and (not name) address)
1468 (if (string-match (concat "<" (regexp-quote address) ">") from)
1469 (setq name (substring from 0 (1- (match-beginning 0))))))
1470 (list (or name from) (or address from))))
1472 (defun gnus-fetch-field (field)
1473 "Return the value of the header FIELD of current article."
1476 (gnus-narrow-to-headers)
1477 (mail-fetch-field field))))
1479 (defun gnus-goto-colon ()
1481 (search-forward ":" (save-excursion (end-of-line) (point)) t))
1483 (defun gnus-narrow-to-headers ()
1487 (if (search-forward "\n\n")
1488 (narrow-to-region 1 (1- (point))))))
1490 ;; Get a number that is suitable for hashing; bigger than MIN
1491 (defun gnus-create-hash-size (min)
1497 (defun gnus-update-format-specifications ()
1498 (setq gnus-summary-line-format-spec
1500 gnus-summary-line-format gnus-summary-line-format-alist))
1501 (gnus-update-summary-mark-positions)
1502 (setq gnus-summary-dummy-line-format-spec
1503 (gnus-parse-format gnus-summary-dummy-line-format
1504 gnus-summary-dummy-line-format-alist))
1505 (setq gnus-group-line-format-spec
1507 gnus-group-line-format
1508 gnus-group-line-format-alist))
1509 (if (and (string-match "%D" gnus-group-line-format)
1510 (not gnus-description-hashtb)
1511 gnus-read-active-file)
1512 (gnus-read-descriptions-file))
1513 (setq gnus-summary-mode-line-format-spec
1514 (gnus-parse-format gnus-summary-mode-line-format
1515 gnus-summary-mode-line-format-alist))
1516 (setq gnus-article-mode-line-format-spec
1517 (gnus-parse-format gnus-article-mode-line-format
1518 gnus-summary-mode-line-format-alist))
1519 (setq gnus-group-mode-line-format-spec
1520 (gnus-parse-format gnus-group-mode-line-format
1521 gnus-group-mode-line-format-alist)))
1523 (defun gnus-update-summary-mark-positions ()
1525 (let ((gnus-replied-mark 129)
1526 (gnus-score-below-mark 130)
1527 (gnus-score-over-mark 130)
1529 (set-buffer (get-buffer-create " *gnus work*"))
1530 (buffer-disable-undo (current-buffer))
1532 (gnus-summary-insert-line
1533 nil ["" "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
1534 (goto-char (point-min))
1535 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
1537 (goto-char (point-min))
1538 (setq pos (cons (cons 'replied (and (search-forward "\201" nil t)
1539 (- (point) 2))) pos))
1540 (goto-char (point-min))
1541 (setq pos (cons (cons 'score (and (search-forward "\202" nil t)
1542 (- (point) 2))) pos))
1543 (setq gnus-summary-mark-positions pos)
1544 (kill-buffer (current-buffer)))))
1546 (defun gnus-format-max-width (var length)
1548 (if (> (length (setq result (eval var))) length)
1549 (format "%s" (substring result 0 length))
1550 (format "%s" result))))
1552 (defun gnus-set-mouse-face (string)
1553 ;; Set mouse face property on STRING.
1554 (put-text-property 0 (length string) 'mouse-face gnus-mouse-face string)
1557 (defun gnus-parse-format (format spec-alist)
1558 ;; This function parses the FORMAT string with the help of the
1559 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
1560 ;; string. If the FORMAT string contains the specifiers %( and %)
1561 ;; the text between them will have the mouse-face text property.
1562 (if (string-match "\\`\\(.*\\)%(\\(.*\\)%)\\(.*\n?\\)\\'" format)
1563 (if (and gnus-visual gnus-mouse-face)
1564 (let ((pre (substring format (match-beginning 1) (match-end 1)))
1565 (button (substring format (match-beginning 2) (match-end 2)))
1566 (post (substring format (match-beginning 3) (match-end 3))))
1568 (gnus-parse-simple-format pre spec-alist)
1569 (list 'gnus-set-mouse-face
1570 (gnus-parse-simple-format button spec-alist))
1571 (gnus-parse-simple-format post spec-alist)))
1572 (gnus-parse-simple-format
1573 (concat (substring format (match-beginning 1) (match-end 1))
1574 (substring format (match-beginning 2) (match-end 2))
1575 (substring format (match-beginning 3) (match-end 3)))
1577 (gnus-parse-simple-format format spec-alist)))
1579 (defun gnus-parse-simple-format (format spec-alist)
1580 ;; This function parses the FORMAT string with the help of the
1581 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
1582 ;; string. The list will consist of the symbol `format', a format
1583 ;; specification string, and a list of forms depending on the
1586 spec flist fstring b newspec max-width elem beg)
1588 (set-buffer (get-buffer-create "*gnus work*"))
1589 (buffer-disable-undo (current-buffer))
1590 (gnus-add-current-to-buffer-list)
1594 (while (re-search-forward "%[-0-9]*\\(,[0-9]*\\)*\\(.\\)\\(.\\)?" nil t)
1595 (setq spec (string-to-char (buffer-substring (match-beginning 2)
1597 ;; First check if there are any specs that look anything like
1598 ;; "%12,12A", ie. with a "max width specification". These have
1599 ;; to be treated specially.
1600 (if (setq beg (match-beginning 1))
1603 (buffer-substring (1+ (match-beginning 1)) (match-end 1))))
1605 (setq beg (match-beginning 2)))
1606 ;; Find the specification from `spec-alist'.
1607 (if (not (setq elem (cdr (assq spec spec-alist))))
1608 (setq elem '("*" ?s)))
1609 ;; Treat user defined format specifiers specially
1610 (and (eq (car elem) 'user-defined)
1613 (list (intern (concat "gnus-user-format-function-"
1619 (delete-region (match-beginning 3) (match-end 3)))
1620 (if (not (zerop max-width))
1621 (let ((el (car elem)))
1622 (cond ((= (car (cdr elem)) ?c)
1623 (setq el (list 'char-to-string el)))
1624 ((= (car (cdr elem)) ?d)
1625 (numberp el) (setq el (list 'int-to-string el))))
1626 (setq flist (cons (list 'gnus-format-max-width
1630 (setq flist (cons (car elem) flist))
1631 (setq newspec (car (cdr elem))))
1632 ;; Remove the old specification (and possibly a ",12" string).
1633 (delete-region beg (match-end 2))
1634 ;; Insert the new specification.
1637 (setq fstring (buffer-substring 1 (point-max))))
1638 (cons 'format (cons fstring (nreverse flist)))))
1640 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
1641 (defun gnus-read-init-file ()
1643 (or (file-exists-p gnus-init-file)
1644 (file-exists-p (concat gnus-init-file ".el"))
1645 (file-exists-p (concat gnus-init-file ".elc")))
1646 (load gnus-init-file nil t)))
1648 ;; Article file names when saving.
1650 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
1651 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
1652 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
1653 Otherwise, it is like ~/News/news/group/num."
1656 (concat (if gnus-use-long-file-name
1657 (gnus-capitalize-newsgroup newsgroup)
1658 (gnus-newsgroup-directory-form newsgroup))
1659 "/" (int-to-string (header-number headers)))
1660 (or gnus-article-save-directory "~/News"))))
1662 (string-equal (file-name-directory default)
1663 (file-name-directory last-file))
1664 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
1666 (or last-file default))))
1668 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
1669 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
1670 If variable `gnus-use-long-file-name' is nil, it is ~/News/news.group/num.
1671 Otherwise, it is like ~/News/news/group/num."
1674 (concat (if gnus-use-long-file-name
1676 (gnus-newsgroup-directory-form newsgroup))
1677 "/" (int-to-string (header-number headers)))
1678 (or gnus-article-save-directory "~/News"))))
1680 (string-equal (file-name-directory default)
1681 (file-name-directory last-file))
1682 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
1684 (or last-file default))))
1686 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
1687 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
1688 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group.
1689 Otherwise, it is like ~/News/news/group/news."
1692 (if gnus-use-long-file-name
1693 (gnus-capitalize-newsgroup newsgroup)
1694 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
1695 (or gnus-article-save-directory "~/News"))))
1697 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
1698 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
1699 If variable `gnus-use-long-file-name' is nil, it is ~/News/news.group.
1700 Otherwise, it is like ~/News/news/group/news."
1703 (if gnus-use-long-file-name
1705 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
1706 (or gnus-article-save-directory "~/News"))))
1708 ;; For subscribing new newsgroup
1710 (defun gnus-subscribe-hierarchical-interactive (groups)
1711 (let ((groups (sort groups 'string<))
1712 prefixes prefix start rest ans group starts)
1714 (setq prefixes (list "^"))
1715 (while (and groups prefixes)
1716 (while (not (string-match (car prefixes) (car groups)))
1717 (setq prefixes (cdr prefixes)))
1718 (setq prefix (car prefixes))
1719 (setq start (1- (length prefix)))
1720 (if (and (string-match "[^\\.]\\." (car groups) start)
1723 (concat "^" (substring (car groups) 0 (match-end 0))))
1724 (string-match prefix (car (cdr groups))))
1726 (setq prefixes (cons prefix prefixes))
1727 (message "Descend hierarchy %s? ([y]nsq): "
1728 (substring prefix 1 (1- (length prefix))))
1729 (setq ans (read-char))
1732 (string-match prefix
1733 (setq group (car groups))))
1734 (setq gnus-killed-list
1735 (cons group gnus-killed-list))
1736 (gnus-sethash group group gnus-killed-hashtb)
1737 (setq groups (cdr groups)))
1738 (setq starts (cdr starts)))
1741 (string-match prefix
1742 (setq group (car groups))))
1743 (gnus-sethash group group gnus-killed-hashtb)
1744 (gnus-subscribe-alphabetically (car groups))
1745 (setq groups (cdr groups)))
1746 (setq starts (cdr starts)))
1749 (setq group (car groups))
1750 (setq gnus-killed-list (cons group gnus-killed-list))
1751 (gnus-sethash group group gnus-killed-hashtb)
1752 (setq groups (cdr groups))))
1754 (message "Subscribe %s? ([n]yq)" (car groups))
1755 (setq ans (read-char))
1756 (setq group (car groups))
1758 (gnus-subscribe-alphabetically (car groups))
1759 (gnus-sethash group group gnus-killed-hashtb))
1762 (setq group (car groups))
1763 (setq gnus-killed-list (cons group gnus-killed-list))
1764 (gnus-sethash group group gnus-killed-hashtb)
1765 (setq groups (cdr groups))))
1767 (setq gnus-killed-list (cons group gnus-killed-list))
1768 (gnus-sethash group group gnus-killed-hashtb)))
1769 (setq groups (cdr groups)))))))
1771 (defun gnus-subscribe-randomly (newsgroup)
1772 "Subscribe new NEWSGROUP by making it the first newsgroup."
1773 (gnus-subscribe-newsgroup newsgroup))
1775 (defun gnus-subscribe-alphabetically (newgroup)
1776 "Subscribe new NEWSGROUP and insert it in alphabetical order."
1777 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
1778 (let ((groups (cdr gnus-newsrc-assoc))
1780 (while (and (not before) groups)
1781 (if (string< newgroup (car (car groups)))
1782 (setq before (car (car groups)))
1783 (setq groups (cdr groups))))
1784 (gnus-subscribe-newsgroup newgroup before)))
1786 (defun gnus-subscribe-hierarchically (newgroup)
1787 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
1788 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
1790 (set-buffer (find-file-noselect gnus-current-startup-file))
1791 (let ((groupkey newgroup)
1793 (while (and (not before) groupkey)
1794 (goto-char (point-min))
1796 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
1797 (while (and (re-search-forward groupkey-re nil t)
1799 (setq before (buffer-substring
1800 (match-beginning 1) (match-end 1)))
1801 (string< before newgroup)))))
1802 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
1804 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
1805 (substring groupkey (match-beginning 1) (match-end 1)))))
1806 (gnus-subscribe-newsgroup newgroup before))))
1808 (defun gnus-subscribe-interactively (newsgroup)
1809 "Subscribe new NEWSGROUP interactively.
1810 It is inserted in hierarchical newsgroup order if subscribed. If not,
1812 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " newsgroup))
1813 (gnus-subscribe-hierarchically newsgroup)
1814 (setq gnus-killed-list (cons newsgroup gnus-killed-list))))
1816 (defun gnus-subscribe-zombies (newsgroup)
1817 "Make new NEWSGROUP a zombie group."
1818 (setq gnus-zombie-list (cons newsgroup gnus-zombie-list)))
1820 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
1821 "Subscribe new NEWSGROUP.
1822 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
1823 the first newsgroup."
1824 ;; We subscribe the group by changing its level to 3.
1825 (gnus-group-change-level
1826 newsgroup 3 9 (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
1827 (message "Subscribe newsgroup: %s" newsgroup))
1831 (defun gnus-newsgroup-directory-form (newsgroup)
1832 "Make hierarchical directory name from NEWSGROUP name."
1833 (let ((newsgroup (substring newsgroup 0)) ;Copy string.
1834 (len (length newsgroup))
1836 ;; Replace all occurrences of `.' with `/'.
1838 (if (= (aref newsgroup idx) ?.)
1839 (aset newsgroup idx ?/))
1840 (setq idx (1+ idx)))
1844 (defun gnus-make-directory (dir)
1845 "Make DIRECTORY recursively."
1846 (let* ((dir (expand-file-name dir default-directory))
1848 (if (string-match "/$" dir)
1849 (setq dir (substring dir 0 (match-beginning 0))))
1850 (while (not (file-exists-p dir))
1851 (setq dirs (cons dir dirs))
1852 (string-match "/[^/]+$" dir)
1853 (setq dir (substring dir 0 (match-beginning 0))))
1855 (make-directory (car dirs))
1856 (setq dirs (cdr dirs)))))
1858 (defun gnus-capitalize-newsgroup (newsgroup)
1859 "Capitalize NEWSGROUP name."
1860 (and (not (zerop (length newsgroup)))
1861 (concat (char-to-string (upcase (aref newsgroup 0)))
1862 (substring newsgroup 1))))
1866 (defun gnus-simplify-subject (subject &optional re-only)
1867 "Remove `Re:' and words in parentheses.
1868 If optional argument RE-ONLY is non-nil, strip `Re:' only."
1869 (let ((case-fold-search t)) ;Ignore case.
1870 ;; Remove `Re:' and `Re^N:'.
1871 (if (string-match "^re:[ \t]*" subject)
1872 (setq subject (substring subject (match-end 0))))
1873 ;; Remove words in parentheses from end.
1875 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1876 (setq subject (substring subject 0 (match-beginning 0)))))
1877 ;; Return subject string.
1881 (defun gnus-add-current-to-buffer-list ()
1882 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list)))
1884 ;; Functions accessing headers.
1885 ;; Functions are more convenient than macros in some case.
1887 (defun gnus-header-number (header)
1888 "Return article number in HEADER."
1889 (header-number header))
1891 (defun gnus-header-subject (header)
1892 "Return subject string in HEADER."
1893 (header-subject header))
1895 (defun gnus-header-from (header)
1896 "Return author string in HEADER."
1897 (header-from header))
1899 (defun gnus-header-xref (header)
1900 "Return xref string in HEADER."
1901 (header-xref header))
1903 (defun gnus-header-lines (header)
1904 "Return lines in HEADER."
1905 (header-lines header))
1907 (defun gnus-header-date (header)
1908 "Return date in HEADER."
1909 (header-date header))
1911 (defun gnus-header-id (header)
1912 "Return Id in HEADER."
1915 (defun gnus-header-references (header)
1916 "Return references in HEADER."
1917 (header-references header))
1919 (defun gnus-clear-system ()
1920 "Clear all variables and buffers."
1921 ;; Clear Gnus variables.
1922 (let ((variables gnus-variable-list))
1924 (set (car variables) nil)
1925 (setq variables (cdr variables))))
1926 ;; Clear other internal variables.
1927 (setq gnus-list-of-killed-groups nil
1928 gnus-have-read-active-file nil
1929 gnus-newsrc-assoc nil
1930 gnus-newsrc-hashtb nil
1931 gnus-killed-list nil
1932 gnus-zombie-list nil
1933 gnus-killed-hashtb nil
1934 gnus-active-hashtb nil
1935 gnus-moderated-list nil
1936 gnus-description-hashtb nil
1937 gnus-newsgroup-headers nil
1938 gnus-score-cache nil
1939 gnus-newsgroup-headers-hashtb-by-number nil
1940 gnus-current-select-method nil)
1941 ;; Kill the startup file.
1942 (and gnus-current-startup-file
1943 (get-file-buffer gnus-current-startup-file)
1944 (kill-buffer (get-file-buffer gnus-current-startup-file)))
1945 (setq gnus-current-startup-file nil)
1946 (gnus-dribble-clear)
1947 ;; Kill global KILL file buffer.
1948 (if (get-file-buffer (gnus-newsgroup-kill-file nil))
1949 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
1950 ;; Kill Gnus buffers.
1951 (while gnus-buffer-list
1952 (if (and (get-buffer (car gnus-buffer-list))
1953 (buffer-name (get-buffer (car gnus-buffer-list))))
1954 (kill-buffer (car gnus-buffer-list)))
1955 (setq gnus-buffer-list (cdr gnus-buffer-list))))
1957 (defun gnus-configure-windows (action &optional force)
1958 "Configure Gnus windows according to the next ACTION.
1959 The ACTION is either a symbol, such as `summary', or a
1960 configuration list such as `(1 1 2)'. If ACTION is not a list,
1961 configuration list is got from the variable gnus-window-configuration.
1962 If FORCE is non-nil, the updating will be done whether it is necessary
1965 (if (listp action) action
1966 (if (listp gnus-window-configuration)
1967 (car (cdr (assq action gnus-window-configuration)))
1968 gnus-window-configuration)))
1969 (grpwin (get-buffer-window gnus-group-buffer))
1970 (subwin (get-buffer-window gnus-summary-buffer))
1971 (artwin (get-buffer-window gnus-article-buffer))
1978 ;; Make split-window-vertically leave focus in upper window.
1979 (split-window-keep-point t))
1980 (if (and (symbolp windows) (fboundp windows))
1981 (funcall windows action)
1982 (if (and (not force)
1983 (or (null windows) ;No configuration is specified.
1984 (and (eq (null grpwin)
1985 (zerop (nth 0 windows)))
1987 (zerop (nth 1 windows)))
1989 (zerop (nth 2 windows))))))
1990 ;; No need to change window configuration.
1992 (select-window (or grpwin subwin artwin (selected-window)))
1993 ;; First of all, compute the height of each window.
1994 (cond (gnus-use-full-window
1995 ;; Take up the entire screen.
1996 (delete-other-windows)
1997 (setq height (window-height (selected-window))))
1999 (setq height (+ (if grpwin (window-height grpwin) 0)
2000 (if subwin (window-height subwin) 0)
2001 (if artwin (window-height artwin) 0)))))
2002 ;; The group buffer exits always. So, use it to extend the
2003 ;; group window so as to get enough window space.
2004 (switch-to-buffer gnus-group-buffer 'norecord)
2005 (and (get-buffer gnus-summary-buffer)
2006 (delete-windows-on gnus-summary-buffer))
2007 (and (get-buffer gnus-article-buffer)
2008 (delete-windows-on gnus-article-buffer))
2009 ;; Compute expected window height.
2010 (setq winsum (apply (function +) windows))
2011 (if (not (zerop (nth 0 windows)))
2012 (setq grpheight (max window-min-height
2013 (/ (* height (nth 0 windows)) winsum))))
2014 (if (not (zerop (nth 1 windows)))
2015 (setq subheight (max window-min-height
2016 (/ (* height (nth 1 windows)) winsum))))
2017 (if (not (zerop (nth 2 windows)))
2018 (setq artheight (max window-min-height
2019 (/ (* height (nth 2 windows)) winsum))))
2020 (setq height (+ grpheight subheight artheight))
2021 (enlarge-window (max 0 (- height (window-height (selected-window)))))
2022 ;; Then split the window.
2023 (and (not (zerop artheight))
2024 (or (not (zerop grpheight))
2025 (not (zerop subheight)))
2026 (split-window-vertically (+ grpheight subheight)))
2027 (and (not (zerop grpheight))
2028 (not (zerop subheight))
2029 (split-window-vertically grpheight))
2030 ;; Then select buffers in each window.
2031 (or (zerop grpheight)
2033 (switch-to-buffer gnus-group-buffer 'norecord)
2035 (or (zerop subheight)
2037 (switch-to-buffer gnus-summary-buffer 'norecord)
2039 (or (zerop artheight)
2041 ;; If article buffer does not exist, it will be created
2043 (gnus-article-setup-buffer)
2044 (switch-to-buffer gnus-article-buffer 'norecord)
2045 (setq buffer-read-only t) ; !!! Why!?!
2046 (bury-buffer gnus-summary-buffer)
2047 (bury-buffer gnus-group-buffer)))
2048 (or (zerop subheight)
2050 (pop-to-buffer gnus-summary-buffer)
2051 ;; It seems that some code in this function will set
2052 ;; buffer-read-only to nil. I have absolutely no idea
2054 (setq buffer-read-only t))) ; !!! Why!?!
2057 (defun gnus-window-configuration-split (action)
2058 (switch-to-buffer gnus-group-buffer t)
2059 (delete-other-windows)
2060 (split-window-horizontally)
2061 (cond ((or (eq action 'newsgroups) (eq action 'summary))
2062 (if (and (get-buffer gnus-summary-buffer)
2063 (buffer-name gnus-summary-buffer))
2064 (switch-to-buffer-other-window gnus-summary-buffer)))
2065 ((eq action 'article)
2066 (switch-to-buffer gnus-summary-buffer t)
2068 (gnus-article-setup-buffer)
2069 (switch-to-buffer gnus-article-buffer t))))
2071 (defun gnus-version ()
2072 "Version numbers of this version of Gnus."
2074 (let ((methods gnus-valid-select-methods)
2077 ;; Go through all the legal select methods and add their version
2078 ;; numbers to the total version string. Only the backends that are
2079 ;; currently in use will have their message numbers taken into
2082 (setq meth (intern (concat (car (car methods)) "-version")))
2084 (stringp (symbol-value meth))
2085 (setq mess (concat mess "; " (symbol-value meth))))
2086 (setq methods (cdr methods)))
2089 (defun gnus-info-find-node ()
2090 "Find Info documentation of Gnus."
2092 ;; Enlarge info window if needed.
2093 (cond ((eq major-mode 'gnus-group-mode)
2094 (gnus-configure-windows '(1 0 0)) ;Take all windows.
2095 (pop-to-buffer gnus-group-buffer))
2096 ((eq major-mode 'gnus-summary-mode)
2097 (gnus-configure-windows '(0 1 0)) ;Take all windows.
2098 (pop-to-buffer gnus-summary-buffer)))
2099 (Info-goto-node (car (cdr (assq major-mode gnus-info-nodes)))))
2102 "Send a bug report to the Gnus maintainers."
2104 (pop-to-buffer "*Gnus Bug*")
2106 (mail-setup gnus-maintainer "[Gnus Bug Report] " nil nil nil nil)
2107 (goto-char (point-min))
2108 (search-forward mail-header-separator)
2110 (insert (format "%s\n%s\n\n" (gnus-version) (emacs-version)))
2115 (defun gnus-debug ()
2116 "Attemps to go through the Gnus source file and report what variables have been changed.
2117 The source file has to be in the Emacs load path."
2119 (let ((dirs load-path)
2122 (if (file-exists-p (setq file (concat (car dirs) "/gnus.el")))
2125 (set-buffer (get-buffer-create "*gnus bug info*"))
2126 (buffer-disable-undo (current-buffer))
2128 (insert-file-contents file)
2129 (goto-char (point-min))
2130 (or (search-forward "\n;; Internal variables" nil t)
2131 (error "Malformed sources"))
2132 (narrow-to-region (point-min) (point))
2133 (goto-char (point-min))
2134 (while (setq expr (condition-case ()
2135 (read (current-buffer)) (error nil)))
2136 (and (eq (car expr) 'defvar)
2137 (stringp (nth 3 expr))
2138 (not (equal (eval (nth 2 expr))
2139 (symbol-value (nth 1 expr))))
2140 (setq olist (cons (nth 1 expr) olist))))
2141 (kill-buffer (current-buffer)))
2142 (setq dirs (cdr dirs))))
2144 (insert "(setq " (symbol-name (car olist)) " '"
2145 (prin1-to-string (symbol-value (car olist))) ")\n")
2146 (setq olist (cdr olist)))
2149 (defun gnus-overload-functions (&optional overloads)
2150 "Overload functions specified by optional argument OVERLOADS.
2151 If nothing is specified, use the variable gnus-overload-functions."
2153 (overloads (or overloads gnus-overload-functions)))
2155 (setq defs (car overloads))
2156 (setq overloads (cdr overloads))
2157 ;; Load file before overloading function if necessary. Make
2158 ;; sure we cannot use `require' always.
2159 (and (not (fboundp (car defs)))
2160 (car (cdr (cdr defs)))
2161 (load (car (cdr (cdr defs))) nil 'nomessage))
2162 (fset (car defs) (car (cdr defs)))
2165 (defun gnus-replace-chars-in-string (string from to)
2166 "Replace characters in STRING from FROM to TO."
2167 (let ((string (substring string 0)) ;Copy string.
2168 (len (length string))
2170 ;; Replace all occurrences of FROM with TO.
2172 (if (= (aref string idx) from)
2173 (aset string idx to))
2174 (setq idx (1+ idx)))
2177 (defun gnus-days-between (date1 date2)
2178 ;; Return the number of days between date1 and date2.
2179 (let ((d1 (mapcar (lambda (s) (and s (string-to-int s)) )
2180 (timezone-parse-date date1)))
2181 (d2 (mapcar (lambda (s) (and s (string-to-int s)) )
2182 (timezone-parse-date date2))))
2183 (- (timezone-absolute-from-gregorian
2184 (nth 1 d1) (nth 2 d1) (car d1))
2185 (timezone-absolute-from-gregorian
2186 (nth 1 d2) (nth 2 d2) (car d2)))))
2188 (defun gnus-file-newer-than (file date)
2189 (let ((fdate (nth 5 (file-attributes file))))
2190 (or (> (car fdate) (car date))
2191 (and (= (car fdate) (car date))
2192 (> (nth 1 fdate) (nth 1 date))))))
2194 (defun gnus-y-or-n-p (prompt)
2199 (defun gnus-yes-or-no-p (prompt)
2201 (yes-or-no-p prompt)
2204 ;; Return a string of length POS+1 representing NUMber in BASE. The
2205 ;; resulting string will be left padded with zeds.
2206 (defun gnus-number-base-x (num pos base)
2211 (aref "zyxwvutsrqponmlkjihgfedcba9876543210" (/ num (expt base pos))))
2213 (% num (expt base pos)) (1- pos) base))))
2215 ;; List and range functions
2217 (defun gnus-last-element (list)
2218 "Return last element of LIST."
2220 (setq list (cdr list)))
2223 (defun gnus-set-difference (list1 list2)
2224 "Return a list of elements of LIST1 that do not appear in LIST2."
2225 (let ((list1 (copy-sequence list1)))
2227 (setq list1 (delq (car list2) list1))
2228 (setq list2 (cdr list2)))
2232 (defun gnus-intersection (list1 list2)
2235 (if (memq (car list2) list1)
2236 (setq result (cons (car list2) result)))
2237 (setq list2 (cdr list2)))
2241 (defun gnus-compress-sequence (numbers &optional always-list)
2242 "Convert list of numbers to a list of ranges or a single range.
2243 If ALWAYS-LIST is non-nil, this function will always release a list of
2245 (let* ((first (car numbers))
2246 (last (car numbers))
2251 (cond ((= last (car numbers)) nil) ;Omit duplicated number
2252 ((= (1+ last) (car numbers)) ;Still in sequence
2253 (setq last (car numbers)))
2254 (t ;End of one sequence
2255 (setq result (cons (cons first last) result))
2256 (setq first (car numbers))
2257 (setq last (car numbers))))
2258 (setq numbers (cdr numbers)))
2259 (if (and (not always-list) (null result))
2261 (nreverse (cons (cons first last) result))))))
2263 (defun gnus-uncompress-sequence (ranges)
2264 "Expand a list of ranges into a list of numbers.
2265 RANGES is either a single range on the form `(num . num)' or a list of
2267 (let (first last result)
2270 (if (atom (car ranges))
2272 (setq first (car ranges))
2273 (setq last (cdr ranges))
2274 (while (<= first last)
2275 (setq result (cons first result))
2276 (setq first (1+ first))))
2278 (setq first (car (car ranges)))
2279 (setq last (cdr (car ranges)))
2280 (while (<= first last)
2281 (setq result (cons first result))
2282 (setq first (1+ first)))
2283 (setq ranges (cdr ranges))))
2284 (nreverse result))))
2286 (defun gnus-add-to-range (ranges list)
2287 "Return a list of ranges that has all articles from both RANGES and LIST.
2288 Note: LIST has to be sorted over `<'."
2289 (let* ((ranges (if (and ranges (atom (car ranges))) (list ranges) ranges))
2292 range nranges first last)
2296 (gnus-compress-sequence list t)
2298 (> (car (car ranges)) 1)
2301 (setq inrange (setq ranges (cons (cons 1 1) ranges)))))
2302 (while (and ranges list)
2303 (setq range (car ranges))
2304 (while (and list (>= (car list) (car range))
2305 (<= (car list) (cdr range)))
2306 (setq list (cdr list)))
2307 (while (and list (= (1- (car list)) (cdr range)))
2308 (setcdr range (car list))
2309 (setq list (cdr list)))
2310 (if (and list (and (> (car list) (cdr range))
2312 (< (car list) (car (car (cdr ranges))))))
2313 (setcdr ranges (cons (cons (car list) (car list)) (cdr ranges))))
2314 (setq ranges (cdr ranges)))
2315 (if (and list (not ranges))
2316 (setq inrange (nconc inrange (gnus-compress-sequence list t))))
2318 (if (eq (cdr (car inrange)) 1)
2319 (setq inrange (cdr inrange))
2320 (setcar (car inrange) 2)))
2321 (setq ranges inrange)
2323 (if (and (cdr ranges) (>= (1+ (cdr (car ranges)))
2324 (car (car (cdr ranges)))))
2326 (setcdr (car ranges) (cdr (car (cdr ranges))))
2327 (setcdr ranges (cdr (cdr ranges))))
2328 (setq ranges (cdr ranges))))
2329 (if (not (cdr inrange))
2333 (defun gnus-remove-from-range (ranges list)
2334 "Return a list of ranges that has all articles from LIST removed from RANGES.
2335 Note: LIST has to be sorted over `<'."
2336 ;; !!! This function shouldn't look like this, but I've got a headache.
2337 (gnus-compress-sequence
2338 (gnus-set-difference
2339 (gnus-uncompress-sequence ranges) list)))
2341 (defun gnus-member-of-range (number ranges)
2343 (while (and ranges not-stop)
2344 (if (and (>= number (car (car ranges)))
2345 (<= number (cdr (car ranges))))
2346 (setq not-stop nil))
2347 (setq ranges (cdr ranges)))
2355 (if gnus-group-mode-map
2357 (setq gnus-group-mode-map (make-keymap))
2358 (suppress-keymap gnus-group-mode-map)
2359 (define-key gnus-group-mode-map " " 'gnus-group-read-group)
2360 (define-key gnus-group-mode-map "=" 'gnus-group-select-group)
2361 (define-key gnus-group-mode-map "j" 'gnus-group-jump-to-group)
2362 (define-key gnus-group-mode-map "n" 'gnus-group-next-unread-group)
2363 (define-key gnus-group-mode-map "p" 'gnus-group-prev-unread-group)
2364 (define-key gnus-group-mode-map [del] 'gnus-group-prev-unread-group)
2365 (define-key gnus-group-mode-map "N" 'gnus-group-next-group)
2366 (define-key gnus-group-mode-map "P" 'gnus-group-prev-group)
2367 (define-key gnus-group-mode-map "\M-n" 'gnus-group-next-unread-group-same-level)
2368 (define-key gnus-group-mode-map "\M-p" 'gnus-group-prev-unread-group-same-level)
2369 (define-key gnus-group-mode-map "," 'gnus-group-best-unread-group)
2370 (define-key gnus-group-mode-map "\r" 'gnus-group-select-group)
2371 (define-key gnus-group-mode-map "u" 'gnus-group-unsubscribe-current-group)
2372 (define-key gnus-group-mode-map "U" 'gnus-group-unsubscribe-group)
2373 (define-key gnus-group-mode-map "c" 'gnus-group-catchup-current)
2374 (define-key gnus-group-mode-map "C" 'gnus-group-catchup-current-all)
2375 (define-key gnus-group-mode-map "l" 'gnus-group-list-groups)
2376 (define-key gnus-group-mode-map "L" 'gnus-group-list-all-groups)
2377 (define-key gnus-group-mode-map "m" 'gnus-group-mail)
2378 (define-key gnus-group-mode-map "g" 'gnus-group-get-new-news)
2379 (define-key gnus-group-mode-map "\M-g" 'gnus-group-get-new-news-this-group)
2380 (define-key gnus-group-mode-map "R" 'gnus-group-restart)
2381 (define-key gnus-group-mode-map "r" 'gnus-group-read-init-file)
2382 (define-key gnus-group-mode-map "B" 'gnus-group-browse-foreign-server)
2383 (define-key gnus-group-mode-map "b" 'gnus-group-check-bogus-groups)
2384 (define-key gnus-group-mode-map "F" 'gnus-find-new-newsgroups)
2385 (define-key gnus-group-mode-map "\C-c\C-d" 'gnus-group-describe-group)
2386 (define-key gnus-group-mode-map "\M-d" 'gnus-group-describe-all-groups)
2387 (define-key gnus-group-mode-map "\C-c\C-a" 'gnus-group-apropos)
2388 (define-key gnus-group-mode-map "\C-c\M-C-a" 'gnus-group-description-apropos)
2389 (define-key gnus-group-mode-map "D" 'gnus-group-make-doc-group)
2390 (define-key gnus-group-mode-map "d" 'gnus-group-make-directory-group)
2391 (define-key gnus-group-mode-map "a" 'gnus-group-post-news)
2392 (define-key gnus-group-mode-map "\M-a" 'gnus-group-add-group)
2393 (define-key gnus-group-mode-map "\M-e" 'gnus-group-edit-group)
2394 (define-key gnus-group-mode-map "\ek" 'gnus-group-edit-local-kill)
2395 (define-key gnus-group-mode-map "\eK" 'gnus-group-edit-global-kill)
2396 (define-key gnus-group-mode-map "\C-k" 'gnus-group-kill-group)
2397 (define-key gnus-group-mode-map "\C-y" 'gnus-group-yank-group)
2398 (define-key gnus-group-mode-map "\C-w" 'gnus-group-kill-region)
2399 (define-key gnus-group-mode-map "\M-z" 'gnus-group-kill-all-zombies)
2400 (define-key gnus-group-mode-map "\C-x\C-t" 'gnus-group-transpose-groups)
2401 (define-key gnus-group-mode-map "\C-c\C-l" 'gnus-group-list-killed)
2402 (define-key gnus-group-mode-map "\C-c\C-k" 'gnus-group-list-killed)
2403 (define-key gnus-group-mode-map "\C-c\C-z" 'gnus-group-list-zombies)
2404 (define-key gnus-group-mode-map "\C-c\C-x" 'gnus-group-expire-articles)
2405 (define-key gnus-group-mode-map "\C-c\M-\C-x" 'gnus-group-expire-all-groups)
2406 (define-key gnus-group-mode-map "V" 'gnus-version)
2407 (define-key gnus-group-mode-map "S" 'gnus-group-set-current-level)
2408 (define-key gnus-group-mode-map "s" 'gnus-group-save-newsrc)
2409 (define-key gnus-group-mode-map "z" 'gnus-group-suspend)
2410 (define-key gnus-group-mode-map "Z" 'gnus-group-clear-dribble)
2411 (define-key gnus-group-mode-map "q" 'gnus-group-exit)
2412 (define-key gnus-group-mode-map "Q" 'gnus-group-quit)
2413 (define-key gnus-group-mode-map "?" 'gnus-group-describe-briefly)
2414 (define-key gnus-group-mode-map "\C-c\C-i" 'gnus-info-find-node)
2415 (define-key gnus-group-mode-map [mouse-2] 'gnus-mouse-pick-group))
2417 (defun gnus-group-mode ()
2418 "Major mode for reading news.
2419 All normal editing commands are switched off.
2420 The following commands are available:
2422 \\<gnus-group-mode-map>
2423 \\[gnus-group-read-group]\t Choose the current group
2424 \\[gnus-group-select-group]\t Select the current group without selecting the first article
2425 \\[gnus-group-jump-to-group]\t Go to some group
2426 \\[gnus-group-next-unread-group]\t Go to the next unread group
2427 \\[gnus-group-prev-unread-group]\t Go to the previous unread group
2428 \\[gnus-group-next-group]\t Go to the next group
2429 \\[gnus-group-prev-group]\t Go to the previous group
2430 \\[gnus-group-next-unread-group-same-level]\t Go to the next unread group on the same level
2431 \\[gnus-group-prev-unread-group-same-level]\t Go to the previous unread group un the same level
2432 \\[gnus-group-unsubscribe-current-group]\t (Un)subscribe to the current group
2433 \\[gnus-group-unsubscribe-group]\t (Un)subscribe to some group
2434 \\[gnus-group-catchup-current]\t Mark all unread articles in the current group as read
2435 \\[gnus-group-catchup-current-all]\t Mark all alrticles in the current group as read
2436 \\[gnus-group-list-groups]\t List groups that have unread articles
2437 \\[gnus-group-list-all-groups]\t List all groups
2438 \\[gnus-group-mail]\t Compose a mail
2439 \\[gnus-group-get-new-news]\t Look for new news
2440 \\[gnus-group-get-new-news-this-group]\t Look for new news for the current group
2441 \\[gnus-group-restart]\t Restart Gnus
2442 \\[gnus-group-save-newsrc]\t Save the startup file(s)
2443 \\[gnus-group-browse-foreign-server]\t Browse a foreign (NNTP) server
2444 \\[gnus-group-check-bogus-groups]\t Check for and remove bogus newsgroups
2445 \\[gnus-find-new-newsgroups]\t Find new newsgroups
2446 \\[gnus-group-describe-group]\t Describe the current newsgroup
2447 \\[gnus-group-describe-all-groups]\t Describe all newsgroups
2448 \\[gnus-group-post-news]\t Post an article to some newsgroup
2449 \\[gnus-group-add-group]\t Add a newsgroup entry
2450 \\[gnus-group-edit-group]\t Edit a newsgroup entry
2451 \\[gnus-group-make-directory-group]\t Read a directory as a newsgroups
2452 \\[gnus-group-edit-local-kill]\t Edit a local kill file
2453 \\[gnus-group-edit-global-kill]\t Edit the global kill file
2454 \\[gnus-group-kill-group]\t Kill the current newsgroup
2455 \\[gnus-group-yank-group]\t Yank a previously killed newsgroup
2456 \\[gnus-group-kill-region]\t Kill all newsgroups between point and mark
2457 \\[gnus-group-kill-all-zombies]\t Kill all zombie newsgroups
2458 \\[gnus-group-transpose-groups]\t Transpose two newsgroups
2459 \\[gnus-group-list-killed]\t List all killed newsgroups
2460 \\[gnus-group-list-zombies]\t List all zombie newsgroups
2461 \\[gnus-group-expire-articles]\t Expire the expirable articles in the current newsgroup
2462 \\[gnus-group-expire-all-groups]\t Expire expirable articles in all newsgroups
2463 \\[gnus-version]\t Display the current Gnus version
2464 \\[gnus-group-set-current-level]\t Set the level of the current newsgroup
2465 \\[gnus-group-suspend]\t Suspend Gnus
2466 \\[gnus-group-clear-dribble]\t Clear the dribble buffer
2467 \\[gnus-group-exit]\t Stop reading news
2468 \\[gnus-group-quit]\t Stop reading news without saving the startup files
2469 \\[gnus-group-describe-briefly]\t Give a brief description of the current mode
2470 \\[gnus-info-find-node]\t Find the info pages for Gnus
2473 (if gnus-visual (gnus-group-make-menu-bar))
2474 (kill-all-local-variables)
2475 (setq mode-line-modified "-- ")
2476 (make-local-variable 'mode-line-format)
2477 (setq mode-line-format (copy-sequence mode-line-format))
2478 (and (equal (nth 3 mode-line-format) " ")
2479 (setcar (nthcdr 3 mode-line-format) ""))
2480 (setq major-mode 'gnus-group-mode)
2481 (setq mode-name "Group")
2482 (gnus-group-set-mode-line)
2483 (setq mode-line-process nil)
2484 (use-local-map gnus-group-mode-map)
2485 (buffer-disable-undo (current-buffer))
2486 (setq truncate-lines t)
2487 (setq buffer-read-only t)
2488 (run-hooks 'gnus-group-mode-hook))
2490 (defun gnus-mouse-pick-group (e)
2493 (gnus-group-read-group nil))
2496 (defun gnus-no-server (&optional arg)
2498 If ARG is a positive number, Gnus will use that as the
2499 startup level. If ARG is nil, Gnus will be started at level 2.
2500 If ARG is non-nil and not a positive number, Gnus will
2501 prompt the user for the name of an NNTP server to use.
2502 As opposed to `gnus', this command will not connect to the local server."
2504 (gnus (or arg 2) t))
2506 (defalias '\(ding\) 'gnus)
2509 (defun gnus (&optional arg dont-connect)
2511 If ARG is non-nil and a positive number, Gnus will use that as the
2512 startup level. If ARG is non-nil and not a positive number, Gnus will
2513 prompt the user for the name of an NNTP server to use."
2515 (if (get-buffer gnus-group-buffer)
2517 (switch-to-buffer gnus-group-buffer)
2518 (gnus-group-get-new-news))
2520 (gnus-read-init-file)
2521 (let ((level (and arg (numberp arg) (> arg 0) arg)))
2524 (switch-to-buffer (get-buffer-create gnus-group-buffer))
2525 (gnus-add-current-to-buffer-list)
2527 (or dont-connect (gnus-start-news-server (and arg (not level)))))
2528 (if (and (not dont-connect)
2529 (not (gnus-server-opened gnus-select-method)))
2531 ;; NNTP server is successfully open.
2532 (gnus-update-format-specifications)
2533 (let ((buffer-read-only nil))
2535 (if (not gnus-inhibit-startup-message)
2537 (gnus-group-startup-message)
2539 (run-hooks 'gnus-startup-hook)
2540 (gnus-setup-news nil level)
2541 (and gnus-use-dribble-file (gnus-dribble-open))
2542 (or t (not gnus-novice-user)
2544 (gnus-group-describe-briefly)) ;Show brief help message.
2545 (gnus-group-list-groups (or level 5)))))))
2547 (defun gnus-group-startup-message (&optional x y)
2548 "Insert startup message in current buffer."
2549 ;; Insert the message.
2565 ;; And then hack it.
2566 ;; 18 is the longest line.
2567 (indent-rigidly (point-min) (point-max)
2568 (/ (max (- (window-width) (or x 22)) 0) 2))
2569 (goto-char (point-min))
2570 ;; +4 is fuzzy factor.
2571 (insert-char ?\n (/ (max (- (window-height) (or y 12)) 0) 2)))
2573 (defun gnus-group-setup-buffer ()
2574 (or (get-buffer gnus-group-buffer)
2576 (switch-to-buffer (get-buffer-create gnus-group-buffer))
2577 (gnus-add-current-to-buffer-list)
2578 (gnus-group-mode))))
2580 (defun gnus-group-list-groups (level &optional unread)
2581 "List newsgroups with level LEVEL or lower that have unread alticles.
2582 Default is 5, which lists all subscribed groups.
2583 If argument UNREAD is non-nil, groups with no unread articles are also listed."
2585 (setq level (or level 5))
2586 (gnus-group-setup-buffer) ;May call from out of group buffer
2587 (let ((case-fold-search nil)
2588 (group (gnus-group-group-name)))
2589 (funcall gnus-group-prepare-function level unread nil)
2590 (if (zerop (buffer-size))
2591 ;; Suggested by Andrew Eskilsson <pi92ae@lelle.pt.hk-r.se>.
2592 (message "No news is horrible news")
2593 (goto-char (point-min))
2595 ;; Go to the first group with unread articles.
2596 (gnus-group-search-forward nil nil nil t)
2597 ;; Find the right group to put point on. If the current group
2598 ;; has disapeared in the new listing, try to find the next
2599 ;; one. If no next one can be found, just leave point at the
2600 ;; first newsgroup in the buffer.
2601 (if (not (gnus-goto-char
2602 (text-property-any (point-min) (point-max)
2603 'gnus-group (intern group))))
2604 (let ((newsrc (nthcdr 3 (gnus-gethash group gnus-newsrc-hashtb))))
2606 (not (gnus-goto-char
2608 (point-min) (point-max) 'gnus-group
2610 (setq newsrc (cdr newsrc))))))
2611 ;; Adjust cursor point.
2612 (gnus-group-position-cursor))))
2614 (defun gnus-group-prepare-flat (level &optional all lowest)
2615 "List all newsgroups with unread articles of level LEVEL or lower.
2616 If ALL is non-nil, list groups that have no unread articles.
2617 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher."
2618 (set-buffer gnus-group-buffer)
2619 (let ((buffer-read-only nil)
2620 (newsrc (cdr gnus-newsrc-assoc))
2621 (lowest (or lowest 1))
2622 info clevel unread group)
2625 ;; List living groups.
2627 (setq info (car newsrc)
2630 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
2631 (and unread ; This group might be bogus
2632 (<= (setq clevel (car (cdr info))) level)
2634 (or all ; We list all groups?
2635 (eq unread t) ; We list unactivated groups
2636 (> unread 0) ; We list groups with unread articles
2637 (cdr (assq 'tick (nth 3 info)))) ; And groups with tickeds
2638 (gnus-group-insert-group-line
2639 nil group (car (cdr info)) (nth 3 info) unread (nth 4 info)))))
2641 ;; List dead groups.
2642 (and (>= level 8) (<= lowest 8)
2643 (gnus-group-prepare-flat-list-dead gnus-zombie-list 8 ?Z))
2644 (and (>= level 9) (<= lowest 9)
2645 (gnus-group-prepare-flat-list-dead gnus-killed-list 9 ?K))
2647 (gnus-group-set-mode-line)
2648 (setq gnus-have-all-newsgroups all)
2649 (run-hooks 'gnus-group-prepare-hook)))
2651 (defun gnus-group-prepare-flat-list-dead (groups level mark)
2652 ;; List zombies and killed lists somehwat faster, which was
2653 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
2654 ;; this by ignoring the group format specification altogether.
2657 (setq group (car groups)
2658 groups (cdr groups))
2660 (insert (format " %c *: %s\n" mark group))
2661 (add-text-properties
2663 (list 'gnus-group (intern group)
2665 'gnus-level level)))))
2667 (defun gnus-group-real-name (group)
2668 "Find the real name of a foreign newsgroup."
2669 (if (string-match "^[^:]+:" group)
2670 (substring group (match-end 0))
2673 (defun gnus-group-prefixed-name (group method)
2674 "Return the whole name from GROUP and METHOD."
2675 (concat (format "%s" (car method))
2676 (if (assoc (format "%s" (car method)) (gnus-methods-using 'address))
2677 (concat "+" (nth 1 method)))
2680 (defun gnus-group-real-prefix (group)
2681 "Return the prefix of the current group name."
2682 (if (string-match "^[^:]+:" group)
2683 (substring group 0 (match-end 0))
2686 (defun gnus-group-method-name (group)
2687 "Return the method used for selecting GROUP."
2688 (let ((prefix (gnus-group-real-prefix group)))
2689 (if (equal prefix "")
2691 (if (string-match "^[^\\+]+\\+" prefix)
2692 (list (intern (substring prefix 0 (1- (match-end 0))))
2693 (substring prefix (match-end 0) (1- (length prefix))))
2694 (list (intern (substring prefix 0 (1- (length prefix)))) "")))))
2696 (defun gnus-group-foreign-p (group)
2697 "Return nil if GROUP is native, non-nil if it is foreign."
2698 (string-match ":" group))
2700 (defun gnus-group-set-info (info)
2701 (let ((entry (gnus-gethash (car info) gnus-newsrc-hashtb)))
2704 (setcar (nthcdr 2 entry) info)
2705 (if (and (not (eq (car entry) t))
2706 (gnus-gethash (car info) gnus-active-hashtb))
2707 (let ((marked (nth 3 info)))
2709 (max 0 (- (length (gnus-list-of-unread-articles
2711 (length (cdr (assq 'tick marked)))
2712 (length (cdr (assq 'dormant marked)))))))))
2713 (error "No such group: %s" (car info)))))
2715 (defun gnus-group-update-group-line ()
2716 "This function updates the current line in the newsgroup buffer and
2717 moves the point to the colon."
2718 (let* ((buffer-read-only nil)
2719 (group (gnus-group-group-name))
2720 (entry (and group (gnus-gethash group gnus-newsrc-hashtb))))
2723 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
2726 (delete-region (point) (save-excursion (forward-line 1) (point)))
2727 (gnus-group-insert-group-line-info group)
2729 (gnus-group-position-cursor)))
2731 (defun gnus-group-insert-group-line-info (group)
2732 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
2736 (setq info (nth 2 entry))
2737 (gnus-group-insert-group-line
2738 nil group (nth 1 info) (nth 3 info) (car entry) (nth 4 info)))
2739 (setq active (gnus-gethash group gnus-active-hashtb))
2740 (gnus-group-insert-group-line
2741 nil group (if (member group gnus-zombie-list) 8 9)
2742 nil (- (1+ (cdr active)) (car active)) nil))))
2744 (defun gnus-group-insert-group-line (gformat group level marked number method)
2745 (let* ((gformat (or gformat gnus-group-line-format-spec))
2746 (active (gnus-gethash group gnus-active-hashtb))
2747 (number-total (if active (1+ (- (cdr active) (car active))) 0))
2748 (number-of-dormant (length (cdr (assq 'dormant marked))))
2749 (number-of-ticked (length (cdr (assq 'tick marked))))
2750 (number-of-ticked-and-dormant
2751 (+ number-of-ticked number-of-dormant))
2752 (number-of-unread-unticked
2753 (if (numberp number) (int-to-string (max 0 number))
2756 (if (numberp number)
2757 (max 0 (- number-total number))
2759 (subscribed (cond ((< level 6) ? )
2763 (qualified-group (gnus-group-real-name group))
2764 (newsgroup-description
2765 (if gnus-description-hashtb
2766 (or (gnus-gethash group gnus-description-hashtb) "")
2768 (moderated (if (member group gnus-moderated-list) ?m ? ))
2769 (moderated-string (if (eq moderated ?m) "(m)" ""))
2770 (news-server (or (car (cdr method)) ""))
2771 (news-method (or (car method) ""))
2773 (if method (format "(%s:%s)" (car method) (car (cdr method))) ""))
2777 (> number-of-ticked 0))
2779 (number (if (eq number t) "*" (+ number number-of-dormant
2781 (buffer-read-only nil)
2785 ;; Insert the visible text.
2786 (insert-before-markers (eval gformat))
2787 (add-text-properties
2788 b (1+ b) (list 'gnus-group (intern group)
2789 'gnus-unread (if (numberp number)
2790 (string-to-int number-of-unread-unticked)
2793 'gnus-level level))))
2795 (defun gnus-group-update-group (group &optional visible-only)
2796 "Update newsgroup info of GROUP.
2797 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't already."
2799 (set-buffer gnus-group-buffer)
2800 (let ((buffer-read-only nil)
2802 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
2805 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
2807 ;; Buffer may be narrowed.
2810 ;; Search a line to modify. If the buffer is large, the search
2811 ;; takes long time. In most cases, current point is on the line
2812 ;; we are looking for. So, first of all, check current line.
2815 (eq (get-text-property (point) 'gnus-group)
2820 (point-min) (point-max) 'gnus-group (intern group)))))
2821 ;; GROUP is listed in current buffer. So, delete old line.
2825 (delete-region (point) (progn (forward-line 1) (point))))
2826 ;; No such line in the buffer, find out where it's supposed to
2827 ;; go, and insert it there (or at the end of the buffer).
2828 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>.
2830 (let ((entry (cdr (gnus-gethash group gnus-newsrc-hashtb))))
2835 (point-min) (point-max)
2836 'gnus-group (intern (car (car entry)))))))
2837 (setq entry (cdr entry)))
2838 (or entry (goto-char (point-max))))))
2839 (if (or visible (not visible-only))
2841 (gnus-group-insert-group-line-info group)
2842 (forward-line -1) ; Move point back to the inserted line.
2844 (gnus-group-set-mode-line)))
2846 (defun gnus-group-set-mode-line ()
2847 (if (memq 'group gnus-updated-mode-lines)
2848 (let* ((gformat (or gnus-group-mode-line-format-spec
2849 (setq gnus-group-mode-line-format-spec
2851 gnus-group-mode-line-format
2852 gnus-group-mode-line-format-alist))))
2853 (news-server (car (cdr gnus-select-method)))
2854 (news-method (car gnus-select-method))
2855 (mode-string (eval gformat))
2857 (if (> (length mode-string) max-len)
2858 (setq mode-string (substring mode-string 0 (- max-len 4))))
2859 (setq mode-line-buffer-identification mode-string)
2860 (set-buffer-modified-p t))))
2862 (defun gnus-group-group-name ()
2863 "Get the name of the newsgroup on the current line."
2864 (let ((group (get-text-property
2865 (save-excursion (beginning-of-line) (point)) 'gnus-group)))
2866 (and group (symbol-name group))))
2868 (defun gnus-group-group-level ()
2869 "Get the level of the newsgroup on the current line."
2870 (get-text-property (save-excursion (beginning-of-line) (point)) 'gnus-level))
2872 (defun gnus-group-search-forward (&optional backward all level first-too)
2873 "Find the next newsgroup with unread articles.
2874 If BACKWARD is non-nil, find the previous newsgroup instead.
2875 If ALL is non-nil, just find any newsgroup.
2876 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
2878 If FIRST-TOO, the current line is also eligeble as a target."
2879 (let ((way (if backward -1 1))
2883 (or first-too (forward-line way))
2891 (get-text-property (point) 'gnus-unread)))
2892 (or (eq unread t) (and unread (> unread 0))))
2893 (> 5 (get-text-property (point) 'gnus-level))))
2895 (let ((lev (get-text-property (point) 'gnus-level)))
2901 (setq pos (point))))
2903 (zerop (forward-line way))))
2905 (progn (gnus-group-position-cursor) t)
2906 (if pos (goto-char pos) (goto-char beg))
2909 ;; Gnus group mode commands
2911 (defun gnus-group-read-group (all &optional no-article group)
2912 "Read news in this newsgroup.
2913 If argument ALL is non-nil, already read articles become readable.
2914 If optional argument NO-ARTICLE is non-nil, no article body is displayed."
2916 (let ((group (or group (gnus-group-group-name)))
2917 number active marked entry)
2918 (or group (error "No group on current line"))
2920 (nth 3 (nth 2 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))))
2921 ;; This group might be a dead group. In that case we have to get
2922 ;; the number of unread articles from `gnus-active-hashtb'.
2924 (setq number (car entry))
2925 (if (setq active (gnus-gethash group gnus-active-hashtb))
2926 (setq number (- (1+ (cdr active)) (car active)))))
2927 (gnus-summary-read-group
2928 group (or all (and (numberp number)
2929 (zerop (+ number (length (cdr (assq 'tick marked)))
2930 (length (cdr (assq 'dormant marked)))))))
2933 (defun gnus-group-select-group (all)
2934 "Select this newsgroup.
2935 No article is selected automatically.
2936 If argument ALL is non-nil, already read articles become readable."
2938 (gnus-group-read-group all t))
2940 (defun gnus-group-jump-to-group (group)
2941 "Jump to newsgroup GROUP."
2944 (completing-read "Group: " gnus-active-hashtb nil t)))
2946 ;; Either go to the line in the group buffer...
2947 (or (and (setq b (text-property-any (point-min) (point-max)
2948 'gnus-group (intern group)))
2950 ;; ... or insert the line.
2951 (progn (gnus-group-update-group group)
2952 (goto-char (text-property-any (point-min) (point-max)
2953 'gnus-group (intern group))))))
2954 ;; Adjust cursor point.
2955 (gnus-group-position-cursor))
2957 (defun gnus-group-next-group (n)
2958 "Go to next N'th newsgroup.
2959 If N is negative, search backward instead.
2960 Returns the difference between N and the number of skips actually
2963 (gnus-group-next-unread-group n t))
2965 (defun gnus-group-next-unread-group (n &optional all level)
2966 "Go to next N'th unread newsgroup.
2967 If N is negative, search backward instead.
2968 If ALL is non-nil, choose any newsgroup, unread or not.
2969 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
2970 such group can be found, the next group with a level higher than
2972 Returns the difference between N and the number of skips actually
2975 (let ((backward (< n 0))
2978 (gnus-group-search-forward backward all level))
2980 (if (/= 0 n) (message "No more%s newsgroups%s" (if all "" " unread")
2981 (if level " on this level or higher" "")))
2984 (defun gnus-group-prev-group (n)
2985 "Go to previous N'th newsgroup.
2986 Returns the difference between N and the number of skips actually
2989 (gnus-group-next-unread-group (- n) t))
2991 (defun gnus-group-prev-unread-group (n)
2992 "Go to previous N'th unread newsgroup.
2993 Returns the difference between N and the number of skips actually
2996 (gnus-group-next-unread-group (- n)))
2998 (defun gnus-group-next-unread-group-same-level (n)
2999 "Go to next N'th unread newsgroup on the same level.
3000 If N is negative, search backward instead.
3001 Returns the difference between N and the number of skips actually
3004 (gnus-group-next-unread-group n t (gnus-group-group-level))
3005 (gnus-group-position-cursor))
3007 (defun gnus-group-prev-unread-group-same-level (n)
3008 "Go to next N'th unread newsgroup on the same level.
3009 Returns the difference between N and the number of skips actually
3012 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
3013 (gnus-group-position-cursor))
3015 (defun gnus-group-best-unread-group ()
3016 "Go to the group with the highest level."
3018 (goto-char (point-min))
3021 (while (setq unread (get-text-property (point) 'gnus-unread))
3022 (if (and (numberp unread) (> unread 0))
3024 (or best-point (setq best-point (point)))
3025 (if (< (get-text-property (point) 'gnus-level) best)
3027 (setq best (get-text-property (point) 'gnus-level))
3028 (setq best-point (point))))))
3030 (if best-point (goto-char best-point))
3031 (gnus-summary-position-cursor)
3032 (and best-point (gnus-group-group-name))))
3034 (defun gnus-group-add-group (name method address)
3035 "Add a new newsgroup.
3036 The user will be prompted for a NAME, for a select METHOD, and an
3040 (read-string "Group name: ")
3041 (completing-read (format "%s method: " name)
3042 gnus-valid-select-methods nil t)
3043 (read-string (format "Get %s by method %s from: " name method))))
3044 (let ((nname (gnus-group-prefixed-name name (list (intern method) address))))
3045 (gnus-group-change-level
3046 (list t nname 3 nil nil (list (intern method) address))
3047 3 9 (gnus-gethash (or (gnus-group-group-name) "dummy.group")
3048 gnus-newsrc-hashtb) t)
3049 (gnus-group-insert-group-line-info nname)))
3051 (defun gnus-group-edit-group ()
3053 (let ((group (gnus-group-group-name))
3055 (if group (setq info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
3056 (error "No group on current line"))
3057 (switch-to-buffer (get-buffer-create gnus-group-edit-buffer))
3058 (gnus-add-current-to-buffer-list)
3060 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3061 (use-local-map (copy-keymap emacs-lisp-mode-map))
3062 (local-set-key "\C-c\C-c" 'gnus-group-edit-group-done)
3064 (insert ";; Type `C-c C-c' after you have edited the newsgroup entry.\n\n")
3065 (insert (format "(gnus-group-set-info\n '%S)\n" info))))
3067 (defun gnus-group-edit-group-done ()
3069 (set-buffer (get-buffer-create gnus-group-edit-buffer))
3070 (eval-current-buffer)
3071 (kill-buffer (current-buffer))
3072 (set-buffer gnus-group-buffer)
3073 (gnus-group-update-group (gnus-group-group-name))
3074 (gnus-group-position-cursor))
3076 (defun gnus-group-make-doc-group ()
3077 "Create the (ding) Gnus documentation group."
3079 (let ((path load-path))
3081 (not (file-exists-p (concat (file-name-as-directory (car path))
3083 (setq path (cdr path)))
3084 (or path (error "Couldn't find doc group"))
3085 (gnus-group-add-group
3087 (concat (file-name-as-directory (car path)) "doc.txt"))))
3089 (defun gnus-group-make-directory-group (dir)
3090 "Create an nndir group.
3091 The user will be prompted for a directory. The contents of this
3092 directory will be used as a newsgroup. The directory should contain
3093 mail messages or news articles in files that have numeric names."
3095 (list (read-file-name "Create group from directory: ")))
3096 (or (file-exists-p dir) (error "No such directory"))
3097 (or (file-directory-p dir) (error "Not a directory"))
3098 (gnus-group-add-group dir "nndir" dir))
3100 (defun gnus-group-catchup-current (n &optional all)
3101 "Mark all articles not marked as unread in current newsgroup as read.
3102 If prefix argument N is numeric, the ARG next newsgroups will be
3103 caught up. If ALL is non-nil, marked articles will also be marked as
3104 read. Cross references (Xref: header) of articles are ignored.
3105 The difference between N and actual number of newsgroups that were
3106 caught up is returned."
3108 (if (or (not gnus-interactive-catchup) ;Without confirmation?
3112 "Do you really want to mark all articles as read? "
3113 "Mark all unread articles as read? ")))
3119 (gnus-group-catchup (gnus-group-group-name) all)
3120 (gnus-group-update-group-line)
3122 (zerop (gnus-group-next-unread-group 1))))))
3125 (defun gnus-group-catchup-current-all (n)
3126 "Mark all articles in current newsgroup as read.
3127 Cross references (Xref: header) of articles are ignored."
3129 (gnus-group-catchup-current n 'all))
3131 (defun gnus-group-catchup (group &optional all)
3132 "Mark all articles in GROUP as read.
3133 If ALL is non-nil, all articles are marked as read.
3134 The return value is the number of articles that were marked as read,
3135 or nil if no action could be taken."
3136 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3138 (marked (nth 3 (nth 2 entry)))
3140 (if (not (numberp (car entry)))
3141 (message "Can't catch up; non-active group")
3142 ;; Do the updating only if the newsgroup isn't killed
3145 (setq ticked (if all nil (cdr (assq 'tick marked))))
3146 (gnus-update-read-articles group ticked nil ticked)
3147 (if (and all marked)
3148 (setcar (nthcdr 3 (nth 2 entry))
3149 (delq (assq 'dormant marked) marked))))))
3152 (defun gnus-group-expire-articles (newsgroup)
3153 "Expire all expirable articles in the current newsgroup."
3154 (interactive (list (gnus-group-group-name)))
3155 (if (not newsgroup) (error "No current newsgroup"))
3157 (assq 'expire (nth 3 (nth 2 (gnus-gethash newsgroup
3158 gnus-newsrc-hashtb))))))
3160 (gnus-check-backend-function 'request-expire-articles newsgroup)
3162 (gnus-request-expire-articles (cdr expirable) newsgroup)))))
3164 (defun gnus-group-expire-all-groups ()
3165 "Expire all expirable articles in all newsgroups."
3167 (message "Expiring...")
3168 (let ((newsrc (cdr gnus-newsrc-assoc)))
3170 (gnus-group-expire-articles (car (car newsrc)))
3171 (setq newsrc (cdr newsrc))))
3172 (message "Expiring...done"))
3174 (defun gnus-group-set-current-level (n)
3175 "Set the level of the current group to the numeric prefix."
3177 (setq n (or n (string-to-int
3180 (mapcar (lambda (n) (list (char-to-string n))) "123456789")
3182 (let ((group (gnus-group-group-name)))
3183 (if (not group) (error "No newsgroup on current line.")
3184 (if (and (numberp n) (>= n 1) (<= n 9))
3186 (message "Changed level of %s from %d to %d"
3187 group (gnus-group-group-level) n)
3188 (gnus-group-change-level group n (gnus-group-group-level))
3189 (gnus-group-update-group-line))
3190 (error "Illegal level: %s" n))))
3192 (gnus-group-position-cursor))
3194 (defun gnus-group-unsubscribe-current-group (arg)
3195 "Toggle subscribe from/to unsubscribe current group."
3197 (let ((group (gnus-group-group-name)))
3198 (or group (error "No newsgroup on current line"))
3199 (or arg (setq arg (if (<= (gnus-group-group-level) 5) 6 3)))
3200 (gnus-group-unsubscribe-group group arg)))
3202 (defun gnus-group-unsubscribe-group (group &optional level)
3203 "Toggle subscribe from/to unsubscribe GROUP.
3204 New newsgroup is added to .newsrc automatically."
3206 (list (completing-read "Group: " gnus-active-hashtb nil
3207 gnus-have-read-active-file)))
3208 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
3210 ;; Toggle subscription flag.
3211 (gnus-group-change-level
3212 newsrc (if level level (if (< (nth 1 (nth 2 newsrc)) 6) 6 4)))
3213 (gnus-group-update-group group))
3214 ((and (stringp group)
3215 (gnus-gethash group gnus-active-hashtb))
3216 ;; Add new newsgroup.
3217 (gnus-group-change-level
3220 (if (member group gnus-zombie-list) 8 9)
3221 (or (and (gnus-group-group-name)
3222 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb))
3223 (gnus-gethash (car (car gnus-newsrc-assoc))
3224 gnus-newsrc-hashtb)))
3225 (gnus-group-update-group group))
3226 (t (error "No such newsgroup: %s" group)))
3227 (gnus-group-position-cursor)))
3229 (defun gnus-group-transpose-groups (arg)
3230 "Exchange current newsgroup and previous newsgroup.
3231 With argument ARG, takes previous newsgroup and moves it past ARG newsgroup."
3233 ;; BUG: last newsgroup and the last but one cannot be transposed
3234 ;; since gnus-group-search-forward does not move forward beyond the
3235 ;; last. If we instead use forward-line, no problem, but I don't
3236 ;; want to use it for later extension.
3238 (gnus-group-search-forward t t)
3239 (gnus-group-kill-group 1)
3240 (gnus-group-search-forward nil t)
3241 (gnus-group-yank-group)
3242 (gnus-group-search-forward nil t)
3243 (setq arg (1- arg))))
3245 (defun gnus-group-kill-all-zombies ()
3246 "Kill all zombie newsgroups."
3248 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
3249 (setq gnus-zombie-list nil)
3250 (funcall gnus-group-prepare-function 5 nil nil)
3251 (goto-char (point-min))
3252 (gnus-group-position-cursor))
3254 (defun gnus-group-kill-region (begin end)
3255 "Kill newsgroups in current region (excluding current point).
3256 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
3259 ;; Exclude a line where current point is on.
3273 (beginning-of-line) ;Important when LINES < 1
3274 (gnus-group-kill-group lines)))
3276 (defun gnus-group-kill-group (n)
3277 "The the next N groups.
3278 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
3279 However, only groups that were alive can be yanked; already killed
3280 groups or zombie groups can't be yanked.
3281 The return value is the name of the (last) newsgroup that was killed."
3283 (let ((buffer-read-only nil)
3285 (while (>= (setq n (1- n)) 0)
3286 (setq group (gnus-group-group-name))
3288 (signal 'end-of-buffer nil))
3289 (setq level (gnus-group-group-level))
3291 (delete-region (point) (progn (forward-line 1) (point)))
3292 (if (setq entry (gnus-gethash group gnus-newsrc-hashtb))
3293 (setq gnus-list-of-killed-groups
3294 (cons (cons (car entry) (nth 2 entry))
3295 gnus-list-of-killed-groups)))
3296 (gnus-group-change-level (if entry entry group) 9 (if entry nil level)))
3299 (gnus-group-position-cursor)
3302 (defun gnus-group-yank-group (&optional arg)
3303 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
3304 inserting it before the current newsgroup. The numeric ARG specifies
3305 how many newsgroups are to be yanked. The name of the (last)
3306 newsgroup yanked is returned."
3308 (if (not arg) (setq arg 1))
3309 (let (info group prev)
3310 (while (>= (setq arg (1- arg)) 0)
3311 (if (not (setq info (car gnus-list-of-killed-groups)))
3312 (error "No more newsgroups to yank"))
3313 (setq group (nth 2 info))
3314 ;; Find which newsgroup to insert this one before - search
3315 ;; backward until something suitable is found. If there are no
3316 ;; other newsgroups in this buffer, just make this newsgroup the
3318 (while (and (not (setq prev (gnus-group-group-name)))
3319 (zerop (forward-line -1))))
3321 (setq prev (car (car gnus-newsrc-assoc))))
3322 (gnus-group-change-level
3324 (gnus-gethash prev gnus-newsrc-hashtb)
3326 (gnus-group-insert-group-line-info (nth 1 info))
3327 (setq gnus-list-of-killed-groups
3328 (cdr gnus-list-of-killed-groups)))
3330 (gnus-group-position-cursor)
3333 (defun gnus-group-list-all-groups (arg)
3334 "List all newsgroups with level ARG or lower.
3335 Default is 7, which lists all subscribed and most unsubscribed groups."
3337 (setq arg (or arg 7))
3338 (gnus-group-list-groups arg t))
3340 (defun gnus-group-list-killed ()
3341 "List all killed newsgroups in the group buffer."
3343 (if (not gnus-killed-list)
3344 (message "No killed groups")
3345 (funcall gnus-group-prepare-function 9 t 9)
3346 (goto-char (point-min)))
3347 (gnus-group-position-cursor))
3349 (defun gnus-group-list-zombies ()
3350 "List all zombie newsgroups in the group buffer."
3352 (if (not gnus-zombie-list)
3353 (message "No zombie groups")
3354 (funcall gnus-group-prepare-function 8 t 8)
3355 (goto-char (point-min)))
3356 (gnus-group-position-cursor))
3358 (defun gnus-group-get-new-news (&optional arg)
3359 "Get newly arrived articles.
3360 If ARG is non-nil, it should be a number between one and nine to
3361 specify which levels you are interested in re-scanning."
3363 (if (and gnus-read-active-file (not arg))
3365 (gnus-read-active-file)
3366 (gnus-get-unread-articles (or arg 6)))
3367 (let ((gnus-read-active-file nil))
3368 (gnus-get-unread-articles (or arg 6))))
3369 (gnus-group-list-groups 5 gnus-have-all-newsgroups))
3371 (defun gnus-group-get-new-news-this-group (n)
3372 "Check for newly arrived news in the current group (and the N-1 next groups).
3373 The difference between N and the number of newsgroup checked is returned.
3374 If N is negative, this group and the N-1 previous groups will be checked."
3376 (let ((way (if (< n 0) -1 1))
3378 (w-p (window-start))
3381 (gnus-get-new-news-in-group (gnus-group-group-name))
3382 (zerop (gnus-group-next-group way)))
3384 (if (/= 0 n) (message "No more newsgroups"))
3385 ;; !!! I don't know why the buffer scrolls forward when updating
3386 ;; the first line in the group buffer, but it does. So we set the
3387 ;; window start forcibly.
3388 (set-window-start (get-buffer-window (current-buffer)) w-p)
3391 (defun gnus-get-new-news-in-group (group)
3392 (if (and group (gnus-activate-newsgroup group))
3394 (gnus-get-unread-articles-in-group
3395 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))
3396 (gnus-gethash group gnus-active-hashtb))
3397 (gnus-group-update-group-line)))
3400 (defun gnus-group-describe-group (&optional group)
3401 "Display a description of the current newsgroup."
3403 (let ((group (or group (gnus-group-group-name))))
3405 (message "No group on current line")
3406 (and (or gnus-description-hashtb
3407 (gnus-read-descriptions-file))
3409 (or (gnus-gethash group gnus-description-hashtb)
3410 "No description available"))))))
3412 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3413 (defun gnus-group-describe-all-groups ()
3414 "Pop up a buffer with descriptons of all newsgroups."
3416 (if (not (or gnus-description-hashtb
3417 (gnus-read-descriptions-file)))
3418 (error "Couldn't request descriptions file"))
3419 (let ((buffer-read-only nil)
3425 (insert (format " *: %-20s %s\n" (symbol-name group)
3426 (symbol-value group)))
3427 (add-text-properties
3428 b (1+ b) (list 'gnus-group group
3429 'gnus-unread t 'gnus-marked nil 'gnus-level 6)))
3430 gnus-description-hashtb)
3431 (goto-char (point-min))
3432 (gnus-group-position-cursor)))
3434 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
3435 (defun gnus-group-apropos (regexp &optional search-description)
3436 "List all newsgroups that have names that match a regexp."
3437 (interactive "sGnus apropos (regexp): ")
3439 (obuf (current-buffer))
3441 ;; Go through all newsgroups that are known to Gnus.
3444 (and (string-match regexp (symbol-name group))
3445 (setq groups (cons (symbol-name group) groups))))
3447 ;; Go through all descriptions that are known to Gnus.
3448 (if search-description
3451 (and (string-match regexp (symbol-value group))
3452 (gnus-gethash (symbol-name group) gnus-active-hashtb)
3453 (setq groups (cons (symbol-name group) groups))))
3454 gnus-description-hashtb))
3456 (message "No groups matched \"%s\"." regexp)
3457 ;; Print out all the groups.
3459 (pop-to-buffer (get-buffer-create "*Gnus Help*"))
3460 (buffer-disable-undo (current-buffer))
3462 (setq groups (sort groups 'string<))
3464 ;; Groups may be entered twice into the list of groups.
3465 (if (not (string= (car groups) prev))
3467 (insert (setq prev (car groups)) "\n")
3468 (if (and gnus-description-hashtb
3469 (setq des (gnus-gethash (car groups)
3470 gnus-description-hashtb)))
3471 (insert " " des "\n"))))
3472 (setq groups (cdr groups)))
3474 (pop-to-buffer obuf)))
3476 (defun gnus-group-description-apropos (regexp)
3477 "List all newsgroups that have names or desccriptions that match a regexp."
3478 (interactive "sGnus description apropos (regexp): ")
3479 (if (not (or gnus-description-hashtb
3480 (gnus-read-descriptions-file)))
3481 (error "Couldn't request descriptions file"))
3482 (gnus-group-apropos regexp t))
3484 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
3485 (defun gnus-group-list-matching (regexp)
3486 "List all newsgroups with unread articles that match REGEXP."
3487 (interactive "sList newsgroups matching: ")
3488 (set-buffer gnus-group-buffer)
3489 (let ((buffer-read-only nil)
3490 (newsrc (cdr gnus-newsrc-assoc))
3491 (zombie gnus-zombie-list)
3492 (killed gnus-killed-list)
3493 info unread active group)
3496 ;; List alive newsgroups.
3498 (setq info (car newsrc)
3501 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
3502 (if (and unread ; This group might be bogus
3503 (string-match regexp group))
3504 (gnus-group-insert-group-line
3505 nil group (car (cdr info)) (nth 3 info) unread
3508 ;; List zombies and killed lists.
3509 (let ((lists (list 'gnus-zombie-list 'gnus-killed-list))
3512 (if (eq (car lists) 'gnus-zombie-list)
3515 (setq newsrc (set (car lists)
3516 (sort (symbol-value (car lists))
3517 (function string<))))
3519 (setq group (car newsrc)
3520 newsrc (cdr newsrc))
3521 (if (not (string-match regexp group))
3524 (insert (format " %c *: %s" mark group))
3525 (add-text-properties
3527 (list 'gnus-group (intern group)
3529 'gnus-level (if (= mark ?Z) 8 9)))))
3530 (setq lists (cdr lists))))
3532 (gnus-group-set-mode-line)
3533 (setq gnus-have-all-newsgroups t)
3534 (run-hooks 'gnus-group-prepare-hook))
3535 (goto-char (point-min))
3536 (gnus-group-position-cursor))
3538 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
3539 (defun gnus-group-save-newsrc ()
3540 "Save the Gnus startup files."
3542 (gnus-save-newsrc-file))
3544 (defun gnus-group-restart (&optional arg)
3545 "Force Gnus to read the .newsrc file."
3547 (gnus-save-newsrc-file)
3548 (gnus-setup-news 'force)
3549 (gnus-group-list-groups (or arg 5) gnus-have-all-newsgroups))
3551 (defun gnus-group-read-init-file ()
3552 "Read the Gnus elisp init file."
3554 (gnus-read-init-file))
3556 (defun gnus-group-check-bogus-groups ()
3557 "Check bogus newsgroups."
3559 (gnus-check-bogus-newsgroups (not gnus-expert-user)) ;Require confirmation.
3560 (gnus-group-list-groups 5 gnus-have-all-newsgroups))
3562 (defun gnus-group-mail ()
3563 "Start composing a mail."
3567 (defun gnus-group-edit-global-kill ()
3568 "Edit a global kill file."
3570 (setq gnus-current-kill-article nil) ;No articles selected.
3571 (gnus-kill-file-edit-file nil) ;Nil stands for global KILL file.
3573 (substitute-command-keys
3574 "Editing a global kill file (Type \\[gnus-kill-file-exit] to exit)")))
3576 (defun gnus-group-edit-local-kill ()
3577 "Edit a local kill file."
3579 (setq gnus-current-kill-article nil) ;No articles selected.
3580 (gnus-kill-file-edit-file (gnus-group-group-name))
3582 (substitute-command-keys
3583 "Editing a local kill file (Type \\[gnus-kill-file-exit] to exit)")))
3585 (defun gnus-group-force-update ()
3586 "Update `.newsrc' file."
3588 (gnus-save-newsrc-file))
3590 (defun gnus-group-suspend ()
3591 "Suspend the current Gnus session.
3592 In fact, cleanup buffers except for group mode buffer.
3593 The hook gnus-suspend-gnus-hook is called before actually suspending."
3595 (run-hooks 'gnus-suspend-gnus-hook)
3596 ;; Kill Gnus buffers except for group mode buffer.
3597 (let ((group-buf (get-buffer gnus-group-buffer)))
3598 (while gnus-buffer-list
3599 (and (not (eq (get-buffer (car gnus-buffer-list)) group-buf))
3600 (get-buffer (car gnus-buffer-list))
3601 (buffer-name (get-buffer (car gnus-buffer-list)))
3602 (kill-buffer (car gnus-buffer-list)))
3603 (setq gnus-buffer-list (cdr gnus-buffer-list)))
3604 (setq gnus-buffer-list (list group-buf))
3605 (bury-buffer group-buf)
3606 (delete-windows-on group-buf t)))
3608 (defun gnus-group-clear-dribble ()
3609 "Clear all information from the dribble buffer."
3611 (gnus-dribble-clear))
3613 (defun gnus-group-exit ()
3614 "Quit reading news after updating .newsrc.eld and .newsrc.
3615 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3617 (if (or noninteractive ;For gnus-batch-kill
3618 (zerop (buffer-size)) ;No news is good news.
3619 (not (gnus-server-opened gnus-select-method)) ;NNTP connection closed
3620 (not gnus-interactive-exit) ;Without confirmation
3622 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
3624 (run-hooks 'gnus-exit-gnus-hook)
3625 (gnus-save-newsrc-file)
3626 (gnus-clear-system))))
3628 (defun gnus-group-quit ()
3629 "Quit reading news without updating .newsrc.eld or .newsrc.
3630 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3632 (if (or noninteractive ;For gnus-batch-kill
3633 (zerop (buffer-size))
3634 (not (gnus-server-opened gnus-select-method))
3636 (not gnus-current-startup-file)
3638 (format "Quit reading news without saving %s? "
3639 (file-name-nondirectory gnus-current-startup-file))))
3641 (run-hooks 'gnus-exit-gnus-hook)
3643 (gnus-clear-system))))
3645 (defun gnus-group-describe-briefly ()
3646 "Give a one line description of the group mode commands."
3649 (substitute-command-keys "\\<gnus-group-mode-map>\\[gnus-group-read-group]:Select \\[gnus-group-next-unread-group]:Forward \\[gnus-group-prev-unread-group]:Backward \\[gnus-group-exit]:Exit \\[gnus-info-find-node]:Run Info \\[gnus-group-describe-briefly]:This help")))
3651 (defun gnus-group-browse-foreign-server (method)
3652 "Browse a foreign news server.
3653 If called interactively, this function will ask for a select method
3654 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
3655 If not, METHOD should be a list where the first element is the method
3656 and the second element is the address."
3658 (list (list (intern (completing-read
3660 gnus-valid-select-methods nil t "nntp"))
3661 ;; Suggested by mapjph@bath.ac.uk.
3664 (mapcar (lambda (server) (list server))
3665 gnus-secondary-servers)))))
3666 (gnus-browse-foreign-server method))
3670 ;;; Browse Server Mode
3673 (defvar gnus-browse-server-mode-hook nil)
3674 (defvar gnus-browse-server-mode-map nil)
3676 (if gnus-browse-server-mode-map
3678 (setq gnus-browse-server-mode-map (make-keymap))
3679 (suppress-keymap gnus-browse-server-mode-map)
3680 (define-key gnus-browse-server-mode-map " " 'gnus-browse-read-group)
3681 (define-key gnus-browse-server-mode-map "=" 'gnus-browse-read-group)
3682 (define-key gnus-browse-server-mode-map "n" 'gnus-browse-next-group)
3683 (define-key gnus-browse-server-mode-map "p" 'gnus-browse-prev-group)
3684 (define-key gnus-browse-server-mode-map [del] 'gnus-browse-prev-group)
3685 (define-key gnus-browse-server-mode-map "N" 'gnus-browse-next-group)
3686 (define-key gnus-browse-server-mode-map "P" 'gnus-group-prev-group)
3687 (define-key gnus-browse-server-mode-map "\M-n" 'gnus-browse-next-group)
3688 (define-key gnus-browse-server-mode-map "\M-p" 'gnus-browse-prev-group)
3689 (define-key gnus-browse-server-mode-map "\r" 'gnus-browse-read-group)
3690 (define-key gnus-browse-server-mode-map "u" 'gnus-browse-unsubscribe-current-group)
3691 (define-key gnus-browse-server-mode-map "q" 'gnus-browse-exit)
3692 (define-key gnus-browse-server-mode-map "Q" 'gnus-browse-exit)
3693 (define-key gnus-browse-server-mode-map "\C-c\C-c" 'gnus-browse-quit)
3694 (define-key gnus-browse-server-mode-map "?" 'gnus-browse-describe-briefly)
3695 (define-key gnus-browse-server-mode-map "\C-c\C-i" 'gnus-info-find-node)
3698 (defvar gnus-browse-current-method nil)
3700 (defun gnus-browse-foreign-server (method)
3701 (setq gnus-browse-current-method method)
3702 (let ((gnus-select-method method)
3704 (message "Connecting to %s..." (nth 1 method))
3705 (if (not (gnus-request-list method))
3706 (error "Unable to contact server: " (gnus-status-message method)))
3707 (set-buffer (get-buffer-create "*Gnus Browse Server*"))
3708 (gnus-add-current-to-buffer-list)
3709 (buffer-disable-undo (current-buffer))
3710 (let ((buffer-read-only nil))
3712 (gnus-browse-server-mode)
3713 (setq mode-line-buffer-identification
3715 "(ding) Browse Server {%s:%s}" (car method) (car (cdr method))))
3717 (set-buffer nntp-server-buffer)
3718 (let ((cur (current-buffer)))
3720 (while (re-search-forward
3721 "\\(^[^ \t]+\\)[ \t]+[0-9]+[ \t]+[0-9]+" nil t)
3722 (goto-char (match-end 1))
3723 (setq groups (cons (cons (buffer-substring (match-beginning 1)
3725 (- (read cur) (read cur)))
3727 (setq groups (sort groups
3729 (string< (car l1) (car l2)))))
3730 (let ((buffer-read-only nil))
3732 (setq group (car groups))
3734 (format "K%7d: %s\n" (cdr group) (car group)))
3735 (setq groups (cdr groups))))
3736 (switch-to-buffer (current-buffer))
3738 (gnus-group-position-cursor)))
3740 (defun gnus-browse-server-mode ()
3741 "Major mode for reading network news."
3743 (kill-all-local-variables)
3744 (setq mode-line-modified "-- ")
3745 (make-local-variable 'mode-line-format)
3746 (setq mode-line-format (copy-sequence mode-line-format))
3747 (and (equal (nth 3 mode-line-format) " ")
3748 (setcar (nthcdr 3 mode-line-format) ""))
3749 (setq major-mode 'gnus-browse-server-mode)
3750 (setq mode-name "Browse Server")
3751 (setq mode-line-process nil)
3752 (use-local-map gnus-browse-server-mode-map)
3753 (buffer-disable-undo (current-buffer))
3754 (setq truncate-lines t)
3755 (setq buffer-read-only t)
3756 (run-hooks 'gnus-browse-server-mode-hook))
3758 (defun gnus-browse-read-group ()
3759 "Not implemented, and will probably never be."
3761 (error "You can't read while browsing"))
3763 (defun gnus-browse-next-group (n)
3764 "Go to the next group."
3768 (gnus-group-position-cursor)))
3770 (defun gnus-browse-prev-group (n)
3771 "Go to the next group."
3773 (gnus-browse-next-group (- n)))
3775 (defun gnus-browse-unsubscribe-current-group (arg)
3776 "(Un)subscribe to the next ARG groups."
3779 (error "No group at current line."))
3780 (let ((ward (if (< arg 0) -1 1))
3782 (while (and (> arg 0)
3784 (gnus-browse-unsubscribe-group)
3785 (zerop (gnus-browse-next-group ward)))
3786 (setq arg (1- arg)))
3787 (gnus-group-position-cursor)
3788 (if (/= 0 arg) (message "No more newsgroups" ))
3791 (defun gnus-browse-unsubscribe-group ()
3793 (buffer-read-only nil)
3797 (if (= (following-char) ?K) (setq sub t))
3798 (re-search-forward ": \\(.*\\)$" nil t)
3799 (setq group (gnus-group-prefixed-name
3800 (buffer-substring (match-beginning 1) (match-end 1))
3801 gnus-browse-current-method))
3806 (gnus-group-change-level
3807 (list t group 3 nil nil gnus-browse-current-method) 3 9
3808 (gnus-gethash (car (nth 1 gnus-newsrc-assoc)) gnus-newsrc-hashtb)
3811 (gnus-group-change-level group 9 3)
3815 (defun gnus-browse-exit ()
3816 "Quit browsing and return to the group buffer."
3818 (if (eq major-mode 'gnus-browse-server-mode)
3819 (kill-buffer (current-buffer)))
3820 (switch-to-buffer gnus-group-buffer)
3821 (gnus-group-list-groups 5))
3823 (defun gnus-browse-describe-briefly ()
3824 "Give a one line description of the group mode commands."
3827 (substitute-command-keys "\\<gnus-browse-server-mode-map>\\[gnus-group-next-group]:Forward \\[gnus-group-prev-group]:Backward \\[gnus-browse-exit]:Exit \\[gnus-info-find-node]:Run Info \\[gnus-browse-describe-briefly]:This help")))
3831 ;;; Gnus summary mode
3834 (defvar gnus-summary-mode-map nil)
3835 (defvar gnus-summary-mark-map nil)
3836 (defvar gnus-summary-send-map nil)
3837 (defvar gnus-summary-extract-map nil)
3838 (defvar gnus-summary-extract-view-map nil)
3839 (defvar gnus-summary-article-map nil)
3840 (defvar gnus-summary-thread-map nil)
3841 (defvar gnus-summary-goto-map nil)
3842 (defvar gnus-summary-exit-map nil)
3843 (defvar gnus-summary-various-map nil)
3844 (defvar gnus-summary-interest-map nil)
3845 (defvar gnus-summary-process-map nil)
3846 (defvar gnus-summary-sort-map nil)
3847 (defvar gnus-summary-mgroup-map nil)
3848 (defvar gnus-summary-vkill-map nil)
3849 (defvar gnus-summary-increase-map nil)
3850 (defvar gnus-summary-inc-subject-map nil)
3851 (defvar gnus-summary-inc-author-map nil)
3852 (defvar gnus-summary-inc-xref-map nil)
3853 (defvar gnus-summary-inc-thread-map nil)
3854 (defvar gnus-summary-inc-fol-map nil)
3855 (defvar gnus-summary-lower-map nil)
3856 (defvar gnus-summary-low-subject-map nil)
3857 (defvar gnus-summary-low-author-map nil)
3858 (defvar gnus-summary-low-xref-map nil)
3859 (defvar gnus-summary-low-thread-map nil)
3860 (defvar gnus-summary-low-fol-map nil)
3862 (if gnus-summary-mode-map
3864 (setq gnus-summary-mode-map (make-keymap))
3865 (suppress-keymap gnus-summary-mode-map)
3867 ;;Non-orthogonal keys
3869 (define-key gnus-summary-mode-map " " 'gnus-summary-next-page)
3870 (define-key gnus-summary-mode-map "\177" 'gnus-summary-prev-page)
3871 (define-key gnus-summary-mode-map "\r" 'gnus-summary-scroll-up)
3872 (define-key gnus-summary-mode-map "n" 'gnus-summary-next-unread-article)
3873 (define-key gnus-summary-mode-map "p" 'gnus-summary-prev-unread-article)
3874 (define-key gnus-summary-mode-map "N" 'gnus-summary-next-article)
3875 (define-key gnus-summary-mode-map "P" 'gnus-summary-prev-article)
3876 (define-key gnus-summary-mode-map "\M-\C-n" 'gnus-summary-next-same-subject)
3877 (define-key gnus-summary-mode-map "\M-\C-p" 'gnus-summary-prev-same-subject)
3878 (define-key gnus-summary-mode-map "\M-n" 'gnus-summary-next-unread-subject)
3879 (define-key gnus-summary-mode-map "\M-p" 'gnus-summary-prev-unread-subject)
3880 (define-key gnus-summary-mode-map "." 'gnus-summary-first-unread-article)
3881 (define-key gnus-summary-mode-map "," 'gnus-summary-best-unread-article)
3882 (define-key gnus-summary-mode-map "\M-s" 'gnus-summary-search-article-forward)
3883 (define-key gnus-summary-mode-map "\M-r" 'gnus-summary-search-article-backward)
3884 (define-key gnus-summary-mode-map "<" 'gnus-summary-beginning-of-article)
3885 (define-key gnus-summary-mode-map ">" 'gnus-summary-end-of-article)
3886 (define-key gnus-summary-mode-map "j" 'gnus-summary-goto-subject)
3887 (define-key gnus-summary-mode-map "^" 'gnus-summary-refer-parent-article)
3888 (define-key gnus-summary-mode-map "\M-^" 'gnus-summary-refer-article)
3889 (define-key gnus-summary-mode-map "u" 'gnus-summary-tick-article-forward)
3890 (define-key gnus-summary-mode-map "!" 'gnus-summary-tick-article-forward)
3891 (define-key gnus-summary-mode-map "U" 'gnus-summary-tick-article-backward)
3892 (define-key gnus-summary-mode-map "d" 'gnus-summary-mark-as-read-forward)
3893 (define-key gnus-summary-mode-map "D" 'gnus-summary-mark-as-read-backward)
3894 (define-key gnus-summary-mode-map "E" 'gnus-summary-mark-as-expirable)
3895 (define-key gnus-summary-mode-map "\M-u" 'gnus-summary-clear-mark-forward)
3896 (define-key gnus-summary-mode-map "\M-U" 'gnus-summary-clear-mark-backward)
3897 (define-key gnus-summary-mode-map "k" 'gnus-summary-kill-same-subject-and-select)
3898 (define-key gnus-summary-mode-map "\C-k" 'gnus-summary-kill-same-subject)
3899 (define-key gnus-summary-mode-map "\M-\C-k" 'gnus-summary-kill-thread)
3900 (define-key gnus-summary-mode-map "\M-\C-l" 'gnus-summary-lower-thread)
3901 (define-key gnus-summary-mode-map "e" 'gnus-summary-edit-article)
3902 (define-key gnus-summary-mode-map "#" 'gnus-summary-mark-as-processable)
3903 (define-key gnus-summary-mode-map "\M-#" 'gnus-summary-unmark-as-processable)
3904 (define-key gnus-summary-mode-map "\M-\C-t" 'gnus-summary-toggle-threads)
3905 (define-key gnus-summary-mode-map "\M-\C-s" 'gnus-summary-show-thread)
3906 (define-key gnus-summary-mode-map "\M-\C-h" 'gnus-summary-hide-thread)
3907 (define-key gnus-summary-mode-map "\M-\C-f" 'gnus-summary-next-thread)
3908 (define-key gnus-summary-mode-map "\M-\C-b" 'gnus-summary-prev-thread)
3909 (define-key gnus-summary-mode-map "\M-\C-u" 'gnus-summary-up-thread)
3910 (define-key gnus-summary-mode-map "\M-\C-d" 'gnus-summary-down-thread)
3911 (define-key gnus-summary-mode-map "&" 'gnus-summary-execute-command)
3912 (define-key gnus-summary-mode-map "c" 'gnus-summary-catchup-and-exit)
3913 (define-key gnus-summary-mode-map "\C-t" 'gnus-summary-toggle-truncation)
3914 (define-key gnus-summary-mode-map "?" 'gnus-summary-mark-as-dormant)
3915 (define-key gnus-summary-mode-map "\C-c\M-\C-s" 'gnus-summary-show-all-expunged)
3916 (define-key gnus-summary-mode-map "\C-c\C-s\C-n" 'gnus-summary-sort-by-number)
3917 (define-key gnus-summary-mode-map "\C-c\C-s\C-a" 'gnus-summary-sort-by-author)
3918 (define-key gnus-summary-mode-map "\C-c\C-s\C-s" 'gnus-summary-sort-by-subject)
3919 (define-key gnus-summary-mode-map "\C-c\C-s\C-d" 'gnus-summary-sort-by-date)
3920 (define-key gnus-summary-mode-map "\C-c\C-s\C-i" 'gnus-summary-sort-by-score)
3921 (define-key gnus-summary-mode-map "=" 'gnus-summary-expand-window)
3922 (define-key gnus-summary-mode-map "\C-x\C-s" 'gnus-summary-reselect-current-group)
3923 (define-key gnus-summary-mode-map "\M-g" 'gnus-summary-rescan-group)
3924 (define-key gnus-summary-mode-map "w" 'gnus-summary-stop-page-breaking)
3925 (define-key gnus-summary-mode-map "\C-c\C-r" 'gnus-summary-caesar-message)
3926 (define-key gnus-summary-mode-map "\M-t" 'gnus-summary-toggle-mime)
3927 (define-key gnus-summary-mode-map "\C-d" 'gnus-summary-enter-digest-group)
3928 (define-key gnus-summary-mode-map "f" 'gnus-summary-followup)
3929 (define-key gnus-summary-mode-map "F" 'gnus-summary-followup-with-original)
3930 (define-key gnus-summary-mode-map "C" 'gnus-summary-cancel-article)
3931 (define-key gnus-summary-mode-map "r" 'gnus-summary-reply)
3932 (define-key gnus-summary-mode-map "R" 'gnus-summary-reply-with-original)
3933 (define-key gnus-summary-mode-map "\C-c\C-f" 'gnus-summary-mail-forward)
3934 (define-key gnus-summary-mode-map "o" 'gnus-summary-save-article)
3935 (define-key gnus-summary-mode-map "\C-o" 'gnus-summary-save-article-mail)
3936 (define-key gnus-summary-mode-map "|" 'gnus-summary-pipe-output)
3937 (define-key gnus-summary-mode-map "\M-k" 'gnus-summary-edit-local-kill)
3938 (define-key gnus-summary-mode-map "\M-K" 'gnus-summary-edit-global-kill)
3939 (define-key gnus-summary-mode-map "V" 'gnus-version)
3940 (define-key gnus-summary-mode-map "\C-c\C-d" 'gnus-summary-describe-group)
3941 (define-key gnus-summary-mode-map "q" 'gnus-summary-exit)
3942 (define-key gnus-summary-mode-map "Q" 'gnus-summary-quit)
3943 (define-key gnus-summary-mode-map "\C-c\C-i" 'gnus-info-find-node)
3944 (define-key gnus-summary-mode-map [mouse-2] 'gnus-mouse-pick-article)
3945 (define-key gnus-summary-mode-map "m" 'gnus-summary-mail-other-window)
3946 (define-key gnus-summary-mode-map "a" 'gnus-summary-post-news)
3947 (define-key gnus-summary-mode-map "x" 'gnus-summary-delete-marked-as-read)
3948 (define-key gnus-summary-mode-map "X" 'gnus-summary-remove-lines-marked-with)
3949 (define-key gnus-summary-mode-map "s" 'gnus-summary-isearch-article)
3950 (define-key gnus-summary-mode-map "t" 'gnus-summary-toggle-header)
3951 (define-key gnus-summary-mode-map "g" 'gnus-summary-show-article)
3952 ; (define-key gnus-summary-mode-map "?" 'gnus-summary-describe-briefly)
3953 (define-key gnus-summary-mode-map "l" 'gnus-summary-goto-last-article)
3954 (define-key gnus-summary-mode-map "\C-c\C-v\C-v" 'gnus-uu-decode-uu)
3957 ;; Orthogonal keymap
3958 (define-prefix-command 'gnus-summary-mark-map)
3959 (define-key gnus-summary-mode-map "M" 'gnus-summary-mark-map)
3960 (define-key gnus-summary-mark-map "t" 'gnus-summary-tick-article-forward)
3961 (define-key gnus-summary-mark-map "!" 'gnus-summary-tick-article-forward)
3962 (define-key gnus-summary-mark-map "d" 'gnus-summary-mark-as-read-forward)
3963 (define-key gnus-summary-mark-map "r" 'gnus-summary-mark-as-read-forward)
3964 (define-key gnus-summary-mark-map "c" 'gnus-summary-clear-mark-forward)
3965 (define-key gnus-summary-mark-map " " 'gnus-summary-clear-mark-forward)
3966 (define-key gnus-summary-mark-map "e" 'gnus-summary-mark-as-expirable)
3967 (define-key gnus-summary-mark-map "x" 'gnus-summary-mark-as-expirable)
3968 (define-key gnus-summary-mark-map "?" 'gnus-summary-mark-as-dormant)
3969 (define-key gnus-summary-mark-map "b" 'gnus-summary-set-bookmark)
3970 (define-key gnus-summary-mark-map "B" 'gnus-summary-remove-bookmark)
3971 (define-key gnus-summary-mark-map "#" 'gnus-summary-mark-as-processable)
3972 (define-key gnus-summary-mark-map "\M-#" 'gnus-summary-unmark-as-processable)
3973 (define-key gnus-summary-mark-map "\M-r" 'gnus-summary-remove-lines-marked-as-read)
3974 (define-key gnus-summary-mark-map "\M-\C-r" 'gnus-summary-remove-lines-marked-with)
3975 (define-key gnus-summary-mark-map "D" 'gnus-summary-show-all-dormant)
3976 (define-key gnus-summary-mark-map "S" 'gnus-summary-show-all-expunged)
3977 (define-key gnus-summary-mark-map "C" 'gnus-summary-catchup)
3978 (define-key gnus-summary-mark-map "H" 'gnus-summary-catchup-to-here)
3979 (define-key gnus-summary-mark-map "\C-c" 'gnus-summary-catchup-all)
3980 (define-key gnus-summary-mark-map "a" 'gnus-summary-clear-above)
3981 (define-key gnus-summary-mark-map "A" 'gnus-summary-tick-above)
3983 (define-prefix-command 'gnus-summary-process-map)
3984 (define-key gnus-summary-mark-map "p" 'gnus-summary-process-map)
3985 (define-key gnus-summary-process-map "p" 'gnus-summary-mark-as-processable)
3986 (define-key gnus-summary-process-map "u" 'gnus-summary-unmark-as-processable)
3987 (define-key gnus-summary-process-map "U" 'gnus-summary-unmark-all-processable)
3988 (define-key gnus-summary-process-map "s" 'gnus-uu-mark-series)
3989 (define-key gnus-summary-process-map "r" 'gnus-uu-mark-region)
3990 (define-key gnus-summary-process-map "R" 'gnus-uu-mark-by-regexp)
3991 (define-key gnus-summary-process-map "t" 'gnus-uu-mark-thread)
3992 (define-key gnus-summary-process-map "a" 'gnus-uu-mark-all)
3993 (define-key gnus-summary-process-map "S" 'gnus-uu-mark-sparse)
3996 (define-prefix-command 'gnus-summary-send-map)
3997 (define-key gnus-summary-mode-map "S" 'gnus-summary-send-map)
3998 (define-key gnus-summary-send-map "p" 'gnus-summary-post-news)
3999 (define-key gnus-summary-send-map "f" 'gnus-summary-followup)
4000 (define-key gnus-summary-send-map "F" 'gnus-summary-followup-with-original)
4001 (define-key gnus-summary-send-map "b" 'gnus-summary-followup-and-reply)
4002 (define-key gnus-summary-send-map "B" 'gnus-summary-followup-and-reply-with-original)
4003 (define-key gnus-summary-send-map "c" 'gnus-summary-cancel-article)
4004 (define-key gnus-summary-send-map "s" 'gnus-summary-supersede-article)
4005 (define-key gnus-summary-send-map "r" 'gnus-summary-reply)
4006 (define-key gnus-summary-send-map "R" 'gnus-summary-reply-with-original)
4007 (define-key gnus-summary-send-map "\C-f" 'gnus-summary-mail-forward)
4008 (define-key gnus-summary-send-map "m" 'gnus-summary-mail-other-window)
4009 (define-key gnus-summary-send-map "u" 'gnus-uu-post-news)
4010 (define-key gnus-summary-send-map "\M-f" 'gnus-uu-digest-and-forward)
4013 (define-prefix-command 'gnus-summary-goto-map)
4014 (define-key gnus-summary-mode-map "G" 'gnus-summary-goto-map)
4015 (define-key gnus-summary-goto-map "n" 'gnus-summary-next-unread-article)
4016 (define-key gnus-summary-goto-map "p" 'gnus-summary-prev-unread-article)
4017 (define-key gnus-summary-goto-map "N" 'gnus-summary-next-article)
4018 (define-key gnus-summary-goto-map "P" 'gnus-summary-prev-article)
4019 (define-key gnus-summary-goto-map "\C-n" 'gnus-summary-next-same-subject)
4020 (define-key gnus-summary-goto-map "\C-p" 'gnus-summary-prev-same-subject)
4021 (define-key gnus-summary-goto-map "\M-n" 'gnus-summary-next-unread-subject)
4022 (define-key gnus-summary-goto-map "\M-p" 'gnus-summary-prev-unread-subject)
4023 (define-key gnus-summary-goto-map "f" 'gnus-summary-first-unread-article)
4024 (define-key gnus-summary-goto-map "b" 'gnus-summary-best-unread-article)
4025 (define-key gnus-summary-goto-map "g" 'gnus-summary-goto-subject)
4026 (define-key gnus-summary-goto-map "l" 'gnus-summary-goto-last-article)
4029 (define-prefix-command 'gnus-summary-thread-map)
4030 (define-key gnus-summary-mode-map "T" 'gnus-summary-thread-map)
4031 (define-key gnus-summary-thread-map "k" 'gnus-summary-kill-thread)
4032 (define-key gnus-summary-thread-map "l" 'gnus-summary-lower-thread)
4033 (define-key gnus-summary-thread-map "r" 'gnus-summary-raise-thread)
4034 (define-key gnus-summary-thread-map "T" 'gnus-summary-toggle-threads)
4035 (define-key gnus-summary-thread-map "s" 'gnus-summary-show-thread)
4036 (define-key gnus-summary-thread-map "S" 'gnus-summary-show-all-threads)
4037 (define-key gnus-summary-thread-map "h" 'gnus-summary-hide-thread)
4038 (define-key gnus-summary-thread-map "H" 'gnus-summary-hide-all-threads)
4039 (define-key gnus-summary-thread-map "n" 'gnus-summary-next-thread)
4040 (define-key gnus-summary-thread-map "p" 'gnus-summary-prev-thread)
4041 (define-key gnus-summary-thread-map "u" 'gnus-summary-up-thread)
4042 (define-key gnus-summary-thread-map "d" 'gnus-summary-down-thread)
4043 (define-key gnus-summary-thread-map "#" 'gnus-uu-mark-thread)
4046 (define-prefix-command 'gnus-summary-exit-map)
4047 (define-key gnus-summary-mode-map "\M-e" 'gnus-summary-exit-map)
4048 (define-key gnus-summary-exit-map "c" 'gnus-summary-catchup-and-exit)
4049 (define-key gnus-summary-exit-map "\C-c" 'gnus-summary-catchup-all-and-exit)
4050 (define-key gnus-summary-exit-map "q" 'gnus-summary-exit)
4051 (define-key gnus-summary-exit-map "e" 'gnus-summary-exit)
4052 (define-key gnus-summary-exit-map "Q" 'gnus-summary-quit)
4053 (define-key gnus-summary-exit-map "E" 'gnus-summary-quit)
4056 (define-prefix-command 'gnus-summary-article-map)
4057 (define-key gnus-summary-mode-map "A" 'gnus-summary-article-map)
4058 (define-key gnus-summary-article-map " " 'gnus-summary-next-page)
4059 (define-key gnus-summary-article-map "n" 'gnus-summary-next-page)
4060 (define-key gnus-summary-article-map "\177" 'gnus-summary-prev-page)
4061 (define-key gnus-summary-article-map "p" 'gnus-summary-prev-page)
4062 (define-key gnus-summary-article-map "\r" 'gnus-summary-scroll-up)
4063 (define-key gnus-summary-article-map "<" 'gnus-summary-beginning-of-article)
4064 (define-key gnus-summary-article-map ">" 'gnus-summary-end-of-article)
4065 (define-key gnus-summary-article-map "b" 'gnus-summary-beginning-of-article)
4066 (define-key gnus-summary-article-map "e" 'gnus-summary-end-of-article)
4067 (define-key gnus-summary-article-map "^" 'gnus-summary-refer-parent-article)
4068 (define-key gnus-summary-article-map "r" 'gnus-summary-refer-parent-article)
4069 (define-key gnus-summary-article-map "w" 'gnus-summary-stop-page-breaking)
4070 (define-key gnus-summary-article-map "c" 'gnus-summary-caesar-message)
4071 (define-key gnus-summary-article-map "g" 'gnus-summary-show-article)
4072 (define-key gnus-summary-article-map "t" 'gnus-summary-toggle-header)
4073 (define-key gnus-summary-article-map "hh" 'gnus-article-hide-headers)
4074 (define-key gnus-summary-article-map "hs" 'gnus-article-hide-signature)
4075 (define-key gnus-summary-article-map "hc" 'gnus-article-hide-citation)
4076 (define-key gnus-summary-article-map "ho" 'gnus-article-treat-overstrike)
4077 (define-key gnus-summary-article-map "hw" 'gnus-article-word-wrap)
4078 (define-key gnus-summary-article-map "hd" 'gnus-article-remove-cr)
4079 (define-key gnus-summary-article-map "hq" 'gnus-article-de-quoted-unreadable)
4080 (define-key gnus-summary-article-map "m" 'gnus-summary-toggle-mime)
4081 (define-key gnus-summary-article-map "s" 'gnus-summary-isearch-article)
4084 (define-prefix-command 'gnus-summary-extract-map)
4085 (define-key gnus-summary-mode-map "X" 'gnus-summary-extract-map)
4086 ; (define-key gnus-summary-extract-map "x" 'gnus-summary-extract-any)
4087 ; (define-key gnus-summary-extract-map "m" 'gnus-summary-extract-mime)
4089 (define-key gnus-summary-extract-map "u" 'gnus-uu-decode-uu)
4090 (define-key gnus-summary-extract-map "U" 'gnus-uu-decode-uu-and-save)
4091 (define-key gnus-summary-extract-map "s" 'gnus-uu-decode-unshar)
4092 (define-key gnus-summary-extract-map "S" 'gnus-uu-decode-unshar-and-save)
4093 (define-key gnus-summary-extract-map "o" 'gnus-uu-decode-save)
4094 (define-key gnus-summary-extract-map "O" 'gnus-uu-decode-save)
4095 (define-key gnus-summary-extract-map "b" 'gnus-uu-decode-binhex)
4096 (define-key gnus-summary-extract-map "B" 'gnus-uu-decode-binhex)
4098 (define-prefix-command 'gnus-summary-extract-view-map)
4099 (define-key gnus-summary-extract-map "v" 'gnus-summary-extract-view-map)
4100 (define-key gnus-summary-extract-view-map "u" 'gnus-uu-decode-uu-view)
4101 (define-key gnus-summary-extract-view-map "U" 'gnus-uu-decode-uu-and-save-view)
4102 (define-key gnus-summary-extract-view-map "s" 'gnus-uu-decode-unshar-view)
4103 (define-key gnus-summary-extract-view-map "S" 'gnus-uu-decode-unshar-and-save-view)
4104 (define-key gnus-summary-extract-view-map "o" 'gnus-uu-decode-save-view)
4105 (define-key gnus-summary-extract-view-map "O" 'gnus-uu-decode-save-view)
4106 (define-key gnus-summary-extract-view-map "b" 'gnus-uu-decode-binhex-view)
4107 (define-key gnus-summary-extract-view-map "B" 'gnus-uu-decode-binhex-view)
4110 (define-prefix-command 'gnus-summary-various-map)
4111 (define-key gnus-summary-mode-map "V" 'gnus-summary-various-map)
4112 (define-key gnus-summary-various-map "u" 'gnus-summary-universal-argument)
4113 (define-key gnus-summary-various-map "\M-s" 'gnus-summary-search-article-forward)
4114 (define-key gnus-summary-various-map "\M-r" 'gnus-summary-search-article-backward)
4115 (define-key gnus-summary-various-map "r" 'gnus-summary-refer-article)
4116 (define-key gnus-summary-various-map "&" 'gnus-summary-execute-command)
4117 (define-key gnus-summary-various-map "\C-t" 'gnus-summary-toggle-truncation)
4118 (define-key gnus-summary-various-map "=" 'gnus-summary-expand-window)
4119 (define-key gnus-summary-various-map "\C-s" 'gnus-summary-reselect-current-group)
4120 (define-key gnus-summary-various-map "g" 'gnus-summary-rescan-group)
4121 (define-key gnus-summary-various-map "o" 'gnus-summary-save-article)
4122 (define-key gnus-summary-various-map "\C-o" 'gnus-summary-save-article-mail)
4123 (define-key gnus-summary-various-map "|" 'gnus-summary-pipe-output)
4124 (define-key gnus-summary-various-map "V" 'gnus-version)
4125 (define-key gnus-summary-various-map "d" 'gnus-summary-describe-group)
4126 (define-key gnus-summary-various-map "?" 'gnus-summary-describe-briefly)
4127 (define-key gnus-summary-various-map "i" 'gnus-info-find-node)
4128 (define-key gnus-summary-various-map "S" 'gnus-summary-set-score)
4129 (define-key gnus-summary-various-map "b" 'gnus-summary-set-mark-below)
4130 (define-key gnus-summary-various-map "D" 'gnus-summary-enter-digest-group)
4132 (define-prefix-command 'gnus-summary-sort-map)
4133 (define-key gnus-summary-various-map "s" 'gnus-summary-sort-map)
4134 (define-key gnus-summary-sort-map "n" 'gnus-summary-sort-by-number)
4135 (define-key gnus-summary-sort-map "a" 'gnus-summary-sort-by-author)
4136 (define-key gnus-summary-sort-map "s" 'gnus-summary-sort-by-subject)
4137 (define-key gnus-summary-sort-map "d" 'gnus-summary-sort-by-date)
4138 (define-key gnus-summary-sort-map "i" 'gnus-summary-sort-by-score)
4140 (define-prefix-command 'gnus-summary-mgroup-map)
4141 (define-key gnus-summary-various-map "m" 'gnus-summary-mgroup-map)
4142 (define-key gnus-summary-mgroup-map "e" 'gnus-summary-expire-articles)
4143 (define-key gnus-summary-mgroup-map "\177" 'gnus-summary-delete-article)
4144 (define-key gnus-summary-mgroup-map "m" 'gnus-summary-move-article)
4145 (define-key gnus-summary-mgroup-map "r" 'gnus-summary-respool-article)
4146 (define-key gnus-summary-mgroup-map "w" 'gnus-summary-edit-article)
4148 (define-prefix-command 'gnus-summary-vkill-map)
4149 (define-key gnus-summary-various-map "k" 'gnus-summary-vkill-map)
4150 (define-key gnus-summary-vkill-map "k" 'gnus-summary-kill-same-subject-and-select)
4151 (define-key gnus-summary-vkill-map "K" 'gnus-summary-kill-same-subject)
4152 (define-key gnus-summary-vkill-map "\M-k" 'gnus-summary-edit-local-kill)
4153 (define-key gnus-summary-vkill-map "\M-K" 'gnus-summary-edit-global-kill)
4154 (define-key gnus-summary-vkill-map "x" 'gnus-kill-file-set-expunge-below)
4155 (define-key gnus-summary-vkill-map "m" 'gnus-kill-file-set-mark-below)
4159 (define-prefix-command 'gnus-summary-increase-map)
4160 (define-key gnus-summary-mode-map "I" 'gnus-summary-increase-map)
4161 (define-key gnus-summary-increase-map "i" 'gnus-summary-raise-same-subject-and-select)
4162 (define-key gnus-summary-increase-map "I" 'gnus-summary-raise-same-subject)
4163 (define-key gnus-summary-increase-map "\C-i" 'gnus-summary-raise-score)
4165 (define-prefix-command 'gnus-summary-inc-subject-map)
4166 (define-key gnus-summary-increase-map "s" 'gnus-summary-inc-subject-map)
4167 (define-key gnus-summary-increase-map "S" 'gnus-summary-temporarily-raise-by-subject)
4168 (define-key gnus-summary-inc-subject-map "s" 'gnus-summary-temporarily-raise-by-subject)
4169 (define-key gnus-summary-inc-subject-map "S" 'gnus-summary-raise-by-subject)
4170 (define-key gnus-summary-inc-subject-map "t" 'gnus-summary-temporarily-raise-by-subject)
4171 (define-key gnus-summary-inc-subject-map "p" 'gnus-summary-raise-by-subject)
4173 (define-prefix-command 'gnus-summary-inc-author-map)
4174 (define-key gnus-summary-increase-map "a" 'gnus-summary-inc-author-map)
4175 (define-key gnus-summary-increase-map "A" 'gnus-summary-temporarily-raise-by-author)
4176 (define-key gnus-summary-inc-author-map "a" 'gnus-summary-temporarily-raise-by-author)
4177 (define-key gnus-summary-inc-author-map "A" 'gnus-summary-raise-by-author)
4178 (define-key gnus-summary-inc-author-map "t" 'gnus-summary-temporarily-raise-by-author)
4179 (define-key gnus-summary-inc-author-map "p" 'gnus-summary-raise-by-author)
4181 (define-prefix-command 'gnus-summary-inc-thread-map)
4182 (define-key gnus-summary-increase-map "t" 'gnus-summary-inc-thread-map)
4183 (define-key gnus-summary-increase-map "T" 'gnus-summary-temporarily-raise-by-thread)
4184 (define-key gnus-summary-inc-thread-map "t" 'gnus-summary-temporarily-raise-by-thread)
4185 (define-key gnus-summary-inc-thread-map "T" 'gnus-summary-raise-by-thread)
4186 (define-key gnus-summary-inc-thread-map "t" 'gnus-summary-temporarily-raise-by-thread)
4187 (define-key gnus-summary-inc-thread-map "p" 'gnus-summary-raise-by-thread)
4189 (define-prefix-command 'gnus-summary-inc-xref-map)
4190 (define-key gnus-summary-increase-map "x" 'gnus-summary-inc-xref-map)
4191 (define-key gnus-summary-increase-map "X" 'gnus-summary-temporarily-raise-by-xref)
4192 (define-key gnus-summary-inc-xref-map "x" 'gnus-summary-temporarily-raise-by-xref)
4193 (define-key gnus-summary-inc-xref-map "X" 'gnus-summary-raise-by-xref)
4194 (define-key gnus-summary-inc-xref-map "t" 'gnus-summary-temporarily-raise-by-xref)
4195 (define-key gnus-summary-inc-xref-map "p" 'gnus-summary-raise-by-xref)
4197 (define-prefix-command 'gnus-summary-inc-fol-map)
4198 (define-key gnus-summary-increase-map "f" 'gnus-summary-inc-fol-map)
4199 (define-key gnus-summary-increase-map "F" 'gnus-summary-raise-followups-to-author)
4200 (define-key gnus-summary-inc-fol-map "f" 'gnus-summary-raise-followups-to-author)
4201 (define-key gnus-summary-inc-fol-map "F" 'gnus-summary-raise-followups-to-author)
4202 (define-key gnus-summary-inc-fol-map "t" 'gnus-summary-raise-followups-to-author)
4203 (define-key gnus-summary-inc-fol-map "p" 'gnus-summary-raise-followups-to-author)
4205 (define-prefix-command 'gnus-summary-lower-map)
4206 (define-key gnus-summary-mode-map "L" 'gnus-summary-lower-map)
4207 (define-key gnus-summary-lower-map "l" 'gnus-summary-lower-same-subject-and-select)
4208 (define-key gnus-summary-lower-map "L" 'gnus-summary-lower-same-subject)
4209 (define-key gnus-summary-lower-map "\C-l" 'gnus-summary-lower-score)
4211 (define-prefix-command 'gnus-summary-low-subject-map)
4212 (define-key gnus-summary-lower-map "s" 'gnus-summary-low-subject-map)
4213 (define-key gnus-summary-lower-map "S" 'gnus-summary-temporarily-lower-by-subject)
4214 (define-key gnus-summary-low-subject-map "s" 'gnus-summary-temporarily-lower-by-subject)
4215 (define-key gnus-summary-low-subject-map "S" 'gnus-summary-lower-by-subject)
4216 (define-key gnus-summary-low-subject-map "t" 'gnus-summary-temporarily-lower-by-subject)
4217 (define-key gnus-summary-low-subject-map "p" 'gnus-summary-lower-by-subject)
4219 (define-prefix-command 'gnus-summary-low-author-map)
4220 (define-key gnus-summary-lower-map "a" 'gnus-summary-low-author-map)
4221 (define-key gnus-summary-lower-map "A" 'gnus-summary-temporarily-lower-by-author)
4222 (define-key gnus-summary-low-author-map "a" 'gnus-summary-temporarily-lower-by-author)
4223 (define-key gnus-summary-low-author-map "A" 'gnus-summary-lower-by-author)
4224 (define-key gnus-summary-low-author-map "t" 'gnus-summary-temporarily-lower-by-author)
4225 (define-key gnus-summary-low-author-map "p" 'gnus-summary-lower-by-author)
4227 (define-prefix-command 'gnus-summary-low-thread-map)
4228 (define-key gnus-summary-lower-map "t" 'gnus-summary-low-thread-map)
4229 (define-key gnus-summary-lower-map "T" 'gnus-summary-temporarily-lower-by-thread)
4230 (define-key gnus-summary-low-thread-map "t" 'gnus-summary-temporarily-lower-by-thread)
4231 (define-key gnus-summary-low-thread-map "T" 'gnus-summary-lower-by-thread)
4232 (define-key gnus-summary-low-thread-map "t" 'gnus-summary-temporarily-lower-by-thread)
4233 (define-key gnus-summary-low-thread-map "p" 'gnus-summary-lower-by-thread)
4235 (define-prefix-command 'gnus-summary-low-xref-map)
4236 (define-key gnus-summary-lower-map "x" 'gnus-summary-low-xref-map)
4237 (define-key gnus-summary-lower-map "X" 'gnus-summary-temporarily-lower-by-xref)
4238 (define-key gnus-summary-low-xref-map "x" 'gnus-summary-temporarily-lower-by-xref)
4239 (define-key gnus-summary-low-xref-map "X" 'gnus-summary-lower-by-xref)
4240 (define-key gnus-summary-low-xref-map "t" 'gnus-summary-temporarily-lower-by-xref)
4241 (define-key gnus-summary-low-xref-map "p" 'gnus-summary-lower-by-xref)
4243 (define-prefix-command 'gnus-summary-low-fol-map)
4244 (define-key gnus-summary-lower-map "f" 'gnus-summary-low-fol-map)
4245 (define-key gnus-summary-lower-map "F" 'gnus-summary-lower-followups-to-author)
4246 (define-key gnus-summary-low-fol-map "f" 'gnus-summary-lower-followups-to-author)
4247 (define-key gnus-summary-low-fol-map "F" 'gnus-summary-lower-followups-to-author)
4248 (define-key gnus-summary-low-fol-map "t" 'gnus-summary-lower-followups-to-author)
4249 (define-key gnus-summary-low-fol-map "p" 'gnus-summary-lower-followups-to-author)
4255 (defun gnus-summary-mode ()
4256 "Major mode for reading articles in this newsgroup.
4257 All normal editing commands are switched off.
4258 The following commands are available:
4260 \\<gnus-summary-mode-map>
4261 \\[gnus-summary-next-page]\t Scroll the article buffer a page forwards
4262 \\[gnus-summary-prev-page]\t Scroll the article buffer a page backwards
4263 \\[gnus-summary-scroll-up]\t Scroll the article buffer one line forwards
4264 \\[gnus-summary-next-unread-article]\t Go to the next unread article
4265 \\[gnus-summary-prev-unread-article]\t Go to the previous unread article
4266 \\[gnus-summary-next-article]\t Go to the next article
4267 \\[gnus-summary-prev-article]\t Go to the previous article
4268 \\[gnus-summary-next-same-subject]\t Go to the next summary line with the same subject
4269 \\[gnus-summary-prev-same-subject]\t Go to the previous summary line with the same subject
4270 \\[gnus-summary-next-subject]\t Go to the next summary line
4271 \\[gnus-summary-prev-subject]\t Go to the previous summary line
4272 \\[gnus-summary-next-unread-subject]\t Go to the next unread summary line
4273 \\[gnus-summary-prev-unread-subject]\t Go to the previous unread summary line
4274 \\[gnus-summary-first-unread-article]\t Go to the first unread article
4275 \\[gnus-summary-best-unread-article]\t Go to the unread article with the highest score
4276 \\[gnus-summary-goto-subject]\t Go to some subject
4277 \\[gnus-summary-goto-last-article]\t Go to the previous article
4279 \\[gnus-summary-beginning-of-article]\t Go to the beginning of the article
4280 \\[gnus-summary-end-of-article]\t Go to the end of the article
4282 \\[gnus-summary-refer-parent-article]\t Get the parent of the current article from the server
4283 \\[gnus-summary-refer-article]\t Request some article by Message-ID from the server
4285 \\[gnus-summary-isearch-article]\t Do an interactive search on the current article
4286 \\[gnus-summary-search-article-forward]\t Search all articles forward for a regular expression
4287 \\[gnus-summary-search-article-backward]\t Search all articles backward for a regular expression
4289 \\[gnus-summary-tick-article-forward]\t Tick current article and move forward
4290 \\[gnus-summary-tick-article-backward]\t Tick current article and move backward
4291 \\[gnus-summary-mark-as-read-forward]\t Mark the current article as read and move forward
4292 \\[gnus-summary-mark-as-read-backward]\t Mark the current article as read and move backward
4293 \\[gnus-summary-clear-mark-forward]\t Clear tick and read marks and move forward
4294 \\[gnus-summary-clear-mark-backward]\t Clear tick and read marks and move backward
4295 \\[gnus-summary-mark-as-processable]\t Set the process mark on the current article
4296 \\[gnus-summary-unmark-as-processable]\t Remove the process mark from the current article
4297 \\[gnus-summary-unmark-all-processable]\t Remove the process mark from all articles
4299 \\[gnus-summary-raise-same-subject-and-select]\t Raise all articles with the current subject and select the next article
4300 \\[gnus-summary-raise-same-subject]\t Raise all articles with the current subject
4301 \\[gnus-summary-lower-same-subject-and-select]\t Lower all articles with the current subject and select the next article
4302 \\[gnus-summary-lower-same-subject]\t Lower all articles with the current subject
4304 \\[gnus-summary-toggle-threads]\t Toggle thread display
4305 \\[gnus-summary-show-thread]\t Show the current thread
4306 \\[gnus-summary-hide-thread]\t Hide the current thread
4307 \\[gnus-summary-next-thread]\t Go to the next thread
4308 \\[gnus-summary-prev-thread]\t Go to the previous thread
4309 \\[gnus-summary-up-thread]\t Go up the current thread
4310 \\[gnus-summary-down-thread]\t Descend the current thread
4311 \\[gnus-summary-raise-thread]\t Raise the current thread
4312 \\[gnus-summary-lower-thread]\t Lower the current thread
4313 \\[gnus-summary-mark-as-expirable]\t Mark the current artivles as expirable
4314 \\[gnus-summary-remove-lines-marked-as-read]\t Remove all articles that are marked as read
4315 \\[gnus-summary-remove-lines-marked-with]\t Remove all articles that have some mark
4317 \\[gnus-summary-execute-command]\t Execute a command
4318 \\[gnus-summary-catchup-and-exit]\t Mark all unread articles as read and exit
4319 \\[gnus-summary-toggle-truncation]\t Toggle truncation of summary lines
4320 \\[gnus-summary-expand-window]\t Expand the summary window
4321 \\[gnus-summary-universal-argument]\t Run a command on all articles with the process mark
4323 \\[gnus-summary-sort-by-number]\t Sort the summary buffer by article number
4324 \\[gnus-summary-sort-by-author]\t Sort the summary buffer by author
4325 \\[gnus-summary-sort-by-subject]\t Sort the summary buffer by subject
4326 \\[gnus-summary-sort-by-date]\t Sort the summary buffer by date
4328 \\[gnus-summary-reselect-current-group]\t Exit and reselect the current group
4329 \\[gnus-summary-rescan-group]\t Exit, get new articles and reselect the group
4330 \\[gnus-summary-stop-page-breaking]\t Stop page breaking of the current article
4331 \\[gnus-summary-caesar-message]\t Caesar rotate (rot13) the current article
4332 \\[gnus-summary-show-article]\t Reselect the current article
4333 \\[gnus-summary-toggle-header]\t Toggle header display
4334 \\[gnus-summary-toggle-mime]\t Toggle whether to use MIME
4335 \\[gnus-summary-enter-digest-group]\t Enter a newsgroup based on the current digest
4336 \\[gnus-summary-post-news]\t Post an article to the current group
4337 \\[gnus-summary-followup]\t Post a followup to the current article
4338 \\[gnus-summary-followup-with-original]\t Post a followup and include the original article
4339 \\[gnus-summary-cancel-article]\t Cancel the current article
4340 \\[gnus-summary-supersede-article]\t Supersede the current article
4341 \\[gnus-summary-reply]\t Mail a reply to the author of the current article
4342 \\[gnus-summary-reply-with-original]\t Mail a reply and include the current article
4343 \\[gnus-summary-mail-forward]\t Forward the current article
4344 \\[gnus-summary-mail-other-window]\t Mail in the other window
4345 \\[gnus-summary-save-article]\t Save the current article
4346 \\[gnus-summary-save-article-mail]\t Save the current article in rmail format
4347 \\[gnus-summary-pipe-output]\t Pipe the current article to a process
4348 \\[gnus-summary-move-article]\t Move the article to a different newsgroup
4349 \\[gnus-summary-respool-article]\t Respool the article
4350 \\[gnus-summary-edit-local-kill]\t Edit the local kill file
4351 \\[gnus-summary-edit-global-kill]\t Edit the global kill file
4352 \\[gnus-version]\t Display the current Gnus version
4353 \\[gnus-summary-exit]\t Exit the summary buffer
4354 \\[gnus-summary-quit]\t Exit the summary buffer without saving any changes
4355 \\[gnus-summary-describe-group]\t Describe the current newsgroup
4356 \\[gnus-summary-describe-briefly]\t Give a brief key overview
4357 \\[gnus-info-find-node]\t Go to the Gnus info node
4359 \\[gnus-kill-file-set-expunge-below] Automatically expunge articles below LEVEL.
4361 \\[gnus-kill-file-set-mark-below] Automatically mark articles below LEVEL.
4362 \\[gnus-summary-temporarily-raise-by-subject]\t Temporarily raise score for articles with the current subject
4363 \\[gnus-summary-temporarily-raise-by-author]\t Temporarily raise score for articles from the current author
4364 \\[gnus-summary-temporarily-raise-by-xref]\t Temporarily raise score for articles with the current cross-posting
4365 \\[gnus-summary-raise-by-subject]\t Permanently raise score for articles with the current subject
4366 \\[gnus-summary-raise-by-author]\t Permanently raise score for articles from the current author
4367 \\[gnus-summary-raise-followups-to-author]\t Permanently raise score for followups to the current author
4368 \\[gnus-summary-raise-by-xref]\t Permanently raise score for articles with the current cross-posting
4369 \\[gnus-summary-temporarily-lower-by-subject]\t Temporarily lower score for articles with the current subject
4370 \\[gnus-summary-temporarily-lower-by-author]\t Temporarily lower score for articles from the current author
4371 \\[gnus-summary-temporarily-lower-by-xref]\t Temporarily lower score for articles with the current cross-posting
4372 \\[gnus-summary-lower-by-subject]\t Permanently lower score for articles with the current subject
4373 \\[gnus-summary-lower-by-author]\t Permanently lower score for articles from the current author
4374 \\[gnus-summary-lower-followups-to-author]\t Permanently lower score for followups to the current author
4375 \\[gnus-summary-lower-by-thread]\t Permanently lower score for articles in the current thread
4376 \\[gnus-summary-lower-by-xref]\t Permanently lower score for articles with the current cross-posting
4379 (if gnus-visual (gnus-summary-make-menu-bar))
4380 (kill-all-local-variables)
4381 (let ((locals gnus-summary-local-variables))
4383 (if (consp (car locals))
4385 (make-local-variable (car (car locals)))
4386 (set (car (car locals)) (eval (cdr (car locals)))))
4387 (make-local-variable (car locals))
4388 (set (car locals) nil))
4389 (setq locals (cdr locals))))
4390 (gnus-update-format-specifications)
4391 (setq mode-line-modified "-- ")
4392 (make-local-variable 'mode-line-format)
4393 (setq mode-line-format (copy-sequence mode-line-format))
4394 (and (equal (nth 3 mode-line-format) " ")
4395 (setcar (nthcdr 3 mode-line-format) ""))
4396 (setq major-mode 'gnus-summary-mode)
4397 (setq mode-name "Summary")
4398 (make-local-variable 'minor-mode-alist)
4399 ; (or (assq 'gnus-show-threads minor-mode-alist)
4400 ; (setq minor-mode-alist
4401 ; (cons (list 'gnus-show-threads " Thread") minor-mode-alist)))
4402 (gnus-set-mode-line 'summary)
4403 (use-local-map gnus-summary-mode-map)
4404 (buffer-disable-undo (current-buffer))
4405 (setq buffer-read-only t) ;Disable modification
4406 (setq truncate-lines t)
4407 (setq selective-display t)
4408 (setq selective-display-ellipses t) ;Display `...'
4409 (run-hooks 'gnus-summary-mode-hook))
4411 (defun gnus-mouse-pick-article (e)
4414 (gnus-summary-next-page nil t))
4416 (defun gnus-summary-setup-buffer (group)
4417 "Initialize summary buffer."
4418 (let ((buffer (concat "*Summary " group "*")))
4419 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
4420 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
4421 (gnus-add-current-to-buffer-list)
4422 (gnus-summary-mode)))
4424 (defun gnus-set-global-variables ()
4425 ;; Set the global equivalents of the summary buffer-local variables
4426 ;; to the latest values they had. These reflect the summary buffer
4427 ;; that was in action when the last article was fetched.
4428 (if (eq major-mode 'gnus-summary-mode)
4430 (setq gnus-summary-buffer (current-buffer))
4431 (let ((name gnus-newsgroup-name)
4432 (marked gnus-newsgroup-marked)
4433 (unread gnus-newsgroup-unreads)
4434 (headers gnus-current-headers))
4436 (set-buffer gnus-group-buffer)
4437 (setq gnus-newsgroup-name name)
4438 (setq gnus-newsgroup-marked marked)
4439 (setq gnus-newsgroup-unreads unread)
4440 (setq gnus-current-headers headers))))))
4442 (defun gnus-summary-insert-dummy-line (sformat subject number)
4444 (setq sformat gnus-summary-dummy-line-format-spec))
4448 (insert (eval sformat))
4449 (add-text-properties
4451 (list 'gnus-subject (gnus-simplify-subject-re subject)
4456 (defun gnus-summary-insert-line
4457 (sformat header level current unread replied expirable subject-or-nil
4458 &optional dummy score)
4459 (or sformat (setq sformat gnus-summary-line-format-spec))
4461 (make-string (* level gnus-thread-indent-level) ? ))
4462 (lines (or (header-lines header) 0))
4463 (score (or score gnus-summary-default-score 0))
4464 (score-char (if (= score gnus-summary-default-score) ?
4465 (if (< score gnus-summary-default-score)
4466 gnus-score-below-mark gnus-score-over-mark)))
4467 (replied (if replied gnus-replied-mark ? ))
4468 (from (header-from header))
4469 (name-address (gnus-extract-address-components from))
4470 (address (car (cdr name-address)))
4471 (name (or (car name-address) (car (cdr name-address))))
4472 (number (header-number header))
4473 (subject (header-subject header))
4474 (buffer-read-only nil)
4475 (opening-bracket (if dummy ?\< ?\[))
4476 (closing-bracket (if dummy ?\> ?\]))
4478 ;; Suggested by Brian Edmonds <bedmonds@prodigy.bc.ca>.
4479 (if (not (numberp lines)) (setq lines 0))
4482 (insert-before-markers (eval sformat))
4483 (add-text-properties
4485 (list 'gnus-subject (gnus-simplify-subject-re subject)
4487 'gnus-mark (or unread gnus-unread-mark ? )
4488 'gnus-thread level))))
4490 (defun gnus-summary-update-line ()
4491 ;; Update summary line after change.
4492 (or (not gnus-summary-default-score)
4493 gnus-summary-inhibit-highlight
4495 (beginning-of-line 1)
4496 (let ((score (gnus-summary-article-score))
4497 (default gnus-summary-default-score)
4498 (below gnus-summary-mark-below))
4501 (if (eq (following-char) gnus-unread-mark)
4502 (gnus-summary-mark-article nil gnus-low-score-mark))
4503 (if (eq (following-char) gnus-low-score-mark)
4504 (gnus-summary-mark-article nil gnus-unread-mark))))
4506 (run-hooks 'gnus-visual-summary-update-hook))))))
4508 (defun gnus-summary-update-lines ()
4509 ;; Rehighlight summary buffer according to `gnus-summary-highlight'.
4510 (if (and gnus-visual gnus-visual-summary-update-hook)
4512 (set-buffer gnus-summary-buffer)
4513 (goto-char (point-min))
4515 (gnus-summary-update-line)
4516 (forward-line 1)))))
4518 (defun gnus-summary-read-group (group &optional show-all no-article kill-buffer)
4519 "Start reading news in newsgroup GROUP.
4520 If SHOW-ALL is non-nil, already read articles are also listed.
4521 If NO-ARTICLE is non-nil, no article is selected initially."
4522 (message "Retrieving newsgroup: %s..." group)
4523 (gnus-summary-setup-buffer group)
4524 (if (gnus-select-newsgroup group show-all)
4526 ;; You can change the subjects in this hook.
4527 (run-hooks 'gnus-select-group-hook)
4528 ;; Do Score Processing.
4529 (gnus-score-headers)
4530 ;; Update the format specifiers.
4531 (gnus-update-format-specifications)
4532 (gnus-summary-prepare)
4533 (if (and (zerop (buffer-size))
4534 gnus-newsgroup-dormant)
4535 (gnus-summary-show-all-dormant))
4536 (gnus-set-global-variables)
4537 ;; Function `gnus-apply-kill-file' must be called in this hook.
4538 (run-hooks 'gnus-apply-kill-hook)
4539 (if (zerop (buffer-size))
4541 ;; This newsgroup is empty.
4542 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
4543 (message "No unread news"))
4544 ;; Hide conversation thread subtrees. We cannot do this in
4545 ;; gnus-summary-prepare-hook since kill processing may not
4546 ;; work with hidden articles.
4547 (and gnus-show-threads
4548 gnus-thread-hide-subtree
4549 (gnus-summary-hide-all-threads))
4550 ;; Show first unread article if requested.
4551 (goto-char (point-min))
4552 (if (and (not no-article)
4553 gnus-auto-select-first
4554 (gnus-summary-first-unread-article))
4555 (gnus-configure-windows 'article)
4556 (gnus-configure-windows 'summary))
4557 (pop-to-buffer gnus-summary-buffer)
4558 (gnus-set-mode-line 'summary)
4559 (gnus-summary-position-cursor)
4560 (if (and kill-buffer
4561 (get-buffer kill-buffer)
4562 (buffer-name (get-buffer kill-buffer)))
4563 (kill-buffer kill-buffer))))
4564 ;; Cannot select newsgroup GROUP.
4565 (message "Couldn't select newsgroup")
4566 (and (eq major-mode 'gnus-summary-mode)
4567 (kill-buffer (current-buffer)))
4568 (switch-to-buffer gnus-group-buffer)))
4570 (defun gnus-summary-prepare ()
4571 "Prepare summary list of current newsgroup in summary buffer."
4572 (let ((buffer-read-only nil))
4574 (gnus-summary-prepare-threads
4575 (if gnus-show-threads
4576 (gnus-gather-threads (gnus-sort-threads (gnus-make-threads)))
4577 gnus-newsgroup-headers)
4579 (gnus-summary-remove-dormant-lines)
4580 ;; Erase header retrieval message.
4582 ;; Call hooks for modifying summary buffer.
4583 ;; Suggested by sven@tde.LTH.Se (Sven Mattisson).
4584 (goto-char (point-min))
4585 (run-hooks 'gnus-summary-prepare-hook)))
4587 (defun gnus-summary-remove-dormant-lines ()
4588 (let ((int gnus-newsgroup-dormant)
4589 (buffer-read-only nil)
4592 (if (gnus-summary-goto-subject (car int))
4595 (setq cur-level (gnus-summary-thread-level))
4597 (re-search-forward "[\n\r]")
4598 (if (<= (gnus-summary-thread-level) cur-level)
4599 ;; If the level of the next article is greater than the
4600 ;; level of this article, then it has to be the child of this
4601 ;; article, so we do not delete this article.
4603 (setq gnus-newsgroup-dormant-subjects
4604 (cons (cons (car int) (buffer-substring beg (point)))
4605 gnus-newsgroup-dormant-subjects))
4606 (delete-region beg (point))))))
4607 (setq int (cdr int)))))
4609 (defun gnus-gather-threads (threads)
4610 "Gather threads that have lost their roots."
4611 (if (not gnus-summary-make-false-root)
4613 (let ((hashtb (gnus-make-hashtable 1023))
4616 thread subject hthread unre-subject whole-subject)
4618 (setq subject (header-subject (car (car threads)))
4619 whole-subject subject)
4620 (and gnus-summary-gather-subject-limit
4621 (> (length subject) gnus-summary-gather-subject-limit)
4623 (substring subject 0 gnus-summary-gather-subject-limit)))
4626 (setq unre-subject (gnus-simplify-subject-re subject))
4629 (or (stringp (car (car hthread)))
4630 (setcar hthread (list whole-subject (car hthread))))
4631 (setcdr (car hthread) (nconc (cdr (car hthread))
4632 (list (car threads))))
4633 (setcdr prev (cdr threads))
4634 (setq threads prev))
4635 (gnus-sethash unre-subject threads hashtb))
4637 (setq threads (cdr threads)))
4640 (defun gnus-make-threads ()
4641 ;; This function takes the dependencies already made by
4642 ;; `gnus-get-newsgroup-headers' and builds the trees. First we go
4643 ;; through the dependecies in the hash table and finds all the
4644 ;; roots. Roots do not refer back to any valid articles.
4646 (and gnus-fetch-old-headers (eq gnus-headers-retrieved-by 'nov)
4647 (gnus-build-old-threads))
4650 (if (not (car (symbol-value refs)))
4651 (setq roots (append (cdr (symbol-value refs)) roots))
4652 ;; Ok, these refer back to valid articles, but if
4653 ;; `gnus-thread-ignore-subject' is nil, we have to check that
4654 ;; the root has the same subject as its children. The children
4655 ;; that do not are made into roots and removed from the list
4657 (or gnus-thread-ignore-subject
4658 (let* ((prev (symbol-value refs))
4659 (subject (gnus-simplify-subject-re
4660 (header-subject (car prev))))
4661 (headers (cdr prev)))
4663 (if (not (string= subject
4664 (gnus-simplify-subject-re
4665 (header-subject (car headers)))))
4667 (setq roots (cons (car headers) roots))
4668 (setcdr prev (cdr headers)))
4669 (setq prev headers))
4670 (setq headers (cdr headers)))))))
4671 gnus-newsgroup-dependencies)
4673 (mapcar (lambda (root) (gnus-trim-thread (gnus-make-sub-thread root)))
4676 (defun gnus-trim-thread (thread)
4677 (if (and (eq gnus-fetch-old-headers 'some)
4678 (memq (header-number (car thread)) gnus-newsgroup-ancient)
4679 (= (length thread) 2))
4680 (gnus-trim-thread (nth 1 thread))
4683 (defun gnus-make-sub-thread (root)
4684 ;; This function makes a sub-tree for a node in the tree.
4685 (let ((children (reverse (cdr (gnus-gethash (downcase (header-id root))
4686 gnus-newsgroup-dependencies)))))
4687 (cons root (mapcar 'gnus-make-sub-thread children))))
4689 (defun gnus-build-old-threads ()
4690 ;; Look at all the articles that refer back to old articles, and
4691 ;; fetch the headers for the articles that aren't there. This will
4692 ;; build complete threads - if the roots haven't been expired by the
4697 (if (not (car (symbol-value refs)))
4699 (setq heads (cdr (symbol-value refs)))
4701 (if (not (memq (header-number (car heads))
4702 gnus-newsgroup-dormant))
4704 (setq id (symbol-name refs))
4705 (while (and (setq id (gnus-build-get-header id))
4706 (not (car (gnus-gethash
4707 id gnus-newsgroup-dependencies)))))
4709 (setq heads (cdr heads)))))))
4710 gnus-newsgroup-dependencies)))
4712 (defun gnus-build-get-header (id)
4713 ;; Look through the buffer of NOV lines and find the header to
4714 ;; ID. Enter this line into the dependencies hash table, and return
4715 ;; the id of the parent article (if any).
4716 (let ((deps gnus-newsgroup-dependencies)
4720 (set-buffer nntp-server-buffer)
4721 (goto-char (point-min))
4722 (while (and (not found) (search-forward id nil t))
4724 (setq found (looking-at (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4725 (regexp-quote id))))
4726 (or found (beginning-of-line 2)))
4731 (setq header (gnus-nov-parse-line
4732 (read (current-buffer)) deps))
4733 (setq ref (header-references header))
4734 (string-match "\\(<[^>]+>\\) *$" ref)
4735 (substring ref (match-beginning 1) (match-end 1))))))
4737 (setq gnus-newsgroup-headers (cons header gnus-newsgroup-headers)
4738 gnus-newsgroup-ancient (cons (header-number header)
4739 gnus-newsgroup-ancient))))))
4741 (defun gnus-sort-threads (threads)
4742 ;; Sort threads as specified in `gnus-thread-sort-functions'.
4743 (let ((fun gnus-thread-sort-functions))
4745 (setq threads (sort threads (car fun))
4749 (defun gnus-thread-header (thread)
4750 ;; Return header of first article in THREAD.
4752 (if (stringp (car thread))
4753 (car (car (cdr thread)))
4757 (defun gnus-thread-sort-by-number (h1 h2)
4758 "Sort threads by root article number."
4759 (let ((h1 (gnus-thread-header h1))
4760 (h2 (gnus-thread-header h2)))
4761 (< (header-number h1) (header-number h2))))
4763 (defun gnus-thread-sort-by-author (h1 h2)
4764 "Sort threads by root author."
4765 (let ((h1 (gnus-thread-header h1))
4766 (h2 (gnus-thread-header h2)))
4768 (let ((extract (gnus-extract-address-components (header-from h1))))
4769 (or (car extract) (cdr extract)))
4770 (let ((extract (gnus-extract-address-components (header-from h2))))
4771 (or (car extract) (cdr extract))))))
4773 (defun gnus-thread-sort-by-subject (h1 h2)
4774 "Sort threads by root subject."
4775 (let ((h1 (gnus-thread-header h1))
4776 (h2 (gnus-thread-header h2)))
4778 (downcase (gnus-simplify-subject (header-subject h1)))
4779 (downcase (gnus-simplify-subject (header-subject h2))))))
4781 (defun gnus-thread-sort-by-date (h1 h2)
4782 "Sort threads by root article date."
4783 (let ((h1 (gnus-thread-header h1))
4784 (h2 (gnus-thread-header h2)))
4786 (gnus-sortable-date (header-date h1))
4787 (gnus-sortable-date (header-date h2)))))
4789 (defun gnus-thread-sort-by-score (h1 h2)
4790 "Sort threads by root article score.
4791 Unscored articles will be counted as havin a score of zero."
4792 (let ((h1 (gnus-thread-header h1))
4793 (h2 (gnus-thread-header h2)))
4794 (let ((s1 (assq (header-number h1) gnus-newsgroup-scored))
4795 (s2 (assq (header-number h2) gnus-newsgroup-scored)))
4796 (> (or (cdr s1) gnus-summary-default-score 0)
4797 (or (cdr s2) gnus-summary-default-score 0)))))
4799 (defun gnus-thread-sort-by-total-score (h1 h2)
4800 "Sort threads by the sum of all scores in the thread.
4801 Unscored articles will be counted as havin a score of zero."
4802 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4804 (defun gnus-thread-total-score (thread)
4805 ;; This function find the total score of THREAD.
4807 (if (stringp (car thread))
4808 (apply gnus-thread-score-function 0
4809 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4810 (gnus-thread-total-score-1 thread))
4811 (gnus-thread-total-score-1 (list thread))))
4813 (defun gnus-thread-total-score-1 (root)
4814 ;; This function find the total score of the thread below ROOT.
4815 (setq root (car root))
4816 (apply gnus-thread-score-function
4817 (or (cdr (assq (header-number root) gnus-newsgroup-scored))
4818 gnus-summary-default-score 0)
4819 (mapcar 'gnus-thread-total-score
4820 (cdr (gnus-gethash (downcase (header-id root))
4821 gnus-newsgroup-dependencies)))))
4823 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4824 (defvar gnus-tmp-prev-subject "")
4825 (defvar gnus-tmp-prev-dormant nil)
4827 ;; Basic ideas by Paul Dworkin <paul@media-lab.media.mit.edu>.
4828 (defun gnus-summary-prepare-threads
4829 (threads level &optional not-child no-subject)
4830 "Prepare summary buffer from THREADS and indentation LEVEL.
4831 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4832 or a straight list of headers."
4833 (let (thread header number subject clevel)
4835 (setq thread (car threads)
4836 threads (cdr threads))
4837 ;; If `thread' is a cons, hierarchical threads are used. If not,
4838 ;; `thread' is the header.
4840 (setq header (car thread))
4841 (setq header thread))
4842 (if (stringp header)
4843 ;; The header is a dummy root.
4845 (cond ((eq gnus-summary-make-false-root 'adopt)
4846 ;; We let the first article adopt the rest.
4847 (gnus-summary-prepare-threads (list (car (cdr thread))) 0)
4848 (setq thread (cdr (cdr thread)))
4850 (gnus-summary-prepare-threads (list (car thread)) 1 t)
4851 (setq thread (cdr thread))))
4852 ((eq gnus-summary-make-false-root 'dummy)
4853 ;; We output a dummy root.
4854 (gnus-summary-insert-dummy-line
4855 nil header (header-number (car (car (cdr thread)))))
4857 ((eq gnus-summary-make-false-root 'empty)
4858 ;; We print the articles with empty subject fields.
4859 (gnus-summary-prepare-threads (list (car (cdr thread))) 0)
4860 (setq thread (cdr (cdr thread)))
4862 (gnus-summary-prepare-threads (list (car thread)) 0 nil
4863 (not gnus-tmp-prev-dormant))
4864 (setq thread (cdr thread))))
4866 ;; We do not make a root for the gathered
4867 ;; sub-threads at all.
4869 ;; Print the sub-threads.
4870 (and (consp thread) (cdr thread)
4871 (gnus-summary-prepare-threads (cdr thread) clevel)))
4872 ;; The header is a real article.
4873 (setq number (header-number header)
4874 subject (header-subject header)
4875 gnus-tmp-prev-dormant (memq number gnus-newsgroup-dormant))
4876 (gnus-summary-insert-line
4877 nil header level nil
4878 (cond ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
4879 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
4880 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
4881 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
4882 (t gnus-ancient-mark))
4883 (memq number gnus-newsgroup-replied)
4884 (memq number gnus-newsgroup-expirable)
4885 (if no-subject gnus-summary-same-subject
4886 (if (or (zerop level)
4887 (and gnus-thread-ignore-subject
4889 (gnus-simplify-subject-re gnus-tmp-prev-subject)
4890 (gnus-simplify-subject-re subject)))))
4892 gnus-summary-same-subject))
4894 (cdr (assq number gnus-newsgroup-scored)))
4895 (setq gnus-tmp-prev-subject subject)
4896 ;; Recursively print subthreads.
4897 (and (consp thread) (cdr thread)
4898 (gnus-summary-prepare-threads (cdr thread) (1+ level)))))))
4900 (defun gnus-select-newsgroup (group &optional read-all)
4901 "Select newsgroup GROUP.
4902 If READ-ALL is non-nil, all articles in the group are selected."
4903 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4904 (info (nth 2 entry))
4905 articles header-marks)
4906 (and (eq (car entry) t)
4907 (or (gnus-activate-newsgroup (car info))
4909 (kill-buffer (current-buffer))
4910 (error "Couldn't request newsgroup %s" group))))
4911 (setq gnus-current-select-method (or (nth 4 info) gnus-select-method))
4912 (gnus-check-news-server (nth 4 info))
4913 (or (gnus-request-group group t)
4915 (kill-buffer (current-buffer))
4916 (error "Couldn't request newsgroup %s" group)))
4918 ;; Initialize the buffer that holds lines that have been removed
4919 ;; from the summary buffer.
4922 (setq gnus-newsgroup-expunged-buffer
4923 (get-buffer-create (format " *gnus expunge %s*" group))))
4924 (buffer-disable-undo (current-buffer))
4926 (gnus-add-current-to-buffer-list))
4928 (setq gnus-newsgroup-name group)
4929 (setq gnus-newsgroup-unselected nil)
4930 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4934 (gnus-adjust-marked-articles info)
4935 (setq gnus-newsgroup-marked
4936 (cdr (assq 'tick (setq marked (nth 3 info)))))
4937 (setq gnus-newsgroup-replied (cdr (assq 'reply marked)))
4938 (setq gnus-newsgroup-expirable (cdr (assq 'expire marked)))
4939 (setq gnus-newsgroup-killed (cdr (assq 'killed marked)))
4940 (setq gnus-newsgroup-bookmarks (cdr (assq 'bookmark marked)))
4941 (setq gnus-newsgroup-dormant (cdr (assq 'dormant marked)))
4942 (setq gnus-newsgroup-scored (cdr (assq 'score marked)))
4943 (setq gnus-newsgroup-processable nil)))
4945 (if (not (setq articles (gnus-articles-to-read group read-all)))
4947 ;; Init the dependencies hash table.
4948 (setq gnus-newsgroup-dependencies
4949 (gnus-make-hashtable (length gnus-newsgroup-unreads)))
4950 ;; Retrieve the headers and read them in.
4951 (setq gnus-newsgroup-headers
4952 (if (eq 'nov (setq gnus-headers-retrieved-by
4953 (gnus-retrieve-headers
4954 (if gnus-fetch-old-headers
4955 (cons 1 articles) articles)
4956 gnus-newsgroup-name)))
4958 (gnus-get-newsgroup-headers-xover articles))
4959 (gnus-get-newsgroup-headers)))
4960 ;; If we were to fetch old headers, but the backend didn't
4961 ;; support XOVER, then it is possible we fetched one article
4962 ;; that we shouldn't have. If that's the case, we pop it off the
4964 (and (not (eq gnus-headers-retrieved-by 'nov))
4965 gnus-fetch-old-headers
4966 gnus-newsgroup-headers
4967 (/= (header-number (car gnus-newsgroup-headers)) (car articles))
4968 (setq gnus-newsgroup-headers (cdr gnus-newsgroup-headers)))
4969 ;; Remove cancelled articles from the list of unread articles.
4970 (setq gnus-newsgroup-unreads
4972 gnus-newsgroup-unreads
4973 (mapcar (lambda (headers) (header-number headers))
4974 gnus-newsgroup-headers)))
4975 ;; Check whether auto-expire is to be done in this group.
4976 (setq gnus-newsgroup-auto-expire
4977 (and (stringp gnus-auto-expirable-newsgroups)
4978 (string-match gnus-auto-expirable-newsgroups
4979 (gnus-group-real-name group))))
4980 ;; First and last article in this newsgroup.
4981 (and gnus-newsgroup-headers
4982 (setq gnus-newsgroup-begin
4983 (header-number (car gnus-newsgroup-headers)))
4984 (setq gnus-newsgroup-end
4985 (header-number (gnus-last-element gnus-newsgroup-headers))))
4986 (setq gnus-reffed-article-number -1)
4987 ;; GROUP is successfully selected.
4988 (or gnus-newsgroup-headers t))))
4990 (defun gnus-articles-to-read (group read-all)
4991 ;; Find out what articles the user wants to read.
4993 ;; Select all articles if `read-all' is non-nil, or if all the
4994 ;; unread articles are dormant articles.
4996 (= (length gnus-newsgroup-unreads)
4997 (length gnus-newsgroup-scored)))
4998 (gnus-uncompress-sequence
4999 (gnus-gethash group gnus-active-hashtb))
5000 gnus-newsgroup-unreads))
5001 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5002 (scored (length scored-list))
5003 (number (length articles))
5004 (marked (+ (length gnus-newsgroup-marked)
5005 (length gnus-newsgroup-dormant)))
5008 (cond ((and (or (<= scored marked)
5010 (numberp gnus-large-newsgroup)
5011 (> number gnus-large-newsgroup))
5015 "How many articles from %s (default %d): "
5016 gnus-newsgroup-name number))))
5017 (if (string-equal input "")
5019 ((and (> scored marked) (< scored number))
5023 "%s %s (%d scored, %d total, %d default): "
5024 "How many articles from"
5025 group scored number scored))))
5026 (if (string-equal input "")
5030 (setq select (if (numberp select) select (string-to-number select)))
5033 (if (and (not (zerop scored)) (<= (abs select) scored))
5035 (setq articles (sort scored-list '<))
5036 (setq number (length articles)))
5037 (setq articles (copy-sequence articles)))
5039 (if (< (abs select) number)
5041 ;; Select the N oldest articles.
5042 (setcdr (nthcdr (1- (abs select)) articles) nil)
5043 ;; Select the N most recent articles.
5044 (setq articles (nthcdr (- number select) articles))))
5045 (setq gnus-newsgroup-unselected
5046 (gnus-set-difference gnus-newsgroup-unreads articles))
5049 (defun gnus-killed-articles (killed articles)
5052 (if (inline (gnus-member-of-range (car articles) killed))
5053 (setq out (cons (car articles) out)))
5054 (setq articles (cdr articles)))
5057 (defun gnus-adjust-marked-articles (info)
5058 "Remove all marked articles that are no longer legal."
5059 (let ((marked-lists (nth 3 info))
5060 (active (gnus-gethash (car info) gnus-active-hashtb))
5062 ;; There are four types of marked articles - ticked, replied,
5063 ;; expirable and dormant.
5065 (setq m (cdr (setq prev (car marked-lists))))
5066 (cond ((or (eq 'tick (car prev)) (eq 'dormant (car prev)))
5067 ;; Make sure that all ticked articles are a subset of the
5068 ;; unread/unselected articles.
5070 (if (or (memq (car m) gnus-newsgroup-unreads)
5071 (memq (car m) gnus-newsgroup-unselected))
5073 (setcdr prev (cdr m)))
5075 ((eq 'score (car prev))
5076 ;; Scored articles should be a subset of
5077 ;; unread/unselected articles.
5079 (if (or (memq (car (car m)) gnus-newsgroup-unreads)
5080 (memq (car (car m)) gnus-newsgroup-unreads))
5082 (setcdr prev (cdr m)))
5084 ((eq 'bookmark (car prev))
5085 ;; Bookmarks should be a subset of active articles.
5087 (if (< (car (car m)) (car active))
5088 (setcdr prev (cdr m))
5091 ((eq 'killed (car prev))
5092 ;; Articles that have been through the kill process are
5093 ;; to be a subset of active articles.
5094 (while (and m (< (cdr (car m)) (car active)))
5095 (setcdr prev (cdr m))
5097 (if (and m (< (car (car m)) (car active)))
5098 (setcar (car m) (car active))))
5099 ((or (eq 'reply (car marked)) (eq 'expire (car marked)))
5100 ;; The replied and expirable articles have to be articles
5103 (if (< (car m) (car active))
5104 (setcdr prev (cdr m))
5107 (setq marked-lists (cdr marked-lists)))
5108 ;; Remove all lists that are empty.
5109 (setq marked-lists (nth 3 info))
5112 (while (= 1 (length (car marked-lists)))
5113 (setq marked-lists (cdr marked-lists)))
5114 (setq m (cdr (setq prev marked-lists)))
5116 (if (= 1 (length (car m)))
5117 (setcdr prev (cdr m))
5120 (setcar (nthcdr 3 info) marked-lists)))
5121 ;; Finally, if there are no marked lists at all left, and if there
5122 ;; are no elements after the lists in the info list, we just chop
5123 ;; the info list off before the marked lists.
5124 (if (and (null marked-lists) (not (nthcdr 4 info)))
5125 (setcdr (nthcdr 2 info) nil)))
5128 (defun gnus-set-marked-articles
5129 (info ticked replied expirable killed dormant bookmark score)
5130 "Enter the various lists of marked articles into the newsgroup info list."
5132 (and ticked (setq newmarked (cons (cons 'tick ticked) nil)))
5133 (and replied (setq newmarked (cons (cons 'reply replied) newmarked)))
5134 (and expirable (setq newmarked (cons (cons 'expire expirable)
5136 (and killed (setq newmarked (cons (cons 'killed killed) newmarked)))
5137 (and dormant (setq newmarked (cons (cons 'dormant dormant) newmarked)))
5138 (and bookmark (setq newmarked (cons (cons 'bookmark bookmark)
5140 (and score (setq newmarked (cons (cons 'score score) newmarked)))
5143 (setcar (nthcdr 3 info) newmarked)
5144 (if (not (nthcdr 4 info))
5145 (setcdr (nthcdr 2 info) nil)
5146 (setcar (nthcdr 3 info) nil)))
5148 (setcdr (nthcdr 2 info) (cons newmarked nil))))))
5150 (defun gnus-add-marked-articles (group type articles &optional info force)
5151 ;; Add ARTICLES of TYPE to the info of GROUP.
5152 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
5153 ;; add, but replace this marked articles of TYPE with ARTICLES.
5154 (let ((info (or info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
5157 (and (not (setq marked (nthcdr 3 info)))
5158 (setcdr (nthcdr 2 info) (list (list (cons type articles)))))
5159 (and (not (setq m (assq type (car marked))))
5160 (setcar marked (cons (cons type articles) (car marked))))
5163 (nconc m articles)))))
5165 (defun gnus-set-mode-line (where)
5166 "This function sets the mode line of the article or summary buffers.
5167 If WHERE is `summary', the summary mode line format will be used."
5168 (if (memq where gnus-updated-mode-lines)
5171 (set-buffer gnus-summary-buffer)
5172 (let* ((mformat (if (eq where 'article)
5173 gnus-article-mode-line-format-spec
5174 gnus-summary-mode-line-format-spec))
5175 (group-name gnus-newsgroup-name)
5176 (article-number (or gnus-current-article 0))
5177 (unread (- (length gnus-newsgroup-unreads)
5178 (length gnus-newsgroup-dormant)))
5179 (unselected (length gnus-newsgroup-unselected))
5180 (unread-and-unselected
5181 (cond ((and (zerop unread) (zerop unselected)) "")
5182 ((zerop unselected) (format "{%d more}" unread))
5183 (t (format "{%d(+%d) more}" unread unselected))))
5185 (if gnus-current-headers
5186 (header-subject gnus-current-headers) ""))
5187 (max-len (if (eq where 'summary) 59 59)))
5188 (setq mode-string (eval mformat))
5189 (if (> (length mode-string) max-len)
5191 (concat (substring mode-string 0 (- max-len 3)) "...")))
5192 (setq mode-string (format (format "%%-%ds" max-len 5)
5194 (setq mode-line-buffer-identification mode-string)
5195 (set-buffer-modified-p t))))
5197 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5198 "Go through the HEADERS list and add all Xrefs to a hash table.
5199 The resulting hash table is returned, or nil if no Xrefs were found."
5200 (let* ((from-method (gnus-find-method-for-group from-newsgroup))
5202 (gnus-group-foreign-p from-newsgroup)
5204 (assoc (symbol-name (car from-method))
5205 gnus-valid-select-methods))))
5206 (gnus-group-real-prefix from-newsgroup)))
5207 (xref-hashtb (make-vector 63 0))
5208 start group entry number xrefs header)
5210 (setq header (car headers))
5211 (if (and (setq xrefs (header-xref header))
5212 (not (memq (header-number header) unreads)))
5215 (while (string-match "\\([^ ]+\\):\\([0-9]+\\)" xrefs start)
5216 (setq start (match-end 0))
5217 (setq group (concat prefix (substring xrefs (match-beginning 1)
5220 (string-to-int (substring xrefs (match-beginning 2)
5222 (if (setq entry (gnus-gethash group xref-hashtb))
5223 (setcdr entry (cons number (cdr entry)))
5224 (gnus-sethash group (cons number nil) xref-hashtb)))))
5225 (setq headers (cdr headers)))
5226 (if start xref-hashtb nil)))
5228 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads expirable)
5229 "Look through all the headers and mark the Xrefs as read."
5230 (let (name entry read info xref-hashtb idlist active num range exps method)
5231 (set-buffer gnus-group-buffer)
5232 (if (setq xref-hashtb
5233 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5236 (if (string= from-newsgroup (setq name (symbol-name group)))
5238 (setq idlist (symbol-value group))
5239 ;; Dead groups are not updated.
5240 (if (and (setq entry (gnus-gethash name gnus-newsrc-hashtb))
5241 ;; Only do the xrefs if the group has the same
5242 ;; select method as the group we have just read.
5243 (or (and (not (nth 4 (setq info (nth 2 entry))))
5244 (eq (gnus-find-method-for-group from-newsgroup)
5245 gnus-select-method))
5248 (car (gnus-find-method-for-group
5250 gnus-valid-select-methods))
5252 (setq method (gnus-find-method-for-group
5254 (and (equal (car (nth 4 info)) (car method))
5255 (equal (nth 1 (nth 4 info)) (nth 1 method))))
5256 gnus-use-cross-reference
5257 (or (not (eq gnus-use-cross-reference t))
5258 (<= (nth 1 info) 5)))
5261 ;; Set the new list of read articles in this group.
5262 (setq active (gnus-gethash name gnus-active-hashtb))
5263 ;; First peel off all illegal article numbers.
5266 (ticked (cdr (memq 'tick (nth 3 info))))
5267 (dormant (cdr (memq 'dormant (nth 3 info))))
5272 (if (or (> id (cdr active))
5276 (setq idlist (delq id idlist)))
5277 (and (memq id expirable)
5278 (setq exps (cons id exps)))
5279 (setq ids (cdr ids)))))
5280 ;; Update expirable articles.
5281 (gnus-add-marked-articles nil 'expirable exps info)
5282 (setcar (nthcdr 2 info)
5286 (setq idlist (sort idlist '<)))))
5287 ;; Then we have to re-compute how many unread
5288 ;; articles there are in this group.
5291 (if (atom (car range))
5293 (setq num (- (1+ (cdr active)) (car active)))
5294 (setq num (- (cdr active) (- (1+ (cdr range))
5297 (setq num (+ num (- (1+ (cdr (car range)))
5298 (car (car range)))))
5299 (setq range (cdr range)))
5300 (setq num (- (cdr active) num)))
5301 ;; Update the number of unread articles.
5304 (max 0 (- num (length
5305 (cdr (memq 'tick (nth 3 info))) )
5306 (length (cdr (memq 'dormant
5308 ;; Update the group buffer.
5309 (gnus-group-update-group name t)))))))
5312 (defsubst gnus-header-value ()
5313 (buffer-substring (match-end 0) (save-excursion (end-of-line) (point))))
5315 (defun gnus-get-newsgroup-headers ()
5316 (setq gnus-article-internal-prepare-hook nil)
5317 (let ((cur nntp-server-buffer)
5318 (dependencies gnus-newsgroup-dependencies)
5320 headers char article id dep end)
5322 (set-buffer nntp-server-buffer)
5324 ;; Search to the beginning of the next header. Error messages
5325 ;; do not begin with 2 or 3.
5326 (while (re-search-forward "^[23][0-9]+ " nil t)
5327 (let ((header (make-vector 9 nil))
5328 (c (following-char))
5329 (case-fold-search t)
5331 from subject in-reply-to references ref)
5337 (header-set-number header (setq article (read cur)))
5338 ;; This implementation of this function, with nine
5339 ;; search-forwards instead of the one re-search-forward and
5340 ;; a case (which basically was the old function) is actually
5341 ;; about twice as fast, even though it looks messier. You
5342 ;; can't have everything, I guess. Speed and elegance
5343 ;; doesn't always come hand in hand.
5345 (narrow-to-region (point) (save-excursion
5346 (search-forward "\n.\n" nil t)))
5347 (if (search-forward "\nfrom: " nil t)
5348 (header-set-from header (gnus-header-value))
5349 (header-set-from header "(nobody)"))
5351 (if (search-forward "\nsubject: " nil t)
5352 (header-set-subject header (gnus-header-value))
5353 (header-set-subject header "(none)"))
5355 (and (search-forward "\nxref: " nil t)
5356 (header-set-xref header (gnus-header-value)))
5358 (and (search-forward "\nlines: " nil t)
5359 (header-set-lines header (read cur)))
5361 (and (search-forward "\ndate: " nil t)
5362 (header-set-date header (gnus-header-value)))
5364 (if (search-forward "\nmessage-id: " nil t)
5365 (header-set-id header (setq id (gnus-header-value)))
5366 ;; If there was no message-id, we just fake one to make
5367 ;; subsequent routines simpler.
5370 (setq id (concat "none+" (int-to-string
5371 (setq none-id (1+ none-id)))))))
5373 (if (search-forward "\nreferences: " nil t)
5375 (header-set-references header (gnus-header-value))
5376 (setq end (match-end 0))
5383 (search-backward ">" end t)
5386 (search-backward "<" end t)
5388 ;; Get the references from the in-reply-to header if there
5389 ;; ware no references and the in-reply-to header looks
5391 (if (and (search-forward "\nin-reply-to: " nil t)
5392 (setq in-reply-to (gnus-header-value))
5393 (string-match "<[^>]+>" in-reply-to))
5395 (header-set-references
5397 (setq ref (substring in-reply-to (match-beginning 0)
5399 (setq ref (downcase ref)))
5401 ;; We do some threading while we read the headers. The
5402 ;; message-id and the last reference are both entered into
5403 ;; the same hash table. Some tippy-toeing around has to be
5404 ;; done in case an article has arrived before the article
5405 ;; which it refers to.
5406 (if (boundp (setq dep (intern (downcase id) dependencies)))
5407 (if (car (symbol-value dep))
5408 ;; An article with this Message-ID has already
5409 ;; been seen, so we ignore this one, except we add
5410 ;; any additional Xrefs (in case the two articles
5411 ;; came from different servers.
5414 (car (symbol-value dep))
5415 (concat (or (header-xref (car (symbol-value dep))) "")
5416 (or (header-xref header) "")))
5418 (setcar (symbol-value dep) header))
5419 (set dep (list header)))
5422 (if (boundp (setq dep (intern ref dependencies)))
5423 (setcdr (symbol-value dep)
5424 (cons header (cdr (symbol-value dep))))
5425 (set dep (list nil header)))
5426 (setq headers (cons header headers))))
5427 (goto-char (point-max))))))
5428 (nreverse headers)))
5430 ;; The following macros and functions were written by Felix Lee
5431 ;; <flee@cse.psu.edu>.
5433 ;; This is almost 4x faster than (string-to-int (buffer-substring ... ))
5434 ;; primarily because of garbage collection. -jwz
5435 (defmacro gnus-read-integer (&optional point move-p)
5436 (` ((, (if move-p 'progn 'save-excursion))
5437 (,@ (if point (list (list 'goto-char point))))
5438 (if (and (<= (following-char) ?9)
5439 (>= (following-char) ?0))
5440 (read (current-buffer))
5443 (defmacro gnus-nov-skip-field ()
5444 '(search-forward "\t" eol 'end))
5446 (defmacro gnus-nov-field ()
5449 (progn (gnus-nov-skip-field) (1- (point)))))
5451 ;; Goes through the xover lines and returns a list of vectors
5452 (defun gnus-get-newsgroup-headers-xover (sequence)
5453 "Parse the news overview data in the server buffer, and return a
5454 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
5455 ;; Get the Xref when the users reads the articles since most/some
5456 ;; NNTP servers do not include Xrefs when using XOVER.
5457 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5458 (let ((cur nntp-server-buffer)
5459 (dependencies gnus-newsgroup-dependencies)
5461 number headers header)
5463 (set-buffer nntp-server-buffer)
5464 (goto-char (point-min))
5465 (while (and sequence (not (eobp)))
5466 (setq number (read cur))
5467 (while (and sequence (< (car sequence) number))
5468 (setq sequence (cdr sequence)))
5470 (eq number (car sequence))
5472 (setq sequence (cdr sequence))
5474 (inline (gnus-nov-parse-line number dependencies)))
5475 (setq headers (cons header headers)))))
5477 (setq headers (nreverse headers)))
5480 (defun gnus-nov-parse-line (number dependencies)
5481 "Point has to be after the number on the beginning of the line."
5483 header eol ref id dep)
5488 ;; overview: [num subject from date id refs chars lines misc]
5492 (gnus-nov-field) ; subject
5493 (gnus-nov-field) ; from
5494 (gnus-nov-field) ; date
5495 (setq id (gnus-nov-field)) ; id
5498 (let ((beg (point)))
5499 (search-forward "\t" eol)
5500 (if (search-backward ">" beg t)
5506 (search-backward "<" beg t)
5509 (gnus-nov-field)) ; refs
5510 (read (current-buffer)) ; chars
5511 (read (current-buffer)) ; lines
5512 (if (/= (following-char) ?\t)
5515 (gnus-nov-field)) ; misc
5517 ;; We build the thread tree.
5522 (or id (concat "none+"
5524 (setq none (1+ none))))))
5526 (if (car (symbol-value dep))
5527 ;; An article with this Message-ID has already been seen,
5528 ;; so we ignore this one, except we add any additional
5529 ;; Xrefs (in case the two articles came from different
5533 (car (symbol-value dep))
5534 (concat (or (header-xref (car (symbol-value dep))) "")
5535 (or (header-xref header) "")))
5537 (setcar (symbol-value dep) header))
5538 (set dep (list header)))
5541 (if (boundp (setq dep (intern (or ref "none")
5543 (setcdr (symbol-value dep)
5544 (cons header (cdr (symbol-value dep))))
5545 (set dep (list nil header)))))
5548 (defun gnus-article-get-xrefs ()
5549 "Fill in the Xref value in `gnus-current-headers', if necessary.
5550 This is meant to be called in `gnus-article-internal-prepare-hook'."
5551 (or (not gnus-use-cross-reference)
5552 (header-xref gnus-current-headers)
5553 (let ((case-fold-search t)
5556 (gnus-narrow-to-headers)
5557 (goto-char (point-min))
5558 (if (or (and (eq (downcase (following-char)) ?x)
5559 (looking-at "Xref:"))
5560 (search-forward "\nXref:" nil t))
5562 (goto-char (1+ (match-end 0)))
5563 (setq xref (buffer-substring (point)
5564 (progn (end-of-line) (point))))
5566 (set-buffer gnus-summary-buffer)
5567 (header-set-xref gnus-current-headers xref))))))))
5569 (defalias 'gnus-find-header-by-number 'gnus-get-header-by-number)
5570 (make-obsolete 'gnus-find-header-by-number 'gnus-get-header-by-number)
5572 ;; Return a header specified by a NUMBER.
5573 (defun gnus-get-header-by-number (number)
5575 (set-buffer gnus-summary-buffer)
5576 (or gnus-newsgroup-headers-hashtb-by-number
5577 (gnus-make-headers-hashtable-by-number))
5578 (gnus-gethash (int-to-string number)
5579 gnus-newsgroup-headers-hashtb-by-number)))
5581 (defun gnus-make-headers-hashtable-by-number ()
5582 "Make hashtable for the variable gnus-newsgroup-headers by number."
5584 (set-buffer gnus-summary-buffer)
5585 (let ((headers gnus-newsgroup-headers)
5587 (setq gnus-newsgroup-headers-hashtb-by-number
5588 (gnus-make-hashtable (length headers)))
5590 (setq header (car headers))
5591 (gnus-sethash (int-to-string (header-number header))
5592 header gnus-newsgroup-headers-hashtb-by-number)
5593 (setq headers (cdr headers))))))
5595 (defun gnus-more-header-backward ()
5596 "Find new header backward."
5597 (let ((first (car (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
5598 (artnum gnus-newsgroup-begin)
5600 (while (and (not header)
5602 (setq artnum (1- artnum))
5603 (setq header (gnus-read-header artnum)))
5606 (defun gnus-more-header-forward ()
5607 "Find new header forward."
5608 (let ((last (cdr (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
5609 (artnum gnus-newsgroup-end)
5611 (while (and (not header)
5613 (setq artnum (1+ artnum))
5614 (setq header (gnus-read-header artnum)))
5617 (defun gnus-extend-newsgroup (header &optional backward)
5618 "Extend newsgroup selection with HEADER.
5619 Optional argument BACKWARD means extend toward backward."
5621 (let ((artnum (header-number header)))
5622 (setq gnus-newsgroup-headers
5624 (cons header gnus-newsgroup-headers)
5625 (nconc gnus-newsgroup-headers (list header))))
5626 (setq gnus-newsgroup-unselected
5627 (delq artnum gnus-newsgroup-unselected))
5628 (setq gnus-newsgroup-begin (min gnus-newsgroup-begin artnum))
5629 (setq gnus-newsgroup-end (max gnus-newsgroup-end artnum)))))
5631 (defun gnus-summary-work-articles (n)
5632 "Return a list of articles to be worked upon. The prefix argument,
5633 the list of process marked articles, and the current article will be
5634 taken into consideration."
5636 (if (and n (numberp n))
5637 (let ((backward (< n 0))
5641 (setq articles (cons (gnus-summary-article-number)
5643 (gnus-summary-search-forward nil nil backward))
5645 (sort articles (function <)))
5646 (or (reverse gnus-newsgroup-processable)
5647 (list (gnus-summary-article-number))))))
5649 (defun gnus-summary-search-group (&optional backward use-level)
5650 "Search for next unread newsgroup.
5651 If optional argument BACKWARD is non-nil, search backward instead."
5653 (set-buffer gnus-group-buffer)
5655 ;; We don't want to alter current point of group mode buffer.
5656 (if (gnus-group-search-forward
5658 (if use-level (gnus-group-group-level) nil))
5659 (gnus-group-group-name)))))
5661 (defun gnus-summary-best-group ()
5662 "Find the name of the best unread group."
5664 (set-buffer gnus-group-buffer)
5666 (gnus-group-best-unread-group))))
5668 (defun gnus-summary-search-subject (&optional backward unread subject)
5669 "Search for article forward.
5670 If BACKWARD is non-nil, search backward.
5671 If UNREAD is non-nil, only unread articles are selected.
5672 If SUBJECT is non-nil, the article which has the same subject will be
5674 (let ((func (if backward 'previous-single-property-change
5675 'next-single-property-change))
5680 (forward-char (if backward (if (bobp) 0 -1) (if (eobp) 0 1)))
5681 (while (and (setq pos (funcall func (point) 'gnus-number))
5682 (goto-char (if backward (1- pos) pos))
5684 (not (and (or (not unread)
5685 (eq (get-text-property (point) 'gnus-mark)
5688 (equal (gnus-simplify-subject-re
5690 (gnus-simplify-subject-re
5693 'gnus-subject)))))))
5694 (if backward (if (bobp) nil (forward-char -1) t)
5695 (if (eobp) nil (forward-char 1) t))))
5697 (progn (goto-char beg) nil)
5699 (get-text-property (point) 'gnus-number)
5700 (gnus-summary-position-cursor)))))
5702 (defun gnus-summary-search-forward (&optional unread subject backward)
5703 "Search for article forward.
5704 If UNREAD is non-nil, only unread articles are selected.
5705 If SUBJECT is non-nil, the article which has the same subject will be
5707 If BACKWARD is non-nil, the search will be performed backwards instead."
5708 (gnus-summary-search-subject backward unread subject))
5710 (defun gnus-summary-search-backward (&optional unread subject)
5711 "Search for article backward.
5712 If 1st optional argument UNREAD is non-nil, only unread article is selected.
5713 If 2nd optional argument SUBJECT is non-nil, the article which has
5714 the same subject will be searched for."
5715 (gnus-summary-search-forward unread subject t))
5717 (defun gnus-summary-article-number (&optional number-or-nil)
5718 "The article number of the article on the current line.
5719 If there isn's an article number here, then we return the current
5721 (let ((number (get-text-property (save-excursion (beginning-of-line) (point))
5723 (if number-or-nil number (or number gnus-current-article))))
5725 (defun gnus-summary-thread-level ()
5726 "The thread level of the article on the current line."
5727 (or (get-text-property (save-excursion (beginning-of-line) (point))
5731 (defun gnus-summary-pseudo-article ()
5732 "The thread level of the article on the current line."
5733 (get-text-property (save-excursion (beginning-of-line) (point))
5736 (defun gnus-summary-article-mark ()
5737 "The mark on the current line."
5738 (get-text-property (save-excursion (beginning-of-line) (point))
5741 (defun gnus-summary-subject-string ()
5742 "Return current subject string or nil if nothing."
5743 (get-text-property (save-excursion (beginning-of-line) (point))
5746 (defalias 'gnus-summary-score 'gnus-summary-article-score)
5747 (make-obsolete 'gnus-summary-score 'gnus-summary-article-score)
5748 (defun gnus-summary-article-score ()
5749 "Return current article score."
5750 (or (cdr (assq (gnus-summary-article-number) gnus-newsgroup-scored))
5751 gnus-summary-default-score))
5753 (defun gnus-summary-recenter ()
5754 "Center point in summary window."
5755 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5756 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
5757 (let ((half (/ (- (window-height) 2) 2)))
5759 ;; It has to be wanted,
5760 gnus-auto-center-summary
5761 ;; the article buffer must be displayed,
5762 (get-buffer-window gnus-article-buffer)
5763 ;; there must be lines left to scroll forward,
5764 (zerop (save-excursion (forward-line (1+ half))))
5768 (defun gnus-summary-jump-to-group (newsgroup)
5769 "Move point to NEWSGROUP in group mode buffer."
5770 ;; Keep update point of group mode buffer if visible.
5771 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
5772 (save-window-excursion
5773 ;; Take care of tree window mode.
5774 (if (get-buffer-window gnus-group-buffer)
5775 (pop-to-buffer gnus-group-buffer))
5776 (gnus-group-jump-to-group newsgroup))
5778 ;; Take care of tree window mode.
5779 (if (get-buffer-window gnus-group-buffer)
5780 (pop-to-buffer gnus-group-buffer)
5781 (set-buffer gnus-group-buffer))
5782 (gnus-group-jump-to-group newsgroup))))
5784 ;; This function returns a list of article numbers based on the
5785 ;; difference between the ranges of read articles in this group and
5786 ;; the range of active articles.
5787 (defun gnus-list-of-unread-articles (group)
5788 (let* ((read (nth 2 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
5789 (active (gnus-gethash group gnus-active-hashtb))
5791 unread first nlast unread)
5792 ;; If none are read, then all are unread.
5794 (setq first (car active))
5795 ;; If the range of read articles is a single range, then the
5796 ;; first unread article is the article after the last read
5797 ;; article. Sounds logical, doesn't it?
5798 (if (atom (car read))
5799 (setq first (1+ (cdr read)))
5800 ;; `read' is a list of ranges.
5803 (while (< first nlast)
5804 (setq unread (cons first unread))
5805 (setq first (1+ first))))
5806 (setq first (1+ (cdr (car read))))
5807 (setq nlast (car (car (cdr read))))
5808 (setq read (cdr read)))))
5809 ;; And add the last unread articles.
5810 (while (<= first last)
5811 (setq unread (cons first unread))
5812 (setq first (1+ first)))
5813 ;; Return the list of unread articles.
5817 ;; Various summary commands
5819 (defun gnus-summary-universal-argument ()
5820 "Perform any operation on all articles marked with the process mark."
5822 (gnus-set-global-variables)
5823 (let ((articles (reverse gnus-newsgroup-processable))
5825 (or articles (error "No articles marked"))
5826 (or (setq func (key-binding (read-key-sequence "C-c C-u")))
5827 (error "Undefined key"))
5829 (gnus-summary-goto-subject (car articles))
5830 (command-execute func)
5831 (gnus-summary-remove-process-mark (car articles))
5832 (setq articles (cdr articles)))))
5834 (defun gnus-summary-toggle-truncation (arg)
5835 "Toggle truncation of summary lines.
5836 With arg, turn line truncation on iff arg is positive."
5838 (setq truncate-lines
5839 (if (null arg) (not truncate-lines)
5840 (> (prefix-numeric-value arg) 0)))
5843 (defun gnus-summary-reselect-current-group (show-all)
5844 "Once exit and then reselect the current newsgroup.
5845 Prefix argument SHOW-ALL means to select all articles."
5847 (gnus-set-global-variables)
5848 (let ((current-subject (gnus-summary-article-number)))
5849 (gnus-summary-exit t)
5850 ;; We have to adjust the point of group mode buffer because the
5851 ;; current point was moved to the next unread newsgroup by
5853 (gnus-summary-jump-to-group gnus-newsgroup-name)
5854 (gnus-group-read-group show-all t)
5855 (gnus-summary-goto-subject current-subject)
5858 (defun gnus-summary-rescan-group (all)
5859 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5861 (gnus-set-global-variables)
5862 ;; Fix by Ilja Weis <kult@uni-paderborn.de>.
5863 (let ((group gnus-newsgroup-name))
5864 (gnus-summary-exit t)
5865 (gnus-summary-jump-to-group group)
5867 (set-buffer gnus-group-buffer)
5868 (gnus-group-get-new-news-this-group 1))
5869 (gnus-summary-jump-to-group group)
5870 (gnus-group-read-group all)))
5872 (defun gnus-summary-exit (&optional temporary)
5873 "Exit reading current newsgroup, and then return to group selection mode.
5874 gnus-exit-group-hook is called with no arguments if that value is non-nil."
5876 (gnus-set-global-variables)
5877 (gnus-kill-save-kill-buffer)
5878 (let* ((group gnus-newsgroup-name)
5879 (quit-buffer (cdr (assoc 'quit-buffer (gnus-find-method-for-group
5880 gnus-newsgroup-name))))
5882 (method (car (gnus-find-method-for-group group)))
5883 (buf (current-buffer)))
5884 (if gnus-newsgroup-kill-headers
5885 (setq gnus-newsgroup-killed
5886 (gnus-compress-sequence
5889 (gnus-uncompress-sequence gnus-newsgroup-killed)
5890 (setq gnus-newsgroup-unselected
5891 (sort gnus-newsgroup-unselected '<)))
5892 (setq gnus-newsgroup-unreads
5893 (sort gnus-newsgroup-unreads '<))))))
5894 (or (listp (cdr gnus-newsgroup-killed))
5895 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5897 (headers gnus-newsgroup-headers))
5898 (gnus-close-group group)
5899 (run-hooks 'gnus-exit-group-hook)
5901 (and gnus-newsgroup-expunged-buffer
5902 (buffer-name gnus-newsgroup-expunged-buffer)
5903 (kill-buffer gnus-newsgroup-expunged-buffer))
5904 (gnus-update-read-articles
5905 group gnus-newsgroup-unreads gnus-newsgroup-unselected
5906 gnus-newsgroup-marked
5907 t gnus-newsgroup-replied gnus-newsgroup-expirable
5908 gnus-newsgroup-killed gnus-newsgroup-dormant
5909 gnus-newsgroup-bookmarks gnus-newsgroup-scored)
5910 ;; t means ignore unsubscribed newsgroups.
5911 (and gnus-use-cross-reference
5912 (gnus-mark-xrefs-as-read
5913 group headers gnus-newsgroup-unreads gnus-newsgroup-expirable))
5914 ;; Do not switch windows but change the buffer to work.
5915 (set-buffer gnus-group-buffer)
5916 (or (eq 'nndigest method)
5917 (gnus-group-update-group group)))
5918 ;; Make sure where I was, and go to next newsgroup.
5919 (if (eq method 'nndigest)
5921 (gnus-group-jump-to-group group)
5922 (gnus-group-next-unread-group 1))
5924 ;; If exiting temporary, caller should adjust group mode
5925 ;; buffer point by itself.
5927 ;; Return to group mode buffer.
5928 (gnus-configure-windows 'newsgroups t)
5929 (and (get-buffer buf)
5930 (eq mode 'gnus-summary-mode)
5932 (if (get-buffer gnus-article-buffer)
5933 (bury-buffer gnus-article-buffer))
5934 (setq gnus-current-select-method gnus-select-method)
5935 (pop-to-buffer gnus-group-buffer)
5936 (if (and quit-buffer (buffer-name quit-buffer))
5938 (switch-to-buffer quit-buffer)
5939 (gnus-set-global-variables)
5940 (gnus-configure-windows 'summary))))))
5942 (defun gnus-summary-quit (&optional no-questions)
5943 "Quit reading current newsgroup without updating read article info."
5945 (let ((group gnus-newsgroup-name)
5946 (quit-buffer (cdr (assoc 'quit-buffer (gnus-find-method-for-group
5947 gnus-newsgroup-name)))))
5948 (if (or no-questions
5950 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
5952 (gnus-close-group group)
5953 ;; Return to group selection mode.
5954 (and gnus-newsgroup-expunged-buffer
5955 (buffer-name gnus-newsgroup-expunged-buffer)
5956 (kill-buffer gnus-newsgroup-expunged-buffer))
5957 (gnus-configure-windows 'newsgroups)
5958 (if (get-buffer gnus-summary-buffer)
5959 (kill-buffer gnus-summary-buffer))
5960 (if (get-buffer gnus-article-buffer)
5961 (bury-buffer gnus-article-buffer))
5962 (pop-to-buffer gnus-group-buffer)
5963 (gnus-group-jump-to-group gnus-newsgroup-name)
5964 (gnus-group-next-group 1)
5965 (if (and quit-buffer (buffer-name quit-buffer))
5967 (switch-to-buffer quit-buffer)
5968 (gnus-configure-windows 'summary)))))))
5970 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5971 (defun gnus-summary-describe-group ()
5972 "Describe the current newsgroup."
5974 (gnus-group-describe-group gnus-newsgroup-name))
5976 (defun gnus-summary-describe-briefly ()
5977 "Describe summary mode commands briefly."
5980 (substitute-command-keys "\\<gnus-summary-mode-map>\\[gnus-summary-next-page]:Select \\[gnus-summary-next-unread-article]:Forward \\[gnus-summary-prev-unread-article]:Backward \\[gnus-summary-exit]:Exit \\[gnus-info-find-node]:Run Info \\[gnus-summary-describe-briefly]:This help")))
5982 ;; Walking around group mode buffer from summary mode.
5984 (defun gnus-summary-next-group (&optional no-article group)
5985 "Exit current newsgroup and then select next unread newsgroup.
5986 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5988 (gnus-set-global-variables)
5989 (let ((ingroup gnus-newsgroup-name)
5990 (sumbuf (current-buffer)))
5991 (gnus-summary-exit t) ;Update all information.
5992 (gnus-group-jump-to-group ingroup)
5993 (let ((group (or group (gnus-summary-search-group)))
5994 (buf gnus-summary-buffer))
5996 (gnus-summary-quit t)
5997 (message "Selecting %s..." group)
5998 ;; We are now in group mode buffer.
5999 ;; Make sure group mode buffer point is on GROUP.
6000 (gnus-group-jump-to-group group)
6002 (gnus-summary-read-group group nil no-article buf)
6003 (and (string= gnus-newsgroup-name ingroup)
6006 (gnus-summary-quit t))))))))
6008 (defun gnus-summary-prev-group (no-article)
6009 "Exit current newsgroup and then select previous unread newsgroup.
6010 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6012 ;; Make sure group mode buffer point is on current newsgroup.
6013 (gnus-summary-jump-to-group gnus-newsgroup-name)
6014 (let ((group (gnus-summary-search-group t)))
6017 (message "Exiting %s..." gnus-newsgroup-name)
6020 (message "Selecting %s..." group)
6021 (gnus-summary-exit t) ;Exit summary mode temporary.
6022 ;; We are now in group mode buffer.
6023 ;; We have to adjust point of group mode buffer because current
6024 ;; point is moved to next unread newsgroup by exiting.
6025 (gnus-summary-jump-to-group group)
6026 (gnus-summary-read-group group nil no-article)
6027 (or (eq (current-buffer)
6028 (get-buffer gnus-summary-buffer))
6029 (eq gnus-auto-select-next t)
6030 ;; Expected newsgroup has nothing to read since the articles
6031 ;; are marked as read by cross-referencing. So, try next
6032 ;; newsgroup. (Make sure we are in group mode buffer now.)
6033 (and (eq (current-buffer)
6034 (get-buffer gnus-group-buffer))
6035 (gnus-summary-search-group t)
6036 (gnus-summary-read-group
6037 (gnus-summary-search-group t) nil no-article))
6041 ;; Walking around summary lines.
6043 (defun gnus-summary-first-subject (unread)
6044 "Go to the first unread subject.
6045 If UNREAD is non-nil, go to the first unread article.
6046 Returns nil if there are no unread articles."
6047 (let ((begin (point)))
6049 (if (not (gnus-goto-char
6050 (text-property-any (point-min) (point-max)
6051 'gnus-mark gnus-unread-mark)))
6053 ;; If there is no unread articles, stay where you are.
6055 (message "No more unread articles")
6058 (goto-char (point-min)))))
6060 (defun gnus-summary-next-subject (n &optional unread)
6061 "Go to next N'th summary line.
6062 If N is negative, go to the previous N'th subject line.
6063 If UNREAD is non-nil, only unread articles are selected.
6064 The difference between N and the actual number of steps taken is
6067 (let ((backward (< n 0))
6070 (gnus-summary-search-forward unread nil backward))
6072 (gnus-summary-recenter)
6073 (if (/= 0 n) (message "No more%s articles" (if unread " unread" "")))
6074 (gnus-summary-position-cursor)
6077 (defun gnus-summary-next-unread-subject (n)
6078 "Go to next N'th unread summary line."
6080 (gnus-summary-next-subject n t))
6082 (defun gnus-summary-prev-subject (n &optional unread)
6083 "Go to previous N'th summary line.
6084 If optional argument UNREAD is non-nil, only unread article is selected."
6086 (gnus-summary-next-subject (- n) unread))
6088 (defun gnus-summary-prev-unread-subject (n)
6089 "Go to previous N'th unread summary line."
6091 (gnus-summary-next-subject (- n) t))
6093 (defun gnus-summary-goto-subject (article)
6094 "Go the subject line of ARTICLE."
6098 (completing-read "Article number: "
6102 (int-to-string (header-number headers))))
6103 gnus-newsgroup-headers)
6104 nil 'require-match))))
6105 (or article (error "No article number"))
6106 (if (or (eq article (gnus-summary-article-number t))
6109 (point-min) (point-max) 'gnus-number article)))
6112 ;; Walking around summary lines with displaying articles.
6114 (defun gnus-summary-expand-window ()
6115 "Expand summary window to show headers full window."
6117 (gnus-set-global-variables)
6118 (gnus-configure-windows 'summary)
6119 (pop-to-buffer gnus-summary-buffer))
6121 (defun gnus-summary-display-article (article &optional all-header)
6122 "Display ARTICLE in article buffer."
6123 (gnus-set-global-variables)
6126 (gnus-article-prepare article all-header)
6127 (if (= (gnus-summary-article-mark) ?Z)
6130 (gnus-summary-position-cursor)))
6131 (run-hooks 'gnus-select-article-hook)
6132 (gnus-summary-recenter)
6133 ; (set-window-point (get-buffer-window (current-buffer)) (point-max))
6135 (gnus-summary-goto-subject article)
6136 ;; Successfully display article.
6139 (defun gnus-summary-select-article (&optional all-headers force pseudo)
6140 "Select the current article.
6141 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
6142 non-nil, the article will be re-fetched even if it already present in
6143 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
6145 (and (not pseudo) (gnus-summary-pseudo-article)
6146 (error "This is a pseudo-article."))
6147 (let ((article (gnus-summary-article-number))
6148 (all-headers (not (not all-headers)))) ;Must be T or NIL.
6149 (if (or (null gnus-current-article)
6150 (null gnus-article-current)
6151 (/= article (cdr gnus-article-current))
6152 (not (equal (car gnus-article-current) gnus-newsgroup-name))
6154 ;; The requested article is different from the current article.
6156 (gnus-summary-display-article article all-headers)
6158 (if all-headers (gnus-article-show-all-headers))
6159 (gnus-configure-windows 'article)
6160 (pop-to-buffer gnus-summary-buffer)
6163 (defun gnus-summary-set-current-mark (&optional current-mark)
6164 "Obsolete function."
6167 (defun gnus-summary-next-article (unread &optional subject)
6168 "Select the article after the current one.
6169 If UNREAD is non-nil, only unread articles are selected."
6172 (method (car (gnus-find-method-for-group gnus-newsgroup-name))))
6173 (cond ((gnus-summary-display-article
6174 (gnus-summary-search-forward unread subject)))
6176 gnus-auto-select-same
6177 (gnus-set-difference gnus-newsgroup-unreads
6178 (append gnus-newsgroup-marked
6179 gnus-newsgroup-dormant))
6181 '(gnus-summary-next-unread-article
6182 gnus-summary-next-page
6183 gnus-summary-kill-same-subject-and-select
6184 ;;gnus-summary-next-article
6185 ;;gnus-summary-next-same-subject
6186 ;;gnus-summary-next-unread-same-subject
6188 ;; Wrap article pointer if there are unread articles.
6189 (let ((buffer (current-buffer))
6190 (last-point (point)))
6191 ;; No more articles with same subject, so jump to the first
6193 (gnus-summary-first-unread-article)
6194 ;;(and (eq buffer (current-buffer))
6195 ;; (= (point) last-point)
6196 ;; ;; Ignore given SUBJECT, and try again.
6197 ;; (gnus-summary-next-article unread nil))
6198 (and (eq buffer (current-buffer))
6199 (< (point) last-point)
6200 (message "Wrapped"))
6202 ((and gnus-auto-extend-newsgroup
6203 (not unread) ;Not unread only
6204 (not subject) ;Only if subject is not specified.
6205 (setq header (gnus-more-header-forward)))
6206 ;; Extend to next article if possible.
6207 ;; Basic ideas by himacdonald@watdragon.waterloo.edu
6208 (gnus-extend-newsgroup header nil)
6209 ;; Threads feature must be turned off.
6210 (let ((buffer-read-only nil))
6211 (goto-char (point-max))
6212 (gnus-summary-prepare-threads (list header) 0))
6213 (gnus-summary-goto-article gnus-newsgroup-end))
6215 ;; Select next newsgroup automatically if requested.
6216 (gnus-summary-jump-to-group gnus-newsgroup-name)
6217 (let ((cmd (aref (this-command-keys) 0))
6218 (group (if (eq gnus-keep-same-level 'best)
6219 (gnus-summary-best-group)
6220 (gnus-summary-search-group
6221 nil gnus-keep-same-level)))
6223 (and gnus-auto-select-next
6224 ;;(null (gnus-set-difference gnus-newsgroup-unreads
6225 ;; gnus-newsgroup-marked))
6227 '(gnus-summary-next-unread-article
6228 gnus-summary-next-article
6229 gnus-summary-next-page
6230 gnus-summary-next-same-subject
6231 gnus-summary-next-unread-same-subject
6232 gnus-summary-kill-same-subject
6233 gnus-summary-kill-same-subject-and-select
6235 ;; Ignore characters typed ahead.
6236 (not (input-pending-p))
6238 ;; Keep just the event type of CMD.
6240 (setq cmd (car cmd)))
6241 (message "No more%s articles%s"
6242 (if unread " unread" "")
6243 (if (and auto-select
6244 (not (eq gnus-auto-select-next 'quietly)))
6245 (if (and group (not (eq method 'nndigest)))
6246 (format " (Type %s for %s [%s])"
6247 (single-key-description cmd)
6250 group gnus-newsrc-hashtb)))
6251 (format " (Type %s to exit %s)"
6252 (single-key-description cmd)
6253 gnus-newsgroup-name))
6255 ;; Select next unread newsgroup automagically.
6256 (cond ((and auto-select
6257 (eq gnus-auto-select-next 'quietly))
6259 (if (eq method 'nndigest)
6261 (gnus-summary-next-group)))
6263 ;; Confirm auto selection.
6264 (let* ((event (read-event))
6269 (if (and (eq event type) (eq event cmd))
6270 (if (eq method 'nndigest)
6272 (gnus-summary-next-group))
6273 (setq unread-command-events (list event)))))
6278 (defun gnus-summary-next-unread-article ()
6279 "Select unread article after current one."
6281 (gnus-summary-next-article t (and gnus-auto-select-same
6282 (gnus-summary-subject-string)))
6283 (gnus-summary-position-cursor))
6285 (defun gnus-summary-prev-article (unread &optional subject)
6286 "Select the article after the current one.
6287 If UNREAD is non-nil, only unread articles are selected."
6290 (cond ((gnus-summary-display-article
6291 (gnus-summary-search-backward unread subject)))
6293 gnus-auto-select-same
6294 (gnus-set-difference gnus-newsgroup-unreads
6295 (append gnus-newsgroup-marked
6296 gnus-newsgroup-dormant))
6298 '(gnus-summary-prev-unread-article
6299 gnus-summary-prev-page)))
6300 ;; Wrap article pointer if there are unread articles.
6301 (let ((buffer (current-buffer))
6302 (last-point (point)))
6303 ;; No more articles with same subject, so jump to the first
6305 (gnus-summary-first-unread-article)
6306 (and (eq buffer (current-buffer))
6307 (< (point) last-point)
6308 (message "Wrapped"))
6310 ((and gnus-auto-extend-newsgroup
6311 (not unread) ;Not unread only
6312 (not subject) ;Only if subject is not specified.
6313 (setq header (gnus-more-header-backward)))
6314 ;; Extend to next article if possible.
6315 ;; Basic ideas by himacdonald@watdragon.waterloo.edu
6316 (gnus-extend-newsgroup header t)
6317 ;; Threads feature must be turned off.
6318 (let ((buffer-read-only nil))
6319 (goto-char (point-min))
6320 (gnus-summary-prepare-threads (list header) 0))
6321 (gnus-summary-goto-article gnus-newsgroup-begin))
6323 ;; Select prev newsgroup automatically if requested.
6324 (gnus-summary-jump-to-group gnus-newsgroup-name)
6325 (let ((cmd (aref (this-command-keys) 0))
6326 (group (if (eq gnus-keep-same-level 'best)
6327 (gnus-summary-best-group)
6328 (gnus-summary-search-group
6329 t gnus-keep-same-level)))
6331 (and gnus-auto-select-next
6333 '(gnus-summary-prev-unread-article
6334 gnus-summary-prev-article
6335 gnus-summary-prev-page))
6336 ;; Ignore characters typed ahead.
6337 (not (input-pending-p)))))
6338 ;; Keep just the event type of CMD.
6340 (setq cmd (car cmd)))
6341 (message "No more%s articles%s"
6342 (if unread " unread" "")
6343 (if (and auto-select
6344 (not (eq gnus-auto-select-next 'quietly)))
6346 (format " (Type %s for %s [%s])"
6347 (single-key-description cmd)
6350 group gnus-newsrc-hashtb)))
6351 (format " (Type %s to exit %s)"
6352 (single-key-description cmd)
6353 gnus-newsgroup-name))
6355 ;; Select next unread newsgroup automagically.
6356 (cond ((and auto-select
6357 (eq gnus-auto-select-next 'quietly))
6359 (gnus-summary-prev-group 1))
6361 ;; Confirm auto selection.
6362 (let* ((event (read-event))
6367 (if (and (eq event type) (eq event cmd))
6368 (gnus-summary-prev-group 1)
6369 (setq unread-command-events (list event)))))
6374 (defun gnus-summary-prev-unread-article ()
6375 "Select unred article before current one."
6377 (gnus-summary-prev-article t (and gnus-auto-select-same
6378 (gnus-summary-subject-string))))
6380 (defun gnus-summary-next-page (lines &optional circular)
6381 "Show next page of selected article.
6382 If end of article, select next article.
6383 Argument LINES specifies lines to be scrolled up.
6384 If CIRCULAR is non-nil, go to the start of the article instead of
6385 instead of selecting the next article when reaching the end of the
6388 (setq gnus-summary-buffer (current-buffer))
6389 (let ((article (gnus-summary-article-number))
6391 (if (or (null gnus-current-article)
6392 (null gnus-article-current)
6393 (/= article (cdr gnus-article-current))
6394 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6395 ;; Selected subject is different from current article's.
6396 (gnus-summary-display-article article)
6397 (gnus-configure-windows 'article)
6398 (pop-to-buffer gnus-summary-buffer)
6399 (gnus-eval-in-buffer-window
6401 (setq endp (gnus-article-next-page lines)))
6404 (gnus-summary-beginning-of-article))
6406 (message "End of message"))
6408 (gnus-summary-next-unread-article))))))
6409 (gnus-summary-position-cursor))
6411 (defun gnus-summary-prev-page (lines)
6412 "Show previous page of selected article.
6413 Argument LINES specifies lines to be scrolled down."
6415 (let ((article (gnus-summary-article-number)))
6416 (if (or (null gnus-current-article)
6417 (null gnus-article-current)
6418 (/= article (cdr gnus-article-current))
6419 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6420 ;; Selected subject is different from current article's.
6421 (gnus-summary-display-article article)
6422 (gnus-configure-windows 'article)
6423 (pop-to-buffer gnus-summary-buffer)
6424 (gnus-eval-in-buffer-window gnus-article-buffer
6425 (gnus-article-prev-page lines))))
6426 (gnus-summary-position-cursor))
6428 (defun gnus-summary-scroll-up (lines)
6429 "Scroll up (or down) one line current article.
6430 Argument LINES specifies lines to be scrolled up (or down if negative)."
6432 (or (gnus-summary-select-article nil nil 'pseudo)
6433 (gnus-eval-in-buffer-window
6436 (if (gnus-article-next-page lines)
6437 (message "End of message")))
6439 (gnus-article-prev-page (- lines))))))
6440 (gnus-summary-position-cursor))
6442 (defun gnus-summary-next-same-subject ()
6443 "Select next article which has the same subject as current one."
6445 (gnus-summary-next-article nil (gnus-summary-subject-string)))
6447 (defun gnus-summary-prev-same-subject ()
6448 "Select previous article which has the same subject as current one."
6450 (gnus-summary-prev-article nil (gnus-summary-subject-string)))
6452 (defun gnus-summary-next-unread-same-subject ()
6453 "Select next unread article which has the same subject as current one."
6455 (gnus-summary-next-article t (gnus-summary-subject-string)))
6457 (defun gnus-summary-prev-unread-same-subject ()
6458 "Select previous unread article which has the same subject as current one."
6460 (gnus-summary-prev-article t (gnus-summary-subject-string)))
6462 (defun gnus-summary-first-unread-article ()
6463 "Select the first unread article.
6464 Return nil if there are no unread articles."
6467 (if (gnus-summary-first-subject t)
6468 (gnus-summary-display-article (gnus-summary-article-number)))
6469 (gnus-summary-position-cursor)))
6471 (defun gnus-summary-best-unread-article ()
6472 "Select the unread article with the highest score."
6474 (gnus-set-global-variables)
6475 (let ((scored gnus-newsgroup-scored)
6479 (or (> best (cdr (car scored)))
6480 (and (memq (setq art (car (car scored))) gnus-newsgroup-unreads)
6481 (not (memq art gnus-newsgroup-marked))
6482 (not (memq art gnus-newsgroup-dormant))
6483 (if (= best (cdr (car scored)))
6484 (setq article (min art article))
6486 (setq best (cdr (car scored))))))
6487 (setq scored (cdr scored)))
6489 (gnus-summary-goto-article article)
6490 (gnus-summary-first-unread-article))
6491 (gnus-summary-position-cursor)))
6493 (defun gnus-summary-goto-article (article &optional all-headers)
6494 "Fetch ARTICLE and display it if it exists.
6495 If ALL-HEADERS is non-nil, no header lines are hidden."
6501 (mapcar (lambda (headers) (list (int-to-string (header-number headers))))
6502 gnus-newsgroup-headers)
6503 nil 'require-match))))
6504 (if (gnus-summary-goto-subject article)
6505 (gnus-summary-display-article article all-headers))
6506 (gnus-summary-position-cursor))
6508 (defun gnus-summary-goto-last-article ()
6509 "Go to the last article."
6511 (if gnus-last-article
6512 (gnus-summary-goto-article gnus-last-article))
6513 (gnus-summary-position-cursor))
6515 ;; Summary article oriented commands
6517 (defun gnus-summary-refer-parent-article (n)
6518 "Refer parent article N times.
6519 The difference between N and the number of articles fetched is returned."
6521 (gnus-set-global-variables)
6525 (let ((ref (header-references (gnus-get-header-by-number
6526 (gnus-summary-article-number)))))
6527 (if (and ref (not (equal ref ""))
6528 (string-match "<[^<>]*>[ \t]*$" ref))
6529 (gnus-summary-refer-article
6530 (substring ref (match-beginning 0) (match-end 0))))))
6532 (or (zerop n) (message "No references in article or expired article."))
6533 (gnus-summary-position-cursor)
6536 (defun gnus-summary-refer-article (message-id)
6537 "Refer article specified by MESSAGE-ID.
6538 NOTE: This command only works with newsgroup that use NNTP."
6539 (interactive "sMessage-ID: ")
6540 (if (or (not (stringp message-id))
6541 (zerop (length message-id)))
6543 ;; Construct the correct Message-ID if necessary.
6544 ;; Suggested by tale@pawl.rpi.edu.
6545 (or (string-match "^<" message-id)
6546 (setq message-id (concat "<" message-id)))
6547 (or (string-match ">$" message-id)
6548 (setq message-id (concat message-id ">")))
6549 (let ((header (car (gnus-gethash message-id gnus-newsgroup-dependencies))))
6551 (gnus-summary-goto-article (header-number header))
6552 (if (gnus-article-prepare message-id nil (gnus-read-header message-id))
6554 (gnus-summary-insert-line
6555 nil gnus-current-headers 0 nil gnus-read-mark nil nil
6556 (header-subject gnus-current-headers))
6558 (gnus-summary-position-cursor)
6559 (gnus-summary-update-line)
6561 (message "No such references")
6564 (defun gnus-summary-enter-digest-group ()
6565 "Enter a digest group based on the current article."
6567 (gnus-summary-select-article)
6568 (let ((name (format "%s/%d"
6569 (gnus-group-prefixed-name
6570 gnus-newsgroup-name (list 'nndigest ""))
6571 gnus-current-article))
6572 (buf (current-buffer)))
6573 (set-buffer gnus-group-buffer)
6576 (list t nil (list name 3 nil nil
6577 (list 'nndigest gnus-article-buffer
6578 (cons 'quit-buffer buf))))
6580 (gnus-group-read-group t nil name)))
6582 (defun gnus-summary-isearch-article ()
6583 "Do incremental search forward on current article."
6585 (gnus-summary-select-article)
6586 (gnus-eval-in-buffer-window gnus-article-buffer
6589 (defun gnus-summary-search-article-forward (regexp)
6590 "Search for an article containing REGEXP forward.
6591 gnus-select-article-hook is not called during the search."
6594 (concat "Search forward (regexp): "
6595 (if gnus-last-search-regexp
6596 (concat "(default " gnus-last-search-regexp ") "))))))
6597 (if (string-equal regexp "")
6598 (setq regexp (or gnus-last-search-regexp ""))
6599 (setq gnus-last-search-regexp regexp))
6600 (if (gnus-summary-search-article regexp nil)
6601 (gnus-eval-in-buffer-window gnus-article-buffer
6605 (error "Search failed: \"%s\"" regexp)
6608 (defun gnus-summary-search-article-backward (regexp)
6609 "Search for an article containing REGEXP backward.
6610 gnus-select-article-hook is not called during the search."
6613 (concat "Search backward (regexp): "
6614 (if gnus-last-search-regexp
6615 (concat "(default " gnus-last-search-regexp ") "))))))
6616 (if (string-equal regexp "")
6617 (setq regexp (or gnus-last-search-regexp ""))
6618 (setq gnus-last-search-regexp regexp))
6619 (if (gnus-summary-search-article regexp t)
6620 (gnus-eval-in-buffer-window gnus-article-buffer
6624 (error "Search failed: \"%s\"" regexp)
6627 (defun gnus-summary-search-article (regexp &optional backward)
6628 "Search for an article containing REGEXP.
6629 Optional argument BACKWARD means do search for backward.
6630 gnus-select-article-hook is not called during the search."
6631 (let ((gnus-select-article-hook nil) ;Disable hook.
6632 (gnus-mark-article-hook nil) ;Inhibit marking as read.
6635 (function re-search-backward) (function re-search-forward)))
6638 ;; Hidden thread subtrees must be searched for ,too.
6639 (gnus-summary-show-all-threads)
6640 (if (eobp) (forward-line -1))
6641 ;; First of all, search current article.
6642 ;; We don't want to read article again from NNTP server nor reset
6644 (gnus-summary-select-article)
6645 (message "Searching article: %d..." gnus-current-article)
6646 (setq last gnus-current-article)
6647 (gnus-eval-in-buffer-window gnus-article-buffer
6650 ;; Begin search from current point.
6651 (setq found (funcall re-search regexp nil t))))
6652 ;; Then search next articles.
6653 (while (and (not found)
6654 (gnus-summary-display-article
6655 (gnus-summary-search-subject backward nil nil)))
6656 (message "Searching article: %d..." gnus-current-article)
6657 (gnus-eval-in-buffer-window gnus-article-buffer
6660 (goto-char (if backward (point-max) (point-min)))
6661 (setq found (funcall re-search regexp nil t)))
6664 ;; Adjust article pointer.
6665 (or (eq last gnus-current-article)
6666 (setq gnus-last-article last))
6667 ;; Return T if found such article.
6671 (defun gnus-summary-execute-command (field regexp command &optional backward)
6672 "If FIELD of article header matches REGEXP, execute a COMMAND string.
6673 If FIELD is an empty string (or nil), entire article body is searched for.
6674 If optional (prefix) argument BACKWARD is non-nil, do backward instead."
6676 (list (let ((completion-ignore-case t))
6677 (completing-read "Field name: "
6678 '(("Number")("Subject")("From")
6679 ("Lines")("Date")("Id")
6680 ("Xref")("References"))
6681 nil 'require-match))
6682 (read-string "Regexp: ")
6683 (read-key-sequence "Command: ")
6684 current-prefix-arg))
6685 ;; Hidden thread subtrees must be searched for ,too.
6686 (gnus-summary-show-all-threads)
6687 ;; We don't want to change current point nor window configuration.
6689 (save-window-excursion
6690 (message "Executing %s..." (key-description command))
6691 ;; We'd like to execute COMMAND interactively so as to give arguments.
6692 (gnus-execute field regexp
6694 (call-interactively '(, (key-binding command)))))
6696 (message "Executing %s... done" (key-description command)))))
6698 (defun gnus-summary-beginning-of-article ()
6699 "Scroll the article back to the beginning."
6701 (gnus-summary-select-article)
6702 (gnus-eval-in-buffer-window gnus-article-buffer
6704 (goto-char (point-min))
6705 (if gnus-break-pages
6706 (gnus-narrow-to-page))
6709 (defun gnus-summary-end-of-article ()
6710 "Scroll to the end of the article."
6712 (gnus-summary-select-article)
6713 (gnus-eval-in-buffer-window gnus-article-buffer
6715 (goto-char (point-max))
6716 (if gnus-break-pages
6717 (gnus-narrow-to-page))
6720 (defun gnus-summary-show-article ()
6721 "Force re-fetching of the current article."
6723 (gnus-summary-select-article gnus-have-all-headers t t))
6725 (defun gnus-summary-toggle-header (arg)
6726 "Show the headers if they are hidden, or hide them if they are shown.
6727 If ARG is a positive number, show the entire header.
6728 If ARG is a negative number, hide the unwanted header lines."
6730 (gnus-set-global-variables)
6732 (set-buffer gnus-article-buffer)
6733 (let ((buffer-read-only nil))
6735 (if (> arg 0) (remove-text-properties 1 (point-max) '(invisible t))
6736 (if (< arg 0) (run-hooks 'gnus-article-display-hook)))
6737 (if (text-property-any 1 (point-max) 'invisible t)
6738 (remove-text-properties 1 (point-max) '(invisible t))
6739 (run-hooks 'gnus-article-display-hook))))))
6741 (defun gnus-summary-show-all-headers ()
6742 "Make all header lines visible."
6744 (gnus-article-show-all-headers))
6746 (defun gnus-summary-toggle-mime (arg)
6747 "Toggle MIME processing.
6748 If ARG is a positive number, turn MIME processing on."
6750 (setq gnus-show-mime
6751 (if (null arg) (not gnus-show-mime)
6752 (> (prefix-numeric-value arg) 0)))
6753 (gnus-summary-select-article t 'force))
6755 (defun gnus-summary-caesar-message (rotnum)
6756 "Caesar rotates all letters of current message by 13/47 places.
6757 With prefix arg, specifies the number of places to rotate each letter forward.
6758 Caesar rotates Japanese letters by 47 places in any case."
6760 (gnus-summary-select-article)
6761 (let ((mail-header-separator "")) ; !!! Is this necessary?
6762 (gnus-overload-functions)
6763 (gnus-eval-in-buffer-window
6767 ;; We don't want to jump to the beginning of the message.
6768 ;; `save-excursion' does not do its job.
6769 (move-to-window-line 0)
6770 (let ((last (point)))
6771 (news-caesar-buffer-body rotnum)
6775 (defun gnus-summary-stop-page-breaking ()
6776 "Stop page breaking in the current article."
6778 (gnus-summary-select-article)
6779 (gnus-eval-in-buffer-window gnus-article-buffer (widen)))
6781 ;; Suggested by Brian Edmonds <bedmonds@prodigy.bc.ca>.
6783 (defun gnus-summary-move-article (n &optional to-newsgroup select-method)
6784 "Move the current article to a different newsgroup.
6785 If N is a positive number, move the N next articles.
6786 If N is a negative number, move the N previous articles.
6787 If N is nil and any articles have been marked with the process mark,
6788 move those articles instead.
6789 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
6790 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
6791 re-spool using this method.
6792 For this function to work, both the current newsgroup and the
6793 newsgroup that you want to move to have to support the `request-move'
6794 and `request-accept' functions. (Ie. mail newsgroups at present.)"
6796 (gnus-set-global-variables)
6797 (or (gnus-check-backend-function 'request-move-article gnus-newsgroup-name)
6798 (error "The current newsgroup does not support article moving"))
6799 (let ((articles (gnus-summary-work-articles n))
6801 (if (and (not to-newsgroup) (not select-method))
6804 (format "Where do you want to move %s? "
6805 (if (> (length articles) 1)
6806 (format "these %d articles" (length articles))
6808 gnus-active-hashtb nil t)))
6809 (or (gnus-check-backend-function 'request-accept-article
6810 (or select-method to-newsgroup))
6811 (error "%s does not support article moving" to-newsgroup))
6812 (message "Moving to %s: %s..." (or select-method to-newsgroup) articles)
6815 (gnus-request-move-article
6818 (nth 1 (gnus-find-method-for-group gnus-newsgroup-name))
6819 (list 'gnus-request-accept-article
6821 (quote select-method)
6823 (let* ((buffer-read-only nil)
6826 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
6828 (gnus-group-prefixed-name
6830 (if select-method (list select-method "")
6831 (gnus-find-method-for-group to-newsgroup)))
6832 gnus-newsrc-hashtb)))
6833 (info (nth 2 entry))
6834 (article (car articles))
6835 (marked (nth 3 info)))
6836 (gnus-summary-goto-subject article)
6837 (delete-region (progn (beginning-of-line) (point))
6838 (progn (forward-line 1) (point)))
6839 (if (not (memq article gnus-newsgroup-unreads))
6840 (setcar (cdr (cdr info))
6841 (gnus-add-to-range (nth 2 info)
6842 (list (cdr art-group)))))
6843 ;; !!! Here one should copy all the marks over to the new
6844 ;; newsgroup, but I couldn't be bothered. nth on that!
6846 (message "Couldn't move article %s" (car articles)))
6847 (gnus-summary-remove-process-mark (car articles))
6848 (setq articles (cdr articles)))))
6850 (defun gnus-summary-respool-article (n &optional respool-method)
6851 "Respool the current article.
6852 The article will be squeezed through the mail spooling process again,
6853 which means that it will be put in some mail newsgroup or other
6854 depending on `nnmail-split-methods'.
6855 If N is a positive number, respool the N next articles.
6856 If N is a negative number, respool the N previous articles.
6857 If N is nil and any articles have been marked with the process mark,
6858 respool those articles instead.
6859 For this function to work, both the current newsgroup and the
6860 newsgroup that you want to move to have to support the `request-move'
6861 and `request-accept' functions. (Ie. mail newsgroups at present.)"
6863 (gnus-set-global-variables)
6865 (setq respool-method
6867 "What method do you want to use when respooling? "
6868 (gnus-methods-using 'respool) nil t)))
6869 (gnus-summary-move-article n nil (intern respool-method)))
6871 ;; Summary score commands.
6873 ;; Suggested by boubaker@cenatls.cena.dgac.fr.
6875 (defun gnus-summary-raise-score (n)
6876 "Raise the score of the current article by N."
6878 (gnus-summary-set-score (+ (gnus-summary-article-score) n)))
6880 (defun gnus-summary-lower-score (n)
6881 "Lower the score of the current article by N."
6883 (gnus-summary-raise-score (- n)))
6885 (defun gnus-summary-set-score (n)
6886 "Set the score of the current article to N."
6888 ;; Skip dummy header line.
6890 (if (= (gnus-summary-article-mark) ?Z) (forward-line 1))
6891 (let ((buffer-read-only nil))
6893 (gnus-summary-update-mark
6894 (if (= n gnus-summary-default-score) ?
6895 (if (< n gnus-summary-default-score)
6896 gnus-score-below-mark gnus-score-over-mark)) 'score))
6897 (let* ((article (gnus-summary-article-number))
6898 (score (assq article gnus-newsgroup-scored)))
6899 (if score (setcdr score n)
6900 (setq gnus-newsgroup-scored
6901 (cons (cons article n) gnus-newsgroup-scored))))
6902 (gnus-summary-update-line)))
6904 (defmacro gnus-raise (field expression level)
6905 (` (gnus-kill (, field) (, expression)
6906 (function (gnus-summary-raise-score (, level))) t)))
6908 (defmacro gnus-lower (field expression level)
6909 (` (gnus-kill (, field) (, expression)
6910 (function (gnus-summary-raise-score (- (, level)))) t)))
6912 ;; Summary marking commands.
6914 (defun gnus-summary-raise-same-subject-and-select (score)
6915 "Raise articles which has the same subject with SCORE and select the next."
6917 (let ((subject (gnus-summary-subject-string)))
6918 (gnus-summary-raise-score score)
6919 (while (gnus-summary-search-subject nil nil subject)
6920 (gnus-summary-raise-score score))
6921 (gnus-summary-next-article t)))
6923 (defun gnus-summary-raise-same-subject (score)
6924 "Raise articles which has the same subject with SCORE."
6926 (let ((subject (gnus-summary-subject-string)))
6927 (gnus-summary-raise-score score)
6928 (while (gnus-summary-search-subject nil nil subject)
6929 (gnus-summary-raise-score score))
6930 (gnus-summary-next-subject 1 t)))
6932 (defun gnus-summary-raise-thread (score)
6933 "Raise articles under current thread with SCORE."
6937 (let ((level (gnus-summary-thread-level)))
6938 (gnus-summary-raise-score score)
6939 (while (and (zerop (gnus-summary-next-subject 1))
6940 (> (gnus-summary-thread-level) level))
6941 (gnus-summary-raise-score score))
6943 (or (zerop (gnus-summary-next-subject 1 t))
6945 (gnus-summary-position-cursor)
6946 (gnus-set-mode-line 'summary))
6948 (defun gnus-summary-lower-same-subject-and-select (score)
6949 "Raise articles which has the same subject with SCORE and select the next."
6951 (gnus-summary-raise-same-subject-and-select (- score)))
6953 (defun gnus-summary-lower-same-subject (score)
6954 "Raise articles which has the same subject with SCORE."
6956 (gnus-summary-raise-same-subject (- score)))
6958 (defun gnus-summary-lower-thread (score)
6959 "Raise articles under current thread with SCORE."
6961 (gnus-summary-raise-thread (- score)))
6963 (defun gnus-summary-kill-same-subject-and-select (unmark)
6964 "Mark articles which has the same subject as read, and then select the next.
6965 If UNMARK is positive, remove any kind of mark.
6966 If UNMARK is negative, tick articles."
6969 (setq unmark (prefix-numeric-value unmark)))
6971 (gnus-summary-mark-same-subject
6972 (gnus-summary-subject-string) unmark)))
6973 ;; Select next unread article. If auto-select-same mode, should
6974 ;; select the first unread article.
6975 (gnus-summary-next-article t (and gnus-auto-select-same
6976 (gnus-summary-subject-string)))
6977 (message "%d articles are marked as %s"
6978 count (if unmark "unread" "read"))
6981 (defun gnus-summary-kill-same-subject (unmark)
6982 "Mark articles which has the same subject as read.
6983 If UNMARK is positive, remove any kind of mark.
6984 If UNMARK is negative, tick articles."
6987 (setq unmark (prefix-numeric-value unmark)))
6989 (gnus-summary-mark-same-subject
6990 (gnus-summary-subject-string) unmark)))
6991 ;; If marked as read, go to next unread subject.
6993 ;; Go to next unread subject.
6994 (gnus-summary-next-subject 1 t))
6995 (message "%d articles are marked as %s"
6996 count (if unmark "unread" "read"))
6999 (defun gnus-summary-mark-same-subject (subject &optional unmark)
7000 "Mark articles with same SUBJECT as read, and return marked number.
7001 If optional argument UNMARK is positive, remove any kinds of marks.
7002 If optional argument UNMARK is negative, mark articles as unread instead."
7005 (cond ((null unmark)
7006 (gnus-summary-mark-as-read nil gnus-killed-mark))
7008 (gnus-summary-tick-article nil t))
7010 (gnus-summary-tick-article)))
7012 (gnus-summary-search-forward nil subject))
7013 (cond ((null unmark)
7014 (gnus-summary-mark-as-read nil gnus-killed-mark))
7016 (gnus-summary-tick-article nil t))
7018 (gnus-summary-tick-article)))
7019 (setq count (1+ count))
7021 ;; Hide killed thread subtrees. Does not work properly always.
7022 ;;(and (null unmark)
7023 ;; gnus-thread-hide-killed
7024 ;; (gnus-summary-hide-thread))
7025 ;; Return number of articles marked as read.
7029 (defun gnus-summary-mark-as-processable (n &optional unmark)
7030 "Set the process mark on the next N articles.
7031 If N is negative, mark backward instead. If UNMARK is non-nil, remove
7032 the process mark instead. The difference between N and the actual
7033 number of articles marked is returned."
7035 (let ((backward (< n 0))
7040 (gnus-summary-remove-process-mark (gnus-summary-article-number))
7041 (gnus-summary-set-process-mark (gnus-summary-article-number)))
7042 (zerop (gnus-summary-next-subject (if backward -1 1))))
7044 (if (/= 0 n) (message "No more articles"))
7047 (defun gnus-summary-unmark-as-processable (n)
7048 "Remove the process mark from the next N articles.
7049 If N is negative, mark backward instead. The difference between N and
7050 the actual number of articles marked is returned."
7052 (gnus-summary-mark-as-processable n t))
7054 (defun gnus-summary-unmark-all-processable ()
7055 "Remove the process mark from all articles."
7058 (while gnus-newsgroup-processable
7059 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
7060 (gnus-summary-position-cursor))
7062 (defun gnus-summary-mark-as-expirable (n)
7063 "Mark N articles forward as expirable.
7064 If N is negative, mark backward instead. The difference between N and
7065 the actual number of articles marked is returned."
7067 (gnus-summary-mark-forward n gnus-expirable-mark))
7069 (defun gnus-summary-expire-articles ()
7070 "Expire all articles that are marked as expirable in the current group."
7072 (if (and gnus-newsgroup-expirable
7073 (gnus-check-backend-function
7074 'request-expire-articles gnus-newsgroup-name))
7075 (let ((expirable gnus-newsgroup-expirable))
7076 ;; The list of articles that weren't expired is returned.
7077 (setq gnus-newsgroup-expirable
7078 (gnus-request-expire-articles gnus-newsgroup-expirable
7079 gnus-newsgroup-name))
7080 ;; We go through the old list of expirable, and mark all
7081 ;; really expired articles as non-existant.
7083 (or (memq (car expirable) gnus-newsgroup-expirable)
7084 (gnus-summary-mark-as-read (car expirable) "%"))
7085 (setq expirable (cdr expirable))))))
7087 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7088 (defun gnus-summary-delete-article (n)
7089 "Delete the N next (mail) articles.
7090 This command actually deletes articles. This is not a marking
7091 command. The article will disappear forever from you life, never to
7093 If N is negative, delete backwards.
7094 If N is nil and articles have been marked with the process mark,
7095 delete these instead."
7097 (or (gnus-check-backend-function 'request-expire-articles
7098 gnus-newsgroup-name)
7099 (error "The current newsgroup does not support article deletion."))
7100 ;; Compute the list of articles to delete.
7102 (if (and n (numberp n))
7103 (let ((backward (< n 0))
7107 (setq articles (cons (gnus-summary-article-number)
7109 (gnus-summary-search-forward nil nil backward))
7111 (setq articles (sort articles (function <))))
7112 (setq articles (or (setq gnus-newsgroup-processable
7113 (sort gnus-newsgroup-processable (function <)))
7114 (list (gnus-summary-article-number)))))
7115 (if (and gnus-novice-user
7117 (format "Do you really want to delete %s forever? "
7118 (if (> (length articles) 1) "these articles"
7121 ;; Delete the articles.
7122 (setq gnus-newsgroup-expirable
7123 (gnus-request-expire-articles
7124 articles gnus-newsgroup-name 'force))
7126 (gnus-summary-mark-as-read (car articles) gnus-canceled-mark)
7127 (setq articles (cdr articles))))))
7129 (defun gnus-summary-edit-article ()
7130 "Enter into a buffer and edit the current article.
7131 This will have permanent effect only in mail groups."
7133 (or (gnus-check-backend-function
7134 'request-replace-article gnus-newsgroup-name)
7135 (error "The current newsgroup does not support article editing."))
7136 (gnus-summary-select-article t)
7138 (message "C-c C-c to end edits")
7139 (setq buffer-read-only nil)
7141 (use-local-map (copy-keymap (current-local-map)))
7142 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
7144 (search-forward "\n\n" nil t))
7146 (defun gnus-summary-edit-article-done ()
7147 "Make edits to the current article permanent."
7149 (if (not (gnus-request-replace-article
7150 (cdr gnus-article-current) (car gnus-article-current)
7152 (error "Couldn't replace article.")
7154 (use-local-map gnus-article-mode-map)
7155 (setq buffer-read-only t)
7156 (pop-to-buffer gnus-summary-buffer)))
7158 (defun gnus-summary-mark-article-as-replied (article)
7159 "Mark ARTICLE replied and update the summary line."
7160 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
7161 (let ((buffer-read-only nil))
7162 (if (gnus-summary-goto-subject article)
7164 (gnus-summary-update-mark gnus-replied-mark 'replied)
7167 (defun gnus-summary-set-bookmark (article)
7168 "Set a bookmark in current article."
7169 (interactive (list (gnus-summary-article-number)))
7170 (if (or (not (get-buffer gnus-article-buffer))
7171 (not gnus-current-article)
7172 (not gnus-article-current)
7173 (not (equal gnus-newsgroup-name (car gnus-article-current))))
7174 (error "No current article selected"))
7175 ;; Remove old bookmark, if one exists.
7176 (let ((old (assq article gnus-newsgroup-bookmarks)))
7177 (if old (setq gnus-newsgroup-bookmarks
7178 (delq old gnus-newsgroup-bookmarks))))
7179 ;; Set the new bookmark, which is on the form
7180 ;; (article-number . line-number-in-body).
7181 (setq gnus-newsgroup-bookmarks
7185 (set-buffer gnus-article-buffer)
7190 (search-forward "\n\n" nil t)
7193 gnus-newsgroup-bookmarks))
7194 (message "A bookmark has been added to the current article."))
7196 (defun gnus-summary-remove-bookmark (article)
7197 "Remove the bookmark from the current article."
7198 (interactive (list (gnus-summary-article-number)))
7199 ;; Remove old bookmark, if one exists.
7200 (let ((old (assq article gnus-newsgroup-bookmarks)))
7203 (setq gnus-newsgroup-bookmarks
7204 (delq old gnus-newsgroup-bookmarks))
7205 (message "Removed bookmark."))
7206 (message "No bookmark in current article."))))
7208 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7209 (defun gnus-summary-mark-as-dormant (n)
7210 "Mark N articles forward as dormant.
7211 If N is negative, mark backward instead. The difference between N and
7212 the actual number of articles marked is returned."
7214 (gnus-summary-mark-forward n gnus-dormant-mark))
7216 (defun gnus-summary-set-process-mark (article)
7217 "Set the process mark on ARTICLE and update the summary line."
7218 (setq gnus-newsgroup-processable (cons article gnus-newsgroup-processable))
7219 (let ((buffer-read-only nil))
7220 (if (gnus-summary-goto-subject article)
7222 (if (= (gnus-summary-article-mark) ?Z) (forward-line 1))
7223 (gnus-summary-update-mark gnus-process-mark 'replied)
7226 (defun gnus-summary-remove-process-mark (article)
7227 "Remove the process mark from ARTICLE and update the summary line."
7228 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
7229 (let ((buffer-read-only nil))
7230 (if (gnus-summary-goto-subject article)
7232 (and (= (gnus-summary-article-mark) ?Z) (forward-line 1))
7233 (gnus-summary-update-mark ? 'replied)
7234 (if (memq article gnus-newsgroup-replied)
7235 (gnus-summary-update-mark gnus-replied-mark 'replied))
7238 (defun gnus-summary-mark-forward (n &optional mark)
7239 "Mark N articles as read forwards.
7240 If N is negative, mark backwards instead.
7241 Mark with MARK. If MARK is ? , ?! or ??, articles will be
7243 The difference between N and the actual number of articles marked is
7246 (gnus-set-global-variables)
7247 (let ((backward (< n 0))
7249 (mark (or mark gnus-dread-mark)))
7251 (gnus-summary-mark-article nil mark)
7252 (zerop (gnus-summary-next-subject (if backward -1 1))))
7254 (if (/= 0 n) (message "No more %sarticles" (if mark "" "unread ")))
7255 (gnus-set-mode-line 'summary)
7258 (defun gnus-summary-mark-article (&optional article mark)
7259 "Mark ARTICLE with MARK.
7260 MARK can be any character.
7261 Five MARK strings are reserved: ? (unread),
7262 ?! (ticked), ?? (dormant), ?D (read), ?E (expirable).
7263 If MARK is nil, then the default character ?D is used.
7264 If ARTICLE is nil, then the article on the current line will be
7266 ;; If no mark is given, then we check auto-expiring.
7268 (and (numberp mark) (or (= mark gnus-killed-mark)
7269 (= mark gnus-read-mark))))
7270 (and gnus-newsgroup-auto-expire (setq mark gnus-expirable-mark)))
7271 (let* ((buffer-read-only nil)
7272 (mark (or (and (stringp mark) (aref mark 0)) mark gnus-dread-mark))
7273 (article (or article (gnus-summary-article-number))))
7274 (if (or (= mark gnus-unread-mark)
7275 (= mark gnus-ticked-mark)
7276 (= mark gnus-dormant-mark))
7277 (gnus-mark-article-as-unread article mark)
7278 (gnus-mark-article-as-read article mark))
7279 (if (gnus-summary-goto-subject article)
7281 (gnus-summary-show-thread)
7283 (if (= (gnus-summary-article-mark) ?Z) (forward-line 1))
7285 (gnus-summary-update-mark mark 'unread)
7288 (defun gnus-summary-update-mark (mark type)
7290 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
7294 (forward-char forward)
7295 (setq plist (text-properties-at (point)))
7297 (and (memq 'gnus-mark plist) (setcar (cdr (memq 'gnus-mark plist)) mark))
7299 (and plist (add-text-properties (1- (point)) (point) plist)))))
7301 (defun gnus-mark-article-as-read (article &optional mark)
7302 "Enter ARTICLE in the pertinent lists and remove it from others."
7303 ;; Make the article expirable.
7304 (let ((mark (or (and (stringp mark) (aref mark 0)) mark gnus-dread-mark)))
7305 (if (= mark gnus-expirable-mark)
7306 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
7307 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
7308 ;; Remove from unread and marked lists.
7309 (setq gnus-newsgroup-unreads
7310 (delq article gnus-newsgroup-unreads))
7311 (setq gnus-newsgroup-marked
7312 (delq article gnus-newsgroup-marked))
7313 (setq gnus-newsgroup-dormant
7314 (delq article gnus-newsgroup-dormant))))
7316 (defun gnus-mark-article-as-unread (article &optional mark)
7317 "Enter ARTICLE in the pertinent lists and remove it from others."
7318 (let ((mark (or (and (stringp mark) (aref mark 0)) mark gnus-ticked-mark)))
7319 ;; Add to unread list.
7320 (or (memq article gnus-newsgroup-unreads)
7321 (setq gnus-newsgroup-unreads
7322 (cons article gnus-newsgroup-unreads)))
7323 ;; If CLEAR-MARK is non-nil, the article must be removed from marked
7324 ;; list. Otherwise, it must be added to the list.
7325 (setq gnus-newsgroup-marked
7326 (delq article gnus-newsgroup-marked))
7327 (setq gnus-newsgroup-dormant
7328 (delq article gnus-newsgroup-dormant))
7329 (setq gnus-newsgroup-expirable
7330 (delq article gnus-newsgroup-expirable))
7331 (if (= mark gnus-ticked-mark)
7332 (setq gnus-newsgroup-marked
7333 (cons article gnus-newsgroup-marked)))
7334 (if (= mark gnus-dormant-mark)
7335 (setq gnus-newsgroup-dormant
7336 (cons article gnus-newsgroup-dormant)))))
7338 (defalias 'gnus-summary-mark-as-unread-forward
7339 'gnus-summary-tick-article-forward)
7340 (make-obsolete 'gnus-summary-mark-as-unread-forward
7341 'gnus-summary-tick-article--forward)
7342 (defun gnus-summary-tick-article-forward (n)
7343 "Tick N articles forwards.
7344 If N is negative, tick backwards instead.
7345 The difference between N and the number of articles ticked is returned."
7347 (gnus-summary-mark-forward n gnus-ticked-mark))
7349 (defalias 'gnus-summary-mark-as-unread-backward 'gnus-summary-tick-article-backward)
7350 (make-obsolete 'gnus-summary-mark-as-unread-backward 'gnus-summary-tick-article-backward)
7351 (defun gnus-summary-tick-article-backward (n)
7352 "Tick N articles backwards.
7353 The difference between N and the number of articles ticked is returned."
7355 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
7357 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7358 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7359 (defun gnus-summary-tick-article (&optional article clear-mark)
7360 "Mark current article as unread.
7361 Optional 1st argument ARTICLE specifies article number to be marked as unread.
7362 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
7363 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
7366 (defun gnus-summary-mark-as-read-forward (n)
7367 "Mark N articles as read forwards.
7368 If N is negative, mark backwards instead.
7369 The difference between N and the actual number of articles marked is
7372 (gnus-summary-mark-forward n))
7374 (defun gnus-summary-mark-as-read-backward (n)
7375 "Mark the N articles as read backwards.
7376 The difference between N and the actual number of articles marked is
7379 (gnus-summary-mark-forward (- n)))
7381 (defun gnus-summary-mark-as-read (&optional article mark)
7382 "Mark current article as read.
7383 ARTICLE specifies the article to be marked as read.
7384 MARK specifies a string to be inserted at the beginning of the line.
7385 Any kind of string (length 1) except for a space and `-' is ok."
7386 (gnus-summary-mark-article article mark))
7388 (defun gnus-summary-clear-mark-forward (n)
7389 "Clear marks from N articles forward.
7390 If N is negative, clear backward instead.
7391 The difference between N and the number of marks cleared is returned."
7393 (gnus-summary-mark-forward n gnus-unread-mark))
7395 (defun gnus-summary-clear-mark-backward (n)
7396 "Clear marks from N articles backward.
7397 The difference between N and the number of marks cleared is returned."
7399 (gnus-summary-mark-forward (- n) gnus-unread-mark))
7401 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>.
7402 (defalias 'gnus-summary-delete-marked-as-read
7403 'gnus-summary-remove-lines-marked-as-read)
7404 (make-obsolete 'gnus-summary-delete-marked-as-read
7405 'gnus-summary-remove-lines-marked-as-read)
7406 (defun gnus-summary-remove-lines-marked-as-read ()
7407 "Remove lines that are marked as read."
7409 (gnus-summary-remove-lines-marked-with
7411 (lambda (char) (char-to-string (symbol-value char)))
7412 '(gnus-dread-mark gnus-read-mark
7413 gnus-killed-mark gnus-kill-file-mark
7414 gnus-low-score-mark gnus-expirable-mark)
7417 (defalias 'gnus-summary-delete-marked-with
7418 'gnus-summary-remove-lines-marked-with)
7419 (make-obsolete 'gnus-summary-delete-marked-with
7420 'gnus-summary-remove-lines-marked-with)
7421 ;; Rewrite by Daniel Quinlan <quinlan@best.com>.
7422 (defun gnus-summary-remove-lines-marked-with (marks)
7423 "Remove lines that are marked with MARKS (e.g. \"DK\")."
7424 (interactive "sMarks: ")
7425 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
7427 (set-buffer gnus-summary-buffer)
7428 (let ((buffer-read-only nil)
7429 (marks (concat "^[" marks "]"))
7431 (goto-char (point-min))
7432 (while (search-forward-regexp marks (point-max) t)
7437 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>
7438 (append-to-buffer gnus-newsgroup-expunged-buffer beg (point))
7439 (delete-region beg (point)))))
7440 (or (zerop (buffer-size))
7442 (gnus-summary-prev-subject 1)
7443 (gnus-summary-position-cursor)))))
7445 (defun gnus-summary-expunge-below (score)
7446 "Remove articles with score less than SCORE."
7448 (setq score (if score
7449 (prefix-numeric-value score)
7450 gnus-summary-default-score))
7452 (set-buffer gnus-summary-buffer)
7453 (goto-char (point-min))
7454 (let ((buffer-read-only nil)
7457 (if (< (gnus-summary-article-score) score)
7461 (append-to-buffer gnus-newsgroup-expunged-buffer beg (point))
7462 (delete-region beg (point)))
7465 (or (zerop (buffer-size))
7467 (gnus-summary-prev-subject 1)
7468 (gnus-summary-position-cursor))))))
7470 (defun gnus-summary-mark-below (score mark)
7471 "Mark articles with score less than SCORE with MARK."
7472 (interactive "P\ncMark: ")
7473 (setq score (if score
7474 (prefix-numeric-value score)
7475 gnus-summary-default-score))
7477 (set-buffer gnus-summary-buffer)
7478 (goto-char (point-min))
7480 (if (< (gnus-summary-article-score) score)
7482 (gnus-summary-mark-article nil (char-to-string mark))
7484 (forward-line 1)))))
7486 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
7487 (defun gnus-summary-set-mark-below (score)
7488 "Automatically mark articles with score below SCORE as read."
7490 (setq score (if score
7491 (prefix-numeric-value score)
7492 gnus-summary-default-score))
7493 (setq gnus-summary-mark-below score)
7494 (gnus-summary-update-lines))
7496 (defun gnus-summary-kill-below (score)
7497 "Mark articles with score below SCORE as read."
7499 (gnus-summary-mark-below score gnus-killed-mark))
7501 (defun gnus-summary-clear-above (score)
7502 "Clear all marks from articles with score above SCORE."
7504 (gnus-summary-mark-above score gnus-unread-mark))
7506 (defun gnus-summary-tick-above (score)
7507 "Tick all articles with score above SCORE."
7509 (gnus-summary-mark-above score gnus-ticked-mark))
7511 (defun gnus-summary-mark-above (score mark)
7512 "Mark articles with score less than SCORE with MARK."
7513 (interactive "P\ncMark: ")
7514 (setq score (if score
7515 (prefix-numeric-value score)
7516 gnus-summary-default-score))
7518 (set-buffer gnus-summary-buffer)
7519 (goto-char (point-min))
7521 (if (> (gnus-summary-article-score) score)
7523 (gnus-summary-mark-article nil mark)
7525 (forward-line 1)))))
7527 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7528 (defun gnus-summary-show-all-expunged ()
7529 "Show all previously expunge articles."
7531 (let ((buffer-read-only nil))
7533 (if (and gnus-newsgroup-expunged-buffer
7535 (set-buffer gnus-newsgroup-expunged-buffer)
7536 (not (zerop (buffer-size)))))
7538 (append-to-buffer gnus-summary-buffer (point-min) (point-max))
7540 (error "No lines expunged")))))
7542 (defun gnus-summary-show-all-dormant ()
7543 "Display all the hidden articles that are marked as dormant."
7545 (let ((int gnus-newsgroup-dormant-subjects)
7546 (buffer-read-only nil))
7548 (error "No dormant articles hidden."))
7549 (goto-char (point-min))
7552 (insert (cdr (car int)))
7553 (setq int (cdr int))))
7554 (gnus-summary-position-cursor)
7555 (setq gnus-newsgroup-dormant-subjects nil)))
7557 (defun gnus-summary-catchup (all &optional quietly to-here)
7558 "Mark all articles not marked as unread in this newsgroup as read.
7559 If prefix argument ALL is non-nil, all articles are marked as read.
7560 If QUIETLY is non-nil, no questions will be asked.
7561 If TO-HERE is non-nil, it should be a point in the buffer. All
7562 articles before this point will be marked as read.
7563 The number of articles marked as read is returned."
7566 (not gnus-interactive-catchup) ;Without confirmation?
7570 "Mark absolutely all articles as read? "
7571 "Mark all unread articles as read? ")))
7572 (let ((unreads (length gnus-newsgroup-unreads)))
7573 (if (gnus-summary-first-subject (not all))
7574 (while (and (gnus-summary-mark-as-read nil gnus-catchup-mark)
7575 (if to-here (< (point) to-here) t)
7576 (gnus-summary-search-subject nil (not all)))))
7577 (- unreads (length gnus-newsgroup-unreads))))
7578 (gnus-summary-position-cursor))
7580 (defun gnus-summary-catchup-to-here (&optional all)
7581 "Mark all unticked articles before the current one as read.
7582 If ALL is non-nil, also mark ticked and dormant articles as read."
7585 (gnus-summary-catchup all nil (point))
7586 (gnus-summary-position-cursor))
7588 (defun gnus-summary-catchup-all (&optional quietly)
7589 "Mark all articles in this newsgroup as read."
7591 (gnus-summary-catchup t quietly))
7593 (defun gnus-summary-catchup-and-exit (all &optional quietly)
7594 "Mark all articles not marked as unread in this newsgroup as read, then exit.
7595 If prefix argument ALL is non-nil, all articles are marked as read."
7597 (gnus-summary-catchup all quietly)
7598 ;; Select next newsgroup or exit.
7599 (if (eq gnus-auto-select-next 'quietly)
7600 (gnus-summary-next-group nil)
7601 (gnus-summary-exit)))
7603 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
7604 "Mark all articles in this newsgroup as read, and then exit."
7606 (gnus-summary-catchup-and-exit t quietly))
7608 ;; Thread-based commands.
7610 (defun gnus-summary-toggle-threads (arg)
7611 "Toggle showing conversation threads.
7612 If ARG is positive number, turn showing conversation threads on."
7614 (let ((current (gnus-summary-article-number)))
7615 (setq gnus-show-threads
7616 (if (null arg) (not gnus-show-threads)
7617 (> (prefix-numeric-value arg) 0)))
7618 (gnus-summary-prepare)
7619 (gnus-summary-goto-subject current)))
7621 (defun gnus-summary-show-all-threads ()
7625 (let ((buffer-read-only nil))
7626 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
7627 (gnus-summary-position-cursor))
7629 (defun gnus-summary-show-thread ()
7630 "Show thread subtrees.
7631 Returns nil if no thread was there to be shown."
7635 (let ((buffer-read-only nil)
7636 (beg (progn (beginning-of-line) (point)))
7637 (end (save-excursion (end-of-line) (point))))
7639 ;; Any hidden lines here?
7640 (search-forward "\r" end t)
7641 (subst-char-in-region beg end ?\^M ?\n t))))
7642 (gnus-summary-position-cursor)))
7644 (defun gnus-summary-hide-all-threads ()
7645 "Hide all thread subtrees."
7648 (goto-char (point-min))
7649 (gnus-summary-hide-thread)
7650 (while (and (not (eobp)) (zerop (forward-line 1)))
7651 (gnus-summary-hide-thread))
7653 (gnus-summary-position-cursor))
7655 (defun gnus-summary-hide-thread ()
7656 "Hide thread subtrees.
7657 Returns nil if no threads were there to be hidden."
7659 (let ((buffer-read-only nil)
7661 (level (gnus-summary-thread-level))
7663 ;; Go forward until either the buffer ends or the subthread
7667 (while (and (zerop (forward-line 1))
7668 (> (gnus-summary-thread-level) level))
7673 (search-backward "\n" start t))
7674 (subst-char-in-region start end ?\n ?\^M t)
7675 (forward-line -1)))))
7677 (defun gnus-summary-go-to-next-thread (&optional previous)
7678 "Go to the same level (or less) next thread.
7679 If PREVIOUS is non-nil, go to previous thread instead.
7680 Return the article number moved to, or nil if moving was impossible."
7681 (let ((level (gnus-summary-thread-level))
7682 (article (gnus-summary-article-number)))
7684 (while (and (zerop (gnus-summary-prev-subject 1))
7685 (> (gnus-summary-thread-level) level)))
7686 (while (and (zerop (gnus-summary-next-subject 1))
7687 (> (gnus-summary-thread-level) level))))
7688 (let ((oart (gnus-summary-article-number)))
7689 (and (/= oart article) oart))))
7691 (defun gnus-summary-next-thread (n)
7692 "Go to the same level next N'th thread.
7693 If N is negative, search backward instead.
7694 Returns the difference between N and the number of skips actually
7697 (let ((backward (< n 0))
7700 (gnus-summary-go-to-next-thread backward))
7702 (gnus-summary-position-cursor)
7703 (if (/= 0 n) (message "No more threads" ))
7706 (defun gnus-summary-prev-thread (n)
7707 "Go to the same level previous N'th thread.
7708 Returns the difference between N and the number of skips actually
7711 (gnus-summary-next-thread (- n)))
7713 (defun gnus-summary-go-down-thread (&optional same)
7714 "Go down one level in the current thread.
7715 If SAME is non-nil, also move to articles of the same level."
7716 (let ((level (gnus-summary-thread-level))
7718 (if (and (zerop (forward-line 1))
7719 (> (gnus-summary-thread-level) level))
7724 (defun gnus-summary-go-up-thread ()
7725 "Go up one level in the current thread."
7726 (let ((level (gnus-summary-thread-level))
7728 (while (and (zerop (forward-line -1))
7729 (>= (gnus-summary-thread-level) level)))
7730 (if (>= (gnus-summary-thread-level) level)
7736 (defun gnus-summary-down-thread (n)
7737 "Go down thread N steps.
7738 If N is negative, go up instead.
7739 Returns the difference between N and how many steps down that were
7745 (if up (gnus-summary-go-up-thread)
7746 (gnus-summary-go-down-thread)))
7748 (gnus-summary-position-cursor)
7749 (if (/= 0 n) (message "Can't go further" ))
7752 (defun gnus-summary-up-thread (n)
7753 "Go up thread N steps.
7754 If N is negative, go up instead.
7755 Returns the difference between N and how many steps down that were
7758 (gnus-summary-down-thread (- n)))
7760 (defun gnus-summary-kill-thread (unmark)
7761 "Mark articles under current thread as read.
7762 If the prefix argument is positive, remove any kinds of marks.
7763 If the prefix argument is negative, tick articles instead."
7766 (setq unmark (prefix-numeric-value unmark)))
7768 (level (gnus-summary-thread-level)))
7771 ;; Mark the article...
7772 (cond ((null unmark) (gnus-summary-mark-as-read nil gnus-killed-mark))
7773 ((> unmark 0) (gnus-summary-tick-article nil t))
7774 (t (gnus-summary-tick-article)))
7775 ;; ...and go forward until either the buffer ends or the subtree
7777 (if (not (and (zerop (forward-line 1))
7778 (> (gnus-summary-thread-level) level)))
7779 (setq killing nil))))
7780 ;; Hide killed subtrees.
7782 gnus-thread-hide-killed
7783 (gnus-summary-hide-thread))
7784 ;; If marked as read, go to next unread subject.
7786 ;; Go to next unread subject.
7787 (gnus-summary-next-subject 1 t)))
7788 (gnus-set-mode-line 'summary))
7790 ;; Summary sorting commands
7792 (defun gnus-summary-sort-by-number (reverse)
7793 "Sort summary buffer by article number.
7794 Argument REVERSE means reverse order."
7796 (gnus-summary-sort 'gnus-summary-article-number reverse))
7798 (defun gnus-summary-sort-by-author (reverse)
7799 "Sort summary buffer by author name alphabetically.
7800 If case-fold-search is non-nil, case of letters is ignored.
7801 Argument REVERSE means reverse order."
7805 (let ((extract (gnus-extract-address-components
7806 (header-from (gnus-get-header-by-number
7807 (gnus-summary-article-number))))))
7808 (or (car extract) (cdr extract))))
7811 (defun gnus-summary-sort-by-subject (reverse)
7812 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
7813 If case-fold-search is non-nil, case of letters is ignored.
7814 Argument REVERSE means reverse order."
7818 (downcase (gnus-simplify-subject (gnus-summary-subject-string))))
7821 (defun gnus-summary-sort-by-date (reverse)
7822 "Sort summary buffer by date.
7823 Argument REVERSE means reverse order."
7828 (header-date (gnus-get-header-by-number (gnus-summary-article-number)))))
7831 (defun gnus-summary-sort-by-score (reverse)
7832 "Sort summary buffer by score.
7833 Argument REVERSE means reverse order."
7835 (gnus-summary-sort 'gnus-summary-article-score (not reverse)))
7837 (defun gnus-summary-sort (predicate reverse)
7838 ;; Sort summary buffer by PREDICATE. REVERSE means reverse order.
7839 (let (buffer-read-only)
7840 (goto-char (point-min))
7841 (sort-subr reverse 'forward-line 'end-of-line predicate)))
7843 (defun gnus-sortable-date (date)
7844 "Make sortable string by string-lessp from DATE.
7845 Timezone package is used."
7846 (let* ((date (timezone-fix-time date nil nil)) ;[Y M D H M S]
7847 (year (aref date 0))
7848 (month (aref date 1))
7849 (day (aref date 2)))
7850 (timezone-make-sortable-date year month day
7851 (timezone-make-time-string
7852 (aref date 3) (aref date 4) (aref date 5)))
7856 ;; Summary saving commands.
7858 (defun gnus-summary-save-article (n)
7859 "Save the current article using the default saver function.
7860 If N is a positive number, save the N next articles.
7861 If N is a negative number, save the N previous articles.
7862 If N is nil and any articles have been marked with the process mark,
7863 save those articles instead.
7864 The variable `gnus-default-article-saver' specifies the saver function."
7866 (let (articles process)
7867 (if (and n (numberp n))
7868 (let ((backward (< n 0))
7872 (setq articles (cons (gnus-summary-article-number)
7874 (gnus-summary-search-forward nil nil backward))
7876 (setq articles (sort articles (function <))))
7877 (if gnus-newsgroup-processable
7879 (setq articles (setq gnus-newsgroup-processable
7880 (nreverse gnus-newsgroup-processable)))
7882 (setq articles (list (gnus-summary-article-number)))))
7884 (let ((header (gnus-gethash (int-to-string (car articles))
7885 gnus-newsgroup-headers-hashtb-by-number)))
7886 (if (vectorp header)
7888 (gnus-summary-display-article (car articles) t)
7889 (if (not gnus-save-all-headers)
7890 (gnus-article-hide-headers t))
7891 (if gnus-default-article-saver
7892 (funcall gnus-default-article-saver)
7893 (error "No default saver is defined.")))
7894 (if (assq 'name header)
7895 (gnus-copy-file (cdr (assq 'name header)))
7896 (message "Article %d is unsaveable" (car articles)))))
7898 (gnus-summary-remove-process-mark (car articles)))
7899 (setq articles (cdr articles)))
7900 (if process (setq gnus-newsgroup-processable
7901 (nreverse gnus-newsgroup-processable)))
7902 (gnus-summary-position-cursor)
7905 (defun gnus-summary-pipe-output (arg)
7906 "Pipe the current article to a subprocess.
7907 If N is a positive number, pipe the N next articles.
7908 If N is a negative number, pipe the N previous articles.
7909 If N is nil and any articles have been marked with the process mark,
7910 pipe those articles instead."
7912 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
7913 (gnus-summary-save-article arg)))
7915 (defun gnus-summary-save-article-mail (arg)
7916 "Append the current article to an mail file.
7917 If N is a positive number, save the N next articles.
7918 If N is a negative number, save the N previous articles.
7919 If N is nil and any articles have been marked with the process mark,
7920 save those articles instead."
7922 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
7923 (gnus-summary-save-article arg)))
7925 (defun gnus-summary-save-in-rmail (&optional filename)
7926 "Append this article to Rmail file.
7927 Optional argument FILENAME specifies file name.
7928 Directory to save to is default to `gnus-article-save-directory' which
7929 is initialized from the SAVEDIR environment variable."
7932 (funcall gnus-rmail-save-name gnus-newsgroup-name
7933 gnus-current-headers gnus-newsgroup-last-rmail)))
7937 (concat "Save article in rmail file: (default "
7938 (file-name-nondirectory default-name) ") ")
7939 (file-name-directory default-name)
7941 (gnus-make-directory (file-name-directory filename))
7942 (gnus-eval-in-buffer-window
7947 (gnus-output-to-rmail filename))))
7948 ;; Remember the directory name to save articles.
7949 (setq gnus-newsgroup-last-rmail filename)))
7951 (defun gnus-summary-save-in-mail (&optional filename)
7952 "Append this article to Unix mail file.
7953 Optional argument FILENAME specifies file name.
7954 Directory to save to is default to `gnus-article-save-directory' which
7955 is initialized from the SAVEDIR environment variable."
7958 (funcall gnus-mail-save-name gnus-newsgroup-name
7959 gnus-current-headers gnus-newsgroup-last-mail)))
7963 (concat "Save article in Unix mail file: (default "
7964 (file-name-nondirectory default-name) ") ")
7965 (file-name-directory default-name)
7968 (expand-file-name filename
7970 (file-name-directory default-name))))
7971 (gnus-make-directory (file-name-directory filename))
7972 (gnus-eval-in-buffer-window
7977 (if (and (file-readable-p filename) (rmail-file-p filename))
7978 (gnus-output-to-rmail filename)
7979 (rmail-output filename 1 t t)))))
7980 ;; Remember the directory name to save articles.
7981 (setq gnus-newsgroup-last-mail filename)))
7983 (defun gnus-summary-save-in-file (&optional filename)
7984 "Append this article to file.
7985 Optional argument FILENAME specifies file name.
7986 Directory to save to is default to `gnus-article-save-directory' which
7987 is initialized from the SAVEDIR environment variable."
7990 (funcall gnus-file-save-name gnus-newsgroup-name
7991 gnus-current-headers gnus-newsgroup-last-file)))
7995 (concat "Save article in file: (default "
7996 (file-name-nondirectory default-name) ") ")
7997 (file-name-directory default-name)
7999 (gnus-make-directory (file-name-directory filename))
8000 (gnus-eval-in-buffer-window
8005 (gnus-output-to-file filename))))
8006 ;; Remember the directory name to save articles.
8007 (setq gnus-newsgroup-last-file filename)))
8009 (defun gnus-summary-save-in-pipe (&optional command)
8010 "Pipe this article to subprocess."
8012 (let ((command (read-string "Shell command on article: "
8013 gnus-last-shell-command)))
8014 (if (string-equal command "")
8015 (setq command gnus-last-shell-command))
8016 (gnus-eval-in-buffer-window
8020 (shell-command-on-region (point-min) (point-max) command nil)))
8021 (setq gnus-last-shell-command command)))
8023 ;; Summary extract commands
8025 (defun gnus-summary-insert-pseudos (pslist)
8026 (let ((buffer-read-only nil)
8027 (article (gnus-summary-article-number))
8029 (or (gnus-summary-goto-subject article)
8030 (error (format "No such article: %d" article)))
8031 (gnus-summary-position-cursor)
8032 (if (eq gnus-view-pseudos 'automatic)
8034 (and (assq 'execute (car pslist))
8035 (gnus-execute-command (cdr (assq 'execute (car pslist)))))
8036 (setq pslist (cdr pslist)))
8039 (gnus-summary-goto-subject (or (cdr (assq 'article (car pslist)))
8040 (gnus-summary-article-number)))
8043 (insert " " (file-name-nondirectory
8044 (cdr (assq 'name (car pslist))))
8045 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
8046 (add-text-properties
8047 b (1+ b) (list 'gnus-subject (cdr (assq 'name (car pslist)))
8048 'gnus-number gnus-reffed-article-number
8049 'gnus-mark gnus-unread-mark
8050 'gnus-pseudo (car pslist)
8052 (gnus-sethash (int-to-string gnus-reffed-article-number)
8053 (car pslist) gnus-newsgroup-headers-hashtb-by-number)
8054 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
8055 (setq pslist (cdr pslist)))))))
8057 (defun gnus-request-pseudo-article (props)
8058 (cond ((assq 'execute props)
8059 (gnus-execute-command (cdr (assq 'execute props))))
8060 ((assq 'digest props)
8063 (let ((gnus-current-article (gnus-summary-article-number)))
8064 (run-hooks 'gnus-mark-article-hook)))
8066 (defun gnus-execute-command (command &optional automatic)
8068 (gnus-article-setup-buffer)
8069 (set-buffer gnus-article-buffer)
8070 (let ((command (if automatic command (read-string "Command: " command)))
8071 (buffer-read-only nil))
8073 (insert "$ " command "\n\n")
8074 (if gnus-view-pseudo-asynchronously
8075 (start-process "gnus-execute" nil "sh" "-c" command)
8076 (call-process "sh" nil t nil "-c" command)))))
8078 (defun gnus-copy-file (file &optional to)
8081 (list (read-file-name "Copy file: " default-directory)
8082 (read-file-name "Copy file to: " default-directory)))
8083 (or to (setq to (read-file-name "Copy file to: " default-directory)))
8084 (and (file-directory-p to)
8085 (setq to (concat (file-name-as-directory to)
8086 (file-name-nondirectory file))))
8087 (copy-file file to))
8089 ;; Summary score file commands
8091 ;; Much modification of the kill (ahem, score) code and lots of the
8092 ;; functions are written by Per Abrahamsen <amanda@iesd.auc.dk>.
8094 (defun gnus-summary-header (header)
8095 ;; Return HEADER for current articles, or error.
8096 (let ((article (gnus-summary-article-number)))
8098 (aref (gnus-get-header-by-number article)
8099 (nth 1 (assoc header gnus-header-index)))
8100 (error "No article on current line"))))
8102 (defun gnus-summary-score-entry (header match type score date &optional prompt)
8103 "Enter score file entry.
8104 HEADER is the header being scored.
8105 MATCH is the string we are looking for.
8106 TYPE is a flag indicating if it is a regexp or substring.
8107 SCORE is the score to add.
8108 DATE is the expire date."
8109 (interactive (list (completing-read "Header: "
8111 (lambda (x) (fboundp (nth 2 x)))
8113 (read-string "Match: ")
8114 (y-or-n-p "Use regexp match? ")
8115 (prefix-numeric-value current-prefix-arg)
8116 (if (y-or-n-p "Expire kill? ")
8117 (current-time-string)
8119 (and prompt (setq match (read-string "Match: " match)))
8120 (let ((score (gnus-score-default score)))
8121 (gnus-summary-score-effect header match type score)
8123 (gnus-summary-score-effect header match type score)
8124 (gnus-score-set header
8125 (cons (list match type score date)
8126 (gnus-score-get header) ))
8127 (gnus-score-set 'touched t)))
8129 (defun gnus-summary-score-effect (header match type score)
8130 "Simulate the effect of a score file entry.
8131 HEADER is the header being scored.
8132 MATCH is the string we are looking for.
8133 TYPE is a flag indicating if it is a regexp or substring.
8134 SCORE is the score to add."
8135 (interactive (list (completing-read "Header: "
8137 (lambda (x) (fboundp (nth 2 x)))
8139 (read-string "Match: ")
8140 (y-or-n-p "Use regexp match? ")
8141 (prefix-numeric-value current-prefix-arg)))
8143 (or (and (stringp match) (> (length match) 0))
8145 (goto-char (point-min))
8146 (let ((regexp (if type
8148 (concat "\\`.*" (regexp-quote match) ".*\\'"))))
8150 (let ((content (gnus-summary-header header))
8151 (case-fold-search t))
8153 (if (string-match regexp content)
8154 (gnus-summary-raise-score score))))
8155 (beginning-of-line 2)))))
8157 (defun gnus-summary-score-crossposting (score date)
8158 ;; Enter score file entry for current crossposting.
8159 ;; SCORE is the score to add.
8160 ;; DATE is the expire date.
8161 (let ((xref (gnus-summary-header "xref"))
8164 (or xref (error "This article is not crossposted"))
8165 (while (string-match " \\([^ \t]+\\):" xref start)
8166 (setq start (match-end 0))
8169 (substring xref (match-beginning 1) (match-end 1)))
8170 gnus-newsgroup-name))
8171 (gnus-summary-score-entry
8172 "xref" (concat " " group ":") nil score date t)))))
8174 (defun gnus-summary-temporarily-lower-by-subject (level)
8175 "Temporarily lower score by LEVEL for current subject.
8176 See `gnus-kill-expiry-days'."
8178 (gnus-summary-score-entry
8179 "subject" (gnus-simplify-subject-re (gnus-summary-header "subject"))
8180 nil (- (gnus-score-default level) )
8181 (current-time-string) t))
8183 (defun gnus-summary-temporarily-lower-by-author (level)
8184 "Temporarily lower score by LEVEL for current author.
8185 See `gnus-kill-expiry-days'."
8187 (gnus-summary-score-entry
8188 "from" (gnus-summary-header "from") nil (- (gnus-score-default level))
8189 (current-time-string) t))
8191 (defun gnus-summary-temporarily-lower-by-xref (level)
8192 "Temporarily lower score by LEVEL for current xref.
8193 See `gnus-kill-expiry-days'."
8195 (gnus-summary-score-crossposting (- (gnus-score-default level)) (current-time-string)))
8197 (defun gnus-summary-temporarily-lower-by-thread (level)
8198 "Temporarily lower score by LEVEL for current thread.
8199 See `gnus-kill-expiry-days'."
8201 (gnus-summary-score-entry
8202 "references" (gnus-summary-header "id")
8203 nil (- (gnus-score-default level)) (current-time-string)))
8205 (defun gnus-summary-lower-by-subject (level)
8206 "Lower score by LEVEL for current subject."
8208 (gnus-summary-score-entry
8209 "subject" (gnus-simplify-subject-re (gnus-summary-header "subject"))
8210 nil (- (gnus-score-default level))
8213 (defun gnus-summary-lower-by-author (level)
8214 "Lower score by LEVEL for current author."
8216 (gnus-summary-score-entry
8217 "from" (gnus-summary-header "from") nil (- (gnus-score-default level)) nil t))
8219 (defun gnus-summary-lower-by-xref (level)
8220 "Lower score by LEVEL for current xref."
8222 (gnus-summary-score-crossposting (- (gnus-score-default level)) nil))
8224 (defun gnus-summary-lower-followups-to-author (level)
8225 "Lower score by LEVEL for all followups to the current author."
8227 (gnus-kill-file-lower-followups-to-author
8228 (gnus-score-default level)
8229 (let ((article (gnus-summary-article-number)))
8230 (if article (gnus-get-header-by-number article)
8231 (error "No article on current line")))))
8233 (defun gnus-summary-temporarily-raise-by-subject (level)
8234 "Temporarily raise score by LEVEL for current subject.
8235 See `gnus-kill-expiry-days'."
8237 (gnus-summary-score-entry
8238 "subject" (gnus-simplify-subject-re (gnus-summary-header "subject"))
8239 nil level (current-time-string) t))
8241 (defun gnus-summary-temporarily-raise-by-author (level)
8242 "Temporarily raise score by LEVEL for current author.
8243 See `gnus-kill-expiry-days'."
8245 (gnus-summary-score-entry
8246 "from" (gnus-summary-header "from") nil level (current-time-string) t))
8248 (defun gnus-summary-temporarily-raise-by-xref (level)
8249 "Temporarily raise score by LEVEL for current xref.
8250 See `gnus-kill-expiry-days'."
8252 (gnus-summary-score-crossposting level (current-time-string)))
8254 (defun gnus-summary-temporarily-raise-by-thread (level)
8255 "Temporarily raise score by LEVEL for current thread.
8256 See `gnus-kill-expiry-days'."
8258 (gnus-summary-score-entry
8259 "references" (gnus-summary-header "id")
8260 nil level (current-time-string)))
8262 (defun gnus-summary-raise-by-subject (level)
8263 "Raise score by LEVEL for current subject."
8265 (gnus-summary-score-entry
8266 "subject" (gnus-simplify-subject-re (gnus-summary-header "subject"))
8269 (defun gnus-summary-raise-by-author (level)
8270 "Raise score by LEVEL for current author."
8272 (gnus-summary-score-entry
8273 "from" (gnus-summary-header "from") nil level nil t))
8275 (defun gnus-summary-raise-by-xref (level)
8276 "Raise score by LEVEL for current xref."
8278 (gnus-summary-score-crossposting level nil))
8280 (defun gnus-summary-edit-global-kill ()
8281 "Edit a global score file."
8283 (setq gnus-current-kill-article (gnus-summary-article-number))
8284 (gnus-kill-file-edit-file nil) ;Nil stands for global score file.
8286 (substitute-command-keys
8287 "Editing a global score file (Type \\[gnus-kill-file-exit] to exit)")))
8289 (defun gnus-summary-raise-followups-to-author (level)
8290 "Raise score by LEVEL for all followups to the current author."
8292 (gnus-kill-file-raise-followups-to-author
8293 (gnus-score-default level)
8294 (let ((article (gnus-summary-article-number)))
8295 (if article (gnus-get-header-by-number article)
8296 (error "No article on current line")))))
8298 (defun gnus-summary-edit-local-kill ()
8299 "Edit a local score file applied to the current newsgroup."
8301 (setq gnus-current-kill-article (gnus-summary-article-number))
8302 (gnus-kill-file-edit-file gnus-newsgroup-name)
8304 (substitute-command-keys
8305 "Editing a local score file (Type \\[gnus-kill-file-exit] to exit)")))
8310 ;;; Gnus article mode
8313 (if gnus-article-mode-map
8315 (setq gnus-article-mode-map (make-keymap))
8316 (suppress-keymap gnus-article-mode-map)
8317 (define-key gnus-article-mode-map " " 'gnus-article-next-page)
8318 (define-key gnus-article-mode-map "\177" 'gnus-article-prev-page)
8319 (define-key gnus-article-mode-map "\C-x^" 'gnus-article-refer-article)
8320 (define-key gnus-article-mode-map "h" 'gnus-article-show-summary)
8321 (define-key gnus-article-mode-map "s" 'gnus-article-show-summary)
8322 (define-key gnus-article-mode-map "\C-xm" 'gnus-article-mail)
8323 (define-key gnus-article-mode-map "\C-xM" 'gnus-article-mail-with-original)
8324 (define-key gnus-article-mode-map "?" 'gnus-article-describe-briefly)
8326 ;; Duplicate almost all summary keystrokes in the article mode map.
8328 (list "#" "\M-#" "\C-c\M-#" "\r" "n" "p"
8329 "N" "P" "\M-\C-n" "\M-\C-p" "." "\M-s" "\M-r"
8330 "<" ">" "l" "j" "^" "\M-^" "-" "u" "U" "d" "D"
8331 "\M-u" "\M-U" "k" "\C-k" "\M-\C-k" "c" "x" "X"
8332 "\M-\C-x" "\M-\177" "b" "B" "$" "w" "\C-c\C-r"
8333 "t" "\M-t" "a" "f" "F" "C" "S" "r" "R" "\C-c\C-f"
8334 "m" "o" "\C-o" "|" "\M-m" "\M-\C-m" "\M-k" "m" "M"
8335 "V" "\C-c\C-d" "q" "Q")))
8337 (define-key gnus-article-mode-map (car commands)
8338 'gnus-article-summary-command)
8339 (setq commands (cdr commands)))))
8342 (defun gnus-article-mode ()
8343 "Major mode for reading an article.
8344 All normal editing commands are switched off.
8345 The following commands are available:
8347 \\<gnus-article-mode-map>
8348 \\[gnus-article-next-page]\t Scroll the article one page forwards
8349 \\[gnus-article-prev-page]\t Scroll the article one page backwards
8350 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
8351 \\[gnus-article-show-summary]\t Display the summary buffer
8352 \\[gnus-article-mail]\t Send a reply to the address near point
8353 \\[gnus-article-mail-with-original]\t Send a reply to the address near point; include the original article
8354 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
8355 \\[gnus-info-find-node]\t Go to the Gnus info node
8359 (if gnus-visual (gnus-article-make-menu-bar))
8360 (kill-all-local-variables)
8361 (setq mode-line-modified "-- ")
8362 (make-local-variable 'mode-line-format)
8363 (setq mode-line-format (copy-sequence mode-line-format))
8364 (and (equal (nth 3 mode-line-format) " ")
8365 (setcar (nthcdr 3 mode-line-format) ""))
8366 (setq mode-name "Article")
8367 (setq major-mode 'gnus-article-mode)
8368 (make-local-variable 'minor-mode-alist)
8369 (or (assq 'gnus-show-mime minor-mode-alist)
8370 (setq minor-mode-alist
8371 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
8372 (use-local-map gnus-article-mode-map)
8373 (make-local-variable 'page-delimiter)
8374 (setq page-delimiter gnus-page-delimiter)
8375 (buffer-disable-undo (current-buffer))
8376 (setq buffer-read-only t) ;Disable modification
8377 (run-hooks 'gnus-article-mode-hook))
8379 (defun gnus-article-setup-buffer ()
8380 "Initialize article mode buffer."
8381 (or (get-buffer gnus-article-buffer)
8383 (set-buffer (get-buffer-create gnus-article-buffer))
8384 (gnus-add-current-to-buffer-list)
8385 (gnus-article-mode))))
8387 (defun gnus-request-article-this-buffer (article &optional group)
8388 "Get an article and insert it into this buffer."
8389 (setq group (or group gnus-newsgroup-name))
8390 ;; Using `gnus-request-article' directly will insert the article into
8391 ;; `nntp-server-buffer' - so we'll save some time by not having to
8392 ;; copy it from the server buffer into the article buffer.
8394 ;; We only request an article by message-id when we do not have the
8395 ;; headers for it, so we'll have to get those.
8396 (and (stringp article) (gnus-read-header article))
8398 ;; If the article number is negative, that means that this article
8399 ;; doesn't belong in this newsgroup (possibly), so we find its
8400 ;; message-id and request it by id instead of number.
8401 (if (and (numberp article) (< article 0))
8403 (set-buffer gnus-summary-buffer)
8404 (let ((header (gnus-gethash (int-to-string article)
8405 gnus-newsgroup-headers-hashtb-by-number)))
8406 (if (vectorp header)
8407 ;; It's a real article.
8408 (setq article (header-id header))
8409 ;; It is an extracted pseudo-article.
8411 (gnus-request-pseudo-article header)))))
8412 ;; Get the article and into the article buffer.
8416 (and (gnus-request-article article group (current-buffer))
8420 (defun gnus-read-header (id)
8421 "Read the headers of article ID and enter them into the Gnus system."
8422 (or gnus-newsgroup-headers-hashtb-by-number
8423 (gnus-make-headers-hashtable-by-number))
8425 (if (not (setq header
8426 (car (if (let ((gnus-nov-is-evil t))
8427 (gnus-retrieve-headers
8428 (list id) gnus-newsgroup-name))
8429 (gnus-get-newsgroup-headers)))))
8432 (header-set-number header gnus-reffed-article-number))
8433 (setq gnus-newsgroup-headers (cons header gnus-newsgroup-headers))
8434 (gnus-sethash (int-to-string (header-number header)) header
8435 gnus-newsgroup-headers-hashtb-by-number)
8437 (setq gnus-reffed-article-number (1- gnus-reffed-article-number)))
8438 (setq gnus-current-headers header)
8441 (defun gnus-article-prepare (article &optional all-headers header)
8442 "Prepare ARTICLE in article mode buffer.
8443 ARTICLE should either be an article number or a Message-ID.
8444 If ARTICLE is an id, HEADER should be the article headers.
8445 If ALL-HEADERS is non-nil, no headers are hidden."
8447 ;; Make sure we start in a summary buffer.
8448 (or (eq major-mode 'gnus-summary-mode)
8449 (set-buffer gnus-summary-buffer))
8450 (setq gnus-summary-buffer (current-buffer))
8451 ;; Make sure the connection to the server is alive.
8452 (or (gnus-server-opened (gnus-find-method-for-group gnus-newsgroup-name))
8454 (gnus-check-news-server
8455 (gnus-find-method-for-group gnus-newsgroup-name))
8456 (gnus-request-group gnus-newsgroup-name t)))
8457 (or gnus-newsgroup-headers-hashtb-by-number
8458 (gnus-make-headers-hashtable-by-number))
8459 (let* ((article (if header (header-number header) article))
8460 (summary-buffer (current-buffer))
8461 (internal-hook gnus-article-internal-prepare-hook)
8462 (bookmark (cdr (assq article gnus-newsgroup-bookmarks)))
8463 (group gnus-newsgroup-name)
8466 (gnus-article-setup-buffer)
8467 (set-buffer gnus-article-buffer)
8468 (let ((buffer-read-only nil))
8469 (if (not (setq result (gnus-request-article-this-buffer
8471 ;; There is no such article.
8474 (set-buffer gnus-summary-buffer)
8475 (setq gnus-current-article 0)
8476 (and (numberp article)
8477 (gnus-summary-mark-as-read article gnus-canceled-mark))
8478 (message "No such article (may be canceled)")
8480 (setq gnus-article-current nil)
8482 (if (not (eq result 'article))
8485 (set-buffer summary-buffer)
8486 (setq gnus-last-article gnus-current-article
8487 gnus-current-article 0
8488 gnus-current-headers nil
8489 gnus-article-current nil)
8490 (gnus-configure-windows 'article)
8491 (gnus-set-mode-line 'summary)
8492 (gnus-set-global-variables))
8493 (gnus-set-mode-line 'article))
8494 ;; The result from the `request' was an actual article -
8495 ;; or at least some text that is now displayed in the
8497 (if (and (numberp article)
8498 (not (eq article gnus-current-article)))
8499 ;; Seems like a new article has been selected.
8500 ;; `gnus-current-article' must be an article number.
8502 (set-buffer summary-buffer)
8503 (setq gnus-last-article gnus-current-article)
8504 (setq gnus-current-article article)
8505 (setq gnus-current-headers
8506 (gnus-get-header-by-number gnus-current-article))
8507 (setq gnus-article-current
8508 (cons gnus-newsgroup-name gnus-current-article))
8509 (gnus-set-mode-line 'summary)
8510 (run-hooks 'gnus-mark-article-hook)
8512 (run-hooks 'gnus-visual-mark-article-hook))
8513 ;; Set the global newsgroup variables here.
8514 ;; Suggested by Jim Sisolak
8515 ;; <sisolak@trans4.neep.wisc.edu>.
8516 (gnus-set-global-variables)))
8517 ;; gnus-have-all-headers must be either T or NIL.
8518 (setq gnus-have-all-headers
8519 (not (not (or all-headers gnus-show-all-headers))))
8520 ;; Hooks for getting information from the article.
8521 ;; This hook must be called before being narrowed.
8522 (run-hooks 'internal-hook)
8523 (run-hooks 'gnus-article-prepare-hook)
8524 ;; Decode MIME message.
8525 (if (and gnus-show-mime
8526 (gnus-fetch-field "Mime-Version"))
8527 (funcall gnus-show-mime-method))
8528 ;; Perform the article display hooks.
8529 (let ((buffer-read-only nil))
8530 (run-hooks 'gnus-article-display-hook))
8532 (goto-char (point-min))
8533 (and gnus-break-pages (gnus-narrow-to-page))
8534 (gnus-set-mode-line 'article)
8535 (gnus-configure-windows 'article)
8538 (get-buffer-window gnus-article-buffer) (point-min))
8541 (message "Moved to bookmark")
8542 (search-forward "\n\n" nil t)
8543 (forward-line bookmark)))
8546 (defun gnus-article-show-all-headers ()
8547 "Show all article headers in article mode buffer."
8549 (setq gnus-have-all-headers t)
8550 (gnus-article-setup-buffer)
8551 (set-buffer gnus-article-buffer)
8552 (let ((buffer-read-only nil))
8553 (remove-text-properties 1 (point-max) '(invisible t)))))
8555 (defun gnus-article-hide-headers-if-wanted ()
8556 "Hide unwanted headers if `gnus-have-all-headers' is nil.
8557 Provided for backwards compatability."
8558 (or gnus-have-all-headers
8559 (gnus-article-hide-headers)))
8561 (defun gnus-article-hide-headers (&optional delete)
8562 "Hide unwanted headers and possibly sort them as well."
8565 (set-buffer gnus-article-buffer)
8567 (let ((sorted gnus-sorted-header-list)
8568 (buffer-read-only nil)
8569 want want-list beg want-l)
8570 ;; First we narrow to just the headers.
8573 ;; Hide any "From " lines at the beginning of (mail) articles.
8574 (while (looking-at rmail-unix-mail-delimiter)
8577 (add-text-properties 1 (point) '(invisible t)))
8578 ;; Then treat the rest of the header lines.
8581 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
8582 ;; Then we use the two regular expressions
8583 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
8584 ;; select which header lines is to remain visible in the
8587 (while (re-search-forward "^[^ \t]*:" nil t)
8589 ;; We add the headers we want to keep to a list and delete
8590 ;; them from the buffer.
8591 (if (or (and (stringp gnus-visible-headers)
8592 (looking-at gnus-visible-headers))
8593 (and (not (stringp gnus-visible-headers))
8594 (stringp gnus-ignored-headers)
8595 (not (looking-at gnus-ignored-headers))))
8599 ;; Be sure to get multi-line headers...
8600 (re-search-forward "^[^ \t]*:" nil t)
8603 (cons (buffer-substring beg (point)) want-list))
8604 (delete-region beg (point))
8607 ;; Next we perform the sorting by looking at
8608 ;; `gnus-sorted-header-list'.
8610 (while (and sorted want-list)
8611 (setq want-l want-list)
8613 (not (string-match (car sorted) (car want-l))))
8614 (setq want-l (cdr want-l)))
8617 (insert (car want-l))
8618 (setq want-list (delq (car want-l) want-list))))
8619 (setq sorted (cdr sorted)))
8620 ;; Any headers that were not matched by the sorted list we
8621 ;; just tack on the end of the visible header list.
8623 (insert (car want-list))
8624 (setq want-list (cdr want-list)))
8625 ;; And finally we make the unwanted headers invisible.
8627 (delete-region (point) (point-max))
8628 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
8629 (add-text-properties (point) (point-max) '(invisible t)))))))
8631 (defun gnus-article-hide-signature ()
8632 "Hides the signature in an article.
8633 It does this by hiding everyting after \"^-- *$\", which is what all
8634 signatures should be preceded by. Note that this may mean that parts
8635 of an article may disappear if the article has such a line in the
8636 middle of the text."
8639 (set-buffer gnus-article-buffer)
8640 (let ((buffer-read-only nil))
8641 (goto-char (point-max))
8642 (if (re-search-backward "^-- *$" nil t)
8644 (add-text-properties (point) (point-max) '(invisible t)))))))
8646 (defun gnus-article-hide-citation ()
8647 "Hide all cited text.
8648 This function uses the famous, extremely intelligent \"shoot in foot\"
8649 algorithm - which is simply deleting all lines that start with
8650 \">\". Your mileage may vary. If you come up with anything better,
8651 please do mail it to me."
8654 (set-buffer gnus-article-buffer)
8655 (let ((buffer-read-only nil))
8657 (search-forward "\n\n" nil t)
8659 (if (looking-at ">")
8660 (add-text-properties
8661 (point) (save-excursion (forward-line 1) (point))
8663 (forward-line 1)))))
8665 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
8666 (defun gnus-article-treat-overstrike ()
8667 ;; Prepare article for overstrike commands.
8670 (set-buffer gnus-article-buffer)
8671 (let ((buffer-read-only nil))
8672 (while (search-forward "\b" nil t)
8673 (let ((next (following-char))
8674 (previous (char-after (- (point) 2))))
8675 (cond ((eq next previous)
8676 (delete-region (- (point) 2) (point))
8677 (put-text-property (point) (1+ (point))
8680 (delete-region (1- (point)) (1+ (point)))
8681 (put-text-property (1- (point)) (point)
8684 (delete-region (- (point) 2) (point))
8685 (put-text-property (point) (1+ (point))
8686 'face 'underline))))))))
8688 (defun gnus-article-word-wrap ()
8689 "Format too long lines."
8692 (set-buffer gnus-article-buffer)
8693 (let ((buffer-read-only nil))
8695 (search-forward "\n\n" nil t)
8697 (let ((paragraph-start "^\\W"))
8699 (and (>= (current-column) (window-width))
8700 (/= (preceding-char) ?:)
8701 (fill-paragraph nil))
8702 (end-of-line 2))))))
8704 (defun gnus-article-remove-cr ()
8707 (let ((buffer-read-only nil))
8708 (set-buffer gnus-article-buffer)
8709 (while (search-forward "\r" nil t)
8710 (replace-match "")))))
8712 (defun gnus-article-de-quoted-unreadable ()
8716 (set-buffer gnus-article-buffer)
8717 (let ((buffer-read-only nil))
8719 (goto-char (point-min))
8720 (while (re-search-forward "=[0-9A-F][0-9A-F]" nil t)
8724 (* 16 (gnus-hex-char-to-integer
8725 (char-after (1+ (match-beginning 0)))))
8726 (gnus-hex-char-to-integer
8727 (char-after (1- (match-end 0))))))))))))
8729 ;; Taken from hexl.el.
8730 (defun gnus-hex-char-to-integer (character)
8731 "Take a char and return its value as if it was a hex digit."
8732 (if (and (>= character ?0) (<= character ?9))
8734 (let ((ch (logior character 32)))
8735 (if (and (>= ch ?a) (<= ch ?f))
8737 (error (format "Invalid hex digit `%c'." ch))))))
8741 (defun gnus-output-to-rmail (file-name)
8742 "Append the current article to an Rmail file named FILE-NAME."
8744 ;; Most of these codes are borrowed from rmailout.el.
8745 (setq file-name (expand-file-name file-name))
8746 (setq rmail-default-rmail-file file-name)
8747 (let ((artbuf (current-buffer))
8748 (tmpbuf (get-buffer-create " *Gnus-output*")))
8750 (or (get-file-buffer file-name)
8751 (file-exists-p file-name)
8752 (if (gnus-yes-or-no-p
8753 (concat "\"" file-name "\" does not exist, create it? "))
8754 (let ((file-buffer (create-file-buffer file-name)))
8756 (set-buffer file-buffer)
8757 (rmail-insert-rmail-file-header)
8758 (let ((require-final-newline nil))
8759 (write-region (point-min) (point-max) file-name t 1)))
8760 (kill-buffer file-buffer))
8761 (error "Output file does not exist")))
8763 (buffer-disable-undo (current-buffer))
8765 (insert-buffer-substring artbuf)
8766 (gnus-convert-article-to-rmail)
8767 ;; Decide whether to append to a file or to an Emacs buffer.
8768 (let ((outbuf (get-file-buffer file-name)))
8770 (append-to-file (point-min) (point-max) file-name)
8771 ;; File has been visited, in buffer OUTBUF.
8773 (let ((buffer-read-only nil)
8774 (msg (and (boundp 'rmail-current-message)
8775 rmail-current-message)))
8776 ;; If MSG is non-nil, buffer is in RMAIL mode.
8779 (narrow-to-region (point-max) (point-max))))
8780 (insert-buffer-substring tmpbuf)
8783 (goto-char (point-min))
8785 (search-backward "\^_")
8786 (narrow-to-region (point) (point-max))
8787 (goto-char (1+ (point-min)))
8788 (rmail-count-new-messages t)
8789 (rmail-show-message msg))))))
8791 (kill-buffer tmpbuf)
8794 (defun gnus-output-to-file (file-name)
8795 "Append the current article to a file named FILE-NAME."
8796 (setq file-name (expand-file-name file-name))
8797 (let ((artbuf (current-buffer))
8798 (tmpbuf (get-buffer-create " *Gnus-output*")))
8801 (buffer-disable-undo (current-buffer))
8803 (insert-buffer-substring artbuf)
8804 ;; Append newline at end of the buffer as separator, and then
8806 (goto-char (point-max))
8808 (append-to-file (point-min) (point-max) file-name))
8809 (kill-buffer tmpbuf)
8812 (defun gnus-convert-article-to-rmail ()
8813 "Convert article in current buffer to Rmail message format."
8814 (let ((buffer-read-only nil))
8815 ;; Convert article directly into Babyl format.
8816 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
8817 (goto-char (point-min))
8818 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
8819 (while (search-forward "\n\^_" nil t) ;single char
8820 (replace-match "\n^_")) ;2 chars: "^" and "_"
8821 (goto-char (point-max))
8824 (defun gnus-narrow-to-page (&optional arg)
8825 "Make text outside current page invisible except for page delimiter.
8826 A numeric arg specifies to move forward or backward by that many pages,
8827 thus showing a page other than the one point was originally in."
8829 (setq arg (if arg (prefix-numeric-value arg) 0))
8831 (forward-page -1) ;Beginning of current page.
8836 (forward-page (1- arg))))
8837 ;; Find the end of the page.
8839 ;; If we stopped due to end of buffer, stay there.
8840 ;; If we stopped after a page delimiter, put end of restriction
8841 ;; at the beginning of that line.
8842 ;; These are commented out.
8843 ;; (if (save-excursion (beginning-of-line)
8844 ;; (looking-at page-delimiter))
8845 ;; (beginning-of-line))
8846 (narrow-to-region (point)
8848 ;; Find the top of the page.
8850 ;; If we found beginning of buffer, stay there.
8851 ;; If extra text follows page delimiter on same line,
8853 ;; Otherwise, show text starting with following line.
8854 (if (and (eolp) (not (bobp)))
8859 (defun gnus-gmt-to-local ()
8860 "Rewrite Date: field described in GMT to local in current buffer.
8861 The variable gnus-local-timezone is used for local time zone.
8862 Intended to be used with gnus-article-prepare-hook."
8866 (goto-char (point-min))
8867 (narrow-to-region (point-min)
8868 (progn (search-forward "\n\n" nil 'move) (point)))
8869 (goto-char (point-min))
8870 (if (re-search-forward "^Date:[ \t]\\(.*\\)$" nil t)
8871 (let ((buffer-read-only nil)
8872 (date (buffer-substring (match-beginning 1) (match-end 1))))
8873 (delete-region (match-beginning 1) (match-end 1))
8875 (timezone-make-date-arpa-standard date nil gnus-local-timezone))
8880 ;; Article mode commands
8882 (defun gnus-article-next-page (lines)
8883 "Show next page of current article.
8884 If end of article, return non-nil. Otherwise return nil.
8885 Argument LINES specifies lines to be scrolled up."
8887 (move-to-window-line -1)
8888 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
8891 (and (pos-visible-in-window-p) ;Not continuation line.
8893 ;; Nothing in this page.
8894 (if (or (not gnus-break-pages)
8897 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
8899 (gnus-narrow-to-page 1) ;Go to next page.
8902 ;; More in this page.
8906 ;; Long lines may cause an end-of-buffer error.
8907 (goto-char (point-max))))
8911 (defun gnus-article-prev-page (lines)
8912 "Show previous page of current article.
8913 Argument LINES specifies lines to be scrolled down."
8915 (move-to-window-line 0)
8916 (if (and gnus-break-pages
8918 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
8920 (gnus-narrow-to-page -1) ;Go to previous page.
8921 (goto-char (point-max))
8923 (scroll-down lines)))
8925 (defun gnus-article-refer-article ()
8926 "Read article specified by message-id around point."
8928 (search-forward ">" nil t) ;Move point to end of "<....>".
8929 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
8931 (buffer-substring (match-beginning 1) (match-end 1))))
8932 (set-buffer gnus-summary-buffer)
8933 (gnus-summary-refer-article message-id))
8934 (error "No references around point")))
8936 (defun gnus-article-mail (yank)
8937 "Send a reply to the address near point.
8938 If YANK is non-nil, include the original article."
8942 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
8943 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
8946 (switch-to-buffer gnus-summary-buffer)
8947 (funcall gnus-mail-reply-method yank address)))))
8949 (defun gnus-article-mail-with-original ()
8950 "Send a reply to the address near point and include the original article."
8952 (gnus-article-mail 'yank))
8954 (defun gnus-article-show-summary ()
8955 "Reconfigure windows to show summary buffer."
8957 (gnus-configure-windows 'article)
8958 (pop-to-buffer gnus-summary-buffer)
8959 (gnus-summary-goto-subject gnus-current-article))
8961 (defun gnus-article-describe-briefly ()
8962 "Describe article mode commands briefly."
8965 (substitute-command-keys "\\<gnus-article-mode-map>\\[gnus-article-next-page]:Next page \\[gnus-article-prev-page]:Prev page \\[gnus-article-show-summary]:Show summary \\[gnus-info-find-node]:Run Info \\[gnus-article-describe-briefly]:This help")))
8967 (defun gnus-article-summary-command ()
8968 "Execute the last keystroke in the summary buffer."
8971 (let ((obuf (current-buffer))
8972 (owin (current-window-configuration)))
8973 (switch-to-buffer gnus-summary-buffer 'norecord)
8974 (execute-kbd-macro (this-command-keys))
8976 (let ((npoint (point)))
8977 (set-window-configuration owin)
8978 (set-window-start (get-buffer-window (current-buffer)) (point)))))
8980 ;; caesar-region written by phr@prep.ai.mit.edu Nov 86
8981 ;; Modified by tower@prep Nov 86
8982 ;; Modified by umerin@flab.flab.Fujitsu.JUNET for ROT47.
8984 (defun gnus-caesar-region (&optional n)
8985 "Caesar rotation of region by N, default 13, for decrypting netnews.
8986 ROT47 will be performed for Japanese text in any case."
8987 (interactive (if current-prefix-arg ; Was there a prefix arg?
8988 (list (prefix-numeric-value current-prefix-arg))
8990 (cond ((not (numberp n)) (setq n 13))
8991 (t (setq n (mod n 26)))) ;canonicalize N
8992 (if (not (zerop n)) ; no action needed for a rot of 0
8994 (if (or (not (boundp 'caesar-translate-table))
8995 (not caesar-translate-table)
8996 (/= (aref caesar-translate-table ?a) (+ ?a n)))
8997 (let ((i 0) (lower "abcdefghijklmnopqrstuvwxyz") upper)
8998 (message "Building caesar-translate-table...")
8999 (setq caesar-translate-table (make-vector 256 0))
9001 (aset caesar-translate-table i i)
9003 (setq lower (concat lower lower) upper (upcase lower) i 0)
9005 (aset caesar-translate-table (+ ?a i) (aref lower (+ i n)))
9006 (aset caesar-translate-table (+ ?A i) (aref upper (+ i n)))
9008 ;; ROT47 for Japanese text.
9009 ;; Thanks to ichikawa@flab.fujitsu.junet.
9011 (let ((t1 (logior ?O 128))
9012 (t2 (logior ?! 128))
9013 (t3 (logior ?~ 128)))
9015 (aset caesar-translate-table i
9016 (let ((v (aref caesar-translate-table i)))
9017 (if (<= v t1) (if (< v t2) v (+ v 47))
9018 (if (<= v t3) (- v 47) v))))
9020 (message "Building caesar-translate-table... done")))
9021 (let ((from (region-beginning))
9024 (setq str (buffer-substring from to))
9025 (setq len (length str))
9027 (aset str i (aref caesar-translate-table (aref str i)))
9030 (delete-region from to)
9035 ;;; Gnus Score File Mode
9038 (if gnus-kill-file-mode-map
9040 (setq gnus-kill-file-mode-map (copy-keymap emacs-lisp-mode-map))
9041 (define-key gnus-kill-file-mode-map "\C-c\C-x"
9042 'gnus-kill-file-set-expunge-below)
9043 (define-key gnus-kill-file-mode-map "\C-c@"
9044 'gnus-kill-file-set-mark-below)
9045 (define-key gnus-kill-file-mode-map "\C-c\C-k\C-s"
9046 'gnus-kill-file-temporarily-lower-by-subject)
9047 (define-key gnus-kill-file-mode-map "\C-c\C-k\C-a"
9048 'gnus-kill-file-temporarily-lower-by-author)
9049 (define-key gnus-kill-file-mode-map "\C-c\C-k\C-x"
9050 'gnus-kill-file-temporarily-lower-by-xref)
9051 (define-key gnus-kill-file-mode-map "\C-c\C-ks"
9052 'gnus-kill-file-lower-by-subject)
9053 (define-key gnus-kill-file-mode-map "\C-c\C-ka"
9054 'gnus-kill-file-lower-by-author)
9055 (define-key gnus-kill-file-mode-map "\C-c\C-kt"
9056 'gnus-kill-file-lower-by-thread)
9057 (define-key gnus-kill-file-mode-map "\C-c\C-kx"
9058 'gnus-kill-file-lower-by-xref)
9059 (define-key gnus-kill-file-mode-map "\C-c\C-kf"
9060 'gnus-kill-file-lower-followups-to-author)
9061 (define-key gnus-kill-file-mode-map "\C-c\C-i\C-s"
9062 'gnus-kill-file-temporarily-raise-by-subject)
9063 (define-key gnus-kill-file-mode-map "\C-c\C-i\C-a"
9064 'gnus-kill-file-temporarily-raise-by-author)
9065 (define-key gnus-kill-file-mode-map "\C-c\C-i\C-t"
9066 'gnus-kill-file-temporarily-raise-by-thread)
9067 (define-key gnus-kill-file-mode-map "\C-c\C-i\C-x"
9068 'gnus-kill-file-temporarily-raise-by-xref)
9069 (define-key gnus-kill-file-mode-map "\C-c\C-is"
9070 'gnus-kill-file-raise-by-subject)
9071 (define-key gnus-kill-file-mode-map "\C-c\C-ia"
9072 'gnus-kill-file-raise-by-author)
9073 (define-key gnus-kill-file-mode-map "\C-c\C-ix"
9074 'gnus-kill-file-raise-by-xref)
9075 (define-key gnus-kill-file-mode-map "\C-c\C-if"
9076 'gnus-kill-file-raise-followups-to-author)
9077 (define-key gnus-kill-file-mode-map "\C-c\C-a" 'gnus-kill-file-apply-buffer)
9078 (define-key gnus-kill-file-mode-map "\C-c\C-e" 'gnus-kill-file-apply-last-sexp)
9079 (define-key gnus-kill-file-mode-map "\C-c\C-c" 'gnus-kill-file-exit)
9080 (define-key gnus-kill-file-mode-map "\C-c\C-i" 'gnus-info-find-node))
9082 (defun gnus-kill-file-mode ()
9083 "Major mode for editing score files.
9085 In addition to Emacs-Lisp mode, the following commands are available:
9087 \\[gnus-kill-file-set-expunge-below] Automatically expunge articles below LEVEL.
9088 \\[gnus-kill-file-set-mark-below] Automatically mark articles below LEVEL.
9089 \\[gnus-kill-file-temporarily-lower-by-author] Insert temporary lower command for current author.
9090 \\[gnus-kill-file-temporarily-lower-by-thread] Insert temporary lower command for current thread.
9091 \\[gnus-kill-file-temporarily-lower-by-xref] Insert temporary lower command for current cross-posting.
9092 \\[gnus-kill-file-lower-by-subject] Insert permanent lower command for current subject.
9093 \\[gnus-kill-file-lower-by-author] Insert permanent lower command for current author.
9094 \\[gnus-kill-file-lower-followups-to-author] Insert permanent lower command for followups to the current author.
9095 \\[gnus-kill-file-lower-by-xref] Insert permanent lower command for current cross-posting.
9096 \\[gnus-kill-file-temporarily-raise-by-subject] Insert temporary raise command for current subject.
9097 \\[gnus-kill-file-temporarily-raise-by-author] Insert temporary raise command for current author.
9098 \\[gnus-kill-file-temporarily-raise-by-thread] Insert temporary raise command for current thread.
9099 \\[gnus-kill-file-temporarily-raise-by-xref] Insert temporary raise command for current cross-posting.
9100 \\[gnus-kill-file-raise-by-subject] Insert permanent raise command for current subject.
9101 \\[gnus-kill-file-raise-by-author] Insert permanent raise command for current author.
9102 \\[gnus-kill-file-raise-followups-to-author] Insert permanent raise command for followups to the current author.
9103 \\[gnus-kill-file-raise-by-xref] Insert permanent raise command for current cross-posting.
9104 \\[gnus-kill-file-apply-buffer] Apply current buffer to selected newsgroup.
9105 \\[gnus-kill-file-apply-last-sexp] Apply sexp before point to selected newsgroup.
9106 \\[gnus-kill-file-exit] Save file and exit editing score file.
9107 \\[gnus-info-find-node] Read Info about score files.
9109 A score file contains Lisp expressions to be applied to a selected
9110 newsgroup. The purpose is to mark articles as read on the basis of
9111 some set of regexps. A global score file is applied to every
9112 newsgroup, and a local score file is applied to a specified newsgroup.
9113 Since a global score file is applied to every newsgroup, for better
9114 performance use a local one.
9116 A score file can contain any kind of Emacs Lisp expressions expected
9117 to be evaluated in the summary buffer. Writing Lisp programs for this
9118 purpose is not so easy because the internal working of Gnus must be
9119 well-known. For this reason, Gnus provides a general function which
9120 does this easily for non-Lisp programmers.
9122 The `gnus-kill' function executes commands available in summary mode
9123 by their key sequences. `gnus-kill' should be called with FIELD,
9124 REGEXP and optional COMMAND and ALL. FIELD is a string representing
9125 the header field or an empty string. If FIELD is an empty string, the
9126 entire article body is searched for. REGEXP is a string which is
9127 compared with FIELD value. COMMAND is a string representing a valid
9128 key sequence in summary mode or Lisp expression. COMMAND defaults to
9129 '(gnus-summary-mark-as-read nil \"X\"). Make sure that COMMAND is
9130 executed in the summary buffer. If the second optional argument ALL
9131 is non-nil, the COMMAND is applied to articles which are already
9132 marked as read or unread. Articles which are marked are skipped over
9135 For example, if you want to mark articles of which subjects contain
9136 the string `AI' as read, a possible score file may look like:
9138 (gnus-kill \"Subject\" \"AI\")
9140 If you want to mark articles with `D' instead of `X', you can use
9141 the following expression:
9143 (gnus-kill \"Subject\" \"AI\" \"d\")
9145 In this example it is assumed that the command
9146 `gnus-summary-mark-as-read-forward' is assigned to `d' in summary mode.
9148 It is possible to remove unnecessary headers which are marked with
9149 `X' in a score file as follows:
9151 (gnus-expunge \"X\")
9153 If the summary buffer is empty after applying score files, Gnus will
9154 exit the selected newsgroup normally. If headers which are marked
9155 with `D' are deleted in a score file, it is impossible to read articles
9156 which are marked as read in the previous Gnus sessions. Marks other
9157 than `D' should be used for articles which should really be deleted.
9159 Entry to this mode calls emacs-lisp-mode-hook and
9160 gnus-kill-file-mode-hook with no arguments, if that value is non-nil."
9162 (kill-all-local-variables)
9163 (use-local-map gnus-kill-file-mode-map)
9164 (set-syntax-table emacs-lisp-mode-syntax-table)
9165 (setq major-mode 'gnus-kill-file-mode)
9166 (setq mode-name "score-file")
9167 (lisp-mode-variables nil)
9168 (run-hooks 'emacs-lisp-mode-hook 'gnus-kill-file-mode-hook))
9170 (defun gnus-kill-file-edit-file (newsgroup)
9171 "Begin editing a score file for NEWSGROUP.
9172 If NEWSGROUP is nil, the global score file is selected."
9173 (interactive "sNewsgroup: ")
9174 (let ((file (gnus-newsgroup-kill-file newsgroup)))
9175 (gnus-make-directory (file-name-directory file))
9176 ;; Save current window configuration if this is first invocation.
9177 (or (and (get-file-buffer file)
9178 (get-buffer-window (get-file-buffer file)))
9179 (setq gnus-winconf-kill-file (current-window-configuration)))
9181 (let ((buffer (find-file-noselect file)))
9182 (cond ((get-buffer-window buffer)
9183 (pop-to-buffer buffer))
9184 ((eq major-mode 'gnus-group-mode)
9185 (gnus-configure-windows '(1 0 0)) ;Take all windows.
9186 (pop-to-buffer gnus-group-buffer)
9187 ;; Fix by sachs@SLINKY.CS.NYU.EDU (Jay Sachs).
9188 (let ((gnus-summary-buffer buffer))
9189 (gnus-configure-windows '(1 1 0))) ;Split into two.
9190 (pop-to-buffer buffer))
9191 ((eq major-mode 'gnus-summary-mode)
9192 (gnus-configure-windows 'article)
9193 (pop-to-buffer gnus-article-buffer)
9194 (bury-buffer gnus-article-buffer)
9195 (switch-to-buffer buffer))
9197 (find-file-other-window file))
9199 (gnus-kill-file-mode)
9202 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
9203 (defun gnus-kill-set-kill-buffer ()
9204 (let* ((file (gnus-newsgroup-kill-file gnus-newsgroup-name))
9205 (buffer (find-file-noselect file)))
9207 (gnus-kill-file-mode)
9208 (bury-buffer buffer)))
9210 (defun gnus-kill-save-kill-buffer ()
9212 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
9213 (if (get-file-buffer file)
9215 (set-buffer (get-file-buffer file))
9216 (and (buffer-modified-p) (save-buffer))
9217 (kill-buffer (current-buffer)))))))
9219 (defun gnus-article-fetch-field (field)
9221 (set-buffer gnus-article-buffer)
9225 (narrow-to-region 1 (save-excursion
9226 (search-forward "\n\n" nil t) (point)))
9229 (mail-fetch-field field)
9232 (defun gnus-kill-file-enter-kill (field regexp level date edit)
9233 ;; Enter score file entry.
9234 ;; FIELD: String containing the name of the header field to score.
9235 ;; REGEXP: The string to score.
9236 ;; LEVEL: How much to raise the score by.
9237 ;; DATE: A date string for expire score or nil for permanent kills.
9238 ;; EDIT: Allow the user to edit REGEXP iff non-nil.
9240 (gnus-kill-set-kill-buffer)
9241 (goto-char (point-min))
9243 (if edit (read-string
9244 (format "Add %d to articles with %s matching: "
9245 level (downcase field))
9248 entry string kill beg)
9249 (setq entry (if date (cons regexp date) regexp)
9250 string (format "(gnus-raise %S (quote %S) %S)\n"
9252 (while (and (setq beg (point))
9254 (setq kill (read (current-buffer)))
9256 (or (not (eq (nth 0 kill) 'gnus-raise))
9257 (not (string= (downcase (nth 1 kill)) (downcase field)))
9258 (not (eq (nth 3 kill) level))))
9262 (goto-char (point-min))
9264 (let ((list (nth 2 kill)))
9265 (if (and (listp list) (eq 'quote (car list)))
9266 (setq list (car (cdr list))))
9269 (if (and (listp list) (listp (cdr list)))
9270 (list 'quote (cons entry list))
9271 (list 'quote (list entry list)))))
9272 (delete-region beg (point))
9273 (insert (gnus-pp-gnus-kill kill)))
9274 (gnus-kill-file-apply-string string))
9275 ;; Added by Sudish Joseph <joseph@cis.ohio-state.edu>.
9277 (message "Added kill file entry %s: %s" (downcase field) regexp))))
9279 (defun gnus-kill-file-set-variable (symbol value)
9280 ;; Set SYMBOL to VALUE in the score file.
9282 (gnus-kill-set-kill-buffer)
9283 (goto-char (point-min))
9284 (let ((string (format "(setq %S %S)\n" symbol value))
9286 (while (and (setq beg (point))
9288 (setq kill (read (current-buffer)))
9290 (or (not (eq (nth 0 kill) 'setq))
9291 (not (eq (nth 1 kill) symbol))))
9295 (goto-char (point-min))
9297 (delete-region beg (point))
9300 (defun gnus-kill-file-set-expunge-below (level)
9301 "Automatically expunge articles with score below LEVEL."
9303 (setq level (if level
9304 (prefix-numeric-value level)
9305 gnus-summary-default-score))
9306 (if (eq major-mode 'gnus-summary-mode)
9308 (gnus-score-set 'expunge level)
9309 (gnus-score-set 'touched t))
9310 (gnus-kill-file-set-variable 'expunge-below level))
9311 (message "Set expunge below level to %d." level))
9313 (defun gnus-kill-file-set-mark-below (level)
9314 "Automatically mark articles with score below LEVEL as read."
9316 (setq level (if level
9317 (prefix-numeric-value level)
9318 gnus-summary-default-score))
9319 (if (eq major-mode 'gnus-summary-mode)
9321 (gnus-score-set 'mark level)
9322 (gnus-score-set 'touched t)
9323 (gnus-summary-set-mark-below level))
9324 (gnus-kill-file-set-variable 'mark-below level))
9325 (message "Set mark below level to %d." level))
9327 (defun gnus-kill-file-temporarily-raise-by-subject (level &optional header)
9328 "Temporarily raise score by LEVEL for current subject.
9329 See `gnus-kill-expiry-days'."
9331 (gnus-kill-file-raise-by-subject level header (current-time-string)))
9333 (defun gnus-kill-file-temporarily-raise-by-author (level &optional header)
9334 "Temporarily raise score by LEVEL for current author.
9335 See `gnus-kill-expiry-days'."
9337 (gnus-kill-file-raise-by-author level header (current-time-string)))
9339 (defun gnus-kill-file-temporarily-raise-by-thread (level &optional header)
9340 "Temporarily raise score by LEVEL for current thread.
9341 See `gnus-kill-expiry-days'."
9343 (gnus-kill-file-enter-kill
9345 (regexp-quote (header-id (or header gnus-current-headers)))
9347 (current-time-string)
9350 (defun gnus-kill-file-temporarily-raise-by-xref (level &optional header)
9351 "Insert temporary score commands for articles that have been crossposted.
9352 By default use the current crossposted groups.
9353 See `gnus-kill-expiry-days'."
9355 (gnus-kill-file-raise-by-xref level header (current-time-string)))
9357 (defun gnus-kill-file-raise-by-subject (level &optional header date)
9358 "Raise score by LEVEL for current subject."
9360 (gnus-kill-file-enter-kill
9363 (gnus-simplify-subject
9364 (header-subject (or header gnus-current-headers))))
9369 (defun gnus-kill-file-raise-by-author (level &optional header date)
9370 "Raise score by LEVEL for current author."
9372 (gnus-kill-file-enter-kill
9374 (regexp-quote (header-from (or header gnus-current-headers)))
9379 (defun gnus-kill-file-raise-by-xref (level &optional header date)
9380 "Raise score by LEVEL for articles that have been crossposted.
9381 By default use the current crossposted groups."
9383 (let ((xref (header-xref (or header gnus-current-headers)))
9387 (while (string-match " \\([^ \t]+\\):" xref start)
9388 (setq start (match-end 0))
9391 (substring xref (match-beginning 1) (match-end 1)))
9392 gnus-newsgroup-name))
9393 (gnus-kill-file-enter-kill
9395 (concat " " (regexp-quote group) ":")
9400 (defun gnus-kill-file-raise-followups-to-author
9401 (level &optional header)
9402 "Raise score for all followups to the current author."
9404 (let ((name (header-from (or header gnus-current-headers)))
9407 (gnus-kill-set-kill-buffer)
9408 (goto-char (point-min))
9409 (setq name (read-string (concat "Add " level
9410 " to followup articles to: ")
9411 (regexp-quote name)))
9413 (format "(gnus-kill %S %S '(gnus-summary-temporarily-raise-by-thread %S))\n"
9416 (gnus-kill-file-apply-string string))
9417 (message "Added permanent score file entry for followups to %s." name)))
9419 (defun gnus-kill-file-temporarily-lower-by-subject (level &optional header)
9420 "Temporarily lower score by LEVEL for current subject.
9421 See `gnus-kill-expiry-days'."
9423 (gnus-kill-file-lower-by-subject level header (current-time-string)))
9425 (defun gnus-kill-file-temporarily-lower-by-author (level &optional header)
9426 "Temporarily lower score by LEVEL for current author.
9427 See `gnus-kill-expiry-days'."
9429 (gnus-kill-file-lower-by-author level header (current-time-string)))
9431 (defun gnus-kill-file-temporarily-lower-by-thread (level &optional header)
9432 "Temporarily lower score by LEVEL for current thread.
9433 See `gnus-kill-expiry-days'."
9435 (gnus-kill-file-temporarily-raise-by-thread (- (gnus-score-default level)) header))
9437 (defun gnus-kill-file-temporarily-lower-by-xref (level &optional header)
9438 "Insert temporary score commands for articles that have been crossposted.
9439 By default use the current crossposted groups.
9440 See `gnus-kill-expiry-days'."
9442 (gnus-kill-file-lower-by-xref level header (current-time-string)))
9444 (defun gnus-kill-file-lower-by-subject (level &optional header date)
9445 "Lower score by LEVEL for current subject."
9447 (gnus-kill-file-raise-by-subject (- (gnus-score-default level)) header date))
9449 (defun gnus-kill-file-lower-by-author (level &optional header date)
9450 "Lower score by LEVEL for current author."
9452 (gnus-kill-file-raise-by-author (- (gnus-score-default level)) header date))
9454 (defun gnus-kill-file-lower-by-xref (level &optional header date)
9455 "Lower score by LEVEL for articles that have been crossposted.
9456 By default use the current crossposted groups."
9457 (gnus-kill-file-raise-by-xref (- (gnus-score-default level)) header date))
9459 (defun gnus-kill-file-lower-followups-to-author
9460 (level &optional header)
9461 "Lower score for all followups to the current author."
9463 (gnus-kill-file-raise-followups-to-author (- (gnus-score-default level)) header))
9465 (defun gnus-kill-file-apply-buffer ()
9466 "Apply current buffer to current newsgroup."
9468 (if (and gnus-current-kill-article
9469 (get-buffer gnus-summary-buffer))
9470 ;; Assume newsgroup is selected.
9471 (gnus-kill-file-apply-string (buffer-string))
9472 (ding) (message "No newsgroup is selected.")))
9474 (defun gnus-kill-file-apply-string (string)
9475 "Apply STRING to current newsgroup."
9477 (let ((string (concat "(progn \n" string "\n)" )))
9479 (save-window-excursion
9480 (pop-to-buffer gnus-summary-buffer)
9481 (eval (car (read-from-string string)))))))
9483 (defun gnus-kill-file-apply-last-sexp ()
9484 "Apply sexp before point in current buffer to current newsgroup."
9486 (if (and gnus-current-kill-article
9487 (get-buffer gnus-summary-buffer))
9488 ;; Assume newsgroup is selected.
9491 (save-excursion (forward-sexp -1) (point)) (point))))
9493 (save-window-excursion
9494 (pop-to-buffer gnus-summary-buffer)
9495 (eval (car (read-from-string string))))))
9496 (ding) (message "No newsgroup is selected.")))
9498 (defun gnus-kill-file-exit ()
9499 "Save a score file, then return to the previous buffer."
9502 (let ((killbuf (current-buffer)))
9503 ;; We don't want to return to article buffer.
9504 (and (get-buffer gnus-article-buffer)
9505 (bury-buffer gnus-article-buffer))
9506 ;; Delete the KILL file windows.
9507 (delete-windows-on killbuf)
9508 ;; Restore last window configuration if available.
9509 (and gnus-winconf-kill-file
9510 (set-window-configuration gnus-winconf-kill-file))
9511 (setq gnus-winconf-kill-file nil)
9512 ;; Kill the KILL file buffer. Suggested by tale@pawl.rpi.edu.
9513 (kill-buffer killbuf)))
9515 ;; Basic ideas by emv@math.lsa.umich.edu (Edward Vielmetti)
9517 (defalias 'gnus-batch-kill 'gnus-batch-score)
9519 (defun gnus-batch-score ()
9520 "Run batched scoring.
9521 Usage: emacs -batch -l gnus -f gnus-batch-kill <newsgroups> ...
9522 Newsgroups is a list of strings in Bnews format. If you want to score
9523 the comp hierarchy, you'd say \"comp.all\". If you would not like to
9524 score the alt hierarchy, you'd say \"!alt.all\"."
9527 (gnus-parse-n-options
9528 (apply (function concat)
9529 (mapcar (lambda (g) (concat g " "))
9530 command-line-args-left))))
9531 (gnus-expert-user t)
9532 (nnmail-spool-file nil)
9533 (gnus-use-dribble-file nil)
9534 (yes (car yes-and-no))
9535 (no (cdr yes-and-no))
9536 group subscribed newsrc entry
9537 ;; Disable verbose message.
9538 gnus-novice-user gnus-large-newsgroup)
9539 ;; Eat all arguments.
9540 (setq command-line-args-left nil)
9543 ;; Apply kills to specified newsgroups in command line arguments.
9544 (setq newsrc (cdr gnus-newsrc-assoc))
9546 (setq group (car (car newsrc)))
9547 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
9548 (if (and (<= (nth 1 (car newsrc)) 5)
9550 (or (eq (car entry) t)
9551 (not (zerop (car entry)))))
9552 (if yes (string-match yes group) t)
9553 (or (null no) (not (string-match no group))))
9555 (gnus-summary-read-group group nil t)
9556 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
9557 (gnus-summary-exit))))
9558 (setq newsrc (cdr newsrc)))
9560 (switch-to-buffer gnus-group-buffer)
9561 (gnus-group-save-newsrc)))
9565 (defun gnus-Newsgroup-kill-file (newsgroup)
9566 "Return the name of a score file for NEWSGROUP.
9567 If NEWSGROUP is nil, return the global score file instead."
9568 (cond ((or (null newsgroup)
9569 (string-equal newsgroup ""))
9570 ;; The global score file is placed at top of the directory.
9571 (expand-file-name gnus-kill-file-name
9572 (or gnus-kill-files-directory "~/News")))
9573 (gnus-use-long-file-name
9574 ;; Append ".KILL" to capitalized newsgroup name.
9575 (expand-file-name (concat (gnus-capitalize-newsgroup newsgroup)
9576 "." gnus-kill-file-name)
9577 (or gnus-kill-files-directory "~/News")))
9579 ;; Place "KILL" under the hierarchical directory.
9580 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
9581 "/" gnus-kill-file-name)
9582 (or gnus-kill-files-directory "~/News")))
9585 (defun gnus-newsgroup-kill-file (newsgroup)
9586 "Return the name of a score file name for NEWSGROUP.
9587 If NEWSGROUP is nil, return the global score file name instead."
9588 (cond ((or (null newsgroup)
9589 (string-equal newsgroup ""))
9590 ;; The global KILL file is placed at top of the directory.
9591 (expand-file-name gnus-kill-file-name
9592 (or gnus-kill-files-directory "~/News")))
9593 (gnus-use-long-file-name
9594 ;; Append ".KILL" to newsgroup name.
9595 (expand-file-name (concat newsgroup "." gnus-kill-file-name)
9596 (or gnus-kill-files-directory "~/News")))
9598 ;; Place "KILL" under the hierarchical directory.
9599 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
9600 "/" gnus-kill-file-name)
9601 (or gnus-kill-files-directory "~/News")))
9605 (defalias 'gnus-expunge 'gnus-summary-remove-lines-marked-with)
9607 (defun gnus-apply-kill-file ()
9608 "Apply a score file to the current newsgroup.
9609 Returns the number of articles marked as read."
9610 (let* ((kill-files (list (gnus-newsgroup-kill-file nil)
9611 (gnus-newsgroup-kill-file gnus-newsgroup-name)))
9612 (unreads (length gnus-newsgroup-unreads))
9613 (gnus-summary-inhibit-highlight t)
9614 (mark-below (or gnus-summary-mark-below gnus-summary-default-score))
9615 (expunge-below gnus-summary-expunge-below)
9617 (setq gnus-newsgroup-kill-headers nil)
9618 (or gnus-newsgroup-headers-hashtb-by-number
9619 (gnus-make-headers-hashtable-by-number))
9620 ;; If there are any previously scored articles, we remove these
9621 ;; from the `gnus-newsgroup-headers' list that the score functions
9622 ;; will see. This is probably pretty wasteful when it comes to
9623 ;; conses, but is, I think, faster than having to assq in every
9624 ;; single score funtion.
9625 (let ((files kill-files))
9627 (if (file-exists-p (car files))
9628 (let ((headers gnus-newsgroup-headers))
9629 (if gnus-kill-killed
9630 (setq gnus-newsgroup-kill-headers
9631 (mapcar (lambda (header) (header-number header))
9634 (or (gnus-member-of-range
9635 (header-number (car headers))
9636 gnus-newsgroup-killed)
9637 (setq gnus-newsgroup-kill-headers
9638 (cons (header-number (car headers))
9639 gnus-newsgroup-kill-headers)))
9640 (setq headers (cdr headers))))
9642 (setq files (cdr files)))))
9643 (if gnus-newsgroup-kill-headers
9646 (if (file-exists-p (car kill-files))
9648 (message "Processing kill file %s..." (car kill-files))
9649 (find-file (car kill-files))
9650 (goto-char (point-min))
9653 (setq form (condition-case nil
9654 (read (current-buffer))
9656 (if (or (eq (car form) 'gnus-kill)
9657 (eq (car form) 'gnus-raise)
9658 (eq (car form) 'gnus-lower))
9660 (delete-region beg (point))
9661 (insert (or (eval form) "")))
9663 (and (buffer-modified-p) (save-buffer))
9664 (message "Processing kill file %s...done" (car kill-files))))
9665 (setq kill-files (cdr kill-files)))))
9666 (if expunge-below (gnus-summary-expunge-below expunge-below))
9667 (let (gnus-summary-inhibit-highlight)
9668 (gnus-summary-set-mark-below mark-below))
9670 (let ((nunreads (- unreads (length gnus-newsgroup-unreads))))
9672 (message "Marked %d articles as read" nunreads))
9676 ;; Kill changes and new format by suggested by JWZ and Sudish Joseph
9677 ;; <joseph@cis.ohio-state.edu>.
9678 (defun gnus-kill (field regexp &optional exe-command all)
9679 "If FIELD of an article matches REGEXP, execute COMMAND.
9680 Optional 1st argument COMMAND is default to
9681 (gnus-summary-mark-as-read nil \"X\").
9682 If optional 2nd argument ALL is non-nil, articles marked are also applied to.
9683 If FIELD is an empty string (or nil), entire article body is searched for.
9684 COMMAND must be a lisp expression or a string representing a key sequence."
9685 ;; We don't want to change current point nor window configuration.
9687 (save-window-excursion
9688 ;; Selected window must be summary buffer to execute keyboard
9689 ;; macros correctly. See command_loop_1.
9690 (switch-to-buffer gnus-summary-buffer 'norecord)
9691 (goto-char (point-min)) ;From the beginning.
9692 (let ((kill-list regexp)
9693 (date (current-time-string))
9694 (command (or exe-command '(gnus-summary-mark-as-read
9695 nil gnus-kill-file-mark)))
9697 (if (listp kill-list)
9699 (if (not (consp (cdr kill-list)))
9700 ;; It's on the form (regexp . date).
9701 (if (zerop (gnus-execute field (car kill-list)
9702 command nil (not all)))
9703 (if (> (gnus-days-between date (cdr kill-list))
9704 gnus-kill-expiry-days)
9706 (setcdr kill-list date))
9707 (while (setq kill (car kill-list))
9709 ;; It's a temporary kill.
9711 (setq kdate (cdr kill))
9712 (if (zerop (gnus-execute
9713 field (car kill) command nil (not all)))
9714 (if (> (gnus-days-between date kdate)
9715 gnus-kill-expiry-days)
9716 ;; Time limit has been exceeded, so we
9717 ;; remove the match.
9719 (setcdr prev (cdr kill-list))
9720 (setq regexp (cdr regexp))))
9721 ;; Successful kill. Set the date to today.
9722 (setcdr kill date)))
9723 ;; It's a permanent kill.
9724 (gnus-execute field kill command nil (not all)))
9725 (setq prev kill-list)
9726 (setq kill-list (cdr kill-list))))
9727 (gnus-execute field kill-list command nil (not all)))
9731 (nconc (list 'gnus-kill field
9732 (if (consp regexp) (list 'quote regexp) regexp))
9733 (if (or exe-command all) (list (list 'quote exe-command)))
9734 (if all (list t) nil)))))
9736 (defun gnus-pp-gnus-kill (object)
9737 (if (or (not (consp (nth 2 object)))
9738 (not (consp (cdr (nth 2 object))))
9739 (and (eq 'quote (car (nth 2 object)))
9740 (not (consp (cdr (car (cdr (nth 2 object))))))))
9741 (concat "\n" (prin1-to-string object))
9743 (set-buffer (get-buffer-create "*Gnus PP*"))
9744 (buffer-disable-undo (current-buffer))
9746 (insert (format "\n(%S %S\n '(" (nth 0 object) (nth 1 object)))
9747 (let ((klist (car (cdr (nth 2 object))))
9750 (insert (if first (progn (setq first nil) "") "\n ")
9751 (prin1-to-string (car klist)))
9752 (setq klist (cdr klist))))
9756 (if (and (consp (nth 3 object))
9757 (not (eq 'quote (car (nth 3 object)))))
9759 (prin1-to-string (nth 3 object))))
9764 (buffer-substring (point-min) (point-max))
9765 (kill-buffer (current-buffer))))))
9767 (defun gnus-execute-1 (function regexp form header)
9773 ;; Compare with header field.
9777 (setq value (funcall function header))
9778 ;; Number (Lines:) or symbol must be converted to string.
9780 (setq value (prin1-to-string value)))
9781 (setq did-kill (string-match regexp value)))
9782 (if (stringp form) ;Keyboard macro.
9783 (execute-kbd-macro form)
9785 ;; Search article body.
9786 (let ((gnus-current-article nil) ;Save article pointer.
9787 (gnus-last-article nil)
9788 (gnus-break-pages nil) ;No need to break pages.
9789 (gnus-mark-article-hook nil)) ;Inhibit marking as read.
9790 (message "Searching for article: %d..." (header-number header))
9791 (gnus-article-setup-buffer)
9792 (gnus-article-prepare (header-number header) t)
9794 (set-buffer gnus-article-buffer)
9795 (goto-char (point-min))
9796 (setq did-kill (re-search-forward regexp nil t)))
9797 (if (stringp form) ;Keyboard macro.
9798 (execute-kbd-macro form)
9802 (defun gnus-execute (field regexp form &optional backward ignore-marked)
9803 "If FIELD of article header matches REGEXP, execute lisp FORM (or a string).
9804 If FIELD is an empty string (or nil), entire article body is searched for.
9805 If optional 1st argument BACKWARD is non-nil, do backward instead.
9806 If optional 2nd argument IGNORE-MARKED is non-nil, articles which are
9807 marked as read or ticked are ignored."
9810 function header article)
9811 (if (or (null field) (string-equal field ""))
9813 ;; Get access function of header filed.
9814 (setq function (intern-soft (concat "gnus-header-" (downcase field))))
9815 (if (and function (fboundp function))
9816 (setq function (symbol-function function))
9817 (error "Unknown header field: \"%s\"" field))
9818 ;; Make FORM funcallable.
9819 (if (and (listp form) (not (eq (car form) 'lambda)))
9820 (setq form (list 'lambda nil form)))
9821 ;; Starting from the current article.
9822 (while (or (and (not article)
9823 (setq article (gnus-summary-article-number))
9826 (gnus-summary-search-subject
9827 backward (not ignore-marked))))
9828 (and (memq article gnus-newsgroup-kill-headers)
9829 (gnus-execute-1 function regexp form
9830 (gnus-get-header-by-number article))
9831 (setq killed-no (1+ killed-no)))))
9837 ;; All score code written by Per Abrahamsen <abraham@iesd.auc.dk>.
9839 (defun gnus-score-default (level)
9840 (if level (prefix-numeric-value level)
9841 gnus-score-interactive-default-score))
9843 (defun gnus-score-set (symbol value &optional alist)
9844 ;; Set SYMBOL to VALUE in ALIST.
9845 (let* ((local-score (gnus-score-file-name gnus-newsgroup-name))
9848 (setq gnus-score-alist
9849 (cdr (assoc local-score gnus-score-cache)))
9851 (gnus-score-load local-score)
9853 (entry (assoc symbol alist)))
9855 (setcdr entry value))
9857 (error "Empty alist"))
9859 (setcdr alist (cons (cons symbol value) (cdr alist)))))))
9861 (defun gnus-score-get (symbol &optional alist)
9862 ;; Get SYMBOL's definition in ALIST.
9865 ; (setq gnus-score-alist
9866 ; (cdr (assoc (gnus-score-file-name gnus-newsgroup-name)
9867 ; gnus-score-cache))
9871 (gnus-score-file-name gnus-newsgroup-name))
9872 gnus-score-alist)))))
9874 (defun gnus-score-edit-file (group)
9875 "Edit score file for GROUP."
9876 (interactive (list (read-string "Edit SCORE file for: "
9877 (cons (or gnus-newsgroup-name "") 1))))
9878 (and (get-buffer gnus-summary-buffer) (gnus-score-save))
9879 (find-file (gnus-score-file-name group))
9882 (defun gnus-score-load-file (file)
9883 ;; Load score file FILE. Updates `gnus-scores-lists'.
9884 (let ((cache (assoc file gnus-score-cache)))
9887 (setq gnus-score-alist (cdr cache))
9888 (if (memq t (mapcar (lambda (e) (stringp (car e))) gnus-score-alist))
9889 (setq gnus-scores-lists
9890 (cons gnus-score-alist gnus-scores-lists))))
9891 (setq gnus-score-alist nil)
9893 (if (memq t (mapcar (lambda (e) (stringp (car e))) gnus-score-alist))
9894 (setq gnus-scores-lists (cons gnus-score-alist gnus-scores-lists)))
9895 (or gnus-score-alist
9896 (setq gnus-score-alist (copy-alist '((touched . nil)))))
9897 (setq gnus-score-cache
9898 (cons (cons file gnus-score-alist) gnus-score-cache))))
9899 (let ((mark (gnus-score-get 'mark))
9900 (expunge (gnus-score-get 'expunge))
9901 (files (gnus-score-get 'files))
9902 (eval (gnus-score-get 'eval)))
9903 (if files (mapcar (lambda (file) (gnus-score-load-file file)) files))
9904 (if eval (eval eval))
9905 (if mark (setq gnus-summary-mark-below mark))
9906 (if expunge (setq gnus-summary-expunge-below expunge))))
9908 (defun gnus-score-load (file)
9910 ;; Updates free variables `gnus-score-alist' and `scores'.
9912 (let ((cache (assoc file gnus-score-cache)))
9914 (setq gnus-score-alist (cdr cache))
9915 (setq gnus-score-alist nil)
9917 (or gnus-score-alist
9918 (setq gnus-score-alist (copy-alist '((touched . nil)))))
9919 (setq gnus-score-cache
9920 (cons (cons file gnus-score-alist) gnus-score-cache)))))
9922 (defun gnus-score-save ()
9923 ;; Save all SCORE information.
9926 (set-buffer gnus-summary-buffer)
9927 (setq cache gnus-score-cache
9928 gnus-score-cache nil))
9930 (setq gnus-score-alist nil)
9931 (set-buffer (get-buffer-create "*Score*"))
9932 (buffer-disable-undo (current-buffer))
9933 (let (entry score file)
9935 (setq entry (car cache)
9939 (if (null (gnus-score-get 'touched score))
9941 (gnus-score-set 'touched nil score)
9943 (let (emacs-lisp-mode-hook)
9944 (pp (list 'setq 'gnus-score-alist (list 'quote score))
9946 (make-directory (file-name-directory file) t)
9947 (write-region (point-min) (point-max) file nil 'silent))))
9948 (kill-buffer (current-buffer)))))
9950 (defun gnus-score-headers ()
9951 ;; Score `gnus-newsgroup-headers'.
9952 (let ((score-files (and gnus-score-find-score-files-function
9953 (fboundp gnus-score-find-score-files-function)
9954 (funcall gnus-score-find-score-files-function
9955 gnus-newsgroup-name)))
9957 ;; Load the SCORE files.
9959 (gnus-score-load-file (car score-files))
9960 (setq score-files (cdr score-files)))
9961 (setq scores gnus-scores-lists
9962 gnus-scores-lists nil)
9963 (if (not (and gnus-summary-default-score
9965 (> (length gnus-newsgroup-headers)
9966 (length gnus-newsgroup-scored))))
9968 (let* ((entries gnus-header-index)
9969 (now (current-time-string))
9970 (expire (- (gnus-useful-date now) gnus-kill-expiry-days))
9971 (headers gnus-newsgroup-headers)
9973 (message "Scoring...")
9974 ;; Create articles, an alist of the form `(HEADER . SCORE)'.
9976 (setq header (car headers)
9977 headers (cdr headers))
9978 ;; WARNING: The assq makes the function O(N*S) while it could
9979 ;; be written as O(N+S), where N is (length gnus-newsgroup-headers)
9980 ;; and S is (length gnus-newsgroup-scored).
9981 (or (assq (header-number header) gnus-newsgroup-scored)
9982 (setq gnus-scores-articles ;Total of 2 * N cons-cells used.
9983 (cons (cons header gnus-summary-default-score)
9984 gnus-scores-articles))))
9987 (set-buffer (get-buffer-create "*Headers*"))
9988 (buffer-disable-undo (current-buffer))
9989 ;; Run each header through the score process.
9991 (setq entry (car entries)
9992 header (nth 0 entry)
9993 entries (cdr entries))
9994 (setq gnus-score-index (nth 1 (assoc header gnus-header-index)))
9995 (if (< 0 (apply 'max (mapcar
9997 (length (gnus-score-get header score)))
9999 (funcall (nth 2 entry) scores header now expire)))
10000 ;; Remove the buffer.
10001 (kill-buffer (current-buffer)))
10003 (message "Scoring...")
10004 ;; Add articles to `gnus-newsgroup-scored'.
10005 (while gnus-scores-articles
10006 (or (= gnus-summary-default-score (cdr (car gnus-scores-articles)))
10007 (setq gnus-newsgroup-scored
10008 (cons (cons (header-number
10009 (car (car gnus-scores-articles)))
10010 (cdr (car gnus-scores-articles)))
10011 gnus-newsgroup-scored)))
10012 (setq gnus-scores-articles (cdr gnus-scores-articles)))
10014 (message "Scoring...done")))))
10016 ;(defun gnus-score-integer (scores header now expire)
10019 ;(defun gnus-score-date (scores header now expire)
10022 (defun gnus-score-string (scores header now expire)
10023 ;; Score ARTICLES according to HEADER in SCORES.
10024 ;; Update matches entries to NOW and remove unmatched entried older
10027 ;; Insert the unique article headers in the buffer.
10028 (let ((gnus-score-index (nth 1 (assoc header gnus-header-index)))
10029 ;; gnus-score-index is used as a free variable.
10030 alike last this art entries alist articles)
10032 ;; Sorting the articles costs os O(N*log N) but will allow us to
10033 ;; only match with each unique header. Thus the actual matching
10034 ;; will be O(M*U) where M is the number of strings to match with,
10035 ;; and U is the number of unique headers. It is assumed (but
10036 ;; untested) this will be a net win because of the large constant
10037 ;; factor involved with string matching.
10038 (setq gnus-scores-articles (sort gnus-scores-articles 'gnus-score-string<)
10039 articles gnus-scores-articles)
10043 (setq art (car articles)
10044 this (aref (car art) gnus-score-index)
10045 articles (cdr articles))
10046 (if (equal last this)
10047 ;; O(N*H) cons-cells used here, where H is the number of
10049 (setq alike (cons art alike))
10052 ;; Insert the line, with a text property on the
10053 ;; terminating newline refering to the articles with
10056 (put-text-property (1- (point)) (point) 'articles alike)))
10057 (setq alike (list art)
10059 (and last ; Bwadr, duplicate code.
10062 (put-text-property (1- (point)) (point) 'articles alike)))
10066 (setq alist (car scores)
10067 scores (cdr scores)
10068 entries (assoc header alist))
10069 (while (cdr entries) ;First entry is the header index.
10070 (let* ((rest (cdr entries))
10072 (match (nth 0 kill))
10073 (type (nth 1 kill))
10074 (score (nth 2 kill))
10075 (date (nth 3 kill))
10077 (case-fold-search t)
10079 (goto-char (point-min))
10081 (re-search-forward match nil t)
10082 (search-forward match nil t))
10085 arts (get-text-property (point) 'articles))
10086 ;; Found a match, update scores.
10088 (setq art (car arts)
10090 (setcdr art (+ score (cdr art)))))
10091 ;; Update expire date
10092 (cond ((null date)) ;Permanent entry.
10093 (found ;Match, update date.
10094 (gnus-score-set 'touched t alist)
10095 (setcar (nthcdr 3 kill) now))
10096 ((< (gnus-useful-date date) expire) ;Old entry, remove.
10097 (gnus-score-set 'touched t alist)
10098 (setcdr entries (cdr rest))
10099 (setq rest entries)))
10100 (setq entries rest))))))
10102 (defun gnus-score-string< (a1 a2)
10103 ;; Compare headers in articles A2 and A2.
10104 ;; The header index used is the free variable `gnus-score-index'.
10105 (string-lessp (aref (car a1) gnus-score-index)
10106 (aref (car a2) gnus-score-index)))
10108 (defun gnus-useful-date (date)
10109 ;; Return the numeric day corresponding to the DATE string.
10110 (let ((d (mapcar (lambda (s) (and s (string-to-int s)) )
10111 (timezone-parse-date date))))
10112 (timezone-absolute-from-gregorian (nth 1 d) (nth 2 d) (car d))))
10114 (defun gnus-score-build-cons (article)
10115 ;; Build a `gnus-newsgroup-scored' type cons from ARTICLE.
10116 (cons (header-number (car article)) (cdr article)))
10118 (defconst gnus-header-index
10119 ;; Name to index alist.
10120 '(("number" 0 gnus-score-integer)
10121 ("subject" 1 gnus-score-string)
10122 ("from" 2 gnus-score-string)
10123 ("date" 3 gnus-score-date)
10124 ("id" 4 gnus-score-string)
10125 ("references" 5 gnus-score-string)
10126 ("chars" 6 gnus-score-integer)
10127 ("lines" 7 gnus-score-integer)
10128 ("xref" 8 gnus-score-string)))
10130 (defvar gnus-score-file-suffix "SCORE"
10131 "Suffix of the score files.")
10133 (defun gnus-score-file-name (newsgroup)
10134 "Return the name of a score file for NEWSGROUP."
10135 (cond ((or (null newsgroup)
10136 (string-equal newsgroup ""))
10137 ;; The global score file is placed at top of the directory.
10138 (expand-file-name gnus-score-file-suffix
10139 (or gnus-kill-files-directory "~/News")))
10140 (gnus-use-long-file-name
10141 ;; Append ".SCORE" to newsgroup name.
10142 (expand-file-name (concat newsgroup "." gnus-score-file-suffix)
10143 (or gnus-kill-files-directory "~/News")))
10145 ;; Place "KILL" under the hierarchical directory.
10146 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
10147 "/" gnus-score-file-suffix)
10148 (or gnus-kill-files-directory "~/News")))))
10150 (defun gnus-score-score-files (group)
10151 "Return a list of all possible score files."
10152 (or gnus-kill-files-directory (setq gnus-kill-files-directory "~/News/"))
10153 (if (not (file-exists-p gnus-kill-files-directory))
10154 (setq gnus-score-file-list nil)
10155 (if gnus-use-long-file-name
10156 (if (or (not gnus-score-file-list)
10157 (gnus-file-newer-than gnus-kill-files-directory
10158 (car gnus-score-file-list)))
10159 (setq gnus-score-file-list
10160 (cons (nth 5 (file-attributes gnus-kill-files-directory))
10162 gnus-kill-files-directory t
10163 (concat gnus-score-file-suffix "$")))))
10164 (let ((dir (expand-file-name
10165 (concat gnus-kill-files-directory
10166 (gnus-replace-chars-in-string group ?. ?/))))
10167 (mdir (length (expand-file-name gnus-kill-files-directory)))
10169 (if (file-exists-p (concat dir "/" gnus-score-file-suffix))
10170 (setq files (list (concat dir "/" gnus-score-file-suffix))))
10171 (while (>= (1+ (length dir)) mdir)
10172 (and (file-exists-p (concat dir "/all/" gnus-score-file-suffix))
10173 (setq files (cons (concat dir "/all/" gnus-score-file-suffix)
10175 (string-match "/[^/]*$" dir)
10176 (setq dir (substring dir (match-beginning 0))))
10177 (setq gnus-score-file-list (cons nil files)))))
10178 (cdr gnus-score-file-list))
10180 (defun gnus-score-find-single (group)
10181 "Return list containing the score file for GROUP."
10182 (list (gnus-score-file-name group)))
10184 (defun gnus-score-find-hierarchical (group)
10185 "Return list of score files for GROUP.
10186 This includes the score file for the group and all its parents."
10187 (let ((all (copy-sequence '(nil)))
10189 (while (string-match "\\." group (1+ start))
10190 (setq start (match-beginning 0))
10191 (setq all (cons (substring group 0 start) all)))
10192 (setq all (cons group all))
10193 (mapcar 'gnus-score-file-name (nreverse all))))
10195 (defun gnus-score-find-bnews (group)
10196 "Return a list of score files for GROUP.
10197 The score files are those files in the ~/News directory which matches
10198 GROUP using BNews sys file syntax."
10199 (let ((sfiles (gnus-score-score-files group))
10200 (klen (length (expand-file-name gnus-kill-files-directory)))
10201 ofiles not-match regexp)
10203 (set-buffer (get-buffer-create "*gnus score files*"))
10204 (buffer-disable-undo (current-buffer))
10207 (insert (car sfiles))
10209 (re-search-forward (concat "." gnus-score-file-suffix "$"))
10213 (while (search-forward "all" nil t)
10214 (replace-match ".+"))
10216 (if (looking-at "not.")
10219 (setq regexp (buffer-substring 5 (point-max))))
10220 (setq regexp (buffer-substring 1 (point-max)))
10221 (setq not-match nil))
10222 (if (or (and not-match
10223 (not (string-match regexp group)))
10224 (and (not not-match)
10225 (string-match regexp group)))
10226 (setq ofiles (cons (car sfiles) ofiles)))
10227 (setq sfiles (cdr sfiles)))
10228 (kill-buffer (current-buffer))
10233 ;;; Gnus Posting Functions
10236 (defvar gnus-organization-file "/usr/lib/news/organization"
10237 "*Local news organization file.")
10239 (defvar gnus-post-news-buffer "*post-news*")
10240 (defvar gnus-winconf-post-news nil)
10242 (autoload 'news-reply-mode "rnewspost")
10244 ;;; Post news commands of Gnus group mode and summary mode
10246 (defun gnus-group-post-news ()
10249 (gnus-set-global-variables)
10250 ;; Save window configuration.
10251 (setq gnus-winconf-post-news (current-window-configuration))
10252 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
10253 (or gnus-newsgroup-name (setq gnus-newsgroup-name (gnus-group-group-name)))
10255 (gnus-post-news 'post nil)
10256 (or (and (eq (current-buffer) (get-buffer gnus-post-news-buffer))
10257 (not (zerop (buffer-size))))
10258 ;; Restore last window configuration.
10259 (and gnus-winconf-post-news
10260 (set-window-configuration gnus-winconf-post-news))))
10261 ;; We don't want to return to summary buffer nor article buffer later.
10262 (setq gnus-winconf-post-news nil)
10263 (if (get-buffer gnus-summary-buffer)
10264 (bury-buffer gnus-summary-buffer))
10265 (if (get-buffer gnus-article-buffer)
10266 (bury-buffer gnus-article-buffer)))
10268 (defun gnus-summary-post-news ()
10271 (gnus-set-global-variables)
10272 ;; Save window configuration.
10273 (setq gnus-winconf-post-news (current-window-configuration))
10275 (gnus-post-news 'post gnus-newsgroup-name)
10276 (or (and (eq (current-buffer) (get-buffer gnus-post-news-buffer))
10277 (not (zerop (buffer-size))))
10278 ;; Restore last window configuration.
10279 (and gnus-winconf-post-news
10280 (set-window-configuration gnus-winconf-post-news))))
10281 ;; We don't want to return to article buffer later.
10282 (if (get-buffer gnus-article-buffer)
10283 (bury-buffer gnus-article-buffer)))
10285 (defun gnus-summary-followup (yank)
10286 "Compose a followup to an article.
10287 If prefix argument YANK is non-nil, original article is yanked automatically."
10289 (gnus-set-global-variables)
10290 (gnus-summary-select-article t)
10291 (let ((headers gnus-current-headers)
10292 (gnus-newsgroup-name gnus-newsgroup-name))
10293 ;; Check Followup-To: poster.
10294 (set-buffer gnus-article-buffer)
10295 (if (and gnus-use-followup-to
10296 (string-equal "poster" (gnus-fetch-field "followup-to"))
10297 (or (not (eq gnus-use-followup-to t))
10298 (not (gnus-y-or-n-p
10299 "Do you want to ignore `Followup-To: poster'? "))))
10300 ;; Mail to the poster. Gnus is now RFC1036 compliant.
10301 (gnus-summary-reply yank)
10302 ;; Save window configuration.
10303 (setq gnus-winconf-post-news (current-window-configuration))
10305 (gnus-post-news 'followup headers gnus-article-buffer yank)
10306 (or (and (eq (current-buffer) (get-buffer gnus-post-news-buffer))
10307 (not (zerop (buffer-size))))
10308 ;; Restore last window configuration.
10309 (and gnus-winconf-post-news
10310 (set-window-configuration gnus-winconf-post-news))))
10311 ;; We don't want to return to article buffer later.
10312 (bury-buffer gnus-article-buffer))))
10314 (defun gnus-summary-followup-with-original ()
10315 "Compose a followup to an article and include the original article."
10317 (gnus-summary-followup t))
10319 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10320 (defun gnus-summary-followup-and-reply (yank)
10321 "Compose a followup and do an auto mail to author."
10323 (let ((gnus-auto-mail-to-author t))
10324 (gnus-summary-followup yank)))
10326 (defun gnus-summary-followup-and-reply-with-original ()
10327 "Compose a followup, include the original, and do an auto mail to author."
10329 (gnus-summary-followup-and-reply t))
10331 (defun gnus-summary-cancel-article ()
10332 "Cancel an article you posted."
10334 (gnus-set-global-variables)
10335 (gnus-summary-select-article t)
10336 (gnus-eval-in-buffer-window gnus-article-buffer
10337 (gnus-cancel-news)))
10339 (defun gnus-summary-supersede-article ()
10340 "Compose an article that will supersede a previous article.
10341 This is done simply by taking the old article and adding a Supersedes
10342 header line with the old Message-ID."
10344 (gnus-set-global-variables)
10347 (downcase (mail-strip-quoted-names
10348 (header-from gnus-current-headers)))
10349 (downcase (mail-strip-quoted-names (gnus-inews-user-name)))))
10350 (error "This article is not yours."))
10351 (gnus-summary-select-article t)
10353 (set-buffer gnus-article-buffer)
10354 (let ((buffer-read-only nil))
10355 (goto-char (point-min))
10356 (search-forward "\n\n" nil t)
10357 (if (not (re-search-backward "^Message-ID: " nil t))
10358 (error "No Message-ID in this article"))))
10359 (if (gnus-post-news 'post gnus-newsgroup-name)
10362 (insert-buffer gnus-article-buffer)
10363 (goto-char (point-min))
10364 (search-forward "\n\n" nil t)
10365 (if (not (re-search-backward "^Message-ID: " nil t))
10366 (error "No Message-ID in this article")
10367 (replace-match "Supersedes: "))
10368 (search-forward "\n\n")
10370 (insert mail-header-separator))))
10373 ;;; Post a News using NNTP
10376 (fset 'sendnews 'gnus-post-news)
10379 (fset 'postnews 'gnus-post-news)
10381 (defun gnus-post-news (method &optional header article-buffer yank)
10382 "Begin editing a new USENET news article to be posted.
10383 Type \\[describe-mode] in the buffer to get a list of commands."
10385 (if (or (not gnus-novice-user)
10389 (format "%s" (car (gnus-find-method-for-group
10390 gnus-newsgroup-name)))
10391 gnus-valid-select-methods))))
10392 (gnus-y-or-n-p "Are you sure you want to post to all of USENET? "))
10393 (let ((sumart (if (eq method 'followup)
10395 (set-buffer gnus-summary-buffer)
10396 (cons (current-buffer) gnus-current-article))))
10398 (if (and gnus-interactive-post
10399 (not gnus-expert-user)
10403 (completing-read "Group: " gnus-active-hashtb nil t)))
10404 (setq mail-reply-buffer article-buffer)
10405 (setq gnus-post-news-buffer
10407 (gnus-request-post-buffer
10408 method (if (stringp header)
10409 (gnus-group-real-name header) header)
10411 (if (eq method 'post)
10413 (delete-other-windows)
10414 (switch-to-buffer post-buf))
10415 (delete-other-windows)
10418 (switch-to-buffer article-buffer)
10419 (pop-to-buffer post-buf))
10420 (switch-to-buffer post-buf)))
10421 (gnus-overload-functions)
10422 (make-local-variable 'gnus-article-reply)
10423 (make-local-variable 'gnus-article-check-size)
10424 (setq gnus-article-reply sumart)
10425 ;; Handle author copy using BCC field.
10426 (if (and gnus-mail-self-blind
10427 (not (mail-fetch-field "bcc")))
10429 (mail-position-on-field "BCC")
10430 (insert (if (stringp gnus-mail-self-blind)
10431 gnus-mail-self-blind
10432 (user-login-name)))))
10433 ;; Handle author copy using FCC field.
10434 (if gnus-author-copy
10436 (mail-position-on-field "FCC")
10437 (insert gnus-author-copy)))
10438 (goto-char (point-min))
10439 (if (and (eq method 'post) (not header))
10441 (search-forward (concat "\n" mail-header-separator "\n"))
10444 (run-hooks 'news-reply-header-hook)
10445 (mail-yank-original nil)))
10446 (if gnus-post-prepare-function
10447 (funcall gnus-post-prepare-function
10448 (if (stringp header) header gnus-newsgroup-name))))))
10449 (setq gnus-article-check-size (cons (buffer-size) (gnus-article-checksum)))
10453 (defun gnus-inews-news (&optional use-group-method)
10454 "Send a news message.
10455 If given a prefix, and the group is a foreign group, this function
10456 will attempt to use the foreign server to post the article."
10458 ;; Check whether the article is a good Net Citizen.
10459 (if (and gnus-article-check-size (not (gnus-inews-check-post)))
10462 ;; Looks ok, so we do the nasty.
10463 (let* ((case-fold-search nil)
10464 (server-running (gnus-server-opened gnus-select-method))
10465 (reply gnus-article-reply))
10467 ;; Connect to default NNTP server if necessary.
10468 ;; Suggested by yuki@flab.fujitsu.junet.
10469 (gnus-start-news-server) ;Use default server.
10470 ;; NNTP server must be opened before current buffer is modified.
10472 (goto-char (point-min))
10473 (run-hooks 'news-inews-hook)
10478 (goto-char (point-min))
10479 (search-forward (concat "\n" mail-header-separator "\n"))
10482 ;; Correct newsgroups field: change sequence of spaces to comma and
10483 ;; eliminate spaces around commas. Eliminate imbedded line breaks.
10484 (goto-char (point-min))
10485 (if (search-forward-regexp "^Newsgroups: +" nil t)
10489 (if (re-search-forward "^[^ \t]" nil 'end)
10490 (match-beginning 0)
10492 (goto-char (point-min))
10493 (replace-regexp "\n[ \t]+" " ") ;No line breaks (too confusing)
10494 (goto-char (point-min))
10495 (replace-regexp "[ \t\n]*,[ \t\n]*\\|[ \t]+" ",")))
10497 ;; Added by Per Abrahamsen <abraham@iesd.auc.dk>.
10498 ;; Help save the the world!
10501 (let ((newsgroups (mail-fetch-field "newsgroups"))
10502 (followup-to (mail-fetch-field "followup-to"))
10504 (if (and (string-match "," newsgroups) (not followup-to))
10506 (while (string-match "," newsgroups)
10508 (cons (list (substring newsgroups
10509 0 (match-beginning 0)))
10511 (setq newsgroups (substring newsgroups (match-end 0))))
10512 (setq groups (nreverse (cons (list newsgroups) groups)))
10515 (completing-read "Followups to: (default all groups) "
10517 (if (> (length to) 0)
10519 (goto-char (point-min))
10520 (insert "Followup-To: " to "\n")))))))
10522 ;; Cleanup Followup-To.
10523 (goto-char (point-min))
10524 (if (search-forward-regexp "^Followup-To: +" nil t)
10528 (if (re-search-forward "^[^ \t]" nil 'end)
10529 (match-beginning 0)
10531 (goto-char (point-min))
10532 (replace-regexp "\n[ \t]+" " ") ;No line breaks (too confusing)
10533 (goto-char (point-min))
10534 (replace-regexp "[ \t\n]*,[ \t\n]*\\|[ \t]+" ",")))
10536 ;; Mail the message too if To:, Bcc:. or Cc: exists.
10537 (if (or (mail-fetch-field "to" nil t)
10538 (mail-fetch-field "bcc" nil t)
10539 (mail-fetch-field "cc" nil t))
10540 (if gnus-mail-send-method
10542 (message "Sending via mail...")
10544 (funcall gnus-mail-send-method)
10545 (message "Sending via mail... done")
10550 1 (re-search-forward mail-header-separator))
10552 (delete-matching-lines "BCC:.*"))))
10554 (message "No mailer defined. To: and/or Cc: fields ignored.")
10557 ;; Send to NNTP server.
10558 (message "Posting to USENET...")
10559 (if (gnus-inews-article use-group-method)
10561 (message "Posting to USENET... done")
10563 (get-buffer (car reply))
10564 (buffer-name (car reply)))
10567 (set-buffer gnus-summary-buffer)
10568 (gnus-summary-mark-article-as-replied
10570 ;; We cannot signal an error.
10571 (ding) (message "Article rejected: %s"
10572 (gnus-status-message gnus-select-method)))
10573 (set-buffer-modified-p nil))
10574 ;; If NNTP server is opened by gnus-inews-news, close it by myself.
10576 (gnus-close-server (gnus-find-method-for-group gnus-newsgroup-name)))
10577 (and (fboundp 'bury-buffer) (bury-buffer))
10578 ;; Restore last window configuration.
10579 (and gnus-winconf-post-news
10580 (set-window-configuration gnus-winconf-post-news))
10581 (setq gnus-winconf-post-news nil))))
10583 (defun gnus-inews-check-post ()
10584 "Check whether the post looks ok."
10586 ;; Check excessive size.
10587 (if (> (buffer-size) 60000)
10588 (gnus-y-or-n-p (format "The article is %d octets long. Really post? "
10591 ;; Check for commands in Subject.
10594 (goto-char (point-min))
10595 (narrow-to-region (point) (search-forward mail-header-separator))
10596 (if (string-match "^cmsg " (mail-fetch-field "subject"))
10598 "The control code \"cmsg \" is in the subject. Really post? ")
10600 ;; Check for control characters.
10602 (if (re-search-forward "[\000-\007\013\015-\037\200-\237]" nil t)
10604 "The article contains control characters. Really post? ")
10606 ;; Check for multiple identical headers.
10610 (goto-char (point-min))
10611 (narrow-to-region (point) (search-forward mail-header-separator))
10612 (goto-char (point-min))
10613 (while (and (not found) (re-search-forward "^[^ \t:]+: " nil t))
10615 (or (re-search-forward
10616 (concat "^" (setq found
10617 (buffer-substring (match-beginning 0)
10620 (setq found nil))))
10623 (format "Multiple %s headers. Really post? " found))
10625 ;; Check for version and sendsys.
10628 (goto-char (point-min))
10629 (narrow-to-region (point) (search-forward mail-header-separator))
10630 (if (re-search-backward "^Sendsys:\\|^Version:" nil t)
10632 (format "The article contains a %s command. Really post? "
10633 (buffer-substring (match-beginning 0) (match-end 0))))
10637 (goto-char (point-min))
10638 (narrow-to-region (point) (search-forward mail-header-separator))
10639 (let* ((case-fold-search t)
10640 (from (mail-fetch-field "from")))
10642 (string-match "@" from)
10643 (not (string-match "@[^\\.]*\\." from)))
10645 (format "The domain looks strange: \"%s\". Really post? "
10648 ;; Use the (size . checksum) variable to see whether the
10649 ;; article is empty or has only quoted text.
10650 (if (and (= (buffer-size) (car gnus-article-check-size))
10651 (= (gnus-article-checksum) (cdr gnus-article-check-size)))
10653 "It looks like there's no new text in your article. Really post? ")
10656 (defun gnus-article-checksum ()
10659 (while (not (eobp))
10660 (setq sum (logxor sum (following-char)))
10664 (defun gnus-cancel-news ()
10665 "Cancel an article you posted."
10667 (if (gnus-yes-or-no-p "Do you really want to cancel this article? ")
10671 (distribution nil))
10673 ;; Get header info. from original article.
10675 (gnus-article-show-all-headers)
10676 (goto-char (point-min))
10677 (search-forward "\n\n" nil 'move)
10678 (narrow-to-region (point-min) (point))
10679 (setq from (mail-fetch-field "from"))
10680 (setq newsgroups (mail-fetch-field "newsgroups"))
10681 (setq message-id (mail-fetch-field "message-id"))
10682 (setq distribution (mail-fetch-field "distribution")))
10683 ;; Verify if the article is absolutely user's by comparing
10684 ;; user id with value of its From: field.
10687 (downcase (mail-strip-quoted-names from))
10688 (downcase (mail-strip-quoted-names (gnus-inews-user-name)))))
10690 (ding) (message "This article is not yours."))
10691 ;; Make control article.
10692 (set-buffer (get-buffer-create " *Gnus-canceling*"))
10693 (buffer-disable-undo (current-buffer))
10695 (insert "Newsgroups: " newsgroups "\n"
10696 "Subject: cancel " message-id "\n"
10697 "Control: cancel " message-id "\n"
10698 mail-header-separator "\n"
10699 "This is a cancel message from " from ".\n")
10700 ;; Send the control article to NNTP server.
10701 (message "Canceling your article...")
10702 (if (gnus-inews-article)
10703 (message "Canceling your article... done")
10704 (ding) (message "Failed to cancel your article"))
10705 ;; Kill the article buffer.
10706 (kill-buffer (current-buffer)))))))
10709 ;;; Lowlevel inews interface
10711 (defun gnus-inews-article (&optional use-group-method)
10712 "Post an article in current buffer using NNTP protocol."
10713 (let ((artbuf (current-buffer))
10714 (tmpbuf (get-buffer-create " *Gnus-posting*")))
10716 (goto-char (point-max))
10717 ;; require a newline at the end for inews to append .signature to
10718 (or (= (preceding-char) ?\n)
10720 ;; Prepare article headers. All message body such as signature
10721 ;; must be inserted before Lines: field is prepared.
10723 (goto-char (point-min))
10727 (search-forward (concat "\n" mail-header-separator "\n"))
10730 (gnus-inews-insert-headers)
10731 (run-hooks gnus-inews-article-header-hook)
10734 (set-buffer tmpbuf)
10735 (buffer-disable-undo (current-buffer))
10737 (insert-buffer-substring artbuf)
10738 ;; Remove the header separator.
10739 (goto-char (point-min))
10740 (search-forward (concat "\n" mail-header-separator "\n"))
10741 (replace-match "\n\n")
10742 ;; This hook may insert a signature.
10743 (run-hooks 'gnus-prepare-article-hook)
10744 ;; Run final inews hooks. This hook may do FCC.
10745 ;; The article must be saved before being posted because
10746 ;; `gnus-request-post' modifies the buffer.
10747 (run-hooks 'gnus-inews-article-hook)
10748 ;; Post an article to NNTP server.
10749 ;; Return NIL if post failed.
10752 (if use-group-method
10753 (gnus-find-method-for-group gnus-newsgroup-name)
10754 gnus-select-method) use-group-method)
10755 (kill-buffer (current-buffer))))))
10757 (defun gnus-inews-insert-headers ()
10758 "Prepare article headers.
10759 Headers already prepared in the buffer are not modified.
10760 Headers in `gnus-required-headers' will be generated."
10761 (let ((Date (gnus-inews-date))
10762 (Message-ID (gnus-inews-message-id))
10763 (Organization (gnus-inews-organization))
10764 (From (gnus-inews-user-name))
10765 (Path (gnus-inews-path))
10769 (Lines (gnus-inews-lines))
10770 (X-Newsreader gnus-version)
10771 (headers gnus-required-headers)
10772 (case-fold-search t)
10774 ;; First we remove any old Message-IDs. This might be slightly
10775 ;; fascist, but if the user really wants to generate Message-IDs
10776 ;; by herself, she should remove it from the `gnus-required-list'.
10777 (goto-char (point-min))
10778 (and (memq 'Message-ID headers)
10779 (re-search-forward "^Message-ID:" nil t)
10780 (delete-region (progn (beginning-of-line) (point))
10781 (progn (forward-line 1) (point))))
10782 ;; Remove NNTP-posting-host.
10783 (goto-char (point-min))
10784 (and (re-search-forward "nntp-posting-host^:" nil t)
10785 (delete-region (progn (beginning-of-line) (point))
10786 (progn (forward-line 1) (point))))
10787 ;; Insert new Sender if the From is strange.
10788 (let ((from (mail-fetch-field "from")))
10789 (if (and from (not (string= (downcase from) (downcase From))))
10791 (goto-char (point-min))
10792 (and (re-search-forward "^Sender:" nil t)
10793 (delete-region (progn (beginning-of-line) (point))
10794 (progn (forward-line 1) (point))))
10795 (insert "Sender: " From "\n"))))
10796 ;; If there are References, and no "Re: ", then the thread has
10797 ;; changed name. See Son-of-1036.
10798 (if (and (mail-fetch-field "references")
10799 (get-buffer gnus-article-buffer))
10800 (let ((psubject (gnus-simplify-subject-re
10801 (mail-fetch-field "subject")))
10804 (set-buffer (get-buffer gnus-article-buffer))
10806 (gnus-narrow-to-headers)
10807 (if (setq subject (mail-fetch-field "subject"))
10809 (and gnus-summary-gather-subject-limit
10810 (> (length subject) gnus-summary-gather-subject-limit)
10812 (substring subject 0
10813 gnus-summary-gather-subject-limit)))
10814 (setq subject (gnus-simplify-subject-re subject))))))
10815 (or (and psubject subject (string= subject psubject))
10817 (string-match "@" Message-ID)
10819 (concat (substring Message-ID 0 (match-beginning 0))
10821 (substring Message-ID (match-beginning 0))))))))
10822 ;; Go through all the required headers and see if they are in the
10823 ;; articles already. If they are not, or are empty, they are
10824 ;; inserted automatically - except for Subject, Newsgroups and
10827 (goto-char (point-min))
10828 (setq header (car headers))
10829 (if (or (not (re-search-forward
10830 (concat "^" (downcase (symbol-name header)) ":") nil t))
10832 (if (= (following-char) ? ) (forward-char 1) (insert " "))
10833 (looking-at "[ \t]*$")))
10835 (setq value (or (and (boundp header) (symbol-value header))
10836 (read-from-minibuffer
10837 (format "Empty header for %s; enter value: "
10841 (goto-char (point-max))
10842 (insert (symbol-name header) ": " value "\n"))
10843 (replace-match value))))
10844 (setq headers (cdr headers)))))
10846 (defun gnus-inews-insert-signature ()
10847 "Insert a signature file.
10848 If `gnus-signature-function' is bound and returns a string, this
10849 string is used instead of the variable `gnus-signature-file'.
10850 In either case, if the string is a file name, this file is
10851 inserted. If the string is not a file name, the string itself is
10853 If you never want any signature inserted, set both those variables to
10857 (or (and gnus-signature-function
10858 (fboundp gnus-signature-function)
10859 (funcall gnus-signature-function gnus-newsgroup-name))
10860 gnus-signature-file))
10863 (or (file-exists-p signature)
10864 (string-match " " signature)
10866 "^/[^/]+/" (expand-file-name signature)))))
10868 (goto-char (point-max))
10869 ;; Delete any previous signatures.
10870 (if (and mail-signature (search-backward "\n-- \n" nil t))
10871 (delete-region (1+ (point)) (point-max)))
10873 (and (< 4 (setq b (count-lines
10876 (if (file-exists-p signature)
10877 (insert-file-contents signature)
10878 (insert signature))
10879 (goto-char (point-max))
10880 (or (bolp) (insert "\n"))
10882 (not gnus-expert-user)
10886 "Your .sig is %d lines; it should be max 4. Really post? "
10888 (if (file-exists-p signature)
10889 (error (format "Edit %s." signature))
10890 (error "Trim your signature."))))))))
10892 (defun gnus-inews-do-fcc ()
10893 "Process FCC: fields in current article buffer.
10894 Unless the first character of the field is `|', the article is saved
10895 to the specified file using the function specified by the variable
10896 gnus-author-copy-saver. The default function rmail-output saves in
10897 Unix mailbox format.
10898 If the first character is `|', the contents of the article is send to
10899 a program specified by the rest of the value."
10900 (let ((fcc-list nil)
10902 (case-fold-search t)) ;Should ignore case.
10905 (goto-char (point-min))
10906 (search-forward "\n\n")
10907 (narrow-to-region (point-min) (point))
10908 (goto-char (point-min))
10909 (while (re-search-forward "^FCC:[ \t]*" nil t)
10911 (cons (buffer-substring
10915 (skip-chars-backward " \t")
10918 (delete-region (match-beginning 0)
10919 (progn (forward-line 1) (point))))
10920 ;; Process FCC operations.
10923 (setq fcc-file (car fcc-list))
10924 (setq fcc-list (cdr fcc-list))
10925 (cond ((string-match "^[ \t]*|[ \t]*\\(.*\\)[ \t]*$" fcc-file)
10926 (let ((program (substring fcc-file
10927 (match-beginning 1) (match-end 1))))
10928 ;; Suggested by yuki@flab.fujitsu.junet.
10929 ;; Send article to named program.
10930 (call-process-region (point-min) (point-max) shell-file-name
10931 nil nil nil "-c" program)
10934 ;; Suggested by hyoko@flab.fujitsu.junet.
10935 ;; Save article in Unix mail format by default.
10936 (if (and gnus-author-copy-saver
10937 (not (eq gnus-author-copy-saver 'rmail-output)))
10938 (funcall gnus-author-copy-saver fcc-file)
10939 (if (and (file-readable-p fcc-file) (rmail-file-p fcc-file))
10940 (gnus-output-to-rmail fcc-file)
10941 (rmail-output fcc-file 1 t t)))
10947 (defun gnus-inews-path ()
10948 "Return uucp path."
10949 (let ((login-name (gnus-inews-login-name)))
10950 (cond ((null gnus-use-generic-path)
10951 (concat (nth 1 gnus-select-method) "!" login-name))
10952 ((stringp gnus-use-generic-path)
10953 ;; Support GENERICPATH. Suggested by vixie@decwrl.dec.com.
10954 (concat gnus-use-generic-path "!" login-name))
10958 (defun gnus-inews-user-name ()
10959 "Return user's network address as \"NAME@DOMAIN (FULL-NAME)\"."
10960 (let ((full-name (gnus-inews-full-name)))
10961 (concat (if (or gnus-user-login-name gnus-use-generic-from
10962 gnus-local-domain (getenv "DOMAINNAME"))
10963 (concat (gnus-inews-login-name) "@"
10964 (gnus-inews-domain-name gnus-use-generic-from))
10966 ;; User's full name.
10967 (cond ((string-equal full-name "") "")
10968 ((string-equal full-name "&") ;Unix hack.
10969 (concat " (" (user-login-name) ")"))
10971 (concat " (" full-name ")"))))))
10973 (defun gnus-inews-login-name ()
10974 "Return login name."
10975 (or gnus-user-login-name (getenv "LOGNAME") (user-login-name)))
10977 (defun gnus-inews-full-name ()
10978 "Return full user name."
10979 (or gnus-user-full-name (getenv "NAME") (user-full-name)))
10981 (defun gnus-inews-domain-name (&optional genericfrom)
10982 "Return user's domain name.
10983 If optional argument GENERICFROM is a string, use it as the domain
10984 name; if it is non-nil, strip off local host name from the domain name.
10985 If the function `system-name' returns full internet name and the
10986 domain is undefined, the domain name is got from it."
10987 (if (or genericfrom gnus-local-domain (getenv "DOMAINNAME"))
10989 (or (if (stringp genericfrom) genericfrom)
10990 (getenv "DOMAINNAME")
10992 ;; Function `system-name' may return full internet name.
10993 ;; Suggested by Mike DeCorte <mrd@sun.soe.clarkson.edu>.
10994 (if (string-match "\\." (system-name))
10995 (substring (system-name) (match-end 0)))
10996 (read-string "Domain name (no host): ")))
10997 (host (or (if (string-match "\\." (system-name))
10998 (substring (system-name) 0 (match-beginning 0)))
11000 (if (string-equal "." (substring domain 0 1))
11001 (setq domain (substring domain 1)))
11002 ;; Support GENERICFROM as same as standard Bnews system.
11003 ;; Suggested by ohm@kaba.junet and vixie@decwrl.dec.com.
11004 (cond ((null genericfrom)
11005 (concat host "." domain))
11006 ;;((stringp genericfrom) genericfrom)
11008 (substring user-mail-address (1+ (string-match "@" user-mail-address)))))
11010 (defun gnus-inews-full-address ()
11011 (let ((domain (gnus-inews-domain-name))
11012 (system (system-name))
11013 (case-fold-search t))
11014 (if (string-match "\\." system) system
11015 (if (string-match (concat "^" (regexp-quote system)) domain) domain
11016 (concat system "." domain)))))
11018 (defun gnus-inews-message-id ()
11019 "Generate unique Message-ID for user."
11020 ;; Message-ID should not contain a slash and should be terminated by
11021 ;; a number. I don't know the reason why it is so.
11022 (concat "<" (gnus-inews-unique-id) "@" (gnus-inews-full-address) ">"))
11024 (defun gnus-inews-unique-id ()
11025 "Generate unique ID from user name and current time."
11026 (concat (downcase (gnus-inews-login-name))
11028 (lambda (num) (gnus-number-base-x num 3 31))
11029 (current-time) "")))
11031 (defun gnus-inews-date ()
11032 "Current time string."
11033 (timezone-make-date-arpa-standard (current-time-string)))
11035 (defun gnus-inews-organization ()
11036 "Return user's organization.
11037 The ORGANIZATION environment variable is used if defined.
11038 If not, the variable `gnus-local-organization' is used instead.
11039 If it is a function, the function will be called with the current
11040 newsgroup name as the argument.
11041 If this is a file name, the contents of this file will be used as the
11043 (let* ((organization
11044 (or (getenv "ORGANIZATION")
11045 (if gnus-local-organization
11046 (if (and (symbolp gnus-local-organization)
11047 (fboundp gnus-local-organization))
11048 (funcall gnus-local-organization gnus-newsgroup-name)
11049 gnus-local-organization))
11050 gnus-organization-file
11051 "~/.organization")))
11052 (and (stringp organization)
11053 (> (length organization) 0)
11054 (or (file-exists-p organization)
11055 (string-match " " organization)
11056 (not (string-match "^/[^/]+/" (expand-file-name organization))))
11058 (set-buffer (get-buffer-create " *Gnus organization*"))
11059 (buffer-disable-undo (current-buffer))
11061 (if (file-exists-p organization)
11062 (insert-file-contents organization)
11063 (insert organization))
11064 (goto-char (point-min))
11065 (while (re-search-forward " *\n *" nil t)
11066 (replace-match " "))
11067 (buffer-substring (point-min) (point-max))))))
11069 (defun gnus-inews-lines ()
11070 "Count the number of lines and return numeric string."
11074 (goto-char (point-min))
11075 (search-forward "\n\n" nil 'move)
11076 (int-to-string (count-lines (point) (point-max))))))
11080 ;;; Gnus Mail Functions
11083 (autoload 'news-mail-reply "rnewspost")
11084 (autoload 'news-mail-other-window "rnewspost")
11086 ;;; Mail reply commands of Gnus summary mode
11088 (defun gnus-summary-reply (yank)
11089 "Reply mail to news author.
11090 If prefix argument YANK is non-nil, original article is yanked automatically.
11091 Customize the variable gnus-mail-reply-method to use another mailer."
11093 ;; Bug fix by jbw@bigbird.bu.edu (Joe Wells)
11094 ;; Stripping headers should be specified with mail-yank-ignored-headers.
11095 (gnus-summary-select-article t)
11096 (setq gnus-winconf-post-news (current-window-configuration))
11097 (let ((gnus-newsgroup-name gnus-newsgroup-name))
11098 (bury-buffer gnus-article-buffer)
11099 (funcall gnus-mail-reply-method yank)))
11101 (defun gnus-summary-reply-with-original ()
11102 "Reply mail to news author with original article.
11103 Customize the variable gnus-mail-reply-method to use another mailer."
11105 (gnus-summary-reply t))
11107 (defun gnus-summary-mail-forward ()
11108 "Forward the current message to another user.
11109 Customize the variable gnus-mail-forward-method to use another mailer."
11111 (gnus-summary-select-article t)
11112 (setq gnus-winconf-post-news (current-window-configuration))
11113 (set-buffer gnus-article-buffer)
11114 (let ((gnus-newsgroup-name gnus-newsgroup-name))
11115 (funcall gnus-mail-forward-method)))
11117 (defun gnus-summary-mail-other-window ()
11118 "Compose mail in other window.
11119 Customize the variable `gnus-mail-other-window-method' to use another
11122 (setq gnus-winconf-post-news (current-window-configuration))
11123 (let ((gnus-newsgroup-name gnus-newsgroup-name))
11124 (funcall gnus-mail-other-window-method)))
11126 (defun gnus-mail-reply-using-mail (&optional yank to-address)
11128 (set-buffer gnus-summary-buffer)
11129 (let ((info (nth 2 (gnus-gethash gnus-newsgroup-name gnus-newsrc-hashtb)))
11130 (group (gnus-group-real-name gnus-newsgroup-name))
11131 (cur (cons (current-buffer) (cdr gnus-article-current)))
11132 from subject date to reply-to message-of
11133 references message-id sender follow-to cc)
11134 (set-buffer (get-buffer-create "*mail*"))
11136 (make-local-variable 'gnus-article-reply)
11137 (setq gnus-article-reply cur)
11138 (local-set-key "\C-c\C-c" 'gnus-mail-send-and-exit)
11139 (if (and (buffer-modified-p)
11140 (> (buffer-size) 0)
11141 (not (gnus-y-or-n-p
11142 "Unsent article being composed; erase it? ")))
11146 (set-buffer gnus-article-buffer)
11147 (let ((buffer-read-only nil))
11148 (goto-char (point-min))
11149 (narrow-to-region (point-min)
11150 (progn (search-forward "\n\n") (point)))
11151 (add-text-properties (point-min) (point-max) '(invisible nil)))
11152 (if (and (boundp 'gnus-reply-to-function)
11153 gnus-reply-to-function)
11156 (gnus-narrow-to-headers)
11157 (setq follow-to (funcall gnus-reply-to-function group)))))
11158 (setq from (mail-fetch-field "from"))
11159 (setq date (mail-fetch-field "date"))
11162 (string-match " *at \\| *@ \\| *(\\| *<" from)))
11164 (concat (if stop-pos (substring from 0 stop-pos) from)
11165 "'s message of " date))))
11166 (setq sender (mail-fetch-field "sender"))
11167 (setq subject (or (mail-fetch-field "subject")
11169 (or (string-match "^[Rr][Ee]:" subject)
11170 (setq subject (concat "Re: " subject)))
11171 (setq cc (mail-fetch-field "cc"))
11172 (setq reply-to (mail-fetch-field "reply-to"))
11173 (setq references (mail-fetch-field "references"))
11174 (setq message-id (mail-fetch-field "message-id"))
11176 (setq news-reply-yank-from from)
11177 (setq news-reply-yank-message-id message-id)
11178 (mail-setup (or to-address follow-to reply-to from sender "")
11179 subject message-of nil gnus-article-buffer nil)
11180 ;; Fold long references line to follow RFC1036.
11181 (mail-position-on-field "References")
11182 (let ((begin (- (point) (length "References: ")))
11184 (fill-prefix "\t"))
11185 (if references (insert references))
11186 (if (and references message-id) (insert " "))
11187 (if message-id (insert message-id))
11188 ;; The region must end with a newline to fill the region
11189 ;; without inserting extra newline.
11190 (fill-region-as-paragraph begin (1+ (point))))
11191 (goto-char (point-min))
11192 (search-forward (concat "\n" mail-header-separator "\n"))
11194 (let ((last (point)))
11195 (run-hooks 'news-reply-header-hook)
11196 (mail-yank-original nil)
11197 (goto-char last))))
11199 (let ((mail (current-buffer)))
11200 (switch-to-buffer gnus-article-buffer)
11201 (delete-other-windows)
11202 (switch-to-buffer-other-window mail))
11203 (delete-other-windows)
11204 (switch-to-buffer (current-buffer))))))
11206 (defun gnus-mail-yank-original ()
11208 (run-hooks 'news-reply-header-hook)
11209 (mail-yank-original nil))
11211 (defun gnus-mail-send-and-exit ()
11213 (let ((cbuf (current-buffer)))
11214 (mail-send-and-exit nil)
11215 (if (get-buffer gnus-group-buffer)
11219 (let ((reply gnus-article-reply))
11221 (get-buffer (car reply))
11222 (buffer-name (car reply)))
11224 (set-buffer (car reply))
11226 (gnus-summary-mark-article-as-replied
11228 (and gnus-winconf-post-news
11229 (set-window-configuration gnus-winconf-post-news))
11230 (setq gnus-winconf-post-news nil)))))
11232 (defun gnus-mail-forward-using-mail ()
11233 "Forward the current message to another user using mail."
11234 ;; This is almost a carbon copy of rmail-forward in rmail.el.
11235 (let ((forward-buffer (current-buffer))
11237 (concat "[" gnus-newsgroup-name "] "
11238 (or (gnus-fetch-field "Subject") "")))
11240 ;; If only one window, use it for the mail buffer.
11241 ;; Otherwise, use another window for the mail buffer
11242 ;; so that the Rmail buffer remains visible
11243 ;; and sending the mail will get back to it.
11244 (if (if (one-window-p t)
11245 (mail nil nil subject)
11246 (mail-other-window nil nil subject))
11248 (setq beg (goto-char (point-max)))
11249 (insert "------- Start of forwarded message -------\n")
11250 (insert-buffer forward-buffer)
11251 (goto-char (point-max))
11252 (insert "------- End of forwarded message -------\n")
11253 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
11255 (while (setq beg (next-single-property-change (point) 'invisible))
11257 (delete-region beg (or (next-single-property-change
11258 (point) 'invisible)
11260 ;; You have a chance to arrange the message.
11261 (run-hooks 'gnus-mail-forward-hook)))))
11263 (defun gnus-mail-other-window-using-mail ()
11264 "Compose mail other window using mail."
11265 (news-mail-other-window)
11266 (gnus-overload-functions))
11273 (defvar gnus-dribble-ignore nil)
11275 (defun gnus-dribble-file-name ()
11276 (concat gnus-startup-file "-dribble"))
11278 (defun gnus-dribble-open ()
11281 (setq gnus-dribble-buffer (find-file-noselect (gnus-dribble-file-name))))
11282 (buffer-disable-undo (current-buffer))
11283 (bury-buffer gnus-dribble-buffer)
11285 (goto-char (point-max))))
11287 (defun gnus-dribble-enter (string)
11288 (if (and (not gnus-dribble-ignore)
11289 gnus-dribble-buffer
11290 (buffer-name gnus-dribble-buffer))
11291 (let ((obuf (current-buffer)))
11292 (set-buffer gnus-dribble-buffer)
11293 (insert string "\n")
11294 (set-window-point (get-buffer-window (current-buffer)) (point-max))
11295 (set-buffer obuf))))
11297 (defun gnus-dribble-read-file ()
11298 (let ((dribble-file (gnus-dribble-file-name)))
11300 (set-buffer (setq gnus-dribble-buffer
11302 (file-name-nondirectory dribble-file))))
11303 (gnus-add-current-to-buffer-list)
11305 (set-visited-file-name dribble-file)
11306 (buffer-disable-undo (current-buffer))
11307 (bury-buffer (current-buffer))
11308 (set-buffer-modified-p nil)
11309 (let ((auto (make-auto-save-file-name))
11310 (gnus-dribble-ignore t))
11311 (if (or (file-exists-p auto) (file-exists-p dribble-file))
11313 (if (file-newer-than-file-p auto dribble-file)
11314 (setq dribble-file auto))
11315 (insert-file-contents dribble-file)
11316 (if (not (zerop (buffer-size)))
11317 (set-buffer-modified-p t))
11319 "Auto-save file exists. Do you want to read it? ")
11321 (message "Reading %s..." dribble-file)
11322 (eval-current-buffer)
11323 (message "Reading %s...done" dribble-file)))))))))
11325 (defun gnus-dribble-delete-file ()
11326 (if (file-exists-p (gnus-dribble-file-name))
11327 (delete-file (gnus-dribble-file-name)))
11328 (if gnus-dribble-buffer
11330 (set-buffer gnus-dribble-buffer)
11331 (let ((auto (make-auto-save-file-name)))
11332 (if (file-exists-p auto)
11333 (delete-file auto))
11335 (set-buffer-modified-p nil)))))
11337 (defun gnus-dribble-save ()
11338 (if (and gnus-dribble-buffer
11339 (buffer-name gnus-dribble-buffer))
11341 (set-buffer gnus-dribble-buffer)
11344 (defun gnus-dribble-clear ()
11346 (if (and gnus-dribble-buffer
11347 (buffer-name (get-buffer gnus-dribble-buffer)))
11349 (set-buffer gnus-dribble-buffer)
11351 (set-buffer-modified-p nil)
11352 (setq buffer-saved-size (buffer-size))))))
11355 ;;; Server Communication
11358 (defun gnus-start-news-server (&optional confirm)
11359 "Open a method for getting news.
11360 If CONFIRM is non-nil, the user will be asked for an NNTP server."
11362 (if gnus-current-select-method
11363 ;; Stream is already opened.
11365 ;; Open NNTP server.
11366 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
11369 ;; Read server name with completion.
11370 (setq gnus-nntp-server
11371 (completing-read "NNTP server: "
11372 (mapcar (lambda (server) (list server))
11373 (cons (list gnus-nntp-server)
11374 gnus-secondary-servers))
11375 nil nil gnus-nntp-server))))
11377 (if (and gnus-nntp-server
11378 (stringp gnus-nntp-server)
11379 (not (string= gnus-nntp-server "")))
11380 (setq gnus-select-method
11381 (cond ((or (string= gnus-nntp-server "")
11382 (string= gnus-nntp-server "::"))
11383 (list 'nnspool (system-name)))
11384 ((string-match ":" gnus-nntp-server)
11385 (list 'nnmh gnus-nntp-server))
11387 (list 'nntp gnus-nntp-server)))))
11389 (setq how (car gnus-select-method))
11390 (setq where (car (cdr gnus-select-method)))
11391 (cond ((eq how 'nnspool)
11393 (message "Looking up local news spool..."))
11396 (message "Looking up mh spool..."))
11399 (setq gnus-current-select-method gnus-select-method)
11400 (run-hooks 'gnus-open-server-hook)
11402 ;; gnus-open-server-hook might have opened it
11403 (gnus-server-opened gnus-select-method)
11404 (gnus-open-server gnus-select-method)
11405 (error "%s" (gnus-nntp-message
11406 (format "Cannot open NNTP server on %s"
11408 gnus-select-method)))
11410 (defun gnus-check-news-server (method)
11411 "If the news server is down, start it up again."
11412 (let ((method (if method method gnus-select-method)))
11413 (if (gnus-server-opened method)
11414 ;; Stream is already opened.
11417 (message "Opening server %s on %s..." (car method) (nth 1 method))
11418 (run-hooks 'gnus-open-server-hook)
11419 (or (gnus-server-opened method)
11420 (gnus-open-server method))
11423 (defun gnus-nntp-message (&optional message)
11424 "Check the status of the NNTP server.
11425 If the status of the server is clear and MESSAGE is non-nil, MESSAGE
11426 is returned insted of the status string."
11427 (let ((status (gnus-status-message (gnus-find-method-for-group
11428 gnus-newsgroup-name)))
11429 (message (or message "")))
11430 (if (and (stringp status) (> (length status) 0))
11433 (defun gnus-get-function (method function)
11434 (let ((func (intern (format "%s-%s" (car method) function))))
11435 (if (not (fboundp func))
11437 (require (car method))
11438 (if (not (fboundp func))
11439 (error "No such function: %s" func))))
11442 ;; Specifying port number suggested by Stephane Laveau <laveau@corse.inria.fr>.
11443 (defun gnus-open-server (method)
11444 (apply (gnus-get-function method 'open-server) (cdr method)))
11446 (defun gnus-close-server (method)
11447 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
11449 (defun gnus-request-list (method)
11450 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
11452 (defun gnus-request-list-newsgroups (method)
11453 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
11455 (defun gnus-request-newgroups (date method)
11456 (funcall (gnus-get-function method 'request-newgroups)
11457 date (nth 1 method)))
11459 (defun gnus-server-opened (method)
11460 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
11462 (defun gnus-status-message (method)
11463 (funcall (gnus-get-function method 'status-message) (nth 1 method)))
11465 (defun gnus-request-group (group &optional dont-check)
11466 (let ((method (gnus-find-method-for-group group)))
11467 (funcall (gnus-get-function method 'request-group)
11468 (gnus-group-real-name group) (nth 1 method) dont-check)))
11470 (defun gnus-close-group (group)
11471 (let ((method (gnus-find-method-for-group group)))
11472 (funcall (gnus-get-function method 'close-group)
11473 (gnus-group-real-name group) (nth 1 method))))
11475 (defun gnus-retrieve-headers (articles group)
11476 (let ((method (gnus-find-method-for-group group)))
11477 (funcall (gnus-get-function method 'retrieve-headers)
11478 articles (gnus-group-real-name group) (nth 1 method))))
11480 (defun gnus-request-article (article group buffer)
11481 (let ((method (gnus-find-method-for-group group)))
11482 (funcall (gnus-get-function method 'request-article)
11483 article (gnus-group-real-name group) (nth 1 method) buffer)))
11485 (defun gnus-request-head (article group)
11486 (let ((method (gnus-find-method-for-group group)))
11487 (funcall (gnus-get-function method 'request-head)
11488 article (gnus-group-real-name group) (nth 1 method))))
11490 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
11491 (defun gnus-request-post-buffer (post header artbuf)
11492 (let* ((group gnus-newsgroup-name)
11493 (info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
11495 (if (and gnus-post-method
11496 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
11498 (format "%s" (car (gnus-find-method-for-group
11499 gnus-newsgroup-name)))
11500 gnus-valid-select-methods)))
11502 (gnus-find-method-for-group gnus-newsgroup-name))))
11503 (funcall (gnus-get-function method 'request-post-buffer)
11504 post header artbuf (gnus-group-real-name group) info)))
11506 (defun gnus-request-post (method &optional force)
11507 (and (not force) gnus-post-method
11508 (memq 'post (assoc (format "%s" (car method))
11509 gnus-valid-select-methods))
11510 (setq method gnus-post-method))
11511 (funcall (gnus-get-function method 'request-post)
11514 (defun gnus-request-expire-articles (articles group &optional force)
11515 (let ((method (gnus-find-method-for-group group)))
11516 (funcall (gnus-get-function method 'request-expire-articles)
11517 articles (gnus-group-real-name group) (nth 1 method)
11520 (defun gnus-request-move-article (article group server accept-function)
11521 (let ((method (gnus-find-method-for-group group)))
11522 (funcall (gnus-get-function method 'request-move-article)
11523 article (gnus-group-real-name group)
11524 (nth 1 method) accept-function)))
11526 (defun gnus-request-accept-article (group)
11527 (let ((func (if (symbolp group) group
11528 (car (gnus-find-method-for-group group)))))
11529 (funcall (intern (format "%s-request-accept-article" func))
11530 (if (stringp group) (gnus-group-real-name group)
11533 (defun gnus-request-replace-article (article group buffer)
11534 (let ((func (car (gnus-find-method-for-group group))))
11535 (funcall (intern (format "%s-request-replace-article" func))
11536 article (gnus-group-real-name group) buffer)))
11538 (defun gnus-find-method-for-group (group)
11539 (let ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
11541 (not (nth 4 info)))
11545 (defun gnus-check-backend-function (func group)
11546 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
11548 (fboundp (intern (format "%s-%s" method func)))))
11550 (defun gnus-methods-using (method)
11551 (let ((valids gnus-valid-select-methods)
11554 (if (memq method (car valids))
11555 (setq outs (cons (car valids) outs)))
11556 (setq valids (cdr valids)))
11560 ;;; Active & Newsrc File Handling
11563 ;; Newsrc related functions.
11564 ;; Gnus internal format of gnus-newsrc-assoc:
11565 ;; (("alt.general" 3 (1 . 1))
11566 ;; ("alt.misc" 3 ((1 . 10) (12 . 15)))
11567 ;; ("alt.test" 7 (1 . 99) (45 57 93)) ...)
11568 ;; The first item is the group name; the second is the subscription
11569 ;; level; the third is either a range of a list of ranges of read
11570 ;; articles, the optional fourth element is a list of marked articles,
11571 ;; the optional fifth element is the select method.
11573 ;; Gnus internal format of gnus-newsrc-hashtb:
11574 ;; (95 ("alt.general" 3 (1 . 1)) ("alt.misc" 3 ((1 . 10) (12 . 15))) ...)
11575 ;; This is the entry for "alt.misc". The first element is the number
11576 ;; of unread articles in "alt.misc". The cdr of this entry is the
11577 ;; element *before* "alt.misc" in gnus-newsrc-assoc, which makes is
11578 ;; trivial to remove or add new elements into gnus-newsrc-assoc
11579 ;; without scanning the entire list. So, to get the actual information
11580 ;; of "alt.misc", you'd say something like
11581 ;; (nth 2 (gnus-gethash "alt.misc" gnus-newsrc-hashtb))
11583 ;; Gnus internal format of gnus-active-hashtb:
11587 ;; The only element in each entry in this hash table is a range of
11588 ;; (possibly) available articles. (Articles in this range may have
11589 ;; been expired or cancelled.)
11591 ;; Gnus internal format of gnus-killed-list and gnus-zombie-list:
11592 ;; ("alt.misc" "alt.test" "alt.general" ...)
11594 (defun gnus-setup-news (&optional rawfile level)
11595 "Setup news information.
11596 If RAWFILE is non-nil, the .newsrc file will also be read.
11597 If LEVEL is non-nil, the news will be set up at level LEVEL."
11598 (let ((init (not (and gnus-newsrc-assoc gnus-active-hashtb (not rawfile)))))
11599 ;; Clear some variables to re-initialize news information.
11600 (if init (setq gnus-newsrc-assoc nil gnus-active-hashtb nil))
11601 ;; Read the active file and create `gnus-active-hashtb'.
11602 ;; If `gnus-read-active-file' is nil, then we just create an empty
11603 ;; hash table. The partial filling out of the hash table will be
11604 ;; done in `gnus-get-unread-articles'.
11605 (if (and gnus-read-active-file (not level))
11606 (gnus-read-active-file)
11607 (setq gnus-active-hashtb (make-vector 4095 0)))
11609 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
11610 (if init (gnus-read-newsrc-file rawfile))
11611 ;; Find the number of unread articles in each non-dead group.
11612 (gnus-get-unread-articles (or level 6))
11613 ;; Find new newsgroups and treat them.
11614 (if (and init gnus-check-new-newsgroups gnus-read-active-file (not level))
11615 (gnus-find-new-newsgroups))
11616 (if (and init gnus-check-bogus-newsgroups
11617 gnus-read-active-file (not level))
11618 (gnus-check-bogus-newsgroups))))
11620 (defun gnus-find-new-newsgroups ()
11621 "Search for new newsgroups and add them.
11622 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
11623 The `-n' option line from .newsrc is respected."
11625 (or (gnus-check-first-time-used)
11626 (if (or (consp gnus-check-new-newsgroups)
11627 (eq gnus-check-new-newsgroups 'ask-server))
11628 (gnus-ask-server-for-new-groups)
11630 group new-newsgroups)
11631 (or gnus-have-read-active-file (gnus-read-active-file))
11632 (setq gnus-newsrc-last-checked-date (current-time-string))
11633 (if (not gnus-killed-hashtb) (gnus-make-hashtable-from-killed))
11634 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
11635 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
11638 (setq group (symbol-name sym))
11639 (if (or (gnus-gethash group gnus-killed-hashtb)
11640 (gnus-gethash group gnus-newsrc-hashtb))
11642 (if (and gnus-newsrc-options-n-yes
11643 (string-match gnus-newsrc-options-n-yes group))
11645 (setq groups (1+ groups))
11646 (gnus-sethash group group gnus-killed-hashtb)
11647 (funcall gnus-subscribe-options-newsgroup-method group))
11648 (if (or (null gnus-newsrc-options-n-no)
11649 (not (string-match gnus-newsrc-options-n-no group)))
11652 (setq groups (1+ groups))
11653 (gnus-sethash group group gnus-killed-hashtb)
11654 (if gnus-subscribe-hierarchical-interactive
11655 (setq new-newsgroups (cons group new-newsgroups))
11656 (funcall gnus-subscribe-newsgroup-method group)))))))
11657 gnus-active-hashtb)
11659 (gnus-subscribe-hierarchical-interactive new-newsgroups))
11660 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
11662 (message "%d new newsgroup%s arrived."
11663 groups (if (> groups 1) "s have" " has")))))))
11665 (defun gnus-ask-server-for-new-groups ()
11666 (let* ((date (timezone-parse-date (or gnus-newsrc-last-checked-date
11667 (current-time-string))))
11668 (methods (cons gnus-select-method
11670 (and (consp gnus-check-new-newsgroups)
11671 gnus-check-new-newsgroups)
11672 gnus-secondary-select-methods)))
11674 (format "%s%02d%02d %s%s%s"
11675 (substring (aref date 0) 2) (string-to-int (aref date 1))
11676 (string-to-int (aref date 2)) (substring (aref date 3) 0 2)
11677 (substring (aref date 3) 3 5) (substring (aref date 3) 6 8)))
11679 (new-date (current-time-string))
11680 hashtb group new-newsgroups)
11681 ;; Go thorugh both primary and secondary select methods and
11682 ;; request new newsgroups.
11684 (if (gnus-request-newgroups time-string (car methods))
11686 (or hashtb (setq hashtb (gnus-make-hashtable
11687 (count-lines (point-min) (point-max)))))
11688 (set-buffer nntp-server-buffer)
11689 ;; Enter all the new groups in a hashtable.
11690 (gnus-active-to-gnus-format (car methods) hashtb)))
11691 (setq methods (cdr methods)))
11692 ;; Now all new groups from all select methods are in `hashtb'.
11694 (lambda (group-sym)
11695 (setq group (symbol-name group-sym))
11696 (if (gnus-gethash group gnus-active-hashtb)
11698 (gnus-sethash group (symbol-value group-sym) gnus-active-hashtb)
11699 (if (and gnus-newsrc-options-n-yes
11700 (string-match gnus-newsrc-options-n-yes group))
11702 (setq groups (1+ groups))
11703 (funcall gnus-subscribe-options-newsgroup-method group))
11704 (if (or (null gnus-newsrc-options-n-no)
11705 (not (string-match gnus-newsrc-options-n-no group)))
11708 (setq groups (1+ groups))
11709 (if gnus-subscribe-hierarchical-interactive
11710 (setq new-newsgroups (cons group new-newsgroups))
11711 (funcall gnus-subscribe-newsgroup-method group)))))))
11714 (gnus-subscribe-hierarchical-interactive new-newsgroups))
11715 (setq gnus-newsrc-last-checked-date new-date)
11716 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
11718 (message "%d new newsgroup%s arrived."
11719 groups (if (> groups 1) "s have" " has")))))
11721 (defun gnus-check-first-time-used ()
11722 (if (or (file-exists-p gnus-startup-file)
11723 (file-exists-p (concat gnus-startup-file ".el"))
11724 (file-exists-p (concat gnus-startup-file ".eld")))
11726 (message "First time user; subscribing you to default groups")
11727 (or gnus-have-read-active-file (gnus-read-active-file))
11728 (setq gnus-newsrc-last-checked-date (current-time-string))
11729 (let ((groups gnus-default-subscribed-newsgroups)
11733 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
11736 (setq group (symbol-name sym))
11737 (if (and gnus-newsrc-options-n-yes
11738 (string-match gnus-newsrc-options-n-yes group))
11739 (funcall gnus-subscribe-options-newsgroup-method group)
11740 (and (or (null gnus-newsrc-options-n-no)
11741 (not (string-match gnus-newsrc-options-n-no group)))
11742 (setq gnus-killed-list (cons group gnus-killed-list)))))
11743 gnus-active-hashtb)
11745 (if (gnus-gethash (car groups) gnus-active-hashtb)
11746 (gnus-group-change-level (car groups) 3 9))
11747 (setq groups (cdr groups)))
11748 (gnus-group-make-doc-group)
11750 (substitute-command-keys "\\<gnus-group-mode-map>\\[gnus-group-list-killed] to list killed groups"))))))
11752 ;; `gnus-group-change-level' is the fundamental function for changing
11753 ;; subscription levels of newsgroups. This might mean just changing
11754 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
11755 ;; again, which subscribes/unsubscribes a group, which is equally
11756 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
11757 ;; from 8-9 to 1-7 means that you remove the group from the list of
11758 ;; killed (or zombie) groups and add them to the (kinda) subscribed
11759 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
11760 ;; which is trivial.
11761 ;; ENTRY can either be a string (newsgroup name) or a list (if
11762 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
11763 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
11765 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
11766 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
11768 (defun gnus-group-change-level (entry level &optional oldlevel
11769 previous fromkilled)
11770 (let (group info active num)
11771 ;; Glean what info we can from the arguments
11773 (if fromkilled (setq group (nth 1 entry))
11774 (setq group (car (nth 2 entry))))
11775 (setq group entry))
11776 (if (and (stringp entry)
11779 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
11780 (if (and (not oldlevel)
11782 (setq oldlevel (car (cdr (nth 2 entry)))))
11783 (if (stringp previous)
11784 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
11786 (gnus-dribble-enter
11787 (format "(gnus-group-change-level %S %S %S %S %S)"
11788 group level oldlevel (car (nth 2 previous)) fromkilled))
11790 ;; Then we remove the newgroup from any old structures, if needed.
11791 ;; If the group was killed, we remove it from the killed or zombie
11792 ;; list. If not, and it is in fact going to be killed, we remove
11793 ;; it from the newsrc hash table and assoc.
11794 (cond ((>= oldlevel 8)
11796 (setq gnus-zombie-list (delete group gnus-zombie-list))
11797 (setq gnus-killed-list (delete group gnus-killed-list))))
11801 (gnus-sethash (car (nth 2 entry))
11802 nil gnus-newsrc-hashtb)
11804 (setcdr (gnus-gethash (car (nth 3 entry))
11805 gnus-newsrc-hashtb)
11807 (setcdr (cdr entry) (cdr (cdr (cdr entry))))))))
11809 ;; Finally we enter (if needed) the list where it is supposed to
11810 ;; go, and change the subscription level. If it is to be killed,
11811 ;; we enter it into the killed or zombie list.
11812 (cond ((>= level 8)
11814 (setq gnus-zombie-list (cons group gnus-zombie-list))
11815 (setq gnus-killed-list (cons group gnus-killed-list))))
11817 ;; If the list is to be entered into the newsrc assoc, and
11818 ;; it was killed, we have to create an entry in the newsrc
11819 ;; hashtb format and fix the pointers in the newsrc assoc.
11820 (if (>= oldlevel 8)
11824 (setq info (cdr entry))
11825 (setq num (car entry)))
11826 (setq active (gnus-gethash group gnus-active-hashtb))
11827 (setq num (- (1+ (cdr active)) (car active)))
11828 ;; Check whether the group is foreign. If so, the
11829 ;; foreign select method has to be entered into the
11831 (let ((method (gnus-group-method-name group)))
11832 (if (eq method gnus-select-method)
11833 (setq info (list group level
11834 (cons 1 (1- (car active)))))
11835 (setq info (list group level (cons 1 (1- (car active)))
11837 (setq entry (cons info (if previous (cdr (cdr previous))
11838 (cdr gnus-newsrc-assoc))))
11839 (setcdr (if previous (cdr previous) gnus-newsrc-assoc)
11841 (gnus-sethash group (cons num (if previous (cdr previous)
11842 gnus-newsrc-assoc))
11843 gnus-newsrc-hashtb)
11845 (setcdr (gnus-gethash (car (car (cdr entry)))
11846 gnus-newsrc-hashtb)
11848 ;; It was alive, and it is going to stay alive, so we
11849 ;; just change the level and don't change any pointers or
11850 ;; hash table entries.
11851 (setcar (cdr (car (cdr (cdr entry)))) level))))))
11853 (defun gnus-kill-newsgroup (newsgroup)
11854 "Obsolete function. Kills a newsgroup."
11855 (gnus-group-change-level (gnus-gethash newsgroup gnus-newsrc-hashtb) 9))
11857 (defun gnus-check-bogus-newsgroups (&optional confirm)
11858 "Remove bogus newsgroups.
11859 If CONFIRM is non-nil, the user has to confirm the deletion of every
11861 (let ((newsrc (cdr gnus-newsrc-assoc))
11863 (message "Checking bogus newsgroups...")
11864 (or gnus-have-read-active-file (gnus-read-active-file))
11865 ;; Find all bogus newsgroup that are subscribed.
11867 (setq group (car (car newsrc)))
11868 (if (or (gnus-gethash group gnus-active-hashtb)
11869 (nth 4 (car newsrc))
11871 (not (gnus-y-or-n-p
11872 (format "Remove bogus newsgroup: %s " group)))))
11873 ;; Active newsgroup.
11875 ;; Found a bogus newsgroup.
11876 (setq bogus (cons group bogus)))
11877 (setq newsrc (cdr newsrc)))
11878 ;; Remove all bogus subscribed groups by first killing them, and
11879 ;; then removing them from the list of killed groups.
11881 (gnus-group-change-level
11882 (gnus-gethash (car bogus) gnus-newsrc-hashtb) 9)
11883 (setq gnus-killed-list (delete (car bogus) gnus-killed-list))
11884 (setq bogus (cdr bogus)))
11885 ;; Then we remove all bogus groups from the list of killed and
11886 ;; zombie groups. They are are removed without confirmation.
11887 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
11890 (setq killed (symbol-value (car dead-lists)))
11892 (setq group (car killed))
11893 (or (gnus-gethash group gnus-active-hashtb)
11894 ;; The group is bogus.
11895 (set (car dead-lists)
11896 (delete group (symbol-value (car dead-lists)))))
11897 (setq killed (cdr killed)))
11898 (setq dead-lists (cdr dead-lists))))
11899 ;; While we're at it, we check the killed list for duplicates.
11900 ;; This has nothing to do with bogosity, but it's a convenient
11901 ;; place to put the check.
11902 (let ((killed gnus-killed-list))
11904 (message "%d" (length killed))
11905 (setcdr killed (delete (car killed) (cdr killed)))
11906 (setq killed (cdr killed))))
11907 (message "Checking bogus newsgroups... done")))
11909 ;; Go though `gnus-newsrc-assoc' and compare with `gnus-active-hashtb'
11910 ;; and compute how many unread articles there are in each group.
11911 (defun gnus-get-unread-articles (&optional level)
11912 (let ((newsrc (cdr gnus-newsrc-assoc))
11913 (level (or level 6))
11915 (message "Checking new news...")
11917 (setq info (car newsrc))
11918 (setq group (car info))
11919 (setq active (gnus-gethash group gnus-active-hashtb))
11921 ;; Check newsgroups. If the user doesn't want to check them, or
11922 ;; they can't be checked (for instance, if the news server can't
11923 ;; be reached) we just set the number of unread articles in this
11924 ;; newsgroup to t. This means that Gnus thinks that there are
11925 ;; unread articles, but it has no idea how many.
11927 (if (or (and gnus-activate-foreign-newsgroups
11928 (not (numberp gnus-activate-foreign-newsgroups)))
11929 (and (numberp gnus-activate-foreign-newsgroups)
11930 (<= (nth 1 info) gnus-activate-foreign-newsgroups)
11931 (<= (nth 1 info) level)))
11932 (or (eq (car (nth 4 info)) 'nnvirtual)
11933 (setq active (gnus-activate-newsgroup (car info)))))
11934 (if (and (not gnus-read-active-file)
11935 (<= (nth 1 info) level))
11937 (setq active (gnus-activate-newsgroup (car info))))))
11939 (or active (progn (gnus-sethash group nil gnus-active-hashtb)
11940 (setcar (gnus-gethash group gnus-newsrc-hashtb) t)))
11941 (and active (gnus-get-unread-articles-in-group info active))
11942 (setq newsrc (cdr newsrc)))
11943 (message "Checking new news... done")))
11945 ;; Create a hash table out of the newsrc alist. The `car's of the
11946 ;; alist elements are used as keys.
11947 (defun gnus-make-hashtable-from-newsrc-alist ()
11948 (let ((alist gnus-newsrc-assoc)
11950 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
11952 (setq prev (setq gnus-newsrc-assoc
11953 (cons (list "dummy.group" 0 (cons 0 0)) alist))))
11955 (gnus-sethash (car (car alist)) (cons nil prev) gnus-newsrc-hashtb)
11957 (setq alist (cdr alist)))))
11959 (defun gnus-make-hashtable-from-killed ()
11960 "Create a hash table from the killed and zombie lists."
11961 (let ((lists '(gnus-killed-list gnus-zombie-list))
11963 (setq gnus-killed-hashtb
11964 (gnus-make-hashtable
11965 (+ (length gnus-killed-list) (length gnus-zombie-list))))
11967 (setq list (symbol-value (car lists)))
11968 (setq lists (cdr lists))
11970 (gnus-sethash (car list) (car list) gnus-killed-hashtb)
11971 (setq list (cdr list))))))
11973 (defun gnus-get-unread-articles-in-group (info active)
11974 (let* ((range (nth 2 info))
11976 (marked (nth 3 info))
11977 srange lowest group)
11978 ;; Modify the list of read articles according to what articles
11979 ;; are available; then tally the unread articles and add the
11980 ;; number to the group hash table entry.
11981 (cond ((zerop (cdr active))
11984 (setq num (- (1+ (cdr active)) (car active))))
11985 ((atom (car range))
11986 ;; Fix a single (num . num) range according to the
11987 ;; active hash table.
11988 (if (< (cdr range) (car active)) (setcdr range (car active)))
11989 ;; Compute number of unread articles.
11990 (setq num (max 0 (- (cdr active)
11991 (- (1+ (cdr range)) (car range))))))
11993 ;; The read list is a list of ranges. Fix them according to
11994 ;; the active hash table.
11995 (setq srange range)
11996 (setq lowest (1- (car active)))
11997 (while (and (< (cdr (car srange)) lowest))
11998 (if (and (cdr srange)
11999 (<= (cdr (car srange)) (1+ lowest)))
12001 (setcdr (car srange) (cdr (car (cdr srange))))
12002 (setcdr srange (cdr (cdr srange))))
12003 (setcdr (car srange) lowest)))
12004 ;; Compute the number of unread articles.
12006 (setq num (+ num (- (1+ (cdr (car range)))
12007 (car (car range)))))
12008 (setq range (cdr range)))
12009 (setq num (max 0 (- (cdr active) num)))))
12011 (setcar (gnus-gethash (car info) gnus-newsrc-hashtb)
12012 (max 0 (- num (length (cdr (assq 'tick marked)))
12013 (length (cdr (assq 'dormant marked)))))))
12016 (defun gnus-activate-newsgroup (group)
12017 (let ((method (gnus-find-method-for-group group))
12019 (or (gnus-server-opened method) (gnus-open-server method))
12020 (and (gnus-request-group group)
12022 (set-buffer nntp-server-buffer)
12024 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
12026 (goto-char (match-beginning 1))
12028 group (setq active (cons (read (current-buffer))
12029 (read (current-buffer))))
12030 gnus-active-hashtb)))))
12033 (defun gnus-update-read-articles
12034 (group unread unselected ticked &optional domarks replied expirable killed
12035 dormant bookmark score)
12036 "Update the list of read and ticked articles in GROUP using the
12037 UNREAD and TICKED lists.
12038 Note: UNSELECTED has to be sorted over `<'.
12039 Returns whether the updating was successful."
12040 (let* ((active (gnus-gethash group gnus-active-hashtb))
12041 (entry (gnus-gethash group gnus-newsrc-hashtb))
12042 (number (car entry))
12043 (info (nth 2 entry))
12044 (marked (nth 3 info))
12046 (unread (sort (copy-sequence unread) (function <)))
12048 (if (or (not info) (not active))
12049 ;; There is no info on this group if it was, in fact,
12050 ;; killed. Gnus stores no information on killed groups, so
12051 ;; there's nothing to be done.
12052 ;; One could store the information somewhere temporarily,
12053 ;; perhaps... Hmmm...
12055 ;; Remove any negative articles numbers.
12056 (while (and unread (< (car unread) 0))
12057 (setq unread (cdr unread)))
12058 (if (not (and (numberp number) (zerop number)))
12059 (setq unread (nconc unselected unread)))
12060 ;; Set the number of unread articles in gnus-newsrc-hashtb.
12061 (setcar entry (max 0 (- (length unread) (length ticked)
12062 (length dormant))))
12063 ;; Compute the ranges of read articles by looking at the list of
12064 ;; unread articles.
12066 (if (/= (car unread) prev)
12067 (setq read (cons (cons prev (1- (car unread))) read)))
12068 (setq prev (1+ (car unread)))
12069 (setq unread (cdr unread)))
12070 (if (<= prev (cdr active))
12071 (setq read (cons (cons prev (cdr active)) read)))
12072 ;; Enter this list into the group info.
12073 (setcar (cdr (cdr info))
12074 (if (> (length read) 1) (nreverse read) (car read)))
12075 ;; Enter the list of ticked articles.
12076 (gnus-set-marked-articles
12078 (if domarks replied (cdr (assq 'reply marked)))
12079 (if domarks expirable (cdr (assq 'expire marked)))
12080 (if domarks killed (cdr (assq 'killed marked)))
12081 (if domarks dormant (cdr (assq 'dormant marked)))
12082 (if domarks bookmark (cdr (assq 'bookmark marked)))
12083 (if domarks score (cdr (assq 'score marked))))
12086 (defun gnus-make-articles-unread (group articles)
12087 "Mark ARTICLES in GROUP as unread."
12088 (let ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
12089 (setcar (nthcdr 2 info)
12090 (gnus-remove-from-range (nth 2 info) articles))
12091 (gnus-group-update-group group t)))
12093 (defun gnus-read-active-file ()
12094 "Get active file from NNTP server."
12095 (gnus-group-set-mode-line)
12096 (let ((methods (cons gnus-select-method gnus-secondary-select-methods)))
12097 (setq gnus-have-read-active-file nil)
12099 (let* ((where (nth 1 (car methods)))
12100 (mesg (format "Reading active file%s via %s..."
12101 (if (and where (not (zerop (length where))))
12102 (concat " from " where) "")
12103 (car (car methods)))))
12105 (if (gnus-request-list (car methods)) ; Get active
12107 (set-buffer nntp-server-buffer)
12108 (gnus-active-to-gnus-format
12109 (and gnus-have-read-active-file (car methods)))
12110 (setq gnus-have-read-active-file t)
12111 (message "%s...done" mesg))
12112 (message "Cannot read active file from %s server."
12113 (car (car methods)))
12115 (setq methods (cdr methods)))))
12117 ;; rewritten by jwz based on ideas from Rick Sladkey <jrs@world.std.com>
12118 ;; Further rewrites by lmi.
12119 (defun gnus-active-to-gnus-format (method &optional hashtb)
12120 "Convert active file format to internal format.
12121 Lines matching `gnus-ignored-newsgroups' are ignored."
12122 (let ((cur (current-buffer))
12126 (setq gnus-active-hashtb
12127 (gnus-make-hashtable
12128 (count-lines (point-min) (point-max))))))))
12129 ;; Delete unnecessary lines.
12130 (goto-char (point-min))
12131 (delete-matching-lines gnus-ignored-newsgroups)
12132 (and method (not (eq method gnus-select-method))
12133 (let ((prefix (gnus-group-prefixed-name "" method)))
12134 (goto-char (point-min))
12135 (while (and (not (eobp))
12136 (null (insert prefix))
12137 (zerop (forward-line 1))))))
12138 (goto-char (point-min))
12139 ;; Store active file in hashtable.
12141 (if (or (re-search-forward "\n.\r?$" nil t)
12142 (goto-char (point-max)))
12144 (beginning-of-line)
12145 (narrow-to-region (point-min) (point))))
12146 (goto-char (point-min))
12147 (if (string-match "%[oO]" gnus-group-line-format)
12148 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
12149 ;; If we want information on moderated groups, we use this
12152 (let ((mod-hashtb (make-vector 7 0))
12154 (while (not (eobp))
12155 (setq group (let ((obarray hashtb))
12157 (setq max (read cur))
12158 (set group (cons (read cur) max))
12159 ;; Enter moderated groups into a list.
12161 (symbol-name (let ((obarray mod-hashtb)) (read cur)))
12163 (setq gnus-moderated-list
12164 (cons (symbol-name group) gnus-moderated-list)))
12167 (progn (ding) (message "Possible error in active file."))))
12168 ;; And if we do not care about moderation, we use this loop,
12169 ;; which is faster.
12172 (while (not (eobp))
12173 ;; group gets set to a symbol interned in the hash table
12175 (setq group (let ((obarray hashtb)) (read cur)))
12176 (setq max (read cur))
12177 (set group (cons (read cur) max))
12180 (progn (ding) (message "Possible error in active file."))))))))
12182 (defun gnus-read-newsrc-file (&optional force)
12183 "Read startup file.
12184 If FORCE is non-nil, the .newsrc file is read."
12185 (setq gnus-current-startup-file (gnus-make-newsrc-file gnus-startup-file))
12186 ;; Reset variables that might be defined in the .newsrc.eld file.
12187 (let ((variables gnus-variable-list))
12189 (set (car variables) nil)
12190 (setq variables (cdr variables))))
12191 (let* ((newsrc-file gnus-current-startup-file)
12192 (quick-file (concat newsrc-file ".el")))
12194 ;; We always load the .newsrc.eld file. If always contains
12195 ;; much information that can not be gotten from the .newsrc
12196 ;; file (ticked articles, killed groups, foreign methods, etc.)
12197 (gnus-read-newsrc-el-file quick-file)
12200 (and (file-newer-than-file-p newsrc-file quick-file)
12201 (file-newer-than-file-p newsrc-file
12202 (concat quick-file "d")))
12203 (not gnus-newsrc-assoc))
12204 ;; We read the .newsrc file. Note that if there if a
12205 ;; .newsrc.eld file exists, it has already been read, and
12206 ;; the `gnus-newsrc-hashtb' has been created. While reading
12207 ;; the .newsrc file, Gnus will only use the information it
12208 ;; can find there for changing the data already read -
12209 ;; ie. reading the .newsrc file will not trash the data
12210 ;; already read (except for read articles).
12212 (message "Reading %s..." newsrc-file)
12213 (set-buffer (find-file-noselect newsrc-file))
12214 (buffer-disable-undo (current-buffer))
12215 (gnus-newsrc-to-gnus-format)
12216 (kill-buffer (current-buffer))
12217 (message "Reading %s... done" newsrc-file)))
12218 (and gnus-use-dribble-file (gnus-dribble-read-file)))))
12220 (defun gnus-read-newsrc-el-file (file)
12221 (let ((ding-file (concat file "d")))
12222 ;; We always, always read the .eld file.
12223 (message "Reading %s..." ding-file)
12224 (condition-case nil
12225 (load ding-file t t t)
12227 (gnus-make-hashtable-from-newsrc-alist)
12228 (if (not (file-newer-than-file-p file ding-file))
12230 ;; Old format quick file
12231 (message "Reading %s..." file)
12232 ;; The .el file is newer than the .eld file, so we read that one
12234 (gnus-read-old-newsrc-el-file file))))
12236 ;; Parse the old-style quick startup file
12237 (defun gnus-read-old-newsrc-el-file (file)
12238 (let (newsrc killed marked group g m len info)
12240 (let (gnus-killed-assoc gnus-marked-assoc gnus-newsrc-assoc)
12242 (condition-case nil
12245 (setq newsrc gnus-newsrc-assoc
12246 killed gnus-killed-assoc
12247 marked gnus-marked-assoc)))
12248 (setq gnus-newsrc-assoc nil)
12250 (setq group (car newsrc))
12251 (let ((info (nth 2 (gnus-gethash (car group) gnus-newsrc-hashtb))))
12254 (setcar (nthcdr 2 info) (cdr (cdr group)))
12255 (setcar (cdr info) (if (nth 1 group) 3 6))
12256 (setq gnus-newsrc-assoc (cons info gnus-newsrc-assoc)))
12257 (setq gnus-newsrc-assoc
12261 (if (nth 1 group) 3 6) (cdr (cdr group))))
12262 gnus-newsrc-assoc)))
12263 (if (setq m (assoc (car group) marked))
12264 (setcdr (cdr (cdr info)) (cons (list (cons 'tick (cdr m))) nil))))
12265 (setq newsrc (cdr newsrc)))
12266 (setq newsrc killed)
12268 (setcar newsrc (car (car newsrc)))
12269 (setq newsrc (cdr newsrc)))
12270 (setq gnus-killed-list killed))
12271 (setq gnus-newsrc-assoc (nreverse gnus-newsrc-assoc))
12272 (gnus-make-hashtable-from-newsrc-alist)))
12274 (defun gnus-make-newsrc-file (file)
12275 "Make server dependent file name by catenating FILE and server host name."
12276 (let* ((file (expand-file-name file nil))
12277 (real-file (concat file "-" (nth 1 gnus-select-method))))
12278 (if (file-exists-p real-file)
12282 ;; jwz: rewrote this function to be much more efficient, and not be subject
12283 ;; to regexp overflow errors when it encounters very long lines -- the old
12284 ;; behavior was to blow off the rest of the *file* when a line was encountered
12285 ;; that was too long to match!! Now it uses only simple looking-at calls, and
12286 ;; doesn't create as many temporary strings. It also now handles multiple
12287 ;; consecutive options lines (before it only handled the first.)
12288 ;; Tiny rewrite by lmi.
12289 (defun gnus-newsrc-to-gnus-format ()
12290 "Parse current buffer as .newsrc file."
12291 ;; We have to re-initialize these variables (except for
12292 ;; gnus-killed-list) because the quick startup file may contain bogus
12294 (setq gnus-newsrc-options nil)
12295 (setq gnus-newsrc-options-n-yes nil)
12296 (setq gnus-newsrc-options-n-no nil)
12297 (setq gnus-newsrc-assoc nil)
12298 (gnus-parse-options-lines)
12299 (gnus-parse-newsrc-body))
12301 (defun gnus-parse-options-lines ()
12302 ;; newsrc.5 seems to indicate that the options line can come anywhere
12303 ;; in the file, and that there can be any number of them:
12305 ;; An options line starts with the word options (left-
12306 ;; justified). Then there are the list of options just as
12307 ;; they would be on the readnews command line. For instance:
12309 ;; options -n all !net.sf-lovers !mod.human-nets -r
12312 ;; A string of lines beginning with a space or tab after the
12313 ;; initial options line will be considered continuation
12316 ;; For now, we only accept it at the beginning of the file.
12318 (goto-char (point-min))
12319 (skip-chars-forward " \t\n")
12320 (setq gnus-newsrc-options nil)
12321 (while (looking-at "^options[ \t]*\\(.*\\)\n")
12322 ;; handle consecutive options lines
12323 (setq gnus-newsrc-options (concat gnus-newsrc-options
12324 (if gnus-newsrc-options "\n\t")
12325 (buffer-substring (match-beginning 1)
12328 (while (looking-at "[ \t]+\\(.*\\)\n")
12329 ;; handle subsequent continuation lines of this options line
12330 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n\t"
12331 (buffer-substring (match-beginning 1)
12334 ;; Gather all "-n" options lines.
12337 (if gnus-newsrc-options
12338 (while (and (string-match "^[ \t]*-n\\([^\n]*\\)$"
12339 gnus-newsrc-options
12341 (setq start (match-end 0)))
12342 (setq result (concat result
12344 (substring gnus-newsrc-options
12345 (match-beginning 1)
12347 (let ((yes-and-no (and result (gnus-parse-n-options result))))
12348 (and (or gnus-options-subscribe (car yes-and-no))
12349 (setq gnus-newsrc-options-n-yes
12350 (concat (or gnus-options-subscribe "")
12351 (or (car yes-and-no) ""))))
12352 (and (or gnus-options-not-subscribe (cdr yes-and-no))
12353 (setq gnus-newsrc-options-n-no
12354 (concat (or gnus-options-not-subscribe "")
12355 (or (cdr yes-and-no) "")))))
12358 (defun gnus-parse-newsrc-body ()
12359 ;; Point has been positioned after the options lines. We shouldn't
12360 ;; see any more in here.
12362 (let ((subscribe nil)
12364 (line (1+ (count-lines (point-min) (point))))
12368 (skip-chars-forward " \t")
12369 (while (not (eobp))
12371 ((= (following-char) ?\n)
12372 ;; skip blank lines
12376 (skip-chars-forward "^:!\n")
12377 (if (= (following-char) ?\n)
12378 (error "line %d is unparsable in %s" line (buffer-name)))
12380 (skip-chars-backward " \t")
12382 ;; #### note: we could avoid consing a string here by binding obarray
12383 ;; and reading the newsgroup directly into the gnus-newsrc-hashtb,
12384 ;; then setq'ing newsgroup to symbol-name of that, like we do in
12385 ;; gnus-active-to-gnus-format.
12386 (setq newsgroup (buffer-substring p (point)))
12389 (setq subscribe (= (following-char) ?:))
12390 (setq read-list nil)
12392 (forward-char 1) ; after : or !
12393 (skip-chars-forward " \t")
12394 (while (not (= (following-char) ?\n))
12395 (skip-chars-forward " \t")
12398 ((looking-at "\\([0-9]+\\)-\\([0-9]+\\)") ; a range
12403 ;; faster that buffer-substring/string-to-int
12404 (narrow-to-region (point-min) (match-end 1))
12405 (read (current-buffer)))
12407 (narrow-to-region (point-min) (match-end 2))
12408 (forward-char) ; skip over "-"
12410 (read (current-buffer))
12414 ((looking-at "[0-9]+")
12415 ;; faster that buffer-substring/string-to-int
12416 (narrow-to-region (point-min) (match-end 0))
12417 (setq p (read (current-buffer)))
12419 (setq read-list (cons (cons p p) read-list))
12422 ;; bogus chars in ranges
12425 (goto-char (match-end 0))
12426 (skip-chars-forward " \t")
12427 (cond ((= (following-char) ?,)
12430 ((= (following-char) ?\n)
12433 ;; bogus char after range
12435 ;; if we get here, the parse failed
12437 (end-of-line) ; give up on this line
12439 (message "Ignoring bogus line %d for %s in %s"
12440 line newsgroup (buffer-name))
12442 ;; We have already read .newsrc.eld, so we gently update the
12443 ;; data in the hash table with the information we have just
12445 (let ((info (nth 2 (gnus-gethash newsgroup gnus-newsrc-hashtb))))
12448 (setcar (nthcdr 2 info) (nreverse read-list))
12449 (setcar (cdr info) (if subscribe 3 (if read-list 6 7)))
12450 (setq gnus-newsrc-assoc (cons info gnus-newsrc-assoc)))
12451 (setq gnus-newsrc-assoc
12452 (cons (list newsgroup (if subscribe 3 (if read-list 6 7))
12453 (nreverse read-list))
12454 gnus-newsrc-assoc))))))
12455 (setq line (1+ line))
12456 (forward-line 1))))
12457 (setq gnus-newsrc-assoc (nreverse gnus-newsrc-assoc))
12458 (gnus-make-hashtable-from-newsrc-alist)
12461 (defun gnus-parse-n-options (options)
12462 "Parse -n NEWSGROUPS options and return a cons of YES and NO regexps."
12465 (yes-or-no nil) ;`!' or not.
12467 ;; Parse each newsgroup description such as "comp.all". Commas
12468 ;; and white spaces can be a newsgroup separator.
12470 (string-match "^[ \t\n,]*\\(!?\\)\\([^- \t\n,][^ \t\n,]*\\)" options)
12472 (substring options (match-beginning 1) (match-end 1)))
12476 (match-beginning 2) (match-end 2))))
12477 (setq options (substring options (match-end 2)))
12478 ;; Rewrite "all" to ".+" not ".*". ".+" requires at least one
12480 (while (string-match "\\(^\\|\\\\[.]\\)all\\(\\\\[.]\\|$\\)" newsgroup)
12482 (concat (substring newsgroup 0 (match-end 1))
12484 (substring newsgroup (match-beginning 2)))))
12485 ;; It is yes or no.
12486 (cond ((string-equal yes-or-no "!")
12487 (setq no (cons newsgroup no)))
12488 ((string-equal newsgroup ".+")) ;Ignore `all'.
12490 (setq yes (cons newsgroup yes))))
12492 ;; Make a cons of regexps from parsing result.
12493 ;; We have to append \(\.\|$\) to prevent matching substring of
12494 ;; newsgroup. For example, "jp.net" should not match with
12496 ;; Fixes for large regexp problems are from yonezu@nak.math.keio.ac.jp.
12499 (apply (function concat)
12501 (lambda (newsgroup)
12502 (concat newsgroup "\\|"))
12504 (car yes) "\\)\\(\\.\\|$\\)"))
12507 (apply (function concat)
12509 (lambda (newsgroup)
12510 (concat newsgroup "\\|"))
12512 (car no) "\\)\\(\\.\\|$\\)")))
12515 (defun gnus-save-newsrc-file ()
12516 "Save .newsrc file."
12517 ;; Note: We cannot save .newsrc file if all newsgroups are removed
12518 ;; from the variable gnus-newsrc-assoc.
12519 (and (or gnus-newsrc-assoc gnus-killed-list)
12520 gnus-current-startup-file
12522 (if (zerop (save-excursion
12523 (set-buffer gnus-dribble-buffer)
12525 (message "(No changes need to be saved)")
12526 (if gnus-save-newsrc-file
12527 (let ((make-backup-files t)
12528 (version-control nil)
12529 (require-final-newline t)) ;Don't ask even if requested.
12530 (message "Saving %s..." gnus-current-startup-file)
12531 ;; Make backup file of master newsrc.
12532 ;; You can stop or change version control of backup file.
12533 ;; Suggested by jason@violet.berkeley.edu.
12534 (run-hooks 'gnus-save-newsrc-hook)
12535 (gnus-gnus-to-newsrc-format)
12536 (message "Saving %s... done" gnus-current-startup-file)))
12537 ;; Quickly loadable .newsrc.
12538 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
12539 (gnus-add-current-to-buffer-list)
12540 (buffer-disable-undo (current-buffer))
12542 (message "Saving %s.eld..." gnus-current-startup-file)
12543 (gnus-gnus-to-quick-newsrc-format)
12544 (let ((make-backup-files nil)
12545 (version-control nil)
12546 (require-final-newline t)) ;Don't ask even if requested.
12547 (write-region 1 (point-max)
12548 (concat gnus-current-startup-file ".eld")
12550 (kill-buffer (current-buffer))
12551 (message "Saving %s.eld... done" gnus-current-startup-file)
12552 (gnus-dribble-delete-file)))))
12554 (defun gnus-gnus-to-quick-newsrc-format ()
12555 "Insert Gnus variables such as gnus-newsrc-assoc in lisp format."
12556 (insert ";; (ding) Gnus startup file.\n")
12557 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
12558 (insert ";; to read .newsrc.\n")
12559 (let ((variables gnus-variable-list)
12560 (gnus-newsrc-assoc (cdr gnus-newsrc-assoc))
12562 ;; insert lisp expressions.
12564 (setq variable (car variables))
12565 (and (boundp variable)
12566 (symbol-value variable)
12567 (or gnus-save-killed-list (not (eq variable 'gnus-killed-list)))
12568 (insert "(setq " (symbol-name variable) " '"
12569 (prin1-to-string (symbol-value variable))
12571 (setq variables (cdr variables)))))
12573 (defun gnus-gnus-to-newsrc-format ()
12574 ;; Generate and save the .newsrc file.
12575 (let ((newsrc (cdr gnus-newsrc-assoc))
12578 (set-buffer (create-file-buffer gnus-startup-file))
12579 (buffer-disable-undo (current-buffer))
12582 (if gnus-newsrc-options (insert "options " gnus-newsrc-options "\n"))
12583 ;; Write subscribed and unsubscribed.
12585 (setq info (car newsrc))
12586 (if (not (nth 4 info)) ;Don't write foreign groups to .newsrc.
12588 (insert (car info) (if (>= (nth 1 info) 6) "!" ":"))
12589 (if (setq ranges (nth 2 info))
12592 (if (atom (car ranges))
12593 (if (= (car ranges) (cdr ranges))
12594 (insert (int-to-string (car ranges)))
12595 (insert (int-to-string (car ranges)) "-"
12596 (int-to-string (cdr ranges))))
12598 (setq range (car ranges)
12599 ranges (cdr ranges))
12600 (if (= (car range) (cdr range))
12601 (insert (int-to-string (car range)))
12602 (insert (int-to-string (car range)) "-"
12603 (int-to-string (cdr range))))
12604 (if ranges (insert ","))))))
12606 (setq newsrc (cdr newsrc)))
12607 (write-region 1 (point-max) gnus-current-startup-file nil 'nomesg)
12608 (kill-buffer (current-buffer)))))
12610 (defun gnus-read-descriptions-file ()
12611 (message "Reading descriptions file...")
12612 (if (not (gnus-request-list-newsgroups gnus-select-method))
12614 (message "Couldn't read newsgroups descriptions")
12617 (setq gnus-description-hashtb
12618 (gnus-make-hashtable (length gnus-active-hashtb)))
12621 (set-buffer nntp-server-buffer)
12622 (goto-char (point-min))
12623 (delete-non-matching-lines "^[a-zA-Z\\.0-9]+[ \t]")
12624 (goto-char (point-min))
12625 (if (or (search-forward "\n.\n" nil t)
12626 (goto-char (point-max)))
12628 (beginning-of-line)
12629 (narrow-to-region (point-min) (point))))
12630 (goto-char (point-min))
12631 (while (not (eobp))
12632 (setq group (let ((obarray gnus-description-hashtb))
12633 (read (current-buffer))))
12634 (skip-chars-forward " \t")
12635 (set group (buffer-substring
12636 (point) (save-excursion (end-of-line) (point))))
12637 (forward-line 1))))
12638 (message "Reading descriptions file...done")
12643 ;;; gnus.el ends here