(minibuffer-setup-hook): Fix misspelling of hook name.
[emacs.git] / lisp / gnus.el
blob7a104bd14b7fef89774db6a7b2b2c9da937c2a34
1 ;;; gnus.el --- a newsreader for GNU Emacs
2 ;; Copyright (C) 1987,88,89,90,93,94,95,96 Free Software Foundation, Inc.
4 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
5 ;; Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
6 ;; Keywords: news
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)
13 ;; any later version.
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 the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
25 ;;; Commentary:
27 ;;; Code:
29 (eval '(run-hooks 'gnus-load-hook))
31 (require 'mail-utils)
32 (require 'timezone)
33 (require 'nnheader)
34 (require 'nnmail)
35 (require 'backquote)
36 (require 'nnoo)
38 (eval-when-compile (require 'cl))
40 (defvar gnus-directory (or (getenv "SAVEDIR") "~/News/")
41 "*Directory variable from which all other Gnus file variables are derived.")
43 ;; Site dependent variables. These variables should be defined in
44 ;; paths.el.
46 (defvar gnus-default-nntp-server nil
47 "Specify a default NNTP server.
48 This variable should be defined in paths.el, and should never be set
49 by the user.
50 If you want to change servers, you should use `gnus-select-method'.
51 See the documentation to that variable.")
53 (defvar gnus-backup-default-subscribed-newsgroups
54 '("news.announce.newusers" "news.groups.questions" "gnu.emacs.gnus")
55 "Default default new newsgroups the first time Gnus is run.
56 Should be set in paths.el, and shouldn't be touched by the user.")
58 (defvar gnus-local-domain nil
59 "Local domain name without a host name.
60 The DOMAINNAME environment variable is used instead if it is defined.
61 If the `system-name' function returns the full Internet name, there is
62 no need to set this variable.")
64 (defvar gnus-local-organization nil
65 "String with a description of what organization (if any) the user belongs to.
66 The ORGANIZATION environment variable is used instead if it is defined.
67 If this variable contains a function, this function will be called
68 with the current newsgroup name as the argument. The function should
69 return a string.
71 In any case, if the string (either in the variable, in the environment
72 variable, or returned by the function) is a file name, the contents of
73 this file will be used as the organization.")
75 ;; Customization variables
77 ;; Don't touch this variable.
78 (defvar gnus-nntp-service "nntp"
79 "*NNTP service name (\"nntp\" or 119).
80 This is an obsolete variable, which is scarcely used. If you use an
81 nntp server for your newsgroup and want to change the port number
82 used to 899, you would say something along these lines:
84 (setq gnus-select-method '(nntp \"my.nntp.server\" (nntp-port-number 899)))")
86 (defvar gnus-nntpserver-file "/etc/nntpserver"
87 "*A file with only the name of the nntp server in it.")
89 ;; This function is used to check both the environment variable
90 ;; NNTPSERVER and the /etc/nntpserver file to see whether one can find
91 ;; an nntp server name default.
92 (defun gnus-getenv-nntpserver ()
93 (or (getenv "NNTPSERVER")
94 (and (file-readable-p gnus-nntpserver-file)
95 (save-excursion
96 (set-buffer (get-buffer-create " *gnus nntp*"))
97 (buffer-disable-undo (current-buffer))
98 (insert-file-contents gnus-nntpserver-file)
99 (let ((name (buffer-string)))
100 (prog1
101 (if (string-match "^[ \t\n]*$" name)
103 name)
104 (kill-buffer (current-buffer))))))))
106 (defvar gnus-select-method
107 (nconc
108 (list 'nntp (or (condition-case ()
109 (gnus-getenv-nntpserver)
110 (error nil))
111 (if (and gnus-default-nntp-server
112 (not (string= gnus-default-nntp-server "")))
113 gnus-default-nntp-server)
114 (system-name)))
115 (if (or (null gnus-nntp-service)
116 (equal gnus-nntp-service "nntp"))
118 (list gnus-nntp-service)))
119 "*Default method for selecting a newsgroup.
120 This variable should be a list, where the first element is how the
121 news is to be fetched, the second is the address.
123 For instance, if you want to get your news via NNTP from
124 \"flab.flab.edu\", you could say:
126 (setq gnus-select-method '(nntp \"flab.flab.edu\"))
128 If you want to use your local spool, say:
130 (setq gnus-select-method (list 'nnspool (system-name)))
132 If you use this variable, you must set `gnus-nntp-server' to nil.
134 There is a lot more to know about select methods and virtual servers -
135 see the manual for details.")
137 (defvar gnus-message-archive-method
138 `(nnfolder
139 "archive"
140 (nnfolder-directory ,(nnheader-concat message-directory "archive"))
141 (nnfolder-active-file
142 ,(nnheader-concat message-directory "archive/active"))
143 (nnfolder-get-new-mail nil)
144 (nnfolder-inhibit-expiry t))
145 "*Method used for archiving messages you've sent.
146 This should be a mail method.
148 It's probably not a very effective to change this variable once you've
149 run Gnus once. After doing that, you must edit this server from the
150 server buffer.")
152 (defvar gnus-message-archive-group nil
153 "*Name of the group in which to save the messages you've written.
154 This can either be a string, a list of strings; or an alist
155 of regexps/functions/forms to be evaluated to return a string (or a list
156 of strings). The functions are called with the name of the current
157 group (or nil) as a parameter.
159 Normally the group names returned by this variable should be
160 unprefixed -- which implictly means \"store on the archive server\".
161 However, you may wish to store the message on some other server. In
162 that case, just return a fully prefixed name of the group --
163 \"nnml+private:mail.misc\", for instance.")
165 (defvar gnus-refer-article-method nil
166 "*Preferred method for fetching an article by Message-ID.
167 If you are reading news from the local spool (with nnspool), fetching
168 articles by Message-ID is painfully slow. By setting this method to an
169 nntp method, you might get acceptable results.
171 The value of this variable must be a valid select method as discussed
172 in the documentation of `gnus-select-method'.")
174 (defvar gnus-secondary-select-methods nil
175 "*A list of secondary methods that will be used for reading news.
176 This is a list where each element is a complete select method (see
177 `gnus-select-method').
179 If, for instance, you want to read your mail with the nnml backend,
180 you could set this variable:
182 (setq gnus-secondary-select-methods '((nnml \"\")))")
184 (defvar gnus-secondary-servers nil
185 "*List of NNTP servers that the user can choose between interactively.
186 To make Gnus query you for a server, you have to give `gnus' a
187 non-numeric prefix - `C-u M-x gnus', in short.")
189 (defvar gnus-nntp-server nil
190 "*The name of the host running the NNTP server.
191 This variable is semi-obsolete. Use the `gnus-select-method'
192 variable instead.")
194 (defvar gnus-startup-file "~/.newsrc"
195 "*Your `.newsrc' file.
196 `.newsrc-SERVER' will be used instead if that exists.")
198 (defvar gnus-init-file "~/.gnus"
199 "*Your Gnus elisp startup file.
200 If a file with the .el or .elc suffixes exist, it will be read
201 instead.")
203 (defvar gnus-group-faq-directory
204 '("/ftp@mirrors.aol.com:/pub/rtfm/usenet/"
205 "/ftp@sunsite.auc.dk:/pub/usenet/"
206 "/ftp@sunsite.doc.ic.ac.uk:/pub/usenet/news-faqs/"
207 "/ftp@src.doc.ic.ac.uk:/usenet/news-FAQS/"
208 "/ftp@ftp.seas.gwu.edu:/pub/rtfm/"
209 "/ftp@rtfm.mit.edu:/pub/usenet/"
210 "/ftp@ftp.uni-paderborn.de:/pub/FAQ/"
211 "/ftp@ftp.sunet.se:/pub/usenet/"
212 "/ftp@nctuccca.edu.tw:/USENET/FAQ/"
213 "/ftp@hwarang.postech.ac.kr:/pub/usenet/"
214 "/ftp@ftp.hk.super.net:/mirror/faqs/")
215 "*Directory where the group FAQs are stored.
216 This will most commonly be on a remote machine, and the file will be
217 fetched by ange-ftp.
219 This variable can also be a list of directories. In that case, the
220 first element in the list will be used by default. The others can
221 be used when being prompted for a site.
223 Note that Gnus uses an aol machine as the default directory. If this
224 feels fundamentally unclean, just think of it as a way to finally get
225 something of value back from them.
227 If the default site is too slow, try one of these:
229 North America: mirrors.aol.com /pub/rtfm/usenet
230 ftp.seas.gwu.edu /pub/rtfm
231 rtfm.mit.edu /pub/usenet
232 Europe: ftp.uni-paderborn.de /pub/FAQ
233 src.doc.ic.ac.uk /usenet/news-FAQS
234 ftp.sunet.se /pub/usenet
235 sunsite.auc.dk /pub/usenet
236 Asia: nctuccca.edu.tw /USENET/FAQ
237 hwarang.postech.ac.kr /pub/usenet
238 ftp.hk.super.net /mirror/faqs")
240 (defvar gnus-group-archive-directory
241 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
242 "*The address of the (ding) archives.")
244 (defvar gnus-group-recent-archive-directory
245 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
246 "*The address of the most recent (ding) articles.")
248 (defvar gnus-default-subscribed-newsgroups nil
249 "*This variable lists what newsgroups should be subscribed the first time Gnus is used.
250 It should be a list of strings.
251 If it is `t', Gnus will not do anything special the first time it is
252 started; it'll just use the normal newsgroups subscription methods.")
254 (defvar gnus-use-cross-reference t
255 "*Non-nil means that cross referenced articles will be marked as read.
256 If nil, ignore cross references. If t, mark articles as read in
257 subscribed newsgroups. If neither t nor nil, mark as read in all
258 newsgroups.")
260 (defvar gnus-single-article-buffer t
261 "*If non-nil, display all articles in the same buffer.
262 If nil, each group will get its own article buffer.")
264 (defvar gnus-use-dribble-file t
265 "*Non-nil means that Gnus will use a dribble file to store user updates.
266 If Emacs should crash without saving the .newsrc files, complete
267 information can be restored from the dribble file.")
269 (defvar gnus-dribble-directory nil
270 "*The directory where dribble files will be saved.
271 If this variable is nil, the directory where the .newsrc files are
272 saved will be used.")
274 (defvar gnus-asynchronous nil
275 "*If non-nil, Gnus will supply backends with data needed for async article fetching.")
277 (defvar gnus-kill-summary-on-exit t
278 "*If non-nil, kill the summary buffer when you exit from it.
279 If nil, the summary will become a \"*Dead Summary*\" buffer, and
280 it will be killed sometime later.")
282 (defvar gnus-large-newsgroup 200
283 "*The number of articles which indicates a large newsgroup.
284 If the number of articles in a newsgroup is greater than this value,
285 confirmation is required for selecting the newsgroup.")
287 ;; Suggested by Andrew Eskilsson <pi92ae@lelle.pt.hk-r.se>.
288 (defvar gnus-no-groups-message "No news is horrible news"
289 "*Message displayed by Gnus when no groups are available.")
291 (defvar gnus-use-long-file-name (not (memq system-type '(usg-unix-v xenix)))
292 "*Non-nil means that the default name of a file to save articles in is the group name.
293 If it's nil, the directory form of the group name is used instead.
295 If this variable is a list, and the list contains the element
296 `not-score', long file names will not be used for score files; if it
297 contains the element `not-save', long file names will not be used for
298 saving; and if it contains the element `not-kill', long file names
299 will not be used for kill files.
301 Note that the default for this variable varies according to what system
302 type you're using. On `usg-unix-v' and `xenix' this variable defaults
303 to nil while on all other systems it defaults to t.")
305 (defvar gnus-article-save-directory gnus-directory
306 "*Name of the directory articles will be saved in (default \"~/News\").")
308 (defvar gnus-kill-files-directory gnus-directory
309 "*Name of the directory where kill files will be stored (default \"~/News\").")
311 (defvar gnus-default-article-saver 'gnus-summary-save-in-rmail
312 "*A function to save articles in your favorite format.
313 The function must be interactively callable (in other words, it must
314 be an Emacs command).
316 Gnus provides the following functions:
318 * gnus-summary-save-in-rmail (Rmail format)
319 * gnus-summary-save-in-mail (Unix mail format)
320 * gnus-summary-save-in-folder (MH folder)
321 * gnus-summary-save-in-file (article format).
322 * gnus-summary-save-in-vm (use VM's folder format).")
324 (defvar gnus-prompt-before-saving 'always
325 "*This variable says how much prompting is to be done when saving articles.
326 If it is nil, no prompting will be done, and the articles will be
327 saved to the default files. If this variable is `always', each and
328 every article that is saved will be preceded by a prompt, even when
329 saving large batches of articles. If this variable is neither nil not
330 `always', there the user will be prompted once for a file name for
331 each invocation of the saving commands.")
333 (defvar gnus-rmail-save-name (function gnus-plain-save-name)
334 "*A function generating a file name to save articles in Rmail format.
335 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
337 (defvar gnus-mail-save-name (function gnus-plain-save-name)
338 "*A function generating a file name to save articles in Unix mail format.
339 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
341 (defvar gnus-folder-save-name (function gnus-folder-save-name)
342 "*A function generating a file name to save articles in MH folder.
343 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER.")
345 (defvar gnus-file-save-name (function gnus-numeric-save-name)
346 "*A function generating a file name to save articles in article format.
347 The function is called with NEWSGROUP, HEADERS, and optional
348 LAST-FILE.")
350 (defvar gnus-split-methods
351 '((gnus-article-archive-name))
352 "*Variable used to suggest where articles are to be saved.
353 For instance, if you would like to save articles related to Gnus in
354 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
355 you could set this variable to something like:
357 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
358 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
360 This variable is an alist where the where the key is the match and the
361 value is a list of possible files to save in if the match is non-nil.
363 If the match is a string, it is used as a regexp match on the
364 article. If the match is a symbol, that symbol will be funcalled
365 from the buffer of the article to be saved with the newsgroup as the
366 parameter. If it is a list, it will be evaled in the same buffer.
368 If this form or function returns a string, this string will be used as
369 a possible file name; and if it returns a non-nil list, that list will
370 be used as possible file names.")
372 (defvar gnus-move-split-methods nil
373 "*Variable used to suggest where articles are to be moved to.
374 It uses the same syntax as the `gnus-split-methods' variable.")
376 (defvar gnus-save-score nil
377 "*If non-nil, save group scoring info.")
379 (defvar gnus-use-adaptive-scoring nil
380 "*If non-nil, use some adaptive scoring scheme.")
382 (defvar gnus-use-cache 'passive
383 "*If nil, Gnus will ignore the article cache.
384 If `passive', it will allow entering (and reading) articles
385 explicitly entered into the cache. If anything else, use the
386 cache to the full extent of the law.")
388 (defvar gnus-use-trees nil
389 "*If non-nil, display a thread tree buffer.")
391 (defvar gnus-use-grouplens nil
392 "*If non-nil, use GroupLens ratings.")
394 (defvar gnus-keep-backlog nil
395 "*If non-nil, Gnus will keep read articles for later re-retrieval.
396 If it is a number N, then Gnus will only keep the last N articles
397 read. If it is neither nil nor a number, Gnus will keep all read
398 articles. This is not a good idea.")
400 (defvar gnus-use-nocem nil
401 "*If non-nil, Gnus will read NoCeM cancel messages.")
403 (defvar gnus-use-demon nil
404 "If non-nil, Gnus might use some demons.")
406 (defvar gnus-use-scoring t
407 "*If non-nil, enable scoring.")
409 (defvar gnus-use-picons nil
410 "*If non-nil, display picons.")
412 (defvar gnus-fetch-old-headers nil
413 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
414 If an unread article in the group refers to an older, already read (or
415 just marked as read) article, the old article will not normally be
416 displayed in the Summary buffer. If this variable is non-nil, Gnus
417 will attempt to grab the headers to the old articles, and thereby
418 build complete threads. If it has the value `some', only enough
419 headers to connect otherwise loose threads will be displayed.
420 This variable can also be a number. In that case, no more than that
421 number of old headers will be fetched.
423 The server has to support NOV for any of this to work.")
425 ;see gnus-cus.el
426 ;(defvar gnus-visual t
427 ; "*If non-nil, will do various highlighting.
428 ;If nil, no mouse highlights (or any other highlights) will be
429 ;performed. This might speed up Gnus some when generating large group
430 ;and summary buffers.")
432 (defvar gnus-novice-user t
433 "*Non-nil means that you are a usenet novice.
434 If non-nil, verbose messages may be displayed and confirmations may be
435 required.")
437 (defvar gnus-expert-user nil
438 "*Non-nil means that you will never be asked for confirmation about anything.
439 And that means *anything*.")
441 (defvar gnus-verbose 7
442 "*Integer that says how verbose Gnus should be.
443 The higher the number, the more messages Gnus will flash to say what
444 it's doing. At zero, Gnus will be totally mute; at five, Gnus will
445 display most important messages; and at ten, Gnus will keep on
446 jabbering all the time.")
448 (defvar gnus-keep-same-level nil
449 "*Non-nil means that the next newsgroup after the current will be on the same level.
450 When you type, for instance, `n' after reading the last article in the
451 current newsgroup, you will go to the next newsgroup. If this variable
452 is nil, the next newsgroup will be the next from the group
453 buffer.
454 If this variable is non-nil, Gnus will either put you in the
455 next newsgroup with the same level, or, if no such newsgroup is
456 available, the next newsgroup with the lowest possible level higher
457 than the current level.
458 If this variable is `best', Gnus will make the next newsgroup the one
459 with the best level.")
461 (defvar gnus-summary-make-false-root 'adopt
462 "*nil means that Gnus won't gather loose threads.
463 If the root of a thread has expired or been read in a previous
464 session, the information necessary to build a complete thread has been
465 lost. Instead of having many small sub-threads from this original thread
466 scattered all over the summary buffer, Gnus can gather them.
468 If non-nil, Gnus will try to gather all loose sub-threads from an
469 original thread into one large thread.
471 If this variable is non-nil, it should be one of `none', `adopt',
472 `dummy' or `empty'.
474 If this variable is `none', Gnus will not make a false root, but just
475 present the sub-threads after another.
476 If this variable is `dummy', Gnus will create a dummy root that will
477 have all the sub-threads as children.
478 If this variable is `adopt', Gnus will make one of the \"children\"
479 the parent and mark all the step-children as such.
480 If this variable is `empty', the \"children\" are printed with empty
481 subject fields. (Or rather, they will be printed with a string
482 given by the `gnus-summary-same-subject' variable.)")
484 (defvar gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
485 "*A regexp to match subjects to be excluded from loose thread gathering.
486 As loose thread gathering is done on subjects only, that means that
487 there can be many false gatherings performed. By rooting out certain
488 common subjects, gathering might become saner.")
490 (defvar gnus-summary-gather-subject-limit nil
491 "*Maximum length of subject comparisons when gathering loose threads.
492 Use nil to compare full subjects. Setting this variable to a low
493 number will help gather threads that have been corrupted by
494 newsreaders chopping off subject lines, but it might also mean that
495 unrelated articles that have subject that happen to begin with the
496 same few characters will be incorrectly gathered.
498 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
499 comparing subjects.")
501 (defvar gnus-simplify-ignored-prefixes nil
502 "*Regexp, matches for which are removed from subject lines when simplifying.")
504 (defvar gnus-build-sparse-threads nil
505 "*If non-nil, fill in the gaps in threads.
506 If `some', only fill in the gaps that are needed to tie loose threads
507 together. If `more', fill in all leaf nodes that Gnus can find. If
508 non-nil and non-`some', fill in all gaps that Gnus manages to guess.")
510 (defvar gnus-summary-thread-gathering-function 'gnus-gather-threads-by-subject
511 "Function used for gathering loose threads.
512 There are two pre-defined functions: `gnus-gather-threads-by-subject',
513 which only takes Subjects into consideration; and
514 `gnus-gather-threads-by-references', which compared the References
515 headers of the articles to find matches.")
517 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
518 (defvar gnus-summary-same-subject ""
519 "*String indicating that the current article has the same subject as the previous.
520 This variable will only be used if the value of
521 `gnus-summary-make-false-root' is `empty'.")
523 (defvar gnus-summary-goto-unread t
524 "*If non-nil, marking commands will go to the next unread article.
525 If `never', \\<gnus-summary-mode-map>\\[gnus-summary-next-page] will go to the next article,
526 whether it is read or not.")
528 (defvar gnus-group-goto-unread t
529 "*If non-nil, movement commands will go to the next unread and subscribed group.")
531 (defvar gnus-goto-next-group-when-activating t
532 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group.")
534 (defvar gnus-check-new-newsgroups t
535 "*Non-nil means that Gnus will add new newsgroups at startup.
536 If this variable is `ask-server', Gnus will ask the server for new
537 groups since the last time it checked. This means that the killed list
538 is no longer necessary, so you could set `gnus-save-killed-list' to
539 nil.
541 A variant is to have this variable be a list of select methods. Gnus
542 will then use the `ask-server' method on all these select methods to
543 query for new groups from all those servers.
546 (setq gnus-check-new-newsgroups
547 '((nntp \"some.server\") (nntp \"other.server\")))
549 If this variable is nil, then you have to tell Gnus explicitly to
550 check for new newsgroups with \\<gnus-group-mode-map>\\[gnus-find-new-newsgroups].")
552 (defvar gnus-check-bogus-newsgroups nil
553 "*Non-nil means that Gnus will check and remove bogus newsgroup at startup.
554 If this variable is nil, then you have to tell Gnus explicitly to
555 check for bogus newsgroups with \\<gnus-group-mode-map>\\[gnus-group-check-bogus-groups].")
557 (defvar gnus-read-active-file t
558 "*Non-nil means that Gnus will read the entire active file at startup.
559 If this variable is nil, Gnus will only know about the groups in your
560 `.newsrc' file.
562 If this variable is `some', Gnus will try to only read the relevant
563 parts of the active file from the server. Not all servers support
564 this, and it might be quite slow with other servers, but this should
565 generally be faster than both the t and nil value.
567 If you set this variable to nil or `some', you probably still want to
568 be told about new newsgroups that arrive. To do that, set
569 `gnus-check-new-newsgroups' to `ask-server'. This may not work
570 properly with all servers.")
572 (defvar gnus-level-subscribed 5
573 "*Groups with levels less than or equal to this variable are subscribed.")
575 (defvar gnus-level-unsubscribed 7
576 "*Groups with levels less than or equal to this variable are unsubscribed.
577 Groups with levels less than `gnus-level-subscribed', which should be
578 less than this variable, are subscribed.")
580 (defvar gnus-level-zombie 8
581 "*Groups with this level are zombie groups.")
583 (defvar gnus-level-killed 9
584 "*Groups with this level are killed.")
586 (defvar gnus-level-default-subscribed 3
587 "*New subscribed groups will be subscribed at this level.")
589 (defvar gnus-level-default-unsubscribed 6
590 "*New unsubscribed groups will be unsubscribed at this level.")
592 (defvar gnus-activate-level (1+ gnus-level-subscribed)
593 "*Groups higher than this level won't be activated on startup.
594 Setting this variable to something log might save lots of time when
595 you have many groups that you aren't interested in.")
597 (defvar gnus-activate-foreign-newsgroups 4
598 "*If nil, Gnus will not check foreign newsgroups at startup.
599 If it is non-nil, it should be a number between one and nine. Foreign
600 newsgroups that have a level lower or equal to this number will be
601 activated on startup. For instance, if you want to active all
602 subscribed newsgroups, but not the rest, you'd set this variable to
603 `gnus-level-subscribed'.
605 If you subscribe to lots of newsgroups from different servers, startup
606 might take a while. By setting this variable to nil, you'll save time,
607 but you won't be told how many unread articles there are in the
608 groups.")
610 (defvar gnus-save-newsrc-file t
611 "*Non-nil means that Gnus will save the `.newsrc' file.
612 Gnus always saves its own startup file, which is called
613 \".newsrc.eld\". The file called \".newsrc\" is in a format that can
614 be readily understood by other newsreaders. If you don't plan on
615 using other newsreaders, set this variable to nil to save some time on
616 exit.")
618 (defvar gnus-save-killed-list t
619 "*If non-nil, save the list of killed groups to the startup file.
620 If you set this variable to nil, you'll save both time (when starting
621 and quitting) and space (both memory and disk), but it will also mean
622 that Gnus has no record of which groups are new and which are old, so
623 the automatic new newsgroups subscription methods become meaningless.
625 You should always set `gnus-check-new-newsgroups' to `ask-server' or
626 nil if you set this variable to nil.")
628 (defvar gnus-interactive-catchup t
629 "*If non-nil, require your confirmation when catching up a group.")
631 (defvar gnus-interactive-exit t
632 "*If non-nil, require your confirmation when exiting Gnus.")
634 (defvar gnus-kill-killed t
635 "*If non-nil, Gnus will apply kill files to already killed articles.
636 If it is nil, Gnus will never apply kill files to articles that have
637 already been through the scoring process, which might very well save lots
638 of time.")
640 (defvar gnus-extract-address-components 'gnus-extract-address-components
641 "*Function for extracting address components from a From header.
642 Two pre-defined function exist: `gnus-extract-address-components',
643 which is the default, quite fast, and too simplistic solution, and
644 `mail-extract-address-components', which works much better, but is
645 slower.")
647 (defvar gnus-summary-default-score 0
648 "*Default article score level.
649 If this variable is nil, scoring will be disabled.")
651 (defvar gnus-summary-zcore-fuzz 0
652 "*Fuzziness factor for the zcore in the summary buffer.
653 Articles with scores closer than this to `gnus-summary-default-score'
654 will not be marked.")
656 (defvar gnus-simplify-subject-fuzzy-regexp nil
657 "*Strings to be removed when doing fuzzy matches.
658 This can either be a regular expression or list of regular expressions
659 that will be removed from subject strings if fuzzy subject
660 simplification is selected.")
662 (defvar gnus-permanently-visible-groups nil
663 "*Regexp to match groups that should always be listed in the group buffer.
664 This means that they will still be listed when there are no unread
665 articles in the groups.")
667 (defvar gnus-list-groups-with-ticked-articles t
668 "*If non-nil, list groups that have only ticked articles.
669 If nil, only list groups that have unread articles.")
671 (defvar gnus-group-default-list-level gnus-level-subscribed
672 "*Default listing level.
673 Ignored if `gnus-group-use-permanent-levels' is non-nil.")
675 (defvar gnus-group-use-permanent-levels nil
676 "*If non-nil, once you set a level, Gnus will use this level.")
678 (defvar gnus-group-list-inactive-groups t
679 "*If non-nil, inactive groups will be listed.")
681 (defvar gnus-show-mime nil
682 "*If non-nil, do mime processing of articles.
683 The articles will simply be fed to the function given by
684 `gnus-show-mime-method'.")
686 (defvar gnus-strict-mime t
687 "*If nil, MIME-decode even if there is no Mime-Version header in the article.")
689 (defvar gnus-show-mime-method 'metamail-buffer
690 "*Function to process a MIME message.
691 The function is called from the article buffer.")
693 (defvar gnus-decode-encoded-word-method (lambda ())
694 "*Function to decode a MIME encoded-words.
695 The function is called from the article buffer.")
697 (defvar gnus-show-threads t
698 "*If non-nil, display threads in summary mode.")
700 (defvar gnus-thread-hide-subtree nil
701 "*If non-nil, hide all threads initially.
702 If threads are hidden, you have to run the command
703 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
704 to expose hidden threads.")
706 (defvar gnus-thread-hide-killed t
707 "*If non-nil, hide killed threads automatically.")
709 (defvar gnus-thread-ignore-subject nil
710 "*If non-nil, ignore subjects and do all threading based on the Reference header.
711 If nil, which is the default, articles that have different subjects
712 from their parents will start separate threads.")
714 (defvar gnus-thread-operation-ignore-subject t
715 "*If non-nil, subjects will be ignored when doing thread commands.
716 This affects commands like `gnus-summary-kill-thread' and
717 `gnus-summary-lower-thread'.
719 If this variable is nil, articles in the same thread with different
720 subjects will not be included in the operation in question. If this
721 variable is `fuzzy', only articles that have subjects that are fuzzily
722 equal will be included.")
724 (defvar gnus-thread-indent-level 4
725 "*Number that says how much each sub-thread should be indented.")
727 (defvar gnus-ignored-newsgroups
728 (purecopy (mapconcat 'identity
729 '("^to\\." ; not "real" groups
730 "^[0-9. \t]+ " ; all digits in name
731 "[][\"#'()]" ; bogus characters
733 "\\|"))
734 "*A regexp to match uninteresting newsgroups in the active file.
735 Any lines in the active file matching this regular expression are
736 removed from the newsgroup list before anything else is done to it,
737 thus making them effectively non-existent.")
739 (defvar gnus-ignored-headers
740 "^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:"
741 "*All headers that match this regexp will be hidden.
742 This variable can also be a list of regexps of headers to be ignored.
743 If `gnus-visible-headers' is non-nil, this variable will be ignored.")
745 (defvar gnus-visible-headers "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-"
746 "*All headers that do not match this regexp will be hidden.
747 This variable can also be a list of regexp of headers to remain visible.
748 If this variable is non-nil, `gnus-ignored-headers' will be ignored.")
750 (defvar gnus-sorted-header-list
751 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^To:"
752 "^Cc:" "^Date:" "^Organization:")
753 "*This variable is a list of regular expressions.
754 If it is non-nil, headers that match the regular expressions will
755 be placed first in the article buffer in the sequence specified by
756 this list.")
758 (defvar gnus-boring-article-headers
759 '(empty followup-to reply-to)
760 "*Headers that are only to be displayed if they have interesting data.
761 Possible values in this list are `empty', `newsgroups', `followup-to',
762 `reply-to', and `date'.")
764 (defvar gnus-show-all-headers nil
765 "*If non-nil, don't hide any headers.")
767 (defvar gnus-save-all-headers t
768 "*If non-nil, don't remove any headers before saving.")
770 (defvar gnus-saved-headers gnus-visible-headers
771 "*Headers to keep if `gnus-save-all-headers' is nil.
772 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
773 If that variable is nil, however, all headers that match this regexp
774 will be kept while the rest will be deleted before saving.")
776 (defvar gnus-inhibit-startup-message nil
777 "*If non-nil, the startup message will not be displayed.")
779 (defvar gnus-signature-separator "^-- *$"
780 "Regexp matching signature separator.")
782 (defvar gnus-signature-limit nil
783 "Provide a limit to what is considered a signature.
784 If it is a number, no signature may not be longer (in characters) than
785 that number. If it is a function, the function will be called without
786 any parameters, and if it returns nil, there is no signature in the
787 buffer. If it is a string, it will be used as a regexp. If it
788 matches, the text in question is not a signature.")
790 (defvar gnus-auto-extend-newsgroup t
791 "*If non-nil, extend newsgroup forward and backward when requested.")
793 (defvar gnus-auto-select-first t
794 "*If nil, don't select the first unread article when entering a group.
795 If this variable is `best', select the highest-scored unread article
796 in the group. If neither nil nor `best', select the first unread
797 article.
799 If you want to prevent automatic selection of the first unread article
800 in some newsgroups, set the variable to nil in
801 `gnus-select-group-hook'.")
803 (defvar gnus-auto-select-next t
804 "*If non-nil, offer to go to the next group from the end of the previous.
805 If the value is t and the next newsgroup is empty, Gnus will exit
806 summary mode and go back to group mode. If the value is neither nil
807 nor t, Gnus will select the following unread newsgroup. In
808 particular, if the value is the symbol `quietly', the next unread
809 newsgroup will be selected without any confirmation, and if it is
810 `almost-quietly', the next group will be selected without any
811 confirmation if you are located on the last article in the group.
812 Finally, if this variable is `slightly-quietly', the `Z n' command
813 will go to the next group without confirmation.")
815 (defvar gnus-auto-select-same nil
816 "*If non-nil, select the next article with the same subject.")
818 (defvar gnus-summary-check-current nil
819 "*If non-nil, consider the current article when moving.
820 The \"unread\" movement commands will stay on the same line if the
821 current article is unread.")
823 (defvar gnus-auto-center-summary t
824 "*If non-nil, always center the current summary buffer.
825 In particular, if `vertical' do only vertical recentering. If non-nil
826 and non-`vertical', do both horizontal and vertical recentering.")
828 (defvar gnus-break-pages t
829 "*If non-nil, do page breaking on articles.
830 The page delimiter is specified by the `gnus-page-delimiter'
831 variable.")
833 (defvar gnus-page-delimiter "^\^L"
834 "*Regexp describing what to use as article page delimiters.
835 The default value is \"^\^L\", which is a form linefeed at the
836 beginning of a line.")
838 (defvar gnus-use-full-window t
839 "*If non-nil, use the entire Emacs screen.")
841 (defvar gnus-window-configuration nil
842 "Obsolete variable. See `gnus-buffer-configuration'.")
844 (defvar gnus-window-min-width 2
845 "*Minimum width of Gnus buffers.")
847 (defvar gnus-window-min-height 1
848 "*Minimum height of Gnus buffers.")
850 (defvar gnus-buffer-configuration
851 '((group
852 (vertical 1.0
853 (group 1.0 point)
854 (if gnus-carpal '(group-carpal 4))))
855 (summary
856 (vertical 1.0
857 (summary 1.0 point)
858 (if gnus-carpal '(summary-carpal 4))))
859 (article
860 (cond
861 (gnus-use-picons
862 '(frame 1.0
863 (vertical 1.0
864 (summary 0.25 point)
865 (if gnus-carpal '(summary-carpal 4))
866 (article 1.0))
867 (vertical ((height . 5) (width . 15)
868 (user-position . t)
869 (left . -1) (top . 1))
870 (picons 1.0))))
871 (gnus-use-trees
872 '(vertical 1.0
873 (summary 0.25 point)
874 (tree 0.25)
875 (article 1.0)))
877 '(vertical 1.0
878 (summary 0.25 point)
879 (if gnus-carpal '(summary-carpal 4))
880 (article 1.0)))))
881 (server
882 (vertical 1.0
883 (server 1.0 point)
884 (if gnus-carpal '(server-carpal 2))))
885 (browse
886 (vertical 1.0
887 (browse 1.0 point)
888 (if gnus-carpal '(browse-carpal 2))))
889 (message
890 (vertical 1.0
891 (message 1.0 point)))
892 (pick
893 (vertical 1.0
894 (article 1.0 point)))
895 (info
896 (vertical 1.0
897 (info 1.0 point)))
898 (summary-faq
899 (vertical 1.0
900 (summary 0.25)
901 (faq 1.0 point)))
902 (edit-group
903 (vertical 1.0
904 (group 0.5)
905 (edit-group 1.0 point)))
906 (edit-server
907 (vertical 1.0
908 (server 0.5)
909 (edit-server 1.0 point)))
910 (edit-score
911 (vertical 1.0
912 (summary 0.25)
913 (edit-score 1.0 point)))
914 (post
915 (vertical 1.0
916 (post 1.0 point)))
917 (reply
918 (vertical 1.0
919 (article-copy 0.5)
920 (message 1.0 point)))
921 (forward
922 (vertical 1.0
923 (message 1.0 point)))
924 (reply-yank
925 (vertical 1.0
926 (message 1.0 point)))
927 (mail-bounce
928 (vertical 1.0
929 (article 0.5)
930 (message 1.0 point)))
931 (draft
932 (vertical 1.0
933 (draft 1.0 point)))
934 (pipe
935 (vertical 1.0
936 (summary 0.25 point)
937 (if gnus-carpal '(summary-carpal 4))
938 ("*Shell Command Output*" 1.0)))
939 (bug
940 (vertical 1.0
941 ("*Gnus Help Bug*" 0.5)
942 ("*Gnus Bug*" 1.0 point)))
943 (compose-bounce
944 (vertical 1.0
945 (article 0.5)
946 (message 1.0 point))))
947 "Window configuration for all possible Gnus buffers.
948 This variable is a list of lists. Each of these lists has a NAME and
949 a RULE. The NAMEs are commonsense names like `group', which names a
950 rule used when displaying the group buffer; `summary', which names a
951 rule for what happens when you enter a group and do not display an
952 article buffer; and so on. See the value of this variable for a
953 complete list of NAMEs.
955 Each RULE is a list of vectors. The first element in this vector is
956 the name of the buffer to be displayed; the second element is the
957 percentage of the screen this buffer is to occupy (a number in the
958 0.0-0.99 range); the optional third element is `point', which should
959 be present to denote which buffer point is to go to after making this
960 buffer configuration.")
962 (defvar gnus-window-to-buffer
963 '((group . gnus-group-buffer)
964 (summary . gnus-summary-buffer)
965 (article . gnus-article-buffer)
966 (server . gnus-server-buffer)
967 (browse . "*Gnus Browse Server*")
968 (edit-group . gnus-group-edit-buffer)
969 (edit-server . gnus-server-edit-buffer)
970 (group-carpal . gnus-carpal-group-buffer)
971 (summary-carpal . gnus-carpal-summary-buffer)
972 (server-carpal . gnus-carpal-server-buffer)
973 (browse-carpal . gnus-carpal-browse-buffer)
974 (edit-score . gnus-score-edit-buffer)
975 (message . gnus-message-buffer)
976 (mail . gnus-message-buffer)
977 (post-news . gnus-message-buffer)
978 (faq . gnus-faq-buffer)
979 (picons . "*Picons*")
980 (tree . gnus-tree-buffer)
981 (info . gnus-info-buffer)
982 (article-copy . gnus-article-copy)
983 (draft . gnus-draft-buffer))
984 "Mapping from short symbols to buffer names or buffer variables.")
986 (defvar gnus-carpal nil
987 "*If non-nil, display clickable icons.")
989 (defvar gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies
990 "*Function called with a group name when new group is detected.
991 A few pre-made functions are supplied: `gnus-subscribe-randomly'
992 inserts new groups at the beginning of the list of groups;
993 `gnus-subscribe-alphabetically' inserts new groups in strict
994 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
995 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
996 for your decision; `gnus-subscribe-killed' kills all new groups;
997 `gnus-subscribe-zombies' will make all new groups into zombies.")
999 ;; Suggested by a bug report by Hallvard B Furuseth.
1000 ;; <h.b.furuseth@usit.uio.no>.
1001 (defvar gnus-subscribe-options-newsgroup-method
1002 (function gnus-subscribe-alphabetically)
1003 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines.
1004 If, for instance, you want to subscribe to all newsgroups in the
1005 \"no\" and \"alt\" hierarchies, you'd put the following in your
1006 .newsrc file:
1008 options -n no.all alt.all
1010 Gnus will the subscribe all new newsgroups in these hierarchies with
1011 the subscription method in this variable.")
1013 (defvar gnus-subscribe-hierarchical-interactive nil
1014 "*If non-nil, Gnus will offer to subscribe hierarchically.
1015 When a new hierarchy appears, Gnus will ask the user:
1017 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
1019 If the user pressed `d', Gnus will descend the hierarchy, `y' will
1020 subscribe to all newsgroups in the hierarchy and `s' will skip this
1021 hierarchy in its entirety.")
1023 (defvar gnus-group-sort-function 'gnus-group-sort-by-alphabet
1024 "*Function used for sorting the group buffer.
1025 This function will be called with group info entries as the arguments
1026 for the groups to be sorted. Pre-made functions include
1027 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-unread',
1028 `gnus-group-sort-by-level', `gnus-group-sort-by-score', and
1029 `gnus-group-sort-by-rank'.
1031 This variable can also be a list of sorting functions. In that case,
1032 the most significant sort function should be the last function in the
1033 list.")
1035 ;; Mark variables suggested by Thomas Michanek
1036 ;; <Thomas.Michanek@telelogic.se>.
1037 (defvar gnus-unread-mark ?
1038 "*Mark used for unread articles.")
1039 (defvar gnus-ticked-mark ?!
1040 "*Mark used for ticked articles.")
1041 (defvar gnus-dormant-mark ??
1042 "*Mark used for dormant articles.")
1043 (defvar gnus-del-mark ?r
1044 "*Mark used for del'd articles.")
1045 (defvar gnus-read-mark ?R
1046 "*Mark used for read articles.")
1047 (defvar gnus-expirable-mark ?E
1048 "*Mark used for expirable articles.")
1049 (defvar gnus-killed-mark ?K
1050 "*Mark used for killed articles.")
1051 (defvar gnus-souped-mark ?F
1052 "*Mark used for killed articles.")
1053 (defvar gnus-kill-file-mark ?X
1054 "*Mark used for articles killed by kill files.")
1055 (defvar gnus-low-score-mark ?Y
1056 "*Mark used for articles with a low score.")
1057 (defvar gnus-catchup-mark ?C
1058 "*Mark used for articles that are caught up.")
1059 (defvar gnus-replied-mark ?A
1060 "*Mark used for articles that have been replied to.")
1061 (defvar gnus-cached-mark ?*
1062 "*Mark used for articles that are in the cache.")
1063 (defvar gnus-saved-mark ?S
1064 "*Mark used for articles that have been saved to.")
1065 (defvar gnus-process-mark ?#
1066 "*Process mark.")
1067 (defvar gnus-ancient-mark ?O
1068 "*Mark used for ancient articles.")
1069 (defvar gnus-sparse-mark ?Q
1070 "*Mark used for sparsely reffed articles.")
1071 (defvar gnus-canceled-mark ?G
1072 "*Mark used for canceled articles.")
1073 (defvar gnus-score-over-mark ?+
1074 "*Score mark used for articles with high scores.")
1075 (defvar gnus-score-below-mark ?-
1076 "*Score mark used for articles with low scores.")
1077 (defvar gnus-empty-thread-mark ?
1078 "*There is no thread under the article.")
1079 (defvar gnus-not-empty-thread-mark ?=
1080 "*There is a thread under the article.")
1082 (defvar gnus-view-pseudo-asynchronously nil
1083 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
1085 (defvar gnus-view-pseudos nil
1086 "*If `automatic', pseudo-articles will be viewed automatically.
1087 If `not-confirm', pseudos will be viewed automatically, and the user
1088 will not be asked to confirm the command.")
1090 (defvar gnus-view-pseudos-separately t
1091 "*If non-nil, one pseudo-article will be created for each file to be viewed.
1092 If nil, all files that use the same viewing command will be given as a
1093 list of parameters to that command.")
1095 (defvar gnus-insert-pseudo-articles t
1096 "*If non-nil, insert pseudo-articles when decoding articles.")
1098 (defvar gnus-group-line-format "%M%S%p%P%5y: %(%g%)%l\n"
1099 "*Format of group lines.
1100 It works along the same lines as a normal formatting string,
1101 with some simple extensions.
1103 %M Only marked articles (character, \"*\" or \" \")
1104 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
1105 %L Level of subscribedness (integer)
1106 %N Number of unread articles (integer)
1107 %I Number of dormant articles (integer)
1108 %i Number of ticked and dormant (integer)
1109 %T Number of ticked articles (integer)
1110 %R Number of read articles (integer)
1111 %t Total number of articles (integer)
1112 %y Number of unread, unticked articles (integer)
1113 %G Group name (string)
1114 %g Qualified group name (string)
1115 %D Group description (string)
1116 %s Select method (string)
1117 %o Moderated group (char, \"m\")
1118 %p Process mark (char)
1119 %O Moderated group (string, \"(m)\" or \"\")
1120 %P Topic indentation (string)
1121 %l Whether there are GroupLens predictions for this group (string)
1122 %n Select from where (string)
1123 %z A string that look like `<%s:%n>' if a foreign select method is used
1124 %u User defined specifier. The next character in the format string should
1125 be a letter. Gnus will call the function gnus-user-format-function-X,
1126 where X is the letter following %u. The function will be passed the
1127 current header as argument. The function should return a string, which
1128 will be inserted into the buffer just like information from any other
1129 group specifier.
1131 Text between %( and %) will be highlighted with `gnus-mouse-face' when
1132 the mouse point move inside the area. There can only be one such area.
1134 Note that this format specification is not always respected. For
1135 reasons of efficiency, when listing killed groups, this specification
1136 is ignored altogether. If the spec is changed considerably, your
1137 output may end up looking strange when listing both alive and killed
1138 groups.
1140 If you use %o or %O, reading the active file will be slower and quite
1141 a bit of extra memory will be used. %D will also worsen performance.
1142 Also note that if you change the format specification to include any
1143 of these specs, you must probably re-start Gnus to see them go into
1144 effect.")
1146 (defvar gnus-summary-line-format "%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n"
1147 "*The format specification of the lines in the summary buffer.
1149 It works along the same lines as a normal formatting string,
1150 with some simple extensions.
1152 %N Article number, left padded with spaces (string)
1153 %S Subject (string)
1154 %s Subject if it is at the root of a thread, and \"\" otherwise (string)
1155 %n Name of the poster (string)
1156 %a Extracted name of the poster (string)
1157 %A Extracted address of the poster (string)
1158 %F Contents of the From: header (string)
1159 %x Contents of the Xref: header (string)
1160 %D Date of the article (string)
1161 %d Date of the article (string) in DD-MMM format
1162 %M Message-id of the article (string)
1163 %r References of the article (string)
1164 %c Number of characters in the article (integer)
1165 %L Number of lines in the article (integer)
1166 %I Indentation based on thread level (a string of spaces)
1167 %T A string with two possible values: 80 spaces if the article
1168 is on thread level two or larger and 0 spaces on level one
1169 %R \"A\" if this article has been replied to, \" \" otherwise (character)
1170 %U Status of this article (character, \"R\", \"K\", \"-\" or \" \")
1171 %[ Opening bracket (character, \"[\" or \"<\")
1172 %] Closing bracket (character, \"]\" or \">\")
1173 %> Spaces of length thread-level (string)
1174 %< Spaces of length (- 20 thread-level) (string)
1175 %i Article score (number)
1176 %z Article zcore (character)
1177 %t Number of articles under the current thread (number).
1178 %e Whether the thread is empty or not (character).
1179 %l GroupLens score (string).
1180 %u User defined specifier. The next character in the format string should
1181 be a letter. Gnus will call the function gnus-user-format-function-X,
1182 where X is the letter following %u. The function will be passed the
1183 current header as argument. The function should return a string, which
1184 will be inserted into the summary just like information from any other
1185 summary specifier.
1187 Text between %( and %) will be highlighted with `gnus-mouse-face'
1188 when the mouse point is placed inside the area. There can only be one
1189 such area.
1191 The %U (status), %R (replied) and %z (zcore) specs have to be handled
1192 with care. For reasons of efficiency, Gnus will compute what column
1193 these characters will end up in, and \"hard-code\" that. This means that
1194 it is illegal to have these specs after a variable-length spec. Well,
1195 you might not be arrested, but your summary buffer will look strange,
1196 which is bad enough.
1198 The smart choice is to have these specs as for to the left as
1199 possible.
1201 This restriction may disappear in later versions of Gnus.")
1203 (defvar gnus-summary-dummy-line-format
1204 "* %(: :%) %S\n"
1205 "*The format specification for the dummy roots in the summary buffer.
1206 It works along the same lines as a normal formatting string,
1207 with some simple extensions.
1209 %S The subject")
1211 (defvar gnus-summary-mode-line-format "Gnus: %%b [%A] %Z"
1212 "*The format specification for the summary mode line.
1213 It works along the same lines as a normal formatting string,
1214 with some simple extensions:
1216 %G Group name
1217 %p Unprefixed group name
1218 %A Current article number
1219 %V Gnus version
1220 %U Number of unread articles in the group
1221 %e Number of unselected articles in the group
1222 %Z A string with unread/unselected article counts
1223 %g Shortish group name
1224 %S Subject of the current article
1225 %u User-defined spec
1226 %s Current score file name
1227 %d Number of dormant articles
1228 %r Number of articles that have been marked as read in this session
1229 %E Number of articles expunged by the score files")
1231 (defvar gnus-article-mode-line-format "Gnus: %%b %S"
1232 "*The format specification for the article mode line.
1233 See `gnus-summary-mode-line-format' for a closer description.")
1235 (defvar gnus-group-mode-line-format "Gnus: %%b {%M%:%S}"
1236 "*The format specification for the group mode line.
1237 It works along the same lines as a normal formatting string,
1238 with some simple extensions:
1240 %S The native news server.
1241 %M The native select method.
1242 %: \":\" if %S isn't \"\".")
1244 (defvar gnus-valid-select-methods
1245 '(("nntp" post address prompt-address)
1246 ("nnspool" post address)
1247 ("nnvirtual" post-mail virtual prompt-address)
1248 ("nnmbox" mail respool address)
1249 ("nnml" mail respool address)
1250 ("nnmh" mail respool address)
1251 ("nndir" post-mail prompt-address address)
1252 ("nneething" none address prompt-address)
1253 ("nndoc" none address prompt-address)
1254 ("nnbabyl" mail address respool)
1255 ("nnkiboze" post virtual)
1256 ("nnsoup" post-mail address)
1257 ("nndraft" post-mail)
1258 ("nnfolder" mail respool address))
1259 "An alist of valid select methods.
1260 The first element of each list lists should be a string with the name
1261 of the select method. The other elements may be be the category of
1262 this method (ie. `post', `mail', `none' or whatever) or other
1263 properties that this method has (like being respoolable).
1264 If you implement a new select method, all you should have to change is
1265 this variable. I think.")
1267 (defvar gnus-updated-mode-lines '(group article summary tree)
1268 "*List of buffers that should update their mode lines.
1269 The list may contain the symbols `group', `article' and `summary'. If
1270 the corresponding symbol is present, Gnus will keep that mode line
1271 updated with information that may be pertinent.
1272 If this variable is nil, screen refresh may be quicker.")
1274 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>.
1275 (defvar gnus-mode-non-string-length nil
1276 "*Max length of mode-line non-string contents.
1277 If this is nil, Gnus will take space as is needed, leaving the rest
1278 of the modeline intact.")
1280 ;see gnus-cus.el
1281 ;(defvar gnus-mouse-face 'highlight
1282 ; "*Face used for mouse highlighting in Gnus.
1283 ;No mouse highlights will be done if `gnus-visual' is nil.")
1285 (defvar gnus-summary-mark-below 0
1286 "*Mark all articles with a score below this variable as read.
1287 This variable is local to each summary buffer and usually set by the
1288 score file.")
1290 (defvar gnus-article-sort-functions '(gnus-article-sort-by-number)
1291 "*List of functions used for sorting articles in the summary buffer.
1292 This variable is only used when not using a threaded display.")
1294 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number)
1295 "*List of functions used for sorting threads in the summary buffer.
1296 By default, threads are sorted by article number.
1298 Each function takes two threads and return non-nil if the first thread
1299 should be sorted before the other. If you use more than one function,
1300 the primary sort function should be the last. You should probably
1301 always include `gnus-thread-sort-by-number' in the list of sorting
1302 functions -- preferably first.
1304 Ready-mady functions include `gnus-thread-sort-by-number',
1305 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
1306 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
1307 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').")
1309 (defvar gnus-thread-score-function '+
1310 "*Function used for calculating the total score of a thread.
1312 The function is called with the scores of the article and each
1313 subthread and should then return the score of the thread.
1315 Some functions you can use are `+', `max', or `min'.")
1317 (defvar gnus-summary-expunge-below nil
1318 "All articles that have a score less than this variable will be expunged.")
1320 (defvar gnus-thread-expunge-below nil
1321 "All threads that have a total score less than this variable will be expunged.
1322 See `gnus-thread-score-function' for en explanation of what a
1323 \"thread score\" is.")
1325 (defvar gnus-auto-subscribed-groups
1326 "^nnml\\|^nnfolder\\|^nnmbox\\|^nnmh\\|^nnbabyl"
1327 "*All new groups that match this regexp will be subscribed automatically.
1328 Note that this variable only deals with new groups. It has no effect
1329 whatsoever on old groups.
1331 New groups that match this regexp will not be handled by
1332 `gnus-subscribe-newsgroup-method'. Instead, they will
1333 be subscribed using `gnus-subscribe-options-newsgroup-method'.")
1335 (defvar gnus-options-subscribe nil
1336 "*All new groups matching this regexp will be subscribed unconditionally.
1337 Note that this variable deals only with new newsgroups. This variable
1338 does not affect old newsgroups.
1340 New groups that match this regexp will not be handled by
1341 `gnus-subscribe-newsgroup-method'. Instead, they will
1342 be subscribed using `gnus-subscribe-options-newsgroup-method'.")
1344 (defvar gnus-options-not-subscribe nil
1345 "*All new groups matching this regexp will be ignored.
1346 Note that this variable deals only with new newsgroups. This variable
1347 does not affect old (already subscribed) newsgroups.")
1349 (defvar gnus-auto-expirable-newsgroups nil
1350 "*Groups in which to automatically mark read articles as expirable.
1351 If non-nil, this should be a regexp that should match all groups in
1352 which to perform auto-expiry. This only makes sense for mail groups.")
1354 (defvar gnus-total-expirable-newsgroups nil
1355 "*Groups in which to perform expiry of all read articles.
1356 Use with extreme caution. All groups that match this regexp will be
1357 expiring - which means that all read articles will be deleted after
1358 (say) one week. (This only goes for mail groups and the like, of
1359 course.)")
1361 (defvar gnus-group-uncollapsed-levels 1
1362 "Number of group name elements to leave alone when making a short group name.")
1364 (defvar gnus-hidden-properties '(invisible t intangible t)
1365 "Property list to use for hiding text.")
1367 (defvar gnus-modtime-botch nil
1368 "*Non-nil means .newsrc should be deleted prior to save.
1369 Its use is due to the bogus appearance that .newsrc was modified on
1370 disc.")
1372 ;; Hooks.
1374 (defvar gnus-group-mode-hook nil
1375 "*A hook for Gnus group mode.")
1377 (defvar gnus-summary-mode-hook nil
1378 "*A hook for Gnus summary mode.
1379 This hook is run before any variables are set in the summary buffer.")
1381 (defvar gnus-article-mode-hook nil
1382 "*A hook for Gnus article mode.")
1384 (defvar gnus-summary-prepare-exit-hook nil
1385 "*A hook called when preparing to exit from the summary buffer.
1386 It calls `gnus-summary-expire-articles' by default.")
1387 (add-hook 'gnus-summary-prepare-exit-hook 'gnus-summary-expire-articles)
1389 (defvar gnus-summary-exit-hook nil
1390 "*A hook called on exit from the summary buffer.")
1392 (defvar gnus-group-catchup-group-hook nil
1393 "*A hook run when catching up a group from the group buffer.")
1395 (defvar gnus-group-update-group-hook nil
1396 "*A hook called when updating group lines.")
1398 (defvar gnus-open-server-hook nil
1399 "*A hook called just before opening connection to the news server.")
1401 (defvar gnus-load-hook nil
1402 "*A hook run while Gnus is loaded.")
1404 (defvar gnus-startup-hook nil
1405 "*A hook called at startup.
1406 This hook is called after Gnus is connected to the NNTP server.")
1408 (defvar gnus-get-new-news-hook nil
1409 "*A hook run just before Gnus checks for new news.")
1411 (defvar gnus-after-getting-new-news-hook nil
1412 "*A hook run after Gnus checks for new news.")
1414 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat
1415 "*A function that is called to generate the group buffer.
1416 The function is called with three arguments: The first is a number;
1417 all group with a level less or equal to that number should be listed,
1418 if the second is non-nil, empty groups should also be displayed. If
1419 the third is non-nil, it is a number. No groups with a level lower
1420 than this number should be displayed.
1422 The only current function implemented is `gnus-group-prepare-flat'.")
1424 (defvar gnus-group-prepare-hook nil
1425 "*A hook called after the group buffer has been generated.
1426 If you want to modify the group buffer, you can use this hook.")
1428 (defvar gnus-summary-prepare-hook nil
1429 "*A hook called after the summary buffer has been generated.
1430 If you want to modify the summary buffer, you can use this hook.")
1432 (defvar gnus-summary-generate-hook nil
1433 "*A hook run just before generating the summary buffer.
1434 This hook is commonly used to customize threading variables and the
1435 like.")
1437 (defvar gnus-article-prepare-hook nil
1438 "*A hook called after an article has been prepared in the article buffer.
1439 If you want to run a special decoding program like nkf, use this hook.")
1441 ;(defvar gnus-article-display-hook nil
1442 ; "*A hook called after the article is displayed in the article buffer.
1443 ;The hook is designed to change the contents of the article
1444 ;buffer. Typical functions that this hook may contain are
1445 ;`gnus-article-hide-headers' (hide selected headers),
1446 ;`gnus-article-maybe-highlight' (perform fancy article highlighting),
1447 ;`gnus-article-hide-signature' (hide signature) and
1448 ;`gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).")
1449 ;(add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted)
1450 ;(add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike)
1451 ;(add-hook 'gnus-article-display-hook 'gnus-article-maybe-highlight)
1453 (defvar gnus-article-x-face-too-ugly nil
1454 "Regexp matching posters whose face shouldn't be shown automatically.")
1456 (defvar gnus-select-group-hook nil
1457 "*A hook called when a newsgroup is selected.
1459 If you'd like to simplify subjects like the
1460 `gnus-summary-next-same-subject' command does, you can use the
1461 following hook:
1463 (setq gnus-select-group-hook
1464 (list
1465 (lambda ()
1466 (mapcar (lambda (header)
1467 (mail-header-set-subject
1468 header
1469 (gnus-simplify-subject
1470 (mail-header-subject header) 're-only)))
1471 gnus-newsgroup-headers))))")
1473 (defvar gnus-select-article-hook nil
1474 "*A hook called when an article is selected.")
1476 (defvar gnus-apply-kill-hook '(gnus-apply-kill-file)
1477 "*A hook called to apply kill files to a group.
1478 This hook is intended to apply a kill file to the selected newsgroup.
1479 The function `gnus-apply-kill-file' is called by default.
1481 Since a general kill file is too heavy to use only for a few
1482 newsgroups, I recommend you to use a lighter hook function. For
1483 example, if you'd like to apply a kill file to articles which contains
1484 a string `rmgroup' in subject in newsgroup `control', you can use the
1485 following hook:
1487 (setq gnus-apply-kill-hook
1488 (list
1489 (lambda ()
1490 (cond ((string-match \"control\" gnus-newsgroup-name)
1491 (gnus-kill \"Subject\" \"rmgroup\")
1492 (gnus-expunge \"X\"))))))")
1494 (defvar gnus-visual-mark-article-hook
1495 (list 'gnus-highlight-selected-summary)
1496 "*Hook run after selecting an article in the summary buffer.
1497 It is meant to be used for highlighting the article in some way. It
1498 is not run if `gnus-visual' is nil.")
1500 (defvar gnus-parse-headers-hook nil
1501 "*A hook called before parsing the headers.")
1502 (add-hook 'gnus-parse-headers-hook 'gnus-decode-rfc1522)
1504 (defvar gnus-exit-group-hook nil
1505 "*A hook called when exiting (not quitting) summary mode.")
1507 (defvar gnus-suspend-gnus-hook nil
1508 "*A hook called when suspending (not exiting) Gnus.")
1510 (defvar gnus-exit-gnus-hook nil
1511 "*A hook called when exiting Gnus.")
1513 (defvar gnus-after-exiting-gnus-hook nil
1514 "*A hook called after exiting Gnus.")
1516 (defvar gnus-save-newsrc-hook nil
1517 "*A hook called before saving any of the newsrc files.")
1519 (defvar gnus-save-quick-newsrc-hook nil
1520 "*A hook called just before saving the quick newsrc file.
1521 Can be used to turn version control on or off.")
1523 (defvar gnus-save-standard-newsrc-hook nil
1524 "*A hook called just before saving the standard newsrc file.
1525 Can be used to turn version control on or off.")
1527 (defvar gnus-summary-update-hook
1528 (list 'gnus-summary-highlight-line)
1529 "*A hook called when a summary line is changed.
1530 The hook will not be called if `gnus-visual' is nil.
1532 The default function `gnus-summary-highlight-line' will
1533 highlight the line according to the `gnus-summary-highlight'
1534 variable.")
1536 (defvar gnus-group-update-hook '(gnus-group-highlight-line)
1537 "*A hook called when a group line is changed.
1538 The hook will not be called if `gnus-visual' is nil.
1540 The default function `gnus-group-highlight-line' will
1541 highlight the line according to the `gnus-group-highlight'
1542 variable.")
1544 (defvar gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
1545 "*A hook called when an article is selected for the first time.
1546 The hook is intended to mark an article as read (or unread)
1547 automatically when it is selected.")
1549 (defvar gnus-group-change-level-function nil
1550 "Function run when a group level is changed.
1551 It is called with three parameters -- GROUP, LEVEL and OLDLEVEL.")
1553 ;; Remove any hilit infestation.
1554 (add-hook 'gnus-startup-hook
1555 (lambda ()
1556 (remove-hook 'gnus-summary-prepare-hook
1557 'hilit-rehighlight-buffer-quietly)
1558 (remove-hook 'gnus-summary-prepare-hook 'hilit-install-line-hooks)
1559 (setq gnus-mark-article-hook
1560 '(gnus-summary-mark-read-and-unread-as-read))
1561 (remove-hook 'gnus-article-prepare-hook
1562 'hilit-rehighlight-buffer-quietly)))
1565 ;; Internal variables
1567 (defvar gnus-tree-buffer "*Tree*"
1568 "Buffer where Gnus thread trees are displayed.")
1570 ;; Dummy variable.
1571 (defvar gnus-use-generic-from nil)
1573 (defvar gnus-thread-indent-array nil)
1574 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1576 (defvar gnus-newsrc-file-version nil)
1578 (defvar gnus-method-history nil)
1579 ;; Variable holding the user answers to all method prompts.
1581 (defvar gnus-group-history nil)
1582 ;; Variable holding the user answers to all group prompts.
1584 (defvar gnus-server-alist nil
1585 "List of available servers.")
1587 (defvar gnus-group-indentation-function nil)
1589 (defvar gnus-topic-indentation "") ;; Obsolete variable.
1591 (defvar gnus-goto-missing-group-function nil)
1593 (defvar gnus-override-subscribe-method nil)
1595 (defvar gnus-group-goto-next-group-function nil
1596 "Function to override finding the next group after listing groups.")
1598 (defconst gnus-article-mark-lists
1599 '((marked . tick) (replied . reply)
1600 (expirable . expire) (killed . killed)
1601 (bookmarks . bookmark) (dormant . dormant)
1602 (scored . score) (saved . save)
1603 (cached . cache)
1606 ;; Avoid highlighting in kill files.
1607 (defvar gnus-summary-inhibit-highlight nil)
1608 (defvar gnus-newsgroup-selected-overlay nil)
1610 (defvar gnus-inhibit-hiding nil)
1611 (defvar gnus-group-indentation "")
1612 (defvar gnus-inhibit-limiting nil)
1613 (defvar gnus-created-frames nil)
1615 (defvar gnus-article-mode-map nil)
1616 (defvar gnus-dribble-buffer nil)
1617 (defvar gnus-headers-retrieved-by nil)
1618 (defvar gnus-article-reply nil)
1619 (defvar gnus-override-method nil)
1620 (defvar gnus-article-check-size nil)
1622 (defvar gnus-current-score-file nil)
1623 (defvar gnus-newsgroup-adaptive-score-file nil)
1624 (defvar gnus-scores-exclude-files nil)
1626 (defvar gnus-opened-servers nil)
1628 (defvar gnus-current-move-group nil)
1629 (defvar gnus-current-copy-group nil)
1630 (defvar gnus-current-crosspost-group nil)
1632 (defvar gnus-newsgroup-dependencies nil)
1633 (defvar gnus-newsgroup-async nil)
1634 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*")
1636 (defvar gnus-newsgroup-adaptive nil)
1638 (defvar gnus-summary-display-table nil)
1639 (defvar gnus-summary-display-article-function nil)
1641 (defvar gnus-summary-highlight-line-function nil
1642 "Function called after highlighting a summary line.")
1644 (defvar gnus-group-line-format-alist
1645 `((?M gnus-tmp-marked-mark ?c)
1646 (?S gnus-tmp-subscribed ?c)
1647 (?L gnus-tmp-level ?d)
1648 (?N (cond ((eq number t) "*" )
1649 ((numberp number)
1650 (int-to-string
1651 (+ number
1652 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1653 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
1654 (t number)) ?s)
1655 (?R gnus-tmp-number-of-read ?s)
1656 (?t gnus-tmp-number-total ?d)
1657 (?y gnus-tmp-number-of-unread ?s)
1658 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
1659 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
1660 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1661 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
1662 (?g gnus-tmp-group ?s)
1663 (?G gnus-tmp-qualified-group ?s)
1664 (?c (gnus-short-group-name gnus-tmp-group) ?s)
1665 (?D gnus-tmp-newsgroup-description ?s)
1666 (?o gnus-tmp-moderated ?c)
1667 (?O gnus-tmp-moderated-string ?s)
1668 (?p gnus-tmp-process-marked ?c)
1669 (?s gnus-tmp-news-server ?s)
1670 (?n gnus-tmp-news-method ?s)
1671 (?P gnus-group-indentation ?s)
1672 (?l gnus-tmp-grouplens ?s)
1673 (?z gnus-tmp-news-method-string ?s)
1674 (?u gnus-tmp-user-defined ?s)))
1676 (defvar gnus-summary-line-format-alist
1677 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1678 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1679 (?s gnus-tmp-subject-or-nil ?s)
1680 (?n gnus-tmp-name ?s)
1681 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1683 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1684 gnus-tmp-from) ?s)
1685 (?F gnus-tmp-from ?s)
1686 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1687 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1688 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1689 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1690 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1691 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1692 (?L gnus-tmp-lines ?d)
1693 (?I gnus-tmp-indentation ?s)
1694 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1695 (?R gnus-tmp-replied ?c)
1696 (?\[ gnus-tmp-opening-bracket ?c)
1697 (?\] gnus-tmp-closing-bracket ?c)
1698 (?\> (make-string gnus-tmp-level ? ) ?s)
1699 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1700 (?i gnus-tmp-score ?d)
1701 (?z gnus-tmp-score-char ?c)
1702 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1703 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1704 (?U gnus-tmp-unread ?c)
1705 (?t (gnus-summary-number-of-articles-in-thread
1706 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1708 (?e (gnus-summary-number-of-articles-in-thread
1709 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1711 (?u gnus-tmp-user-defined ?s))
1712 "An alist of format specifications that can appear in summary lines,
1713 and what variables they correspond with, along with the type of the
1714 variable (string, integer, character, etc).")
1716 (defvar gnus-summary-dummy-line-format-alist
1717 `((?S gnus-tmp-subject ?s)
1718 (?N gnus-tmp-number ?d)
1719 (?u gnus-tmp-user-defined ?s)))
1721 (defvar gnus-summary-mode-line-format-alist
1722 `((?G gnus-tmp-group-name ?s)
1723 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1724 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1725 (?A gnus-tmp-article-number ?d)
1726 (?Z gnus-tmp-unread-and-unselected ?s)
1727 (?V gnus-version ?s)
1728 (?U gnus-tmp-unread-and-unticked ?d)
1729 (?S gnus-tmp-subject ?s)
1730 (?e gnus-tmp-unselected ?d)
1731 (?u gnus-tmp-user-defined ?s)
1732 (?d (length gnus-newsgroup-dormant) ?d)
1733 (?t (length gnus-newsgroup-marked) ?d)
1734 (?r (length gnus-newsgroup-reads) ?d)
1735 (?E gnus-newsgroup-expunged-tally ?d)
1736 (?s (gnus-current-score-file-nondirectory) ?s)))
1738 (defvar gnus-article-mode-line-format-alist
1739 gnus-summary-mode-line-format-alist)
1741 (defvar gnus-group-mode-line-format-alist
1742 `((?S gnus-tmp-news-server ?s)
1743 (?M gnus-tmp-news-method ?s)
1744 (?u gnus-tmp-user-defined ?s)
1745 (?: gnus-tmp-colon ?s)))
1747 (defvar gnus-have-read-active-file nil)
1749 (defconst gnus-maintainer
1750 "gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls + Boys)"
1751 "The mail address of the Gnus maintainers.")
1753 (defconst gnus-version-number "5.3"
1754 "Version number for this version of Gnus.")
1756 (defconst gnus-version (format "Gnus v%s" gnus-version-number)
1757 "Version string for this version of Gnus.")
1759 (defvar gnus-info-nodes
1760 '((gnus-group-mode "(gnus)The Group Buffer")
1761 (gnus-summary-mode "(gnus)The Summary Buffer")
1762 (gnus-article-mode "(gnus)The Article Buffer")
1763 (gnus-server-mode "(gnus)The Server Buffer")
1764 (gnus-browse-mode "(gnus)Browse Foreign Server")
1765 (gnus-tree-mode "(gnus)Tree Display")
1767 "Alist of major modes and related Info nodes.")
1769 (defvar gnus-group-buffer "*Group*")
1770 (defvar gnus-summary-buffer "*Summary*")
1771 (defvar gnus-article-buffer "*Article*")
1772 (defvar gnus-server-buffer "*Server*")
1774 (defvar gnus-work-buffer " *gnus work*")
1776 (defvar gnus-original-article-buffer " *Original Article*")
1777 (defvar gnus-original-article nil)
1779 (defvar gnus-buffer-list nil
1780 "Gnus buffers that should be killed on exit.")
1782 (defvar gnus-slave nil
1783 "Whether this Gnus is a slave or not.")
1785 (defvar gnus-variable-list
1786 '(gnus-newsrc-options gnus-newsrc-options-n
1787 gnus-newsrc-last-checked-date
1788 gnus-newsrc-alist gnus-server-alist
1789 gnus-killed-list gnus-zombie-list
1790 gnus-topic-topology gnus-topic-alist
1791 gnus-format-specs)
1792 "Gnus variables saved in the quick startup file.")
1794 (defvar gnus-newsrc-options nil
1795 "Options line in the .newsrc file.")
1797 (defvar gnus-newsrc-options-n nil
1798 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1800 (defvar gnus-newsrc-last-checked-date nil
1801 "Date Gnus last asked server for new newsgroups.")
1803 (defvar gnus-topic-topology nil
1804 "The complete topic hierarchy.")
1806 (defvar gnus-topic-alist nil
1807 "The complete topic-group alist.")
1809 (defvar gnus-newsrc-alist nil
1810 "Assoc list of read articles.
1811 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1813 (defvar gnus-newsrc-hashtb nil
1814 "Hashtable of gnus-newsrc-alist.")
1816 (defvar gnus-killed-list nil
1817 "List of killed newsgroups.")
1819 (defvar gnus-killed-hashtb nil
1820 "Hash table equivalent of gnus-killed-list.")
1822 (defvar gnus-zombie-list nil
1823 "List of almost dead newsgroups.")
1825 (defvar gnus-description-hashtb nil
1826 "Descriptions of newsgroups.")
1828 (defvar gnus-list-of-killed-groups nil
1829 "List of newsgroups that have recently been killed by the user.")
1831 (defvar gnus-active-hashtb nil
1832 "Hashtable of active articles.")
1834 (defvar gnus-moderated-list nil
1835 "List of moderated newsgroups.")
1837 (defvar gnus-group-marked nil)
1839 (defvar gnus-current-startup-file nil
1840 "Startup file for the current host.")
1842 (defvar gnus-last-search-regexp nil
1843 "Default regexp for article search command.")
1845 (defvar gnus-last-shell-command nil
1846 "Default shell command on article.")
1848 (defvar gnus-current-select-method nil
1849 "The current method for selecting a newsgroup.")
1851 (defvar gnus-group-list-mode nil)
1853 (defvar gnus-article-internal-prepare-hook nil)
1855 (defvar gnus-newsgroup-name nil)
1856 (defvar gnus-newsgroup-begin nil)
1857 (defvar gnus-newsgroup-end nil)
1858 (defvar gnus-newsgroup-last-rmail nil)
1859 (defvar gnus-newsgroup-last-mail nil)
1860 (defvar gnus-newsgroup-last-folder nil)
1861 (defvar gnus-newsgroup-last-file nil)
1862 (defvar gnus-newsgroup-auto-expire nil)
1863 (defvar gnus-newsgroup-active nil)
1865 (defvar gnus-newsgroup-data nil)
1866 (defvar gnus-newsgroup-data-reverse nil)
1867 (defvar gnus-newsgroup-limit nil)
1868 (defvar gnus-newsgroup-limits nil)
1870 (defvar gnus-newsgroup-unreads nil
1871 "List of unread articles in the current newsgroup.")
1873 (defvar gnus-newsgroup-unselected nil
1874 "List of unselected unread articles in the current newsgroup.")
1876 (defvar gnus-newsgroup-reads nil
1877 "Alist of read articles and article marks in the current newsgroup.")
1879 (defvar gnus-newsgroup-expunged-tally nil)
1881 (defvar gnus-newsgroup-marked nil
1882 "List of ticked articles in the current newsgroup (a subset of unread art).")
1884 (defvar gnus-newsgroup-killed nil
1885 "List of ranges of articles that have been through the scoring process.")
1887 (defvar gnus-newsgroup-cached nil
1888 "List of articles that come from the article cache.")
1890 (defvar gnus-newsgroup-saved nil
1891 "List of articles that have been saved.")
1893 (defvar gnus-newsgroup-kill-headers nil)
1895 (defvar gnus-newsgroup-replied nil
1896 "List of articles that have been replied to in the current newsgroup.")
1898 (defvar gnus-newsgroup-expirable nil
1899 "List of articles in the current newsgroup that can be expired.")
1901 (defvar gnus-newsgroup-processable nil
1902 "List of articles in the current newsgroup that can be processed.")
1904 (defvar gnus-newsgroup-bookmarks nil
1905 "List of articles in the current newsgroup that have bookmarks.")
1907 (defvar gnus-newsgroup-dormant nil
1908 "List of dormant articles in the current newsgroup.")
1910 (defvar gnus-newsgroup-scored nil
1911 "List of scored articles in the current newsgroup.")
1913 (defvar gnus-newsgroup-headers nil
1914 "List of article headers in the current newsgroup.")
1916 (defvar gnus-newsgroup-threads nil)
1918 (defvar gnus-newsgroup-prepared nil
1919 "Whether the current group has been prepared properly.")
1921 (defvar gnus-newsgroup-ancient nil
1922 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1924 (defvar gnus-newsgroup-sparse nil)
1926 (defvar gnus-current-article nil)
1927 (defvar gnus-article-current nil)
1928 (defvar gnus-current-headers nil)
1929 (defvar gnus-have-all-headers nil)
1930 (defvar gnus-last-article nil)
1931 (defvar gnus-newsgroup-history nil)
1932 (defvar gnus-current-kill-article nil)
1934 ;; Save window configuration.
1935 (defvar gnus-prev-winconf nil)
1937 (defvar gnus-summary-mark-positions nil)
1938 (defvar gnus-group-mark-positions nil)
1940 (defvar gnus-reffed-article-number nil)
1942 ;;; Let the byte-compiler know that we know about this variable.
1943 (defvar rmail-default-rmail-file)
1945 (defvar gnus-cache-removable-articles nil)
1947 (defvar gnus-dead-summary nil)
1949 (defconst gnus-summary-local-variables
1950 '(gnus-newsgroup-name
1951 gnus-newsgroup-begin gnus-newsgroup-end
1952 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1953 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1954 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1955 gnus-newsgroup-unselected gnus-newsgroup-marked
1956 gnus-newsgroup-reads gnus-newsgroup-saved
1957 gnus-newsgroup-replied gnus-newsgroup-expirable
1958 gnus-newsgroup-processable gnus-newsgroup-killed
1959 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1960 gnus-newsgroup-headers gnus-newsgroup-threads
1961 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1962 gnus-current-article gnus-current-headers gnus-have-all-headers
1963 gnus-last-article gnus-article-internal-prepare-hook
1964 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1965 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1966 gnus-newsgroup-async gnus-thread-expunge-below
1967 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1968 (gnus-summary-mark-below . global)
1969 gnus-newsgroup-active gnus-scores-exclude-files
1970 gnus-newsgroup-history gnus-newsgroup-ancient
1971 gnus-newsgroup-sparse
1972 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1973 gnus-newsgroup-adaptive-score-file
1974 (gnus-newsgroup-expunged-tally . 0)
1975 gnus-cache-removable-articles gnus-newsgroup-cached
1976 gnus-newsgroup-data gnus-newsgroup-data-reverse
1977 gnus-newsgroup-limit gnus-newsgroup-limits)
1978 "Variables that are buffer-local to the summary buffers.")
1980 (defconst gnus-bug-message
1981 "Sending a bug report to the Gnus Towers.
1982 ========================================
1984 The buffer below is a mail buffer. When you press `C-c C-c', it will
1985 be sent to the Gnus Bug Exterminators.
1987 At the bottom of the buffer you'll see lots of variable settings.
1988 Please do not delete those. They will tell the Bug People what your
1989 environment is, so that it will be easier to locate the bugs.
1991 If you have found a bug that makes Emacs go \"beep\", set
1992 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
1993 and include the backtrace in your bug report.
1995 Please describe the bug in annoying, painstaking detail.
1997 Thank you for your help in stamping out bugs.
2000 ;;; End of variables.
2002 ;; Define some autoload functions Gnus might use.
2003 (eval-and-compile
2005 ;; This little mapcar goes through the list below and marks the
2006 ;; symbols in question as autoloaded functions.
2007 (mapcar
2008 (lambda (package)
2009 (let ((interactive (nth 1 (memq ':interactive package))))
2010 (mapcar
2011 (lambda (function)
2012 (let (keymap)
2013 (when (consp function)
2014 (setq keymap (car (memq 'keymap function)))
2015 (setq function (car function)))
2016 (autoload function (car package) nil interactive keymap)))
2017 (if (eq (nth 1 package) ':interactive)
2018 (cdddr package)
2019 (cdr package)))))
2020 '(("metamail" metamail-buffer)
2021 ("info" Info-goto-node)
2022 ("hexl" hexl-hex-string-to-integer)
2023 ("pp" pp pp-to-string pp-eval-expression)
2024 ("mail-extr" mail-extract-address-components)
2025 ("nnmail" nnmail-split-fancy nnmail-article-group)
2026 ("nnvirtual" nnvirtual-catchup-group)
2027 ("timezone" timezone-make-date-arpa-standard timezone-fix-time
2028 timezone-make-sortable-date timezone-make-time-string)
2029 ("rmailout" rmail-output)
2030 ("rmail" rmail-insert-rmail-file-header rmail-count-new-messages
2031 rmail-show-message)
2032 ("gnus-soup" :interactive t
2033 gnus-group-brew-soup gnus-brew-soup gnus-soup-add-article
2034 gnus-soup-send-replies gnus-soup-save-areas gnus-soup-pack-packet)
2035 ("nnsoup" nnsoup-pack-replies)
2036 ("score-mode" :interactive t gnus-score-mode)
2037 ("gnus-mh" gnus-mh-mail-setup gnus-summary-save-article-folder
2038 gnus-Folder-save-name gnus-folder-save-name)
2039 ("gnus-mh" :interactive t gnus-summary-save-in-folder)
2040 ("gnus-vis" gnus-group-make-menu-bar gnus-summary-make-menu-bar
2041 gnus-server-make-menu-bar gnus-article-make-menu-bar
2042 gnus-browse-make-menu-bar gnus-highlight-selected-summary
2043 gnus-summary-highlight-line gnus-carpal-setup-buffer
2044 gnus-group-highlight-line
2045 gnus-article-add-button gnus-insert-next-page-button
2046 gnus-insert-prev-page-button gnus-visual-turn-off-edit-menu)
2047 ("gnus-vis" :interactive t
2048 gnus-article-push-button gnus-article-press-button
2049 gnus-article-highlight gnus-article-highlight-some
2050 gnus-article-highlight-headers gnus-article-highlight-signature
2051 gnus-article-add-buttons gnus-article-add-buttons-to-head
2052 gnus-article-next-button gnus-article-prev-button)
2053 ("gnus-demon" gnus-demon-add-nocem gnus-demon-add-scanmail
2054 gnus-demon-add-disconnection gnus-demon-add-handler
2055 gnus-demon-remove-handler)
2056 ("gnus-demon" :interactive t
2057 gnus-demon-init gnus-demon-cancel)
2058 ("gnus-salt" gnus-highlight-selected-tree gnus-possibly-generate-tree
2059 gnus-tree-open gnus-tree-close)
2060 ("gnus-nocem" gnus-nocem-scan-groups gnus-nocem-close
2061 gnus-nocem-unwanted-article-p)
2062 ("gnus-srvr" gnus-enter-server-buffer gnus-server-set-info)
2063 ("gnus-srvr" gnus-browse-foreign-server)
2064 ("gnus-cite" :interactive t
2065 gnus-article-highlight-citation gnus-article-hide-citation-maybe
2066 gnus-article-hide-citation gnus-article-fill-cited-article
2067 gnus-article-hide-citation-in-followups)
2068 ("gnus-kill" gnus-kill gnus-apply-kill-file-internal
2069 gnus-kill-file-edit-file gnus-kill-file-raise-followups-to-author
2070 gnus-execute gnus-expunge)
2071 ("gnus-cache" gnus-cache-possibly-enter-article gnus-cache-save-buffers
2072 gnus-cache-possibly-remove-articles gnus-cache-request-article
2073 gnus-cache-retrieve-headers gnus-cache-possibly-alter-active
2074 gnus-cache-enter-remove-article gnus-cached-article-p
2075 gnus-cache-open gnus-cache-close gnus-cache-update-article)
2076 ("gnus-cache" :interactive t gnus-jog-cache gnus-cache-enter-article
2077 gnus-cache-remove-article)
2078 ("gnus-score" :interactive t
2079 gnus-summary-increase-score gnus-summary-lower-score
2080 gnus-score-flush-cache gnus-score-close
2081 gnus-score-raise-same-subject-and-select
2082 gnus-score-raise-same-subject gnus-score-default
2083 gnus-score-raise-thread gnus-score-lower-same-subject-and-select
2084 gnus-score-lower-same-subject gnus-score-lower-thread
2085 gnus-possibly-score-headers gnus-summary-raise-score
2086 gnus-summary-set-score gnus-summary-current-score)
2087 ("gnus-score"
2088 (gnus-summary-score-map keymap) gnus-score-save gnus-score-headers
2089 gnus-current-score-file-nondirectory gnus-score-adaptive
2090 gnus-score-find-trace gnus-score-file-name)
2091 ("gnus-edit" :interactive t gnus-score-customize)
2092 ("gnus-topic" :interactive t gnus-topic-mode)
2093 ("gnus-topic" gnus-topic-remove-group)
2094 ("gnus-salt" :interactive t gnus-pick-mode gnus-binary-mode)
2095 ("gnus-uu" (gnus-uu-extract-map keymap) (gnus-uu-mark-map keymap))
2096 ("gnus-uu" :interactive t
2097 gnus-uu-digest-mail-forward gnus-uu-digest-post-forward
2098 gnus-uu-mark-series gnus-uu-mark-region gnus-uu-mark-buffer
2099 gnus-uu-mark-by-regexp gnus-uu-mark-all
2100 gnus-uu-mark-sparse gnus-uu-mark-thread gnus-uu-decode-uu
2101 gnus-uu-decode-uu-and-save gnus-uu-decode-unshar
2102 gnus-uu-decode-unshar-and-save gnus-uu-decode-save
2103 gnus-uu-decode-binhex gnus-uu-decode-uu-view
2104 gnus-uu-decode-uu-and-save-view gnus-uu-decode-unshar-view
2105 gnus-uu-decode-unshar-and-save-view gnus-uu-decode-save-view
2106 gnus-uu-decode-binhex-view)
2107 ("gnus-msg" (gnus-summary-send-map keymap)
2108 gnus-mail-yank-original gnus-mail-send-and-exit
2109 gnus-article-mail gnus-new-mail gnus-mail-reply)
2110 ("gnus-msg" :interactive t
2111 gnus-group-post-news gnus-group-mail gnus-summary-post-news
2112 gnus-summary-followup gnus-summary-followup-with-original
2113 gnus-summary-cancel-article gnus-summary-supersede-article
2114 gnus-post-news gnus-inews-news
2115 gnus-summary-reply gnus-summary-reply-with-original
2116 gnus-summary-mail-forward gnus-summary-mail-other-window
2117 gnus-bug)
2118 ("gnus-picon" :interactive t gnus-article-display-picons
2119 gnus-group-display-picons gnus-picons-article-display-x-face
2120 gnus-picons-display-x-face)
2121 ("gnus-gl" bbb-login bbb-logout bbb-grouplens-group-p
2122 gnus-grouplens-mode)
2123 ("smiley" :interactive t gnus-smiley-display)
2124 ("gnus-vm" gnus-vm-mail-setup)
2125 ("gnus-vm" :interactive t gnus-summary-save-in-vm
2126 gnus-summary-save-article-vm))))
2130 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2131 ;; If you want the cursor to go somewhere else, set these two
2132 ;; functions in some startup hook to whatever you want.
2133 (defalias 'gnus-summary-position-point 'gnus-goto-colon)
2134 (defalias 'gnus-group-position-point 'gnus-goto-colon)
2136 ;;; Various macros and substs.
2138 (defun gnus-header-from (header)
2139 (mail-header-from header))
2141 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
2142 "Pop to BUFFER, evaluate FORMS, and then return to the original window."
2143 (let ((tempvar (make-symbol "GnusStartBufferWindow"))
2144 (w (make-symbol "w"))
2145 (buf (make-symbol "buf")))
2146 `(let* ((,tempvar (selected-window))
2147 (,buf ,buffer)
2148 (,w (get-buffer-window ,buf 'visible)))
2149 (unwind-protect
2150 (progn
2151 (if ,w
2152 (select-window ,w)
2153 (pop-to-buffer ,buf))
2154 ,@forms)
2155 (select-window ,tempvar)))))
2157 (put 'gnus-eval-in-buffer-window 'lisp-indent-function 1)
2158 (put 'gnus-eval-in-buffer-window 'lisp-indent-hook 1)
2159 (put 'gnus-eval-in-buffer-window 'edebug-form-spec '(form body))
2161 (defmacro gnus-gethash (string hashtable)
2162 "Get hash value of STRING in HASHTABLE."
2163 `(symbol-value (intern-soft ,string ,hashtable)))
2165 (defmacro gnus-sethash (string value hashtable)
2166 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2167 `(set (intern ,string ,hashtable) ,value))
2169 (defmacro gnus-intern-safe (string hashtable)
2170 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2171 `(let ((symbol (intern ,string ,hashtable)))
2172 (or (boundp symbol)
2173 (set symbol nil))
2174 symbol))
2176 (defmacro gnus-group-unread (group)
2177 "Get the currently computed number of unread articles in GROUP."
2178 `(car (gnus-gethash ,group gnus-newsrc-hashtb)))
2180 (defmacro gnus-group-entry (group)
2181 "Get the newsrc entry for GROUP."
2182 `(gnus-gethash ,group gnus-newsrc-hashtb))
2184 (defmacro gnus-active (group)
2185 "Get active info on GROUP."
2186 `(gnus-gethash ,group gnus-active-hashtb))
2188 (defmacro gnus-set-active (group active)
2189 "Set GROUP's active info."
2190 `(gnus-sethash ,group ,active gnus-active-hashtb))
2192 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2193 ;; function `substring' might cut on a middle of multi-octet
2194 ;; character.
2195 (defun gnus-truncate-string (str width)
2196 (substring str 0 width))
2198 ;; Added by Geoffrey T. Dairiki <dairiki@u.washington.edu>. A safe way
2199 ;; to limit the length of a string. This function is necessary since
2200 ;; `(substr "abc" 0 30)' pukes with "Args out of range".
2201 (defsubst gnus-limit-string (str width)
2202 (if (> (length str) width)
2203 (substring str 0 width)
2204 str))
2206 (defsubst gnus-simplify-subject-re (subject)
2207 "Remove \"Re:\" from subject lines."
2208 (if (string-match "^[Rr][Ee]: *" subject)
2209 (substring subject (match-end 0))
2210 subject))
2212 (defsubst gnus-functionp (form)
2213 "Return non-nil if FORM is funcallable."
2214 (or (and (symbolp form) (fboundp form))
2215 (and (listp form) (eq (car form) 'lambda))))
2217 (defsubst gnus-goto-char (point)
2218 (and point (goto-char point)))
2220 (defmacro gnus-buffer-exists-p (buffer)
2221 `(let ((buffer ,buffer))
2222 (and buffer
2223 (funcall (if (stringp buffer) 'get-buffer 'buffer-name)
2224 buffer))))
2226 (defmacro gnus-kill-buffer (buffer)
2227 `(let ((buf ,buffer))
2228 (if (gnus-buffer-exists-p buf)
2229 (kill-buffer buf))))
2231 (defsubst gnus-point-at-bol ()
2232 "Return point at the beginning of the line."
2233 (let ((p (point)))
2234 (beginning-of-line)
2235 (prog1
2236 (point)
2237 (goto-char p))))
2239 (defsubst gnus-point-at-eol ()
2240 "Return point at the end of the line."
2241 (let ((p (point)))
2242 (end-of-line)
2243 (prog1
2244 (point)
2245 (goto-char p))))
2247 (defun gnus-alive-p ()
2248 "Say whether Gnus is running or not."
2249 (and gnus-group-buffer
2250 (get-buffer gnus-group-buffer)))
2252 (defun gnus-delete-first (elt list)
2253 "Delete by side effect the first occurrence of ELT as a member of LIST."
2254 (if (equal (car list) elt)
2255 (cdr list)
2256 (let ((total list))
2257 (while (and (cdr list)
2258 (not (equal (cadr list) elt)))
2259 (setq list (cdr list)))
2260 (when (cdr list)
2261 (setcdr list (cddr list)))
2262 total)))
2264 ;; Delete the current line (and the next N lines.);
2265 (defmacro gnus-delete-line (&optional n)
2266 `(delete-region (progn (beginning-of-line) (point))
2267 (progn (forward-line ,(or n 1)) (point))))
2269 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
2270 (defvar gnus-init-inhibit nil)
2271 (defun gnus-read-init-file (&optional inhibit-next)
2272 (if gnus-init-inhibit
2273 (setq gnus-init-inhibit nil)
2274 (setq gnus-init-inhibit inhibit-next)
2275 (and gnus-init-file
2276 (or (and (file-exists-p gnus-init-file)
2277 ;; Don't try to load a directory.
2278 (not (file-directory-p gnus-init-file)))
2279 (file-exists-p (concat gnus-init-file ".el"))
2280 (file-exists-p (concat gnus-init-file ".elc")))
2281 (condition-case var
2282 (load gnus-init-file nil t)
2283 (error
2284 (error "Error in %s: %s" gnus-init-file var))))))
2286 ;; Info access macros.
2288 (defmacro gnus-info-group (info)
2289 `(nth 0 ,info))
2290 (defmacro gnus-info-rank (info)
2291 `(nth 1 ,info))
2292 (defmacro gnus-info-read (info)
2293 `(nth 2 ,info))
2294 (defmacro gnus-info-marks (info)
2295 `(nth 3 ,info))
2296 (defmacro gnus-info-method (info)
2297 `(nth 4 ,info))
2298 (defmacro gnus-info-params (info)
2299 `(nth 5 ,info))
2301 (defmacro gnus-info-level (info)
2302 `(let ((rank (gnus-info-rank ,info)))
2303 (if (consp rank)
2304 (car rank)
2305 rank)))
2306 (defmacro gnus-info-score (info)
2307 `(let ((rank (gnus-info-rank ,info)))
2308 (or (and (consp rank) (cdr rank)) 0)))
2310 (defmacro gnus-info-set-group (info group)
2311 `(setcar ,info ,group))
2312 (defmacro gnus-info-set-rank (info rank)
2313 `(setcar (nthcdr 1 ,info) ,rank))
2314 (defmacro gnus-info-set-read (info read)
2315 `(setcar (nthcdr 2 ,info) ,read))
2316 (defmacro gnus-info-set-marks (info marks)
2317 `(setcar (nthcdr 3 ,info) ,marks))
2318 (defmacro gnus-info-set-method (info method)
2319 `(setcar (nthcdr 4 ,info) ,method))
2320 (defmacro gnus-info-set-params (info params)
2321 `(setcar (nthcdr 5 ,info) ,params))
2323 (defmacro gnus-info-set-level (info level)
2324 `(let ((rank (cdr ,info)))
2325 (if (consp (car rank))
2326 (setcar (car rank) ,level)
2327 (setcar rank ,level))))
2328 (defmacro gnus-info-set-score (info score)
2329 `(let ((rank (cdr ,info)))
2330 (if (consp (car rank))
2331 (setcdr (car rank) ,score)
2332 (setcar rank (cons (car rank) ,score)))))
2334 (defmacro gnus-get-info (group)
2335 `(nth 2 (gnus-gethash ,group gnus-newsrc-hashtb)))
2337 (defun gnus-byte-code (func)
2338 "Return a form that can be `eval'ed based on FUNC."
2339 (let ((fval (symbol-function func)))
2340 (if (byte-code-function-p fval)
2341 (let ((flist (append fval nil)))
2342 (setcar flist 'byte-code)
2343 flist)
2344 (cons 'progn (cddr fval)))))
2346 ;; Find out whether the gnus-visual TYPE is wanted.
2347 (defun gnus-visual-p (&optional type class)
2348 (and gnus-visual ; Has to be non-nil, at least.
2349 (if (not type) ; We don't care about type.
2350 gnus-visual
2351 (if (listp gnus-visual) ; It's a list, so we check it.
2352 (or (memq type gnus-visual)
2353 (memq class gnus-visual))
2354 t))))
2356 ;;; Load the compatability functions.
2358 (require 'gnus-cus)
2359 (require 'gnus-ems)
2363 ;;; Shutdown
2366 (defvar gnus-shutdown-alist nil)
2368 (defun gnus-add-shutdown (function &rest symbols)
2369 "Run FUNCTION whenever one of SYMBOLS is shut down."
2370 (push (cons function symbols) gnus-shutdown-alist))
2372 (defun gnus-shutdown (symbol)
2373 "Shut down everything that waits for SYMBOL."
2374 (let ((alist gnus-shutdown-alist)
2375 entry)
2376 (while (setq entry (pop alist))
2377 (when (memq symbol (cdr entry))
2378 (funcall (car entry))))))
2382 ;; Format specs. The chunks below are the machine-generated forms
2383 ;; that are to be evaled as the result of the default format strings.
2384 ;; We write them in here to get them byte-compiled. That way the
2385 ;; default actions will be quite fast, while still retaining the full
2386 ;; flexibility of the user-defined format specs.
2388 ;; First we have lots of dummy defvars to let the compiler know these
2389 ;; are really dynamic variables.
2391 (defvar gnus-tmp-unread)
2392 (defvar gnus-tmp-replied)
2393 (defvar gnus-tmp-score-char)
2394 (defvar gnus-tmp-indentation)
2395 (defvar gnus-tmp-opening-bracket)
2396 (defvar gnus-tmp-lines)
2397 (defvar gnus-tmp-name)
2398 (defvar gnus-tmp-closing-bracket)
2399 (defvar gnus-tmp-subject-or-nil)
2400 (defvar gnus-tmp-subject)
2401 (defvar gnus-tmp-marked)
2402 (defvar gnus-tmp-marked-mark)
2403 (defvar gnus-tmp-subscribed)
2404 (defvar gnus-tmp-process-marked)
2405 (defvar gnus-tmp-number-of-unread)
2406 (defvar gnus-tmp-group-name)
2407 (defvar gnus-tmp-group)
2408 (defvar gnus-tmp-article-number)
2409 (defvar gnus-tmp-unread-and-unselected)
2410 (defvar gnus-tmp-news-method)
2411 (defvar gnus-tmp-news-server)
2412 (defvar gnus-tmp-article-number)
2413 (defvar gnus-mouse-face)
2414 (defvar gnus-mouse-face-prop)
2416 (defun gnus-summary-line-format-spec ()
2417 (insert gnus-tmp-unread gnus-tmp-replied
2418 gnus-tmp-score-char gnus-tmp-indentation)
2419 (gnus-put-text-property
2420 (point)
2421 (progn
2422 (insert
2423 gnus-tmp-opening-bracket
2424 (format "%4d: %-20s"
2425 gnus-tmp-lines
2426 (if (> (length gnus-tmp-name) 20)
2427 (substring gnus-tmp-name 0 20)
2428 gnus-tmp-name))
2429 gnus-tmp-closing-bracket)
2430 (point))
2431 gnus-mouse-face-prop gnus-mouse-face)
2432 (insert " " gnus-tmp-subject-or-nil "\n"))
2434 (defvar gnus-summary-line-format-spec
2435 (gnus-byte-code 'gnus-summary-line-format-spec))
2437 (defun gnus-summary-dummy-line-format-spec ()
2438 (insert "* ")
2439 (gnus-put-text-property
2440 (point)
2441 (progn
2442 (insert ": :")
2443 (point))
2444 gnus-mouse-face-prop gnus-mouse-face)
2445 (insert " " gnus-tmp-subject "\n"))
2447 (defvar gnus-summary-dummy-line-format-spec
2448 (gnus-byte-code 'gnus-summary-dummy-line-format-spec))
2450 (defun gnus-group-line-format-spec ()
2451 (insert gnus-tmp-marked-mark gnus-tmp-subscribed
2452 gnus-tmp-process-marked
2453 gnus-group-indentation
2454 (format "%5s: " gnus-tmp-number-of-unread))
2455 (gnus-put-text-property
2456 (point)
2457 (progn
2458 (insert gnus-tmp-group "\n")
2459 (1- (point)))
2460 gnus-mouse-face-prop gnus-mouse-face))
2461 (defvar gnus-group-line-format-spec
2462 (gnus-byte-code 'gnus-group-line-format-spec))
2464 (defvar gnus-format-specs
2465 `((version . ,emacs-version)
2466 (group ,gnus-group-line-format ,gnus-group-line-format-spec)
2467 (summary-dummy ,gnus-summary-dummy-line-format
2468 ,gnus-summary-dummy-line-format-spec)
2469 (summary ,gnus-summary-line-format ,gnus-summary-line-format-spec)))
2471 (defvar gnus-article-mode-line-format-spec nil)
2472 (defvar gnus-summary-mode-line-format-spec nil)
2473 (defvar gnus-group-mode-line-format-spec nil)
2475 ;;; Phew. All that gruft is over, fortunately.
2479 ;;; Gnus Utility Functions
2482 (defun gnus-extract-address-components (from)
2483 (let (name address)
2484 ;; First find the address - the thing with the @ in it. This may
2485 ;; not be accurate in mail addresses, but does the trick most of
2486 ;; the time in news messages.
2487 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
2488 (setq address (substring from (match-beginning 0) (match-end 0))))
2489 ;; Then we check whether the "name <address>" format is used.
2490 (and address
2491 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2492 ;; Linear white space is not required.
2493 (string-match (concat "[ \t]*<" (regexp-quote address) ">") from)
2494 (and (setq name (substring from 0 (match-beginning 0)))
2495 ;; Strip any quotes from the name.
2496 (string-match "\".*\"" name)
2497 (setq name (substring name 1 (1- (match-end 0))))))
2498 ;; If not, then "address (name)" is used.
2499 (or name
2500 (and (string-match "(.+)" from)
2501 (setq name (substring from (1+ (match-beginning 0))
2502 (1- (match-end 0)))))
2503 (and (string-match "()" from)
2504 (setq name address))
2505 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>.
2506 ;; XOVER might not support folded From headers.
2507 (and (string-match "(.*" from)
2508 (setq name (substring from (1+ (match-beginning 0))
2509 (match-end 0)))))
2510 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2511 (list (or name from) (or address from))))
2513 (defun gnus-fetch-field (field)
2514 "Return the value of the header FIELD of current article."
2515 (save-excursion
2516 (save-restriction
2517 (let ((case-fold-search t)
2518 (inhibit-point-motion-hooks t))
2519 (nnheader-narrow-to-headers)
2520 (message-fetch-field field)))))
2522 (defun gnus-goto-colon ()
2523 (beginning-of-line)
2524 (search-forward ":" (gnus-point-at-eol) t))
2526 ;;;###autoload
2527 (defun gnus-update-format (var)
2528 "Update the format specification near point."
2529 (interactive
2530 (list
2531 (save-excursion
2532 (eval-defun nil)
2533 ;; Find the end of the current word.
2534 (re-search-forward "[ \t\n]" nil t)
2535 ;; Search backward.
2536 (when (re-search-backward "\\(gnus-[-a-z]+-line-format\\)" nil t)
2537 (match-string 1)))))
2538 (let* ((type (intern (progn (string-match "gnus-\\([-a-z]+\\)-line" var)
2539 (match-string 1 var))))
2540 (entry (assq type gnus-format-specs))
2541 value spec)
2542 (when entry
2543 (setq gnus-format-specs (delq entry gnus-format-specs)))
2544 (set
2545 (intern (format "%s-spec" var))
2546 (gnus-parse-format (setq value (symbol-value (intern var)))
2547 (symbol-value (intern (format "%s-alist" var)))
2548 (not (string-match "mode" var))))
2549 (setq spec (symbol-value (intern (format "%s-spec" var))))
2550 (push (list type value spec) gnus-format-specs)
2552 (pop-to-buffer "*Gnus Format*")
2553 (erase-buffer)
2554 (lisp-interaction-mode)
2555 (insert (pp-to-string spec))))
2557 (defun gnus-update-format-specifications (&optional force)
2558 "Update all (necessary) format specifications."
2559 ;; Make the indentation array.
2560 (gnus-make-thread-indent-array)
2562 ;; See whether all the stored info needs to be flushed.
2563 (when (or force
2564 (not (equal emacs-version
2565 (cdr (assq 'version gnus-format-specs)))))
2566 (setq gnus-format-specs nil))
2568 ;; Go through all the formats and see whether they need updating.
2569 (let ((types '(summary summary-dummy group
2570 summary-mode group-mode article-mode))
2571 new-format entry type val)
2572 (while (setq type (pop types))
2573 ;; Jump to the proper buffer to find out the value of
2574 ;; the variable, if possible. (It may be buffer-local.)
2575 (save-excursion
2576 (let ((buffer (intern (format "gnus-%s-buffer" type)))
2577 val)
2578 (when (and (boundp buffer)
2579 (setq val (symbol-value buffer))
2580 (get-buffer val)
2581 (buffer-name (get-buffer val)))
2582 (set-buffer (get-buffer val)))
2583 (setq new-format (symbol-value
2584 (intern (format "gnus-%s-line-format" type))))))
2585 (setq entry (cdr (assq type gnus-format-specs)))
2586 (if (and entry
2587 (equal (car entry) new-format))
2588 ;; Use the old format.
2589 (set (intern (format "gnus-%s-line-format-spec" type))
2590 (cadr entry))
2591 ;; This is a new format.
2592 (setq val
2593 (if (not (stringp new-format))
2594 ;; This is a function call or something.
2595 new-format
2596 ;; This is a "real" format.
2597 (gnus-parse-format
2598 new-format
2599 (symbol-value
2600 (intern (format "gnus-%s-line-format-alist"
2601 (if (eq type 'article-mode)
2602 'summary-mode type))))
2603 (not (string-match "mode$" (symbol-name type))))))
2604 ;; Enter the new format spec into the list.
2605 (if entry
2606 (progn
2607 (setcar (cdr entry) val)
2608 (setcar entry new-format))
2609 (push (list type new-format val) gnus-format-specs))
2610 (set (intern (format "gnus-%s-line-format-spec" type)) val))))
2612 (unless (assq 'version gnus-format-specs)
2613 (push (cons 'version emacs-version) gnus-format-specs))
2615 (gnus-update-group-mark-positions)
2616 (gnus-update-summary-mark-positions))
2618 (defun gnus-update-summary-mark-positions ()
2619 "Compute where the summary marks are to go."
2620 (save-excursion
2621 (when (and gnus-summary-buffer
2622 (get-buffer gnus-summary-buffer)
2623 (buffer-name (get-buffer gnus-summary-buffer)))
2624 (set-buffer gnus-summary-buffer))
2625 (let ((gnus-replied-mark 129)
2626 (gnus-score-below-mark 130)
2627 (gnus-score-over-mark 130)
2628 (thread nil)
2629 (gnus-visual nil)
2630 (spec gnus-summary-line-format-spec)
2631 pos)
2632 (save-excursion
2633 (gnus-set-work-buffer)
2634 (let ((gnus-summary-line-format-spec spec))
2635 (gnus-summary-insert-line
2636 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2637 (goto-char (point-min))
2638 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2639 (- (point) 2)))))
2640 (goto-char (point-min))
2641 (push (cons 'replied (and (search-forward "\201" nil t)
2642 (- (point) 2)))
2643 pos)
2644 (goto-char (point-min))
2645 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2646 pos)))
2647 (setq gnus-summary-mark-positions pos))))
2649 (defun gnus-update-group-mark-positions ()
2650 (save-excursion
2651 (let ((gnus-process-mark 128)
2652 (gnus-group-marked '("dummy.group"))
2653 (gnus-active-hashtb (make-vector 10 0)))
2654 (gnus-set-active "dummy.group" '(0 . 0))
2655 (gnus-set-work-buffer)
2656 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
2657 (goto-char (point-min))
2658 (setq gnus-group-mark-positions
2659 (list (cons 'process (and (search-forward "\200" nil t)
2660 (- (point) 2))))))))
2662 (defvar gnus-mouse-face-0 'highlight)
2663 (defvar gnus-mouse-face-1 'highlight)
2664 (defvar gnus-mouse-face-2 'highlight)
2665 (defvar gnus-mouse-face-3 'highlight)
2666 (defvar gnus-mouse-face-4 'highlight)
2668 (defun gnus-mouse-face-function (form type)
2669 `(gnus-put-text-property
2670 (point) (progn ,@form (point))
2671 gnus-mouse-face-prop
2672 ,(if (equal type 0)
2673 'gnus-mouse-face
2674 `(quote ,(symbol-value (intern (format "gnus-mouse-face-%d" type)))))))
2676 (defvar gnus-face-0 'bold)
2677 (defvar gnus-face-1 'italic)
2678 (defvar gnus-face-2 'bold-italic)
2679 (defvar gnus-face-3 'bold)
2680 (defvar gnus-face-4 'bold)
2682 (defun gnus-face-face-function (form type)
2683 `(gnus-put-text-property
2684 (point) (progn ,@form (point))
2685 'face ',(symbol-value (intern (format "gnus-face-%d" type)))))
2687 (defun gnus-max-width-function (el max-width)
2688 (or (numberp max-width) (signal 'wrong-type-argument '(numberp max-width)))
2689 (if (symbolp el)
2690 `(if (> (length ,el) ,max-width)
2691 (substring ,el 0 ,max-width)
2692 ,el)
2693 `(let ((val (eval ,el)))
2694 (if (numberp val)
2695 (setq val (int-to-string val)))
2696 (if (> (length val) ,max-width)
2697 (substring val 0 ,max-width)
2698 val))))
2700 (defun gnus-parse-format (format spec-alist &optional insert)
2701 ;; This function parses the FORMAT string with the help of the
2702 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
2703 ;; string. If the FORMAT string contains the specifiers %( and %)
2704 ;; the text between them will have the mouse-face text property.
2705 (if (string-match
2706 "\\`\\(.*\\)%[0-9]?[{(]\\(.*\\)%[0-9]?[})]\\(.*\n?\\)\\'"
2707 format)
2708 (gnus-parse-complex-format format spec-alist)
2709 ;; This is a simple format.
2710 (gnus-parse-simple-format format spec-alist insert)))
2712 (defun gnus-parse-complex-format (format spec-alist)
2713 (save-excursion
2714 (gnus-set-work-buffer)
2715 (insert format)
2716 (goto-char (point-min))
2717 (while (re-search-forward "\"" nil t)
2718 (replace-match "\\\"" nil t))
2719 (goto-char (point-min))
2720 (insert "(\"")
2721 (while (re-search-forward "%\\([0-9]+\\)?\\([{}()]\\)" nil t)
2722 (let ((number (if (match-beginning 1)
2723 (match-string 1) "0"))
2724 (delim (aref (match-string 2) 0)))
2725 (if (or (= delim ?\() (= delim ?\{))
2726 (replace-match (concat "\"(" (if (= delim ?\() "mouse" "face")
2727 " " number " \""))
2728 (replace-match "\")\""))))
2729 (goto-char (point-max))
2730 (insert "\")")
2731 (goto-char (point-min))
2732 (let ((form (read (current-buffer))))
2733 (cons 'progn (gnus-complex-form-to-spec form spec-alist)))))
2735 (defun gnus-complex-form-to-spec (form spec-alist)
2736 (delq nil
2737 (mapcar
2738 (lambda (sform)
2739 (if (stringp sform)
2740 (gnus-parse-simple-format sform spec-alist t)
2741 (funcall (intern (format "gnus-%s-face-function" (car sform)))
2742 (gnus-complex-form-to-spec (cddr sform) spec-alist)
2743 (nth 1 sform))))
2744 form)))
2746 (defun gnus-parse-simple-format (format spec-alist &optional insert)
2747 ;; This function parses the FORMAT string with the help of the
2748 ;; SPEC-ALIST and returns a list that can be eval'ed to return a
2749 ;; string.
2750 (let ((max-width 0)
2751 spec flist fstring newspec elem beg result dontinsert)
2752 (save-excursion
2753 (gnus-set-work-buffer)
2754 (insert format)
2755 (goto-char (point-min))
2756 (while (re-search-forward "%[-0-9]*\\(,[0-9]+\\)?\\([^0-9]\\)\\(.\\)?"
2757 nil t)
2758 (if (= (setq spec (string-to-char (match-string 2))) ?%)
2759 (setq newspec "%"
2760 beg (1+ (match-beginning 0)))
2761 ;; First check if there are any specs that look anything like
2762 ;; "%12,12A", ie. with a "max width specification". These have
2763 ;; to be treated specially.
2764 (if (setq beg (match-beginning 1))
2765 (setq max-width
2766 (string-to-int
2767 (buffer-substring
2768 (1+ (match-beginning 1)) (match-end 1))))
2769 (setq max-width 0)
2770 (setq beg (match-beginning 2)))
2771 ;; Find the specification from `spec-alist'.
2772 (unless (setq elem (cdr (assq spec spec-alist)))
2773 (setq elem '("*" ?s)))
2774 ;; Treat user defined format specifiers specially.
2775 (when (eq (car elem) 'gnus-tmp-user-defined)
2776 (setq elem
2777 (list
2778 (list (intern (concat "gnus-user-format-function-"
2779 (match-string 3)))
2780 'gnus-tmp-header) ?s))
2781 (delete-region (match-beginning 3) (match-end 3)))
2782 (if (not (zerop max-width))
2783 (let ((el (car elem)))
2784 (cond ((= (cadr elem) ?c)
2785 (setq el (list 'char-to-string el)))
2786 ((= (cadr elem) ?d)
2787 (setq el (list 'int-to-string el))))
2788 (setq flist (cons (gnus-max-width-function el max-width)
2789 flist))
2790 (setq newspec ?s))
2791 (progn
2792 (setq flist (cons (car elem) flist))
2793 (setq newspec (cadr elem)))))
2794 ;; Remove the old specification (and possibly a ",12" string).
2795 (delete-region beg (match-end 2))
2796 ;; Insert the new specification.
2797 (goto-char beg)
2798 (insert newspec))
2799 (setq fstring (buffer-substring 1 (point-max))))
2800 ;; Do some postprocessing to increase efficiency.
2801 (setq
2802 result
2803 (cond
2804 ;; Emptyness.
2805 ((string= fstring "")
2806 nil)
2807 ;; Not a format string.
2808 ((not (string-match "%" fstring))
2809 (list fstring))
2810 ;; A format string with just a single string spec.
2811 ((string= fstring "%s")
2812 (list (car flist)))
2813 ;; A single character.
2814 ((string= fstring "%c")
2815 (list (car flist)))
2816 ;; A single number.
2817 ((string= fstring "%d")
2818 (setq dontinsert)
2819 (if insert
2820 (list `(princ ,(car flist)))
2821 (list `(int-to-string ,(car flist)))))
2822 ;; Just lots of chars and strings.
2823 ((string-match "\\`\\(%[cs]\\)+\\'" fstring)
2824 (nreverse flist))
2825 ;; A single string spec at the beginning of the spec.
2826 ((string-match "\\`%[sc][^%]+\\'" fstring)
2827 (list (car flist) (substring fstring 2)))
2828 ;; A single string spec in the middle of the spec.
2829 ((string-match "\\`\\([^%]+\\)%[sc]\\([^%]+\\)\\'" fstring)
2830 (list (match-string 1 fstring) (car flist) (match-string 2 fstring)))
2831 ;; A single string spec in the end of the spec.
2832 ((string-match "\\`\\([^%]+\\)%[sc]\\'" fstring)
2833 (list (match-string 1 fstring) (car flist)))
2834 ;; A more complex spec.
2836 (list (cons 'format (cons fstring (nreverse flist)))))))
2838 (if insert
2839 (when result
2840 (if dontinsert
2841 result
2842 (cons 'insert result)))
2843 (cond ((stringp result)
2844 result)
2845 ((consp result)
2846 (cons 'concat result))
2847 (t "")))))
2849 (defun gnus-eval-format (format &optional alist props)
2850 "Eval the format variable FORMAT, using ALIST.
2851 If PROPS, insert the result."
2852 (let ((form (gnus-parse-format format alist props)))
2853 (if props
2854 (gnus-add-text-properties (point) (progn (eval form) (point)) props)
2855 (eval form))))
2857 (defun gnus-remove-text-with-property (prop)
2858 "Delete all text in the current buffer with text property PROP."
2859 (save-excursion
2860 (goto-char (point-min))
2861 (while (not (eobp))
2862 (while (get-text-property (point) prop)
2863 (delete-char 1))
2864 (goto-char (next-single-property-change (point) prop nil (point-max))))))
2866 (defun gnus-set-work-buffer ()
2867 (if (get-buffer gnus-work-buffer)
2868 (progn
2869 (set-buffer gnus-work-buffer)
2870 (erase-buffer))
2871 (set-buffer (get-buffer-create gnus-work-buffer))
2872 (kill-all-local-variables)
2873 (buffer-disable-undo (current-buffer))
2874 (gnus-add-current-to-buffer-list)))
2876 ;; Article file names when saving.
2878 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2879 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2880 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
2881 Otherwise, it is like ~/News/news/group/num."
2882 (let ((default
2883 (expand-file-name
2884 (concat (if (gnus-use-long-file-name 'not-save)
2885 (gnus-capitalize-newsgroup newsgroup)
2886 (gnus-newsgroup-directory-form newsgroup))
2887 "/" (int-to-string (mail-header-number headers)))
2888 gnus-article-save-directory)))
2889 (if (and last-file
2890 (string-equal (file-name-directory default)
2891 (file-name-directory last-file))
2892 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2893 default
2894 (or last-file default))))
2896 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2897 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2898 If variable `gnus-use-long-file-name' is non-nil, it is
2899 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2900 (let ((default
2901 (expand-file-name
2902 (concat (if (gnus-use-long-file-name 'not-save)
2903 newsgroup
2904 (gnus-newsgroup-directory-form newsgroup))
2905 "/" (int-to-string (mail-header-number headers)))
2906 gnus-article-save-directory)))
2907 (if (and last-file
2908 (string-equal (file-name-directory default)
2909 (file-name-directory last-file))
2910 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2911 default
2912 (or last-file default))))
2914 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2915 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2916 If variable `gnus-use-long-file-name' is non-nil, it is
2917 ~/News/News.group. Otherwise, it is like ~/News/news/group/news."
2918 (or last-file
2919 (expand-file-name
2920 (if (gnus-use-long-file-name 'not-save)
2921 (gnus-capitalize-newsgroup newsgroup)
2922 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2923 gnus-article-save-directory)))
2925 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2926 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2927 If variable `gnus-use-long-file-name' is non-nil, it is
2928 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2929 (or last-file
2930 (expand-file-name
2931 (if (gnus-use-long-file-name 'not-save)
2932 newsgroup
2933 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2934 gnus-article-save-directory)))
2936 ;; For subscribing new newsgroup
2938 (defun gnus-subscribe-hierarchical-interactive (groups)
2939 (let ((groups (sort groups 'string<))
2940 prefixes prefix start ans group starts)
2941 (while groups
2942 (setq prefixes (list "^"))
2943 (while (and groups prefixes)
2944 (while (not (string-match (car prefixes) (car groups)))
2945 (setq prefixes (cdr prefixes)))
2946 (setq prefix (car prefixes))
2947 (setq start (1- (length prefix)))
2948 (if (and (string-match "[^\\.]\\." (car groups) start)
2949 (cdr groups)
2950 (setq prefix
2951 (concat "^" (substring (car groups) 0 (match-end 0))))
2952 (string-match prefix (cadr groups)))
2953 (progn
2954 (setq prefixes (cons prefix prefixes))
2955 (message "Descend hierarchy %s? ([y]nsq): "
2956 (substring prefix 1 (1- (length prefix))))
2957 (while (not (memq (setq ans (read-char)) '(?y ?\n ?n ?s ?q)))
2958 (ding)
2959 (message "Descend hierarchy %s? ([y]nsq): "
2960 (substring prefix 1 (1- (length prefix)))))
2961 (cond ((= ans ?n)
2962 (while (and groups
2963 (string-match prefix
2964 (setq group (car groups))))
2965 (setq gnus-killed-list
2966 (cons group gnus-killed-list))
2967 (gnus-sethash group group gnus-killed-hashtb)
2968 (setq groups (cdr groups)))
2969 (setq starts (cdr starts)))
2970 ((= ans ?s)
2971 (while (and groups
2972 (string-match prefix
2973 (setq group (car groups))))
2974 (gnus-sethash group group gnus-killed-hashtb)
2975 (gnus-subscribe-alphabetically (car groups))
2976 (setq groups (cdr groups)))
2977 (setq starts (cdr starts)))
2978 ((= ans ?q)
2979 (while groups
2980 (setq group (car groups))
2981 (setq gnus-killed-list (cons group gnus-killed-list))
2982 (gnus-sethash group group gnus-killed-hashtb)
2983 (setq groups (cdr groups))))
2984 (t nil)))
2985 (message "Subscribe %s? ([n]yq)" (car groups))
2986 (while (not (memq (setq ans (read-char)) '(?y ?\n ?q ?n)))
2987 (ding)
2988 (message "Subscribe %s? ([n]yq)" (car groups)))
2989 (setq group (car groups))
2990 (cond ((= ans ?y)
2991 (gnus-subscribe-alphabetically (car groups))
2992 (gnus-sethash group group gnus-killed-hashtb))
2993 ((= ans ?q)
2994 (while groups
2995 (setq group (car groups))
2996 (setq gnus-killed-list (cons group gnus-killed-list))
2997 (gnus-sethash group group gnus-killed-hashtb)
2998 (setq groups (cdr groups))))
3000 (setq gnus-killed-list (cons group gnus-killed-list))
3001 (gnus-sethash group group gnus-killed-hashtb)))
3002 (setq groups (cdr groups)))))))
3004 (defun gnus-subscribe-randomly (newsgroup)
3005 "Subscribe new NEWSGROUP by making it the first newsgroup."
3006 (gnus-subscribe-newsgroup newsgroup))
3008 (defun gnus-subscribe-alphabetically (newgroup)
3009 "Subscribe new NEWSGROUP and insert it in alphabetical order."
3010 (let ((groups (cdr gnus-newsrc-alist))
3011 before)
3012 (while (and (not before) groups)
3013 (if (string< newgroup (caar groups))
3014 (setq before (caar groups))
3015 (setq groups (cdr groups))))
3016 (gnus-subscribe-newsgroup newgroup before)))
3018 (defun gnus-subscribe-hierarchically (newgroup)
3019 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
3020 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
3021 (save-excursion
3022 (set-buffer (find-file-noselect gnus-current-startup-file))
3023 (let ((groupkey newgroup)
3024 before)
3025 (while (and (not before) groupkey)
3026 (goto-char (point-min))
3027 (let ((groupkey-re
3028 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
3029 (while (and (re-search-forward groupkey-re nil t)
3030 (progn
3031 (setq before (match-string 1))
3032 (string< before newgroup)))))
3033 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
3034 (setq groupkey
3035 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
3036 (substring groupkey (match-beginning 1) (match-end 1)))))
3037 (gnus-subscribe-newsgroup newgroup before))
3038 (kill-buffer (current-buffer))))
3040 (defun gnus-subscribe-interactively (group)
3041 "Subscribe the new GROUP interactively.
3042 It is inserted in hierarchical newsgroup order if subscribed. If not,
3043 it is killed."
3044 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " group))
3045 (gnus-subscribe-hierarchically group)
3046 (push group gnus-killed-list)))
3048 (defun gnus-subscribe-zombies (group)
3049 "Make the new GROUP into a zombie group."
3050 (push group gnus-zombie-list))
3052 (defun gnus-subscribe-killed (group)
3053 "Make the new GROUP a killed group."
3054 (push group gnus-killed-list))
3056 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
3057 "Subscribe new NEWSGROUP.
3058 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
3059 the first newsgroup."
3060 ;; We subscribe the group by changing its level to `subscribed'.
3061 (gnus-group-change-level
3062 newsgroup gnus-level-default-subscribed
3063 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
3064 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))
3066 ;; For directories
3068 (defun gnus-newsgroup-directory-form (newsgroup)
3069 "Make hierarchical directory name from NEWSGROUP name."
3070 (let ((newsgroup (gnus-newsgroup-savable-name newsgroup))
3071 (len (length newsgroup))
3072 idx)
3073 ;; If this is a foreign group, we don't want to translate the
3074 ;; entire name.
3075 (if (setq idx (string-match ":" newsgroup))
3076 (aset newsgroup idx ?/)
3077 (setq idx 0))
3078 ;; Replace all occurrences of `.' with `/'.
3079 (while (< idx len)
3080 (if (= (aref newsgroup idx) ?.)
3081 (aset newsgroup idx ?/))
3082 (setq idx (1+ idx)))
3083 newsgroup))
3085 (defun gnus-newsgroup-savable-name (group)
3086 ;; Replace any slashes in a group name (eg. an ange-ftp nndoc group)
3087 ;; with dots.
3088 (nnheader-replace-chars-in-string group ?/ ?.))
3090 (defun gnus-make-directory (dir)
3091 "Make DIRECTORY recursively."
3092 ;; Why don't we use `(make-directory dir 'parents)'? That's just one
3093 ;; of the many mysteries of the universe.
3094 (let* ((dir (expand-file-name dir default-directory))
3095 dirs err)
3096 (if (string-match "/$" dir)
3097 (setq dir (substring dir 0 (match-beginning 0))))
3098 ;; First go down the path until we find a directory that exists.
3099 (while (not (file-exists-p dir))
3100 (setq dirs (cons dir dirs))
3101 (string-match "/[^/]+$" dir)
3102 (setq dir (substring dir 0 (match-beginning 0))))
3103 ;; Then create all the subdirs.
3104 (while (and dirs (not err))
3105 (condition-case ()
3106 (make-directory (car dirs))
3107 (error (setq err t)))
3108 (setq dirs (cdr dirs)))
3109 ;; We return whether we were successful or not.
3110 (not dirs)))
3112 (defun gnus-capitalize-newsgroup (newsgroup)
3113 "Capitalize NEWSGROUP name."
3114 (and (not (zerop (length newsgroup)))
3115 (concat (char-to-string (upcase (aref newsgroup 0)))
3116 (substring newsgroup 1))))
3118 ;; Various... things.
3120 (defun gnus-simplify-subject (subject &optional re-only)
3121 "Remove `Re:' and words in parentheses.
3122 If RE-ONLY is non-nil, strip leading `Re:'s only."
3123 (let ((case-fold-search t)) ;Ignore case.
3124 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
3125 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
3126 (setq subject (substring subject (match-end 0))))
3127 ;; Remove uninteresting prefixes.
3128 (if (and (not re-only)
3129 gnus-simplify-ignored-prefixes
3130 (string-match gnus-simplify-ignored-prefixes subject))
3131 (setq subject (substring subject (match-end 0))))
3132 ;; Remove words in parentheses from end.
3133 (unless re-only
3134 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
3135 (setq subject (substring subject 0 (match-beginning 0)))))
3136 ;; Return subject string.
3137 subject))
3139 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
3140 ;; all whitespace.
3141 ;; Written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
3142 (defun gnus-simplify-buffer-fuzzy ()
3143 (let ((case-fold-search t))
3144 (goto-char (point-min))
3145 (while (search-forward "\t" nil t)
3146 (replace-match " " t t))
3147 (goto-char (point-min))
3148 (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *" nil t)
3149 (goto-char (match-beginning 0))
3150 (while (or
3151 (looking-at "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
3152 (looking-at "^[[].*: .*[]]$"))
3153 (goto-char (point-min))
3154 (while (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *"
3155 nil t)
3156 (replace-match "" t t))
3157 (goto-char (point-min))
3158 (while (re-search-forward "^[[].*: .*[]]$" nil t)
3159 (goto-char (match-end 0))
3160 (delete-char -1)
3161 (delete-region
3162 (progn (goto-char (match-beginning 0)))
3163 (re-search-forward ":"))))
3164 (goto-char (point-min))
3165 (while (re-search-forward " *[[{(][^()\n]*[]})] *$" nil t)
3166 (replace-match "" t t))
3167 (goto-char (point-min))
3168 (while (re-search-forward " +" nil t)
3169 (replace-match " " t t))
3170 (goto-char (point-min))
3171 (while (re-search-forward " $" nil t)
3172 (replace-match "" t t))
3173 (goto-char (point-min))
3174 (while (re-search-forward "^ +" nil t)
3175 (replace-match "" t t))
3176 (goto-char (point-min))
3177 (when gnus-simplify-subject-fuzzy-regexp
3178 (if (listp gnus-simplify-subject-fuzzy-regexp)
3179 (let ((list gnus-simplify-subject-fuzzy-regexp))
3180 (while list
3181 (goto-char (point-min))
3182 (while (re-search-forward (car list) nil t)
3183 (replace-match "" t t))
3184 (setq list (cdr list))))
3185 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
3186 (replace-match "" t t))))))
3188 (defun gnus-simplify-subject-fuzzy (subject)
3189 "Siplify a subject string fuzzily."
3190 (save-excursion
3191 (gnus-set-work-buffer)
3192 (let ((case-fold-search t))
3193 (insert subject)
3194 (inline (gnus-simplify-buffer-fuzzy))
3195 (buffer-string))))
3197 ;; Add the current buffer to the list of buffers to be killed on exit.
3198 (defun gnus-add-current-to-buffer-list ()
3199 (or (memq (current-buffer) gnus-buffer-list)
3200 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list))))
3202 (defun gnus-string> (s1 s2)
3203 (not (or (string< s1 s2)
3204 (string= s1 s2))))
3206 (defun gnus-read-active-file-p ()
3207 "Say whether the active file has been read from `gnus-select-method'."
3208 (memq gnus-select-method gnus-have-read-active-file))
3210 ;;; General various misc type functions.
3212 (defun gnus-clear-system ()
3213 "Clear all variables and buffers."
3214 ;; Clear Gnus variables.
3215 (let ((variables gnus-variable-list))
3216 (while variables
3217 (set (car variables) nil)
3218 (setq variables (cdr variables))))
3219 ;; Clear other internal variables.
3220 (setq gnus-list-of-killed-groups nil
3221 gnus-have-read-active-file nil
3222 gnus-newsrc-alist nil
3223 gnus-newsrc-hashtb nil
3224 gnus-killed-list nil
3225 gnus-zombie-list nil
3226 gnus-killed-hashtb nil
3227 gnus-active-hashtb nil
3228 gnus-moderated-list nil
3229 gnus-description-hashtb nil
3230 gnus-current-headers nil
3231 gnus-thread-indent-array nil
3232 gnus-newsgroup-headers nil
3233 gnus-newsgroup-name nil
3234 gnus-server-alist nil
3235 gnus-group-list-mode nil
3236 gnus-opened-servers nil
3237 gnus-group-mark-positions nil
3238 gnus-newsgroup-data nil
3239 gnus-newsgroup-unreads nil
3240 nnoo-state-alist nil
3241 gnus-current-select-method nil)
3242 (gnus-shutdown 'gnus)
3243 ;; Kill the startup file.
3244 (and gnus-current-startup-file
3245 (get-file-buffer gnus-current-startup-file)
3246 (kill-buffer (get-file-buffer gnus-current-startup-file)))
3247 ;; Clear the dribble buffer.
3248 (gnus-dribble-clear)
3249 ;; Kill global KILL file buffer.
3250 (when (get-file-buffer (gnus-newsgroup-kill-file nil))
3251 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
3252 (gnus-kill-buffer nntp-server-buffer)
3253 ;; Kill Gnus buffers.
3254 (while gnus-buffer-list
3255 (gnus-kill-buffer (pop gnus-buffer-list)))
3256 ;; Remove Gnus frames.
3257 (gnus-kill-gnus-frames))
3259 (defun gnus-kill-gnus-frames ()
3260 "Kill all frames Gnus has created."
3261 (while gnus-created-frames
3262 (when (frame-live-p (car gnus-created-frames))
3263 ;; We slap a condition-case around this `delete-frame' to ensure
3264 ;; against errors if we try do delete the single frame that's left.
3265 (condition-case ()
3266 (delete-frame (car gnus-created-frames))
3267 (error nil)))
3268 (pop gnus-created-frames)))
3270 (defun gnus-windows-old-to-new (setting)
3271 ;; First we take care of the really, really old Gnus 3 actions.
3272 (when (symbolp setting)
3273 (setq setting
3274 ;; Take care of ooold GNUS 3.x values.
3275 (cond ((eq setting 'SelectArticle) 'article)
3276 ((memq setting '(SelectSubject ExpandSubject)) 'summary)
3277 ((memq setting '(SelectNewsgroup ExitNewsgroup)) 'group)
3278 (t setting))))
3279 (if (or (listp setting)
3280 (not (and gnus-window-configuration
3281 (memq setting '(group summary article)))))
3282 setting
3283 (let* ((setting (if (eq setting 'group)
3284 (if (assq 'newsgroup gnus-window-configuration)
3285 'newsgroup
3286 'newsgroups) setting))
3287 (elem (cadr (assq setting gnus-window-configuration)))
3288 (total (apply '+ elem))
3289 (types '(group summary article))
3290 (pbuf (if (eq setting 'newsgroups) 'group 'summary))
3291 (i 0)
3292 perc
3293 out)
3294 (while (< i 3)
3295 (or (not (numberp (nth i elem)))
3296 (zerop (nth i elem))
3297 (progn
3298 (setq perc (if (= i 2)
3300 (/ (float (nth 0 elem)) total)))
3301 (setq out (cons (if (eq pbuf (nth i types))
3302 (list (nth i types) perc 'point)
3303 (list (nth i types) perc))
3304 out))))
3305 (setq i (1+ i)))
3306 `(vertical 1.0 ,@(nreverse out)))))
3308 ;;;###autoload
3309 (defun gnus-add-configuration (conf)
3310 "Add the window configuration CONF to `gnus-buffer-configuration'."
3311 (setq gnus-buffer-configuration
3312 (cons conf (delq (assq (car conf) gnus-buffer-configuration)
3313 gnus-buffer-configuration))))
3315 (defvar gnus-frame-list nil)
3317 (defun gnus-configure-frame (split &optional window)
3318 "Split WINDOW according to SPLIT."
3319 (unless window
3320 (setq window (get-buffer-window (current-buffer))))
3321 (select-window window)
3322 ;; This might be an old-stylee buffer config.
3323 (when (vectorp split)
3324 (setq split (append split nil)))
3325 (when (or (consp (car split))
3326 (vectorp (car split)))
3327 (push 1.0 split)
3328 (push 'vertical split))
3329 ;; The SPLIT might be something that is to be evaled to
3330 ;; return a new SPLIT.
3331 (while (and (not (assq (car split) gnus-window-to-buffer))
3332 (gnus-functionp (car split)))
3333 (setq split (eval split)))
3334 (let* ((type (car split))
3335 (subs (cddr split))
3336 (len (if (eq type 'horizontal) (window-width) (window-height)))
3337 (total 0)
3338 (window-min-width (or gnus-window-min-width window-min-width))
3339 (window-min-height (or gnus-window-min-height window-min-height))
3340 s result new-win rest comp-subs size sub)
3341 (cond
3342 ;; Nothing to do here.
3343 ((null split))
3344 ;; Don't switch buffers.
3345 ((null type)
3346 (and (memq 'point split) window))
3347 ;; This is a buffer to be selected.
3348 ((not (memq type '(frame horizontal vertical)))
3349 (let ((buffer (cond ((stringp type) type)
3350 (t (cdr (assq type gnus-window-to-buffer)))))
3351 buf)
3352 (unless buffer
3353 (error "Illegal buffer type: %s" type))
3354 (unless (setq buf (get-buffer (if (symbolp buffer)
3355 (symbol-value buffer) buffer)))
3356 (setq buf (get-buffer-create (if (symbolp buffer)
3357 (symbol-value buffer) buffer))))
3358 (switch-to-buffer buf)
3359 ;; We return the window if it has the `point' spec.
3360 (and (memq 'point split) window)))
3361 ;; This is a frame split.
3362 ((eq type 'frame)
3363 (unless gnus-frame-list
3364 (setq gnus-frame-list (list (window-frame
3365 (get-buffer-window (current-buffer))))))
3366 (let ((i 0)
3367 params frame fresult)
3368 (while (< i (length subs))
3369 ;; Frame parameter is gotten from the sub-split.
3370 (setq params (cadr (elt subs i)))
3371 ;; It should be a list.
3372 (unless (listp params)
3373 (setq params nil))
3374 ;; Create a new frame?
3375 (unless (setq frame (elt gnus-frame-list i))
3376 (nconc gnus-frame-list (list (setq frame (make-frame params))))
3377 (push frame gnus-created-frames))
3378 ;; Is the old frame still alive?
3379 (unless (frame-live-p frame)
3380 (setcar (nthcdr i gnus-frame-list)
3381 (setq frame (make-frame params))))
3382 ;; Select the frame in question and do more splits there.
3383 (select-frame frame)
3384 (setq fresult (or (gnus-configure-frame (elt subs i)) fresult))
3385 (incf i))
3386 ;; Select the frame that has the selected buffer.
3387 (when fresult
3388 (select-frame (window-frame fresult)))))
3389 ;; This is a normal split.
3391 (when (> (length subs) 0)
3392 ;; First we have to compute the sizes of all new windows.
3393 (while subs
3394 (setq sub (append (pop subs) nil))
3395 (while (and (not (assq (car sub) gnus-window-to-buffer))
3396 (gnus-functionp (car sub)))
3397 (setq sub (eval sub)))
3398 (when sub
3399 (push sub comp-subs)
3400 (setq size (cadar comp-subs))
3401 (cond ((equal size 1.0)
3402 (setq rest (car comp-subs))
3403 (setq s 0))
3404 ((floatp size)
3405 (setq s (floor (* size len))))
3406 ((integerp size)
3407 (setq s size))
3409 (error "Illegal size: %s" size)))
3410 ;; Try to make sure that we are inside the safe limits.
3411 (cond ((zerop s))
3412 ((eq type 'horizontal)
3413 (setq s (max s window-min-width)))
3414 ((eq type 'vertical)
3415 (setq s (max s window-min-height))))
3416 (setcar (cdar comp-subs) s)
3417 (incf total s)))
3418 ;; Take care of the "1.0" spec.
3419 (if rest
3420 (setcar (cdr rest) (- len total))
3421 (error "No 1.0 specs in %s" split))
3422 ;; The we do the actual splitting in a nice recursive
3423 ;; fashion.
3424 (setq comp-subs (nreverse comp-subs))
3425 (while comp-subs
3426 (if (null (cdr comp-subs))
3427 (setq new-win window)
3428 (setq new-win
3429 (split-window window (cadar comp-subs)
3430 (eq type 'horizontal))))
3431 (setq result (or (gnus-configure-frame
3432 (car comp-subs) window) result))
3433 (select-window new-win)
3434 (setq window new-win)
3435 (setq comp-subs (cdr comp-subs))))
3436 ;; Return the proper window, if any.
3437 (when result
3438 (select-window result))))))
3440 (defvar gnus-frame-split-p nil)
3442 (defun gnus-configure-windows (setting &optional force)
3443 (setq setting (gnus-windows-old-to-new setting))
3444 (let ((split (if (symbolp setting)
3445 (cadr (assq setting gnus-buffer-configuration))
3446 setting))
3447 all-visible)
3449 (setq gnus-frame-split-p nil)
3451 (unless split
3452 (error "No such setting: %s" setting))
3454 (if (and (setq all-visible (gnus-all-windows-visible-p split))
3455 (not force))
3456 ;; All the windows mentioned are already visible, so we just
3457 ;; put point in the assigned buffer, and do not touch the
3458 ;; winconf.
3459 (select-window all-visible)
3461 ;; Either remove all windows or just remove all Gnus windows.
3462 (let ((frame (selected-frame)))
3463 (unwind-protect
3464 (if gnus-use-full-window
3465 ;; We want to remove all other windows.
3466 (if (not gnus-frame-split-p)
3467 ;; This is not a `frame' split, so we ignore the
3468 ;; other frames.
3469 (delete-other-windows)
3470 ;; This is a `frame' split, so we delete all windows
3471 ;; on all frames.
3472 (mapcar
3473 (lambda (frame)
3474 (unless (eq (cdr (assq 'minibuffer
3475 (frame-parameters frame)))
3476 'only)
3477 (select-frame frame)
3478 (delete-other-windows)))
3479 (frame-list)))
3480 ;; Just remove some windows.
3481 (gnus-remove-some-windows)
3482 (switch-to-buffer nntp-server-buffer))
3483 (select-frame frame)))
3485 (switch-to-buffer nntp-server-buffer)
3486 (gnus-configure-frame split (get-buffer-window (current-buffer))))))
3488 (defun gnus-all-windows-visible-p (split)
3489 "Say whether all buffers in SPLIT are currently visible.
3490 In particular, the value returned will be the window that
3491 should have point."
3492 (let ((stack (list split))
3493 (all-visible t)
3494 type buffer win buf)
3495 (while (and (setq split (pop stack))
3496 all-visible)
3497 ;; Be backwards compatible.
3498 (when (vectorp split)
3499 (setq split (append split nil)))
3500 (when (or (consp (car split))
3501 (vectorp (car split)))
3502 (push 1.0 split)
3503 (push 'vertical split))
3504 ;; The SPLIT might be something that is to be evaled to
3505 ;; return a new SPLIT.
3506 (while (and (not (assq (car split) gnus-window-to-buffer))
3507 (gnus-functionp (car split)))
3508 (setq split (eval split)))
3510 (setq type (elt split 0))
3511 (cond
3512 ;; Nothing here.
3513 ((null split) t)
3514 ;; A buffer.
3515 ((not (memq type '(horizontal vertical frame)))
3516 (setq buffer (cond ((stringp type) type)
3517 (t (cdr (assq type gnus-window-to-buffer)))))
3518 (unless buffer
3519 (error "Illegal buffer type: %s" type))
3520 (when (setq buf (get-buffer (if (symbolp buffer)
3521 (symbol-value buffer)
3522 buffer)))
3523 (setq win (get-buffer-window buf t)))
3524 (if win
3525 (when (memq 'point split)
3526 (setq all-visible win))
3527 (setq all-visible nil)))
3529 (when (eq type 'frame)
3530 (setq gnus-frame-split-p t))
3531 (setq stack (append (cddr split) stack)))))
3532 (unless (eq all-visible t)
3533 all-visible)))
3535 (defun gnus-window-top-edge (&optional window)
3536 (nth 1 (window-edges window)))
3538 (defun gnus-remove-some-windows ()
3539 (let ((buffers gnus-window-to-buffer)
3540 buf bufs lowest-buf lowest)
3541 (save-excursion
3542 ;; Remove windows on all known Gnus buffers.
3543 (while buffers
3544 (setq buf (cdar buffers))
3545 (if (symbolp buf)
3546 (setq buf (and (boundp buf) (symbol-value buf))))
3547 (and buf
3548 (get-buffer-window buf)
3549 (progn
3550 (setq bufs (cons buf bufs))
3551 (pop-to-buffer buf)
3552 (if (or (not lowest)
3553 (< (gnus-window-top-edge) lowest))
3554 (progn
3555 (setq lowest (gnus-window-top-edge))
3556 (setq lowest-buf buf)))))
3557 (setq buffers (cdr buffers)))
3558 ;; Remove windows on *all* summary buffers.
3559 (walk-windows
3560 (lambda (win)
3561 (let ((buf (window-buffer win)))
3562 (if (string-match "^\\*Summary" (buffer-name buf))
3563 (progn
3564 (setq bufs (cons buf bufs))
3565 (pop-to-buffer buf)
3566 (if (or (not lowest)
3567 (< (gnus-window-top-edge) lowest))
3568 (progn
3569 (setq lowest-buf buf)
3570 (setq lowest (gnus-window-top-edge)))))))))
3571 (and lowest-buf
3572 (progn
3573 (pop-to-buffer lowest-buf)
3574 (switch-to-buffer nntp-server-buffer)))
3575 (while bufs
3576 (and (not (eq (car bufs) lowest-buf))
3577 (delete-windows-on (car bufs)))
3578 (setq bufs (cdr bufs))))))
3580 (defun gnus-version (&optional arg)
3581 "Version number of this version of Gnus.
3582 If ARG, insert string at point."
3583 (interactive "P")
3584 (let ((methods gnus-valid-select-methods)
3585 (mess gnus-version)
3586 meth)
3587 ;; Go through all the legal select methods and add their version
3588 ;; numbers to the total version string. Only the backends that are
3589 ;; currently in use will have their message numbers taken into
3590 ;; consideration.
3591 (while methods
3592 (setq meth (intern (concat (caar methods) "-version")))
3593 (and (boundp meth)
3594 (stringp (symbol-value meth))
3595 (setq mess (concat mess "; " (symbol-value meth))))
3596 (setq methods (cdr methods)))
3597 (if arg
3598 (insert (message mess))
3599 (message mess))))
3601 (defun gnus-info-find-node ()
3602 "Find Info documentation of Gnus."
3603 (interactive)
3604 ;; Enlarge info window if needed.
3605 (let ((mode major-mode)
3606 gnus-info-buffer)
3607 (Info-goto-node (cadr (assq mode gnus-info-nodes)))
3608 (setq gnus-info-buffer (current-buffer))
3609 (gnus-configure-windows 'info)))
3611 (defun gnus-days-between (date1 date2)
3612 ;; Return the number of days between date1 and date2.
3613 (- (gnus-day-number date1) (gnus-day-number date2)))
3615 (defun gnus-day-number (date)
3616 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
3617 (timezone-parse-date date))))
3618 (timezone-absolute-from-gregorian
3619 (nth 1 dat) (nth 2 dat) (car dat))))
3621 (defun gnus-encode-date (date)
3622 "Convert DATE to internal time."
3623 (let* ((parse (timezone-parse-date date))
3624 (date (mapcar (lambda (d) (and d (string-to-int d))) parse))
3625 (time (mapcar 'string-to-int (timezone-parse-time (aref parse 3)))))
3626 (encode-time (caddr time) (cadr time) (car time)
3627 (caddr date) (cadr date) (car date) (nth 4 date))))
3629 (defun gnus-time-minus (t1 t2)
3630 "Subtract two internal times."
3631 (let ((borrow (< (cadr t1) (cadr t2))))
3632 (list (- (car t1) (car t2) (if borrow 1 0))
3633 (- (+ (if borrow 65536 0) (cadr t1)) (cadr t2)))))
3635 (defun gnus-file-newer-than (file date)
3636 (let ((fdate (nth 5 (file-attributes file))))
3637 (or (> (car fdate) (car date))
3638 (and (= (car fdate) (car date))
3639 (> (nth 1 fdate) (nth 1 date))))))
3641 (defmacro gnus-local-set-keys (&rest plist)
3642 "Set the keys in PLIST in the current keymap."
3643 `(gnus-define-keys-1 (current-local-map) ',plist))
3645 (defmacro gnus-define-keys (keymap &rest plist)
3646 "Define all keys in PLIST in KEYMAP."
3647 `(gnus-define-keys-1 (quote ,keymap) (quote ,plist)))
3649 (put 'gnus-define-keys 'lisp-indent-function 1)
3650 (put 'gnus-define-keys 'lisp-indent-hook 1)
3651 (put 'gnus-define-keymap 'lisp-indent-function 1)
3652 (put 'gnus-define-keymap 'lisp-indent-hook 1)
3654 (defmacro gnus-define-keymap (keymap &rest plist)
3655 "Define all keys in PLIST in KEYMAP."
3656 `(gnus-define-keys-1 ,keymap (quote ,plist)))
3658 (defun gnus-define-keys-1 (keymap plist)
3659 (when (null keymap)
3660 (error "Can't set keys in a null keymap"))
3661 (cond ((symbolp keymap)
3662 (setq keymap (symbol-value keymap)))
3663 ((keymapp keymap))
3664 ((listp keymap)
3665 (set (car keymap) nil)
3666 (define-prefix-command (car keymap))
3667 (define-key (symbol-value (caddr keymap)) (cadr keymap) (car keymap))
3668 (setq keymap (symbol-value (car keymap)))))
3669 (let (key)
3670 (while plist
3671 (when (symbolp (setq key (pop plist)))
3672 (setq key (symbol-value key)))
3673 (define-key keymap key (pop plist)))))
3675 (defun gnus-group-read-only-p (&optional group)
3676 "Check whether GROUP supports editing or not.
3677 If GROUP is nil, `gnus-newsgroup-name' will be checked instead. Note
3678 that that variable is buffer-local to the summary buffers."
3679 (let ((group (or group gnus-newsgroup-name)))
3680 (not (gnus-check-backend-function 'request-replace-article group))))
3682 (defun gnus-group-total-expirable-p (group)
3683 "Check whether GROUP is total-expirable or not."
3684 (let ((params (gnus-info-params (gnus-get-info group))))
3685 (or (memq 'total-expire params)
3686 (cdr (assq 'total-expire params)) ; (total-expire . t)
3687 (and gnus-total-expirable-newsgroups ; Check var.
3688 (string-match gnus-total-expirable-newsgroups group)))))
3690 (defun gnus-group-auto-expirable-p (group)
3691 "Check whether GROUP is total-expirable or not."
3692 (let ((params (gnus-info-params (gnus-get-info group))))
3693 (or (memq 'auto-expire params)
3694 (cdr (assq 'auto-expire params)) ; (auto-expire . t)
3695 (and gnus-auto-expirable-newsgroups ; Check var.
3696 (string-match gnus-auto-expirable-newsgroups group)))))
3698 (defun gnus-virtual-group-p (group)
3699 "Say whether GROUP is virtual or not."
3700 (memq 'virtual (assoc (symbol-name (car (gnus-find-method-for-group group)))
3701 gnus-valid-select-methods)))
3703 (defun gnus-news-group-p (group &optional article)
3704 "Return non-nil if GROUP (and ARTICLE) come from a news server."
3705 (or (gnus-member-of-valid 'post group) ; Ordinary news group.
3706 (and (gnus-member-of-valid 'post-mail group) ; Combined group.
3707 (eq (gnus-request-type group article) 'news))))
3709 (defsubst gnus-simplify-subject-fully (subject)
3710 "Simplify a subject string according to the user's wishes."
3711 (cond
3712 ((null gnus-summary-gather-subject-limit)
3713 (gnus-simplify-subject-re subject))
3714 ((eq gnus-summary-gather-subject-limit 'fuzzy)
3715 (gnus-simplify-subject-fuzzy subject))
3716 ((numberp gnus-summary-gather-subject-limit)
3717 (gnus-limit-string (gnus-simplify-subject-re subject)
3718 gnus-summary-gather-subject-limit))
3720 subject)))
3722 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
3723 "Check whether two subjects are equal. If optional argument
3724 simple-first is t, first argument is already simplified."
3725 (cond
3726 ((null simple-first)
3727 (equal (gnus-simplify-subject-fully s1)
3728 (gnus-simplify-subject-fully s2)))
3730 (equal s1
3731 (gnus-simplify-subject-fully s2)))))
3733 ;; Returns a list of writable groups.
3734 (defun gnus-writable-groups ()
3735 (let ((alist gnus-newsrc-alist)
3736 groups group)
3737 (while (setq group (car (pop alist)))
3738 (unless (gnus-group-read-only-p group)
3739 (push group groups)))
3740 (nreverse groups)))
3742 (defun gnus-completing-read (default prompt &rest args)
3743 ;; Like `completing-read', except that DEFAULT is the default argument.
3744 (let* ((prompt (if default
3745 (concat prompt " (default " default ") ")
3746 (concat prompt " ")))
3747 (answer (apply 'completing-read prompt args)))
3748 (if (or (null answer) (zerop (length answer)))
3749 default
3750 answer)))
3752 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
3753 ;; the echo area.
3754 (defun gnus-y-or-n-p (prompt)
3755 (prog1
3756 (y-or-n-p prompt)
3757 (message "")))
3759 (defun gnus-yes-or-no-p (prompt)
3760 (prog1
3761 (yes-or-no-p prompt)
3762 (message "")))
3764 ;; Check whether to use long file names.
3765 (defun gnus-use-long-file-name (symbol)
3766 ;; The variable has to be set...
3767 (and gnus-use-long-file-name
3768 ;; If it isn't a list, then we return t.
3769 (or (not (listp gnus-use-long-file-name))
3770 ;; If it is a list, and the list contains `symbol', we
3771 ;; return nil.
3772 (not (memq symbol gnus-use-long-file-name)))))
3774 ;; I suspect there's a better way, but I haven't taken the time to do
3775 ;; it yet. -erik selberg@cs.washington.edu
3776 (defun gnus-dd-mmm (messy-date)
3777 "Return a string like DD-MMM from a big messy string"
3778 (let ((datevec (condition-case () (timezone-parse-date messy-date)
3779 (error nil))))
3780 (if (not datevec)
3781 "??-???"
3782 (format "%2s-%s"
3783 (condition-case ()
3784 ;; Make sure leading zeroes are stripped.
3785 (number-to-string (string-to-number (aref datevec 2)))
3786 (error "??"))
3787 (capitalize
3788 (or (car
3789 (nth (1- (string-to-number (aref datevec 1)))
3790 timezone-months-assoc))
3791 "???"))))))
3793 (defun gnus-mode-string-quote (string)
3794 "Quote all \"%\" in STRING."
3795 (save-excursion
3796 (gnus-set-work-buffer)
3797 (insert string)
3798 (goto-char (point-min))
3799 (while (search-forward "%" nil t)
3800 (insert "%"))
3801 (buffer-string)))
3803 ;; Make a hash table (default and minimum size is 255).
3804 ;; Optional argument HASHSIZE specifies the table size.
3805 (defun gnus-make-hashtable (&optional hashsize)
3806 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0))
3808 ;; Make a number that is suitable for hashing; bigger than MIN and one
3809 ;; less than 2^x.
3810 (defun gnus-create-hash-size (min)
3811 (let ((i 1))
3812 (while (< i min)
3813 (setq i (* 2 i)))
3814 (1- i)))
3816 ;; Show message if message has a lower level than `gnus-verbose'.
3817 ;; Guideline for numbers:
3818 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages
3819 ;; for things that take a long time, 7 - not very important messages
3820 ;; on stuff, 9 - messages inside loops.
3821 (defun gnus-message (level &rest args)
3822 (if (<= level gnus-verbose)
3823 (apply 'message args)
3824 ;; We have to do this format thingy here even if the result isn't
3825 ;; shown - the return value has to be the same as the return value
3826 ;; from `message'.
3827 (apply 'format args)))
3829 (defun gnus-error (level &rest args)
3830 "Beep an error if LEVEL is equal to or less than `gnus-verbose'."
3831 (when (<= (floor level) gnus-verbose)
3832 (apply 'message args)
3833 (ding)
3834 (let (duration)
3835 (when (and (floatp level)
3836 (not (zerop (setq duration (* 10 (- level (floor level)))))))
3837 (sit-for duration))))
3838 nil)
3840 ;; Generate a unique new group name.
3841 (defun gnus-generate-new-group-name (leaf)
3842 (let ((name leaf)
3843 (num 0))
3844 (while (gnus-gethash name gnus-newsrc-hashtb)
3845 (setq name (concat leaf "<" (int-to-string (setq num (1+ num))) ">")))
3846 name))
3848 (defsubst gnus-hide-text (b e props)
3849 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
3850 (gnus-add-text-properties b e props)
3851 (when (memq 'intangible props)
3852 (gnus-put-text-property (max (1- b) (point-min))
3853 b 'intangible (cddr (memq 'intangible props)))))
3855 (defsubst gnus-unhide-text (b e)
3856 "Remove hidden text properties from region between B and E."
3857 (remove-text-properties b e gnus-hidden-properties)
3858 (when (memq 'intangible gnus-hidden-properties)
3859 (gnus-put-text-property (max (1- b) (point-min))
3860 b 'intangible nil)))
3862 (defun gnus-hide-text-type (b e type)
3863 "Hide text of TYPE between B and E."
3864 (gnus-hide-text b e (cons 'gnus-type (cons type gnus-hidden-properties))))
3866 (defun gnus-parent-headers (headers &optional generation)
3867 "Return the headers of the GENERATIONeth parent of HEADERS."
3868 (unless generation
3869 (setq generation 1))
3870 (let (references parent)
3871 (while (and headers (not (zerop generation)))
3872 (setq references (mail-header-references headers))
3873 (when (and references
3874 (setq parent (gnus-parent-id references))
3875 (setq headers (car (gnus-id-to-thread parent))))
3876 (decf generation)))
3877 headers))
3879 (defun gnus-parent-id (references)
3880 "Return the last Message-ID in REFERENCES."
3881 (when (and references
3882 (string-match "\\(<[^\n<>]+>\\)[ \t\n]*\\'" references))
3883 (substring references (match-beginning 1) (match-end 1))))
3885 (defun gnus-split-references (references)
3886 "Return a list of Message-IDs in REFERENCES."
3887 (let ((beg 0)
3888 ids)
3889 (while (string-match "<[^>]+>" references beg)
3890 (push (substring references (match-beginning 0) (setq beg (match-end 0)))
3891 ids))
3892 (nreverse ids)))
3894 (defun gnus-buffer-live-p (buffer)
3895 "Say whether BUFFER is alive or not."
3896 (and buffer
3897 (get-buffer buffer)
3898 (buffer-name (get-buffer buffer))))
3900 (defun gnus-ephemeral-group-p (group)
3901 "Say whether GROUP is ephemeral or not."
3902 (gnus-group-get-parameter group 'quit-config))
3904 (defun gnus-group-quit-config (group)
3905 "Return the quit-config of GROUP."
3906 (gnus-group-get-parameter group 'quit-config))
3908 (defun gnus-simplify-mode-line ()
3909 "Make mode lines a bit simpler."
3910 (setq mode-line-modified "-- ")
3911 (when (listp mode-line-format)
3912 (make-local-variable 'mode-line-format)
3913 (setq mode-line-format (copy-sequence mode-line-format))
3914 (when (equal (nth 3 mode-line-format) " ")
3915 (setcar (nthcdr 3 mode-line-format) " "))))
3917 ;;; List and range functions
3919 (defun gnus-last-element (list)
3920 "Return last element of LIST."
3921 (while (cdr list)
3922 (setq list (cdr list)))
3923 (car list))
3925 (defun gnus-copy-sequence (list)
3926 "Do a complete, total copy of a list."
3927 (if (and (consp list) (not (consp (cdr list))))
3928 (cons (car list) (cdr list))
3929 (mapcar (lambda (elem) (if (consp elem)
3930 (if (consp (cdr elem))
3931 (gnus-copy-sequence elem)
3932 (cons (car elem) (cdr elem)))
3933 elem))
3934 list)))
3936 (defun gnus-set-difference (list1 list2)
3937 "Return a list of elements of LIST1 that do not appear in LIST2."
3938 (let ((list1 (copy-sequence list1)))
3939 (while list2
3940 (setq list1 (delq (car list2) list1))
3941 (setq list2 (cdr list2)))
3942 list1))
3944 (defun gnus-sorted-complement (list1 list2)
3945 "Return a list of elements of LIST1 that do not appear in LIST2.
3946 Both lists have to be sorted over <."
3947 (let (out)
3948 (if (or (null list1) (null list2))
3949 (or list1 list2)
3950 (while (and list1 list2)
3951 (cond ((= (car list1) (car list2))
3952 (setq list1 (cdr list1)
3953 list2 (cdr list2)))
3954 ((< (car list1) (car list2))
3955 (setq out (cons (car list1) out))
3956 (setq list1 (cdr list1)))
3958 (setq out (cons (car list2) out))
3959 (setq list2 (cdr list2)))))
3960 (nconc (nreverse out) (or list1 list2)))))
3962 (defun gnus-intersection (list1 list2)
3963 (let ((result nil))
3964 (while list2
3965 (if (memq (car list2) list1)
3966 (setq result (cons (car list2) result)))
3967 (setq list2 (cdr list2)))
3968 result))
3970 (defun gnus-sorted-intersection (list1 list2)
3971 ;; LIST1 and LIST2 have to be sorted over <.
3972 (let (out)
3973 (while (and list1 list2)
3974 (cond ((= (car list1) (car list2))
3975 (setq out (cons (car list1) out)
3976 list1 (cdr list1)
3977 list2 (cdr list2)))
3978 ((< (car list1) (car list2))
3979 (setq list1 (cdr list1)))
3981 (setq list2 (cdr list2)))))
3982 (nreverse out)))
3984 (defun gnus-set-sorted-intersection (list1 list2)
3985 ;; LIST1 and LIST2 have to be sorted over <.
3986 ;; This function modifies LIST1.
3987 (let* ((top (cons nil list1))
3988 (prev top))
3989 (while (and list1 list2)
3990 (cond ((= (car list1) (car list2))
3991 (setq prev list1
3992 list1 (cdr list1)
3993 list2 (cdr list2)))
3994 ((< (car list1) (car list2))
3995 (setcdr prev (cdr list1))
3996 (setq list1 (cdr list1)))
3998 (setq list2 (cdr list2)))))
3999 (setcdr prev nil)
4000 (cdr top)))
4002 (defun gnus-compress-sequence (numbers &optional always-list)
4003 "Convert list of numbers to a list of ranges or a single range.
4004 If ALWAYS-LIST is non-nil, this function will always release a list of
4005 ranges."
4006 (let* ((first (car numbers))
4007 (last (car numbers))
4008 result)
4009 (if (null numbers)
4011 (if (not (listp (cdr numbers)))
4012 numbers
4013 (while numbers
4014 (cond ((= last (car numbers)) nil) ;Omit duplicated number
4015 ((= (1+ last) (car numbers)) ;Still in sequence
4016 (setq last (car numbers)))
4017 (t ;End of one sequence
4018 (setq result
4019 (cons (if (= first last) first
4020 (cons first last)) result))
4021 (setq first (car numbers))
4022 (setq last (car numbers))))
4023 (setq numbers (cdr numbers)))
4024 (if (and (not always-list) (null result))
4025 (if (= first last) (list first) (cons first last))
4026 (nreverse (cons (if (= first last) first (cons first last))
4027 result)))))))
4029 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
4030 (defun gnus-uncompress-range (ranges)
4031 "Expand a list of ranges into a list of numbers.
4032 RANGES is either a single range on the form `(num . num)' or a list of
4033 these ranges."
4034 (let (first last result)
4035 (cond
4036 ((null ranges)
4037 nil)
4038 ((not (listp (cdr ranges)))
4039 (setq first (car ranges))
4040 (setq last (cdr ranges))
4041 (while (<= first last)
4042 (setq result (cons first result))
4043 (setq first (1+ first)))
4044 (nreverse result))
4046 (while ranges
4047 (if (atom (car ranges))
4048 (if (numberp (car ranges))
4049 (setq result (cons (car ranges) result)))
4050 (setq first (caar ranges))
4051 (setq last (cdar ranges))
4052 (while (<= first last)
4053 (setq result (cons first result))
4054 (setq first (1+ first))))
4055 (setq ranges (cdr ranges)))
4056 (nreverse result)))))
4058 (defun gnus-add-to-range (ranges list)
4059 "Return a list of ranges that has all articles from both RANGES and LIST.
4060 Note: LIST has to be sorted over `<'."
4061 (if (not ranges)
4062 (gnus-compress-sequence list t)
4063 (setq list (copy-sequence list))
4064 (or (listp (cdr ranges))
4065 (setq ranges (list ranges)))
4066 (let ((out ranges)
4067 ilist lowest highest temp)
4068 (while (and ranges list)
4069 (setq ilist list)
4070 (setq lowest (or (and (atom (car ranges)) (car ranges))
4071 (caar ranges)))
4072 (while (and list (cdr list) (< (cadr list) lowest))
4073 (setq list (cdr list)))
4074 (if (< (car ilist) lowest)
4075 (progn
4076 (setq temp list)
4077 (setq list (cdr list))
4078 (setcdr temp nil)
4079 (setq out (nconc (gnus-compress-sequence ilist t) out))))
4080 (setq highest (or (and (atom (car ranges)) (car ranges))
4081 (cdar ranges)))
4082 (while (and list (<= (car list) highest))
4083 (setq list (cdr list)))
4084 (setq ranges (cdr ranges)))
4085 (if list
4086 (setq out (nconc (gnus-compress-sequence list t) out)))
4087 (setq out (sort out (lambda (r1 r2)
4088 (< (or (and (atom r1) r1) (car r1))
4089 (or (and (atom r2) r2) (car r2))))))
4090 (setq ranges out)
4091 (while ranges
4092 (if (atom (car ranges))
4093 (if (cdr ranges)
4094 (if (atom (cadr ranges))
4095 (if (= (1+ (car ranges)) (cadr ranges))
4096 (progn
4097 (setcar ranges (cons (car ranges)
4098 (cadr ranges)))
4099 (setcdr ranges (cddr ranges))))
4100 (if (= (1+ (car ranges)) (caadr ranges))
4101 (progn
4102 (setcar (cadr ranges) (car ranges))
4103 (setcar ranges (cadr ranges))
4104 (setcdr ranges (cddr ranges))))))
4105 (if (cdr ranges)
4106 (if (atom (cadr ranges))
4107 (if (= (1+ (cdar ranges)) (cadr ranges))
4108 (progn
4109 (setcdr (car ranges) (cadr ranges))
4110 (setcdr ranges (cddr ranges))))
4111 (if (= (1+ (cdar ranges)) (caadr ranges))
4112 (progn
4113 (setcdr (car ranges) (cdadr ranges))
4114 (setcdr ranges (cddr ranges)))))))
4115 (setq ranges (cdr ranges)))
4116 out)))
4118 (defun gnus-remove-from-range (ranges list)
4119 "Return a list of ranges that has all articles from LIST removed from RANGES.
4120 Note: LIST has to be sorted over `<'."
4121 ;; !!! This function shouldn't look like this, but I've got a headache.
4122 (gnus-compress-sequence
4123 (gnus-sorted-complement
4124 (gnus-uncompress-range ranges) list)))
4126 (defun gnus-member-of-range (number ranges)
4127 (if (not (listp (cdr ranges)))
4128 (and (>= number (car ranges))
4129 (<= number (cdr ranges)))
4130 (let ((not-stop t))
4131 (while (and ranges
4132 (if (numberp (car ranges))
4133 (>= number (car ranges))
4134 (>= number (caar ranges)))
4135 not-stop)
4136 (if (if (numberp (car ranges))
4137 (= number (car ranges))
4138 (and (>= number (caar ranges))
4139 (<= number (cdar ranges))))
4140 (setq not-stop nil))
4141 (setq ranges (cdr ranges)))
4142 (not not-stop))))
4144 (defun gnus-range-length (range)
4145 "Return the length RANGE would have if uncompressed."
4146 (length (gnus-uncompress-range range)))
4148 (defun gnus-sublist-p (list sublist)
4149 "Test whether all elements in SUBLIST are members of LIST."
4150 (let ((sublistp t))
4151 (while sublist
4152 (unless (memq (pop sublist) list)
4153 (setq sublistp nil
4154 sublist nil)))
4155 sublistp))
4159 ;;; Gnus group mode
4162 (defvar gnus-group-mode-map nil)
4163 (put 'gnus-group-mode 'mode-class 'special)
4165 (unless gnus-group-mode-map
4166 (setq gnus-group-mode-map (make-keymap))
4167 (suppress-keymap gnus-group-mode-map)
4169 (gnus-define-keys gnus-group-mode-map
4170 " " gnus-group-read-group
4171 "=" gnus-group-select-group
4172 "\r" gnus-group-select-group
4173 "\M-\r" gnus-group-quick-select-group
4174 "j" gnus-group-jump-to-group
4175 "n" gnus-group-next-unread-group
4176 "p" gnus-group-prev-unread-group
4177 "\177" gnus-group-prev-unread-group
4178 [delete] gnus-group-prev-unread-group
4179 "N" gnus-group-next-group
4180 "P" gnus-group-prev-group
4181 "\M-n" gnus-group-next-unread-group-same-level
4182 "\M-p" gnus-group-prev-unread-group-same-level
4183 "," gnus-group-best-unread-group
4184 "." gnus-group-first-unread-group
4185 "u" gnus-group-unsubscribe-current-group
4186 "U" gnus-group-unsubscribe-group
4187 "c" gnus-group-catchup-current
4188 "C" gnus-group-catchup-current-all
4189 "l" gnus-group-list-groups
4190 "L" gnus-group-list-all-groups
4191 "m" gnus-group-mail
4192 "g" gnus-group-get-new-news
4193 "\M-g" gnus-group-get-new-news-this-group
4194 "R" gnus-group-restart
4195 "r" gnus-group-read-init-file
4196 "B" gnus-group-browse-foreign-server
4197 "b" gnus-group-check-bogus-groups
4198 "F" gnus-find-new-newsgroups
4199 "\C-c\C-d" gnus-group-describe-group
4200 "\M-d" gnus-group-describe-all-groups
4201 "\C-c\C-a" gnus-group-apropos
4202 "\C-c\M-\C-a" gnus-group-description-apropos
4203 "a" gnus-group-post-news
4204 "\ek" gnus-group-edit-local-kill
4205 "\eK" gnus-group-edit-global-kill
4206 "\C-k" gnus-group-kill-group
4207 "\C-y" gnus-group-yank-group
4208 "\C-w" gnus-group-kill-region
4209 "\C-x\C-t" gnus-group-transpose-groups
4210 "\C-c\C-l" gnus-group-list-killed
4211 "\C-c\C-x" gnus-group-expire-articles
4212 "\C-c\M-\C-x" gnus-group-expire-all-groups
4213 "V" gnus-version
4214 "s" gnus-group-save-newsrc
4215 "z" gnus-group-suspend
4216 ; "Z" gnus-group-clear-dribble
4217 "q" gnus-group-exit
4218 "Q" gnus-group-quit
4219 "?" gnus-group-describe-briefly
4220 "\C-c\C-i" gnus-info-find-node
4221 "\M-e" gnus-group-edit-group-method
4222 "^" gnus-group-enter-server-mode
4223 gnus-mouse-2 gnus-mouse-pick-group
4224 "<" beginning-of-buffer
4225 ">" end-of-buffer
4226 "\C-c\C-b" gnus-bug
4227 "\C-c\C-s" gnus-group-sort-groups
4228 "t" gnus-topic-mode
4229 "\C-c\M-g" gnus-activate-all-groups
4230 "\M-&" gnus-group-universal-argument
4231 "#" gnus-group-mark-group
4232 "\M-#" gnus-group-unmark-group)
4234 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
4235 "m" gnus-group-mark-group
4236 "u" gnus-group-unmark-group
4237 "w" gnus-group-mark-region
4238 "m" gnus-group-mark-buffer
4239 "r" gnus-group-mark-regexp
4240 "U" gnus-group-unmark-all-groups)
4242 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
4243 "d" gnus-group-make-directory-group
4244 "h" gnus-group-make-help-group
4245 "a" gnus-group-make-archive-group
4246 "k" gnus-group-make-kiboze-group
4247 "m" gnus-group-make-group
4248 "E" gnus-group-edit-group
4249 "e" gnus-group-edit-group-method
4250 "p" gnus-group-edit-group-parameters
4251 "v" gnus-group-add-to-virtual
4252 "V" gnus-group-make-empty-virtual
4253 "D" gnus-group-enter-directory
4254 "f" gnus-group-make-doc-group
4255 "r" gnus-group-rename-group
4256 "\177" gnus-group-delete-group
4257 [delete] gnus-group-delete-group)
4259 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
4260 "b" gnus-group-brew-soup
4261 "w" gnus-soup-save-areas
4262 "s" gnus-soup-send-replies
4263 "p" gnus-soup-pack-packet
4264 "r" nnsoup-pack-replies)
4266 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
4267 "s" gnus-group-sort-groups
4268 "a" gnus-group-sort-groups-by-alphabet
4269 "u" gnus-group-sort-groups-by-unread
4270 "l" gnus-group-sort-groups-by-level
4271 "v" gnus-group-sort-groups-by-score
4272 "r" gnus-group-sort-groups-by-rank
4273 "m" gnus-group-sort-groups-by-method)
4275 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
4276 "k" gnus-group-list-killed
4277 "z" gnus-group-list-zombies
4278 "s" gnus-group-list-groups
4279 "u" gnus-group-list-all-groups
4280 "A" gnus-group-list-active
4281 "a" gnus-group-apropos
4282 "d" gnus-group-description-apropos
4283 "m" gnus-group-list-matching
4284 "M" gnus-group-list-all-matching
4285 "l" gnus-group-list-level)
4287 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
4288 "f" gnus-score-flush-cache)
4290 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
4291 "f" gnus-group-fetch-faq)
4293 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
4294 "l" gnus-group-set-current-level
4295 "t" gnus-group-unsubscribe-current-group
4296 "s" gnus-group-unsubscribe-group
4297 "k" gnus-group-kill-group
4298 "y" gnus-group-yank-group
4299 "w" gnus-group-kill-region
4300 "\C-k" gnus-group-kill-level
4301 "z" gnus-group-kill-all-zombies))
4303 (defun gnus-group-mode ()
4304 "Major mode for reading news.
4306 All normal editing commands are switched off.
4307 \\<gnus-group-mode-map>
4308 The group buffer lists (some of) the groups available. For instance,
4309 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
4310 lists all zombie groups.
4312 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
4313 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
4315 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
4317 The following commands are available:
4319 \\{gnus-group-mode-map}"
4320 (interactive)
4321 (when (and menu-bar-mode
4322 (gnus-visual-p 'group-menu 'menu))
4323 (gnus-group-make-menu-bar))
4324 (kill-all-local-variables)
4325 (gnus-simplify-mode-line)
4326 (setq major-mode 'gnus-group-mode)
4327 (setq mode-name "Group")
4328 (gnus-group-set-mode-line)
4329 (setq mode-line-process nil)
4330 (use-local-map gnus-group-mode-map)
4331 (buffer-disable-undo (current-buffer))
4332 (setq truncate-lines t)
4333 (setq buffer-read-only t)
4334 (gnus-make-local-hook 'post-command-hook)
4335 (gnus-add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
4336 (run-hooks 'gnus-group-mode-hook))
4338 (defun gnus-clear-inboxes-moved ()
4339 (setq nnmail-moved-inboxes nil))
4341 (defun gnus-mouse-pick-group (e)
4342 "Enter the group under the mouse pointer."
4343 (interactive "e")
4344 (mouse-set-point e)
4345 (gnus-group-read-group nil))
4347 ;; Look at LEVEL and find out what the level is really supposed to be.
4348 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
4349 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
4350 (defun gnus-group-default-level (&optional level number-or-nil)
4351 (cond
4352 (gnus-group-use-permanent-levels
4353 (or (setq gnus-group-use-permanent-levels
4354 (or level (if (numberp gnus-group-use-permanent-levels)
4355 gnus-group-use-permanent-levels
4356 (or gnus-group-default-list-level
4357 gnus-level-subscribed))))
4358 gnus-group-default-list-level gnus-level-subscribed))
4359 (number-or-nil
4360 level)
4362 (or level gnus-group-default-list-level gnus-level-subscribed))))
4364 ;;;###autoload
4365 (defun gnus-slave-no-server (&optional arg)
4366 "Read network news as a slave, without connecting to local server"
4367 (interactive "P")
4368 (gnus-no-server arg t))
4370 ;;;###autoload
4371 (defun gnus-no-server (&optional arg slave)
4372 "Read network news.
4373 If ARG is a positive number, Gnus will use that as the
4374 startup level. If ARG is nil, Gnus will be started at level 2.
4375 If ARG is non-nil and not a positive number, Gnus will
4376 prompt the user for the name of an NNTP server to use.
4377 As opposed to `gnus', this command will not connect to the local server."
4378 (interactive "P")
4379 (let ((val (or arg (1- gnus-level-default-subscribed))))
4380 (gnus val t slave)
4381 (make-local-variable 'gnus-group-use-permanent-levels)
4382 (setq gnus-group-use-permanent-levels val)))
4384 ;;;###autoload
4385 (defun gnus-slave (&optional arg)
4386 "Read news as a slave."
4387 (interactive "P")
4388 (gnus arg nil 'slave))
4390 ;;;###autoload
4391 (defun gnus-other-frame (&optional arg)
4392 "Pop up a frame to read news."
4393 (interactive "P")
4394 (if (get-buffer gnus-group-buffer)
4395 (let ((pop-up-frames t))
4396 (gnus arg))
4397 (select-frame (make-frame))
4398 (gnus arg)))
4400 ;;;###autoload
4401 (defun gnus (&optional arg dont-connect slave)
4402 "Read network news.
4403 If ARG is non-nil and a positive number, Gnus will use that as the
4404 startup level. If ARG is non-nil and not a positive number, Gnus will
4405 prompt the user for the name of an NNTP server to use."
4406 (interactive "P")
4408 (if (get-buffer gnus-group-buffer)
4409 (progn
4410 (switch-to-buffer gnus-group-buffer)
4411 (gnus-group-get-new-news))
4413 (gnus-clear-system)
4414 (nnheader-init-server-buffer)
4415 (gnus-read-init-file)
4416 (setq gnus-slave slave)
4418 (gnus-group-setup-buffer)
4419 (let ((buffer-read-only nil))
4420 (erase-buffer)
4421 (if (not gnus-inhibit-startup-message)
4422 (progn
4423 (gnus-group-startup-message)
4424 (sit-for 0))))
4426 (let ((level (and (numberp arg) (> arg 0) arg))
4427 did-connect)
4428 (unwind-protect
4429 (progn
4430 (or dont-connect
4431 (setq did-connect
4432 (gnus-start-news-server (and arg (not level))))))
4433 (if (and (not dont-connect)
4434 (not did-connect))
4435 (gnus-group-quit)
4436 (run-hooks 'gnus-startup-hook)
4437 ;; NNTP server is successfully open.
4439 ;; Find the current startup file name.
4440 (setq gnus-current-startup-file
4441 (gnus-make-newsrc-file gnus-startup-file))
4443 ;; Read the dribble file.
4444 (when (or gnus-slave gnus-use-dribble-file)
4445 (gnus-dribble-read-file))
4447 ;; Allow using GroupLens predictions.
4448 (when gnus-use-grouplens
4449 (bbb-login)
4450 (add-hook 'gnus-summary-mode-hook 'gnus-grouplens-mode))
4452 (gnus-summary-make-display-table)
4453 ;; Do the actual startup.
4454 (gnus-setup-news nil level dont-connect)
4455 ;; Generate the group buffer.
4456 (gnus-group-list-groups level)
4457 (gnus-group-first-unread-group)
4458 (gnus-configure-windows 'group)
4459 (gnus-group-set-mode-line))))))
4461 (defun gnus-unload ()
4462 "Unload all Gnus features."
4463 (interactive)
4464 (or (boundp 'load-history)
4465 (error "Sorry, `gnus-unload' is not implemented in this Emacs version."))
4466 (let ((history load-history)
4467 feature)
4468 (while history
4469 (and (string-match "^\\(gnus\\|nn\\)" (caar history))
4470 (setq feature (cdr (assq 'provide (car history))))
4471 (unload-feature feature 'force))
4472 (setq history (cdr history)))))
4474 (defun gnus-compile ()
4475 "Byte-compile the user-defined format specs."
4476 (interactive)
4477 (let ((entries gnus-format-specs)
4478 entry gnus-tmp-func)
4479 (save-excursion
4480 (gnus-message 7 "Compiling format specs...")
4482 (while entries
4483 (setq entry (pop entries))
4484 (if (eq (car entry) 'version)
4485 (setq gnus-format-specs (delq entry gnus-format-specs))
4486 (when (and (listp (caddr entry))
4487 (not (eq 'byte-code (caaddr entry))))
4488 (fset 'gnus-tmp-func
4489 `(lambda () ,(caddr entry)))
4490 (byte-compile 'gnus-tmp-func)
4491 (setcar (cddr entry) (gnus-byte-code 'gnus-tmp-func)))))
4493 (push (cons 'version emacs-version) gnus-format-specs)
4495 (gnus-message 7 "Compiling user specs...done"))))
4497 (defun gnus-indent-rigidly (start end arg)
4498 "Indent rigidly using only spaces and no tabs."
4499 (save-excursion
4500 (save-restriction
4501 (narrow-to-region start end)
4502 (indent-rigidly start end arg)
4503 (goto-char (point-min))
4504 (while (search-forward "\t" nil t)
4505 (replace-match " " t t)))))
4507 (defun gnus-group-startup-message (&optional x y)
4508 "Insert startup message in current buffer."
4509 ;; Insert the message.
4510 (erase-buffer)
4511 (insert
4512 (format " %s
4513 _ ___ _ _
4514 _ ___ __ ___ __ _ ___
4515 __ _ ___ __ ___
4516 _ ___ _
4517 _ _ __ _
4518 ___ __ _
4519 __ _
4520 _ _ _
4521 _ _ _
4522 _ _ _
4523 __ ___
4524 _ _ _ _
4532 ""))
4533 ;; And then hack it.
4534 (gnus-indent-rigidly (point-min) (point-max)
4535 (/ (max (- (window-width) (or x 46)) 0) 2))
4536 (goto-char (point-min))
4537 (forward-line 1)
4538 (let* ((pheight (count-lines (point-min) (point-max)))
4539 (wheight (window-height))
4540 (rest (- wheight pheight)))
4541 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
4542 ;; Fontify some.
4543 (goto-char (point-min))
4544 (and (search-forward "Praxis" nil t)
4545 (gnus-put-text-property (match-beginning 0) (match-end 0) 'face 'bold))
4546 (goto-char (point-min))
4547 (let* ((mode-string (gnus-group-set-mode-line)))
4548 (setq mode-line-buffer-identification
4549 (list (concat gnus-version (substring (car mode-string) 4))))
4550 (set-buffer-modified-p t)))
4552 (defun gnus-group-setup-buffer ()
4553 (or (get-buffer gnus-group-buffer)
4554 (progn
4555 (switch-to-buffer gnus-group-buffer)
4556 (gnus-add-current-to-buffer-list)
4557 (gnus-group-mode)
4558 (and gnus-carpal (gnus-carpal-setup-buffer 'group)))))
4560 (defun gnus-group-list-groups (&optional level unread lowest)
4561 "List newsgroups with level LEVEL or lower that have unread articles.
4562 Default is all subscribed groups.
4563 If argument UNREAD is non-nil, groups with no unread articles are also
4564 listed."
4565 (interactive (list (if current-prefix-arg
4566 (prefix-numeric-value current-prefix-arg)
4568 (gnus-group-default-level nil t)
4569 gnus-group-default-list-level
4570 gnus-level-subscribed))))
4571 (or level
4572 (setq level (car gnus-group-list-mode)
4573 unread (cdr gnus-group-list-mode)))
4574 (setq level (gnus-group-default-level level))
4575 (gnus-group-setup-buffer) ;May call from out of group buffer
4576 (gnus-update-format-specifications)
4577 (let ((case-fold-search nil)
4578 (props (text-properties-at (gnus-point-at-bol)))
4579 (group (gnus-group-group-name)))
4580 (set-buffer gnus-group-buffer)
4581 (funcall gnus-group-prepare-function level unread lowest)
4582 (if (zerop (buffer-size))
4583 (gnus-message 5 gnus-no-groups-message)
4584 (goto-char (point-max))
4585 (when (or (not gnus-group-goto-next-group-function)
4586 (not (funcall gnus-group-goto-next-group-function
4587 group props)))
4588 (if (not group)
4589 ;; Go to the first group with unread articles.
4590 (gnus-group-search-forward t)
4591 ;; Find the right group to put point on. If the current group
4592 ;; has disappeared in the new listing, try to find the next
4593 ;; one. If no next one can be found, just leave point at the
4594 ;; first newsgroup in the buffer.
4595 (if (not (gnus-goto-char
4596 (text-property-any
4597 (point-min) (point-max)
4598 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
4599 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
4600 (while (and newsrc
4601 (not (gnus-goto-char
4602 (text-property-any
4603 (point-min) (point-max) 'gnus-group
4604 (gnus-intern-safe
4605 (caar newsrc) gnus-active-hashtb)))))
4606 (setq newsrc (cdr newsrc)))
4607 (or newsrc (progn (goto-char (point-max))
4608 (forward-line -1)))))))
4609 ;; Adjust cursor point.
4610 (gnus-group-position-point))))
4612 (defun gnus-group-list-level (level &optional all)
4613 "List groups on LEVEL.
4614 If ALL (the prefix), also list groups that have no unread articles."
4615 (interactive "nList groups on level: \nP")
4616 (gnus-group-list-groups level all level))
4618 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
4619 "List all newsgroups with unread articles of level LEVEL or lower.
4620 If ALL is non-nil, list groups that have no unread articles.
4621 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
4622 If REGEXP, only list groups matching REGEXP."
4623 (set-buffer gnus-group-buffer)
4624 (let ((buffer-read-only nil)
4625 (newsrc (cdr gnus-newsrc-alist))
4626 (lowest (or lowest 1))
4627 info clevel unread group params)
4628 (erase-buffer)
4629 (if (< lowest gnus-level-zombie)
4630 ;; List living groups.
4631 (while newsrc
4632 (setq info (car newsrc)
4633 group (gnus-info-group info)
4634 params (gnus-info-params info)
4635 newsrc (cdr newsrc)
4636 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
4637 (and unread ; This group might be bogus
4638 (or (not regexp)
4639 (string-match regexp group))
4640 (<= (setq clevel (gnus-info-level info)) level)
4641 (>= clevel lowest)
4642 (or all ; We list all groups?
4643 (if (eq unread t) ; Unactivated?
4644 gnus-group-list-inactive-groups ; We list unactivated
4645 (> unread 0)) ; We list groups with unread articles
4646 (and gnus-list-groups-with-ticked-articles
4647 (cdr (assq 'tick (gnus-info-marks info))))
4648 ; And groups with tickeds
4649 ;; Check for permanent visibility.
4650 (and gnus-permanently-visible-groups
4651 (string-match gnus-permanently-visible-groups
4652 group))
4653 (memq 'visible params)
4654 (cdr (assq 'visible params)))
4655 (gnus-group-insert-group-line
4656 group (gnus-info-level info)
4657 (gnus-info-marks info) unread (gnus-info-method info)))))
4659 ;; List dead groups.
4660 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
4661 (gnus-group-prepare-flat-list-dead
4662 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
4663 gnus-level-zombie ?Z
4664 regexp))
4665 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
4666 (gnus-group-prepare-flat-list-dead
4667 (setq gnus-killed-list (sort gnus-killed-list 'string<))
4668 gnus-level-killed ?K regexp))
4670 (gnus-group-set-mode-line)
4671 (setq gnus-group-list-mode (cons level all))
4672 (run-hooks 'gnus-group-prepare-hook)))
4674 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
4675 ;; List zombies and killed lists somewhat faster, which was
4676 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
4677 ;; this by ignoring the group format specification altogether.
4678 (let (group)
4679 (if regexp
4680 ;; This loop is used when listing groups that match some
4681 ;; regexp.
4682 (while groups
4683 (setq group (pop groups))
4684 (when (string-match regexp group)
4685 (gnus-add-text-properties
4686 (point) (prog1 (1+ (point))
4687 (insert " " mark " *: " group "\n"))
4688 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4689 'gnus-unread t
4690 'gnus-level level))))
4691 ;; This loop is used when listing all groups.
4692 (while groups
4693 (gnus-add-text-properties
4694 (point) (prog1 (1+ (point))
4695 (insert " " mark " *: "
4696 (setq group (pop groups)) "\n"))
4697 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4698 'gnus-unread t
4699 'gnus-level level))))))
4701 (defmacro gnus-group-real-name (group)
4702 "Find the real name of a foreign newsgroup."
4703 `(let ((gname ,group))
4704 (if (string-match ":[^:]+$" gname)
4705 (substring gname (1+ (match-beginning 0)))
4706 gname)))
4708 (defsubst gnus-server-add-address (method)
4709 (let ((method-name (symbol-name (car method))))
4710 (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
4711 (not (assq (intern (concat method-name "-address")) method)))
4712 (append method (list (list (intern (concat method-name "-address"))
4713 (nth 1 method))))
4714 method)))
4716 (defsubst gnus-server-get-method (group method)
4717 ;; Input either a server name, and extended server name, or a
4718 ;; select method, and return a select method.
4719 (cond ((stringp method)
4720 (gnus-server-to-method method))
4721 ((equal method gnus-select-method)
4722 gnus-select-method)
4723 ((and (stringp (car method)) group)
4724 (gnus-server-extend-method group method))
4725 ((and method (not group)
4726 (equal (cadr method) ""))
4727 method)
4729 (gnus-server-add-address method))))
4731 (defun gnus-server-to-method (server)
4732 "Map virtual server names to select methods."
4733 (or
4734 ;; Is this a method, perhaps?
4735 (and server (listp server) server)
4736 ;; Perhaps this is the native server?
4737 (and (equal server "native") gnus-select-method)
4738 ;; It should be in the server alist.
4739 (cdr (assoc server gnus-server-alist))
4740 ;; If not, we look through all the opened server
4741 ;; to see whether we can find it there.
4742 (let ((opened gnus-opened-servers))
4743 (while (and opened
4744 (not (equal server (format "%s:%s" (caaar opened)
4745 (cadaar opened)))))
4746 (pop opened))
4747 (caar opened))))
4749 (defmacro gnus-method-equal (ss1 ss2)
4750 "Say whether two servers are equal."
4751 `(let ((s1 ,ss1)
4752 (s2 ,ss2))
4753 (or (equal s1 s2)
4754 (and (= (length s1) (length s2))
4755 (progn
4756 (while (and s1 (member (car s1) s2))
4757 (setq s1 (cdr s1)))
4758 (null s1))))))
4760 (defun gnus-server-equal (m1 m2)
4761 "Say whether two methods are equal."
4762 (let ((m1 (cond ((null m1) gnus-select-method)
4763 ((stringp m1) (gnus-server-to-method m1))
4764 (t m1)))
4765 (m2 (cond ((null m2) gnus-select-method)
4766 ((stringp m2) (gnus-server-to-method m2))
4767 (t m2))))
4768 (gnus-method-equal m1 m2)))
4770 (defun gnus-servers-using-backend (backend)
4771 "Return a list of known servers using BACKEND."
4772 (let ((opened gnus-opened-servers)
4773 out)
4774 (while opened
4775 (when (eq backend (caaar opened))
4776 (push (caar opened) out))
4777 (pop opened))
4778 out))
4780 (defun gnus-archive-server-wanted-p ()
4781 "Say whether the user wants to use the archive server."
4782 (cond
4783 ((or (not gnus-message-archive-method)
4784 (not gnus-message-archive-group))
4785 nil)
4786 ((and gnus-message-archive-method gnus-message-archive-group)
4789 (let ((active (cadr (assq 'nnfolder-active-file
4790 gnus-message-archive-method))))
4791 (and active
4792 (file-exists-p active))))))
4794 (defun gnus-group-prefixed-name (group method)
4795 "Return the whole name from GROUP and METHOD."
4796 (and (stringp method) (setq method (gnus-server-to-method method)))
4797 (concat (format "%s" (car method))
4798 (if (and
4799 (or (assoc (format "%s" (car method))
4800 (gnus-methods-using 'address))
4801 (gnus-server-equal method gnus-message-archive-method))
4802 (nth 1 method)
4803 (not (string= (nth 1 method) "")))
4804 (concat "+" (nth 1 method)))
4805 ":" group))
4807 (defun gnus-group-real-prefix (group)
4808 "Return the prefix of the current group name."
4809 (if (string-match "^[^:]+:" group)
4810 (substring group 0 (match-end 0))
4811 ""))
4813 (defun gnus-group-method (group)
4814 "Return the server or method used for selecting GROUP."
4815 (let ((prefix (gnus-group-real-prefix group)))
4816 (if (equal prefix "")
4817 gnus-select-method
4818 (let ((servers gnus-opened-servers)
4819 (server "")
4820 backend possible found)
4821 (if (string-match "^[^\\+]+\\+" prefix)
4822 (setq backend (intern (substring prefix 0 (1- (match-end 0))))
4823 server (substring prefix (match-end 0) (1- (length prefix))))
4824 (setq backend (intern (substring prefix 0 (1- (length prefix))))))
4825 (while servers
4826 (when (eq (caaar servers) backend)
4827 (setq possible (caar servers))
4828 (when (equal (cadaar servers) server)
4829 (setq found (caar servers))))
4830 (pop servers))
4831 (or (car (rassoc found gnus-server-alist))
4832 found
4833 (car (rassoc possible gnus-server-alist))
4834 possible
4835 (list backend server))))))
4837 (defsubst gnus-secondary-method-p (method)
4838 "Return whether METHOD is a secondary select method."
4839 (let ((methods gnus-secondary-select-methods)
4840 (gmethod (gnus-server-get-method nil method)))
4841 (while (and methods
4842 (not (equal (gnus-server-get-method nil (car methods))
4843 gmethod)))
4844 (setq methods (cdr methods)))
4845 methods))
4847 (defun gnus-group-foreign-p (group)
4848 "Say whether a group is foreign or not."
4849 (and (not (gnus-group-native-p group))
4850 (not (gnus-group-secondary-p group))))
4852 (defun gnus-group-native-p (group)
4853 "Say whether the group is native or not."
4854 (not (string-match ":" group)))
4856 (defun gnus-group-secondary-p (group)
4857 "Say whether the group is secondary or not."
4858 (gnus-secondary-method-p (gnus-find-method-for-group group)))
4860 (defun gnus-group-get-parameter (group &optional symbol)
4861 "Returns the group parameters for GROUP.
4862 If SYMBOL, return the value of that symbol in the group parameters."
4863 (let ((params (gnus-info-params (gnus-get-info group))))
4864 (if symbol
4865 (gnus-group-parameter-value params symbol)
4866 params)))
4868 (defun gnus-group-parameter-value (params symbol)
4869 "Return the value of SYMBOL in group PARAMS."
4870 (or (car (memq symbol params)) ; It's either a simple symbol
4871 (cdr (assq symbol params)))) ; or a cons.
4873 (defun gnus-group-add-parameter (group param)
4874 "Add parameter PARAM to GROUP."
4875 (let ((info (gnus-get-info group)))
4876 (if (not info)
4877 () ; This is a dead group. We just ignore it.
4878 ;; Cons the new param to the old one and update.
4879 (gnus-group-set-info (cons param (gnus-info-params info))
4880 group 'params))))
4882 (defun gnus-group-set-parameter (group name value)
4883 "Set parameter NAME to VALUE in GROUP."
4884 (let ((info (gnus-get-info group)))
4885 (if (not info)
4886 () ; This is a dead group. We just ignore it.
4887 (let ((old-params (gnus-info-params info))
4888 (new-params (list (cons name value))))
4889 (while old-params
4890 (if (or (not (listp (car old-params)))
4891 (not (eq (caar old-params) name)))
4892 (setq new-params (append new-params (list (car old-params)))))
4893 (setq old-params (cdr old-params)))
4894 (gnus-group-set-info new-params group 'params)))))
4896 (defun gnus-group-add-score (group &optional score)
4897 "Add SCORE to the GROUP score.
4898 If SCORE is nil, add 1 to the score of GROUP."
4899 (let ((info (gnus-get-info group)))
4900 (when info
4901 (gnus-info-set-score info (+ (gnus-info-score info) (or score 1))))))
4903 (defun gnus-summary-bubble-group ()
4904 "Increase the score of the current group.
4905 This is a handy function to add to `gnus-summary-exit-hook' to
4906 increase the score of each group you read."
4907 (gnus-group-add-score gnus-newsgroup-name))
4909 (defun gnus-group-set-info (info &optional method-only-group part)
4910 (let* ((entry (gnus-gethash
4911 (or method-only-group (gnus-info-group info))
4912 gnus-newsrc-hashtb))
4913 (part-info info)
4914 (info (if method-only-group (nth 2 entry) info))
4915 method)
4916 (when method-only-group
4917 (unless entry
4918 (error "Trying to change non-existent group %s" method-only-group))
4919 ;; We have received parts of the actual group info - either the
4920 ;; select method or the group parameters. We first check
4921 ;; whether we have to extend the info, and if so, do that.
4922 (let ((len (length info))
4923 (total (if (eq part 'method) 5 6)))
4924 (when (< len total)
4925 (setcdr (nthcdr (1- len) info)
4926 (make-list (- total len) nil)))
4927 ;; Then we enter the new info.
4928 (setcar (nthcdr (1- total) info) part-info)))
4929 (unless entry
4930 ;; This is a new group, so we just create it.
4931 (save-excursion
4932 (set-buffer gnus-group-buffer)
4933 (setq method (gnus-info-method info))
4934 (when (gnus-server-equal method "native")
4935 (setq method nil))
4936 (save-excursion
4937 (set-buffer gnus-group-buffer)
4938 (if method
4939 ;; It's a foreign group...
4940 (gnus-group-make-group
4941 (gnus-group-real-name (gnus-info-group info))
4942 (if (stringp method) method
4943 (prin1-to-string (car method)))
4944 (and (consp method)
4945 (nth 1 (gnus-info-method info))))
4946 ;; It's a native group.
4947 (gnus-group-make-group (gnus-info-group info))))
4948 (gnus-message 6 "Note: New group created")
4949 (setq entry
4950 (gnus-gethash (gnus-group-prefixed-name
4951 (gnus-group-real-name (gnus-info-group info))
4952 (or (gnus-info-method info) gnus-select-method))
4953 gnus-newsrc-hashtb))))
4954 ;; Whether it was a new group or not, we now have the entry, so we
4955 ;; can do the update.
4956 (if entry
4957 (progn
4958 (setcar (nthcdr 2 entry) info)
4959 (when (and (not (eq (car entry) t))
4960 (gnus-active (gnus-info-group info)))
4961 (setcar entry (length (gnus-list-of-unread-articles (car info))))))
4962 (error "No such group: %s" (gnus-info-group info)))))
4964 (defun gnus-group-set-method-info (group select-method)
4965 (gnus-group-set-info select-method group 'method))
4967 (defun gnus-group-set-params-info (group params)
4968 (gnus-group-set-info params group 'params))
4970 (defun gnus-group-update-group-line ()
4971 "Update the current line in the group buffer."
4972 (let* ((buffer-read-only nil)
4973 (group (gnus-group-group-name))
4974 (entry (and group (gnus-gethash group gnus-newsrc-hashtb)))
4975 gnus-group-indentation)
4976 (when group
4977 (and entry
4978 (not (gnus-ephemeral-group-p group))
4979 (gnus-dribble-enter
4980 (concat "(gnus-group-set-info '"
4981 (prin1-to-string (nth 2 entry)) ")")))
4982 (setq gnus-group-indentation (gnus-group-group-indentation))
4983 (gnus-delete-line)
4984 (gnus-group-insert-group-line-info group)
4985 (forward-line -1)
4986 (gnus-group-position-point))))
4988 (defun gnus-group-insert-group-line-info (group)
4989 "Insert GROUP on the current line."
4990 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
4991 active info)
4992 (if entry
4993 (progn
4994 ;; (Un)subscribed group.
4995 (setq info (nth 2 entry))
4996 (gnus-group-insert-group-line
4997 group (gnus-info-level info) (gnus-info-marks info)
4998 (or (car entry) t) (gnus-info-method info)))
4999 ;; This group is dead.
5000 (gnus-group-insert-group-line
5001 group
5002 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
5004 (if (setq active (gnus-active group))
5005 (- (1+ (cdr active)) (car active)) 0)
5006 nil))))
5008 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
5009 gnus-tmp-marked number
5010 gnus-tmp-method)
5011 "Insert a group line in the group buffer."
5012 (let* ((gnus-tmp-active (gnus-active gnus-tmp-group))
5013 (gnus-tmp-number-total
5014 (if gnus-tmp-active
5015 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
5017 (gnus-tmp-number-of-unread
5018 (if (numberp number) (int-to-string (max 0 number))
5019 "*"))
5020 (gnus-tmp-number-of-read
5021 (if (numberp number)
5022 (int-to-string (max 0 (- gnus-tmp-number-total number)))
5023 "*"))
5024 (gnus-tmp-subscribed
5025 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
5026 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
5027 ((= gnus-tmp-level gnus-level-zombie) ?Z)
5028 (t ?K)))
5029 (gnus-tmp-qualified-group (gnus-group-real-name gnus-tmp-group))
5030 (gnus-tmp-newsgroup-description
5031 (if gnus-description-hashtb
5032 (or (gnus-gethash gnus-tmp-group gnus-description-hashtb) "")
5033 ""))
5034 (gnus-tmp-moderated
5035 (if (member gnus-tmp-group gnus-moderated-list) ?m ? ))
5036 (gnus-tmp-moderated-string
5037 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
5038 (gnus-tmp-method
5039 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
5040 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
5041 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
5042 (gnus-tmp-news-method-string
5043 (if gnus-tmp-method
5044 (format "(%s:%s)" (car gnus-tmp-method)
5045 (cadr gnus-tmp-method)) ""))
5046 (gnus-tmp-marked-mark
5047 (if (and (numberp number)
5048 (zerop number)
5049 (cdr (assq 'tick gnus-tmp-marked)))
5050 ?* ? ))
5051 (gnus-tmp-process-marked
5052 (if (member gnus-tmp-group gnus-group-marked)
5053 gnus-process-mark ? ))
5054 (gnus-tmp-grouplens
5055 (or (and gnus-use-grouplens
5056 (bbb-grouplens-group-p gnus-tmp-group))
5057 ""))
5058 (buffer-read-only nil)
5059 header gnus-tmp-header) ; passed as parameter to user-funcs.
5060 (beginning-of-line)
5061 (gnus-add-text-properties
5062 (point)
5063 (prog1 (1+ (point))
5064 ;; Insert the text.
5065 (eval gnus-group-line-format-spec))
5066 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
5067 gnus-unread ,(if (numberp number)
5068 (string-to-int gnus-tmp-number-of-unread)
5070 gnus-marked ,gnus-tmp-marked-mark
5071 gnus-indentation ,gnus-group-indentation
5072 gnus-level ,gnus-tmp-level))
5073 (when (inline (gnus-visual-p 'group-highlight 'highlight))
5074 (forward-line -1)
5075 (run-hooks 'gnus-group-update-hook)
5076 (forward-line))
5077 ;; Allow XEmacs to remove front-sticky text properties.
5078 (gnus-group-remove-excess-properties)))
5080 (defun gnus-group-update-group (group &optional visible-only)
5081 "Update all lines where GROUP appear.
5082 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
5083 already."
5084 (save-excursion
5085 (set-buffer gnus-group-buffer)
5086 ;; The buffer may be narrowed.
5087 (save-restriction
5088 (widen)
5089 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
5090 (loc (point-min))
5091 found buffer-read-only)
5092 ;; Enter the current status into the dribble buffer.
5093 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
5094 (if (and entry (not (gnus-ephemeral-group-p group)))
5095 (gnus-dribble-enter
5096 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
5097 ")"))))
5098 ;; Find all group instances. If topics are in use, each group
5099 ;; may be listed in more than once.
5100 (while (setq loc (text-property-any
5101 loc (point-max) 'gnus-group ident))
5102 (setq found t)
5103 (goto-char loc)
5104 (let ((gnus-group-indentation (gnus-group-group-indentation)))
5105 (gnus-delete-line)
5106 (gnus-group-insert-group-line-info group)
5107 (save-excursion
5108 (forward-line -1)
5109 (run-hooks 'gnus-group-update-group-hook)))
5110 (setq loc (1+ loc)))
5111 (unless (or found visible-only)
5112 ;; No such line in the buffer, find out where it's supposed to
5113 ;; go, and insert it there (or at the end of the buffer).
5114 (if gnus-goto-missing-group-function
5115 (funcall gnus-goto-missing-group-function group)
5116 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
5117 (while (and entry (car entry)
5118 (not
5119 (gnus-goto-char
5120 (text-property-any
5121 (point-min) (point-max)
5122 'gnus-group (gnus-intern-safe
5123 (caar entry) gnus-active-hashtb)))))
5124 (setq entry (cdr entry)))
5125 (or entry (goto-char (point-max)))))
5126 ;; Finally insert the line.
5127 (let ((gnus-group-indentation (gnus-group-group-indentation)))
5128 (gnus-group-insert-group-line-info group)
5129 (save-excursion
5130 (forward-line -1)
5131 (run-hooks 'gnus-group-update-group-hook))))
5132 (gnus-group-set-mode-line)))))
5134 (defun gnus-group-set-mode-line ()
5135 "Update the mode line in the group buffer."
5136 (when (memq 'group gnus-updated-mode-lines)
5137 ;; Yes, we want to keep this mode line updated.
5138 (save-excursion
5139 (set-buffer gnus-group-buffer)
5140 (let* ((gformat (or gnus-group-mode-line-format-spec
5141 (setq gnus-group-mode-line-format-spec
5142 (gnus-parse-format
5143 gnus-group-mode-line-format
5144 gnus-group-mode-line-format-alist))))
5145 (gnus-tmp-news-server (cadr gnus-select-method))
5146 (gnus-tmp-news-method (car gnus-select-method))
5147 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
5148 (max-len 60)
5149 gnus-tmp-header ;Dummy binding for user-defined formats
5150 ;; Get the resulting string.
5151 (modified
5152 (and gnus-dribble-buffer
5153 (buffer-name gnus-dribble-buffer)
5154 (buffer-modified-p gnus-dribble-buffer)
5155 (save-excursion
5156 (set-buffer gnus-dribble-buffer)
5157 (not (zerop (buffer-size))))))
5158 (mode-string (eval gformat)))
5159 ;; Say whether the dribble buffer has been modified.
5160 (setq mode-line-modified
5161 (if modified "---*- " "----- "))
5162 ;; If the line is too long, we chop it off.
5163 (when (> (length mode-string) max-len)
5164 (setq mode-string (substring mode-string 0 (- max-len 4))))
5165 (prog1
5166 (setq mode-line-buffer-identification
5167 (gnus-mode-line-buffer-identification
5168 (list mode-string)))
5169 (set-buffer-modified-p modified))))))
5171 (defun gnus-group-group-name ()
5172 "Get the name of the newsgroup on the current line."
5173 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
5174 (and group (symbol-name group))))
5176 (defun gnus-group-group-level ()
5177 "Get the level of the newsgroup on the current line."
5178 (get-text-property (gnus-point-at-bol) 'gnus-level))
5180 (defun gnus-group-group-indentation ()
5181 "Get the indentation of the newsgroup on the current line."
5182 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
5183 (and gnus-group-indentation-function
5184 (funcall gnus-group-indentation-function))
5185 ""))
5187 (defun gnus-group-group-unread ()
5188 "Get the number of unread articles of the newsgroup on the current line."
5189 (get-text-property (gnus-point-at-bol) 'gnus-unread))
5191 (defun gnus-group-search-forward (&optional backward all level first-too)
5192 "Find the next newsgroup with unread articles.
5193 If BACKWARD is non-nil, find the previous newsgroup instead.
5194 If ALL is non-nil, just find any newsgroup.
5195 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
5196 group exists.
5197 If FIRST-TOO, the current line is also eligible as a target."
5198 (let ((way (if backward -1 1))
5199 (low gnus-level-killed)
5200 (beg (point))
5201 pos found lev)
5202 (if (and backward (progn (beginning-of-line)) (bobp))
5204 (or first-too (forward-line way))
5205 (while (and
5206 (not (eobp))
5207 (not (setq
5208 found
5209 (and (or all
5210 (and
5211 (let ((unread
5212 (get-text-property (point) 'gnus-unread)))
5213 (and (numberp unread) (> unread 0)))
5214 (setq lev (get-text-property (point)
5215 'gnus-level))
5216 (<= lev gnus-level-subscribed)))
5217 (or (not level)
5218 (and (setq lev (get-text-property (point)
5219 'gnus-level))
5220 (or (= lev level)
5221 (and (< lev low)
5222 (< level lev)
5223 (progn
5224 (setq low lev)
5225 (setq pos (point))
5226 nil))))))))
5227 (zerop (forward-line way)))))
5228 (if found
5229 (progn (gnus-group-position-point) t)
5230 (goto-char (or pos beg))
5231 (and pos t))))
5233 ;;; Gnus group mode commands
5235 ;; Group marking.
5237 (defun gnus-group-mark-group (n &optional unmark no-advance)
5238 "Mark the current group."
5239 (interactive "p")
5240 (let ((buffer-read-only nil)
5241 group)
5242 (while (and (> n 0)
5243 (not (eobp)))
5244 (when (setq group (gnus-group-group-name))
5245 ;; Update the mark.
5246 (beginning-of-line)
5247 (forward-char
5248 (or (cdr (assq 'process gnus-group-mark-positions)) 2))
5249 (delete-char 1)
5250 (if unmark
5251 (progn
5252 (insert " ")
5253 (setq gnus-group-marked (delete group gnus-group-marked)))
5254 (insert "#")
5255 (setq gnus-group-marked
5256 (cons group (delete group gnus-group-marked)))))
5257 (or no-advance (gnus-group-next-group 1))
5258 (decf n))
5259 (gnus-summary-position-point)
5262 (defun gnus-group-unmark-group (n)
5263 "Remove the mark from the current group."
5264 (interactive "p")
5265 (gnus-group-mark-group n 'unmark)
5266 (gnus-group-position-point))
5268 (defun gnus-group-unmark-all-groups ()
5269 "Unmark all groups."
5270 (interactive)
5271 (let ((groups gnus-group-marked))
5272 (save-excursion
5273 (while groups
5274 (gnus-group-remove-mark (pop groups)))))
5275 (gnus-group-position-point))
5277 (defun gnus-group-mark-region (unmark beg end)
5278 "Mark all groups between point and mark.
5279 If UNMARK, remove the mark instead."
5280 (interactive "P\nr")
5281 (let ((num (count-lines beg end)))
5282 (save-excursion
5283 (goto-char beg)
5284 (- num (gnus-group-mark-group num unmark)))))
5286 (defun gnus-group-mark-buffer (&optional unmark)
5287 "Mark all groups in the buffer.
5288 If UNMARK, remove the mark instead."
5289 (interactive "P")
5290 (gnus-group-mark-region unmark (point-min) (point-max)))
5292 (defun gnus-group-mark-regexp (regexp)
5293 "Mark all groups that match some regexp."
5294 (interactive "sMark (regexp): ")
5295 (let ((alist (cdr gnus-newsrc-alist))
5296 group)
5297 (while alist
5298 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
5299 (gnus-group-set-mark group))))
5300 (gnus-group-position-point))
5302 (defun gnus-group-remove-mark (group)
5303 "Remove the process mark from GROUP and move point there.
5304 Return nil if the group isn't displayed."
5305 (if (gnus-group-goto-group group)
5306 (save-excursion
5307 (gnus-group-mark-group 1 'unmark t)
5309 (setq gnus-group-marked
5310 (delete group gnus-group-marked))
5311 nil))
5313 (defun gnus-group-set-mark (group)
5314 "Set the process mark on GROUP."
5315 (if (gnus-group-goto-group group)
5316 (save-excursion
5317 (gnus-group-mark-group 1 nil t))
5318 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
5320 (defun gnus-group-universal-argument (arg &optional groups func)
5321 "Perform any command on all groups accoring to the process/prefix convention."
5322 (interactive "P")
5323 (let ((groups (or groups (gnus-group-process-prefix arg)))
5324 group func)
5325 (if (eq (setq func (or func
5326 (key-binding
5327 (read-key-sequence
5328 (substitute-command-keys
5329 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
5330 'undefined)
5331 (gnus-error 1 "Undefined key")
5332 (while groups
5333 (gnus-group-remove-mark (setq group (pop groups)))
5334 (command-execute func))))
5335 (gnus-group-position-point))
5337 (defun gnus-group-process-prefix (n)
5338 "Return a list of groups to work on.
5339 Take into consideration N (the prefix) and the list of marked groups."
5340 (cond
5342 (setq n (prefix-numeric-value n))
5343 ;; There is a prefix, so we return a list of the N next
5344 ;; groups.
5345 (let ((way (if (< n 0) -1 1))
5346 (n (abs n))
5347 group groups)
5348 (save-excursion
5349 (while (and (> n 0)
5350 (setq group (gnus-group-group-name)))
5351 (setq groups (cons group groups))
5352 (setq n (1- n))
5353 (gnus-group-next-group way)))
5354 (nreverse groups)))
5355 ((and (boundp 'transient-mark-mode)
5356 transient-mark-mode
5357 (boundp 'mark-active)
5358 mark-active)
5359 ;; Work on the region between point and mark.
5360 (let ((max (max (point) (mark)))
5361 groups)
5362 (save-excursion
5363 (goto-char (min (point) (mark)))
5364 (while
5365 (and
5366 (push (gnus-group-group-name) groups)
5367 (zerop (gnus-group-next-group 1))
5368 (< (point) max)))
5369 (nreverse groups))))
5370 (gnus-group-marked
5371 ;; No prefix, but a list of marked articles.
5372 (reverse gnus-group-marked))
5374 ;; Neither marked articles or a prefix, so we return the
5375 ;; current group.
5376 (let ((group (gnus-group-group-name)))
5377 (and group (list group))))))
5379 ;; Selecting groups.
5381 (defun gnus-group-read-group (&optional all no-article group)
5382 "Read news in this newsgroup.
5383 If the prefix argument ALL is non-nil, already read articles become
5384 readable. IF ALL is a number, fetch this number of articles. If the
5385 optional argument NO-ARTICLE is non-nil, no article will be
5386 auto-selected upon group entry. If GROUP is non-nil, fetch that
5387 group."
5388 (interactive "P")
5389 (let ((group (or group (gnus-group-group-name)))
5390 number active marked entry)
5391 (or group (error "No group on current line"))
5392 (setq marked (nth 3 (nth 2 (setq entry (gnus-gethash
5393 group gnus-newsrc-hashtb)))))
5394 ;; This group might be a dead group. In that case we have to get
5395 ;; the number of unread articles from `gnus-active-hashtb'.
5396 (setq number
5397 (cond ((numberp all) all)
5398 (entry (car entry))
5399 ((setq active (gnus-active group))
5400 (- (1+ (cdr active)) (car active)))))
5401 (gnus-summary-read-group
5402 group (or all (and (numberp number)
5403 (zerop (+ number (length (cdr (assq 'tick marked)))
5404 (length (cdr (assq 'dormant marked)))))))
5405 no-article)))
5407 (defun gnus-group-select-group (&optional all)
5408 "Select this newsgroup.
5409 No article is selected automatically.
5410 If ALL is non-nil, already read articles become readable.
5411 If ALL is a number, fetch this number of articles."
5412 (interactive "P")
5413 (gnus-group-read-group all t))
5415 (defun gnus-group-quick-select-group (&optional all)
5416 "Select the current group \"quickly\".
5417 This means that no highlighting or scoring will be performed."
5418 (interactive "P")
5419 (let (gnus-visual
5420 gnus-score-find-score-files-function
5421 gnus-apply-kill-hook
5422 gnus-summary-expunge-below)
5423 (gnus-group-read-group all t)))
5425 (defun gnus-group-visible-select-group (&optional all)
5426 "Select the current group without hiding any articles."
5427 (interactive "P")
5428 (let ((gnus-inhibit-limiting t))
5429 (gnus-group-read-group all t)))
5431 ;;;###autoload
5432 (defun gnus-fetch-group (group)
5433 "Start Gnus if necessary and enter GROUP.
5434 Returns whether the fetching was successful or not."
5435 (interactive "sGroup name: ")
5436 (or (get-buffer gnus-group-buffer)
5437 (gnus))
5438 (gnus-group-read-group nil nil group))
5440 ;; Enter a group that is not in the group buffer. Non-nil is returned
5441 ;; if selection was successful.
5442 (defun gnus-group-read-ephemeral-group
5443 (group method &optional activate quit-config)
5444 (let ((group (if (gnus-group-foreign-p group) group
5445 (gnus-group-prefixed-name group method))))
5446 (gnus-sethash
5447 group
5448 `(t nil (,group ,gnus-level-default-subscribed nil nil ,method
5449 ((quit-config . ,(if quit-config quit-config
5450 (cons (current-buffer) 'summary))))))
5451 gnus-newsrc-hashtb)
5452 (set-buffer gnus-group-buffer)
5453 (or (gnus-check-server method)
5454 (error "Unable to contact server: %s" (gnus-status-message method)))
5455 (if activate (or (gnus-request-group group)
5456 (error "Couldn't request group")))
5457 (condition-case ()
5458 (gnus-group-read-group t t group)
5459 (error nil)
5460 (quit nil))))
5462 (defun gnus-group-jump-to-group (group)
5463 "Jump to newsgroup GROUP."
5464 (interactive
5465 (list (completing-read
5466 "Group: " gnus-active-hashtb nil
5467 (gnus-read-active-file-p)
5469 'gnus-group-history)))
5471 (when (equal group "")
5472 (error "Empty group name"))
5474 (when (string-match "[\000-\032]" group)
5475 (error "Control characters in group: %s" group))
5477 (let ((b (text-property-any
5478 (point-min) (point-max)
5479 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
5480 (unless (gnus-ephemeral-group-p group)
5481 (if b
5482 ;; Either go to the line in the group buffer...
5483 (goto-char b)
5484 ;; ... or insert the line.
5486 (gnus-active group)
5487 (gnus-activate-group group)
5488 (error "%s error: %s" group (gnus-status-message group)))
5490 (gnus-group-update-group group)
5491 (goto-char (text-property-any
5492 (point-min) (point-max)
5493 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))
5494 ;; Adjust cursor point.
5495 (gnus-group-position-point)))
5497 (defun gnus-group-goto-group (group)
5498 "Goto to newsgroup GROUP."
5499 (when group
5500 (let ((b (text-property-any (point-min) (point-max)
5501 'gnus-group (gnus-intern-safe
5502 group gnus-active-hashtb))))
5503 (and b (goto-char b)))))
5505 (defun gnus-group-next-group (n)
5506 "Go to next N'th newsgroup.
5507 If N is negative, search backward instead.
5508 Returns the difference between N and the number of skips actually
5509 done."
5510 (interactive "p")
5511 (gnus-group-next-unread-group n t))
5513 (defun gnus-group-next-unread-group (n &optional all level)
5514 "Go to next N'th unread newsgroup.
5515 If N is negative, search backward instead.
5516 If ALL is non-nil, choose any newsgroup, unread or not.
5517 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
5518 such group can be found, the next group with a level higher than
5519 LEVEL.
5520 Returns the difference between N and the number of skips actually
5521 made."
5522 (interactive "p")
5523 (let ((backward (< n 0))
5524 (n (abs n)))
5525 (while (and (> n 0)
5526 (gnus-group-search-forward
5527 backward (or (not gnus-group-goto-unread) all) level))
5528 (setq n (1- n)))
5529 (if (/= 0 n) (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
5530 (if level " on this level or higher" "")))
5533 (defun gnus-group-prev-group (n)
5534 "Go to previous N'th newsgroup.
5535 Returns the difference between N and the number of skips actually
5536 done."
5537 (interactive "p")
5538 (gnus-group-next-unread-group (- n) t))
5540 (defun gnus-group-prev-unread-group (n)
5541 "Go to previous N'th unread newsgroup.
5542 Returns the difference between N and the number of skips actually
5543 done."
5544 (interactive "p")
5545 (gnus-group-next-unread-group (- n)))
5547 (defun gnus-group-next-unread-group-same-level (n)
5548 "Go to next N'th unread newsgroup on the same level.
5549 If N is negative, search backward instead.
5550 Returns the difference between N and the number of skips actually
5551 done."
5552 (interactive "p")
5553 (gnus-group-next-unread-group n t (gnus-group-group-level))
5554 (gnus-group-position-point))
5556 (defun gnus-group-prev-unread-group-same-level (n)
5557 "Go to next N'th unread newsgroup on the same level.
5558 Returns the difference between N and the number of skips actually
5559 done."
5560 (interactive "p")
5561 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
5562 (gnus-group-position-point))
5564 (defun gnus-group-best-unread-group (&optional exclude-group)
5565 "Go to the group with the highest level.
5566 If EXCLUDE-GROUP, do not go to that group."
5567 (interactive)
5568 (goto-char (point-min))
5569 (let ((best 100000)
5570 unread best-point)
5571 (while (not (eobp))
5572 (setq unread (get-text-property (point) 'gnus-unread))
5573 (if (and (numberp unread) (> unread 0))
5574 (progn
5575 (if (and (get-text-property (point) 'gnus-level)
5576 (< (get-text-property (point) 'gnus-level) best)
5577 (or (not exclude-group)
5578 (not (equal exclude-group (gnus-group-group-name)))))
5579 (progn
5580 (setq best (get-text-property (point) 'gnus-level))
5581 (setq best-point (point))))))
5582 (forward-line 1))
5583 (if best-point (goto-char best-point))
5584 (gnus-summary-position-point)
5585 (and best-point (gnus-group-group-name))))
5587 (defun gnus-group-first-unread-group ()
5588 "Go to the first group with unread articles."
5589 (interactive)
5590 (prog1
5591 (let ((opoint (point))
5592 unread)
5593 (goto-char (point-min))
5594 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
5595 (and (numberp unread) ; Not a topic.
5596 (not (zerop unread))) ; Has unread articles.
5597 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
5598 (point) ; Success.
5599 (goto-char opoint)
5600 nil)) ; Not success.
5601 (gnus-group-position-point)))
5603 (defun gnus-group-enter-server-mode ()
5604 "Jump to the server buffer."
5605 (interactive)
5606 (gnus-enter-server-buffer))
5608 (defun gnus-group-make-group (name &optional method address)
5609 "Add a new newsgroup.
5610 The user will be prompted for a NAME, for a select METHOD, and an
5611 ADDRESS."
5612 (interactive
5613 (cons
5614 (read-string "Group name: ")
5615 (let ((method
5616 (completing-read
5617 "Method: " (append gnus-valid-select-methods gnus-server-alist)
5618 nil t nil 'gnus-method-history)))
5619 (cond ((assoc method gnus-valid-select-methods)
5620 (list method
5621 (if (memq 'prompt-address
5622 (assoc method gnus-valid-select-methods))
5623 (read-string "Address: ")
5624 "")))
5625 ((assoc method gnus-server-alist)
5626 (list method))
5628 (list method ""))))))
5630 (let* ((meth (and method (if address (list (intern method) address)
5631 method)))
5632 (nname (if method (gnus-group-prefixed-name name meth) name))
5633 backend info)
5634 (when (gnus-gethash nname gnus-newsrc-hashtb)
5635 (error "Group %s already exists" nname))
5636 ;; Subscribe to the new group.
5637 (gnus-group-change-level
5638 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
5639 gnus-level-default-subscribed gnus-level-killed
5640 (and (gnus-group-group-name)
5641 (gnus-gethash (gnus-group-group-name)
5642 gnus-newsrc-hashtb))
5644 ;; Make it active.
5645 (gnus-set-active nname (cons 1 0))
5646 (or (gnus-ephemeral-group-p name)
5647 (gnus-dribble-enter
5648 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")")))
5649 ;; Insert the line.
5650 (gnus-group-insert-group-line-info nname)
5651 (forward-line -1)
5652 (gnus-group-position-point)
5654 ;; Load the backend and try to make the backend create
5655 ;; the group as well.
5656 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
5657 nil meth))))
5658 gnus-valid-select-methods)
5659 (require backend))
5660 (gnus-check-server meth)
5661 (and (gnus-check-backend-function 'request-create-group nname)
5662 (gnus-request-create-group nname))
5665 (defun gnus-group-delete-group (group &optional force)
5666 "Delete the current group. Only meaningful with mail groups.
5667 If FORCE (the prefix) is non-nil, all the articles in the group will
5668 be deleted. This is \"deleted\" as in \"removed forever from the face
5669 of the Earth\". There is no undo. The user will be prompted before
5670 doing the deletion."
5671 (interactive
5672 (list (gnus-group-group-name)
5673 current-prefix-arg))
5674 (or group (error "No group to rename"))
5675 (or (gnus-check-backend-function 'request-delete-group group)
5676 (error "This backend does not support group deletion"))
5677 (prog1
5678 (if (not (gnus-yes-or-no-p
5679 (format
5680 "Do you really want to delete %s%s? "
5681 group (if force " and all its contents" ""))))
5682 () ; Whew!
5683 (gnus-message 6 "Deleting group %s..." group)
5684 (if (not (gnus-request-delete-group group force))
5685 (gnus-error 3 "Couldn't delete group %s" group)
5686 (gnus-message 6 "Deleting group %s...done" group)
5687 (gnus-group-goto-group group)
5688 (gnus-group-kill-group 1 t)
5689 (gnus-sethash group nil gnus-active-hashtb)
5691 (gnus-group-position-point)))
5693 (defun gnus-group-rename-group (group new-name)
5694 (interactive
5695 (list
5696 (gnus-group-group-name)
5697 (progn
5698 (or (gnus-check-backend-function
5699 'request-rename-group (gnus-group-group-name))
5700 (error "This backend does not support renaming groups"))
5701 (read-string "New group name: "))))
5703 (or (gnus-check-backend-function 'request-rename-group group)
5704 (error "This backend does not support renaming groups"))
5706 (or group (error "No group to rename"))
5707 (and (string-match "^[ \t]*$" new-name)
5708 (error "Not a valid group name"))
5710 ;; We find the proper prefixed name.
5711 (setq new-name
5712 (gnus-group-prefixed-name
5713 (gnus-group-real-name new-name)
5714 (gnus-info-method (gnus-get-info group))))
5716 (gnus-message 6 "Renaming group %s to %s..." group new-name)
5717 (prog1
5718 (if (not (gnus-request-rename-group group new-name))
5719 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
5720 ;; We rename the group internally by killing it...
5721 (gnus-group-goto-group group)
5722 (gnus-group-kill-group)
5723 ;; ... changing its name ...
5724 (setcar (cdar gnus-list-of-killed-groups) new-name)
5725 ;; ... and then yanking it. Magic!
5726 (gnus-group-yank-group)
5727 (gnus-set-active new-name (gnus-active group))
5728 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
5729 new-name)
5730 (gnus-group-position-point)))
5732 (defun gnus-group-edit-group (group &optional part)
5733 "Edit the group on the current line."
5734 (interactive (list (gnus-group-group-name)))
5735 (let* ((part (or part 'info))
5736 (done-func `(lambda ()
5737 "Exit editing mode and update the information."
5738 (interactive)
5739 (gnus-group-edit-group-done ',part ,group)))
5740 (winconf (current-window-configuration))
5741 info)
5742 (or group (error "No group on current line"))
5743 (or (setq info (gnus-get-info group))
5744 (error "Killed group; can't be edited"))
5745 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5746 (gnus-configure-windows 'edit-group)
5747 (gnus-add-current-to-buffer-list)
5748 (emacs-lisp-mode)
5749 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
5750 (use-local-map (copy-keymap emacs-lisp-mode-map))
5751 (local-set-key "\C-c\C-c" done-func)
5752 (make-local-variable 'gnus-prev-winconf)
5753 (setq gnus-prev-winconf winconf)
5754 (erase-buffer)
5755 (insert
5756 (cond
5757 ((eq part 'method)
5758 ";; Type `C-c C-c' after editing the select method.\n\n")
5759 ((eq part 'params)
5760 ";; Type `C-c C-c' after editing the group parameters.\n\n")
5761 ((eq part 'info)
5762 ";; Type `C-c C-c' after editing the group info.\n\n")))
5763 (insert
5764 (pp-to-string
5765 (cond ((eq part 'method)
5766 (or (gnus-info-method info) "native"))
5767 ((eq part 'params)
5768 (gnus-info-params info))
5769 (t info)))
5770 "\n")))
5772 (defun gnus-group-edit-group-method (group)
5773 "Edit the select method of GROUP."
5774 (interactive (list (gnus-group-group-name)))
5775 (gnus-group-edit-group group 'method))
5777 (defun gnus-group-edit-group-parameters (group)
5778 "Edit the group parameters of GROUP."
5779 (interactive (list (gnus-group-group-name)))
5780 (gnus-group-edit-group group 'params))
5782 (defun gnus-group-edit-group-done (part group)
5783 "Get info from buffer, update variables and jump to the group buffer."
5784 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5785 (goto-char (point-min))
5786 (let* ((form (read (current-buffer)))
5787 (winconf gnus-prev-winconf)
5788 (method (cond ((eq part 'info) (nth 4 form))
5789 ((eq part 'method) form)
5790 (t nil)))
5791 (info (cond ((eq part 'info) form)
5792 ((eq part 'method) (gnus-get-info group))
5793 (t nil)))
5794 (new-group (if info
5795 (if (or (not method)
5796 (gnus-server-equal
5797 gnus-select-method method))
5798 (gnus-group-real-name (car info))
5799 (gnus-group-prefixed-name
5800 (gnus-group-real-name (car info)) method))
5801 nil)))
5802 (when (and new-group
5803 (not (equal new-group group)))
5804 (when (gnus-group-goto-group group)
5805 (gnus-group-kill-group 1))
5806 (gnus-activate-group new-group))
5807 ;; Set the info.
5808 (if (and info new-group)
5809 (progn
5810 (setq info (gnus-copy-sequence info))
5811 (setcar info new-group)
5812 (unless (gnus-server-equal method "native")
5813 (unless (nthcdr 3 info)
5814 (nconc info (list nil nil)))
5815 (unless (nthcdr 4 info)
5816 (nconc info (list nil)))
5817 (gnus-info-set-method info method))
5818 (gnus-group-set-info info))
5819 (gnus-group-set-info form (or new-group group) part))
5820 (kill-buffer (current-buffer))
5821 (and winconf (set-window-configuration winconf))
5822 (set-buffer gnus-group-buffer)
5823 (gnus-group-update-group (or new-group group))
5824 (gnus-group-position-point)))
5826 (defun gnus-group-make-help-group ()
5827 "Create the Gnus documentation group."
5828 (interactive)
5829 (let ((path load-path)
5830 (name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
5831 file dir)
5832 (and (gnus-gethash name gnus-newsrc-hashtb)
5833 (error "Documentation group already exists"))
5834 (while path
5835 (setq dir (file-name-as-directory (expand-file-name (pop path)))
5836 file nil)
5837 (when (or (file-exists-p (setq file (concat dir "gnus-tut.txt")))
5838 (file-exists-p
5839 (setq file (concat (file-name-directory
5840 (directory-file-name dir))
5841 "etc/gnus-tut.txt"))))
5842 (setq path nil)))
5843 (if (not file)
5844 (gnus-message 1 "Couldn't find doc group")
5845 (gnus-group-make-group
5846 (gnus-group-real-name name)
5847 (list 'nndoc "gnus-help"
5848 (list 'nndoc-address file)
5849 (list 'nndoc-article-type 'mbox)))))
5850 (gnus-group-position-point))
5852 (defun gnus-group-make-doc-group (file type)
5853 "Create a group that uses a single file as the source."
5854 (interactive
5855 (list (read-file-name "File name: ")
5856 (and current-prefix-arg 'ask)))
5857 (when (eq type 'ask)
5858 (let ((err "")
5859 char found)
5860 (while (not found)
5861 (message
5862 "%sFile type (mbox, babyl, digest, forward, mmfd, guess) [mbdfag]: "
5863 err)
5864 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
5865 ((= char ?b) 'babyl)
5866 ((= char ?d) 'digest)
5867 ((= char ?f) 'forward)
5868 ((= char ?a) 'mmfd)
5869 (t (setq err (format "%c unknown. " char))
5870 nil))))
5871 (setq type found)))
5872 (let* ((file (expand-file-name file))
5873 (name (gnus-generate-new-group-name
5874 (gnus-group-prefixed-name
5875 (file-name-nondirectory file) '(nndoc "")))))
5876 (gnus-group-make-group
5877 (gnus-group-real-name name)
5878 (list 'nndoc (file-name-nondirectory file)
5879 (list 'nndoc-address file)
5880 (list 'nndoc-article-type (or type 'guess))))))
5882 (defun gnus-group-make-archive-group (&optional all)
5883 "Create the (ding) Gnus archive group of the most recent articles.
5884 Given a prefix, create a full group."
5885 (interactive "P")
5886 (let ((group (gnus-group-prefixed-name
5887 (if all "ding.archives" "ding.recent") '(nndir ""))))
5888 (and (gnus-gethash group gnus-newsrc-hashtb)
5889 (error "Archive group already exists"))
5890 (gnus-group-make-group
5891 (gnus-group-real-name group)
5892 (list 'nndir (if all "hpc" "edu")
5893 (list 'nndir-directory
5894 (if all gnus-group-archive-directory
5895 gnus-group-recent-archive-directory))))))
5897 (defun gnus-group-make-directory-group (dir)
5898 "Create an nndir group.
5899 The user will be prompted for a directory. The contents of this
5900 directory will be used as a newsgroup. The directory should contain
5901 mail messages or news articles in files that have numeric names."
5902 (interactive
5903 (list (read-file-name "Create group from directory: ")))
5904 (or (file-exists-p dir) (error "No such directory"))
5905 (or (file-directory-p dir) (error "Not a directory"))
5906 (let ((ext "")
5907 (i 0)
5908 group)
5909 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
5910 (setq group
5911 (gnus-group-prefixed-name
5912 (concat (file-name-as-directory (directory-file-name dir))
5913 ext)
5914 '(nndir "")))
5915 (setq ext (format "<%d>" (setq i (1+ i)))))
5916 (gnus-group-make-group
5917 (gnus-group-real-name group)
5918 (list 'nndir group (list 'nndir-directory dir)))))
5920 (defun gnus-group-make-kiboze-group (group address scores)
5921 "Create an nnkiboze group.
5922 The user will be prompted for a name, a regexp to match groups, and
5923 score file entries for articles to include in the group."
5924 (interactive
5925 (list
5926 (read-string "nnkiboze group name: ")
5927 (read-string "Source groups (regexp): ")
5928 (let ((headers (mapcar (lambda (group) (list group))
5929 '("subject" "from" "number" "date" "message-id"
5930 "references" "chars" "lines" "xref"
5931 "followup" "all" "body" "head")))
5932 scores header regexp regexps)
5933 (while (not (equal "" (setq header (completing-read
5934 "Match on header: " headers nil t))))
5935 (setq regexps nil)
5936 (while (not (equal "" (setq regexp (read-string
5937 (format "Match on %s (string): "
5938 header)))))
5939 (setq regexps (cons (list regexp nil nil 'r) regexps)))
5940 (setq scores (cons (cons header regexps) scores)))
5941 scores)))
5942 (gnus-group-make-group group "nnkiboze" address)
5943 (nnheader-temp-write (gnus-score-file-name (concat "nnkiboze:" group))
5944 (let (emacs-lisp-mode-hook)
5945 (pp scores (current-buffer)))))
5947 (defun gnus-group-add-to-virtual (n vgroup)
5948 "Add the current group to a virtual group."
5949 (interactive
5950 (list current-prefix-arg
5951 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
5952 "nnvirtual:")))
5953 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
5954 (error "%s is not an nnvirtual group" vgroup))
5955 (let* ((groups (gnus-group-process-prefix n))
5956 (method (gnus-info-method (gnus-get-info vgroup))))
5957 (setcar (cdr method)
5958 (concat
5959 (nth 1 method) "\\|"
5960 (mapconcat
5961 (lambda (s)
5962 (gnus-group-remove-mark s)
5963 (concat "\\(^" (regexp-quote s) "$\\)"))
5964 groups "\\|"))))
5965 (gnus-group-position-point))
5967 (defun gnus-group-make-empty-virtual (group)
5968 "Create a new, fresh, empty virtual group."
5969 (interactive "sCreate new, empty virtual group: ")
5970 (let* ((method (list 'nnvirtual "^$"))
5971 (pgroup (gnus-group-prefixed-name group method)))
5972 ;; Check whether it exists already.
5973 (and (gnus-gethash pgroup gnus-newsrc-hashtb)
5974 (error "Group %s already exists." pgroup))
5975 ;; Subscribe the new group after the group on the current line.
5976 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
5977 (gnus-group-update-group pgroup)
5978 (forward-line -1)
5979 (gnus-group-position-point)))
5981 (defun gnus-group-enter-directory (dir)
5982 "Enter an ephemeral nneething group."
5983 (interactive "DDirectory to read: ")
5984 (let* ((method (list 'nneething dir '(nneething-read-only t)))
5985 (leaf (gnus-group-prefixed-name
5986 (file-name-nondirectory (directory-file-name dir))
5987 method))
5988 (name (gnus-generate-new-group-name leaf)))
5989 (unless (gnus-group-read-ephemeral-group
5990 name method t
5991 (cons (current-buffer)
5992 (if (eq major-mode 'gnus-summary-mode)
5993 'summary 'group)))
5994 (error "Couldn't enter %s" dir))))
5996 ;; Group sorting commands
5997 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
5999 (defun gnus-group-sort-groups (func &optional reverse)
6000 "Sort the group buffer according to FUNC.
6001 If REVERSE, reverse the sorting order."
6002 (interactive (list gnus-group-sort-function
6003 current-prefix-arg))
6004 (let ((func (cond
6005 ((not (listp func)) func)
6006 ((null func) func)
6007 ((= 1 (length func)) (car func))
6008 (t `(lambda (t1 t2)
6009 ,(gnus-make-sort-function
6010 (reverse func)))))))
6011 ;; We peel off the dummy group from the alist.
6012 (when func
6013 (when (equal (car (gnus-info-group gnus-newsrc-alist)) "dummy.group")
6014 (pop gnus-newsrc-alist))
6015 ;; Do the sorting.
6016 (setq gnus-newsrc-alist
6017 (sort gnus-newsrc-alist func))
6018 (when reverse
6019 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
6020 ;; Regenerate the hash table.
6021 (gnus-make-hashtable-from-newsrc-alist)
6022 (gnus-group-list-groups))))
6024 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
6025 "Sort the group buffer alphabetically by group name.
6026 If REVERSE, sort in reverse order."
6027 (interactive "P")
6028 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
6030 (defun gnus-group-sort-groups-by-unread (&optional reverse)
6031 "Sort the group buffer by number of unread articles.
6032 If REVERSE, sort in reverse order."
6033 (interactive "P")
6034 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
6036 (defun gnus-group-sort-groups-by-level (&optional reverse)
6037 "Sort the group buffer by group level.
6038 If REVERSE, sort in reverse order."
6039 (interactive "P")
6040 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
6042 (defun gnus-group-sort-groups-by-score (&optional reverse)
6043 "Sort the group buffer by group score.
6044 If REVERSE, sort in reverse order."
6045 (interactive "P")
6046 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
6048 (defun gnus-group-sort-groups-by-rank (&optional reverse)
6049 "Sort the group buffer by group rank.
6050 If REVERSE, sort in reverse order."
6051 (interactive "P")
6052 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
6054 (defun gnus-group-sort-groups-by-method (&optional reverse)
6055 "Sort the group buffer alphabetically by backend name.
6056 If REVERSE, sort in reverse order."
6057 (interactive "P")
6058 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
6060 (defun gnus-group-sort-by-alphabet (info1 info2)
6061 "Sort alphabetically."
6062 (string< (gnus-info-group info1) (gnus-info-group info2)))
6064 (defun gnus-group-sort-by-unread (info1 info2)
6065 "Sort by number of unread articles."
6066 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
6067 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
6068 (< (or (and (numberp n1) n1) 0)
6069 (or (and (numberp n2) n2) 0))))
6071 (defun gnus-group-sort-by-level (info1 info2)
6072 "Sort by level."
6073 (< (gnus-info-level info1) (gnus-info-level info2)))
6075 (defun gnus-group-sort-by-method (info1 info2)
6076 "Sort alphabetically by backend name."
6077 (string< (symbol-name (car (gnus-find-method-for-group
6078 (gnus-info-group info1) info1)))
6079 (symbol-name (car (gnus-find-method-for-group
6080 (gnus-info-group info2) info2)))))
6082 (defun gnus-group-sort-by-score (info1 info2)
6083 "Sort by group score."
6084 (< (gnus-info-score info1) (gnus-info-score info2)))
6086 (defun gnus-group-sort-by-rank (info1 info2)
6087 "Sort by level and score."
6088 (let ((level1 (gnus-info-level info1))
6089 (level2 (gnus-info-level info2)))
6090 (or (< level1 level2)
6091 (and (= level1 level2)
6092 (> (gnus-info-score info1) (gnus-info-score info2))))))
6094 ;; Group catching up.
6096 (defun gnus-group-clear-data (n)
6097 "Clear all marks and read ranges from the current group."
6098 (interactive "P")
6099 (let ((groups (gnus-group-process-prefix n))
6100 group info)
6101 (while (setq group (pop groups))
6102 (setq info (gnus-get-info group))
6103 (gnus-info-set-read info nil)
6104 (when (gnus-info-marks info)
6105 (gnus-info-set-marks info nil))
6106 (gnus-get-unread-articles-in-group info (gnus-active group) t)
6107 (when (gnus-group-goto-group group)
6108 (gnus-group-remove-mark group)
6109 (gnus-group-update-group-line)))))
6111 (defun gnus-group-catchup-current (&optional n all)
6112 "Mark all articles not marked as unread in current newsgroup as read.
6113 If prefix argument N is numeric, the ARG next newsgroups will be
6114 caught up. If ALL is non-nil, marked articles will also be marked as
6115 read. Cross references (Xref: header) of articles are ignored.
6116 The difference between N and actual number of newsgroups that were
6117 caught up is returned."
6118 (interactive "P")
6119 (unless (gnus-group-group-name)
6120 (error "No group on the current line"))
6121 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
6122 gnus-expert-user
6123 (gnus-y-or-n-p
6124 (if all
6125 "Do you really want to mark all articles as read? "
6126 "Mark all unread articles as read? "))))
6128 (let ((groups (gnus-group-process-prefix n))
6129 (ret 0))
6130 (while groups
6131 ;; Virtual groups have to be given special treatment.
6132 (let ((method (gnus-find-method-for-group (car groups))))
6133 (if (eq 'nnvirtual (car method))
6134 (nnvirtual-catchup-group
6135 (gnus-group-real-name (car groups)) (nth 1 method) all)))
6136 (gnus-group-remove-mark (car groups))
6137 (if (>= (gnus-group-group-level) gnus-level-zombie)
6138 (gnus-message 2 "Dead groups can't be caught up")
6139 (if (prog1
6140 (gnus-group-goto-group (car groups))
6141 (gnus-group-catchup (car groups) all))
6142 (gnus-group-update-group-line)
6143 (setq ret (1+ ret))))
6144 (setq groups (cdr groups)))
6145 (gnus-group-next-unread-group 1)
6146 ret)))
6148 (defun gnus-group-catchup-current-all (&optional n)
6149 "Mark all articles in current newsgroup as read.
6150 Cross references (Xref: header) of articles are ignored."
6151 (interactive "P")
6152 (gnus-group-catchup-current n 'all))
6154 (defun gnus-group-catchup (group &optional all)
6155 "Mark all articles in GROUP as read.
6156 If ALL is non-nil, all articles are marked as read.
6157 The return value is the number of articles that were marked as read,
6158 or nil if no action could be taken."
6159 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
6160 (num (car entry)))
6161 ;; Do the updating only if the newsgroup isn't killed.
6162 (if (not (numberp (car entry)))
6163 (gnus-message 1 "Can't catch up; non-active group")
6164 ;; Do auto-expirable marks if that's required.
6165 (when (gnus-group-auto-expirable-p group)
6166 (gnus-add-marked-articles
6167 group 'expire (gnus-list-of-unread-articles group))
6168 (when all
6169 (let ((marks (nth 3 (nth 2 entry))))
6170 (gnus-add-marked-articles
6171 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))
6172 (gnus-add-marked-articles
6173 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))))))
6174 (when entry
6175 (gnus-update-read-articles group nil)
6176 ;; Also nix out the lists of marks and dormants.
6177 (when all
6178 (gnus-add-marked-articles group 'tick nil nil 'force)
6179 (gnus-add-marked-articles group 'dormant nil nil 'force))
6180 (run-hooks 'gnus-group-catchup-group-hook)
6181 num))))
6183 (defun gnus-group-expire-articles (&optional n)
6184 "Expire all expirable articles in the current newsgroup."
6185 (interactive "P")
6186 (let ((groups (gnus-group-process-prefix n))
6187 group)
6188 (unless groups
6189 (error "No groups to expire"))
6190 (while (setq group (pop groups))
6191 (gnus-group-remove-mark group)
6192 (when (gnus-check-backend-function 'request-expire-articles group)
6193 (gnus-message 6 "Expiring articles in %s..." group)
6194 (let* ((info (gnus-get-info group))
6195 (expirable (if (gnus-group-total-expirable-p group)
6196 (cons nil (gnus-list-of-read-articles group))
6197 (assq 'expire (gnus-info-marks info))))
6198 (expiry-wait (gnus-group-get-parameter group 'expiry-wait)))
6199 (when expirable
6200 (setcdr
6201 expirable
6202 (gnus-compress-sequence
6203 (if expiry-wait
6204 ;; We set the expiry variables to the groupp
6205 ;; parameter.
6206 (let ((nnmail-expiry-wait-function nil)
6207 (nnmail-expiry-wait expiry-wait))
6208 (gnus-request-expire-articles
6209 (gnus-uncompress-sequence (cdr expirable)) group))
6210 ;; Just expire using the normal expiry values.
6211 (gnus-request-expire-articles
6212 (gnus-uncompress-sequence (cdr expirable)) group))))
6213 (gnus-close-group group))
6214 (gnus-message 6 "Expiring articles in %s...done" group)))
6215 (gnus-group-position-point))))
6217 (defun gnus-group-expire-all-groups ()
6218 "Expire all expirable articles in all newsgroups."
6219 (interactive)
6220 (save-excursion
6221 (gnus-message 5 "Expiring...")
6222 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
6223 (cdr gnus-newsrc-alist))))
6224 (gnus-group-expire-articles nil)))
6225 (gnus-group-position-point)
6226 (gnus-message 5 "Expiring...done"))
6228 (defun gnus-group-set-current-level (n level)
6229 "Set the level of the next N groups to LEVEL."
6230 (interactive
6231 (list
6232 current-prefix-arg
6233 (string-to-int
6234 (let ((s (read-string
6235 (format "Level (default %s): "
6236 (or (gnus-group-group-level)
6237 gnus-level-default-subscribed)))))
6238 (if (string-match "^\\s-*$" s)
6239 (int-to-string (or (gnus-group-group-level)
6240 gnus-level-default-subscribed))
6241 s)))))
6242 (or (and (>= level 1) (<= level gnus-level-killed))
6243 (error "Illegal level: %d" level))
6244 (let ((groups (gnus-group-process-prefix n))
6245 group)
6246 (while (setq group (pop groups))
6247 (gnus-group-remove-mark group)
6248 (gnus-message 6 "Changed level of %s from %d to %d"
6249 group (or (gnus-group-group-level) gnus-level-killed)
6250 level)
6251 (gnus-group-change-level
6252 group level (or (gnus-group-group-level) gnus-level-killed))
6253 (gnus-group-update-group-line)))
6254 (gnus-group-position-point))
6256 (defun gnus-group-unsubscribe-current-group (&optional n)
6257 "Toggle subscription of the current group.
6258 If given numerical prefix, toggle the N next groups."
6259 (interactive "P")
6260 (let ((groups (gnus-group-process-prefix n))
6261 group)
6262 (while groups
6263 (setq group (car groups)
6264 groups (cdr groups))
6265 (gnus-group-remove-mark group)
6266 (gnus-group-unsubscribe-group
6267 group (if (<= (gnus-group-group-level) gnus-level-subscribed)
6268 gnus-level-default-unsubscribed
6269 gnus-level-default-subscribed) t)
6270 (gnus-group-update-group-line))
6271 (gnus-group-next-group 1)))
6273 (defun gnus-group-unsubscribe-group (group &optional level silent)
6274 "Toggle subscription to GROUP.
6275 Killed newsgroups are subscribed. If SILENT, don't try to update the
6276 group line."
6277 (interactive
6278 (list (completing-read
6279 "Group: " gnus-active-hashtb nil
6280 (gnus-read-active-file-p)
6281 nil
6282 'gnus-group-history)))
6283 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
6284 (cond
6285 ((string-match "^[ \t]$" group)
6286 (error "Empty group name"))
6287 (newsrc
6288 ;; Toggle subscription flag.
6289 (gnus-group-change-level
6290 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
6291 gnus-level-subscribed)
6292 (1+ gnus-level-subscribed)
6293 gnus-level-default-subscribed)))
6294 (unless silent
6295 (gnus-group-update-group group)))
6296 ((and (stringp group)
6297 (or (not (gnus-read-active-file-p))
6298 (gnus-active group)))
6299 ;; Add new newsgroup.
6300 (gnus-group-change-level
6301 group
6302 (if level level gnus-level-default-subscribed)
6303 (or (and (member group gnus-zombie-list)
6304 gnus-level-zombie)
6305 gnus-level-killed)
6306 (and (gnus-group-group-name)
6307 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
6308 (unless silent
6309 (gnus-group-update-group group)))
6310 (t (error "No such newsgroup: %s" group)))
6311 (gnus-group-position-point)))
6313 (defun gnus-group-transpose-groups (n)
6314 "Move the current newsgroup up N places.
6315 If given a negative prefix, move down instead. The difference between
6316 N and the number of steps taken is returned."
6317 (interactive "p")
6318 (or (gnus-group-group-name)
6319 (error "No group on current line"))
6320 (gnus-group-kill-group 1)
6321 (prog1
6322 (forward-line (- n))
6323 (gnus-group-yank-group)
6324 (gnus-group-position-point)))
6326 (defun gnus-group-kill-all-zombies ()
6327 "Kill all zombie newsgroups."
6328 (interactive)
6329 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
6330 (setq gnus-zombie-list nil)
6331 (gnus-group-list-groups))
6333 (defun gnus-group-kill-region (begin end)
6334 "Kill newsgroups in current region (excluding current point).
6335 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
6336 (interactive "r")
6337 (let ((lines
6338 ;; Count lines.
6339 (save-excursion
6340 (count-lines
6341 (progn
6342 (goto-char begin)
6343 (beginning-of-line)
6344 (point))
6345 (progn
6346 (goto-char end)
6347 (beginning-of-line)
6348 (point))))))
6349 (goto-char begin)
6350 (beginning-of-line) ;Important when LINES < 1
6351 (gnus-group-kill-group lines)))
6353 (defun gnus-group-kill-group (&optional n discard)
6354 "Kill the next N groups.
6355 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
6356 However, only groups that were alive can be yanked; already killed
6357 groups or zombie groups can't be yanked.
6358 The return value is the name of the group that was killed, or a list
6359 of groups killed."
6360 (interactive "P")
6361 (let ((buffer-read-only nil)
6362 (groups (gnus-group-process-prefix n))
6363 group entry level out)
6364 (if (< (length groups) 10)
6365 ;; This is faster when there are few groups.
6366 (while groups
6367 (push (setq group (pop groups)) out)
6368 (gnus-group-remove-mark group)
6369 (setq level (gnus-group-group-level))
6370 (gnus-delete-line)
6371 (when (and (not discard)
6372 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
6373 (push (cons (car entry) (nth 2 entry))
6374 gnus-list-of-killed-groups))
6375 (gnus-group-change-level
6376 (if entry entry group) gnus-level-killed (if entry nil level)))
6377 ;; If there are lots and lots of groups to be killed, we use
6378 ;; this thing instead.
6379 (let (entry)
6380 (setq groups (nreverse groups))
6381 (while groups
6382 (gnus-group-remove-mark (setq group (pop groups)))
6383 (gnus-delete-line)
6384 (push group gnus-killed-list)
6385 (setq gnus-newsrc-alist
6386 (delq (assoc group gnus-newsrc-alist)
6387 gnus-newsrc-alist))
6388 (when gnus-group-change-level-function
6389 (funcall gnus-group-change-level-function group 9 3))
6390 (cond
6391 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
6392 (push (cons (car entry) (nth 2 entry))
6393 gnus-list-of-killed-groups)
6394 (setcdr (cdr entry) (cdddr entry)))
6395 ((member group gnus-zombie-list)
6396 (setq gnus-zombie-list (delete group gnus-zombie-list)))))
6397 (gnus-make-hashtable-from-newsrc-alist)))
6399 (gnus-group-position-point)
6400 (if (< (length out) 2) (car out) (nreverse out))))
6402 (defun gnus-group-yank-group (&optional arg)
6403 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
6404 inserting it before the current newsgroup. The numeric ARG specifies
6405 how many newsgroups are to be yanked. The name of the newsgroup yanked
6406 is returned, or (if several groups are yanked) a list of yanked groups
6407 is returned."
6408 (interactive "p")
6409 (setq arg (or arg 1))
6410 (let (info group prev out)
6411 (while (>= (decf arg) 0)
6412 (if (not (setq info (pop gnus-list-of-killed-groups)))
6413 (error "No more newsgroups to yank"))
6414 (push (setq group (nth 1 info)) out)
6415 ;; Find which newsgroup to insert this one before - search
6416 ;; backward until something suitable is found. If there are no
6417 ;; other newsgroups in this buffer, just make this newsgroup the
6418 ;; first newsgroup.
6419 (setq prev (gnus-group-group-name))
6420 (gnus-group-change-level
6421 info (gnus-info-level (cdr info)) gnus-level-killed
6422 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
6424 (gnus-group-insert-group-line-info group))
6425 (forward-line -1)
6426 (gnus-group-position-point)
6427 (if (< (length out) 2) (car out) (nreverse out))))
6429 (defun gnus-group-kill-level (level)
6430 "Kill all groups that is on a certain LEVEL."
6431 (interactive "nKill all groups on level: ")
6432 (cond
6433 ((= level gnus-level-zombie)
6434 (setq gnus-killed-list
6435 (nconc gnus-zombie-list gnus-killed-list))
6436 (setq gnus-zombie-list nil))
6437 ((and (< level gnus-level-zombie)
6438 (> level 0)
6439 (or gnus-expert-user
6440 (gnus-yes-or-no-p
6441 (format
6442 "Do you really want to kill all groups on level %d? "
6443 level))))
6444 (let* ((prev gnus-newsrc-alist)
6445 (alist (cdr prev)))
6446 (while alist
6447 (if (= (gnus-info-level (car alist)) level)
6448 (progn
6449 (push (gnus-info-group (car alist)) gnus-killed-list)
6450 (setcdr prev (cdr alist)))
6451 (setq prev alist))
6452 (setq alist (cdr alist)))
6453 (gnus-make-hashtable-from-newsrc-alist)
6454 (gnus-group-list-groups)))
6456 (error "Can't kill; illegal level: %d" level))))
6458 (defun gnus-group-list-all-groups (&optional arg)
6459 "List all newsgroups with level ARG or lower.
6460 Default is gnus-level-unsubscribed, which lists all subscribed and most
6461 unsubscribed groups."
6462 (interactive "P")
6463 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
6465 ;; Redefine this to list ALL killed groups if prefix arg used.
6466 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
6467 (defun gnus-group-list-killed (&optional arg)
6468 "List all killed newsgroups in the group buffer.
6469 If ARG is non-nil, list ALL killed groups known to Gnus. This may
6470 entail asking the server for the groups."
6471 (interactive "P")
6472 ;; Find all possible killed newsgroups if arg.
6473 (when arg
6474 (gnus-get-killed-groups))
6475 (if (not gnus-killed-list)
6476 (gnus-message 6 "No killed groups")
6477 (let (gnus-group-list-mode)
6478 (funcall gnus-group-prepare-function
6479 gnus-level-killed t gnus-level-killed))
6480 (goto-char (point-min)))
6481 (gnus-group-position-point))
6483 (defun gnus-group-list-zombies ()
6484 "List all zombie newsgroups in the group buffer."
6485 (interactive)
6486 (if (not gnus-zombie-list)
6487 (gnus-message 6 "No zombie groups")
6488 (let (gnus-group-list-mode)
6489 (funcall gnus-group-prepare-function
6490 gnus-level-zombie t gnus-level-zombie))
6491 (goto-char (point-min)))
6492 (gnus-group-position-point))
6494 (defun gnus-group-list-active ()
6495 "List all groups that are available from the server(s)."
6496 (interactive)
6497 ;; First we make sure that we have really read the active file.
6498 (unless (gnus-read-active-file-p)
6499 (let ((gnus-read-active-file t))
6500 (gnus-read-active-file)))
6501 ;; Find all groups and sort them.
6502 (let ((groups
6503 (sort
6504 (let (list)
6505 (mapatoms
6506 (lambda (sym)
6507 (and (boundp sym)
6508 (symbol-value sym)
6509 (setq list (cons (symbol-name sym) list))))
6510 gnus-active-hashtb)
6511 list)
6512 'string<))
6513 (buffer-read-only nil))
6514 (erase-buffer)
6515 (while groups
6516 (gnus-group-insert-group-line-info (pop groups)))
6517 (goto-char (point-min))))
6519 (defun gnus-activate-all-groups (level)
6520 "Activate absolutely all groups."
6521 (interactive (list 7))
6522 (let ((gnus-activate-level level)
6523 (gnus-activate-foreign-newsgroups level))
6524 (gnus-group-get-new-news)))
6526 (defun gnus-group-get-new-news (&optional arg)
6527 "Get newly arrived articles.
6528 If ARG is a number, it specifies which levels you are interested in
6529 re-scanning. If ARG is non-nil and not a number, this will force
6530 \"hard\" re-reading of the active files from all servers."
6531 (interactive "P")
6532 (run-hooks 'gnus-get-new-news-hook)
6533 ;; We might read in new NoCeM messages here.
6534 (when (and gnus-use-nocem
6535 (null arg))
6536 (gnus-nocem-scan-groups))
6537 ;; If ARG is not a number, then we read the active file.
6538 (when (and arg (not (numberp arg)))
6539 (let ((gnus-read-active-file t))
6540 (gnus-read-active-file))
6541 (setq arg nil))
6543 (setq arg (gnus-group-default-level arg t))
6544 (if (and gnus-read-active-file (not arg))
6545 (progn
6546 (gnus-read-active-file)
6547 (gnus-get-unread-articles arg))
6548 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
6549 (gnus-get-unread-articles arg)))
6550 (run-hooks 'gnus-after-getting-new-news-hook)
6551 (gnus-group-list-groups))
6553 (defun gnus-group-get-new-news-this-group (&optional n)
6554 "Check for newly arrived news in the current group (and the N-1 next groups).
6555 The difference between N and the number of newsgroup checked is returned.
6556 If N is negative, this group and the N-1 previous groups will be checked."
6557 (interactive "P")
6558 (let* ((groups (gnus-group-process-prefix n))
6559 (ret (if (numberp n) (- n (length groups)) 0))
6560 (beg (unless n (point)))
6561 group)
6562 (while (setq group (pop groups))
6563 (gnus-group-remove-mark group)
6564 (if (gnus-activate-group group 'scan)
6565 (progn
6566 (gnus-get-unread-articles-in-group
6567 (gnus-get-info group) (gnus-active group) t)
6568 (unless (gnus-virtual-group-p group)
6569 (gnus-close-group group))
6570 (gnus-group-update-group group))
6571 (if (eq (gnus-server-status (gnus-find-method-for-group group))
6572 'denied)
6573 (gnus-error "Server denied access")
6574 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
6575 (when beg (goto-char beg))
6576 (when gnus-goto-next-group-when-activating
6577 (gnus-group-next-unread-group 1 t))
6578 (gnus-summary-position-point)
6579 ret))
6581 (defun gnus-group-fetch-faq (group &optional faq-dir)
6582 "Fetch the FAQ for the current group."
6583 (interactive
6584 (list
6585 (and (gnus-group-group-name)
6586 (gnus-group-real-name (gnus-group-group-name)))
6587 (cond (current-prefix-arg
6588 (completing-read
6589 "Faq dir: " (and (listp gnus-group-faq-directory)
6590 (mapcar (lambda (file) (list file))
6591 gnus-group-faq-directory)))))))
6592 (or faq-dir
6593 (setq faq-dir (if (listp gnus-group-faq-directory)
6594 (car gnus-group-faq-directory)
6595 gnus-group-faq-directory)))
6596 (or group (error "No group name given"))
6597 (let ((file (concat (file-name-as-directory faq-dir)
6598 (gnus-group-real-name group))))
6599 (if (not (file-exists-p file))
6600 (error "No such file: %s" file)
6601 (find-file file))))
6603 (defun gnus-group-describe-group (force &optional group)
6604 "Display a description of the current newsgroup."
6605 (interactive (list current-prefix-arg (gnus-group-group-name)))
6606 (let* ((method (gnus-find-method-for-group group))
6607 (mname (gnus-group-prefixed-name "" method))
6608 desc)
6609 (when (and force
6610 gnus-description-hashtb)
6611 (gnus-sethash mname nil gnus-description-hashtb))
6612 (or group (error "No group name given"))
6613 (and (or (and gnus-description-hashtb
6614 ;; We check whether this group's method has been
6615 ;; queried for a description file.
6616 (gnus-gethash mname gnus-description-hashtb))
6617 (setq desc (gnus-group-get-description group))
6618 (gnus-read-descriptions-file method))
6619 (gnus-message 1
6620 (or desc (gnus-gethash group gnus-description-hashtb)
6621 "No description available")))))
6623 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6624 (defun gnus-group-describe-all-groups (&optional force)
6625 "Pop up a buffer with descriptions of all newsgroups."
6626 (interactive "P")
6627 (and force (setq gnus-description-hashtb nil))
6628 (if (not (or gnus-description-hashtb
6629 (gnus-read-all-descriptions-files)))
6630 (error "Couldn't request descriptions file"))
6631 (let ((buffer-read-only nil)
6633 (erase-buffer)
6634 (mapatoms
6635 (lambda (group)
6636 (setq b (point))
6637 (insert (format " *: %-20s %s\n" (symbol-name group)
6638 (symbol-value group)))
6639 (gnus-add-text-properties
6640 b (1+ b) (list 'gnus-group group
6641 'gnus-unread t 'gnus-marked nil
6642 'gnus-level (1+ gnus-level-subscribed))))
6643 gnus-description-hashtb)
6644 (goto-char (point-min))
6645 (gnus-group-position-point)))
6647 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
6648 (defun gnus-group-apropos (regexp &optional search-description)
6649 "List all newsgroups that have names that match a regexp."
6650 (interactive "sGnus apropos (regexp): ")
6651 (let ((prev "")
6652 (obuf (current-buffer))
6653 groups des)
6654 ;; Go through all newsgroups that are known to Gnus.
6655 (mapatoms
6656 (lambda (group)
6657 (and (symbol-name group)
6658 (string-match regexp (symbol-name group))
6659 (setq groups (cons (symbol-name group) groups))))
6660 gnus-active-hashtb)
6661 ;; Also go through all descriptions that are known to Gnus.
6662 (when search-description
6663 (mapatoms
6664 (lambda (group)
6665 (and (string-match regexp (symbol-value group))
6666 (gnus-active (symbol-name group))
6667 (setq groups (cons (symbol-name group) groups))))
6668 gnus-description-hashtb))
6669 (if (not groups)
6670 (gnus-message 3 "No groups matched \"%s\"." regexp)
6671 ;; Print out all the groups.
6672 (save-excursion
6673 (pop-to-buffer "*Gnus Help*")
6674 (buffer-disable-undo (current-buffer))
6675 (erase-buffer)
6676 (setq groups (sort groups 'string<))
6677 (while groups
6678 ;; Groups may be entered twice into the list of groups.
6679 (if (not (string= (car groups) prev))
6680 (progn
6681 (insert (setq prev (car groups)) "\n")
6682 (if (and gnus-description-hashtb
6683 (setq des (gnus-gethash (car groups)
6684 gnus-description-hashtb)))
6685 (insert " " des "\n"))))
6686 (setq groups (cdr groups)))
6687 (goto-char (point-min))))
6688 (pop-to-buffer obuf)))
6690 (defun gnus-group-description-apropos (regexp)
6691 "List all newsgroups that have names or descriptions that match a regexp."
6692 (interactive "sGnus description apropos (regexp): ")
6693 (if (not (or gnus-description-hashtb
6694 (gnus-read-all-descriptions-files)))
6695 (error "Couldn't request descriptions file"))
6696 (gnus-group-apropos regexp t))
6698 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6699 (defun gnus-group-list-matching (level regexp &optional all lowest)
6700 "List all groups with unread articles that match REGEXP.
6701 If the prefix LEVEL is non-nil, it should be a number that says which
6702 level to cut off listing groups.
6703 If ALL, also list groups with no unread articles.
6704 If LOWEST, don't list groups with level lower than LOWEST.
6706 This command may read the active file."
6707 (interactive "P\nsList newsgroups matching: ")
6708 ;; First make sure active file has been read.
6709 (when (and level
6710 (> (prefix-numeric-value level) gnus-level-killed))
6711 (gnus-get-killed-groups))
6712 (gnus-group-prepare-flat (or level gnus-level-subscribed)
6713 all (or lowest 1) regexp)
6714 (goto-char (point-min))
6715 (gnus-group-position-point))
6717 (defun gnus-group-list-all-matching (level regexp &optional lowest)
6718 "List all groups that match REGEXP.
6719 If the prefix LEVEL is non-nil, it should be a number that says which
6720 level to cut off listing groups.
6721 If LOWEST, don't list groups with level lower than LOWEST."
6722 (interactive "P\nsList newsgroups matching: ")
6723 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
6725 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
6726 (defun gnus-group-save-newsrc (&optional force)
6727 "Save the Gnus startup files.
6728 If FORCE, force saving whether it is necessary or not."
6729 (interactive "P")
6730 (gnus-save-newsrc-file force))
6732 (defun gnus-group-restart (&optional arg)
6733 "Force Gnus to read the .newsrc file."
6734 (interactive "P")
6735 (when (gnus-yes-or-no-p
6736 (format "Are you sure you want to read %s? "
6737 gnus-current-startup-file))
6738 (gnus-save-newsrc-file)
6739 (gnus-setup-news 'force)
6740 (gnus-group-list-groups arg)))
6742 (defun gnus-group-read-init-file ()
6743 "Read the Gnus elisp init file."
6744 (interactive)
6745 (gnus-read-init-file))
6747 (defun gnus-group-check-bogus-groups (&optional silent)
6748 "Check bogus newsgroups.
6749 If given a prefix, don't ask for confirmation before removing a bogus
6750 group."
6751 (interactive "P")
6752 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
6753 (gnus-group-list-groups))
6755 (defun gnus-group-edit-global-kill (&optional article group)
6756 "Edit the global kill file.
6757 If GROUP, edit that local kill file instead."
6758 (interactive "P")
6759 (setq gnus-current-kill-article article)
6760 (gnus-kill-file-edit-file group)
6761 (gnus-message
6763 (substitute-command-keys
6764 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
6765 (if group "local" "global")))))
6767 (defun gnus-group-edit-local-kill (article group)
6768 "Edit a local kill file."
6769 (interactive (list nil (gnus-group-group-name)))
6770 (gnus-group-edit-global-kill article group))
6772 (defun gnus-group-force-update ()
6773 "Update `.newsrc' file."
6774 (interactive)
6775 (gnus-save-newsrc-file))
6777 (defun gnus-group-suspend ()
6778 "Suspend the current Gnus session.
6779 In fact, cleanup buffers except for group mode buffer.
6780 The hook gnus-suspend-gnus-hook is called before actually suspending."
6781 (interactive)
6782 (run-hooks 'gnus-suspend-gnus-hook)
6783 ;; Kill Gnus buffers except for group mode buffer.
6784 (let* ((group-buf (get-buffer gnus-group-buffer))
6785 ;; Do this on a separate list in case the user does a ^G before we finish
6786 (gnus-buffer-list
6787 (delete group-buf (delete gnus-dribble-buffer
6788 (append gnus-buffer-list nil)))))
6789 (while gnus-buffer-list
6790 (gnus-kill-buffer (pop gnus-buffer-list)))
6791 (gnus-kill-gnus-frames)
6792 (when group-buf
6793 (setq gnus-buffer-list (list group-buf))
6794 (bury-buffer group-buf)
6795 (delete-windows-on group-buf t))))
6797 (defun gnus-group-clear-dribble ()
6798 "Clear all information from the dribble buffer."
6799 (interactive)
6800 (gnus-dribble-clear)
6801 (gnus-message 7 "Cleared dribble buffer"))
6803 (defun gnus-group-exit ()
6804 "Quit reading news after updating .newsrc.eld and .newsrc.
6805 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6806 (interactive)
6807 (when
6808 (or noninteractive ;For gnus-batch-kill
6809 (not gnus-interactive-exit) ;Without confirmation
6810 gnus-expert-user
6811 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
6812 (run-hooks 'gnus-exit-gnus-hook)
6813 ;; Offer to save data from non-quitted summary buffers.
6814 (gnus-offer-save-summaries)
6815 ;; Save the newsrc file(s).
6816 (gnus-save-newsrc-file)
6817 ;; Kill-em-all.
6818 (gnus-close-backends)
6819 ;; Reset everything.
6820 (gnus-clear-system)
6821 ;; Allow the user to do things after cleaning up.
6822 (run-hooks 'gnus-after-exiting-gnus-hook)))
6824 (defun gnus-close-backends ()
6825 ;; Send a close request to all backends that support such a request.
6826 (let ((methods gnus-valid-select-methods)
6827 func)
6828 (while methods
6829 (if (fboundp (setq func (intern (concat (caar methods)
6830 "-request-close"))))
6831 (funcall func))
6832 (setq methods (cdr methods)))))
6834 (defun gnus-group-quit ()
6835 "Quit reading news without updating .newsrc.eld or .newsrc.
6836 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6837 (interactive)
6838 (when (or noninteractive ;For gnus-batch-kill
6839 (zerop (buffer-size))
6840 (not (gnus-server-opened gnus-select-method))
6841 gnus-expert-user
6842 (not gnus-current-startup-file)
6843 (gnus-yes-or-no-p
6844 (format "Quit reading news without saving %s? "
6845 (file-name-nondirectory gnus-current-startup-file))))
6846 (run-hooks 'gnus-exit-gnus-hook)
6847 (if gnus-use-full-window
6848 (delete-other-windows)
6849 (gnus-remove-some-windows))
6850 (gnus-dribble-save)
6851 (gnus-close-backends)
6852 (gnus-clear-system)
6853 ;; Allow the user to do things after cleaning up.
6854 (run-hooks 'gnus-after-exiting-gnus-hook)))
6856 (defun gnus-offer-save-summaries ()
6857 "Offer to save all active summary buffers."
6858 (save-excursion
6859 (let ((buflist (buffer-list))
6860 buffers bufname)
6861 ;; Go through all buffers and find all summaries.
6862 (while buflist
6863 (and (setq bufname (buffer-name (car buflist)))
6864 (string-match "Summary" bufname)
6865 (save-excursion
6866 (set-buffer bufname)
6867 ;; We check that this is, indeed, a summary buffer.
6868 (and (eq major-mode 'gnus-summary-mode)
6869 ;; Also make sure this isn't bogus.
6870 gnus-newsgroup-prepared))
6871 (push bufname buffers))
6872 (setq buflist (cdr buflist)))
6873 ;; Go through all these summary buffers and offer to save them.
6874 (when buffers
6875 (map-y-or-n-p
6876 "Update summary buffer %s? "
6877 (lambda (buf) (set-buffer buf) (gnus-summary-exit))
6878 buffers)))))
6880 (defun gnus-group-describe-briefly ()
6881 "Give a one line description of the group mode commands."
6882 (interactive)
6883 (gnus-message 7 (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")))
6885 (defun gnus-group-browse-foreign-server (method)
6886 "Browse a foreign news server.
6887 If called interactively, this function will ask for a select method
6888 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
6889 If not, METHOD should be a list where the first element is the method
6890 and the second element is the address."
6891 (interactive
6892 (list (let ((how (completing-read
6893 "Which backend: "
6894 (append gnus-valid-select-methods gnus-server-alist)
6895 nil t (cons "nntp" 0) 'gnus-method-history)))
6896 ;; We either got a backend name or a virtual server name.
6897 ;; If the first, we also need an address.
6898 (if (assoc how gnus-valid-select-methods)
6899 (list (intern how)
6900 ;; Suggested by mapjph@bath.ac.uk.
6901 (completing-read
6902 "Address: "
6903 (mapcar (lambda (server) (list server))
6904 gnus-secondary-servers)))
6905 ;; We got a server name, so we find the method.
6906 (gnus-server-to-method how)))))
6907 (gnus-browse-foreign-server method))
6911 ;;; Gnus summary mode
6914 (defvar gnus-summary-mode-map nil)
6916 (put 'gnus-summary-mode 'mode-class 'special)
6918 (unless gnus-summary-mode-map
6919 (setq gnus-summary-mode-map (make-keymap))
6920 (suppress-keymap gnus-summary-mode-map)
6922 ;; Non-orthogonal keys
6924 (gnus-define-keys gnus-summary-mode-map
6925 " " gnus-summary-next-page
6926 "\177" gnus-summary-prev-page
6927 [delete] gnus-summary-prev-page
6928 "\r" gnus-summary-scroll-up
6929 "n" gnus-summary-next-unread-article
6930 "p" gnus-summary-prev-unread-article
6931 "N" gnus-summary-next-article
6932 "P" gnus-summary-prev-article
6933 "\M-\C-n" gnus-summary-next-same-subject
6934 "\M-\C-p" gnus-summary-prev-same-subject
6935 "\M-n" gnus-summary-next-unread-subject
6936 "\M-p" gnus-summary-prev-unread-subject
6937 "." gnus-summary-first-unread-article
6938 "," gnus-summary-best-unread-article
6939 "\M-s" gnus-summary-search-article-forward
6940 "\M-r" gnus-summary-search-article-backward
6941 "<" gnus-summary-beginning-of-article
6942 ">" gnus-summary-end-of-article
6943 "j" gnus-summary-goto-article
6944 "^" gnus-summary-refer-parent-article
6945 "\M-^" gnus-summary-refer-article
6946 "u" gnus-summary-tick-article-forward
6947 "!" gnus-summary-tick-article-forward
6948 "U" gnus-summary-tick-article-backward
6949 "d" gnus-summary-mark-as-read-forward
6950 "D" gnus-summary-mark-as-read-backward
6951 "E" gnus-summary-mark-as-expirable
6952 "\M-u" gnus-summary-clear-mark-forward
6953 "\M-U" gnus-summary-clear-mark-backward
6954 "k" gnus-summary-kill-same-subject-and-select
6955 "\C-k" gnus-summary-kill-same-subject
6956 "\M-\C-k" gnus-summary-kill-thread
6957 "\M-\C-l" gnus-summary-lower-thread
6958 "e" gnus-summary-edit-article
6959 "#" gnus-summary-mark-as-processable
6960 "\M-#" gnus-summary-unmark-as-processable
6961 "\M-\C-t" gnus-summary-toggle-threads
6962 "\M-\C-s" gnus-summary-show-thread
6963 "\M-\C-h" gnus-summary-hide-thread
6964 "\M-\C-f" gnus-summary-next-thread
6965 "\M-\C-b" gnus-summary-prev-thread
6966 "\M-\C-u" gnus-summary-up-thread
6967 "\M-\C-d" gnus-summary-down-thread
6968 "&" gnus-summary-execute-command
6969 "c" gnus-summary-catchup-and-exit
6970 "\C-w" gnus-summary-mark-region-as-read
6971 "\C-t" gnus-summary-toggle-truncation
6972 "?" gnus-summary-mark-as-dormant
6973 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
6974 "\C-c\C-s\C-n" gnus-summary-sort-by-number
6975 "\C-c\C-s\C-a" gnus-summary-sort-by-author
6976 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
6977 "\C-c\C-s\C-d" gnus-summary-sort-by-date
6978 "\C-c\C-s\C-i" gnus-summary-sort-by-score
6979 "=" gnus-summary-expand-window
6980 "\C-x\C-s" gnus-summary-reselect-current-group
6981 "\M-g" gnus-summary-rescan-group
6982 "w" gnus-summary-stop-page-breaking
6983 "\C-c\C-r" gnus-summary-caesar-message
6984 "\M-t" gnus-summary-toggle-mime
6985 "f" gnus-summary-followup
6986 "F" gnus-summary-followup-with-original
6987 "C" gnus-summary-cancel-article
6988 "r" gnus-summary-reply
6989 "R" gnus-summary-reply-with-original
6990 "\C-c\C-f" gnus-summary-mail-forward
6991 "o" gnus-summary-save-article
6992 "\C-o" gnus-summary-save-article-mail
6993 "|" gnus-summary-pipe-output
6994 "\M-k" gnus-summary-edit-local-kill
6995 "\M-K" gnus-summary-edit-global-kill
6996 "V" gnus-version
6997 "\C-c\C-d" gnus-summary-describe-group
6998 "q" gnus-summary-exit
6999 "Q" gnus-summary-exit-no-update
7000 "\C-c\C-i" gnus-info-find-node
7001 gnus-mouse-2 gnus-mouse-pick-article
7002 "m" gnus-summary-mail-other-window
7003 "a" gnus-summary-post-news
7004 "x" gnus-summary-limit-to-unread
7005 "s" gnus-summary-isearch-article
7006 "t" gnus-article-hide-headers
7007 "g" gnus-summary-show-article
7008 "l" gnus-summary-goto-last-article
7009 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
7010 "\C-d" gnus-summary-enter-digest-group
7011 "\C-c\C-b" gnus-bug
7012 "*" gnus-cache-enter-article
7013 "\M-*" gnus-cache-remove-article
7014 "\M-&" gnus-summary-universal-argument
7015 "\C-l" gnus-recenter
7016 "I" gnus-summary-increase-score
7017 "L" gnus-summary-lower-score
7019 "V" gnus-summary-score-map
7020 "X" gnus-uu-extract-map
7021 "S" gnus-summary-send-map)
7023 ;; Sort of orthogonal keymap
7024 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
7025 "t" gnus-summary-tick-article-forward
7026 "!" gnus-summary-tick-article-forward
7027 "d" gnus-summary-mark-as-read-forward
7028 "r" gnus-summary-mark-as-read-forward
7029 "c" gnus-summary-clear-mark-forward
7030 " " gnus-summary-clear-mark-forward
7031 "e" gnus-summary-mark-as-expirable
7032 "x" gnus-summary-mark-as-expirable
7033 "?" gnus-summary-mark-as-dormant
7034 "b" gnus-summary-set-bookmark
7035 "B" gnus-summary-remove-bookmark
7036 "#" gnus-summary-mark-as-processable
7037 "\M-#" gnus-summary-unmark-as-processable
7038 "S" gnus-summary-limit-include-expunged
7039 "C" gnus-summary-catchup
7040 "H" gnus-summary-catchup-to-here
7041 "\C-c" gnus-summary-catchup-all
7042 "k" gnus-summary-kill-same-subject-and-select
7043 "K" gnus-summary-kill-same-subject
7044 "P" gnus-uu-mark-map)
7046 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mode-map)
7047 "c" gnus-summary-clear-above
7048 "u" gnus-summary-tick-above
7049 "m" gnus-summary-mark-above
7050 "k" gnus-summary-kill-below)
7052 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
7053 "/" gnus-summary-limit-to-subject
7054 "n" gnus-summary-limit-to-articles
7055 "w" gnus-summary-pop-limit
7056 "s" gnus-summary-limit-to-subject
7057 "a" gnus-summary-limit-to-author
7058 "u" gnus-summary-limit-to-unread
7059 "m" gnus-summary-limit-to-marks
7060 "v" gnus-summary-limit-to-score
7061 "D" gnus-summary-limit-include-dormant
7062 "d" gnus-summary-limit-exclude-dormant
7063 ;; "t" gnus-summary-limit-exclude-thread
7064 "E" gnus-summary-limit-include-expunged
7065 "c" gnus-summary-limit-exclude-childless-dormant
7066 "C" gnus-summary-limit-mark-excluded-as-read)
7068 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
7069 "n" gnus-summary-next-unread-article
7070 "p" gnus-summary-prev-unread-article
7071 "N" gnus-summary-next-article
7072 "P" gnus-summary-prev-article
7073 "\C-n" gnus-summary-next-same-subject
7074 "\C-p" gnus-summary-prev-same-subject
7075 "\M-n" gnus-summary-next-unread-subject
7076 "\M-p" gnus-summary-prev-unread-subject
7077 "f" gnus-summary-first-unread-article
7078 "b" gnus-summary-best-unread-article
7079 "j" gnus-summary-goto-article
7080 "g" gnus-summary-goto-subject
7081 "l" gnus-summary-goto-last-article
7082 "p" gnus-summary-pop-article)
7084 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
7085 "k" gnus-summary-kill-thread
7086 "l" gnus-summary-lower-thread
7087 "i" gnus-summary-raise-thread
7088 "T" gnus-summary-toggle-threads
7089 "t" gnus-summary-rethread-current
7090 "^" gnus-summary-reparent-thread
7091 "s" gnus-summary-show-thread
7092 "S" gnus-summary-show-all-threads
7093 "h" gnus-summary-hide-thread
7094 "H" gnus-summary-hide-all-threads
7095 "n" gnus-summary-next-thread
7096 "p" gnus-summary-prev-thread
7097 "u" gnus-summary-up-thread
7098 "o" gnus-summary-top-thread
7099 "d" gnus-summary-down-thread
7100 "#" gnus-uu-mark-thread
7101 "\M-#" gnus-uu-unmark-thread)
7103 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
7104 "c" gnus-summary-catchup-and-exit
7105 "C" gnus-summary-catchup-all-and-exit
7106 "E" gnus-summary-exit-no-update
7107 "Q" gnus-summary-exit
7108 "Z" gnus-summary-exit
7109 "n" gnus-summary-catchup-and-goto-next-group
7110 "R" gnus-summary-reselect-current-group
7111 "G" gnus-summary-rescan-group
7112 "N" gnus-summary-next-group
7113 "P" gnus-summary-prev-group)
7115 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
7116 " " gnus-summary-next-page
7117 "n" gnus-summary-next-page
7118 "\177" gnus-summary-prev-page
7119 [delete] gnus-summary-prev-page
7120 "p" gnus-summary-prev-page
7121 "\r" gnus-summary-scroll-up
7122 "<" gnus-summary-beginning-of-article
7123 ">" gnus-summary-end-of-article
7124 "b" gnus-summary-beginning-of-article
7125 "e" gnus-summary-end-of-article
7126 "^" gnus-summary-refer-parent-article
7127 "r" gnus-summary-refer-parent-article
7128 "R" gnus-summary-refer-references
7129 "g" gnus-summary-show-article
7130 "s" gnus-summary-isearch-article)
7132 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
7133 "b" gnus-article-add-buttons
7134 "B" gnus-article-add-buttons-to-head
7135 "o" gnus-article-treat-overstrike
7136 ;; "w" gnus-article-word-wrap
7137 "w" gnus-article-fill-cited-article
7138 "c" gnus-article-remove-cr
7139 "L" gnus-article-remove-trailing-blank-lines
7140 "q" gnus-article-de-quoted-unreadable
7141 "f" gnus-article-display-x-face
7142 "l" gnus-summary-stop-page-breaking
7143 "r" gnus-summary-caesar-message
7144 "t" gnus-article-hide-headers
7145 "v" gnus-summary-verbose-headers
7146 "m" gnus-summary-toggle-mime)
7148 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
7149 "a" gnus-article-hide
7150 "h" gnus-article-hide-headers
7151 "b" gnus-article-hide-boring-headers
7152 "s" gnus-article-hide-signature
7153 "c" gnus-article-hide-citation
7154 "p" gnus-article-hide-pgp
7155 "\C-c" gnus-article-hide-citation-maybe)
7157 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
7158 "a" gnus-article-highlight
7159 "h" gnus-article-highlight-headers
7160 "c" gnus-article-highlight-citation
7161 "s" gnus-article-highlight-signature)
7163 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
7164 "z" gnus-article-date-ut
7165 "u" gnus-article-date-ut
7166 "l" gnus-article-date-local
7167 "e" gnus-article-date-lapsed
7168 "o" gnus-article-date-original)
7170 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
7171 "v" gnus-version
7172 "f" gnus-summary-fetch-faq
7173 "d" gnus-summary-describe-group
7174 "h" gnus-summary-describe-briefly
7175 "i" gnus-info-find-node)
7177 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
7178 "e" gnus-summary-expire-articles
7179 "\M-\C-e" gnus-summary-expire-articles-now
7180 "\177" gnus-summary-delete-article
7181 [delete] gnus-summary-delete-article
7182 "m" gnus-summary-move-article
7183 "r" gnus-summary-respool-article
7184 "w" gnus-summary-edit-article
7185 "c" gnus-summary-copy-article
7186 "B" gnus-summary-crosspost-article
7187 "q" gnus-summary-respool-query
7188 "i" gnus-summary-import-article)
7190 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
7191 "o" gnus-summary-save-article
7192 "m" gnus-summary-save-article-mail
7193 "r" gnus-summary-save-article-rmail
7194 "f" gnus-summary-save-article-file
7195 "b" gnus-summary-save-article-body-file
7196 "h" gnus-summary-save-article-folder
7197 "v" gnus-summary-save-article-vm
7198 "p" gnus-summary-pipe-output
7199 "s" gnus-soup-add-article)
7204 (defun gnus-summary-mode (&optional group)
7205 "Major mode for reading articles.
7207 All normal editing commands are switched off.
7208 \\<gnus-summary-mode-map>
7209 Each line in this buffer represents one article. To read an
7210 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
7211 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
7212 respectively.
7214 You can also post articles and send mail from this buffer. To
7215 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
7216 of an article, type `\\[gnus-summary-reply]'.
7218 There are approx. one gazillion commands you can execute in this
7219 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
7221 The following commands are available:
7223 \\{gnus-summary-mode-map}"
7224 (interactive)
7225 (when (and menu-bar-mode
7226 (gnus-visual-p 'summary-menu 'menu))
7227 (gnus-summary-make-menu-bar))
7228 (kill-all-local-variables)
7229 (gnus-summary-make-local-variables)
7230 (gnus-make-thread-indent-array)
7231 (gnus-simplify-mode-line)
7232 (setq major-mode 'gnus-summary-mode)
7233 (setq mode-name "Summary")
7234 (make-local-variable 'minor-mode-alist)
7235 (use-local-map gnus-summary-mode-map)
7236 (buffer-disable-undo (current-buffer))
7237 (setq buffer-read-only t) ;Disable modification
7238 (setq truncate-lines t)
7239 (setq selective-display t)
7240 (setq selective-display-ellipses t) ;Display `...'
7241 (setq buffer-display-table gnus-summary-display-table)
7242 (setq gnus-newsgroup-name group)
7243 (make-local-variable 'gnus-summary-line-format)
7244 (make-local-variable 'gnus-summary-line-format-spec)
7245 (make-local-variable 'gnus-summary-mark-positions)
7246 (gnus-make-local-hook 'post-command-hook)
7247 (gnus-add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
7248 (run-hooks 'gnus-summary-mode-hook))
7250 (defun gnus-summary-make-local-variables ()
7251 "Make all the local summary buffer variables."
7252 (let ((locals gnus-summary-local-variables)
7253 global local)
7254 (while (setq local (pop locals))
7255 (if (consp local)
7256 (progn
7257 (if (eq (cdr local) 'global)
7258 ;; Copy the global value of the variable.
7259 (setq global (symbol-value (car local)))
7260 ;; Use the value from the list.
7261 (setq global (eval (cdr local))))
7262 (make-local-variable (car local))
7263 (set (car local) global))
7264 ;; Simple nil-valued local variable.
7265 (make-local-variable local)
7266 (set local nil)))))
7268 (defun gnus-summary-make-display-table ()
7269 ;; Change the display table. Odd characters have a tendency to mess
7270 ;; up nicely formatted displays - we make all possible glyphs
7271 ;; display only a single character.
7273 ;; We start from the standard display table, if any.
7274 (setq gnus-summary-display-table
7275 (or (copy-sequence standard-display-table)
7276 (make-display-table)))
7277 ;; Nix out all the control chars...
7278 (let ((i 32))
7279 (while (>= (setq i (1- i)) 0)
7280 (aset gnus-summary-display-table i [??])))
7281 ;; ... but not newline and cr, of course. (cr is necessary for the
7282 ;; selective display).
7283 (aset gnus-summary-display-table ?\n nil)
7284 (aset gnus-summary-display-table ?\r nil)
7285 ;; We nix out any glyphs over 126 that are not set already.
7286 (let ((i 256))
7287 (while (>= (setq i (1- i)) 127)
7288 ;; Only modify if the entry is nil.
7289 (or (aref gnus-summary-display-table i)
7290 (aset gnus-summary-display-table i [??])))))
7292 (defun gnus-summary-clear-local-variables ()
7293 (let ((locals gnus-summary-local-variables))
7294 (while locals
7295 (if (consp (car locals))
7296 (and (vectorp (caar locals))
7297 (set (caar locals) nil))
7298 (and (vectorp (car locals))
7299 (set (car locals) nil)))
7300 (setq locals (cdr locals)))))
7302 ;; Summary data functions.
7304 (defmacro gnus-data-number (data)
7305 `(car ,data))
7307 (defmacro gnus-data-set-number (data number)
7308 `(setcar ,data ,number))
7310 (defmacro gnus-data-mark (data)
7311 `(nth 1 ,data))
7313 (defmacro gnus-data-set-mark (data mark)
7314 `(setcar (nthcdr 1 ,data) ,mark))
7316 (defmacro gnus-data-pos (data)
7317 `(nth 2 ,data))
7319 (defmacro gnus-data-set-pos (data pos)
7320 `(setcar (nthcdr 2 ,data) ,pos))
7322 (defmacro gnus-data-header (data)
7323 `(nth 3 ,data))
7325 (defmacro gnus-data-level (data)
7326 `(nth 4 ,data))
7328 (defmacro gnus-data-unread-p (data)
7329 `(= (nth 1 ,data) gnus-unread-mark))
7331 (defmacro gnus-data-pseudo-p (data)
7332 `(consp (nth 3 ,data)))
7334 (defmacro gnus-data-find (number)
7335 `(assq ,number gnus-newsgroup-data))
7337 (defmacro gnus-data-find-list (number &optional data)
7338 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
7339 (memq (assq ,number bdata)
7340 bdata)))
7342 (defmacro gnus-data-make (number mark pos header level)
7343 `(list ,number ,mark ,pos ,header ,level))
7345 (defun gnus-data-enter (after-article number mark pos header level offset)
7346 (let ((data (gnus-data-find-list after-article)))
7347 (or data (error "No such article: %d" after-article))
7348 (setcdr data (cons (gnus-data-make number mark pos header level)
7349 (cdr data)))
7350 (setq gnus-newsgroup-data-reverse nil)
7351 (gnus-data-update-list (cddr data) offset)))
7353 (defun gnus-data-enter-list (after-article list &optional offset)
7354 (when list
7355 (let ((data (and after-article (gnus-data-find-list after-article)))
7356 (ilist list))
7357 (or data (not after-article) (error "No such article: %d" after-article))
7358 ;; Find the last element in the list to be spliced into the main
7359 ;; list.
7360 (while (cdr list)
7361 (setq list (cdr list)))
7362 (if (not data)
7363 (progn
7364 (setcdr list gnus-newsgroup-data)
7365 (setq gnus-newsgroup-data ilist)
7366 (and offset (gnus-data-update-list (cdr list) offset)))
7367 (setcdr list (cdr data))
7368 (setcdr data ilist)
7369 (and offset (gnus-data-update-list (cdr data) offset)))
7370 (setq gnus-newsgroup-data-reverse nil))))
7372 (defun gnus-data-remove (article &optional offset)
7373 (let ((data gnus-newsgroup-data))
7374 (if (= (gnus-data-number (car data)) article)
7375 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
7376 gnus-newsgroup-data-reverse nil)
7377 (while (cdr data)
7378 (and (= (gnus-data-number (cadr data)) article)
7379 (progn
7380 (setcdr data (cddr data))
7381 (and offset (gnus-data-update-list (cdr data) offset))
7382 (setq data nil
7383 gnus-newsgroup-data-reverse nil)))
7384 (setq data (cdr data))))))
7386 (defmacro gnus-data-list (backward)
7387 `(if ,backward
7388 (or gnus-newsgroup-data-reverse
7389 (setq gnus-newsgroup-data-reverse
7390 (reverse gnus-newsgroup-data)))
7391 gnus-newsgroup-data))
7393 (defun gnus-data-update-list (data offset)
7394 "Add OFFSET to the POS of all data entries in DATA."
7395 (while data
7396 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
7397 (setq data (cdr data))))
7399 (defun gnus-data-compute-positions ()
7400 "Compute the positions of all articles."
7401 (let ((data gnus-newsgroup-data)
7402 pos)
7403 (while data
7404 (when (setq pos (text-property-any
7405 (point-min) (point-max)
7406 'gnus-number (gnus-data-number (car data))))
7407 (gnus-data-set-pos (car data) (+ pos 3)))
7408 (setq data (cdr data)))))
7410 (defun gnus-summary-article-pseudo-p (article)
7411 "Say whether this article is a pseudo article or not."
7412 (not (vectorp (gnus-data-header (gnus-data-find article)))))
7414 (defun gnus-article-parent-p (number)
7415 "Say whether this article is a parent or not."
7416 (let ((data (gnus-data-find-list number)))
7417 (and (cdr data) ; There has to be an article after...
7418 (< (gnus-data-level (car data)) ; And it has to have a higher level.
7419 (gnus-data-level (nth 1 data))))))
7421 (defun gnus-article-children (number)
7422 "Return a list of all children to NUMBER."
7423 (let* ((data (gnus-data-find-list number))
7424 (level (gnus-data-level (car data)))
7425 children)
7426 (setq data (cdr data))
7427 (while (and data
7428 (= (gnus-data-level (car data)) (1+ level)))
7429 (push (gnus-data-number (car data)) children)
7430 (setq data (cdr data)))
7431 children))
7433 (defmacro gnus-summary-skip-intangible ()
7434 "If the current article is intangible, then jump to a different article."
7435 '(let ((to (get-text-property (point) 'gnus-intangible)))
7436 (and to (gnus-summary-goto-subject to))))
7438 (defmacro gnus-summary-article-intangible-p ()
7439 "Say whether this article is intangible or not."
7440 '(get-text-property (point) 'gnus-intangible))
7442 ;; Some summary mode macros.
7444 (defmacro gnus-summary-article-number ()
7445 "The article number of the article on the current line.
7446 If there isn's an article number here, then we return the current
7447 article number."
7448 '(progn
7449 (gnus-summary-skip-intangible)
7450 (or (get-text-property (point) 'gnus-number)
7451 (gnus-summary-last-subject))))
7453 (defmacro gnus-summary-article-header (&optional number)
7454 `(gnus-data-header (gnus-data-find
7455 ,(or number '(gnus-summary-article-number)))))
7457 (defmacro gnus-summary-thread-level (&optional number)
7458 `(if (and (eq gnus-summary-make-false-root 'dummy)
7459 (get-text-property (point) 'gnus-intangible))
7461 (gnus-data-level (gnus-data-find
7462 ,(or number '(gnus-summary-article-number))))))
7464 (defmacro gnus-summary-article-mark (&optional number)
7465 `(gnus-data-mark (gnus-data-find
7466 ,(or number '(gnus-summary-article-number)))))
7468 (defmacro gnus-summary-article-pos (&optional number)
7469 `(gnus-data-pos (gnus-data-find
7470 ,(or number '(gnus-summary-article-number)))))
7472 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
7473 (defmacro gnus-summary-article-subject (&optional number)
7474 "Return current subject string or nil if nothing."
7475 `(let ((headers
7476 ,(if number
7477 `(gnus-data-header (assq ,number gnus-newsgroup-data))
7478 '(gnus-data-header (assq (gnus-summary-article-number)
7479 gnus-newsgroup-data)))))
7480 (and headers
7481 (vectorp headers)
7482 (mail-header-subject headers))))
7484 (defmacro gnus-summary-article-score (&optional number)
7485 "Return current article score."
7486 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
7487 gnus-newsgroup-scored))
7488 gnus-summary-default-score 0))
7490 (defun gnus-summary-article-children (&optional number)
7491 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
7492 (level (gnus-data-level (car data)))
7493 l children)
7494 (while (and (setq data (cdr data))
7495 (> (setq l (gnus-data-level (car data))) level))
7496 (and (= (1+ level) l)
7497 (setq children (cons (gnus-data-number (car data))
7498 children))))
7499 (nreverse children)))
7501 (defun gnus-summary-article-parent (&optional number)
7502 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
7503 (gnus-data-list t)))
7504 (level (gnus-data-level (car data))))
7505 (if (zerop level)
7506 () ; This is a root.
7507 ;; We search until we find an article with a level less than
7508 ;; this one. That function has to be the parent.
7509 (while (and (setq data (cdr data))
7510 (not (< (gnus-data-level (car data)) level))))
7511 (and data (gnus-data-number (car data))))))
7513 (defun gnus-unread-mark-p (mark)
7514 "Say whether MARK is the unread mark."
7515 (= mark gnus-unread-mark))
7517 (defun gnus-read-mark-p (mark)
7518 "Say whether MARK is one of the marks that mark as read.
7519 This is all marks except unread, ticked, dormant, and expirable."
7520 (not (or (= mark gnus-unread-mark)
7521 (= mark gnus-ticked-mark)
7522 (= mark gnus-dormant-mark)
7523 (= mark gnus-expirable-mark))))
7525 ;; Saving hidden threads.
7527 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
7528 (put 'gnus-save-hidden-threads 'lisp-indent-hook 0)
7529 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
7531 (defmacro gnus-save-hidden-threads (&rest forms)
7532 "Save hidden threads, eval FORMS, and restore the hidden threads."
7533 (let ((config (make-symbol "config")))
7534 `(let ((,config (gnus-hidden-threads-configuration)))
7535 (unwind-protect
7536 (progn
7537 ,@forms)
7538 (gnus-restore-hidden-threads-configuration ,config)))))
7540 (defun gnus-hidden-threads-configuration ()
7541 "Return the current hidden threads configuration."
7542 (save-excursion
7543 (let (config)
7544 (goto-char (point-min))
7545 (while (search-forward "\r" nil t)
7546 (push (1- (point)) config))
7547 config)))
7549 (defun gnus-restore-hidden-threads-configuration (config)
7550 "Restore hidden threads configuration from CONFIG."
7551 (let (point buffer-read-only)
7552 (while (setq point (pop config))
7553 (when (and (< point (point-max))
7554 (goto-char point)
7555 (= (following-char) ?\n))
7556 (subst-char-in-region point (1+ point) ?\n ?\r)))))
7558 ;; Various summary mode internalish functions.
7560 (defun gnus-mouse-pick-article (e)
7561 (interactive "e")
7562 (mouse-set-point e)
7563 (gnus-summary-next-page nil t))
7565 (defun gnus-summary-setup-buffer (group)
7566 "Initialize summary buffer."
7567 (let ((buffer (concat "*Summary " group "*")))
7568 (if (get-buffer buffer)
7569 (progn
7570 (set-buffer buffer)
7571 (setq gnus-summary-buffer (current-buffer))
7572 (not gnus-newsgroup-prepared))
7573 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
7574 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
7575 (gnus-add-current-to-buffer-list)
7576 (gnus-summary-mode group)
7577 (when gnus-carpal
7578 (gnus-carpal-setup-buffer 'summary))
7579 (unless gnus-single-article-buffer
7580 (make-local-variable 'gnus-article-buffer)
7581 (make-local-variable 'gnus-article-current)
7582 (make-local-variable 'gnus-original-article-buffer))
7583 (setq gnus-newsgroup-name group)
7584 t)))
7586 (defun gnus-set-global-variables ()
7587 ;; Set the global equivalents of the summary buffer-local variables
7588 ;; to the latest values they had. These reflect the summary buffer
7589 ;; that was in action when the last article was fetched.
7590 (when (eq major-mode 'gnus-summary-mode)
7591 (setq gnus-summary-buffer (current-buffer))
7592 (let ((name gnus-newsgroup-name)
7593 (marked gnus-newsgroup-marked)
7594 (unread gnus-newsgroup-unreads)
7595 (headers gnus-current-headers)
7596 (data gnus-newsgroup-data)
7597 (summary gnus-summary-buffer)
7598 (article-buffer gnus-article-buffer)
7599 (original gnus-original-article-buffer)
7600 (gac gnus-article-current)
7601 (score-file gnus-current-score-file))
7602 (save-excursion
7603 (set-buffer gnus-group-buffer)
7604 (setq gnus-newsgroup-name name)
7605 (setq gnus-newsgroup-marked marked)
7606 (setq gnus-newsgroup-unreads unread)
7607 (setq gnus-current-headers headers)
7608 (setq gnus-newsgroup-data data)
7609 (setq gnus-article-current gac)
7610 (setq gnus-summary-buffer summary)
7611 (setq gnus-article-buffer article-buffer)
7612 (setq gnus-original-article-buffer original)
7613 (setq gnus-current-score-file score-file)))))
7615 (defun gnus-summary-last-article-p (&optional article)
7616 "Return whether ARTICLE is the last article in the buffer."
7617 (if (not (setq article (or article (gnus-summary-article-number))))
7618 t ; All non-existant numbers are the last article. :-)
7619 (not (cdr (gnus-data-find-list article)))))
7621 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
7622 "Insert a dummy root in the summary buffer."
7623 (beginning-of-line)
7624 (gnus-add-text-properties
7625 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
7626 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
7628 (defun gnus-make-thread-indent-array ()
7629 (let ((n 200))
7630 (unless (and gnus-thread-indent-array
7631 (= gnus-thread-indent-level gnus-thread-indent-array-level))
7632 (setq gnus-thread-indent-array (make-vector 201 "")
7633 gnus-thread-indent-array-level gnus-thread-indent-level)
7634 (while (>= n 0)
7635 (aset gnus-thread-indent-array n
7636 (make-string (* n gnus-thread-indent-level) ? ))
7637 (setq n (1- n))))))
7639 (defun gnus-summary-insert-line
7640 (gnus-tmp-header gnus-tmp-level gnus-tmp-current gnus-tmp-unread
7641 gnus-tmp-replied gnus-tmp-expirable gnus-tmp-subject-or-nil
7642 &optional gnus-tmp-dummy gnus-tmp-score gnus-tmp-process)
7643 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
7644 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
7645 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
7646 (gnus-tmp-score-char
7647 (if (or (null gnus-summary-default-score)
7648 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
7649 gnus-summary-zcore-fuzz)) ?
7650 (if (< gnus-tmp-score gnus-summary-default-score)
7651 gnus-score-below-mark gnus-score-over-mark)))
7652 (gnus-tmp-replied (cond (gnus-tmp-process gnus-process-mark)
7653 ((memq gnus-tmp-current gnus-newsgroup-cached)
7654 gnus-cached-mark)
7655 (gnus-tmp-replied gnus-replied-mark)
7656 ((memq gnus-tmp-current gnus-newsgroup-saved)
7657 gnus-saved-mark)
7658 (t gnus-unread-mark)))
7659 (gnus-tmp-from (mail-header-from gnus-tmp-header))
7660 (gnus-tmp-name
7661 (cond
7662 ((string-match "(.+)" gnus-tmp-from)
7663 (substring gnus-tmp-from
7664 (1+ (match-beginning 0)) (1- (match-end 0))))
7665 ((string-match "<[^>]+> *$" gnus-tmp-from)
7666 (let ((beg (match-beginning 0)))
7667 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
7668 (substring gnus-tmp-from (1+ (match-beginning 0))
7669 (1- (match-end 0))))
7670 (substring gnus-tmp-from 0 beg))))
7671 (t gnus-tmp-from)))
7672 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
7673 (gnus-tmp-number (mail-header-number gnus-tmp-header))
7674 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
7675 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
7676 (buffer-read-only nil))
7677 (when (string= gnus-tmp-name "")
7678 (setq gnus-tmp-name gnus-tmp-from))
7679 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
7680 (gnus-put-text-property
7681 (point)
7682 (progn (eval gnus-summary-line-format-spec) (point))
7683 'gnus-number gnus-tmp-number)
7684 (when (gnus-visual-p 'summary-highlight 'highlight)
7685 (forward-line -1)
7686 (run-hooks 'gnus-summary-update-hook)
7687 (forward-line 1))))
7689 (defun gnus-summary-update-line (&optional dont-update)
7690 ;; Update summary line after change.
7691 (when (and gnus-summary-default-score
7692 (not gnus-summary-inhibit-highlight))
7693 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
7694 (article (gnus-summary-article-number))
7695 (score (gnus-summary-article-score article)))
7696 (unless dont-update
7697 (if (and gnus-summary-mark-below
7698 (< (gnus-summary-article-score)
7699 gnus-summary-mark-below))
7700 ;; This article has a low score, so we mark it as read.
7701 (when (memq article gnus-newsgroup-unreads)
7702 (gnus-summary-mark-article-as-read gnus-low-score-mark))
7703 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
7704 ;; This article was previously marked as read on account
7705 ;; of a low score, but now it has risen, so we mark it as
7706 ;; unread.
7707 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
7708 (gnus-summary-update-mark
7709 (if (or (null gnus-summary-default-score)
7710 (<= (abs (- score gnus-summary-default-score))
7711 gnus-summary-zcore-fuzz)) ?
7712 (if (< score gnus-summary-default-score)
7713 gnus-score-below-mark gnus-score-over-mark)) 'score))
7714 ;; Do visual highlighting.
7715 (when (gnus-visual-p 'summary-highlight 'highlight)
7716 (run-hooks 'gnus-summary-update-hook)))))
7718 (defvar gnus-tmp-new-adopts nil)
7720 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
7721 ;; Sum up all elements (and sub-elements) in a list.
7722 (let* ((number
7723 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
7724 (cond
7725 ((and (consp thread) (cdr thread))
7726 (apply
7727 '+ 1 (mapcar
7728 'gnus-summary-number-of-articles-in-thread (cdr thread))))
7729 ((null thread)
7731 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
7733 (t 0))))
7734 (when (and level (zerop level) gnus-tmp-new-adopts)
7735 (incf number
7736 (apply '+ (mapcar
7737 'gnus-summary-number-of-articles-in-thread
7738 gnus-tmp-new-adopts))))
7739 (if char
7740 (if (> number 1) gnus-not-empty-thread-mark
7741 gnus-empty-thread-mark)
7742 number)))
7744 (defun gnus-summary-set-local-parameters (group)
7745 "Go through the local params of GROUP and set all variable specs in that list."
7746 (let ((params (gnus-info-params (gnus-get-info group)))
7747 elem)
7748 (while params
7749 (setq elem (car params)
7750 params (cdr params))
7751 (and (consp elem) ; Has to be a cons.
7752 (consp (cdr elem)) ; The cdr has to be a list.
7753 (symbolp (car elem)) ; Has to be a symbol in there.
7754 (not (memq (car elem)
7755 '(quit-config to-address to-list to-group)))
7756 (progn ; So we set it.
7757 (make-local-variable (car elem))
7758 (set (car elem) (eval (nth 1 elem))))))))
7760 (defun gnus-summary-read-group (group &optional show-all no-article
7761 kill-buffer no-display)
7762 "Start reading news in newsgroup GROUP.
7763 If SHOW-ALL is non-nil, already read articles are also listed.
7764 If NO-ARTICLE is non-nil, no article is selected initially.
7765 If NO-DISPLAY, don't generate a summary buffer."
7766 (gnus-message 5 "Retrieving newsgroup: %s..." group)
7767 (let* ((new-group (gnus-summary-setup-buffer group))
7768 (quit-config (gnus-group-quit-config group))
7769 (did-select (and new-group (gnus-select-newsgroup group show-all))))
7770 (cond
7771 ;; This summary buffer exists already, so we just select it.
7772 ((not new-group)
7773 (gnus-set-global-variables)
7774 (when kill-buffer
7775 (gnus-kill-or-deaden-summary kill-buffer))
7776 (gnus-configure-windows 'summary 'force)
7777 (gnus-set-mode-line 'summary)
7778 (gnus-summary-position-point)
7779 (message "")
7781 ;; We couldn't select this group.
7782 ((null did-select)
7783 (when (and (eq major-mode 'gnus-summary-mode)
7784 (not (equal (current-buffer) kill-buffer)))
7785 (kill-buffer (current-buffer))
7786 (if (not quit-config)
7787 (progn
7788 (set-buffer gnus-group-buffer)
7789 (gnus-group-jump-to-group group)
7790 (gnus-group-next-unread-group 1))
7791 (if (not (buffer-name (car quit-config)))
7792 (gnus-configure-windows 'group 'force)
7793 (set-buffer (car quit-config))
7794 (and (eq major-mode 'gnus-summary-mode)
7795 (gnus-set-global-variables))
7796 (gnus-configure-windows (cdr quit-config)))))
7797 (gnus-message 3 "Can't select group")
7798 nil)
7799 ;; The user did a `C-g' while prompting for number of articles,
7800 ;; so we exit this group.
7801 ((eq did-select 'quit)
7802 (and (eq major-mode 'gnus-summary-mode)
7803 (not (equal (current-buffer) kill-buffer))
7804 (kill-buffer (current-buffer)))
7805 (when kill-buffer
7806 (gnus-kill-or-deaden-summary kill-buffer))
7807 (if (not quit-config)
7808 (progn
7809 (set-buffer gnus-group-buffer)
7810 (gnus-group-jump-to-group group)
7811 (gnus-group-next-unread-group 1)
7812 (gnus-configure-windows 'group 'force))
7813 (if (not (buffer-name (car quit-config)))
7814 (gnus-configure-windows 'group 'force)
7815 (set-buffer (car quit-config))
7816 (and (eq major-mode 'gnus-summary-mode)
7817 (gnus-set-global-variables))
7818 (gnus-configure-windows (cdr quit-config))))
7819 ;; Finally signal the quit.
7820 (signal 'quit nil))
7821 ;; The group was successfully selected.
7823 (gnus-set-global-variables)
7824 ;; Save the active value in effect when the group was entered.
7825 (setq gnus-newsgroup-active
7826 (gnus-copy-sequence
7827 (gnus-active gnus-newsgroup-name)))
7828 ;; You can change the summary buffer in some way with this hook.
7829 (run-hooks 'gnus-select-group-hook)
7830 ;; Set any local variables in the group parameters.
7831 (gnus-summary-set-local-parameters gnus-newsgroup-name)
7832 (gnus-update-format-specifications)
7833 ;; Do score processing.
7834 (when gnus-use-scoring
7835 (gnus-possibly-score-headers))
7836 ;; Check whether to fill in the gaps in the threads.
7837 (when gnus-build-sparse-threads
7838 (gnus-build-sparse-threads))
7839 ;; Find the initial limit.
7840 (if gnus-show-threads
7841 (if show-all
7842 (let ((gnus-newsgroup-dormant nil))
7843 (gnus-summary-initial-limit show-all))
7844 (gnus-summary-initial-limit show-all))
7845 (setq gnus-newsgroup-limit
7846 (mapcar
7847 (lambda (header) (mail-header-number header))
7848 gnus-newsgroup-headers)))
7849 ;; Generate the summary buffer.
7850 (unless no-display
7851 (gnus-summary-prepare))
7852 (when gnus-use-trees
7853 (gnus-tree-open group)
7854 (setq gnus-summary-highlight-line-function
7855 'gnus-tree-highlight-article))
7856 ;; If the summary buffer is empty, but there are some low-scored
7857 ;; articles or some excluded dormants, we include these in the
7858 ;; buffer.
7859 (when (and (zerop (buffer-size))
7860 (not no-display))
7861 (cond (gnus-newsgroup-dormant
7862 (gnus-summary-limit-include-dormant))
7863 ((and gnus-newsgroup-scored show-all)
7864 (gnus-summary-limit-include-expunged))))
7865 ;; Function `gnus-apply-kill-file' must be called in this hook.
7866 (run-hooks 'gnus-apply-kill-hook)
7867 (if (and (zerop (buffer-size))
7868 (not no-display))
7869 (progn
7870 ;; This newsgroup is empty.
7871 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
7872 (gnus-message 6 "No unread news")
7873 (when kill-buffer
7874 (gnus-kill-or-deaden-summary kill-buffer))
7875 ;; Return nil from this function.
7876 nil)
7877 ;; Hide conversation thread subtrees. We cannot do this in
7878 ;; gnus-summary-prepare-hook since kill processing may not
7879 ;; work with hidden articles.
7880 (and gnus-show-threads
7881 gnus-thread-hide-subtree
7882 (gnus-summary-hide-all-threads))
7883 ;; Show first unread article if requested.
7884 (if (and (not no-article)
7885 (not no-display)
7886 gnus-newsgroup-unreads
7887 gnus-auto-select-first)
7888 (unless (if (eq gnus-auto-select-first 'best)
7889 (gnus-summary-best-unread-article)
7890 (gnus-summary-first-unread-article))
7891 (gnus-configure-windows 'summary))
7892 ;; Don't select any articles, just move point to the first
7893 ;; article in the group.
7894 (goto-char (point-min))
7895 (gnus-summary-position-point)
7896 (gnus-set-mode-line 'summary)
7897 (gnus-configure-windows 'summary 'force))
7898 ;; If we are in async mode, we send some info to the backend.
7899 (when gnus-newsgroup-async
7900 (gnus-request-asynchronous gnus-newsgroup-name gnus-newsgroup-data))
7901 (when kill-buffer
7902 (gnus-kill-or-deaden-summary kill-buffer))
7903 (when (get-buffer-window gnus-group-buffer t)
7904 ;; Gotta use windows, because recenter does wierd stuff if
7905 ;; the current buffer ain't the displayed window.
7906 (let ((owin (selected-window)))
7907 (select-window (get-buffer-window gnus-group-buffer t))
7908 (when (gnus-group-goto-group group)
7909 (recenter))
7910 (select-window owin))))
7911 ;; Mark this buffer as "prepared".
7912 (setq gnus-newsgroup-prepared t)
7913 t))))
7915 (defun gnus-summary-prepare ()
7916 "Generate the summary buffer."
7917 (let ((buffer-read-only nil))
7918 (erase-buffer)
7919 (setq gnus-newsgroup-data nil
7920 gnus-newsgroup-data-reverse nil)
7921 (run-hooks 'gnus-summary-generate-hook)
7922 ;; Generate the buffer, either with threads or without.
7923 (when gnus-newsgroup-headers
7924 (gnus-summary-prepare-threads
7925 (if gnus-show-threads
7926 (gnus-sort-gathered-threads
7927 (funcall gnus-summary-thread-gathering-function
7928 (gnus-sort-threads
7929 (gnus-cut-threads (gnus-make-threads)))))
7930 ;; Unthreaded display.
7931 (gnus-sort-articles gnus-newsgroup-headers))))
7932 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
7933 ;; Call hooks for modifying summary buffer.
7934 (goto-char (point-min))
7935 (run-hooks 'gnus-summary-prepare-hook)))
7937 (defun gnus-gather-threads-by-subject (threads)
7938 "Gather threads by looking at Subject headers."
7939 (if (not gnus-summary-make-false-root)
7940 threads
7941 (let ((hashtb (gnus-make-hashtable 1023))
7942 (prev threads)
7943 (result threads)
7944 subject hthread whole-subject)
7945 (while threads
7946 (setq whole-subject (mail-header-subject (caar threads)))
7947 (setq subject
7948 (cond
7949 ;; Truncate the subject.
7950 ((numberp gnus-summary-gather-subject-limit)
7951 (setq subject (gnus-simplify-subject-re whole-subject))
7952 (if (> (length subject) gnus-summary-gather-subject-limit)
7953 (substring subject 0 gnus-summary-gather-subject-limit)
7954 subject))
7955 ;; Fuzzily simplify it.
7956 ((eq 'fuzzy gnus-summary-gather-subject-limit)
7957 (gnus-simplify-subject-fuzzy whole-subject))
7958 ;; Just remove the leading "Re:".
7960 (gnus-simplify-subject-re whole-subject))))
7962 (if (and gnus-summary-gather-exclude-subject
7963 (string-match gnus-summary-gather-exclude-subject
7964 subject))
7965 () ; We don't want to do anything with this article.
7966 ;; We simplify the subject before looking it up in the
7967 ;; hash table.
7969 (if (setq hthread (gnus-gethash subject hashtb))
7970 (progn
7971 ;; We enter a dummy root into the thread, if we
7972 ;; haven't done that already.
7973 (unless (stringp (caar hthread))
7974 (setcar hthread (list whole-subject (car hthread))))
7975 ;; We add this new gathered thread to this gathered
7976 ;; thread.
7977 (setcdr (car hthread)
7978 (nconc (cdar hthread) (list (car threads))))
7979 ;; Remove it from the list of threads.
7980 (setcdr prev (cdr threads))
7981 (setq threads prev))
7982 ;; Enter this thread into the hash table.
7983 (gnus-sethash subject threads hashtb)))
7984 (setq prev threads)
7985 (setq threads (cdr threads)))
7986 result)))
7988 (defun gnus-gather-threads-by-references (threads)
7989 "Gather threads by looking at References headers."
7990 (let ((idhashtb (gnus-make-hashtable 1023))
7991 (thhashtb (gnus-make-hashtable 1023))
7992 (prev threads)
7993 (result threads)
7994 ids references id gthread gid entered)
7995 (while threads
7996 (when (setq references (mail-header-references (caar threads)))
7997 (setq id (mail-header-id (caar threads)))
7998 (setq ids (gnus-split-references references))
7999 (setq entered nil)
8000 (while ids
8001 (if (not (setq gid (gnus-gethash (car ids) idhashtb)))
8002 (progn
8003 (gnus-sethash (car ids) id idhashtb)
8004 (gnus-sethash id threads thhashtb))
8005 (setq gthread (gnus-gethash gid thhashtb))
8006 (unless entered
8007 ;; We enter a dummy root into the thread, if we
8008 ;; haven't done that already.
8009 (unless (stringp (caar gthread))
8010 (setcar gthread (list (mail-header-subject (caar gthread))
8011 (car gthread))))
8012 ;; We add this new gathered thread to this gathered
8013 ;; thread.
8014 (setcdr (car gthread)
8015 (nconc (cdar gthread) (list (car threads)))))
8016 ;; Add it into the thread hash table.
8017 (gnus-sethash id gthread thhashtb)
8018 (setq entered t)
8019 ;; Remove it from the list of threads.
8020 (setcdr prev (cdr threads))
8021 (setq threads prev))
8022 (setq ids (cdr ids))))
8023 (setq prev threads)
8024 (setq threads (cdr threads)))
8025 result))
8027 (defun gnus-sort-gathered-threads (threads)
8028 "Sort subtreads inside each gathered thread by article number."
8029 (let ((result threads))
8030 (while threads
8031 (when (stringp (caar threads))
8032 (setcdr (car threads)
8033 (sort (cdar threads) 'gnus-thread-sort-by-number)))
8034 (setq threads (cdr threads)))
8035 result))
8037 (defun gnus-make-threads ()
8038 "Go through the dependency hashtb and find the roots. Return all threads."
8039 (let (threads)
8040 (mapatoms
8041 (lambda (refs)
8042 (unless (car (symbol-value refs))
8043 ;; These threads do not refer back to any other articles,
8044 ;; so they're roots.
8045 (setq threads (append (cdr (symbol-value refs)) threads))))
8046 gnus-newsgroup-dependencies)
8047 threads))
8049 (defun gnus-build-sparse-threads ()
8050 (let ((headers gnus-newsgroup-headers)
8051 (deps gnus-newsgroup-dependencies)
8052 header references generation relations
8053 cthread subject child end pthread relation)
8054 ;; First we create an alist of generations/relations, where
8055 ;; generations is how much we trust the ralation, and the relation
8056 ;; is parent/child.
8057 (gnus-message 7 "Making sparse threads...")
8058 (save-excursion
8059 (nnheader-set-temp-buffer " *gnus sparse threads*")
8060 (while (setq header (pop headers))
8061 (when (and (setq references (mail-header-references header))
8062 (not (string= references "")))
8063 (insert references)
8064 (setq child (mail-header-id header)
8065 subject (mail-header-subject header))
8066 (setq generation 0)
8067 (while (search-backward ">" nil t)
8068 (setq end (1+ (point)))
8069 (when (search-backward "<" nil t)
8070 (push (list (incf generation)
8071 child (setq child (buffer-substring (point) end))
8072 subject)
8073 relations)))
8074 (push (list (1+ generation) child nil subject) relations)
8075 (erase-buffer)))
8076 (kill-buffer (current-buffer)))
8077 ;; Sort over trustworthiness.
8078 (setq relations (sort relations (lambda (r1 r2) (< (car r1) (car r2)))))
8079 (while (setq relation (pop relations))
8080 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
8081 (unless (car (symbol-value cthread))
8082 ;; Make this article the parent of these threads.
8083 (setcar (symbol-value cthread)
8084 (vector gnus-reffed-article-number
8085 (cadddr relation)
8086 "" ""
8087 (cadr relation)
8088 (or (caddr relation) "") 0 0 "")))
8089 (set cthread (list (vector gnus-reffed-article-number
8090 (cadddr relation)
8091 "" "" (cadr relation)
8092 (or (caddr relation) "") 0 0 ""))))
8093 (push gnus-reffed-article-number gnus-newsgroup-limit)
8094 (push gnus-reffed-article-number gnus-newsgroup-sparse)
8095 (push (cons gnus-reffed-article-number gnus-sparse-mark)
8096 gnus-newsgroup-reads)
8097 (decf gnus-reffed-article-number)
8098 ;; Make this new thread the child of its parent.
8099 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
8100 (setcdr (symbol-value pthread)
8101 (nconc (cdr (symbol-value pthread))
8102 (list (symbol-value cthread))))
8103 (set pthread (list nil (symbol-value cthread))))))
8104 (gnus-message 7 "Making sparse threads...done")))
8106 (defun gnus-build-old-threads ()
8107 ;; Look at all the articles that refer back to old articles, and
8108 ;; fetch the headers for the articles that aren't there. This will
8109 ;; build complete threads - if the roots haven't been expired by the
8110 ;; server, that is.
8111 (let (id heads)
8112 (mapatoms
8113 (lambda (refs)
8114 (when (not (car (symbol-value refs)))
8115 (setq heads (cdr (symbol-value refs)))
8116 (while heads
8117 (if (memq (mail-header-number (caar heads))
8118 gnus-newsgroup-dormant)
8119 (setq heads (cdr heads))
8120 (setq id (symbol-name refs))
8121 (while (and (setq id (gnus-build-get-header id))
8122 (not (car (gnus-gethash
8123 id gnus-newsgroup-dependencies)))))
8124 (setq heads nil)))))
8125 gnus-newsgroup-dependencies)))
8127 (defun gnus-build-get-header (id)
8128 ;; Look through the buffer of NOV lines and find the header to
8129 ;; ID. Enter this line into the dependencies hash table, and return
8130 ;; the id of the parent article (if any).
8131 (let ((deps gnus-newsgroup-dependencies)
8132 found header)
8133 (prog1
8134 (save-excursion
8135 (set-buffer nntp-server-buffer)
8136 (goto-char (point-min))
8137 (while (and (not found) (search-forward id nil t))
8138 (beginning-of-line)
8139 (setq found (looking-at
8140 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
8141 (regexp-quote id))))
8142 (or found (beginning-of-line 2)))
8143 (when found
8144 (beginning-of-line)
8145 (and
8146 (setq header (gnus-nov-parse-line
8147 (read (current-buffer)) deps))
8148 (gnus-parent-id (mail-header-references header)))))
8149 (when header
8150 (let ((number (mail-header-number header)))
8151 (push number gnus-newsgroup-limit)
8152 (push header gnus-newsgroup-headers)
8153 (if (memq number gnus-newsgroup-unselected)
8154 (progn
8155 (push number gnus-newsgroup-unreads)
8156 (setq gnus-newsgroup-unselected
8157 (delq number gnus-newsgroup-unselected)))
8158 (push number gnus-newsgroup-ancient)))))))
8160 (defun gnus-summary-update-article (article &optional iheader)
8161 "Update ARTICLE in the summary buffer."
8162 (set-buffer gnus-summary-buffer)
8163 (let* ((header (or iheader (gnus-summary-article-header article)))
8164 (id (mail-header-id header))
8165 (data (gnus-data-find article))
8166 (thread (gnus-id-to-thread id))
8167 (references (mail-header-references header))
8168 (parent
8169 (gnus-id-to-thread
8170 (or (gnus-parent-id
8171 (if (and references
8172 (not (equal "" references)))
8173 references))
8174 "none")))
8175 (buffer-read-only nil)
8176 (old (car thread))
8177 (number (mail-header-number header))
8178 pos)
8179 (when thread
8180 ;; !!! Should this be in or not?
8181 (unless iheader
8182 (setcar thread nil))
8183 (when parent
8184 (delq thread parent))
8185 (if (gnus-summary-insert-subject id header iheader)
8186 ;; Set the (possibly) new article number in the data structure.
8187 (gnus-data-set-number data (gnus-id-to-article id))
8188 (setcar thread old)
8189 nil))))
8191 (defun gnus-rebuild-thread (id)
8192 "Rebuild the thread containing ID."
8193 (let ((buffer-read-only nil)
8194 current thread data)
8195 (if (not gnus-show-threads)
8196 (setq thread (list (car (gnus-id-to-thread id))))
8197 ;; Get the thread this article is part of.
8198 (setq thread (gnus-remove-thread id)))
8199 (setq current (save-excursion
8200 (and (zerop (forward-line -1))
8201 (gnus-summary-article-number))))
8202 ;; If this is a gathered thread, we have to go some re-gathering.
8203 (when (stringp (car thread))
8204 (let ((subject (car thread))
8205 roots thr)
8206 (setq thread (cdr thread))
8207 (while thread
8208 (unless (memq (setq thr (gnus-id-to-thread
8209 (gnus-root-id
8210 (mail-header-id (caar thread)))))
8211 roots)
8212 (push thr roots))
8213 (setq thread (cdr thread)))
8214 ;; We now have all (unique) roots.
8215 (if (= (length roots) 1)
8216 ;; All the loose roots are now one solid root.
8217 (setq thread (car roots))
8218 (setq thread (cons subject (gnus-sort-threads roots))))))
8219 (let (threads)
8220 ;; We then insert this thread into the summary buffer.
8221 (let (gnus-newsgroup-data gnus-newsgroup-threads)
8222 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
8223 (setq data (nreverse gnus-newsgroup-data))
8224 (setq threads gnus-newsgroup-threads))
8225 ;; We splice the new data into the data structure.
8226 (gnus-data-enter-list current data)
8227 (gnus-data-compute-positions)
8228 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
8230 (defun gnus-number-to-header (number)
8231 "Return the header for article NUMBER."
8232 (let ((headers gnus-newsgroup-headers))
8233 (while (and headers
8234 (not (= number (mail-header-number (car headers)))))
8235 (pop headers))
8236 (when headers
8237 (car headers))))
8239 (defun gnus-id-to-thread (id)
8240 "Return the (sub-)thread where ID appears."
8241 (gnus-gethash id gnus-newsgroup-dependencies))
8243 (defun gnus-id-to-article (id)
8244 "Return the article number of ID."
8245 (let ((thread (gnus-id-to-thread id)))
8246 (when (and thread
8247 (car thread))
8248 (mail-header-number (car thread)))))
8250 (defun gnus-id-to-header (id)
8251 "Return the article headers of ID."
8252 (car (gnus-id-to-thread id)))
8254 (defun gnus-article-displayed-root-p (article)
8255 "Say whether ARTICLE is a root(ish) article."
8256 (let ((level (gnus-summary-thread-level article))
8257 (refs (mail-header-references (gnus-summary-article-header article)))
8258 particle)
8259 (cond
8260 ((null level) nil)
8261 ((zerop level) t)
8262 ((null refs) t)
8263 ((null (gnus-parent-id refs)) t)
8264 ((and (= 1 level)
8265 (null (setq particle (gnus-id-to-article
8266 (gnus-parent-id refs))))
8267 (null (gnus-summary-thread-level particle)))))))
8269 (defun gnus-root-id (id)
8270 "Return the id of the root of the thread where ID appears."
8271 (let (last-id prev)
8272 (while (and id (setq prev (car (gnus-gethash
8273 id gnus-newsgroup-dependencies))))
8274 (setq last-id id
8275 id (gnus-parent-id (mail-header-references prev))))
8276 last-id))
8278 (defun gnus-remove-thread (id &optional dont-remove)
8279 "Remove the thread that has ID in it."
8280 (let ((dep gnus-newsgroup-dependencies)
8281 headers thread last-id)
8282 ;; First go up in this thread until we find the root.
8283 (setq last-id (gnus-root-id id))
8284 (setq headers (list (car (gnus-id-to-thread last-id))
8285 (caadr (gnus-id-to-thread last-id))))
8286 ;; We have now found the real root of this thread. It might have
8287 ;; been gathered into some loose thread, so we have to search
8288 ;; through the threads to find the thread we wanted.
8289 (let ((threads gnus-newsgroup-threads)
8290 sub)
8291 (while threads
8292 (setq sub (car threads))
8293 (if (stringp (car sub))
8294 ;; This is a gathered threads, so we look at the roots
8295 ;; below it to find whether this article in in this
8296 ;; gathered root.
8297 (progn
8298 (setq sub (cdr sub))
8299 (while sub
8300 (when (member (caar sub) headers)
8301 (setq thread (car threads)
8302 threads nil
8303 sub nil))
8304 (setq sub (cdr sub))))
8305 ;; It's an ordinary thread, so we check it.
8306 (when (eq (car sub) (car headers))
8307 (setq thread sub
8308 threads nil)))
8309 (setq threads (cdr threads)))
8310 ;; If this article is in no thread, then it's a root.
8311 (if thread
8312 (unless dont-remove
8313 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
8314 (setq thread (gnus-gethash last-id dep)))
8315 (when thread
8316 (prog1
8317 thread ; We return this thread.
8318 (unless dont-remove
8319 (if (stringp (car thread))
8320 (progn
8321 ;; If we use dummy roots, then we have to remove the
8322 ;; dummy root as well.
8323 (when (eq gnus-summary-make-false-root 'dummy)
8324 ;; Uhm.
8326 (setq thread (cdr thread))
8327 (while thread
8328 (gnus-remove-thread-1 (car thread))
8329 (setq thread (cdr thread))))
8330 (gnus-remove-thread-1 thread))))))))
8332 (defun gnus-remove-thread-1 (thread)
8333 "Remove the thread THREAD recursively."
8334 (let ((number (mail-header-number (car thread)))
8335 pos)
8336 (when (setq pos (text-property-any
8337 (point-min) (point-max) 'gnus-number number))
8338 (goto-char pos)
8339 (gnus-delete-line)
8340 (gnus-data-remove number))
8341 (setq thread (cdr thread))
8342 (while thread
8343 (gnus-remove-thread-1 (pop thread)))))
8345 (defun gnus-sort-threads (threads)
8346 "Sort THREADS."
8347 (if (not gnus-thread-sort-functions)
8348 threads
8349 (let ((func (if (= 1 (length gnus-thread-sort-functions))
8350 (car gnus-thread-sort-functions)
8351 `(lambda (t1 t2)
8352 ,(gnus-make-sort-function
8353 (reverse gnus-thread-sort-functions))))))
8354 (gnus-message 7 "Sorting threads...")
8355 (prog1
8356 (sort threads func)
8357 (gnus-message 7 "Sorting threads...done")))))
8359 (defun gnus-sort-articles (articles)
8360 "Sort ARTICLES."
8361 (when gnus-article-sort-functions
8362 (let ((func (if (= 1 (length gnus-article-sort-functions))
8363 (car gnus-article-sort-functions)
8364 `(lambda (t1 t2)
8365 ,(gnus-make-sort-function
8366 (reverse gnus-article-sort-functions))))))
8367 (gnus-message 7 "Sorting articles...")
8368 (prog1
8369 (setq gnus-newsgroup-headers (sort articles func))
8370 (gnus-message 7 "Sorting articles...done")))))
8372 (defun gnus-make-sort-function (funs)
8373 "Return a composite sort condition based on the functions in FUNC."
8374 (if (cdr funs)
8375 `(or (,(car funs) t1 t2)
8376 (and (not (,(car funs) t2 t1))
8377 ,(gnus-make-sort-function (cdr funs))))
8378 `(,(car funs) t1 t2)))
8380 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
8381 (defmacro gnus-thread-header (thread)
8382 ;; Return header of first article in THREAD.
8383 ;; Note that THREAD must never, ever be anything else than a variable -
8384 ;; using some other form will lead to serious barfage.
8385 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
8386 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
8387 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
8388 (vector thread) 2))
8390 (defsubst gnus-article-sort-by-number (h1 h2)
8391 "Sort articles by article number."
8392 (< (mail-header-number h1)
8393 (mail-header-number h2)))
8395 (defun gnus-thread-sort-by-number (h1 h2)
8396 "Sort threads by root article number."
8397 (gnus-article-sort-by-number
8398 (gnus-thread-header h1) (gnus-thread-header h2)))
8400 (defsubst gnus-article-sort-by-author (h1 h2)
8401 "Sort articles by root author."
8402 (string-lessp
8403 (let ((extract (funcall
8404 gnus-extract-address-components
8405 (mail-header-from h1))))
8406 (or (car extract) (cdr extract)))
8407 (let ((extract (funcall
8408 gnus-extract-address-components
8409 (mail-header-from h2))))
8410 (or (car extract) (cdr extract)))))
8412 (defun gnus-thread-sort-by-author (h1 h2)
8413 "Sort threads by root author."
8414 (gnus-article-sort-by-author
8415 (gnus-thread-header h1) (gnus-thread-header h2)))
8417 (defsubst gnus-article-sort-by-subject (h1 h2)
8418 "Sort articles by root subject."
8419 (string-lessp
8420 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
8421 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
8423 (defun gnus-thread-sort-by-subject (h1 h2)
8424 "Sort threads by root subject."
8425 (gnus-article-sort-by-subject
8426 (gnus-thread-header h1) (gnus-thread-header h2)))
8428 (defsubst gnus-article-sort-by-date (h1 h2)
8429 "Sort articles by root article date."
8430 (string-lessp
8431 (inline (gnus-sortable-date (mail-header-date h1)))
8432 (inline (gnus-sortable-date (mail-header-date h2)))))
8434 (defun gnus-thread-sort-by-date (h1 h2)
8435 "Sort threads by root article date."
8436 (gnus-article-sort-by-date
8437 (gnus-thread-header h1) (gnus-thread-header h2)))
8439 (defsubst gnus-article-sort-by-score (h1 h2)
8440 "Sort articles by root article score.
8441 Unscored articles will be counted as having a score of zero."
8442 (> (or (cdr (assq (mail-header-number h1)
8443 gnus-newsgroup-scored))
8444 gnus-summary-default-score 0)
8445 (or (cdr (assq (mail-header-number h2)
8446 gnus-newsgroup-scored))
8447 gnus-summary-default-score 0)))
8449 (defun gnus-thread-sort-by-score (h1 h2)
8450 "Sort threads by root article score."
8451 (gnus-article-sort-by-score
8452 (gnus-thread-header h1) (gnus-thread-header h2)))
8454 (defun gnus-thread-sort-by-total-score (h1 h2)
8455 "Sort threads by the sum of all scores in the thread.
8456 Unscored articles will be counted as having a score of zero."
8457 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
8459 (defun gnus-thread-total-score (thread)
8460 ;; This function find the total score of THREAD.
8461 (cond ((null thread)
8463 ((consp thread)
8464 (if (stringp (car thread))
8465 (apply gnus-thread-score-function 0
8466 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
8467 (gnus-thread-total-score-1 thread)))
8469 (gnus-thread-total-score-1 (list thread)))))
8471 (defun gnus-thread-total-score-1 (root)
8472 ;; This function find the total score of the thread below ROOT.
8473 (setq root (car root))
8474 (apply gnus-thread-score-function
8475 (or (append
8476 (mapcar 'gnus-thread-total-score
8477 (cdr (gnus-gethash (mail-header-id root)
8478 gnus-newsgroup-dependencies)))
8479 (if (> (mail-header-number root) 0)
8480 (list (or (cdr (assq (mail-header-number root)
8481 gnus-newsgroup-scored))
8482 gnus-summary-default-score 0))))
8483 (list gnus-summary-default-score)
8484 '(0))))
8486 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8487 (defvar gnus-tmp-prev-subject nil)
8488 (defvar gnus-tmp-false-parent nil)
8489 (defvar gnus-tmp-root-expunged nil)
8490 (defvar gnus-tmp-dummy-line nil)
8492 (defun gnus-summary-prepare-threads (threads)
8493 "Prepare summary buffer from THREADS and indentation LEVEL.
8494 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
8495 or a straight list of headers."
8496 (gnus-message 7 "Generating summary...")
8498 (setq gnus-newsgroup-threads threads)
8499 (beginning-of-line)
8501 (let ((gnus-tmp-level 0)
8502 (default-score (or gnus-summary-default-score 0))
8503 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
8504 thread number subject stack state gnus-tmp-gathered beg-match
8505 new-roots gnus-tmp-new-adopts thread-end
8506 gnus-tmp-header gnus-tmp-unread
8507 gnus-tmp-replied gnus-tmp-subject-or-nil
8508 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
8509 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
8510 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
8512 (setq gnus-tmp-prev-subject nil)
8514 (if (vectorp (car threads))
8515 ;; If this is a straight (sic) list of headers, then a
8516 ;; threaded summary display isn't required, so we just create
8517 ;; an unthreaded one.
8518 (gnus-summary-prepare-unthreaded threads)
8520 ;; Do the threaded display.
8522 (while (or threads stack gnus-tmp-new-adopts new-roots)
8524 (if (and (= gnus-tmp-level 0)
8525 (not (setq gnus-tmp-dummy-line nil))
8526 (or (not stack)
8527 (= (caar stack) 0))
8528 (not gnus-tmp-false-parent)
8529 (or gnus-tmp-new-adopts new-roots))
8530 (if gnus-tmp-new-adopts
8531 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
8532 thread (list (car gnus-tmp-new-adopts))
8533 gnus-tmp-header (caar thread)
8534 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
8535 (if new-roots
8536 (setq thread (list (car new-roots))
8537 gnus-tmp-header (caar thread)
8538 new-roots (cdr new-roots))))
8540 (if threads
8541 ;; If there are some threads, we do them before the
8542 ;; threads on the stack.
8543 (setq thread threads
8544 gnus-tmp-header (caar thread))
8545 ;; There were no current threads, so we pop something off
8546 ;; the stack.
8547 (setq state (car stack)
8548 gnus-tmp-level (car state)
8549 thread (cdr state)
8550 stack (cdr stack)
8551 gnus-tmp-header (caar thread))))
8553 (setq gnus-tmp-false-parent nil)
8554 (setq gnus-tmp-root-expunged nil)
8555 (setq thread-end nil)
8557 (if (stringp gnus-tmp-header)
8558 ;; The header is a dummy root.
8559 (cond
8560 ((eq gnus-summary-make-false-root 'adopt)
8561 ;; We let the first article adopt the rest.
8562 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
8563 (cddar thread)))
8564 (setq gnus-tmp-gathered
8565 (nconc (mapcar
8566 (lambda (h) (mail-header-number (car h)))
8567 (cddar thread))
8568 gnus-tmp-gathered))
8569 (setq thread (cons (list (caar thread)
8570 (cadar thread))
8571 (cdr thread)))
8572 (setq gnus-tmp-level -1
8573 gnus-tmp-false-parent t))
8574 ((eq gnus-summary-make-false-root 'empty)
8575 ;; We print adopted articles with empty subject fields.
8576 (setq gnus-tmp-gathered
8577 (nconc (mapcar
8578 (lambda (h) (mail-header-number (car h)))
8579 (cddar thread))
8580 gnus-tmp-gathered))
8581 (setq gnus-tmp-level -1))
8582 ((eq gnus-summary-make-false-root 'dummy)
8583 ;; We remember that we probably want to output a dummy
8584 ;; root.
8585 (setq gnus-tmp-dummy-line gnus-tmp-header)
8586 (setq gnus-tmp-prev-subject gnus-tmp-header))
8588 ;; We do not make a root for the gathered
8589 ;; sub-threads at all.
8590 (setq gnus-tmp-level -1)))
8592 (setq number (mail-header-number gnus-tmp-header)
8593 subject (mail-header-subject gnus-tmp-header))
8595 (cond
8596 ;; If the thread has changed subject, we might want to make
8597 ;; this subthread into a root.
8598 ((and (null gnus-thread-ignore-subject)
8599 (not (zerop gnus-tmp-level))
8600 gnus-tmp-prev-subject
8601 (not (inline
8602 (gnus-subject-equal gnus-tmp-prev-subject subject))))
8603 (setq new-roots (nconc new-roots (list (car thread)))
8604 thread-end t
8605 gnus-tmp-header nil))
8606 ;; If the article lies outside the current limit,
8607 ;; then we do not display it.
8608 ((and (not (memq number gnus-newsgroup-limit))
8609 (not gnus-tmp-dummy-line))
8610 (setq gnus-tmp-gathered
8611 (nconc (mapcar
8612 (lambda (h) (mail-header-number (car h)))
8613 (cdar thread))
8614 gnus-tmp-gathered))
8615 (setq gnus-tmp-new-adopts (if (cdar thread)
8616 (append gnus-tmp-new-adopts
8617 (cdar thread))
8618 gnus-tmp-new-adopts)
8619 thread-end t
8620 gnus-tmp-header nil)
8621 (when (zerop gnus-tmp-level)
8622 (setq gnus-tmp-root-expunged t)))
8623 ;; Perhaps this article is to be marked as read?
8624 ((and gnus-summary-mark-below
8625 (< (or (cdr (assq number gnus-newsgroup-scored))
8626 default-score)
8627 gnus-summary-mark-below)
8628 ;; Don't touch sparse articles.
8629 (not (memq number gnus-newsgroup-sparse))
8630 (not (memq number gnus-newsgroup-ancient)))
8631 (setq gnus-newsgroup-unreads
8632 (delq number gnus-newsgroup-unreads))
8633 (if gnus-newsgroup-auto-expire
8634 (push number gnus-newsgroup-expirable)
8635 (push (cons number gnus-low-score-mark)
8636 gnus-newsgroup-reads))))
8638 (when gnus-tmp-header
8639 ;; We may have an old dummy line to output before this
8640 ;; article.
8641 (when gnus-tmp-dummy-line
8642 (gnus-summary-insert-dummy-line
8643 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
8644 (setq gnus-tmp-dummy-line nil))
8646 ;; Compute the mark.
8647 (setq
8648 gnus-tmp-unread
8649 (cond
8650 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8651 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8652 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8653 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8654 (t (or (cdr (assq number gnus-newsgroup-reads))
8655 gnus-ancient-mark))))
8657 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
8658 gnus-tmp-header gnus-tmp-level)
8659 gnus-newsgroup-data)
8661 ;; Actually insert the line.
8662 (setq
8663 gnus-tmp-subject-or-nil
8664 (cond
8665 ((and gnus-thread-ignore-subject
8666 gnus-tmp-prev-subject
8667 (not (inline (gnus-subject-equal
8668 gnus-tmp-prev-subject subject))))
8669 subject)
8670 ((zerop gnus-tmp-level)
8671 (if (and (eq gnus-summary-make-false-root 'empty)
8672 (memq number gnus-tmp-gathered)
8673 gnus-tmp-prev-subject
8674 (inline (gnus-subject-equal
8675 gnus-tmp-prev-subject subject)))
8676 gnus-summary-same-subject
8677 subject))
8678 (t gnus-summary-same-subject)))
8679 (if (and (eq gnus-summary-make-false-root 'adopt)
8680 (= gnus-tmp-level 1)
8681 (memq number gnus-tmp-gathered))
8682 (setq gnus-tmp-opening-bracket ?\<
8683 gnus-tmp-closing-bracket ?\>)
8684 (setq gnus-tmp-opening-bracket ?\[
8685 gnus-tmp-closing-bracket ?\]))
8686 (setq
8687 gnus-tmp-indentation
8688 (aref gnus-thread-indent-array gnus-tmp-level)
8689 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
8690 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
8691 gnus-summary-default-score 0)
8692 gnus-tmp-score-char
8693 (if (or (null gnus-summary-default-score)
8694 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
8695 gnus-summary-zcore-fuzz)) ?
8696 (if (< gnus-tmp-score gnus-summary-default-score)
8697 gnus-score-below-mark gnus-score-over-mark))
8698 gnus-tmp-replied
8699 (cond ((memq number gnus-newsgroup-processable)
8700 gnus-process-mark)
8701 ((memq number gnus-newsgroup-cached)
8702 gnus-cached-mark)
8703 ((memq number gnus-newsgroup-replied)
8704 gnus-replied-mark)
8705 ((memq number gnus-newsgroup-saved)
8706 gnus-saved-mark)
8707 (t gnus-unread-mark))
8708 gnus-tmp-from (mail-header-from gnus-tmp-header)
8709 gnus-tmp-name
8710 (cond
8711 ((string-match "(.+)" gnus-tmp-from)
8712 (substring gnus-tmp-from
8713 (1+ (match-beginning 0)) (1- (match-end 0))))
8714 ((string-match "<[^>]+> *$" gnus-tmp-from)
8715 (setq beg-match (match-beginning 0))
8716 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
8717 (substring gnus-tmp-from (1+ (match-beginning 0))
8718 (1- (match-end 0))))
8719 (substring gnus-tmp-from 0 beg-match)))
8720 (t gnus-tmp-from)))
8721 (when (string= gnus-tmp-name "")
8722 (setq gnus-tmp-name gnus-tmp-from))
8723 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
8724 (gnus-put-text-property
8725 (point)
8726 (progn (eval gnus-summary-line-format-spec) (point))
8727 'gnus-number number)
8728 (when gnus-visual-p
8729 (forward-line -1)
8730 (run-hooks 'gnus-summary-update-hook)
8731 (forward-line 1))
8733 (setq gnus-tmp-prev-subject subject)))
8735 (when (nth 1 thread)
8736 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
8737 (incf gnus-tmp-level)
8738 (setq threads (if thread-end nil (cdar thread)))
8739 (unless threads
8740 (setq gnus-tmp-level 0)))))
8741 (gnus-message 7 "Generating summary...done"))
8743 (defun gnus-summary-prepare-unthreaded (headers)
8744 "Generate an unthreaded summary buffer based on HEADERS."
8745 (let (header number mark)
8747 (while headers
8748 ;; We may have to root out some bad articles...
8749 (when (memq (setq number (mail-header-number
8750 (setq header (pop headers))))
8751 gnus-newsgroup-limit)
8752 ;; Mark article as read when it has a low score.
8753 (when (and gnus-summary-mark-below
8754 (< (or (cdr (assq number gnus-newsgroup-scored))
8755 gnus-summary-default-score 0)
8756 gnus-summary-mark-below)
8757 (not (memq number gnus-newsgroup-ancient)))
8758 (setq gnus-newsgroup-unreads
8759 (delq number gnus-newsgroup-unreads))
8760 (if gnus-newsgroup-auto-expire
8761 (push number gnus-newsgroup-expirable)
8762 (push (cons number gnus-low-score-mark)
8763 gnus-newsgroup-reads)))
8765 (setq mark
8766 (cond
8767 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8768 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8769 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8770 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8771 (t (or (cdr (assq number gnus-newsgroup-reads))
8772 gnus-ancient-mark))))
8773 (setq gnus-newsgroup-data
8774 (cons (gnus-data-make number mark (1+ (point)) header 0)
8775 gnus-newsgroup-data))
8776 (gnus-summary-insert-line
8777 header 0 nil mark (memq number gnus-newsgroup-replied)
8778 (memq number gnus-newsgroup-expirable)
8779 (mail-header-subject header) nil
8780 (cdr (assq number gnus-newsgroup-scored))
8781 (memq number gnus-newsgroup-processable))))))
8783 (defun gnus-select-newsgroup (group &optional read-all)
8784 "Select newsgroup GROUP.
8785 If READ-ALL is non-nil, all articles in the group are selected."
8786 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
8787 (info (nth 2 entry))
8788 articles fetched-articles cached)
8790 (or (gnus-check-server
8791 (setq gnus-current-select-method (gnus-find-method-for-group group)))
8792 (error "Couldn't open server"))
8794 (or (and entry (not (eq (car entry) t))) ; Either it's active...
8795 (gnus-activate-group group) ; Or we can activate it...
8796 (progn ; Or we bug out.
8797 (when (equal major-mode 'gnus-summary-mode)
8798 (kill-buffer (current-buffer)))
8799 (error "Couldn't request group %s: %s"
8800 group (gnus-status-message group))))
8802 (unless (gnus-request-group group t)
8803 (when (equal major-mode 'gnus-summary-mode)
8804 (kill-buffer (current-buffer)))
8805 (error "Couldn't request group %s: %s"
8806 group (gnus-status-message group)))
8808 (setq gnus-newsgroup-name group)
8809 (setq gnus-newsgroup-unselected nil)
8810 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
8812 (and gnus-asynchronous
8813 (gnus-check-backend-function
8814 'request-asynchronous gnus-newsgroup-name)
8815 (setq gnus-newsgroup-async
8816 (gnus-request-asynchronous gnus-newsgroup-name)))
8818 ;; Adjust and set lists of article marks.
8819 (when info
8820 (gnus-adjust-marked-articles info))
8822 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8823 (when (gnus-virtual-group-p group)
8824 (setq cached gnus-newsgroup-cached))
8826 (setq gnus-newsgroup-unreads
8827 (gnus-set-difference
8828 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
8829 gnus-newsgroup-dormant))
8831 (setq gnus-newsgroup-processable nil)
8833 (setq articles (gnus-articles-to-read group read-all))
8835 (cond
8836 ((null articles)
8837 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
8838 'quit)
8839 ((eq articles 0) nil)
8841 ;; Init the dependencies hash table.
8842 (setq gnus-newsgroup-dependencies
8843 (gnus-make-hashtable (length articles)))
8844 ;; Retrieve the headers and read them in.
8845 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8846 (setq gnus-newsgroup-headers
8847 (if (eq 'nov
8848 (setq gnus-headers-retrieved-by
8849 (gnus-retrieve-headers
8850 articles gnus-newsgroup-name
8851 ;; We might want to fetch old headers, but
8852 ;; not if there is only 1 article.
8853 (and gnus-fetch-old-headers
8854 (or (and
8855 (not (eq gnus-fetch-old-headers 'some))
8856 (not (numberp gnus-fetch-old-headers)))
8857 (> (length articles) 1))))))
8858 (gnus-get-newsgroup-headers-xover articles)
8859 (gnus-get-newsgroup-headers)))
8860 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
8862 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8863 (when cached
8864 (setq gnus-newsgroup-cached cached))
8866 ;; Set the initial limit.
8867 (setq gnus-newsgroup-limit (copy-sequence articles))
8868 ;; Remove canceled articles from the list of unread articles.
8869 (setq gnus-newsgroup-unreads
8870 (gnus-set-sorted-intersection
8871 gnus-newsgroup-unreads
8872 (setq fetched-articles
8873 (mapcar (lambda (headers) (mail-header-number headers))
8874 gnus-newsgroup-headers))))
8875 ;; Removed marked articles that do not exist.
8876 (gnus-update-missing-marks
8877 (gnus-sorted-complement fetched-articles articles))
8878 ;; We might want to build some more threads first.
8879 (and gnus-fetch-old-headers
8880 (eq gnus-headers-retrieved-by 'nov)
8881 (gnus-build-old-threads))
8882 ;; Check whether auto-expire is to be done in this group.
8883 (setq gnus-newsgroup-auto-expire
8884 (gnus-group-auto-expirable-p group))
8885 ;; Set up the article buffer now, if necessary.
8886 (unless gnus-single-article-buffer
8887 (gnus-article-setup-buffer))
8888 ;; First and last article in this newsgroup.
8889 (when gnus-newsgroup-headers
8890 (setq gnus-newsgroup-begin
8891 (mail-header-number (car gnus-newsgroup-headers))
8892 gnus-newsgroup-end
8893 (mail-header-number
8894 (gnus-last-element gnus-newsgroup-headers))))
8895 (setq gnus-reffed-article-number -1)
8896 ;; GROUP is successfully selected.
8897 (or gnus-newsgroup-headers t)))))
8899 (defun gnus-articles-to-read (group read-all)
8900 ;; Find out what articles the user wants to read.
8901 (let* ((articles
8902 ;; Select all articles if `read-all' is non-nil, or if there
8903 ;; are no unread articles.
8904 (if (or read-all
8905 (and (zerop (length gnus-newsgroup-marked))
8906 (zerop (length gnus-newsgroup-unreads))))
8907 (gnus-uncompress-range (gnus-active group))
8908 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
8909 (copy-sequence gnus-newsgroup-unreads))
8910 '<)))
8911 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
8912 (scored (length scored-list))
8913 (number (length articles))
8914 (marked (+ (length gnus-newsgroup-marked)
8915 (length gnus-newsgroup-dormant)))
8916 (select
8917 (cond
8918 ((numberp read-all)
8919 read-all)
8921 (condition-case ()
8922 (cond
8923 ((and (or (<= scored marked) (= scored number))
8924 (numberp gnus-large-newsgroup)
8925 (> number gnus-large-newsgroup))
8926 (let ((input
8927 (read-string
8928 (format
8929 "How many articles from %s (default %d): "
8930 gnus-newsgroup-name number))))
8931 (if (string-match "^[ \t]*$" input) number input)))
8932 ((and (> scored marked) (< scored number)
8933 (> (- scored number) 20))
8934 (let ((input
8935 (read-string
8936 (format "%s %s (%d scored, %d total): "
8937 "How many articles from"
8938 group scored number))))
8939 (if (string-match "^[ \t]*$" input)
8940 number input)))
8941 (t number))
8942 (quit nil))))))
8943 (setq select (if (stringp select) (string-to-number select) select))
8944 (if (or (null select) (zerop select))
8945 select
8946 (if (and (not (zerop scored)) (<= (abs select) scored))
8947 (progn
8948 (setq articles (sort scored-list '<))
8949 (setq number (length articles)))
8950 (setq articles (copy-sequence articles)))
8952 (if (< (abs select) number)
8953 (if (< select 0)
8954 ;; Select the N oldest articles.
8955 (setcdr (nthcdr (1- (abs select)) articles) nil)
8956 ;; Select the N most recent articles.
8957 (setq articles (nthcdr (- number select) articles))))
8958 (setq gnus-newsgroup-unselected
8959 (gnus-sorted-intersection
8960 gnus-newsgroup-unreads
8961 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
8962 articles)))
8964 (defun gnus-killed-articles (killed articles)
8965 (let (out)
8966 (while articles
8967 (if (inline (gnus-member-of-range (car articles) killed))
8968 (setq out (cons (car articles) out)))
8969 (setq articles (cdr articles)))
8970 out))
8972 (defun gnus-uncompress-marks (marks)
8973 "Uncompress the mark ranges in MARKS."
8974 (let ((uncompressed '(score bookmark))
8975 out)
8976 (while marks
8977 (if (memq (caar marks) uncompressed)
8978 (push (car marks) out)
8979 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
8980 (setq marks (cdr marks)))
8981 out))
8983 (defun gnus-adjust-marked-articles (info)
8984 "Set all article lists and remove all marks that are no longer legal."
8985 (let* ((marked-lists (gnus-info-marks info))
8986 (active (gnus-active (gnus-info-group info)))
8987 (min (car active))
8988 (max (cdr active))
8989 (types gnus-article-mark-lists)
8990 (uncompressed '(score bookmark killed))
8991 marks var articles article mark)
8993 (while marked-lists
8994 (setq marks (pop marked-lists))
8995 (set (setq var (intern (format "gnus-newsgroup-%s"
8996 (car (rassq (setq mark (car marks))
8997 types)))))
8998 (if (memq (car marks) uncompressed) (cdr marks)
8999 (gnus-uncompress-range (cdr marks))))
9001 (setq articles (symbol-value var))
9003 ;; All articles have to be subsets of the active articles.
9004 (cond
9005 ;; Adjust "simple" lists.
9006 ((memq mark '(tick dormant expirable reply save))
9007 (while articles
9008 (when (or (< (setq article (pop articles)) min) (> article max))
9009 (set var (delq article (symbol-value var))))))
9010 ;; Adjust assocs.
9011 ((memq mark uncompressed)
9012 (while articles
9013 (when (or (not (consp (setq article (pop articles))))
9014 (< (car article) min)
9015 (> (car article) max))
9016 (set var (delq article (symbol-value var))))))))))
9018 (defun gnus-update-missing-marks (missing)
9019 "Go through the list of MISSING articles and remove them mark lists."
9020 (when missing
9021 (let ((types gnus-article-mark-lists)
9022 var m)
9023 ;; Go through all types.
9024 (while types
9025 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
9026 (when (symbol-value var)
9027 ;; This list has articles. So we delete all missing articles
9028 ;; from it.
9029 (setq m missing)
9030 (while m
9031 (set var (delq (pop m) (symbol-value var)))))))))
9033 (defun gnus-update-marks ()
9034 "Enter the various lists of marked articles into the newsgroup info list."
9035 (let ((types gnus-article-mark-lists)
9036 (info (gnus-get-info gnus-newsgroup-name))
9037 (uncompressed '(score bookmark killed))
9038 type list newmarked symbol)
9039 (when info
9040 ;; Add all marks lists that are non-nil to the list of marks lists.
9041 (while types
9042 (setq type (pop types))
9043 (when (setq list (symbol-value
9044 (setq symbol
9045 (intern (format "gnus-newsgroup-%s"
9046 (car type))))))
9047 (push (cons (cdr type)
9048 (if (memq (cdr type) uncompressed) list
9049 (gnus-compress-sequence
9050 (set symbol (sort list '<)) t)))
9051 newmarked)))
9053 ;; Enter these new marks into the info of the group.
9054 (if (nthcdr 3 info)
9055 (setcar (nthcdr 3 info) newmarked)
9056 ;; Add the marks lists to the end of the info.
9057 (when newmarked
9058 (setcdr (nthcdr 2 info) (list newmarked))))
9060 ;; Cut off the end of the info if there's nothing else there.
9061 (let ((i 5))
9062 (while (and (> i 2)
9063 (not (nth i info)))
9064 (when (nthcdr (decf i) info)
9065 (setcdr (nthcdr i info) nil)))))))
9067 (defun gnus-add-marked-articles (group type articles &optional info force)
9068 ;; Add ARTICLES of TYPE to the info of GROUP.
9069 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
9070 ;; add, but replace marked articles of TYPE with ARTICLES.
9071 (let ((info (or info (gnus-get-info group)))
9072 (uncompressed '(score bookmark killed))
9073 marked m)
9074 (or (not info)
9075 (and (not (setq marked (nthcdr 3 info)))
9076 (or (null articles)
9077 (setcdr (nthcdr 2 info)
9078 (list (list (cons type (gnus-compress-sequence
9079 articles t)))))))
9080 (and (not (setq m (assq type (car marked))))
9081 (or (null articles)
9082 (setcar marked
9083 (cons (cons type (gnus-compress-sequence articles t) )
9084 (car marked)))))
9085 (if force
9086 (if (null articles)
9087 (setcar (nthcdr 3 info)
9088 (delq (assq type (car marked)) (car marked)))
9089 (setcdr m (gnus-compress-sequence articles t)))
9090 (setcdr m (gnus-compress-sequence
9091 (sort (nconc (gnus-uncompress-range (cdr m))
9092 (copy-sequence articles)) '<) t))))))
9094 (defun gnus-set-mode-line (where)
9095 "This function sets the mode line of the article or summary buffers.
9096 If WHERE is `summary', the summary mode line format will be used."
9097 ;; Is this mode line one we keep updated?
9098 (when (memq where gnus-updated-mode-lines)
9099 (let (mode-string)
9100 (save-excursion
9101 ;; We evaluate this in the summary buffer since these
9102 ;; variables are buffer-local to that buffer.
9103 (set-buffer gnus-summary-buffer)
9104 ;; We bind all these variables that are used in the `eval' form
9105 ;; below.
9106 (let* ((mformat (symbol-value
9107 (intern
9108 (format "gnus-%s-mode-line-format-spec" where))))
9109 (gnus-tmp-group-name gnus-newsgroup-name)
9110 (gnus-tmp-article-number (or gnus-current-article 0))
9111 (gnus-tmp-unread gnus-newsgroup-unreads)
9112 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
9113 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
9114 (gnus-tmp-unread-and-unselected
9115 (cond ((and (zerop gnus-tmp-unread-and-unticked)
9116 (zerop gnus-tmp-unselected)) "")
9117 ((zerop gnus-tmp-unselected)
9118 (format "{%d more}" gnus-tmp-unread-and-unticked))
9119 (t (format "{%d(+%d) more}"
9120 gnus-tmp-unread-and-unticked
9121 gnus-tmp-unselected))))
9122 (gnus-tmp-subject
9123 (if (and gnus-current-headers
9124 (vectorp gnus-current-headers))
9125 (gnus-mode-string-quote
9126 (mail-header-subject gnus-current-headers)) ""))
9127 max-len
9128 gnus-tmp-header);; passed as argument to any user-format-funcs
9129 (setq mode-string (eval mformat))
9130 (setq max-len (max 4 (if gnus-mode-non-string-length
9131 (- (window-width)
9132 gnus-mode-non-string-length)
9133 (length mode-string))))
9134 ;; We might have to chop a bit of the string off...
9135 (when (> (length mode-string) max-len)
9136 (setq mode-string
9137 (concat (gnus-truncate-string mode-string (- max-len 3))
9138 "...")))
9139 ;; Pad the mode string a bit.
9140 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
9141 ;; Update the mode line.
9142 (setq mode-line-buffer-identification
9143 (gnus-mode-line-buffer-identification
9144 (list mode-string)))
9145 (set-buffer-modified-p t))))
9147 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
9148 "Go through the HEADERS list and add all Xrefs to a hash table.
9149 The resulting hash table is returned, or nil if no Xrefs were found."
9150 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
9151 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
9152 (xref-hashtb (make-vector 63 0))
9153 start group entry number xrefs header)
9154 (while headers
9155 (setq header (pop headers))
9156 (when (and (setq xrefs (mail-header-xref header))
9157 (not (memq (setq number (mail-header-number header))
9158 unreads)))
9159 (setq start 0)
9160 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
9161 (setq start (match-end 0))
9162 (setq group (if prefix
9163 (concat prefix (substring xrefs (match-beginning 1)
9164 (match-end 1)))
9165 (substring xrefs (match-beginning 1) (match-end 1))))
9166 (setq number
9167 (string-to-int (substring xrefs (match-beginning 2)
9168 (match-end 2))))
9169 (if (setq entry (gnus-gethash group xref-hashtb))
9170 (setcdr entry (cons number (cdr entry)))
9171 (gnus-sethash group (cons number nil) xref-hashtb)))))
9172 (and start xref-hashtb)))
9174 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
9175 "Look through all the headers and mark the Xrefs as read."
9176 (let ((virtual (gnus-virtual-group-p from-newsgroup))
9177 name entry info xref-hashtb idlist method nth4)
9178 (save-excursion
9179 (set-buffer gnus-group-buffer)
9180 (when (setq xref-hashtb
9181 (gnus-create-xref-hashtb from-newsgroup headers unreads))
9182 (mapatoms
9183 (lambda (group)
9184 (unless (string= from-newsgroup (setq name (symbol-name group)))
9185 (setq idlist (symbol-value group))
9186 ;; Dead groups are not updated.
9187 (and (prog1
9188 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
9189 info (nth 2 entry))
9190 (if (stringp (setq nth4 (gnus-info-method info)))
9191 (setq nth4 (gnus-server-to-method nth4))))
9192 ;; Only do the xrefs if the group has the same
9193 ;; select method as the group we have just read.
9194 (or (gnus-methods-equal-p
9195 nth4 (gnus-find-method-for-group from-newsgroup))
9196 virtual
9197 (equal nth4 (setq method (gnus-find-method-for-group
9198 from-newsgroup)))
9199 (and (equal (car nth4) (car method))
9200 (equal (nth 1 nth4) (nth 1 method))))
9201 gnus-use-cross-reference
9202 (or (not (eq gnus-use-cross-reference t))
9203 virtual
9204 ;; Only do cross-references on subscribed
9205 ;; groups, if that is what is wanted.
9206 (<= (gnus-info-level info) gnus-level-subscribed))
9207 (gnus-group-make-articles-read name idlist))))
9208 xref-hashtb)))))
9210 (defun gnus-group-make-articles-read (group articles)
9211 (let* ((num 0)
9212 (entry (gnus-gethash group gnus-newsrc-hashtb))
9213 (info (nth 2 entry))
9214 (active (gnus-active group))
9215 range)
9216 ;; First peel off all illegal article numbers.
9217 (if active
9218 (let ((ids articles)
9219 id first)
9220 (while ids
9221 (setq id (car ids))
9222 (if (and first (> id (cdr active)))
9223 (progn
9224 ;; We'll end up in this situation in one particular
9225 ;; obscure situation. If you re-scan a group and get
9226 ;; a new article that is cross-posted to a different
9227 ;; group that has not been re-scanned, you might get
9228 ;; crossposted article that has a higher number than
9229 ;; Gnus believes possible. So we re-activate this
9230 ;; group as well. This might mean doing the
9231 ;; crossposting thingy will *increase* the number
9232 ;; of articles in some groups. Tsk, tsk.
9233 (setq active (or (gnus-activate-group group) active))))
9234 (if (or (> id (cdr active))
9235 (< id (car active)))
9236 (setq articles (delq id articles)))
9237 (setq ids (cdr ids)))))
9238 ;; If the read list is nil, we init it.
9239 (and active
9240 (null (gnus-info-read info))
9241 (> (car active) 1)
9242 (gnus-info-set-read info (cons 1 (1- (car active)))))
9243 ;; Then we add the read articles to the range.
9244 (gnus-info-set-read
9245 info
9246 (setq range
9247 (gnus-add-to-range
9248 (gnus-info-read info) (setq articles (sort articles '<)))))
9249 ;; Then we have to re-compute how many unread
9250 ;; articles there are in this group.
9251 (if active
9252 (progn
9253 (cond
9254 ((not range)
9255 (setq num (- (1+ (cdr active)) (car active))))
9256 ((not (listp (cdr range)))
9257 (setq num (- (cdr active) (- (1+ (cdr range))
9258 (car range)))))
9260 (while range
9261 (if (numberp (car range))
9262 (setq num (1+ num))
9263 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
9264 (setq range (cdr range)))
9265 (setq num (- (cdr active) num))))
9266 ;; Update the number of unread articles.
9267 (setcar entry num)
9268 ;; Update the group buffer.
9269 (gnus-group-update-group group t)))))
9271 (defun gnus-methods-equal-p (m1 m2)
9272 (let ((m1 (or m1 gnus-select-method))
9273 (m2 (or m2 gnus-select-method)))
9274 (or (equal m1 m2)
9275 (and (eq (car m1) (car m2))
9276 (or (not (memq 'address (assoc (symbol-name (car m1))
9277 gnus-valid-select-methods)))
9278 (equal (nth 1 m1) (nth 1 m2)))))))
9280 (defsubst gnus-header-value ()
9281 (buffer-substring (match-end 0) (gnus-point-at-eol)))
9283 (defvar gnus-newsgroup-none-id 0)
9285 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
9286 (let ((cur nntp-server-buffer)
9287 (dependencies
9288 (or dependencies
9289 (save-excursion (set-buffer gnus-summary-buffer)
9290 gnus-newsgroup-dependencies)))
9291 headers id id-dep ref-dep end ref)
9292 (save-excursion
9293 (set-buffer nntp-server-buffer)
9294 (run-hooks 'gnus-parse-headers-hook)
9295 (let ((case-fold-search t)
9296 in-reply-to header p lines)
9297 (goto-char (point-min))
9298 ;; Search to the beginning of the next header. Error messages
9299 ;; do not begin with 2 or 3.
9300 (while (re-search-forward "^[23][0-9]+ " nil t)
9301 (setq id nil
9302 ref nil)
9303 ;; This implementation of this function, with nine
9304 ;; search-forwards instead of the one re-search-forward and
9305 ;; a case (which basically was the old function) is actually
9306 ;; about twice as fast, even though it looks messier. You
9307 ;; can't have everything, I guess. Speed and elegance
9308 ;; doesn't always go hand in hand.
9309 (setq
9310 header
9311 (vector
9312 ;; Number.
9313 (prog1
9314 (read cur)
9315 (end-of-line)
9316 (setq p (point))
9317 (narrow-to-region (point)
9318 (or (and (search-forward "\n.\n" nil t)
9319 (- (point) 2))
9320 (point))))
9321 ;; Subject.
9322 (progn
9323 (goto-char p)
9324 (if (search-forward "\nsubject: " nil t)
9325 (gnus-header-value) "(none)"))
9326 ;; From.
9327 (progn
9328 (goto-char p)
9329 (if (search-forward "\nfrom: " nil t)
9330 (gnus-header-value) "(nobody)"))
9331 ;; Date.
9332 (progn
9333 (goto-char p)
9334 (if (search-forward "\ndate: " nil t)
9335 (gnus-header-value) ""))
9336 ;; Message-ID.
9337 (progn
9338 (goto-char p)
9339 (if (search-forward "\nmessage-id: " nil t)
9340 (setq id (gnus-header-value))
9341 ;; If there was no message-id, we just fake one to make
9342 ;; subsequent routines simpler.
9343 (setq id (concat "none+"
9344 (int-to-string
9345 (setq gnus-newsgroup-none-id
9346 (1+ gnus-newsgroup-none-id)))))))
9347 ;; References.
9348 (progn
9349 (goto-char p)
9350 (if (search-forward "\nreferences: " nil t)
9351 (progn
9352 (setq end (point))
9353 (prog1
9354 (gnus-header-value)
9355 (setq ref
9356 (buffer-substring
9357 (progn
9358 (end-of-line)
9359 (search-backward ">" end t)
9360 (1+ (point)))
9361 (progn
9362 (search-backward "<" end t)
9363 (point))))))
9364 ;; Get the references from the in-reply-to header if there
9365 ;; were no references and the in-reply-to header looks
9366 ;; promising.
9367 (if (and (search-forward "\nin-reply-to: " nil t)
9368 (setq in-reply-to (gnus-header-value))
9369 (string-match "<[^>]+>" in-reply-to))
9370 (setq ref (substring in-reply-to (match-beginning 0)
9371 (match-end 0)))
9372 (setq ref ""))))
9373 ;; Chars.
9375 ;; Lines.
9376 (progn
9377 (goto-char p)
9378 (if (search-forward "\nlines: " nil t)
9379 (if (numberp (setq lines (read cur)))
9380 lines 0)
9382 ;; Xref.
9383 (progn
9384 (goto-char p)
9385 (and (search-forward "\nxref: " nil t)
9386 (gnus-header-value)))))
9387 ;; We do the threading while we read the headers. The
9388 ;; message-id and the last reference are both entered into
9389 ;; the same hash table. Some tippy-toeing around has to be
9390 ;; done in case an article has arrived before the article
9391 ;; which it refers to.
9392 (if (boundp (setq id-dep (intern id dependencies)))
9393 (if (and (car (symbol-value id-dep))
9394 (not force-new))
9395 ;; An article with this Message-ID has already
9396 ;; been seen, so we ignore this one, except we add
9397 ;; any additional Xrefs (in case the two articles
9398 ;; came from different servers).
9399 (progn
9400 (mail-header-set-xref
9401 (car (symbol-value id-dep))
9402 (concat (or (mail-header-xref
9403 (car (symbol-value id-dep))) "")
9404 (or (mail-header-xref header) "")))
9405 (setq header nil))
9406 (setcar (symbol-value id-dep) header))
9407 (set id-dep (list header)))
9408 (when header
9409 (if (boundp (setq ref-dep (intern ref dependencies)))
9410 (setcdr (symbol-value ref-dep)
9411 (nconc (cdr (symbol-value ref-dep))
9412 (list (symbol-value id-dep))))
9413 (set ref-dep (list nil (symbol-value id-dep))))
9414 (setq headers (cons header headers)))
9415 (goto-char (point-max))
9416 (widen))
9417 (nreverse headers)))))
9419 ;; The following macros and functions were written by Felix Lee
9420 ;; <flee@cse.psu.edu>.
9422 (defmacro gnus-nov-read-integer ()
9423 '(prog1
9424 (if (= (following-char) ?\t)
9426 (let ((num (condition-case nil (read buffer) (error nil))))
9427 (if (numberp num) num 0)))
9428 (or (eobp) (forward-char 1))))
9430 (defmacro gnus-nov-skip-field ()
9431 '(search-forward "\t" eol 'move))
9433 (defmacro gnus-nov-field ()
9434 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
9436 ;; Goes through the xover lines and returns a list of vectors
9437 (defun gnus-get-newsgroup-headers-xover (sequence &optional
9438 force-new dependencies)
9439 "Parse the news overview data in the server buffer, and return a
9440 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
9441 ;; Get the Xref when the users reads the articles since most/some
9442 ;; NNTP servers do not include Xrefs when using XOVER.
9443 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
9444 (let ((cur nntp-server-buffer)
9445 (dependencies (or dependencies gnus-newsgroup-dependencies))
9446 number headers header)
9447 (save-excursion
9448 (set-buffer nntp-server-buffer)
9449 ;; Allow the user to mangle the headers before parsing them.
9450 (run-hooks 'gnus-parse-headers-hook)
9451 (goto-char (point-min))
9452 (while (and sequence (not (eobp)))
9453 (setq number (read cur))
9454 (while (and sequence (< (car sequence) number))
9455 (setq sequence (cdr sequence)))
9456 (and sequence
9457 (eq number (car sequence))
9458 (progn
9459 (setq sequence (cdr sequence))
9460 (if (setq header
9461 (inline (gnus-nov-parse-line
9462 number dependencies force-new)))
9463 (setq headers (cons header headers)))))
9464 (forward-line 1))
9465 (setq headers (nreverse headers)))
9466 headers))
9468 ;; This function has to be called with point after the article number
9469 ;; on the beginning of the line.
9470 (defun gnus-nov-parse-line (number dependencies &optional force-new)
9471 (let ((none 0)
9472 (eol (gnus-point-at-eol))
9473 (buffer (current-buffer))
9474 header ref id id-dep ref-dep)
9476 ;; overview: [num subject from date id refs chars lines misc]
9477 (narrow-to-region (point) eol)
9478 (or (eobp) (forward-char))
9480 (condition-case nil
9481 (setq header
9482 (vector
9483 number ; number
9484 (gnus-nov-field) ; subject
9485 (gnus-nov-field) ; from
9486 (gnus-nov-field) ; date
9487 (setq id (or (gnus-nov-field)
9488 (concat "none+"
9489 (int-to-string
9490 (setq none (1+ none)))))) ; id
9491 (progn
9492 (save-excursion
9493 (let ((beg (point)))
9494 (search-forward "\t" eol)
9495 (if (search-backward ">" beg t)
9496 (setq ref
9497 (buffer-substring
9498 (1+ (point))
9499 (search-backward "<" beg t)))
9500 (setq ref nil))))
9501 (gnus-nov-field)) ; refs
9502 (gnus-nov-read-integer) ; chars
9503 (gnus-nov-read-integer) ; lines
9504 (if (= (following-char) ?\n)
9506 (gnus-nov-field)) ; misc
9508 (error (progn
9509 (gnus-error 4 "Strange nov line")
9510 (setq header nil)
9511 (goto-char eol))))
9513 (widen)
9515 ;; We build the thread tree.
9516 (when header
9517 (if (boundp (setq id-dep (intern id dependencies)))
9518 (if (and (car (symbol-value id-dep))
9519 (not force-new))
9520 ;; An article with this Message-ID has already been seen,
9521 ;; so we ignore this one, except we add any additional
9522 ;; Xrefs (in case the two articles came from different
9523 ;; servers.
9524 (progn
9525 (mail-header-set-xref
9526 (car (symbol-value id-dep))
9527 (concat (or (mail-header-xref
9528 (car (symbol-value id-dep))) "")
9529 (or (mail-header-xref header) "")))
9530 (setq header nil))
9531 (setcar (symbol-value id-dep) header))
9532 (set id-dep (list header))))
9533 (when header
9534 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
9535 (setcdr (symbol-value ref-dep)
9536 (nconc (cdr (symbol-value ref-dep))
9537 (list (symbol-value id-dep))))
9538 (set ref-dep (list nil (symbol-value id-dep)))))
9539 header))
9541 (defun gnus-article-get-xrefs ()
9542 "Fill in the Xref value in `gnus-current-headers', if necessary.
9543 This is meant to be called in `gnus-article-internal-prepare-hook'."
9544 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
9545 gnus-current-headers)))
9546 (or (not gnus-use-cross-reference)
9547 (not headers)
9548 (and (mail-header-xref headers)
9549 (not (string= (mail-header-xref headers) "")))
9550 (let ((case-fold-search t)
9551 xref)
9552 (save-restriction
9553 (nnheader-narrow-to-headers)
9554 (goto-char (point-min))
9555 (if (or (and (eq (downcase (following-char)) ?x)
9556 (looking-at "Xref:"))
9557 (search-forward "\nXref:" nil t))
9558 (progn
9559 (goto-char (1+ (match-end 0)))
9560 (setq xref (buffer-substring (point)
9561 (progn (end-of-line) (point))))
9562 (mail-header-set-xref headers xref))))))))
9564 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
9565 "Find article ID and insert the summary line for that article."
9566 (let ((header (if (and old-header use-old-header)
9567 old-header (gnus-read-header id)))
9568 (number (and (numberp id) id))
9569 pos)
9570 (when header
9571 ;; Rebuild the thread that this article is part of and go to the
9572 ;; article we have fetched.
9573 (when (and (not gnus-show-threads)
9574 old-header)
9575 (when (setq pos (text-property-any
9576 (point-min) (point-max) 'gnus-number
9577 (mail-header-number old-header)))
9578 (goto-char pos)
9579 (gnus-delete-line)
9580 (gnus-data-remove (mail-header-number old-header))))
9581 (when old-header
9582 (mail-header-set-number header (mail-header-number old-header)))
9583 (setq gnus-newsgroup-sparse
9584 (delq (setq number (mail-header-number header))
9585 gnus-newsgroup-sparse))
9586 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
9587 (gnus-rebuild-thread (mail-header-id header))
9588 (gnus-summary-goto-subject number nil t))
9589 (when (and (numberp number)
9590 (> number 0))
9591 ;; We have to update the boundaries even if we can't fetch the
9592 ;; article if ID is a number -- so that the next `P' or `N'
9593 ;; command will fetch the previous (or next) article even
9594 ;; if the one we tried to fetch this time has been canceled.
9595 (and (> number gnus-newsgroup-end)
9596 (setq gnus-newsgroup-end number))
9597 (and (< number gnus-newsgroup-begin)
9598 (setq gnus-newsgroup-begin number))
9599 (setq gnus-newsgroup-unselected
9600 (delq number gnus-newsgroup-unselected)))
9601 ;; Report back a success?
9602 (and header (mail-header-number header))))
9604 (defun gnus-summary-work-articles (n)
9605 "Return a list of articles to be worked upon. The prefix argument,
9606 the list of process marked articles, and the current article will be
9607 taken into consideration."
9608 (cond
9610 ;; A numerical prefix has been given.
9611 (let ((backward (< n 0))
9612 (n (abs (prefix-numeric-value n)))
9613 articles article)
9614 (save-excursion
9615 (while
9616 (and (> n 0)
9617 (push (setq article (gnus-summary-article-number))
9618 articles)
9619 (if backward
9620 (gnus-summary-find-prev nil article)
9621 (gnus-summary-find-next nil article)))
9622 (decf n)))
9623 (nreverse articles)))
9624 ((and (boundp 'transient-mark-mode)
9625 transient-mark-mode
9626 mark-active)
9627 ;; Work on the region between point and mark.
9628 (let ((max (max (point) (mark)))
9629 articles article)
9630 (save-excursion
9631 (goto-char (min (point) (mark)))
9632 (while
9633 (and
9634 (push (setq article (gnus-summary-article-number)) articles)
9635 (gnus-summary-find-next nil article)
9636 (< (point) max)))
9637 (nreverse articles))))
9638 (gnus-newsgroup-processable
9639 ;; There are process-marked articles present.
9640 (reverse gnus-newsgroup-processable))
9642 ;; Just return the current article.
9643 (list (gnus-summary-article-number)))))
9645 (defun gnus-summary-search-group (&optional backward use-level)
9646 "Search for next unread newsgroup.
9647 If optional argument BACKWARD is non-nil, search backward instead."
9648 (save-excursion
9649 (set-buffer gnus-group-buffer)
9650 (if (gnus-group-search-forward
9651 backward nil (if use-level (gnus-group-group-level) nil))
9652 (gnus-group-group-name))))
9654 (defun gnus-summary-best-group (&optional exclude-group)
9655 "Find the name of the best unread group.
9656 If EXCLUDE-GROUP, do not go to this group."
9657 (save-excursion
9658 (set-buffer gnus-group-buffer)
9659 (save-excursion
9660 (gnus-group-best-unread-group exclude-group))))
9662 (defun gnus-summary-find-next (&optional unread article backward)
9663 (if backward (gnus-summary-find-prev)
9664 (let* ((dummy (gnus-summary-article-intangible-p))
9665 (article (or article (gnus-summary-article-number)))
9666 (arts (gnus-data-find-list article))
9667 result)
9668 (when (and (not dummy)
9669 (or (not gnus-summary-check-current)
9670 (not unread)
9671 (not (gnus-data-unread-p (car arts)))))
9672 (setq arts (cdr arts)))
9673 (when (setq result
9674 (if unread
9675 (progn
9676 (while arts
9677 (when (gnus-data-unread-p (car arts))
9678 (setq result (car arts)
9679 arts nil))
9680 (setq arts (cdr arts)))
9681 result)
9682 (car arts)))
9683 (goto-char (gnus-data-pos result))
9684 (gnus-data-number result)))))
9686 (defun gnus-summary-find-prev (&optional unread article)
9687 (let* ((eobp (eobp))
9688 (article (or article (gnus-summary-article-number)))
9689 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
9690 result)
9691 (when (and (not eobp)
9692 (or (not gnus-summary-check-current)
9693 (not unread)
9694 (not (gnus-data-unread-p (car arts)))))
9695 (setq arts (cdr arts)))
9696 (if (setq result
9697 (if unread
9698 (progn
9699 (while arts
9700 (and (gnus-data-unread-p (car arts))
9701 (setq result (car arts)
9702 arts nil))
9703 (setq arts (cdr arts)))
9704 result)
9705 (car arts)))
9706 (progn
9707 (goto-char (gnus-data-pos result))
9708 (gnus-data-number result)))))
9710 (defun gnus-summary-find-subject (subject &optional unread backward article)
9711 (let* ((simp-subject (gnus-simplify-subject-fully subject))
9712 (article (or article (gnus-summary-article-number)))
9713 (articles (gnus-data-list backward))
9714 (arts (gnus-data-find-list article articles))
9715 result)
9716 (when (or (not gnus-summary-check-current)
9717 (not unread)
9718 (not (gnus-data-unread-p (car arts))))
9719 (setq arts (cdr arts)))
9720 (while arts
9721 (and (or (not unread)
9722 (gnus-data-unread-p (car arts)))
9723 (vectorp (gnus-data-header (car arts)))
9724 (gnus-subject-equal
9725 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
9726 (setq result (car arts)
9727 arts nil))
9728 (setq arts (cdr arts)))
9729 (and result
9730 (goto-char (gnus-data-pos result))
9731 (gnus-data-number result))))
9733 (defun gnus-summary-search-forward (&optional unread subject backward)
9734 "Search forward for an article.
9735 If UNREAD, look for unread articles. If SUBJECT, look for
9736 articles with that subject. If BACKWARD, search backward instead."
9737 (cond (subject (gnus-summary-find-subject subject unread backward))
9738 (backward (gnus-summary-find-prev unread))
9739 (t (gnus-summary-find-next unread))))
9741 (defun gnus-recenter (&optional n)
9742 "Center point in window and redisplay frame.
9743 Also do horizontal recentering."
9744 (interactive "P")
9745 (when (and gnus-auto-center-summary
9746 (not (eq gnus-auto-center-summary 'vertical)))
9747 (gnus-horizontal-recenter))
9748 (recenter n))
9750 (defun gnus-summary-recenter ()
9751 "Center point in the summary window.
9752 If `gnus-auto-center-summary' is nil, or the article buffer isn't
9753 displayed, no centering will be performed."
9754 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
9755 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
9756 (let* ((top (cond ((< (window-height) 4) 0)
9757 ((< (window-height) 7) 1)
9758 (t 2)))
9759 (height (1- (window-height)))
9760 (bottom (save-excursion (goto-char (point-max))
9761 (forward-line (- height))
9762 (point)))
9763 (window (get-buffer-window (current-buffer))))
9764 ;; The user has to want it.
9765 (when gnus-auto-center-summary
9766 (when (get-buffer-window gnus-article-buffer)
9767 ;; Only do recentering when the article buffer is displayed,
9768 ;; Set the window start to either `bottom', which is the biggest
9769 ;; possible valid number, or the second line from the top,
9770 ;; whichever is the least.
9771 (set-window-start
9772 window (min bottom (save-excursion
9773 (forward-line (- top)) (point)))))
9774 ;; Do horizontal recentering while we're at it.
9775 (when (and (get-buffer-window (current-buffer) t)
9776 (not (eq gnus-auto-center-summary 'vertical)))
9777 (let ((selected (selected-window)))
9778 (select-window (get-buffer-window (current-buffer) t))
9779 (gnus-summary-position-point)
9780 (gnus-horizontal-recenter)
9781 (select-window selected))))))
9783 (defun gnus-horizontal-recenter ()
9784 "Recenter the current buffer horizontally."
9785 (if (< (current-column) (/ (window-width) 2))
9786 (set-window-hscroll (get-buffer-window (current-buffer) t) 0)
9787 (let* ((orig (point))
9788 (end (window-end (get-buffer-window (current-buffer) t)))
9789 (max 0))
9790 ;; Find the longest line currently displayed in the window.
9791 (goto-char (window-start))
9792 (while (and (not (eobp))
9793 (< (point) end))
9794 (end-of-line)
9795 (setq max (max max (current-column)))
9796 (forward-line 1))
9797 (goto-char orig)
9798 ;; Scroll horizontally to center (sort of) the point.
9799 (if (> max (window-width))
9800 (set-window-hscroll
9801 (get-buffer-window (current-buffer) t)
9802 (min (- (current-column) (/ (window-width) 3))
9803 (+ 2 (- max (window-width)))))
9804 (set-window-hscroll (get-buffer-window (current-buffer) t) 0))
9805 max)))
9807 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
9808 (defun gnus-short-group-name (group &optional levels)
9809 "Collapse GROUP name LEVELS."
9810 (let* ((name "")
9811 (foreign "")
9812 (depth 0)
9813 (skip 1)
9814 (levels (or levels
9815 (progn
9816 (while (string-match "\\." group skip)
9817 (setq skip (match-end 0)
9818 depth (+ depth 1)))
9819 depth))))
9820 (if (string-match ":" group)
9821 (setq foreign (substring group 0 (match-end 0))
9822 group (substring group (match-end 0))))
9823 (while group
9824 (if (and (string-match "\\." group)
9825 (> levels (- gnus-group-uncollapsed-levels 1)))
9826 (setq name (concat name (substring group 0 1))
9827 group (substring group (match-end 0))
9828 levels (- levels 1)
9829 name (concat name "."))
9830 (setq name (concat foreign name group)
9831 group nil)))
9832 name))
9834 (defun gnus-summary-jump-to-group (newsgroup)
9835 "Move point to NEWSGROUP in group mode buffer."
9836 ;; Keep update point of group mode buffer if visible.
9837 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
9838 (save-window-excursion
9839 ;; Take care of tree window mode.
9840 (if (get-buffer-window gnus-group-buffer)
9841 (pop-to-buffer gnus-group-buffer))
9842 (gnus-group-jump-to-group newsgroup))
9843 (save-excursion
9844 ;; Take care of tree window mode.
9845 (if (get-buffer-window gnus-group-buffer)
9846 (pop-to-buffer gnus-group-buffer)
9847 (set-buffer gnus-group-buffer))
9848 (gnus-group-jump-to-group newsgroup))))
9850 ;; This function returns a list of article numbers based on the
9851 ;; difference between the ranges of read articles in this group and
9852 ;; the range of active articles.
9853 (defun gnus-list-of-unread-articles (group)
9854 (let* ((read (gnus-info-read (gnus-get-info group)))
9855 (active (gnus-active group))
9856 (last (cdr active))
9857 first nlast unread)
9858 ;; If none are read, then all are unread.
9859 (if (not read)
9860 (setq first (car active))
9861 ;; If the range of read articles is a single range, then the
9862 ;; first unread article is the article after the last read
9863 ;; article. Sounds logical, doesn't it?
9864 (if (not (listp (cdr read)))
9865 (setq first (1+ (cdr read)))
9866 ;; `read' is a list of ranges.
9867 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
9868 (caar read))) 1)
9869 (setq first 1))
9870 (while read
9871 (if first
9872 (while (< first nlast)
9873 (setq unread (cons first unread))
9874 (setq first (1+ first))))
9875 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
9876 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
9877 (setq read (cdr read)))))
9878 ;; And add the last unread articles.
9879 (while (<= first last)
9880 (setq unread (cons first unread))
9881 (setq first (1+ first)))
9882 ;; Return the list of unread articles.
9883 (nreverse unread)))
9885 (defun gnus-list-of-read-articles (group)
9886 "Return a list of unread, unticked and non-dormant articles."
9887 (let* ((info (gnus-get-info group))
9888 (marked (gnus-info-marks info))
9889 (active (gnus-active group)))
9890 (and info active
9891 (gnus-set-difference
9892 (gnus-sorted-complement
9893 (gnus-uncompress-range active)
9894 (gnus-list-of-unread-articles group))
9895 (append
9896 (gnus-uncompress-range (cdr (assq 'dormant marked)))
9897 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
9899 ;; Various summary commands
9901 (defun gnus-summary-universal-argument (arg)
9902 "Perform any operation on all articles that are process/prefixed."
9903 (interactive "P")
9904 (gnus-set-global-variables)
9905 (let ((articles (gnus-summary-work-articles arg))
9906 func article)
9907 (if (eq
9908 (setq
9909 func
9910 (key-binding
9911 (read-key-sequence
9912 (substitute-command-keys
9913 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
9914 ))))
9915 'undefined)
9916 (gnus-error 1 "Undefined key")
9917 (save-excursion
9918 (while articles
9919 (gnus-summary-goto-subject (setq article (pop articles)))
9920 (command-execute func)
9921 (gnus-summary-remove-process-mark article)))))
9922 (gnus-summary-position-point))
9924 (defun gnus-summary-toggle-truncation (&optional arg)
9925 "Toggle truncation of summary lines.
9926 With arg, turn line truncation on iff arg is positive."
9927 (interactive "P")
9928 (setq truncate-lines
9929 (if (null arg) (not truncate-lines)
9930 (> (prefix-numeric-value arg) 0)))
9931 (redraw-display))
9933 (defun gnus-summary-reselect-current-group (&optional all rescan)
9934 "Exit and then reselect the current newsgroup.
9935 The prefix argument ALL means to select all articles."
9936 (interactive "P")
9937 (gnus-set-global-variables)
9938 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
9939 (error "Ephemeral groups can't be reselected"))
9940 (let ((current-subject (gnus-summary-article-number))
9941 (group gnus-newsgroup-name))
9942 (setq gnus-newsgroup-begin nil)
9943 (gnus-summary-exit)
9944 ;; We have to adjust the point of group mode buffer because the
9945 ;; current point was moved to the next unread newsgroup by
9946 ;; exiting.
9947 (gnus-summary-jump-to-group group)
9948 (when rescan
9949 (save-excursion
9950 (gnus-group-get-new-news-this-group 1)))
9951 (gnus-group-read-group all t)
9952 (gnus-summary-goto-subject current-subject nil t)))
9954 (defun gnus-summary-rescan-group (&optional all)
9955 "Exit the newsgroup, ask for new articles, and select the newsgroup."
9956 (interactive "P")
9957 (gnus-summary-reselect-current-group all t))
9959 (defun gnus-summary-update-info ()
9960 (let* ((group gnus-newsgroup-name))
9961 (when gnus-newsgroup-kill-headers
9962 (setq gnus-newsgroup-killed
9963 (gnus-compress-sequence
9964 (nconc
9965 (gnus-set-sorted-intersection
9966 (gnus-uncompress-range gnus-newsgroup-killed)
9967 (setq gnus-newsgroup-unselected
9968 (sort gnus-newsgroup-unselected '<)))
9969 (setq gnus-newsgroup-unreads
9970 (sort gnus-newsgroup-unreads '<))) t)))
9971 (unless (listp (cdr gnus-newsgroup-killed))
9972 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
9973 (let ((headers gnus-newsgroup-headers))
9974 (run-hooks 'gnus-exit-group-hook)
9975 (unless gnus-save-score
9976 (setq gnus-newsgroup-scored nil))
9977 ;; Set the new ranges of read articles.
9978 (gnus-update-read-articles
9979 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
9980 ;; Set the current article marks.
9981 (gnus-update-marks)
9982 ;; Do the cross-ref thing.
9983 (when gnus-use-cross-reference
9984 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
9985 ;; Do adaptive scoring, and possibly save score files.
9986 (when gnus-newsgroup-adaptive
9987 (gnus-score-adaptive))
9988 (when gnus-use-scoring
9989 (gnus-score-save))
9990 ;; Do not switch windows but change the buffer to work.
9991 (set-buffer gnus-group-buffer)
9992 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
9993 (gnus-group-update-group group)))))
9995 (defun gnus-summary-exit (&optional temporary)
9996 "Exit reading current newsgroup, and then return to group selection mode.
9997 gnus-exit-group-hook is called with no arguments if that value is non-nil."
9998 (interactive)
9999 (gnus-set-global-variables)
10000 (gnus-kill-save-kill-buffer)
10001 (let* ((group gnus-newsgroup-name)
10002 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
10003 (mode major-mode)
10004 (buf (current-buffer)))
10005 (run-hooks 'gnus-summary-prepare-exit-hook)
10006 ;; If we have several article buffers, we kill them at exit.
10007 (unless gnus-single-article-buffer
10008 (gnus-kill-buffer gnus-original-article-buffer)
10009 (setq gnus-article-current nil))
10010 (when gnus-use-cache
10011 (gnus-cache-possibly-remove-articles)
10012 (gnus-cache-save-buffers))
10013 (when gnus-use-trees
10014 (gnus-tree-close group))
10015 ;; Make all changes in this group permanent.
10016 (unless quit-config
10017 (gnus-summary-update-info))
10018 (gnus-close-group group)
10019 ;; Make sure where I was, and go to next newsgroup.
10020 (set-buffer gnus-group-buffer)
10021 (unless quit-config
10022 (gnus-group-jump-to-group group))
10023 (run-hooks 'gnus-summary-exit-hook)
10024 (unless quit-config
10025 (gnus-group-next-unread-group 1))
10026 (if temporary
10027 nil ;Nothing to do.
10028 ;; If we have several article buffers, we kill them at exit.
10029 (unless gnus-single-article-buffer
10030 (gnus-kill-buffer gnus-article-buffer)
10031 (gnus-kill-buffer gnus-original-article-buffer)
10032 (setq gnus-article-current nil))
10033 (set-buffer buf)
10034 (if (not gnus-kill-summary-on-exit)
10035 (gnus-deaden-summary)
10036 ;; We set all buffer-local variables to nil. It is unclear why
10037 ;; this is needed, but if we don't, buffer-local variables are
10038 ;; not garbage-collected, it seems. This would the lead to en
10039 ;; ever-growing Emacs.
10040 (gnus-summary-clear-local-variables)
10041 (when (get-buffer gnus-article-buffer)
10042 (bury-buffer gnus-article-buffer))
10043 ;; We clear the global counterparts of the buffer-local
10044 ;; variables as well, just to be on the safe side.
10045 (gnus-configure-windows 'group 'force)
10046 (gnus-summary-clear-local-variables)
10047 ;; Return to group mode buffer.
10048 (if (eq mode 'gnus-summary-mode)
10049 (gnus-kill-buffer buf)))
10050 (setq gnus-current-select-method gnus-select-method)
10051 (pop-to-buffer gnus-group-buffer)
10052 ;; Clear the current group name.
10053 (if (not quit-config)
10054 (progn
10055 (gnus-group-jump-to-group group)
10056 (gnus-group-next-unread-group 1)
10057 (gnus-configure-windows 'group 'force))
10058 (if (not (buffer-name (car quit-config)))
10059 (gnus-configure-windows 'group 'force)
10060 (set-buffer (car quit-config))
10061 (and (eq major-mode 'gnus-summary-mode)
10062 (gnus-set-global-variables))
10063 (gnus-configure-windows (cdr quit-config))))
10064 (unless quit-config
10065 (setq gnus-newsgroup-name nil)))))
10067 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
10068 (defun gnus-summary-exit-no-update (&optional no-questions)
10069 "Quit reading current newsgroup without updating read article info."
10070 (interactive)
10071 (gnus-set-global-variables)
10072 (let* ((group gnus-newsgroup-name)
10073 (quit-config (gnus-group-quit-config group)))
10074 (when (or no-questions
10075 gnus-expert-user
10076 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
10077 ;; If we have several article buffers, we kill them at exit.
10078 (unless gnus-single-article-buffer
10079 (gnus-kill-buffer gnus-article-buffer)
10080 (gnus-kill-buffer gnus-original-article-buffer)
10081 (setq gnus-article-current nil))
10082 (if (not gnus-kill-summary-on-exit)
10083 (gnus-deaden-summary)
10084 (gnus-close-group group)
10085 (gnus-summary-clear-local-variables)
10086 (set-buffer gnus-group-buffer)
10087 (gnus-summary-clear-local-variables)
10088 (when (get-buffer gnus-summary-buffer)
10089 (kill-buffer gnus-summary-buffer)))
10090 (unless gnus-single-article-buffer
10091 (setq gnus-article-current nil))
10092 (when gnus-use-trees
10093 (gnus-tree-close group))
10094 (when (get-buffer gnus-article-buffer)
10095 (bury-buffer gnus-article-buffer))
10096 ;; Return to the group buffer.
10097 (gnus-configure-windows 'group 'force)
10098 ;; Clear the current group name.
10099 (setq gnus-newsgroup-name nil)
10100 (when (equal (gnus-group-group-name) group)
10101 (gnus-group-next-unread-group 1))
10102 (when quit-config
10103 (if (not (buffer-name (car quit-config)))
10104 (gnus-configure-windows 'group 'force)
10105 (set-buffer (car quit-config))
10106 (when (eq major-mode 'gnus-summary-mode)
10107 (gnus-set-global-variables))
10108 (gnus-configure-windows (cdr quit-config)))))))
10110 ;;; Dead summaries.
10112 (defvar gnus-dead-summary-mode-map nil)
10114 (if gnus-dead-summary-mode-map
10116 (setq gnus-dead-summary-mode-map (make-keymap))
10117 (suppress-keymap gnus-dead-summary-mode-map)
10118 (substitute-key-definition
10119 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
10120 (let ((keys '("\C-d" "\r" "\177")))
10121 (while keys
10122 (define-key gnus-dead-summary-mode-map
10123 (pop keys) 'gnus-summary-wake-up-the-dead))))
10125 (defvar gnus-dead-summary-mode nil
10126 "Minor mode for Gnus summary buffers.")
10128 (defun gnus-dead-summary-mode (&optional arg)
10129 "Minor mode for Gnus summary buffers."
10130 (interactive "P")
10131 (when (eq major-mode 'gnus-summary-mode)
10132 (make-local-variable 'gnus-dead-summary-mode)
10133 (setq gnus-dead-summary-mode
10134 (if (null arg) (not gnus-dead-summary-mode)
10135 (> (prefix-numeric-value arg) 0)))
10136 (when gnus-dead-summary-mode
10137 (unless (assq 'gnus-dead-summary-mode minor-mode-alist)
10138 (push '(gnus-dead-summary-mode " Dead") minor-mode-alist))
10139 (unless (assq 'gnus-dead-summary-mode minor-mode-map-alist)
10140 (push (cons 'gnus-dead-summary-mode gnus-dead-summary-mode-map)
10141 minor-mode-map-alist)))))
10143 (defun gnus-deaden-summary ()
10144 "Make the current summary buffer into a dead summary buffer."
10145 ;; Kill any previous dead summary buffer.
10146 (when (and gnus-dead-summary
10147 (buffer-name gnus-dead-summary))
10148 (save-excursion
10149 (set-buffer gnus-dead-summary)
10150 (when gnus-dead-summary-mode
10151 (kill-buffer (current-buffer)))))
10152 ;; Make this the current dead summary.
10153 (setq gnus-dead-summary (current-buffer))
10154 (gnus-dead-summary-mode 1)
10155 (let ((name (buffer-name)))
10156 (when (string-match "Summary" name)
10157 (rename-buffer
10158 (concat (substring name 0 (match-beginning 0)) "Dead "
10159 (substring name (match-beginning 0))) t))))
10161 (defun gnus-kill-or-deaden-summary (buffer)
10162 "Kill or deaden the summary BUFFER."
10163 (when (and (buffer-name buffer)
10164 (not gnus-single-article-buffer))
10165 (save-excursion
10166 (set-buffer buffer)
10167 (gnus-kill-buffer gnus-article-buffer)
10168 (gnus-kill-buffer gnus-original-article-buffer)))
10169 (cond (gnus-kill-summary-on-exit
10170 (when (and gnus-use-trees
10171 (and (get-buffer buffer)
10172 (buffer-name (get-buffer buffer))))
10173 (save-excursion
10174 (set-buffer (get-buffer buffer))
10175 (gnus-tree-close gnus-newsgroup-name)))
10176 (gnus-kill-buffer buffer))
10177 ((and (get-buffer buffer)
10178 (buffer-name (get-buffer buffer)))
10179 (save-excursion
10180 (set-buffer buffer)
10181 (gnus-deaden-summary)))))
10183 (defun gnus-summary-wake-up-the-dead (&rest args)
10184 "Wake up the dead summary buffer."
10185 (interactive)
10186 (gnus-dead-summary-mode -1)
10187 (let ((name (buffer-name)))
10188 (when (string-match "Dead " name)
10189 (rename-buffer
10190 (concat (substring name 0 (match-beginning 0))
10191 (substring name (match-end 0))) t)))
10192 (gnus-message 3 "This dead summary is now alive again"))
10194 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
10195 (defun gnus-summary-fetch-faq (&optional faq-dir)
10196 "Fetch the FAQ for the current group.
10197 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
10198 in."
10199 (interactive
10200 (list
10201 (if current-prefix-arg
10202 (completing-read
10203 "Faq dir: " (and (listp gnus-group-faq-directory)
10204 gnus-group-faq-directory)))))
10205 (let (gnus-faq-buffer)
10206 (and (setq gnus-faq-buffer
10207 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
10208 (gnus-configure-windows 'summary-faq))))
10210 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
10211 (defun gnus-summary-describe-group (&optional force)
10212 "Describe the current newsgroup."
10213 (interactive "P")
10214 (gnus-group-describe-group force gnus-newsgroup-name))
10216 (defun gnus-summary-describe-briefly ()
10217 "Describe summary mode commands briefly."
10218 (interactive)
10219 (gnus-message 6
10220 (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")))
10222 ;; Walking around group mode buffer from summary mode.
10224 (defun gnus-summary-next-group (&optional no-article target-group backward)
10225 "Exit current newsgroup and then select next unread newsgroup.
10226 If prefix argument NO-ARTICLE is non-nil, no article is selected
10227 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
10228 previous group instead."
10229 (interactive "P")
10230 (gnus-set-global-variables)
10231 (let ((current-group gnus-newsgroup-name)
10232 (current-buffer (current-buffer))
10233 entered)
10234 ;; First we semi-exit this group to update Xrefs and all variables.
10235 ;; We can't do a real exit, because the window conf must remain
10236 ;; the same in case the user is prompted for info, and we don't
10237 ;; want the window conf to change before that...
10238 (gnus-summary-exit t)
10239 (while (not entered)
10240 ;; Then we find what group we are supposed to enter.
10241 (set-buffer gnus-group-buffer)
10242 (gnus-group-jump-to-group current-group)
10243 (setq target-group
10244 (or target-group
10245 (if (eq gnus-keep-same-level 'best)
10246 (gnus-summary-best-group gnus-newsgroup-name)
10247 (gnus-summary-search-group backward gnus-keep-same-level))))
10248 (if (not target-group)
10249 ;; There are no further groups, so we return to the group
10250 ;; buffer.
10251 (progn
10252 (gnus-message 5 "Returning to the group buffer")
10253 (setq entered t)
10254 (set-buffer current-buffer)
10255 (gnus-summary-exit))
10256 ;; We try to enter the target group.
10257 (gnus-group-jump-to-group target-group)
10258 (let ((unreads (gnus-group-group-unread)))
10259 (if (and (or (eq t unreads)
10260 (and unreads (not (zerop unreads))))
10261 (gnus-summary-read-group
10262 target-group nil no-article current-buffer))
10263 (setq entered t)
10264 (setq current-group target-group
10265 target-group nil)))))))
10267 (defun gnus-summary-prev-group (&optional no-article)
10268 "Exit current newsgroup and then select previous unread newsgroup.
10269 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
10270 (interactive "P")
10271 (gnus-summary-next-group no-article nil t))
10273 ;; Walking around summary lines.
10275 (defun gnus-summary-first-subject (&optional unread)
10276 "Go to the first unread subject.
10277 If UNREAD is non-nil, go to the first unread article.
10278 Returns the article selected or nil if there are no unread articles."
10279 (interactive "P")
10280 (prog1
10281 (cond
10282 ;; Empty summary.
10283 ((null gnus-newsgroup-data)
10284 (gnus-message 3 "No articles in the group")
10285 nil)
10286 ;; Pick the first article.
10287 ((not unread)
10288 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
10289 (gnus-data-number (car gnus-newsgroup-data)))
10290 ;; No unread articles.
10291 ((null gnus-newsgroup-unreads)
10292 (gnus-message 3 "No more unread articles")
10293 nil)
10294 ;; Find the first unread article.
10296 (let ((data gnus-newsgroup-data))
10297 (while (and data
10298 (not (gnus-data-unread-p (car data))))
10299 (setq data (cdr data)))
10300 (if data
10301 (progn
10302 (goto-char (gnus-data-pos (car data)))
10303 (gnus-data-number (car data)))))))
10304 (gnus-summary-position-point)))
10306 (defun gnus-summary-next-subject (n &optional unread dont-display)
10307 "Go to next N'th summary line.
10308 If N is negative, go to the previous N'th subject line.
10309 If UNREAD is non-nil, only unread articles are selected.
10310 The difference between N and the actual number of steps taken is
10311 returned."
10312 (interactive "p")
10313 (let ((backward (< n 0))
10314 (n (abs n)))
10315 (while (and (> n 0)
10316 (if backward
10317 (gnus-summary-find-prev unread)
10318 (gnus-summary-find-next unread)))
10319 (setq n (1- n)))
10320 (if (/= 0 n) (gnus-message 7 "No more%s articles"
10321 (if unread " unread" "")))
10322 (unless dont-display
10323 (gnus-summary-recenter)
10324 (gnus-summary-position-point))
10327 (defun gnus-summary-next-unread-subject (n)
10328 "Go to next N'th unread summary line."
10329 (interactive "p")
10330 (gnus-summary-next-subject n t))
10332 (defun gnus-summary-prev-subject (n &optional unread)
10333 "Go to previous N'th summary line.
10334 If optional argument UNREAD is non-nil, only unread article is selected."
10335 (interactive "p")
10336 (gnus-summary-next-subject (- n) unread))
10338 (defun gnus-summary-prev-unread-subject (n)
10339 "Go to previous N'th unread summary line."
10340 (interactive "p")
10341 (gnus-summary-next-subject (- n) t))
10343 (defun gnus-summary-goto-subject (article &optional force silent)
10344 "Go the subject line of ARTICLE.
10345 If FORCE, also allow jumping to articles not currently shown."
10346 (let ((b (point))
10347 (data (gnus-data-find article)))
10348 ;; We read in the article if we have to.
10349 (and (not data)
10350 force
10351 (gnus-summary-insert-subject article (and (vectorp force) force) t)
10352 (setq data (gnus-data-find article)))
10353 (goto-char b)
10354 (if (not data)
10355 (progn
10356 (unless silent
10357 (gnus-message 3 "Can't find article %d" article))
10358 nil)
10359 (goto-char (gnus-data-pos data))
10360 article)))
10362 ;; Walking around summary lines with displaying articles.
10364 (defun gnus-summary-expand-window (&optional arg)
10365 "Make the summary buffer take up the entire Emacs frame.
10366 Given a prefix, will force an `article' buffer configuration."
10367 (interactive "P")
10368 (gnus-set-global-variables)
10369 (if arg
10370 (gnus-configure-windows 'article 'force)
10371 (gnus-configure-windows 'summary 'force)))
10373 (defun gnus-summary-display-article (article &optional all-header)
10374 "Display ARTICLE in article buffer."
10375 (gnus-set-global-variables)
10376 (if (null article)
10378 (prog1
10379 (if gnus-summary-display-article-function
10380 (funcall gnus-summary-display-article-function article all-header)
10381 (gnus-article-prepare article all-header))
10382 (run-hooks 'gnus-select-article-hook)
10383 (unless (zerop gnus-current-article)
10384 (gnus-summary-goto-subject gnus-current-article))
10385 (gnus-summary-recenter)
10386 (when gnus-use-trees
10387 (gnus-possibly-generate-tree article)
10388 (gnus-highlight-selected-tree article))
10389 ;; Successfully display article.
10390 (gnus-article-set-window-start
10391 (cdr (assq article gnus-newsgroup-bookmarks))))))
10393 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
10394 "Select the current article.
10395 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
10396 non-nil, the article will be re-fetched even if it already present in
10397 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
10398 be displayed."
10399 ;; Make sure we are in the summary buffer to work around bbdb bug.
10400 (unless (eq major-mode 'gnus-summary-mode)
10401 (set-buffer gnus-summary-buffer))
10402 (let ((article (or article (gnus-summary-article-number)))
10403 (all-headers (not (not all-headers))) ;Must be T or NIL.
10404 gnus-summary-display-article-function
10405 did)
10406 (and (not pseudo)
10407 (gnus-summary-article-pseudo-p article)
10408 (error "This is a pseudo-article."))
10409 (prog1
10410 (save-excursion
10411 (set-buffer gnus-summary-buffer)
10412 (if (or (and gnus-single-article-buffer
10413 (or (null gnus-current-article)
10414 (null gnus-article-current)
10415 (null (get-buffer gnus-article-buffer))
10416 (not (eq article (cdr gnus-article-current)))
10417 (not (equal (car gnus-article-current)
10418 gnus-newsgroup-name))))
10419 (and (not gnus-single-article-buffer)
10420 (or (null gnus-current-article)
10421 (not (eq gnus-current-article article))))
10422 force)
10423 ;; The requested article is different from the current article.
10424 (prog1
10425 (gnus-summary-display-article article all-headers)
10426 (setq did article))
10427 (if (or all-headers gnus-show-all-headers)
10428 (gnus-article-show-all-headers))
10429 'old))
10430 (if did
10431 (gnus-article-set-window-start
10432 (cdr (assq article gnus-newsgroup-bookmarks)))))))
10434 (defun gnus-summary-set-current-mark (&optional current-mark)
10435 "Obsolete function."
10436 nil)
10438 (defun gnus-summary-next-article (&optional unread subject backward push)
10439 "Select the next article.
10440 If UNREAD, only unread articles are selected.
10441 If SUBJECT, only articles with SUBJECT are selected.
10442 If BACKWARD, the previous article is selected instead of the next."
10443 (interactive "P")
10444 (gnus-set-global-variables)
10445 (cond
10446 ;; Is there such an article?
10447 ((and (gnus-summary-search-forward unread subject backward)
10448 (or (gnus-summary-display-article (gnus-summary-article-number))
10449 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
10450 (gnus-summary-position-point))
10451 ;; If not, we try the first unread, if that is wanted.
10452 ((and subject
10453 gnus-auto-select-same
10454 (gnus-summary-first-unread-article))
10455 (gnus-summary-position-point)
10456 (gnus-message 6 "Wrapped"))
10457 ;; Try to get next/previous article not displayed in this group.
10458 ((and gnus-auto-extend-newsgroup
10459 (not unread) (not subject))
10460 (gnus-summary-goto-article
10461 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
10462 nil t))
10463 ;; Go to next/previous group.
10465 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
10466 (gnus-summary-jump-to-group gnus-newsgroup-name))
10467 (let ((cmd last-command-char)
10468 (group
10469 (if (eq gnus-keep-same-level 'best)
10470 (gnus-summary-best-group gnus-newsgroup-name)
10471 (gnus-summary-search-group backward gnus-keep-same-level))))
10472 ;; For some reason, the group window gets selected. We change
10473 ;; it back.
10474 (select-window (get-buffer-window (current-buffer)))
10475 ;; Select next unread newsgroup automagically.
10476 (cond
10477 ((or (not gnus-auto-select-next)
10478 (not cmd))
10479 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
10480 ((or (eq gnus-auto-select-next 'quietly)
10481 (and (eq gnus-auto-select-next 'slightly-quietly)
10482 push)
10483 (and (eq gnus-auto-select-next 'almost-quietly)
10484 (gnus-summary-last-article-p)))
10485 ;; Select quietly.
10486 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
10487 (gnus-summary-exit)
10488 (gnus-message 7 "No more%s articles (%s)..."
10489 (if unread " unread" "")
10490 (if group (concat "selecting " group)
10491 "exiting"))
10492 (gnus-summary-next-group nil group backward)))
10494 (gnus-summary-walk-group-buffer
10495 gnus-newsgroup-name cmd unread backward)))))))
10497 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward)
10498 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
10499 (?\C-p (gnus-group-prev-unread-group 1))))
10500 keve key group ended)
10501 (save-excursion
10502 (set-buffer gnus-group-buffer)
10503 (gnus-summary-jump-to-group from-group)
10504 (setq group
10505 (if (eq gnus-keep-same-level 'best)
10506 (gnus-summary-best-group gnus-newsgroup-name)
10507 (gnus-summary-search-group backward gnus-keep-same-level))))
10508 (while (not ended)
10509 (gnus-message
10510 5 "No more%s articles%s" (if unread " unread" "")
10511 (if (and group
10512 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
10513 (format " (Type %s for %s [%s])"
10514 (single-key-description cmd) group
10515 (car (gnus-gethash group gnus-newsrc-hashtb)))
10516 (format " (Type %s to exit %s)"
10517 (single-key-description cmd)
10518 gnus-newsgroup-name)))
10519 ;; Confirm auto selection.
10520 (setq key (car (setq keve (gnus-read-event-char))))
10521 (setq ended t)
10522 (cond
10523 ((assq key keystrokes)
10524 (let ((obuf (current-buffer)))
10525 (switch-to-buffer gnus-group-buffer)
10526 (and group
10527 (gnus-group-jump-to-group group))
10528 (eval (cadr (assq key keystrokes)))
10529 (setq group (gnus-group-group-name))
10530 (switch-to-buffer obuf))
10531 (setq ended nil))
10532 ((equal key cmd)
10533 (if (or (not group)
10534 (gnus-ephemeral-group-p gnus-newsgroup-name))
10535 (gnus-summary-exit)
10536 (gnus-summary-next-group nil group backward)))
10538 (push (cdr keve) unread-command-events))))))
10540 (defun gnus-read-event-char ()
10541 "Get the next event."
10542 (let ((event (read-event)))
10543 (cons (and (numberp event) event) event)))
10545 (defun gnus-summary-next-unread-article ()
10546 "Select unread article after current one."
10547 (interactive)
10548 (gnus-summary-next-article t (and gnus-auto-select-same
10549 (gnus-summary-article-subject))))
10551 (defun gnus-summary-prev-article (&optional unread subject)
10552 "Select the article after the current one.
10553 If UNREAD is non-nil, only unread articles are selected."
10554 (interactive "P")
10555 (gnus-summary-next-article unread subject t))
10557 (defun gnus-summary-prev-unread-article ()
10558 "Select unred article before current one."
10559 (interactive)
10560 (gnus-summary-prev-article t (and gnus-auto-select-same
10561 (gnus-summary-article-subject))))
10563 (defun gnus-summary-next-page (&optional lines circular)
10564 "Show next page of the selected article.
10565 If at the end of the current article, select the next article.
10566 LINES says how many lines should be scrolled up.
10568 If CIRCULAR is non-nil, go to the start of the article instead of
10569 selecting the next article when reaching the end of the current
10570 article."
10571 (interactive "P")
10572 (setq gnus-summary-buffer (current-buffer))
10573 (gnus-set-global-variables)
10574 (let ((article (gnus-summary-article-number))
10575 (endp nil))
10576 (gnus-configure-windows 'article)
10577 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
10578 (if (and (eq gnus-summary-goto-unread 'never)
10579 (not (gnus-summary-last-article-p article)))
10580 (gnus-summary-next-article)
10581 (gnus-summary-next-unread-article))
10582 (if (or (null gnus-current-article)
10583 (null gnus-article-current)
10584 (/= article (cdr gnus-article-current))
10585 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10586 ;; Selected subject is different from current article's.
10587 (gnus-summary-display-article article)
10588 (gnus-eval-in-buffer-window gnus-article-buffer
10589 (setq endp (gnus-article-next-page lines)))
10590 (if endp
10591 (cond (circular
10592 (gnus-summary-beginning-of-article))
10593 (lines
10594 (gnus-message 3 "End of message"))
10595 ((null lines)
10596 (if (and (eq gnus-summary-goto-unread 'never)
10597 (not (gnus-summary-last-article-p article)))
10598 (gnus-summary-next-article)
10599 (gnus-summary-next-unread-article)))))))
10600 (gnus-summary-recenter)
10601 (gnus-summary-position-point)))
10603 (defun gnus-summary-prev-page (&optional lines)
10604 "Show previous page of selected article.
10605 Argument LINES specifies lines to be scrolled down."
10606 (interactive "P")
10607 (gnus-set-global-variables)
10608 (let ((article (gnus-summary-article-number)))
10609 (gnus-configure-windows 'article)
10610 (if (or (null gnus-current-article)
10611 (null gnus-article-current)
10612 (/= article (cdr gnus-article-current))
10613 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10614 ;; Selected subject is different from current article's.
10615 (gnus-summary-display-article article)
10616 (gnus-summary-recenter)
10617 (gnus-eval-in-buffer-window gnus-article-buffer
10618 (gnus-article-prev-page lines))))
10619 (gnus-summary-position-point))
10621 (defun gnus-summary-scroll-up (lines)
10622 "Scroll up (or down) one line current article.
10623 Argument LINES specifies lines to be scrolled up (or down if negative)."
10624 (interactive "p")
10625 (gnus-set-global-variables)
10626 (gnus-configure-windows 'article)
10627 (gnus-summary-show-thread)
10628 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
10629 (gnus-eval-in-buffer-window gnus-article-buffer
10630 (cond ((> lines 0)
10631 (if (gnus-article-next-page lines)
10632 (gnus-message 3 "End of message")))
10633 ((< lines 0)
10634 (gnus-article-prev-page (- lines))))))
10635 (gnus-summary-recenter)
10636 (gnus-summary-position-point))
10638 (defun gnus-summary-next-same-subject ()
10639 "Select next article which has the same subject as current one."
10640 (interactive)
10641 (gnus-set-global-variables)
10642 (gnus-summary-next-article nil (gnus-summary-article-subject)))
10644 (defun gnus-summary-prev-same-subject ()
10645 "Select previous article which has the same subject as current one."
10646 (interactive)
10647 (gnus-set-global-variables)
10648 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
10650 (defun gnus-summary-next-unread-same-subject ()
10651 "Select next unread article which has the same subject as current one."
10652 (interactive)
10653 (gnus-set-global-variables)
10654 (gnus-summary-next-article t (gnus-summary-article-subject)))
10656 (defun gnus-summary-prev-unread-same-subject ()
10657 "Select previous unread article which has the same subject as current one."
10658 (interactive)
10659 (gnus-set-global-variables)
10660 (gnus-summary-prev-article t (gnus-summary-article-subject)))
10662 (defun gnus-summary-first-unread-article ()
10663 "Select the first unread article.
10664 Return nil if there are no unread articles."
10665 (interactive)
10666 (gnus-set-global-variables)
10667 (prog1
10668 (if (gnus-summary-first-subject t)
10669 (progn
10670 (gnus-summary-show-thread)
10671 (gnus-summary-first-subject t)
10672 (gnus-summary-display-article (gnus-summary-article-number))))
10673 (gnus-summary-position-point)))
10675 (defun gnus-summary-best-unread-article ()
10676 "Select the unread article with the highest score."
10677 (interactive)
10678 (gnus-set-global-variables)
10679 (let ((best -1000000)
10680 (data gnus-newsgroup-data)
10681 article score)
10682 (while data
10683 (and (gnus-data-unread-p (car data))
10684 (> (setq score
10685 (gnus-summary-article-score (gnus-data-number (car data))))
10686 best)
10687 (setq best score
10688 article (gnus-data-number (car data))))
10689 (setq data (cdr data)))
10690 (prog1
10691 (if article
10692 (gnus-summary-goto-article article)
10693 (error "No unread articles"))
10694 (gnus-summary-position-point))))
10696 (defun gnus-summary-last-subject ()
10697 "Go to the last displayed subject line in the group."
10698 (let ((article (gnus-data-number (car (gnus-data-list t)))))
10699 (when article
10700 (gnus-summary-goto-subject article))))
10702 (defun gnus-summary-goto-article (article &optional all-headers force)
10703 "Fetch ARTICLE and display it if it exists.
10704 If ALL-HEADERS is non-nil, no header lines are hidden."
10705 (interactive
10706 (list
10707 (string-to-int
10708 (completing-read
10709 "Article number: "
10710 (mapcar (lambda (number) (list (int-to-string number)))
10711 gnus-newsgroup-limit)))
10712 current-prefix-arg
10714 (prog1
10715 (if (gnus-summary-goto-subject article force)
10716 (gnus-summary-display-article article all-headers)
10717 (gnus-message 4 "Couldn't go to article %s" article) nil)
10718 (gnus-summary-position-point)))
10720 (defun gnus-summary-goto-last-article ()
10721 "Go to the previously read article."
10722 (interactive)
10723 (prog1
10724 (and gnus-last-article
10725 (gnus-summary-goto-article gnus-last-article))
10726 (gnus-summary-position-point)))
10728 (defun gnus-summary-pop-article (number)
10729 "Pop one article off the history and go to the previous.
10730 NUMBER articles will be popped off."
10731 (interactive "p")
10732 (let (to)
10733 (setq gnus-newsgroup-history
10734 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
10735 (if to
10736 (gnus-summary-goto-article (car to))
10737 (error "Article history empty")))
10738 (gnus-summary-position-point))
10740 ;; Summary commands and functions for limiting the summary buffer.
10742 (defun gnus-summary-limit-to-articles (n)
10743 "Limit the summary buffer to the next N articles.
10744 If not given a prefix, use the process marked articles instead."
10745 (interactive "P")
10746 (gnus-set-global-variables)
10747 (prog1
10748 (let ((articles (gnus-summary-work-articles n)))
10749 (setq gnus-newsgroup-processable nil)
10750 (gnus-summary-limit articles))
10751 (gnus-summary-position-point)))
10753 (defun gnus-summary-pop-limit (&optional total)
10754 "Restore the previous limit.
10755 If given a prefix, remove all limits."
10756 (interactive "P")
10757 (gnus-set-global-variables)
10758 (when total
10759 (setq gnus-newsgroup-limits
10760 (list (mapcar (lambda (h) (mail-header-number h))
10761 gnus-newsgroup-headers))))
10762 (unless gnus-newsgroup-limits
10763 (error "No limit to pop"))
10764 (prog1
10765 (gnus-summary-limit nil 'pop)
10766 (gnus-summary-position-point)))
10768 (defun gnus-summary-limit-to-subject (subject &optional header)
10769 "Limit the summary buffer to articles that have subjects that match a regexp."
10770 (interactive "sRegexp: ")
10771 (unless header
10772 (setq header "subject"))
10773 (when (not (equal "" subject))
10774 (prog1
10775 (let ((articles (gnus-summary-find-matching
10776 (or header "subject") subject 'all)))
10777 (or articles (error "Found no matches for \"%s\"" subject))
10778 (gnus-summary-limit articles))
10779 (gnus-summary-position-point))))
10781 (defun gnus-summary-limit-to-author (from)
10782 "Limit the summary buffer to articles that have authors that match a regexp."
10783 (interactive "sRegexp: ")
10784 (gnus-summary-limit-to-subject from "from"))
10786 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10787 (make-obsolete
10788 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10790 (defun gnus-summary-limit-to-unread (&optional all)
10791 "Limit the summary buffer to articles that are not marked as read.
10792 If ALL is non-nil, limit strictly to unread articles."
10793 (interactive "P")
10794 (if all
10795 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
10796 (gnus-summary-limit-to-marks
10797 ;; Concat all the marks that say that an article is read and have
10798 ;; those removed.
10799 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
10800 gnus-killed-mark gnus-kill-file-mark
10801 gnus-low-score-mark gnus-expirable-mark
10802 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark)
10803 'reverse)))
10805 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10806 (make-obsolete 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10808 (defun gnus-summary-limit-to-marks (marks &optional reverse)
10809 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
10810 If REVERSE, limit the summary buffer to articles that are not marked
10811 with MARKS. MARKS can either be a string of marks or a list of marks.
10812 Returns how many articles were removed."
10813 (interactive "sMarks: ")
10814 (gnus-set-global-variables)
10815 (prog1
10816 (let ((data gnus-newsgroup-data)
10817 (marks (if (listp marks) marks
10818 (append marks nil))) ; Transform to list.
10819 articles)
10820 (while data
10821 (and (if reverse (not (memq (gnus-data-mark (car data)) marks))
10822 (memq (gnus-data-mark (car data)) marks))
10823 (setq articles (cons (gnus-data-number (car data)) articles)))
10824 (setq data (cdr data)))
10825 (gnus-summary-limit articles))
10826 (gnus-summary-position-point)))
10828 (defun gnus-summary-limit-to-score (&optional score)
10829 "Limit to articles with score at or above SCORE."
10830 (interactive "P")
10831 (gnus-set-global-variables)
10832 (setq score (if score
10833 (prefix-numeric-value score)
10834 (or gnus-summary-default-score 0)))
10835 (let ((data gnus-newsgroup-data)
10836 articles)
10837 (while data
10838 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
10839 score)
10840 (push (gnus-data-number (car data)) articles))
10841 (setq data (cdr data)))
10842 (prog1
10843 (gnus-summary-limit articles)
10844 (gnus-summary-position-point))))
10846 (defun gnus-summary-limit-include-dormant ()
10847 "Display all the hidden articles that are marked as dormant."
10848 (interactive)
10849 (gnus-set-global-variables)
10850 (or gnus-newsgroup-dormant
10851 (error "There are no dormant articles in this group"))
10852 (prog1
10853 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
10854 (gnus-summary-position-point)))
10856 (defun gnus-summary-limit-exclude-dormant ()
10857 "Hide all dormant articles."
10858 (interactive)
10859 (gnus-set-global-variables)
10860 (prog1
10861 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
10862 (gnus-summary-position-point)))
10864 (defun gnus-summary-limit-exclude-childless-dormant ()
10865 "Hide all dormant articles that have no children."
10866 (interactive)
10867 (gnus-set-global-variables)
10868 (let ((data (gnus-data-list t))
10869 articles d children)
10870 ;; Find all articles that are either not dormant or have
10871 ;; children.
10872 (while (setq d (pop data))
10873 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
10874 (and (setq children
10875 (gnus-article-children (gnus-data-number d)))
10876 (let (found)
10877 (while children
10878 (when (memq (car children) articles)
10879 (setq children nil
10880 found t))
10881 (pop children))
10882 found)))
10883 (push (gnus-data-number d) articles)))
10884 ;; Do the limiting.
10885 (prog1
10886 (gnus-summary-limit articles)
10887 (gnus-summary-position-point))))
10889 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
10890 "Mark all unread excluded articles as read.
10891 If ALL, mark even excluded ticked and dormants as read."
10892 (interactive "P")
10893 (let ((articles (gnus-sorted-complement
10894 (sort
10895 (mapcar (lambda (h) (mail-header-number h))
10896 gnus-newsgroup-headers)
10898 (sort gnus-newsgroup-limit '<)))
10899 article)
10900 (setq gnus-newsgroup-unreads nil)
10901 (if all
10902 (setq gnus-newsgroup-dormant nil
10903 gnus-newsgroup-marked nil
10904 gnus-newsgroup-reads
10905 (nconc
10906 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
10907 gnus-newsgroup-reads))
10908 (while (setq article (pop articles))
10909 (unless (or (memq article gnus-newsgroup-dormant)
10910 (memq article gnus-newsgroup-marked))
10911 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
10913 (defun gnus-summary-limit (articles &optional pop)
10914 (if pop
10915 ;; We pop the previous limit off the stack and use that.
10916 (setq articles (car gnus-newsgroup-limits)
10917 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
10918 ;; We use the new limit, so we push the old limit on the stack.
10919 (setq gnus-newsgroup-limits
10920 (cons gnus-newsgroup-limit gnus-newsgroup-limits)))
10921 ;; Set the limit.
10922 (setq gnus-newsgroup-limit articles)
10923 (let ((total (length gnus-newsgroup-data))
10924 (data (gnus-data-find-list (gnus-summary-article-number)))
10925 (gnus-summary-mark-below nil) ; Inhibit this.
10926 found)
10927 ;; This will do all the work of generating the new summary buffer
10928 ;; according to the new limit.
10929 (gnus-summary-prepare)
10930 ;; Hide any threads, possibly.
10931 (and gnus-show-threads
10932 gnus-thread-hide-subtree
10933 (gnus-summary-hide-all-threads))
10934 ;; Try to return to the article you were at, or one in the
10935 ;; neighborhood.
10936 (if data
10937 ;; We try to find some article after the current one.
10938 (while data
10939 (and (gnus-summary-goto-subject
10940 (gnus-data-number (car data)) nil t)
10941 (setq data nil
10942 found t))
10943 (setq data (cdr data))))
10944 (or found
10945 ;; If there is no data, that means that we were after the last
10946 ;; article. The same goes when we can't find any articles
10947 ;; after the current one.
10948 (progn
10949 (goto-char (point-max))
10950 (gnus-summary-find-prev)))
10951 ;; We return how many articles were removed from the summary
10952 ;; buffer as a result of the new limit.
10953 (- total (length gnus-newsgroup-data))))
10955 (defsubst gnus-invisible-cut-children (threads)
10956 (let ((num 0))
10957 (while threads
10958 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
10959 (incf num))
10960 (pop threads))
10961 (< num 2)))
10963 (defsubst gnus-cut-thread (thread)
10964 "Go forwards in the thread until we find an article that we want to display."
10965 (when (or (eq gnus-fetch-old-headers 'some)
10966 (eq gnus-build-sparse-threads 'some)
10967 (eq gnus-build-sparse-threads 'more))
10968 ;; Deal with old-fetched headers and sparse threads.
10969 (while (and
10970 thread
10972 (memq (mail-header-number (car thread)) gnus-newsgroup-sparse)
10973 (memq (mail-header-number (car thread)) gnus-newsgroup-ancient))
10974 (or (<= (length (cdr thread)) 1)
10975 (gnus-invisible-cut-children (cdr thread))))
10976 (setq thread (cadr thread))))
10977 thread)
10979 (defun gnus-cut-threads (threads)
10980 "Cut off all uninteresting articles from the beginning of threads."
10981 (when (or (eq gnus-fetch-old-headers 'some)
10982 (eq gnus-build-sparse-threads 'some)
10983 (eq gnus-build-sparse-threads 'more))
10984 (let ((th threads))
10985 (while th
10986 (setcar th (gnus-cut-thread (car th)))
10987 (setq th (cdr th)))))
10988 ;; Remove nixed out threads.
10989 (delq nil threads))
10991 (defun gnus-summary-initial-limit (&optional show-if-empty)
10992 "Figure out what the initial limit is supposed to be on group entry.
10993 This entails weeding out unwanted dormants, low-scored articles,
10994 fetch-old-headers verbiage, and so on."
10995 ;; Most groups have nothing to remove.
10996 (if (or gnus-inhibit-limiting
10997 (and (null gnus-newsgroup-dormant)
10998 (not (eq gnus-fetch-old-headers 'some))
10999 (null gnus-summary-expunge-below)
11000 (not (eq gnus-build-sparse-threads 'some))
11001 (not (eq gnus-build-sparse-threads 'more))
11002 (null gnus-thread-expunge-below)
11003 (not gnus-use-nocem)))
11004 () ; Do nothing.
11005 (push gnus-newsgroup-limit gnus-newsgroup-limits)
11006 (setq gnus-newsgroup-limit nil)
11007 (mapatoms
11008 (lambda (node)
11009 (unless (car (symbol-value node))
11010 ;; These threads have no parents -- they are roots.
11011 (let ((nodes (cdr (symbol-value node)))
11012 thread)
11013 (while nodes
11014 (if (and gnus-thread-expunge-below
11015 (< (gnus-thread-total-score (car nodes))
11016 gnus-thread-expunge-below))
11017 (gnus-expunge-thread (pop nodes))
11018 (setq thread (pop nodes))
11019 (gnus-summary-limit-children thread))))))
11020 gnus-newsgroup-dependencies)
11021 ;; If this limitation resulted in an empty group, we might
11022 ;; pop the previous limit and use it instead.
11023 (when (and (not gnus-newsgroup-limit)
11024 show-if-empty)
11025 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
11026 gnus-newsgroup-limit))
11028 (defun gnus-summary-limit-children (thread)
11029 "Return 1 if this subthread is visible and 0 if it is not."
11030 ;; First we get the number of visible children to this thread. This
11031 ;; is done by recursing down the thread using this function, so this
11032 ;; will really go down to a leaf article first, before slowly
11033 ;; working its way up towards the root.
11034 (when thread
11035 (let ((children
11036 (if (cdr thread)
11037 (apply '+ (mapcar 'gnus-summary-limit-children
11038 (cdr thread)))
11040 (number (mail-header-number (car thread)))
11041 score)
11042 (if (or
11043 ;; If this article is dormant and has absolutely no visible
11044 ;; children, then this article isn't visible.
11045 (and (memq number gnus-newsgroup-dormant)
11046 (= children 0))
11047 ;; If this is "fetch-old-headered" and there is only one
11048 ;; visible child (or less), then we don't want this article.
11049 (and (eq gnus-fetch-old-headers 'some)
11050 (memq number gnus-newsgroup-ancient)
11051 (zerop children))
11052 ;; If this is a sparsely inserted article with no children,
11053 ;; we don't want it.
11054 (and (eq gnus-build-sparse-threads 'some)
11055 (memq number gnus-newsgroup-sparse)
11056 (zerop children))
11057 ;; If we use expunging, and this article is really
11058 ;; low-scored, then we don't want this article.
11059 (when (and gnus-summary-expunge-below
11060 (< (setq score
11061 (or (cdr (assq number gnus-newsgroup-scored))
11062 gnus-summary-default-score))
11063 gnus-summary-expunge-below))
11064 ;; We increase the expunge-tally here, but that has
11065 ;; nothing to do with the limits, really.
11066 (incf gnus-newsgroup-expunged-tally)
11067 ;; We also mark as read here, if that's wanted.
11068 (when (and gnus-summary-mark-below
11069 (< score gnus-summary-mark-below))
11070 (setq gnus-newsgroup-unreads
11071 (delq number gnus-newsgroup-unreads))
11072 (if gnus-newsgroup-auto-expire
11073 (push number gnus-newsgroup-expirable)
11074 (push (cons number gnus-low-score-mark)
11075 gnus-newsgroup-reads)))
11077 (and gnus-use-nocem
11078 (gnus-nocem-unwanted-article-p (mail-header-id (car thread)))))
11079 ;; Nope, invisible article.
11081 ;; Ok, this article is to be visible, so we add it to the limit
11082 ;; and return 1.
11083 (setq gnus-newsgroup-limit (cons number gnus-newsgroup-limit))
11084 1))))
11086 (defun gnus-expunge-thread (thread)
11087 "Mark all articles in THREAD as read."
11088 (let* ((number (mail-header-number (car thread))))
11089 (incf gnus-newsgroup-expunged-tally)
11090 ;; We also mark as read here, if that's wanted.
11091 (setq gnus-newsgroup-unreads
11092 (delq number gnus-newsgroup-unreads))
11093 (if gnus-newsgroup-auto-expire
11094 (push number gnus-newsgroup-expirable)
11095 (push (cons number gnus-low-score-mark)
11096 gnus-newsgroup-reads)))
11097 ;; Go recursively through all subthreads.
11098 (mapcar 'gnus-expunge-thread (cdr thread)))
11100 ;; Summary article oriented commands
11102 (defun gnus-summary-refer-parent-article (n)
11103 "Refer parent article N times.
11104 The difference between N and the number of articles fetched is returned."
11105 (interactive "p")
11106 (gnus-set-global-variables)
11107 (while
11108 (and
11109 (> n 0)
11110 (let* ((header (gnus-summary-article-header))
11111 (ref
11112 ;; If we try to find the parent of the currently
11113 ;; displayed article, then we take a look at the actual
11114 ;; References header, since this is slightly more
11115 ;; reliable than the References field we got from the
11116 ;; server.
11117 (if (and (eq (mail-header-number header)
11118 (cdr gnus-article-current))
11119 (equal gnus-newsgroup-name
11120 (car gnus-article-current)))
11121 (save-excursion
11122 (set-buffer gnus-original-article-buffer)
11123 (nnheader-narrow-to-headers)
11124 (prog1
11125 (message-fetch-field "references")
11126 (widen)))
11127 ;; It's not the current article, so we take a bet on
11128 ;; the value we got from the server.
11129 (mail-header-references header))))
11130 (if (setq ref (or ref (mail-header-references header)))
11131 (or (gnus-summary-refer-article (gnus-parent-id ref))
11132 (gnus-message 1 "Couldn't find parent"))
11133 (gnus-message 1 "No references in article %d"
11134 (gnus-summary-article-number))
11135 nil)))
11136 (setq n (1- n)))
11137 (gnus-summary-position-point)
11140 (defun gnus-summary-refer-references ()
11141 "Fetch all articles mentioned in the References header.
11142 Return how many articles were fetched."
11143 (interactive)
11144 (gnus-set-global-variables)
11145 (let ((ref (mail-header-references (gnus-summary-article-header)))
11146 (current (gnus-summary-article-number))
11147 (n 0))
11148 ;; For each Message-ID in the References header...
11149 (while (string-match "<[^>]*>" ref)
11150 (incf n)
11151 ;; ... fetch that article.
11152 (gnus-summary-refer-article
11153 (prog1 (match-string 0 ref)
11154 (setq ref (substring ref (match-end 0))))))
11155 (gnus-summary-goto-subject current)
11156 (gnus-summary-position-point)
11159 (defun gnus-summary-refer-article (message-id)
11160 "Fetch an article specified by MESSAGE-ID."
11161 (interactive "sMessage-ID: ")
11162 (when (and (stringp message-id)
11163 (not (zerop (length message-id))))
11164 ;; Construct the correct Message-ID if necessary.
11165 ;; Suggested by tale@pawl.rpi.edu.
11166 (unless (string-match "^<" message-id)
11167 (setq message-id (concat "<" message-id)))
11168 (unless (string-match ">$" message-id)
11169 (setq message-id (concat message-id ">")))
11170 (let* ((header (gnus-id-to-header message-id))
11171 (sparse (and header
11172 (memq (mail-header-number header)
11173 gnus-newsgroup-sparse))))
11174 (if header
11175 (prog1
11176 ;; The article is present in the buffer, to we just go to it.
11177 (gnus-summary-goto-article
11178 (mail-header-number header) nil header)
11179 (when sparse
11180 (gnus-summary-update-article (mail-header-number header))))
11181 ;; We fetch the article
11182 (let ((gnus-override-method
11183 (and (gnus-news-group-p gnus-newsgroup-name)
11184 gnus-refer-article-method))
11185 number)
11186 ;; Start the special refer-article method, if necessary.
11187 (when (and gnus-refer-article-method
11188 (gnus-news-group-p gnus-newsgroup-name))
11189 (gnus-check-server gnus-refer-article-method))
11190 ;; Fetch the header, and display the article.
11191 (if (setq number (gnus-summary-insert-subject message-id))
11192 (gnus-summary-select-article nil nil nil number)
11193 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
11195 (defun gnus-summary-enter-digest-group (&optional force)
11196 "Enter a digest group based on the current article."
11197 (interactive "P")
11198 (gnus-set-global-variables)
11199 (gnus-summary-select-article)
11200 (let ((name (format "%s-%d"
11201 (gnus-group-prefixed-name
11202 gnus-newsgroup-name (list 'nndoc ""))
11203 gnus-current-article))
11204 (ogroup gnus-newsgroup-name)
11205 (case-fold-search t)
11206 (buf (current-buffer))
11207 dig)
11208 (save-excursion
11209 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
11210 (insert-buffer-substring gnus-original-article-buffer)
11211 (narrow-to-region
11212 (goto-char (point-min))
11213 (or (search-forward "\n\n" nil t) (point)))
11214 (goto-char (point-min))
11215 (delete-matching-lines "^\\(Path\\):\\|^From ")
11216 (widen))
11217 (unwind-protect
11218 (if (gnus-group-read-ephemeral-group
11219 name `(nndoc ,name (nndoc-address
11220 ,(get-buffer dig))
11221 (nndoc-article-type ,(if force 'digest 'guess))) t)
11222 ;; Make all postings to this group go to the parent group.
11223 (nconc (gnus-info-params (gnus-get-info name))
11224 (list (cons 'to-group ogroup)))
11225 ;; Couldn't select this doc group.
11226 (switch-to-buffer buf)
11227 (gnus-set-global-variables)
11228 (gnus-configure-windows 'summary)
11229 (gnus-message 3 "Article couldn't be entered?"))
11230 (kill-buffer dig))))
11232 (defun gnus-summary-isearch-article (&optional regexp-p)
11233 "Do incremental search forward on the current article.
11234 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
11235 (interactive "P")
11236 (gnus-set-global-variables)
11237 (gnus-summary-select-article)
11238 (gnus-configure-windows 'article)
11239 (gnus-eval-in-buffer-window gnus-article-buffer
11240 (goto-char (point-min))
11241 (isearch-forward regexp-p)))
11243 (defun gnus-summary-search-article-forward (regexp &optional backward)
11244 "Search for an article containing REGEXP forward.
11245 If BACKWARD, search backward instead."
11246 (interactive
11247 (list (read-string
11248 (format "Search article %s (regexp%s): "
11249 (if current-prefix-arg "backward" "forward")
11250 (if gnus-last-search-regexp
11251 (concat ", default " gnus-last-search-regexp)
11252 "")))
11253 current-prefix-arg))
11254 (gnus-set-global-variables)
11255 (if (string-equal regexp "")
11256 (setq regexp (or gnus-last-search-regexp ""))
11257 (setq gnus-last-search-regexp regexp))
11258 (unless (gnus-summary-search-article regexp backward)
11259 (error "Search failed: \"%s\"" regexp)))
11261 (defun gnus-summary-search-article-backward (regexp)
11262 "Search for an article containing REGEXP backward."
11263 (interactive
11264 (list (read-string
11265 (format "Search article backward (regexp%s): "
11266 (if gnus-last-search-regexp
11267 (concat ", default " gnus-last-search-regexp)
11268 "")))))
11269 (gnus-summary-search-article-forward regexp 'backward))
11271 (defun gnus-summary-search-article (regexp &optional backward)
11272 "Search for an article containing REGEXP.
11273 Optional argument BACKWARD means do search for backward.
11274 `gnus-select-article-hook' is not called during the search."
11275 (let ((gnus-select-article-hook nil) ;Disable hook.
11276 (gnus-article-display-hook nil)
11277 (gnus-mark-article-hook nil) ;Inhibit marking as read.
11278 (re-search
11279 (if backward
11280 're-search-backward 're-search-forward))
11281 (sum (current-buffer))
11282 (found nil))
11283 (gnus-save-hidden-threads
11284 (gnus-summary-select-article)
11285 (set-buffer gnus-article-buffer)
11286 (when backward
11287 (forward-line -1))
11288 (while (not found)
11289 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
11290 (if (if backward
11291 (re-search-backward regexp nil t)
11292 (re-search-forward regexp nil t))
11293 ;; We found the regexp.
11294 (progn
11295 (setq found 'found)
11296 (beginning-of-line)
11297 (set-window-start
11298 (get-buffer-window (current-buffer))
11299 (point))
11300 (forward-line 1)
11301 (set-buffer sum))
11302 ;; We didn't find it, so we go to the next article.
11303 (set-buffer sum)
11304 (if (not (if backward (gnus-summary-find-prev)
11305 (gnus-summary-find-next)))
11306 ;; No more articles.
11307 (setq found t)
11308 ;; Select the next article and adjust point.
11309 (gnus-summary-select-article)
11310 (set-buffer gnus-article-buffer)
11311 (widen)
11312 (goto-char (if backward (point-max) (point-min))))))
11313 (gnus-message 7 ""))
11314 ;; Return whether we found the regexp.
11315 (when (eq found 'found)
11316 (gnus-summary-show-thread)
11317 (gnus-summary-goto-subject gnus-current-article)
11318 (gnus-summary-position-point)
11319 t)))
11321 (defun gnus-summary-find-matching (header regexp &optional backward unread
11322 not-case-fold)
11323 "Return a list of all articles that match REGEXP on HEADER.
11324 The search stars on the current article and goes forwards unless
11325 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
11326 If UNREAD is non-nil, only unread articles will
11327 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
11328 in the comparisons."
11329 (let ((data (if (eq backward 'all) gnus-newsgroup-data
11330 (gnus-data-find-list
11331 (gnus-summary-article-number) (gnus-data-list backward))))
11332 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
11333 (case-fold-search (not not-case-fold))
11334 articles d)
11335 (or (fboundp (intern (concat "mail-header-" header)))
11336 (error "%s is not a valid header" header))
11337 (while data
11338 (setq d (car data))
11339 (and (or (not unread) ; We want all articles...
11340 (gnus-data-unread-p d)) ; Or just unreads.
11341 (vectorp (gnus-data-header d)) ; It's not a pseudo.
11342 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
11343 (setq articles (cons (gnus-data-number d) articles))) ; Success!
11344 (setq data (cdr data)))
11345 (nreverse articles)))
11347 (defun gnus-summary-execute-command (header regexp command &optional backward)
11348 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
11349 If HEADER is an empty string (or nil), the match is done on the entire
11350 article. If BACKWARD (the prefix) is non-nil, search backward instead."
11351 (interactive
11352 (list (let ((completion-ignore-case t))
11353 (completing-read
11354 "Header name: "
11355 (mapcar (lambda (string) (list string))
11356 '("Number" "Subject" "From" "Lines" "Date"
11357 "Message-ID" "Xref" "References" "Body"))
11358 nil 'require-match))
11359 (read-string "Regexp: ")
11360 (read-key-sequence "Command: ")
11361 current-prefix-arg))
11362 (when (equal header "Body")
11363 (setq header ""))
11364 (gnus-set-global-variables)
11365 ;; Hidden thread subtrees must be searched as well.
11366 (gnus-summary-show-all-threads)
11367 ;; We don't want to change current point nor window configuration.
11368 (save-excursion
11369 (save-window-excursion
11370 (gnus-message 6 "Executing %s..." (key-description command))
11371 ;; We'd like to execute COMMAND interactively so as to give arguments.
11372 (gnus-execute header regexp
11373 `(lambda () (call-interactively ',(key-binding command)))
11374 backward)
11375 (gnus-message 6 "Executing %s...done" (key-description command)))))
11377 (defun gnus-summary-beginning-of-article ()
11378 "Scroll the article back to the beginning."
11379 (interactive)
11380 (gnus-set-global-variables)
11381 (gnus-summary-select-article)
11382 (gnus-configure-windows 'article)
11383 (gnus-eval-in-buffer-window gnus-article-buffer
11384 (widen)
11385 (goto-char (point-min))
11386 (and gnus-break-pages (gnus-narrow-to-page))))
11388 (defun gnus-summary-end-of-article ()
11389 "Scroll to the end of the article."
11390 (interactive)
11391 (gnus-set-global-variables)
11392 (gnus-summary-select-article)
11393 (gnus-configure-windows 'article)
11394 (gnus-eval-in-buffer-window gnus-article-buffer
11395 (widen)
11396 (goto-char (point-max))
11397 (recenter -3)
11398 (and gnus-break-pages (gnus-narrow-to-page))))
11400 (defun gnus-summary-show-article (&optional arg)
11401 "Force re-fetching of the current article.
11402 If ARG (the prefix) is non-nil, show the raw article without any
11403 article massaging functions being run."
11404 (interactive "P")
11405 (gnus-set-global-variables)
11406 (if (not arg)
11407 ;; Select the article the normal way.
11408 (gnus-summary-select-article nil 'force)
11409 ;; Bind the article treatment functions to nil.
11410 (let ((gnus-have-all-headers t)
11411 gnus-article-display-hook
11412 gnus-article-prepare-hook
11413 gnus-break-pages
11414 gnus-visual)
11415 (gnus-summary-select-article nil 'force)))
11416 (gnus-summary-goto-subject gnus-current-article)
11417 ; (gnus-configure-windows 'article)
11418 (gnus-summary-position-point))
11420 (defun gnus-summary-verbose-headers (&optional arg)
11421 "Toggle permanent full header display.
11422 If ARG is a positive number, turn header display on.
11423 If ARG is a negative number, turn header display off."
11424 (interactive "P")
11425 (gnus-set-global-variables)
11426 (gnus-summary-toggle-header arg)
11427 (setq gnus-show-all-headers
11428 (cond ((or (not (numberp arg))
11429 (zerop arg))
11430 (not gnus-show-all-headers))
11431 ((natnump arg)
11432 t))))
11434 (defun gnus-summary-toggle-header (&optional arg)
11435 "Show the headers if they are hidden, or hide them if they are shown.
11436 If ARG is a positive number, show the entire header.
11437 If ARG is a negative number, hide the unwanted header lines."
11438 (interactive "P")
11439 (gnus-set-global-variables)
11440 (save-excursion
11441 (set-buffer gnus-article-buffer)
11442 (let* ((buffer-read-only nil)
11443 (inhibit-point-motion-hooks t)
11444 (hidden (text-property-any
11445 (goto-char (point-min)) (search-forward "\n\n")
11446 'invisible t))
11448 (goto-char (point-min))
11449 (when (search-forward "\n\n" nil t)
11450 (delete-region (point-min) (1- (point))))
11451 (goto-char (point-min))
11452 (save-excursion
11453 (set-buffer gnus-original-article-buffer)
11454 (goto-char (point-min))
11455 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
11456 (insert-buffer-substring gnus-original-article-buffer 1 e)
11457 (let ((gnus-inhibit-hiding t))
11458 (run-hooks 'gnus-article-display-hook))
11459 (if (or (not hidden) (and (numberp arg) (< arg 0)))
11460 (gnus-article-hide-headers)))))
11462 (defun gnus-summary-show-all-headers ()
11463 "Make all header lines visible."
11464 (interactive)
11465 (gnus-set-global-variables)
11466 (gnus-article-show-all-headers))
11468 (defun gnus-summary-toggle-mime (&optional arg)
11469 "Toggle MIME processing.
11470 If ARG is a positive number, turn MIME processing on."
11471 (interactive "P")
11472 (gnus-set-global-variables)
11473 (setq gnus-show-mime
11474 (if (null arg) (not gnus-show-mime)
11475 (> (prefix-numeric-value arg) 0)))
11476 (gnus-summary-select-article t 'force))
11478 (defun gnus-summary-caesar-message (&optional arg)
11479 "Caesar rotate the current article by 13.
11480 The numerical prefix specifies how manu places to rotate each letter
11481 forward."
11482 (interactive "P")
11483 (gnus-set-global-variables)
11484 (gnus-summary-select-article)
11485 (let ((mail-header-separator ""))
11486 (gnus-eval-in-buffer-window gnus-article-buffer
11487 (save-restriction
11488 (widen)
11489 (let ((start (window-start))
11490 buffer-read-only)
11491 (message-caesar-buffer-body arg)
11492 (set-window-start (get-buffer-window (current-buffer)) start))))))
11494 (defun gnus-summary-stop-page-breaking ()
11495 "Stop page breaking in the current article."
11496 (interactive)
11497 (gnus-set-global-variables)
11498 (gnus-summary-select-article)
11499 (gnus-eval-in-buffer-window gnus-article-buffer
11500 (widen)))
11502 (defun gnus-summary-move-article (&optional n to-newsgroup select-method action)
11503 "Move the current article to a different newsgroup.
11504 If N is a positive number, move the N next articles.
11505 If N is a negative number, move the N previous articles.
11506 If N is nil and any articles have been marked with the process mark,
11507 move those articles instead.
11508 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11509 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
11510 re-spool using this method.
11512 For this function to work, both the current newsgroup and the
11513 newsgroup that you want to move to have to support the `request-move'
11514 and `request-accept' functions."
11515 (interactive "P")
11516 (unless action (setq action 'move))
11517 (gnus-set-global-variables)
11518 ;; Check whether the source group supports the required functions.
11519 (cond ((and (eq action 'move)
11520 (not (gnus-check-backend-function
11521 'request-move-article gnus-newsgroup-name)))
11522 (error "The current group does not support article moving"))
11523 ((and (eq action 'crosspost)
11524 (not (gnus-check-backend-function
11525 'request-replace-article gnus-newsgroup-name)))
11526 (error "The current group does not support article editing")))
11527 (let ((articles (gnus-summary-work-articles n))
11528 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
11529 (names '((move "Move" "Moving")
11530 (copy "Copy" "Copying")
11531 (crosspost "Crosspost" "Crossposting")))
11532 (copy-buf (save-excursion
11533 (nnheader-set-temp-buffer " *copy article*")))
11534 art-group to-method new-xref article to-groups)
11535 (unless (assq action names)
11536 (error "Unknown action %s" action))
11537 ;; Read the newsgroup name.
11538 (when (and (not to-newsgroup)
11539 (not select-method))
11540 (setq to-newsgroup
11541 (gnus-read-move-group-name
11542 (cadr (assq action names))
11543 (symbol-value (intern (format "gnus-current-%s-group" action)))
11544 articles prefix))
11545 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
11546 (setq to-method (or select-method
11547 (gnus-group-name-to-method to-newsgroup)))
11548 ;; Check the method we are to move this article to...
11549 (or (gnus-check-backend-function 'request-accept-article (car to-method))
11550 (error "%s does not support article copying" (car to-method)))
11551 (or (gnus-check-server to-method)
11552 (error "Can't open server %s" (car to-method)))
11553 (gnus-message 6 "%s to %s: %s..."
11554 (caddr (assq action names))
11555 (or (car select-method) to-newsgroup) articles)
11556 (while articles
11557 (setq article (pop articles))
11558 (setq
11559 art-group
11560 (cond
11561 ;; Move the article.
11562 ((eq action 'move)
11563 (gnus-request-move-article
11564 article ; Article to move
11565 gnus-newsgroup-name ; From newsgrouo
11566 (nth 1 (gnus-find-method-for-group
11567 gnus-newsgroup-name)) ; Server
11568 (list 'gnus-request-accept-article
11569 to-newsgroup (list 'quote select-method)
11570 (not articles)) ; Accept form
11571 (not articles))) ; Only save nov last time
11572 ;; Copy the article.
11573 ((eq action 'copy)
11574 (save-excursion
11575 (set-buffer copy-buf)
11576 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11577 (gnus-request-accept-article
11578 to-newsgroup select-method (not articles))))
11579 ;; Crosspost the article.
11580 ((eq action 'crosspost)
11581 (let ((xref (mail-header-xref (gnus-summary-article-header article))))
11582 (setq new-xref (concat gnus-newsgroup-name ":" article))
11583 (if (and xref (not (string= xref "")))
11584 (progn
11585 (when (string-match "^Xref: " xref)
11586 (setq xref (substring xref (match-end 0))))
11587 (setq new-xref (concat xref " " new-xref)))
11588 (setq new-xref (concat (system-name) " " new-xref)))
11589 (save-excursion
11590 (set-buffer copy-buf)
11591 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11592 (nnheader-replace-header "xref" new-xref)
11593 (gnus-request-accept-article
11594 to-newsgroup select-method (not articles)))))))
11595 (if (not art-group)
11596 (gnus-message 1 "Couldn't %s article %s"
11597 (cadr (assq action names)) article)
11598 (let* ((entry
11600 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
11601 (gnus-gethash
11602 (gnus-group-prefixed-name
11603 (car art-group)
11604 (or select-method
11605 (gnus-find-method-for-group to-newsgroup)))
11606 gnus-newsrc-hashtb)))
11607 (info (nth 2 entry))
11608 (to-group (gnus-info-group info)))
11609 ;; Update the group that has been moved to.
11610 (when (and info
11611 (memq action '(move copy)))
11612 (unless (member to-group to-groups)
11613 (push to-group to-groups))
11615 (unless (memq article gnus-newsgroup-unreads)
11616 (gnus-info-set-read
11617 info (gnus-add-to-range (gnus-info-read info)
11618 (list (cdr art-group)))))
11620 ;; Copy any marks over to the new group.
11621 (let ((marks gnus-article-mark-lists)
11622 (to-article (cdr art-group)))
11624 ;; See whether the article is to be put in the cache.
11625 (when gnus-use-cache
11626 (gnus-cache-possibly-enter-article
11627 to-group to-article
11628 (let ((header (copy-sequence
11629 (gnus-summary-article-header article))))
11630 (mail-header-set-number header to-article)
11631 header)
11632 (memq article gnus-newsgroup-marked)
11633 (memq article gnus-newsgroup-dormant)
11634 (memq article gnus-newsgroup-unreads)))
11636 (while marks
11637 (when (memq article (symbol-value
11638 (intern (format "gnus-newsgroup-%s"
11639 (caar marks)))))
11640 ;; If the other group is the same as this group,
11641 ;; then we have to add the mark to the list.
11642 (when (equal to-group gnus-newsgroup-name)
11643 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
11644 (cons to-article
11645 (symbol-value
11646 (intern (format "gnus-newsgroup-%s"
11647 (caar marks)))))))
11648 ;; Copy mark to other group.
11649 (gnus-add-marked-articles
11650 to-group (cdar marks) (list to-article) info))
11651 (setq marks (cdr marks)))))
11653 ;; Update the Xref header in this article to point to
11654 ;; the new crossposted article we have just created.
11655 (when (eq action 'crosspost)
11656 (save-excursion
11657 (set-buffer copy-buf)
11658 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11659 (nnheader-replace-header
11660 "xref" (concat new-xref " " (gnus-group-prefixed-name
11661 (car art-group) to-method)
11662 ":" (cdr art-group)))
11663 (gnus-request-replace-article
11664 article gnus-newsgroup-name (current-buffer)))))
11666 (gnus-summary-goto-subject article)
11667 (when (eq action 'move)
11668 (gnus-summary-mark-article article gnus-canceled-mark)))
11669 (gnus-summary-remove-process-mark article))
11670 ;; Re-activate all groups that have been moved to.
11671 (while to-groups
11672 (gnus-activate-group (pop to-groups)))
11674 (gnus-kill-buffer copy-buf)
11675 (gnus-summary-position-point)
11676 (gnus-set-mode-line 'summary)))
11678 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
11679 "Move the current article to a different newsgroup.
11680 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11681 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
11682 re-spool using this method."
11683 (interactive "P")
11684 (gnus-summary-move-article n nil select-method 'copy))
11686 (defun gnus-summary-crosspost-article (&optional n)
11687 "Crosspost the current article to some other group."
11688 (interactive "P")
11689 (gnus-summary-move-article n nil nil 'crosspost))
11691 (defvar gnus-summary-respool-default-method nil
11692 "Default method for respooling an article.
11693 If nil, use to the current newsgroup method.")
11695 (defun gnus-summary-respool-article (&optional n method)
11696 "Respool the current article.
11697 The article will be squeezed through the mail spooling process again,
11698 which means that it will be put in some mail newsgroup or other
11699 depending on `nnmail-split-methods'.
11700 If N is a positive number, respool the N next articles.
11701 If N is a negative number, respool the N previous articles.
11702 If N is nil and any articles have been marked with the process mark,
11703 respool those articles instead.
11705 Respooling can be done both from mail groups and \"real\" newsgroups.
11706 In the former case, the articles in question will be moved from the
11707 current group into whatever groups they are destined to. In the
11708 latter case, they will be copied into the relevant groups."
11709 (interactive
11710 (list current-prefix-arg
11711 (let* ((methods (gnus-methods-using 'respool))
11712 (methname
11713 (symbol-name (or gnus-summary-respool-default-method
11714 (car (gnus-find-method-for-group
11715 gnus-newsgroup-name)))))
11716 (method
11717 (gnus-completing-read
11718 methname "What backend do you want to use when respooling?"
11719 methods nil t nil 'gnus-method-history))
11721 (cond
11722 ((zerop (length (setq ms (gnus-servers-using-backend method))))
11723 (list (intern method) ""))
11724 ((= 1 (length ms))
11725 (car ms))
11727 (cdr (completing-read
11728 "Server name: "
11729 (mapcar (lambda (m) (cons (cadr m) m)) ms) nil t)))))))
11730 (gnus-set-global-variables)
11731 (unless method
11732 (error "No method given for respooling"))
11733 (if (assoc (symbol-name
11734 (car (gnus-find-method-for-group gnus-newsgroup-name)))
11735 (gnus-methods-using 'respool))
11736 (gnus-summary-move-article n nil method)
11737 (gnus-summary-copy-article n nil method)))
11739 (defun gnus-summary-import-article (file)
11740 "Import a random file into a mail newsgroup."
11741 (interactive "fImport file: ")
11742 (gnus-set-global-variables)
11743 (let ((group gnus-newsgroup-name)
11744 (now (current-time))
11745 atts lines)
11746 (or (gnus-check-backend-function 'request-accept-article group)
11747 (error "%s does not support article importing" group))
11748 (or (file-readable-p file)
11749 (not (file-regular-p file))
11750 (error "Can't read %s" file))
11751 (save-excursion
11752 (set-buffer (get-buffer-create " *import file*"))
11753 (buffer-disable-undo (current-buffer))
11754 (erase-buffer)
11755 (insert-file-contents file)
11756 (goto-char (point-min))
11757 (unless (nnheader-article-p)
11758 ;; This doesn't look like an article, so we fudge some headers.
11759 (setq atts (file-attributes file)
11760 lines (count-lines (point-min) (point-max)))
11761 (insert "From: " (read-string "From: ") "\n"
11762 "Subject: " (read-string "Subject: ") "\n"
11763 "Date: " (timezone-make-date-arpa-standard
11764 (current-time-string (nth 5 atts))
11765 (current-time-zone now)
11766 (current-time-zone now)) "\n"
11767 "Message-ID: " (message-make-message-id) "\n"
11768 "Lines: " (int-to-string lines) "\n"
11769 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
11770 (gnus-request-accept-article group nil t)
11771 (kill-buffer (current-buffer)))))
11773 (defun gnus-summary-expire-articles (&optional now)
11774 "Expire all articles that are marked as expirable in the current group."
11775 (interactive)
11776 (gnus-set-global-variables)
11777 (when (gnus-check-backend-function
11778 'request-expire-articles gnus-newsgroup-name)
11779 ;; This backend supports expiry.
11780 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
11781 (expirable (if total
11782 (gnus-list-of-read-articles gnus-newsgroup-name)
11783 (setq gnus-newsgroup-expirable
11784 (sort gnus-newsgroup-expirable '<))))
11785 (expiry-wait (if now 'immediate
11786 (gnus-group-get-parameter
11787 gnus-newsgroup-name 'expiry-wait)))
11789 (when expirable
11790 ;; There are expirable articles in this group, so we run them
11791 ;; through the expiry process.
11792 (gnus-message 6 "Expiring articles...")
11793 ;; The list of articles that weren't expired is returned.
11794 (if expiry-wait
11795 (let ((nnmail-expiry-wait-function nil)
11796 (nnmail-expiry-wait expiry-wait))
11797 (setq es (gnus-request-expire-articles
11798 expirable gnus-newsgroup-name)))
11799 (setq es (gnus-request-expire-articles
11800 expirable gnus-newsgroup-name)))
11801 (or total (setq gnus-newsgroup-expirable es))
11802 ;; We go through the old list of expirable, and mark all
11803 ;; really expired articles as nonexistent.
11804 (unless (eq es expirable) ;If nothing was expired, we don't mark.
11805 (let ((gnus-use-cache nil))
11806 (while expirable
11807 (unless (memq (car expirable) es)
11808 (when (gnus-data-find (car expirable))
11809 (gnus-summary-mark-article
11810 (car expirable) gnus-canceled-mark)))
11811 (setq expirable (cdr expirable)))))
11812 (gnus-message 6 "Expiring articles...done")))))
11814 (defun gnus-summary-expire-articles-now ()
11815 "Expunge all expirable articles in the current group.
11816 This means that *all* articles that are marked as expirable will be
11817 deleted forever, right now."
11818 (interactive)
11819 (gnus-set-global-variables)
11820 (or gnus-expert-user
11821 (gnus-y-or-n-p
11822 "Are you really, really, really sure you want to delete all these messages? ")
11823 (error "Phew!"))
11824 (gnus-summary-expire-articles t))
11826 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
11827 (defun gnus-summary-delete-article (&optional n)
11828 "Delete the N next (mail) articles.
11829 This command actually deletes articles. This is not a marking
11830 command. The article will disappear forever from your life, never to
11831 return.
11832 If N is negative, delete backwards.
11833 If N is nil and articles have been marked with the process mark,
11834 delete these instead."
11835 (interactive "P")
11836 (gnus-set-global-variables)
11837 (or (gnus-check-backend-function 'request-expire-articles
11838 gnus-newsgroup-name)
11839 (error "The current newsgroup does not support article deletion."))
11840 ;; Compute the list of articles to delete.
11841 (let ((articles (gnus-summary-work-articles n))
11842 not-deleted)
11843 (if (and gnus-novice-user
11844 (not (gnus-y-or-n-p
11845 (format "Do you really want to delete %s forever? "
11846 (if (> (length articles) 1)
11847 (format "these %s articles" (length articles))
11848 "this article")))))
11850 ;; Delete the articles.
11851 (setq not-deleted (gnus-request-expire-articles
11852 articles gnus-newsgroup-name 'force))
11853 (while articles
11854 (gnus-summary-remove-process-mark (car articles))
11855 ;; The backend might not have been able to delete the article
11856 ;; after all.
11857 (or (memq (car articles) not-deleted)
11858 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
11859 (setq articles (cdr articles))))
11860 (gnus-summary-position-point)
11861 (gnus-set-mode-line 'summary)
11862 not-deleted))
11864 (defun gnus-summary-edit-article (&optional force)
11865 "Enter into a buffer and edit the current article.
11866 This will have permanent effect only in mail groups.
11867 If FORCE is non-nil, allow editing of articles even in read-only
11868 groups."
11869 (interactive "P")
11870 (save-excursion
11871 (set-buffer gnus-summary-buffer)
11872 (gnus-set-global-variables)
11873 (when (and (not force)
11874 (gnus-group-read-only-p))
11875 (error "The current newsgroup does not support article editing."))
11876 (gnus-summary-select-article t nil t)
11877 (gnus-configure-windows 'article)
11878 (select-window (get-buffer-window gnus-article-buffer))
11879 (gnus-message 6 "C-c C-c to end edits")
11880 (setq buffer-read-only nil)
11881 (text-mode)
11882 (use-local-map (copy-keymap (current-local-map)))
11883 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
11884 (buffer-enable-undo)
11885 (widen)
11886 (goto-char (point-min))
11887 (search-forward "\n\n" nil t)))
11889 (defun gnus-summary-edit-article-done ()
11890 "Make edits to the current article permanent."
11891 (interactive)
11892 (if (gnus-group-read-only-p)
11893 (progn
11894 (let ((beep (not (eq major-mode 'text-mode))))
11895 (gnus-summary-edit-article-postpone)
11896 (when beep
11897 (gnus-error
11898 3 "The current newsgroup does not support article editing."))))
11899 (let ((buf (format "%s" (buffer-string))))
11900 (erase-buffer)
11901 (insert buf)
11902 (if (not (gnus-request-replace-article
11903 (cdr gnus-article-current) (car gnus-article-current)
11904 (current-buffer)))
11905 (error "Couldn't replace article.")
11906 (gnus-article-mode)
11907 (use-local-map gnus-article-mode-map)
11908 (setq buffer-read-only t)
11909 (buffer-disable-undo (current-buffer))
11910 (gnus-configure-windows 'summary)
11911 (gnus-summary-update-article (cdr gnus-article-current))
11912 (when gnus-use-cache
11913 (gnus-cache-update-article
11914 (car gnus-article-current) (cdr gnus-article-current)))
11915 (when gnus-keep-backlog
11916 (gnus-backlog-remove-article
11917 (car gnus-article-current) (cdr gnus-article-current))))
11918 (save-excursion
11919 (when (get-buffer gnus-original-article-buffer)
11920 (set-buffer gnus-original-article-buffer)
11921 (setq gnus-original-article nil)))
11922 (setq gnus-article-current nil
11923 gnus-current-article nil)
11924 (run-hooks 'gnus-article-display-hook)
11925 (and (gnus-visual-p 'summary-highlight 'highlight)
11926 (run-hooks 'gnus-visual-mark-article-hook)))))
11928 (defun gnus-summary-edit-article-postpone ()
11929 "Postpone changes to the current article."
11930 (interactive)
11931 (gnus-article-mode)
11932 (use-local-map gnus-article-mode-map)
11933 (setq buffer-read-only t)
11934 (buffer-disable-undo (current-buffer))
11935 (gnus-configure-windows 'summary)
11936 (and (gnus-visual-p 'summary-highlight 'highlight)
11937 (run-hooks 'gnus-visual-mark-article-hook)))
11939 (defun gnus-summary-respool-query ()
11940 "Query where the respool algorithm would put this article."
11941 (interactive)
11942 (gnus-set-global-variables)
11943 (gnus-summary-select-article)
11944 (save-excursion
11945 (set-buffer gnus-article-buffer)
11946 (save-restriction
11947 (goto-char (point-min))
11948 (search-forward "\n\n")
11949 (narrow-to-region (point-min) (point))
11950 (pp-eval-expression
11951 (list 'quote (mapcar 'car (nnmail-article-group 'identity)))))))
11953 ;; Summary marking commands.
11955 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
11956 "Mark articles which has the same subject as read, and then select the next.
11957 If UNMARK is positive, remove any kind of mark.
11958 If UNMARK is negative, tick articles."
11959 (interactive "P")
11960 (gnus-set-global-variables)
11961 (if unmark
11962 (setq unmark (prefix-numeric-value unmark)))
11963 (let ((count
11964 (gnus-summary-mark-same-subject
11965 (gnus-summary-article-subject) unmark)))
11966 ;; Select next unread article. If auto-select-same mode, should
11967 ;; select the first unread article.
11968 (gnus-summary-next-article t (and gnus-auto-select-same
11969 (gnus-summary-article-subject)))
11970 (gnus-message 7 "%d article%s marked as %s"
11971 count (if (= count 1) " is" "s are")
11972 (if unmark "unread" "read"))))
11974 (defun gnus-summary-kill-same-subject (&optional unmark)
11975 "Mark articles which has the same subject as read.
11976 If UNMARK is positive, remove any kind of mark.
11977 If UNMARK is negative, tick articles."
11978 (interactive "P")
11979 (gnus-set-global-variables)
11980 (if unmark
11981 (setq unmark (prefix-numeric-value unmark)))
11982 (let ((count
11983 (gnus-summary-mark-same-subject
11984 (gnus-summary-article-subject) unmark)))
11985 ;; If marked as read, go to next unread subject.
11986 (if (null unmark)
11987 ;; Go to next unread subject.
11988 (gnus-summary-next-subject 1 t))
11989 (gnus-message 7 "%d articles are marked as %s"
11990 count (if unmark "unread" "read"))))
11992 (defun gnus-summary-mark-same-subject (subject &optional unmark)
11993 "Mark articles with same SUBJECT as read, and return marked number.
11994 If optional argument UNMARK is positive, remove any kinds of marks.
11995 If optional argument UNMARK is negative, mark articles as unread instead."
11996 (let ((count 1))
11997 (save-excursion
11998 (cond
11999 ((null unmark) ; Mark as read.
12000 (while (and
12001 (progn
12002 (gnus-summary-mark-article-as-read gnus-killed-mark)
12003 (gnus-summary-show-thread) t)
12004 (gnus-summary-find-subject subject))
12005 (setq count (1+ count))))
12006 ((> unmark 0) ; Tick.
12007 (while (and
12008 (progn
12009 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
12010 (gnus-summary-show-thread) t)
12011 (gnus-summary-find-subject subject))
12012 (setq count (1+ count))))
12013 (t ; Mark as unread.
12014 (while (and
12015 (progn
12016 (gnus-summary-mark-article-as-unread gnus-unread-mark)
12017 (gnus-summary-show-thread) t)
12018 (gnus-summary-find-subject subject))
12019 (setq count (1+ count)))))
12020 (gnus-set-mode-line 'summary)
12021 ;; Return the number of marked articles.
12022 count)))
12024 (defun gnus-summary-mark-as-processable (n &optional unmark)
12025 "Set the process mark on the next N articles.
12026 If N is negative, mark backward instead. If UNMARK is non-nil, remove
12027 the process mark instead. The difference between N and the actual
12028 number of articles marked is returned."
12029 (interactive "p")
12030 (gnus-set-global-variables)
12031 (let ((backward (< n 0))
12032 (n (abs n)))
12033 (while (and
12034 (> n 0)
12035 (if unmark
12036 (gnus-summary-remove-process-mark
12037 (gnus-summary-article-number))
12038 (gnus-summary-set-process-mark (gnus-summary-article-number)))
12039 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
12040 (setq n (1- n)))
12041 (if (/= 0 n) (gnus-message 7 "No more articles"))
12042 (gnus-summary-recenter)
12043 (gnus-summary-position-point)
12046 (defun gnus-summary-unmark-as-processable (n)
12047 "Remove the process mark from the next N articles.
12048 If N is negative, mark backward instead. The difference between N and
12049 the actual number of articles marked is returned."
12050 (interactive "p")
12051 (gnus-set-global-variables)
12052 (gnus-summary-mark-as-processable n t))
12054 (defun gnus-summary-unmark-all-processable ()
12055 "Remove the process mark from all articles."
12056 (interactive)
12057 (gnus-set-global-variables)
12058 (save-excursion
12059 (while gnus-newsgroup-processable
12060 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
12061 (gnus-summary-position-point))
12063 (defun gnus-summary-mark-as-expirable (n)
12064 "Mark N articles forward as expirable.
12065 If N is negative, mark backward instead. The difference between N and
12066 the actual number of articles marked is returned."
12067 (interactive "p")
12068 (gnus-set-global-variables)
12069 (gnus-summary-mark-forward n gnus-expirable-mark))
12071 (defun gnus-summary-mark-article-as-replied (article)
12072 "Mark ARTICLE replied and update the summary line."
12073 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
12074 (let ((buffer-read-only nil))
12075 (when (gnus-summary-goto-subject article)
12076 (gnus-summary-update-secondary-mark article))))
12078 (defun gnus-summary-set-bookmark (article)
12079 "Set a bookmark in current article."
12080 (interactive (list (gnus-summary-article-number)))
12081 (gnus-set-global-variables)
12082 (if (or (not (get-buffer gnus-article-buffer))
12083 (not gnus-current-article)
12084 (not gnus-article-current)
12085 (not (equal gnus-newsgroup-name (car gnus-article-current))))
12086 (error "No current article selected"))
12087 ;; Remove old bookmark, if one exists.
12088 (let ((old (assq article gnus-newsgroup-bookmarks)))
12089 (if old (setq gnus-newsgroup-bookmarks
12090 (delq old gnus-newsgroup-bookmarks))))
12091 ;; Set the new bookmark, which is on the form
12092 ;; (article-number . line-number-in-body).
12093 (setq gnus-newsgroup-bookmarks
12094 (cons
12095 (cons article
12096 (save-excursion
12097 (set-buffer gnus-article-buffer)
12098 (count-lines
12099 (min (point)
12100 (save-excursion
12101 (goto-char (point-min))
12102 (search-forward "\n\n" nil t)
12103 (point)))
12104 (point))))
12105 gnus-newsgroup-bookmarks))
12106 (gnus-message 6 "A bookmark has been added to the current article."))
12108 (defun gnus-summary-remove-bookmark (article)
12109 "Remove the bookmark from the current article."
12110 (interactive (list (gnus-summary-article-number)))
12111 (gnus-set-global-variables)
12112 ;; Remove old bookmark, if one exists.
12113 (let ((old (assq article gnus-newsgroup-bookmarks)))
12114 (if old
12115 (progn
12116 (setq gnus-newsgroup-bookmarks
12117 (delq old gnus-newsgroup-bookmarks))
12118 (gnus-message 6 "Removed bookmark."))
12119 (gnus-message 6 "No bookmark in current article."))))
12121 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
12122 (defun gnus-summary-mark-as-dormant (n)
12123 "Mark N articles forward as dormant.
12124 If N is negative, mark backward instead. The difference between N and
12125 the actual number of articles marked is returned."
12126 (interactive "p")
12127 (gnus-set-global-variables)
12128 (gnus-summary-mark-forward n gnus-dormant-mark))
12130 (defun gnus-summary-set-process-mark (article)
12131 "Set the process mark on ARTICLE and update the summary line."
12132 (setq gnus-newsgroup-processable
12133 (cons article
12134 (delq article gnus-newsgroup-processable)))
12135 (when (gnus-summary-goto-subject article)
12136 (gnus-summary-show-thread)
12137 (gnus-summary-update-secondary-mark article)))
12139 (defun gnus-summary-remove-process-mark (article)
12140 "Remove the process mark from ARTICLE and update the summary line."
12141 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
12142 (when (gnus-summary-goto-subject article)
12143 (gnus-summary-show-thread)
12144 (gnus-summary-update-secondary-mark article)))
12146 (defun gnus-summary-set-saved-mark (article)
12147 "Set the process mark on ARTICLE and update the summary line."
12148 (push article gnus-newsgroup-saved)
12149 (when (gnus-summary-goto-subject article)
12150 (gnus-summary-update-secondary-mark article)))
12152 (defun gnus-summary-mark-forward (n &optional mark no-expire)
12153 "Mark N articles as read forwards.
12154 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
12155 The difference between N and the actual number of articles marked is
12156 returned."
12157 (interactive "p")
12158 (gnus-set-global-variables)
12159 (let ((backward (< n 0))
12160 (gnus-summary-goto-unread
12161 (and gnus-summary-goto-unread
12162 (not (eq gnus-summary-goto-unread 'never))
12163 (not (memq mark (list gnus-unread-mark
12164 gnus-ticked-mark gnus-dormant-mark)))))
12165 (n (abs n))
12166 (mark (or mark gnus-del-mark)))
12167 (while (and (> n 0)
12168 (gnus-summary-mark-article nil mark no-expire)
12169 (zerop (gnus-summary-next-subject
12170 (if backward -1 1)
12171 (and gnus-summary-goto-unread
12172 (not (eq gnus-summary-goto-unread 'never)))
12173 t)))
12174 (setq n (1- n)))
12175 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
12176 (gnus-summary-recenter)
12177 (gnus-summary-position-point)
12178 (gnus-set-mode-line 'summary)
12181 (defun gnus-summary-mark-article-as-read (mark)
12182 "Mark the current article quickly as read with MARK."
12183 (let ((article (gnus-summary-article-number)))
12184 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12185 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12186 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12187 (setq gnus-newsgroup-reads
12188 (cons (cons article mark) gnus-newsgroup-reads))
12189 ;; Possibly remove from cache, if that is used.
12190 (and gnus-use-cache (gnus-cache-enter-remove-article article))
12191 ;; Allow the backend to change the mark.
12192 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
12193 ;; Check for auto-expiry.
12194 (when (and gnus-newsgroup-auto-expire
12195 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
12196 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
12197 (= mark gnus-ancient-mark)
12198 (= mark gnus-read-mark) (= mark gnus-souped-mark)))
12199 (setq mark gnus-expirable-mark)
12200 (push article gnus-newsgroup-expirable))
12201 ;; Set the mark in the buffer.
12202 (gnus-summary-update-mark mark 'unread)
12205 (defun gnus-summary-mark-article-as-unread (mark)
12206 "Mark the current article quickly as unread with MARK."
12207 (let ((article (gnus-summary-article-number)))
12208 (if (< article 0)
12209 (gnus-error 1 "Unmarkable article")
12210 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12211 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12212 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
12213 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
12214 (cond ((= mark gnus-ticked-mark)
12215 (push article gnus-newsgroup-marked))
12216 ((= mark gnus-dormant-mark)
12217 (push article gnus-newsgroup-dormant))
12219 (push article gnus-newsgroup-unreads)))
12220 (setq gnus-newsgroup-reads
12221 (delq (assq article gnus-newsgroup-reads)
12222 gnus-newsgroup-reads))
12224 ;; See whether the article is to be put in the cache.
12225 (and gnus-use-cache
12226 (vectorp (gnus-summary-article-header article))
12227 (save-excursion
12228 (gnus-cache-possibly-enter-article
12229 gnus-newsgroup-name article
12230 (gnus-summary-article-header article)
12231 (= mark gnus-ticked-mark)
12232 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
12234 ;; Fix the mark.
12235 (gnus-summary-update-mark mark 'unread))
12238 (defun gnus-summary-mark-article (&optional article mark no-expire)
12239 "Mark ARTICLE with MARK. MARK can be any character.
12240 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
12241 `??' (dormant) and `?E' (expirable).
12242 If MARK is nil, then the default character `?D' is used.
12243 If ARTICLE is nil, then the article on the current line will be
12244 marked."
12245 ;; The mark might be a string.
12246 (and (stringp mark)
12247 (setq mark (aref mark 0)))
12248 ;; If no mark is given, then we check auto-expiring.
12249 (and (not no-expire)
12250 gnus-newsgroup-auto-expire
12251 (or (not mark)
12252 (and (numberp mark)
12253 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
12254 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
12255 (= mark gnus-read-mark) (= mark gnus-souped-mark))))
12256 (setq mark gnus-expirable-mark))
12257 (let* ((mark (or mark gnus-del-mark))
12258 (article (or article (gnus-summary-article-number))))
12259 (or article (error "No article on current line"))
12260 (if (or (= mark gnus-unread-mark)
12261 (= mark gnus-ticked-mark)
12262 (= mark gnus-dormant-mark))
12263 (gnus-mark-article-as-unread article mark)
12264 (gnus-mark-article-as-read article mark))
12266 ;; See whether the article is to be put in the cache.
12267 (and gnus-use-cache
12268 (not (= mark gnus-canceled-mark))
12269 (vectorp (gnus-summary-article-header article))
12270 (save-excursion
12271 (gnus-cache-possibly-enter-article
12272 gnus-newsgroup-name article
12273 (gnus-summary-article-header article)
12274 (= mark gnus-ticked-mark)
12275 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
12277 (if (gnus-summary-goto-subject article nil t)
12278 (let ((buffer-read-only nil))
12279 (gnus-summary-show-thread)
12280 ;; Fix the mark.
12281 (gnus-summary-update-mark mark 'unread)
12282 t))))
12284 (defun gnus-summary-update-secondary-mark (article)
12285 "Update the secondary (read, process, cache) mark."
12286 (gnus-summary-update-mark
12287 (cond ((memq article gnus-newsgroup-processable)
12288 gnus-process-mark)
12289 ((memq article gnus-newsgroup-cached)
12290 gnus-cached-mark)
12291 ((memq article gnus-newsgroup-replied)
12292 gnus-replied-mark)
12293 ((memq article gnus-newsgroup-saved)
12294 gnus-saved-mark)
12295 (t gnus-unread-mark))
12296 'replied)
12297 (when (gnus-visual-p 'summary-highlight 'highlight)
12298 (run-hooks 'gnus-summary-update-hook))
12301 (defun gnus-summary-update-mark (mark type)
12302 (beginning-of-line)
12303 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
12304 (buffer-read-only nil))
12305 (when (and forward
12306 (<= (+ forward (point)) (point-max)))
12307 ;; Go to the right position on the line.
12308 (goto-char (+ forward (point)))
12309 ;; Replace the old mark with the new mark.
12310 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
12311 ;; Optionally update the marks by some user rule.
12312 (when (eq type 'unread)
12313 (gnus-data-set-mark
12314 (gnus-data-find (gnus-summary-article-number)) mark)
12315 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
12317 (defun gnus-mark-article-as-read (article &optional mark)
12318 "Enter ARTICLE in the pertinent lists and remove it from others."
12319 ;; Make the article expirable.
12320 (let ((mark (or mark gnus-del-mark)))
12321 (if (= mark gnus-expirable-mark)
12322 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
12323 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
12324 ;; Remove from unread and marked lists.
12325 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12326 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12327 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12328 (push (cons article mark) gnus-newsgroup-reads)
12329 ;; Possibly remove from cache, if that is used.
12330 (when gnus-use-cache
12331 (gnus-cache-enter-remove-article article))))
12333 (defun gnus-mark-article-as-unread (article &optional mark)
12334 "Enter ARTICLE in the pertinent lists and remove it from others."
12335 (let ((mark (or mark gnus-ticked-mark)))
12336 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12337 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12338 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
12339 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12340 (cond ((= mark gnus-ticked-mark)
12341 (push article gnus-newsgroup-marked))
12342 ((= mark gnus-dormant-mark)
12343 (push article gnus-newsgroup-dormant))
12345 (push article gnus-newsgroup-unreads)))
12346 (setq gnus-newsgroup-reads
12347 (delq (assq article gnus-newsgroup-reads)
12348 gnus-newsgroup-reads))))
12350 (defalias 'gnus-summary-mark-as-unread-forward
12351 'gnus-summary-tick-article-forward)
12352 (make-obsolete 'gnus-summary-mark-as-unread-forward
12353 'gnus-summary-tick-article-forward)
12354 (defun gnus-summary-tick-article-forward (n)
12355 "Tick N articles forwards.
12356 If N is negative, tick backwards instead.
12357 The difference between N and the number of articles ticked is returned."
12358 (interactive "p")
12359 (gnus-summary-mark-forward n gnus-ticked-mark))
12361 (defalias 'gnus-summary-mark-as-unread-backward
12362 'gnus-summary-tick-article-backward)
12363 (make-obsolete 'gnus-summary-mark-as-unread-backward
12364 'gnus-summary-tick-article-backward)
12365 (defun gnus-summary-tick-article-backward (n)
12366 "Tick N articles backwards.
12367 The difference between N and the number of articles ticked is returned."
12368 (interactive "p")
12369 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
12371 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
12372 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
12373 (defun gnus-summary-tick-article (&optional article clear-mark)
12374 "Mark current article as unread.
12375 Optional 1st argument ARTICLE specifies article number to be marked as unread.
12376 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
12377 (interactive)
12378 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
12379 gnus-ticked-mark)))
12381 (defun gnus-summary-mark-as-read-forward (n)
12382 "Mark N articles as read forwards.
12383 If N is negative, mark backwards instead.
12384 The difference between N and the actual number of articles marked is
12385 returned."
12386 (interactive "p")
12387 (gnus-summary-mark-forward n gnus-del-mark t))
12389 (defun gnus-summary-mark-as-read-backward (n)
12390 "Mark the N articles as read backwards.
12391 The difference between N and the actual number of articles marked is
12392 returned."
12393 (interactive "p")
12394 (gnus-summary-mark-forward (- n) gnus-del-mark t))
12396 (defun gnus-summary-mark-as-read (&optional article mark)
12397 "Mark current article as read.
12398 ARTICLE specifies the article to be marked as read.
12399 MARK specifies a string to be inserted at the beginning of the line."
12400 (gnus-summary-mark-article article mark))
12402 (defun gnus-summary-clear-mark-forward (n)
12403 "Clear marks from N articles forward.
12404 If N is negative, clear backward instead.
12405 The difference between N and the number of marks cleared is returned."
12406 (interactive "p")
12407 (gnus-summary-mark-forward n gnus-unread-mark))
12409 (defun gnus-summary-clear-mark-backward (n)
12410 "Clear marks from N articles backward.
12411 The difference between N and the number of marks cleared is returned."
12412 (interactive "p")
12413 (gnus-summary-mark-forward (- n) gnus-unread-mark))
12415 (defun gnus-summary-mark-unread-as-read ()
12416 "Intended to be used by `gnus-summary-mark-article-hook'."
12417 (when (memq gnus-current-article gnus-newsgroup-unreads)
12418 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
12420 (defun gnus-summary-mark-read-and-unread-as-read ()
12421 "Intended to be used by `gnus-summary-mark-article-hook'."
12422 (let ((mark (gnus-summary-article-mark)))
12423 (when (or (gnus-unread-mark-p mark)
12424 (gnus-read-mark-p mark))
12425 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
12427 (defun gnus-summary-mark-region-as-read (point mark all)
12428 "Mark all unread articles between point and mark as read.
12429 If given a prefix, mark all articles between point and mark as read,
12430 even ticked and dormant ones."
12431 (interactive "r\nP")
12432 (save-excursion
12433 (let (article)
12434 (goto-char point)
12435 (beginning-of-line)
12436 (while (and
12437 (< (point) mark)
12438 (progn
12439 (when (or all
12440 (memq (setq article (gnus-summary-article-number))
12441 gnus-newsgroup-unreads))
12442 (gnus-summary-mark-article article gnus-del-mark))
12444 (gnus-summary-find-next))))))
12446 (defun gnus-summary-mark-below (score mark)
12447 "Mark articles with score less than SCORE with MARK."
12448 (interactive "P\ncMark: ")
12449 (gnus-set-global-variables)
12450 (setq score (if score
12451 (prefix-numeric-value score)
12452 (or gnus-summary-default-score 0)))
12453 (save-excursion
12454 (set-buffer gnus-summary-buffer)
12455 (goto-char (point-min))
12456 (while
12457 (progn
12458 (and (< (gnus-summary-article-score) score)
12459 (gnus-summary-mark-article nil mark))
12460 (gnus-summary-find-next)))))
12462 (defun gnus-summary-kill-below (&optional score)
12463 "Mark articles with score below SCORE as read."
12464 (interactive "P")
12465 (gnus-set-global-variables)
12466 (gnus-summary-mark-below score gnus-killed-mark))
12468 (defun gnus-summary-clear-above (&optional score)
12469 "Clear all marks from articles with score above SCORE."
12470 (interactive "P")
12471 (gnus-set-global-variables)
12472 (gnus-summary-mark-above score gnus-unread-mark))
12474 (defun gnus-summary-tick-above (&optional score)
12475 "Tick all articles with score above SCORE."
12476 (interactive "P")
12477 (gnus-set-global-variables)
12478 (gnus-summary-mark-above score gnus-ticked-mark))
12480 (defun gnus-summary-mark-above (score mark)
12481 "Mark articles with score over SCORE with MARK."
12482 (interactive "P\ncMark: ")
12483 (gnus-set-global-variables)
12484 (setq score (if score
12485 (prefix-numeric-value score)
12486 (or gnus-summary-default-score 0)))
12487 (save-excursion
12488 (set-buffer gnus-summary-buffer)
12489 (goto-char (point-min))
12490 (while (and (progn
12491 (if (> (gnus-summary-article-score) score)
12492 (gnus-summary-mark-article nil mark))
12494 (gnus-summary-find-next)))))
12496 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
12497 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
12498 (defun gnus-summary-limit-include-expunged ()
12499 "Display all the hidden articles that were expunged for low scores."
12500 (interactive)
12501 (gnus-set-global-variables)
12502 (let ((buffer-read-only nil))
12503 (let ((scored gnus-newsgroup-scored)
12504 headers h)
12505 (while scored
12506 (or (gnus-summary-goto-subject (caar scored))
12507 (and (setq h (gnus-summary-article-header (caar scored)))
12508 (< (cdar scored) gnus-summary-expunge-below)
12509 (setq headers (cons h headers))))
12510 (setq scored (cdr scored)))
12511 (or headers (error "No expunged articles hidden."))
12512 (goto-char (point-min))
12513 (gnus-summary-prepare-unthreaded (nreverse headers)))
12514 (goto-char (point-min))
12515 (gnus-summary-position-point)))
12517 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
12518 "Mark all articles not marked as unread in this newsgroup as read.
12519 If prefix argument ALL is non-nil, all articles are marked as read.
12520 If QUIETLY is non-nil, no questions will be asked.
12521 If TO-HERE is non-nil, it should be a point in the buffer. All
12522 articles before this point will be marked as read.
12523 The number of articles marked as read is returned."
12524 (interactive "P")
12525 (gnus-set-global-variables)
12526 (prog1
12527 (if (or quietly
12528 (not gnus-interactive-catchup) ;Without confirmation?
12529 gnus-expert-user
12530 (gnus-y-or-n-p
12531 (if all
12532 "Mark absolutely all articles as read? "
12533 "Mark all unread articles as read? ")))
12534 (if (and not-mark
12535 (not gnus-newsgroup-adaptive)
12536 (not gnus-newsgroup-auto-expire))
12537 (progn
12538 (when all
12539 (setq gnus-newsgroup-marked nil
12540 gnus-newsgroup-dormant nil))
12541 (setq gnus-newsgroup-unreads nil))
12542 ;; We actually mark all articles as canceled, which we
12543 ;; have to do when using auto-expiry or adaptive scoring.
12544 (gnus-summary-show-all-threads)
12545 (if (gnus-summary-first-subject (not all))
12546 (while (and
12547 (if to-here (< (point) to-here) t)
12548 (gnus-summary-mark-article-as-read gnus-catchup-mark)
12549 (gnus-summary-find-next (not all)))))
12550 (unless to-here
12551 (setq gnus-newsgroup-unreads nil))
12552 (gnus-set-mode-line 'summary)))
12553 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
12554 (if (and (not to-here) (eq 'nnvirtual (car method)))
12555 (nnvirtual-catchup-group
12556 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
12557 (gnus-summary-position-point)))
12559 (defun gnus-summary-catchup-to-here (&optional all)
12560 "Mark all unticked articles before the current one as read.
12561 If ALL is non-nil, also mark ticked and dormant articles as read."
12562 (interactive "P")
12563 (gnus-set-global-variables)
12564 (save-excursion
12565 (gnus-save-hidden-threads
12566 (let ((beg (point)))
12567 ;; We check that there are unread articles.
12568 (when (or all (gnus-summary-find-prev))
12569 (gnus-summary-catchup all t beg)))))
12570 (gnus-summary-position-point))
12572 (defun gnus-summary-catchup-all (&optional quietly)
12573 "Mark all articles in this newsgroup as read."
12574 (interactive "P")
12575 (gnus-set-global-variables)
12576 (gnus-summary-catchup t quietly))
12578 (defun gnus-summary-catchup-and-exit (&optional all quietly)
12579 "Mark all articles not marked as unread in this newsgroup as read, then exit.
12580 If prefix argument ALL is non-nil, all articles are marked as read."
12581 (interactive "P")
12582 (gnus-set-global-variables)
12583 (gnus-summary-catchup all quietly nil 'fast)
12584 ;; Select next newsgroup or exit.
12585 (if (eq gnus-auto-select-next 'quietly)
12586 (gnus-summary-next-group nil)
12587 (gnus-summary-exit)))
12589 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
12590 "Mark all articles in this newsgroup as read, and then exit."
12591 (interactive "P")
12592 (gnus-set-global-variables)
12593 (gnus-summary-catchup-and-exit t quietly))
12595 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
12596 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
12597 "Mark all articles in this group as read and select the next group.
12598 If given a prefix, mark all articles, unread as well as ticked, as
12599 read."
12600 (interactive "P")
12601 (gnus-set-global-variables)
12602 (save-excursion
12603 (gnus-summary-catchup all))
12604 (gnus-summary-next-article t nil nil t))
12606 ;; Thread-based commands.
12608 (defun gnus-summary-articles-in-thread (&optional article)
12609 "Return a list of all articles in the current thread.
12610 If ARTICLE is non-nil, return all articles in the thread that starts
12611 with that article."
12612 (let* ((article (or article (gnus-summary-article-number)))
12613 (data (gnus-data-find-list article))
12614 (top-level (gnus-data-level (car data)))
12615 (top-subject
12616 (cond ((null gnus-thread-operation-ignore-subject)
12617 (gnus-simplify-subject-re
12618 (mail-header-subject (gnus-data-header (car data)))))
12619 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
12620 (gnus-simplify-subject-fuzzy
12621 (mail-header-subject (gnus-data-header (car data)))))
12622 (t nil)))
12623 (end-point (save-excursion
12624 (if (gnus-summary-go-to-next-thread)
12625 (point) (point-max))))
12626 articles)
12627 (while (and data
12628 (< (gnus-data-pos (car data)) end-point))
12629 (when (or (not top-subject)
12630 (string= top-subject
12631 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
12632 (gnus-simplify-subject-fuzzy
12633 (mail-header-subject
12634 (gnus-data-header (car data))))
12635 (gnus-simplify-subject-re
12636 (mail-header-subject
12637 (gnus-data-header (car data)))))))
12638 (push (gnus-data-number (car data)) articles))
12639 (unless (and (setq data (cdr data))
12640 (> (gnus-data-level (car data)) top-level))
12641 (setq data nil)))
12642 ;; Return the list of articles.
12643 (nreverse articles)))
12645 (defun gnus-summary-rethread-current ()
12646 "Rethread the thread the current article is part of."
12647 (interactive)
12648 (gnus-set-global-variables)
12649 (let* ((gnus-show-threads t)
12650 (article (gnus-summary-article-number))
12651 (id (mail-header-id (gnus-summary-article-header)))
12652 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
12653 (unless id
12654 (error "No article on the current line"))
12655 (gnus-rebuild-thread id)
12656 (gnus-summary-goto-subject article)))
12658 (defun gnus-summary-reparent-thread ()
12659 "Make current article child of the marked (or previous) article.
12661 Note that the re-threading will only work if `gnus-thread-ignore-subject'
12662 is non-nil or the Subject: of both articles are the same."
12663 (interactive)
12664 (or (not (gnus-group-read-only-p))
12665 (error "The current newsgroup does not support article editing."))
12666 (or (<= (length gnus-newsgroup-processable) 1)
12667 (error "No more than one article may be marked."))
12668 (save-window-excursion
12669 (let ((gnus-article-buffer " *reparent*")
12670 (current-article (gnus-summary-article-number))
12671 ; first grab the marked article, otherwise one line up.
12672 (parent-article (if (not (null gnus-newsgroup-processable))
12673 (car gnus-newsgroup-processable)
12674 (save-excursion
12675 (if (eq (forward-line -1) 0)
12676 (gnus-summary-article-number)
12677 (error "Beginning of summary buffer."))))))
12678 (or (not (eq current-article parent-article))
12679 (error "An article may not be self-referential."))
12680 (let ((message-id (mail-header-id
12681 (gnus-summary-article-header parent-article))))
12682 (or (and message-id (not (equal message-id "")))
12683 (error "No message-id in desired parent."))
12684 (gnus-summary-select-article t t nil current-article)
12685 (set-buffer gnus-article-buffer)
12686 (setq buffer-read-only nil)
12687 (let ((buf (format "%s" (buffer-string))))
12688 (erase-buffer)
12689 (insert buf))
12690 (goto-char (point-min))
12691 (if (search-forward-regexp "^References: " nil t)
12692 (insert message-id " " )
12693 (insert "References: " message-id "\n"))
12694 (or (gnus-request-replace-article current-article
12695 (car gnus-article-current)
12696 gnus-article-buffer)
12697 (error "Couldn't replace article."))
12698 (set-buffer gnus-summary-buffer)
12699 (gnus-summary-unmark-all-processable)
12700 (gnus-summary-rethread-current)
12701 (gnus-message 3 "Article %d is now the child of article %d."
12702 current-article parent-article)))))
12704 (defun gnus-summary-toggle-threads (&optional arg)
12705 "Toggle showing conversation threads.
12706 If ARG is positive number, turn showing conversation threads on."
12707 (interactive "P")
12708 (gnus-set-global-variables)
12709 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
12710 (setq gnus-show-threads
12711 (if (null arg) (not gnus-show-threads)
12712 (> (prefix-numeric-value arg) 0)))
12713 (gnus-summary-prepare)
12714 (gnus-summary-goto-subject current)
12715 (gnus-summary-position-point)))
12717 (defun gnus-summary-show-all-threads ()
12718 "Show all threads."
12719 (interactive)
12720 (gnus-set-global-variables)
12721 (save-excursion
12722 (let ((buffer-read-only nil))
12723 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
12724 (gnus-summary-position-point))
12726 (defun gnus-summary-show-thread ()
12727 "Show thread subtrees.
12728 Returns nil if no thread was there to be shown."
12729 (interactive)
12730 (gnus-set-global-variables)
12731 (let ((buffer-read-only nil)
12732 (orig (point))
12733 ;; first goto end then to beg, to have point at beg after let
12734 (end (progn (end-of-line) (point)))
12735 (beg (progn (beginning-of-line) (point))))
12736 (prog1
12737 ;; Any hidden lines here?
12738 (search-forward "\r" end t)
12739 (subst-char-in-region beg end ?\^M ?\n t)
12740 (goto-char orig)
12741 (gnus-summary-position-point))))
12743 (defun gnus-summary-hide-all-threads ()
12744 "Hide all thread subtrees."
12745 (interactive)
12746 (gnus-set-global-variables)
12747 (save-excursion
12748 (goto-char (point-min))
12749 (gnus-summary-hide-thread)
12750 (while (zerop (gnus-summary-next-thread 1 t))
12751 (gnus-summary-hide-thread)))
12752 (gnus-summary-position-point))
12754 (defun gnus-summary-hide-thread ()
12755 "Hide thread subtrees.
12756 Returns nil if no threads were there to be hidden."
12757 (interactive)
12758 (gnus-set-global-variables)
12759 (let ((buffer-read-only nil)
12760 (start (point))
12761 (article (gnus-summary-article-number)))
12762 (goto-char start)
12763 ;; Go forward until either the buffer ends or the subthread
12764 ;; ends.
12765 (when (and (not (eobp))
12766 (or (zerop (gnus-summary-next-thread 1 t))
12767 (goto-char (point-max))))
12768 (prog1
12769 (if (and (> (point) start)
12770 (search-backward "\n" start t))
12771 (progn
12772 (subst-char-in-region start (point) ?\n ?\^M)
12773 (gnus-summary-goto-subject article))
12774 (goto-char start)
12775 nil)
12776 ;;(gnus-summary-position-point)
12777 ))))
12779 (defun gnus-summary-go-to-next-thread (&optional previous)
12780 "Go to the same level (or less) next thread.
12781 If PREVIOUS is non-nil, go to previous thread instead.
12782 Return the article number moved to, or nil if moving was impossible."
12783 (let ((level (gnus-summary-thread-level))
12784 (way (if previous -1 1))
12785 (beg (point)))
12786 (forward-line way)
12787 (while (and (not (eobp))
12788 (< level (gnus-summary-thread-level)))
12789 (forward-line way))
12790 (if (eobp)
12791 (progn
12792 (goto-char beg)
12793 nil)
12794 (setq beg (point))
12795 (prog1
12796 (gnus-summary-article-number)
12797 (goto-char beg)))))
12799 (defun gnus-summary-go-to-next-thread-old (&optional previous)
12800 "Go to the same level (or less) next thread.
12801 If PREVIOUS is non-nil, go to previous thread instead.
12802 Return the article number moved to, or nil if moving was impossible."
12803 (if (and (eq gnus-summary-make-false-root 'dummy)
12804 (gnus-summary-article-intangible-p))
12805 (let ((beg (point)))
12806 (while (and (zerop (forward-line 1))
12807 (not (gnus-summary-article-intangible-p))
12808 (not (zerop (save-excursion
12809 (gnus-summary-thread-level))))))
12810 (if (eobp)
12811 (progn
12812 (goto-char beg)
12813 nil)
12814 (point)))
12815 (let* ((level (gnus-summary-thread-level))
12816 (article (gnus-summary-article-number))
12817 (data (cdr (gnus-data-find-list article (gnus-data-list previous))))
12818 oart)
12819 (while data
12820 (if (<= (gnus-data-level (car data)) level)
12821 (setq oart (gnus-data-number (car data))
12822 data nil)
12823 (setq data (cdr data))))
12824 (and oart
12825 (gnus-summary-goto-subject oart)))))
12827 (defun gnus-summary-next-thread (n &optional silent)
12828 "Go to the same level next N'th thread.
12829 If N is negative, search backward instead.
12830 Returns the difference between N and the number of skips actually
12831 done.
12833 If SILENT, don't output messages."
12834 (interactive "p")
12835 (gnus-set-global-variables)
12836 (let ((backward (< n 0))
12837 (n (abs n))
12838 old dum int)
12839 (while (and (> n 0)
12840 (gnus-summary-go-to-next-thread backward))
12841 (decf n))
12842 (unless silent
12843 (gnus-summary-position-point))
12844 (when (and (not silent) (/= 0 n))
12845 (gnus-message 7 "No more threads"))
12848 (defun gnus-summary-prev-thread (n)
12849 "Go to the same level previous N'th thread.
12850 Returns the difference between N and the number of skips actually
12851 done."
12852 (interactive "p")
12853 (gnus-set-global-variables)
12854 (gnus-summary-next-thread (- n)))
12856 (defun gnus-summary-go-down-thread ()
12857 "Go down one level in the current thread."
12858 (let ((children (gnus-summary-article-children)))
12859 (and children
12860 (gnus-summary-goto-subject (car children)))))
12862 (defun gnus-summary-go-up-thread ()
12863 "Go up one level in the current thread."
12864 (let ((parent (gnus-summary-article-parent)))
12865 (and parent
12866 (gnus-summary-goto-subject parent))))
12868 (defun gnus-summary-down-thread (n)
12869 "Go down thread N steps.
12870 If N is negative, go up instead.
12871 Returns the difference between N and how many steps down that were
12872 taken."
12873 (interactive "p")
12874 (gnus-set-global-variables)
12875 (let ((up (< n 0))
12876 (n (abs n)))
12877 (while (and (> n 0)
12878 (if up (gnus-summary-go-up-thread)
12879 (gnus-summary-go-down-thread)))
12880 (setq n (1- n)))
12881 (gnus-summary-position-point)
12882 (if (/= 0 n) (gnus-message 7 "Can't go further"))
12885 (defun gnus-summary-up-thread (n)
12886 "Go up thread N steps.
12887 If N is negative, go up instead.
12888 Returns the difference between N and how many steps down that were
12889 taken."
12890 (interactive "p")
12891 (gnus-set-global-variables)
12892 (gnus-summary-down-thread (- n)))
12894 (defun gnus-summary-top-thread ()
12895 "Go to the top of the thread."
12896 (interactive)
12897 (gnus-set-global-variables)
12898 (while (gnus-summary-go-up-thread))
12899 (gnus-summary-article-number))
12901 (defun gnus-summary-kill-thread (&optional unmark)
12902 "Mark articles under current thread as read.
12903 If the prefix argument is positive, remove any kinds of marks.
12904 If the prefix argument is negative, tick articles instead."
12905 (interactive "P")
12906 (gnus-set-global-variables)
12907 (when unmark
12908 (setq unmark (prefix-numeric-value unmark)))
12909 (let ((articles (gnus-summary-articles-in-thread)))
12910 (save-excursion
12911 ;; Expand the thread.
12912 (gnus-summary-show-thread)
12913 ;; Mark all the articles.
12914 (while articles
12915 (gnus-summary-goto-subject (car articles))
12916 (cond ((null unmark)
12917 (gnus-summary-mark-article-as-read gnus-killed-mark))
12918 ((> unmark 0)
12919 (gnus-summary-mark-article-as-unread gnus-unread-mark))
12921 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
12922 (setq articles (cdr articles))))
12923 ;; Hide killed subtrees.
12924 (and (null unmark)
12925 gnus-thread-hide-killed
12926 (gnus-summary-hide-thread))
12927 ;; If marked as read, go to next unread subject.
12928 (if (null unmark)
12929 ;; Go to next unread subject.
12930 (gnus-summary-next-subject 1 t)))
12931 (gnus-set-mode-line 'summary))
12933 ;; Summary sorting commands
12935 (defun gnus-summary-sort-by-number (&optional reverse)
12936 "Sort summary buffer by article number.
12937 Argument REVERSE means reverse order."
12938 (interactive "P")
12939 (gnus-summary-sort 'number reverse))
12941 (defun gnus-summary-sort-by-author (&optional reverse)
12942 "Sort summary buffer by author name alphabetically.
12943 If case-fold-search is non-nil, case of letters is ignored.
12944 Argument REVERSE means reverse order."
12945 (interactive "P")
12946 (gnus-summary-sort 'author reverse))
12948 (defun gnus-summary-sort-by-subject (&optional reverse)
12949 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
12950 If case-fold-search is non-nil, case of letters is ignored.
12951 Argument REVERSE means reverse order."
12952 (interactive "P")
12953 (gnus-summary-sort 'subject reverse))
12955 (defun gnus-summary-sort-by-date (&optional reverse)
12956 "Sort summary buffer by date.
12957 Argument REVERSE means reverse order."
12958 (interactive "P")
12959 (gnus-summary-sort 'date reverse))
12961 (defun gnus-summary-sort-by-score (&optional reverse)
12962 "Sort summary buffer by score.
12963 Argument REVERSE means reverse order."
12964 (interactive "P")
12965 (gnus-summary-sort 'score reverse))
12967 (defun gnus-summary-sort (predicate reverse)
12968 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
12969 (gnus-set-global-variables)
12970 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
12971 (article (intern (format "gnus-article-sort-by-%s" predicate)))
12972 (gnus-thread-sort-functions
12973 (list
12974 (if (not reverse)
12975 thread
12976 `(lambda (t1 t2)
12977 (,thread t2 t1)))))
12978 (gnus-article-sort-functions
12979 (list
12980 (if (not reverse)
12981 article
12982 `(lambda (t1 t2)
12983 (,article t2 t1)))))
12984 (buffer-read-only)
12985 (gnus-summary-prepare-hook nil))
12986 ;; We do the sorting by regenerating the threads.
12987 (gnus-summary-prepare)
12988 ;; Hide subthreads if needed.
12989 (when (and gnus-show-threads gnus-thread-hide-subtree)
12990 (gnus-summary-hide-all-threads)))
12991 ;; If in async mode, we send some info to the backend.
12992 (when gnus-newsgroup-async
12993 (gnus-request-asynchronous
12994 gnus-newsgroup-name gnus-newsgroup-data)))
12996 (defun gnus-sortable-date (date)
12997 "Make sortable string by string-lessp from DATE.
12998 Timezone package is used."
12999 (condition-case ()
13000 (progn
13001 (setq date (inline (timezone-fix-time
13002 date nil
13003 (aref (inline (timezone-parse-date date)) 4))))
13004 (inline
13005 (timezone-make-sortable-date
13006 (aref date 0) (aref date 1) (aref date 2)
13007 (inline
13008 (timezone-make-time-string
13009 (aref date 3) (aref date 4) (aref date 5))))))
13010 (error "")))
13012 ;; Summary saving commands.
13014 (defun gnus-summary-save-article (&optional n not-saved)
13015 "Save the current article using the default saver function.
13016 If N is a positive number, save the N next articles.
13017 If N is a negative number, save the N previous articles.
13018 If N is nil and any articles have been marked with the process mark,
13019 save those articles instead.
13020 The variable `gnus-default-article-saver' specifies the saver function."
13021 (interactive "P")
13022 (gnus-set-global-variables)
13023 (let ((articles (gnus-summary-work-articles n))
13024 (save-buffer (save-excursion
13025 (nnheader-set-temp-buffer " *Gnus Save*")))
13026 file header article)
13027 (while articles
13028 (setq header (gnus-summary-article-header
13029 (setq article (pop articles))))
13030 (if (not (vectorp header))
13031 ;; This is a pseudo-article.
13032 (if (assq 'name header)
13033 (gnus-copy-file (cdr (assq 'name header)))
13034 (gnus-message 1 "Article %d is unsaveable" article))
13035 ;; This is a real article.
13036 (save-window-excursion
13037 (gnus-summary-select-article t nil nil article))
13038 (save-excursion
13039 (set-buffer save-buffer)
13040 (erase-buffer)
13041 (insert-buffer-substring gnus-original-article-buffer))
13042 (unless gnus-save-all-headers
13043 ;; Remove headers accoring to `gnus-saved-headers'.
13044 (let ((gnus-visible-headers
13045 (or gnus-saved-headers gnus-visible-headers))
13046 (gnus-article-buffer save-buffer))
13047 (gnus-article-hide-headers 1 t)))
13048 (save-window-excursion
13049 (if (not gnus-default-article-saver)
13050 (error "No default saver is defined.")
13051 ;; !!! Magic! The saving functions all save
13052 ;; `gnus-original-article-buffer' (or so they think),
13053 ;; but we bind that variable to our save-buffer.
13054 (set-buffer gnus-article-buffer)
13055 (let ((gnus-original-article-buffer save-buffer))
13056 (set-buffer gnus-summary-buffer)
13057 (setq file (funcall
13058 gnus-default-article-saver
13059 (cond
13060 ((not gnus-prompt-before-saving)
13061 'default)
13062 ((eq gnus-prompt-before-saving 'always)
13063 nil)
13064 (t file)))))))
13065 (gnus-summary-remove-process-mark article)
13066 (unless not-saved
13067 (gnus-summary-set-saved-mark article))))
13068 (gnus-kill-buffer save-buffer)
13069 (gnus-summary-position-point)
13072 (defun gnus-summary-pipe-output (&optional arg)
13073 "Pipe the current article to a subprocess.
13074 If N is a positive number, pipe the N next articles.
13075 If N is a negative number, pipe the N previous articles.
13076 If N is nil and any articles have been marked with the process mark,
13077 pipe those articles instead."
13078 (interactive "P")
13079 (gnus-set-global-variables)
13080 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
13081 (gnus-summary-save-article arg t))
13082 (gnus-configure-windows 'pipe))
13084 (defun gnus-summary-save-article-mail (&optional arg)
13085 "Append the current article to an mail file.
13086 If N is a positive number, save the N next articles.
13087 If N is a negative number, save the N previous articles.
13088 If N is nil and any articles have been marked with the process mark,
13089 save those articles instead."
13090 (interactive "P")
13091 (gnus-set-global-variables)
13092 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
13093 (gnus-summary-save-article arg)))
13095 (defun gnus-summary-save-article-rmail (&optional arg)
13096 "Append the current article to an rmail file.
13097 If N is a positive number, save the N next articles.
13098 If N is a negative number, save the N previous articles.
13099 If N is nil and any articles have been marked with the process mark,
13100 save those articles instead."
13101 (interactive "P")
13102 (gnus-set-global-variables)
13103 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
13104 (gnus-summary-save-article arg)))
13106 (defun gnus-summary-save-article-file (&optional arg)
13107 "Append the current article to a file.
13108 If N is a positive number, save the N next articles.
13109 If N is a negative number, save the N previous articles.
13110 If N is nil and any articles have been marked with the process mark,
13111 save those articles instead."
13112 (interactive "P")
13113 (gnus-set-global-variables)
13114 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
13115 (gnus-summary-save-article arg)))
13117 (defun gnus-summary-save-article-body-file (&optional arg)
13118 "Append the current article body to a file.
13119 If N is a positive number, save the N next articles.
13120 If N is a negative number, save the N previous articles.
13121 If N is nil and any articles have been marked with the process mark,
13122 save those articles instead."
13123 (interactive "P")
13124 (gnus-set-global-variables)
13125 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
13126 (gnus-summary-save-article arg)))
13128 (defun gnus-get-split-value (methods)
13129 "Return a value based on the split METHODS."
13130 (let (split-name method result match)
13131 (when methods
13132 (save-excursion
13133 (set-buffer gnus-original-article-buffer)
13134 (save-restriction
13135 (nnheader-narrow-to-headers)
13136 (while methods
13137 (goto-char (point-min))
13138 (setq method (pop methods))
13139 (setq match (car method))
13140 (when (cond
13141 ((stringp match)
13142 ;; Regular expression.
13143 (condition-case ()
13144 (re-search-forward match nil t)
13145 (error nil)))
13146 ((gnus-functionp match)
13147 ;; Function.
13148 (save-restriction
13149 (widen)
13150 (setq result (funcall match gnus-newsgroup-name))))
13151 ((consp match)
13152 ;; Form.
13153 (save-restriction
13154 (widen)
13155 (setq result (eval match)))))
13156 (setq split-name (append (cdr method) split-name))
13157 (cond ((stringp result)
13158 (push result split-name))
13159 ((consp result)
13160 (setq split-name (append result split-name)))))))))
13161 split-name))
13163 (defun gnus-read-move-group-name (prompt default articles prefix)
13164 "Read a group name."
13165 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
13166 (minibuffer-confirm-incomplete nil) ; XEmacs
13167 group-map
13168 (dum (mapatoms
13169 (lambda (g)
13170 (and (boundp g)
13171 (symbol-name g)
13172 (memq 'respool
13173 (assoc (symbol-name
13174 (car (gnus-find-method-for-group
13175 (symbol-name g))))
13176 gnus-valid-select-methods))
13177 (push (list (symbol-name g)) group-map)))
13178 gnus-active-hashtb))
13179 (prom
13180 (format "%s %s to:"
13181 prompt
13182 (if (> (length articles) 1)
13183 (format "these %d articles" (length articles))
13184 "this article")))
13185 (to-newsgroup
13186 (cond
13187 ((null split-name)
13188 (gnus-completing-read default prom
13189 group-map nil nil prefix
13190 'gnus-group-history))
13191 ((= 1 (length split-name))
13192 (gnus-completing-read (car split-name) prom group-map
13193 nil nil nil
13194 'gnus-group-history))
13196 (gnus-completing-read nil prom
13197 (mapcar (lambda (el) (list el))
13198 (nreverse split-name))
13199 nil nil nil
13200 'gnus-group-history)))))
13201 (when to-newsgroup
13202 (if (or (string= to-newsgroup "")
13203 (string= to-newsgroup prefix))
13204 (setq to-newsgroup (or default "")))
13205 (or (gnus-active to-newsgroup)
13206 (gnus-activate-group to-newsgroup)
13207 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
13208 to-newsgroup))
13209 (or (and (gnus-request-create-group
13210 to-newsgroup (gnus-group-name-to-method to-newsgroup))
13211 (gnus-activate-group to-newsgroup nil nil
13212 (gnus-group-name-to-method
13213 to-newsgroup)))
13214 (error "Couldn't create group %s" to-newsgroup)))
13215 (error "No such group: %s" to-newsgroup)))
13216 to-newsgroup))
13218 (defun gnus-read-save-file-name (prompt default-name)
13219 (let* ((split-name (gnus-get-split-value gnus-split-methods))
13220 (file
13221 ;; Let the split methods have their say.
13222 (cond
13223 ;; No split name was found.
13224 ((null split-name)
13225 (read-file-name
13226 (concat prompt " (default "
13227 (file-name-nondirectory default-name) ") ")
13228 (file-name-directory default-name)
13229 default-name))
13230 ;; A single split name was found
13231 ((= 1 (length split-name))
13232 (let* ((name (car split-name))
13233 (dir (cond ((file-directory-p name)
13234 (file-name-as-directory name))
13235 ((file-exists-p name) name)
13236 (t gnus-article-save-directory))))
13237 (read-file-name
13238 (concat prompt " (default " name ") ")
13239 dir name)))
13240 ;; A list of splits was found.
13242 (setq split-name (nreverse split-name))
13243 (let (result)
13244 (let ((file-name-history (nconc split-name file-name-history)))
13245 (setq result
13246 (read-file-name
13247 (concat prompt " (`M-p' for defaults) ")
13248 gnus-article-save-directory
13249 (car split-name))))
13250 (car (push result file-name-history)))))))
13251 ;; If we have read a directory, we append the default file name.
13252 (when (file-directory-p file)
13253 (setq file (concat (file-name-as-directory file)
13254 (file-name-nondirectory default-name))))
13255 ;; Possibly translate some charaters.
13256 (nnheader-translate-file-chars file)))
13258 (defun gnus-article-archive-name (group)
13259 "Return the first instance of an \"Archive-name\" in the current buffer."
13260 (let ((case-fold-search t))
13261 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
13262 (match-string 1))))
13264 (defun gnus-summary-save-in-rmail (&optional filename)
13265 "Append this article to Rmail file.
13266 Optional argument FILENAME specifies file name.
13267 Directory to save to is default to `gnus-article-save-directory'."
13268 (interactive)
13269 (gnus-set-global-variables)
13270 (let ((default-name
13271 (funcall gnus-rmail-save-name gnus-newsgroup-name
13272 gnus-current-headers gnus-newsgroup-last-rmail)))
13273 (setq filename
13274 (cond ((eq filename 'default)
13275 default-name)
13276 (filename filename)
13277 (t (gnus-read-save-file-name
13278 "Save in rmail file:" default-name))))
13279 (gnus-make-directory (file-name-directory filename))
13280 (gnus-eval-in-buffer-window gnus-original-article-buffer
13281 (save-excursion
13282 (save-restriction
13283 (widen)
13284 (gnus-output-to-rmail filename))))
13285 ;; Remember the directory name to save articles
13286 (setq gnus-newsgroup-last-rmail filename)))
13288 (defun gnus-summary-save-in-mail (&optional filename)
13289 "Append this article to Unix mail file.
13290 Optional argument FILENAME specifies file name.
13291 Directory to save to is default to `gnus-article-save-directory'."
13292 (interactive)
13293 (gnus-set-global-variables)
13294 (let ((default-name
13295 (funcall gnus-mail-save-name gnus-newsgroup-name
13296 gnus-current-headers gnus-newsgroup-last-mail)))
13297 (setq filename
13298 (cond ((eq filename 'default)
13299 default-name)
13300 (filename filename)
13301 (t (gnus-read-save-file-name
13302 "Save in Unix mail file:" default-name))))
13303 (setq filename
13304 (expand-file-name filename
13305 (and default-name
13306 (file-name-directory default-name))))
13307 (gnus-make-directory (file-name-directory filename))
13308 (gnus-eval-in-buffer-window gnus-original-article-buffer
13309 (save-excursion
13310 (save-restriction
13311 (widen)
13312 (if (and (file-readable-p filename) (mail-file-babyl-p filename))
13313 (gnus-output-to-rmail filename)
13314 (let ((mail-use-rfc822 t))
13315 (rmail-output filename 1 t t))))))
13316 ;; Remember the directory name to save articles.
13317 (setq gnus-newsgroup-last-mail filename)))
13319 (defun gnus-summary-save-in-file (&optional filename)
13320 "Append this article to file.
13321 Optional argument FILENAME specifies file name.
13322 Directory to save to is default to `gnus-article-save-directory'."
13323 (interactive)
13324 (gnus-set-global-variables)
13325 (let ((default-name
13326 (funcall gnus-file-save-name gnus-newsgroup-name
13327 gnus-current-headers gnus-newsgroup-last-file)))
13328 (setq filename
13329 (cond ((eq filename 'default)
13330 default-name)
13331 (filename filename)
13332 (t (gnus-read-save-file-name
13333 "Save in file:" default-name))))
13334 (gnus-make-directory (file-name-directory filename))
13335 (gnus-eval-in-buffer-window gnus-original-article-buffer
13336 (save-excursion
13337 (save-restriction
13338 (widen)
13339 (gnus-output-to-file filename))))
13340 ;; Remember the directory name to save articles.
13341 (setq gnus-newsgroup-last-file filename)))
13343 (defun gnus-summary-save-body-in-file (&optional filename)
13344 "Append this article body to a file.
13345 Optional argument FILENAME specifies file name.
13346 The directory to save in defaults to `gnus-article-save-directory'."
13347 (interactive)
13348 (gnus-set-global-variables)
13349 (let ((default-name
13350 (funcall gnus-file-save-name gnus-newsgroup-name
13351 gnus-current-headers gnus-newsgroup-last-file)))
13352 (setq filename
13353 (cond ((eq filename 'default)
13354 default-name)
13355 (filename filename)
13356 (t (gnus-read-save-file-name
13357 "Save body in file:" default-name))))
13358 (gnus-make-directory (file-name-directory filename))
13359 (gnus-eval-in-buffer-window gnus-original-article-buffer
13360 (save-excursion
13361 (save-restriction
13362 (widen)
13363 (goto-char (point-min))
13364 (and (search-forward "\n\n" nil t)
13365 (narrow-to-region (point) (point-max)))
13366 (gnus-output-to-file filename))))
13367 ;; Remember the directory name to save articles.
13368 (setq gnus-newsgroup-last-file filename)))
13370 (defun gnus-summary-save-in-pipe (&optional command)
13371 "Pipe this article to subprocess."
13372 (interactive)
13373 (gnus-set-global-variables)
13374 (setq command
13375 (cond ((eq command 'default)
13376 gnus-last-shell-command)
13377 (command command)
13378 (t (read-string "Shell command on article: "
13379 gnus-last-shell-command))))
13380 (if (string-equal command "")
13381 (setq command gnus-last-shell-command))
13382 (gnus-eval-in-buffer-window gnus-article-buffer
13383 (save-restriction
13384 (widen)
13385 (shell-command-on-region (point-min) (point-max) command nil)))
13386 (setq gnus-last-shell-command command))
13388 ;; Summary extract commands
13390 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
13391 (let ((buffer-read-only nil)
13392 (article (gnus-summary-article-number))
13393 after-article b e)
13394 (or (gnus-summary-goto-subject article)
13395 (error (format "No such article: %d" article)))
13396 (gnus-summary-position-point)
13397 ;; If all commands are to be bunched up on one line, we collect
13398 ;; them here.
13399 (if gnus-view-pseudos-separately
13401 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
13402 files action)
13403 (while ps
13404 (setq action (cdr (assq 'action (car ps))))
13405 (setq files (list (cdr (assq 'name (car ps)))))
13406 (while (and ps (cdr ps)
13407 (string= (or action "1")
13408 (or (cdr (assq 'action (cadr ps))) "2")))
13409 (setq files (cons (cdr (assq 'name (cadr ps))) files))
13410 (setcdr ps (cddr ps)))
13411 (if (not files)
13413 (if (not (string-match "%s" action))
13414 (setq files (cons " " files)))
13415 (setq files (cons " " files))
13416 (and (assq 'execute (car ps))
13417 (setcdr (assq 'execute (car ps))
13418 (funcall (if (string-match "%s" action)
13419 'format 'concat)
13420 action
13421 (mapconcat (lambda (f) f) files " ")))))
13422 (setq ps (cdr ps)))))
13423 (if (and gnus-view-pseudos (not not-view))
13424 (while pslist
13425 (and (assq 'execute (car pslist))
13426 (gnus-execute-command (cdr (assq 'execute (car pslist)))
13427 (eq gnus-view-pseudos 'not-confirm)))
13428 (setq pslist (cdr pslist)))
13429 (save-excursion
13430 (while pslist
13431 (setq after-article (or (cdr (assq 'article (car pslist)))
13432 (gnus-summary-article-number)))
13433 (gnus-summary-goto-subject after-article)
13434 (forward-line 1)
13435 (setq b (point))
13436 (insert " " (file-name-nondirectory
13437 (cdr (assq 'name (car pslist))))
13438 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
13439 (setq e (point))
13440 (forward-line -1) ; back to `b'
13441 (gnus-add-text-properties
13442 b (1- e) (list 'gnus-number gnus-reffed-article-number
13443 gnus-mouse-face-prop gnus-mouse-face))
13444 (gnus-data-enter
13445 after-article gnus-reffed-article-number
13446 gnus-unread-mark b (car pslist) 0 (- e b))
13447 (push gnus-reffed-article-number gnus-newsgroup-unreads)
13448 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
13449 (setq pslist (cdr pslist)))))))
13451 (defun gnus-pseudos< (p1 p2)
13452 (let ((c1 (cdr (assq 'action p1)))
13453 (c2 (cdr (assq 'action p2))))
13454 (and c1 c2 (string< c1 c2))))
13456 (defun gnus-request-pseudo-article (props)
13457 (cond ((assq 'execute props)
13458 (gnus-execute-command (cdr (assq 'execute props)))))
13459 (let ((gnus-current-article (gnus-summary-article-number)))
13460 (run-hooks 'gnus-mark-article-hook)))
13462 (defun gnus-execute-command (command &optional automatic)
13463 (save-excursion
13464 (gnus-article-setup-buffer)
13465 (set-buffer gnus-article-buffer)
13466 (setq buffer-read-only nil)
13467 (let ((command (if automatic command (read-string "Command: " command)))
13468 ;; Just binding this here doesn't help, because there might
13469 ;; be output from the process after exiting the scope of
13470 ;; this `let'.
13471 ;; (buffer-read-only nil)
13473 (erase-buffer)
13474 (insert "$ " command "\n\n")
13475 (if gnus-view-pseudo-asynchronously
13476 (start-process "gnus-execute" nil shell-file-name
13477 shell-command-switch command)
13478 (call-process shell-file-name nil t nil
13479 shell-command-switch command)))))
13481 (defun gnus-copy-file (file &optional to)
13482 "Copy FILE to TO."
13483 (interactive
13484 (list (read-file-name "Copy file: " default-directory)
13485 (read-file-name "Copy file to: " default-directory)))
13486 (gnus-set-global-variables)
13487 (or to (setq to (read-file-name "Copy file to: " default-directory)))
13488 (and (file-directory-p to)
13489 (setq to (concat (file-name-as-directory to)
13490 (file-name-nondirectory file))))
13491 (copy-file file to))
13493 ;; Summary kill commands.
13495 (defun gnus-summary-edit-global-kill (article)
13496 "Edit the \"global\" kill file."
13497 (interactive (list (gnus-summary-article-number)))
13498 (gnus-set-global-variables)
13499 (gnus-group-edit-global-kill article))
13501 (defun gnus-summary-edit-local-kill ()
13502 "Edit a local kill file applied to the current newsgroup."
13503 (interactive)
13504 (gnus-set-global-variables)
13505 (setq gnus-current-headers (gnus-summary-article-header))
13506 (gnus-set-global-variables)
13507 (gnus-group-edit-local-kill
13508 (gnus-summary-article-number) gnus-newsgroup-name))
13512 ;;; Gnus article mode
13515 (put 'gnus-article-mode 'mode-class 'special)
13517 (if gnus-article-mode-map
13519 (setq gnus-article-mode-map (make-keymap))
13520 (suppress-keymap gnus-article-mode-map)
13522 (gnus-define-keys gnus-article-mode-map
13523 " " gnus-article-goto-next-page
13524 "\177" gnus-article-goto-prev-page
13525 [delete] gnus-article-goto-prev-page
13526 "\C-c^" gnus-article-refer-article
13527 "h" gnus-article-show-summary
13528 "s" gnus-article-show-summary
13529 "\C-c\C-m" gnus-article-mail
13530 "?" gnus-article-describe-briefly
13531 gnus-mouse-2 gnus-article-push-button
13532 "\r" gnus-article-press-button
13533 "\t" gnus-article-next-button
13534 "\M-\t" gnus-article-prev-button
13535 "<" beginning-of-buffer
13536 ">" end-of-buffer
13537 "\C-c\C-i" gnus-info-find-node
13538 "\C-c\C-b" gnus-bug)
13540 (substitute-key-definition
13541 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map))
13543 (defun gnus-article-mode ()
13544 "Major mode for displaying an article.
13546 All normal editing commands are switched off.
13548 The following commands are available:
13550 \\<gnus-article-mode-map>
13551 \\[gnus-article-next-page]\t Scroll the article one page forwards
13552 \\[gnus-article-prev-page]\t Scroll the article one page backwards
13553 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
13554 \\[gnus-article-show-summary]\t Display the summary buffer
13555 \\[gnus-article-mail]\t Send a reply to the address near point
13556 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
13557 \\[gnus-info-find-node]\t Go to the Gnus info node"
13558 (interactive)
13559 (when (and menu-bar-mode
13560 (gnus-visual-p 'article-menu 'menu))
13561 (gnus-article-make-menu-bar))
13562 (kill-all-local-variables)
13563 (gnus-simplify-mode-line)
13564 (setq mode-name "Article")
13565 (setq major-mode 'gnus-article-mode)
13566 (make-local-variable 'minor-mode-alist)
13567 (or (assq 'gnus-show-mime minor-mode-alist)
13568 (setq minor-mode-alist
13569 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
13570 (use-local-map gnus-article-mode-map)
13571 (make-local-variable 'page-delimiter)
13572 (setq page-delimiter gnus-page-delimiter)
13573 (buffer-disable-undo (current-buffer))
13574 (setq buffer-read-only t) ;Disable modification
13575 (run-hooks 'gnus-article-mode-hook))
13577 (defun gnus-article-setup-buffer ()
13578 "Initialize the article buffer."
13579 (let* ((name (if gnus-single-article-buffer "*Article*"
13580 (concat "*Article " gnus-newsgroup-name "*")))
13581 (original
13582 (progn (string-match "\\*Article" name)
13583 (concat " *Original Article"
13584 (substring name (match-end 0))))))
13585 (setq gnus-article-buffer name)
13586 (setq gnus-original-article-buffer original)
13587 ;; This might be a variable local to the summary buffer.
13588 (unless gnus-single-article-buffer
13589 (save-excursion
13590 (set-buffer gnus-summary-buffer)
13591 (setq gnus-article-buffer name)
13592 (setq gnus-original-article-buffer original)
13593 (gnus-set-global-variables))
13594 (make-local-variable 'gnus-summary-buffer))
13595 ;; Init original article buffer.
13596 (save-excursion
13597 (set-buffer (get-buffer-create gnus-original-article-buffer))
13598 (buffer-disable-undo (current-buffer))
13599 (setq major-mode 'gnus-original-article-mode)
13600 (make-local-variable 'gnus-original-article))
13601 (if (get-buffer name)
13602 (save-excursion
13603 (set-buffer name)
13604 (buffer-disable-undo (current-buffer))
13605 (setq buffer-read-only t)
13606 (gnus-add-current-to-buffer-list)
13607 (or (eq major-mode 'gnus-article-mode)
13608 (gnus-article-mode))
13609 (current-buffer))
13610 (save-excursion
13611 (set-buffer (get-buffer-create name))
13612 (gnus-add-current-to-buffer-list)
13613 (gnus-article-mode)
13614 (current-buffer)))))
13616 ;; Set article window start at LINE, where LINE is the number of lines
13617 ;; from the head of the article.
13618 (defun gnus-article-set-window-start (&optional line)
13619 (set-window-start
13620 (get-buffer-window gnus-article-buffer t)
13621 (save-excursion
13622 (set-buffer gnus-article-buffer)
13623 (goto-char (point-min))
13624 (if (not line)
13625 (point-min)
13626 (gnus-message 6 "Moved to bookmark")
13627 (search-forward "\n\n" nil t)
13628 (forward-line line)
13629 (point)))))
13631 (defun gnus-kill-all-overlays ()
13632 "Delete all overlays in the current buffer."
13633 (when (fboundp 'overlay-lists)
13634 (let* ((overlayss (overlay-lists))
13635 (buffer-read-only nil)
13636 (overlays (nconc (car overlayss) (cdr overlayss))))
13637 (while overlays
13638 (delete-overlay (pop overlays))))))
13640 (defun gnus-request-article-this-buffer (article group)
13641 "Get an article and insert it into this buffer."
13642 (let (do-update-line)
13643 (prog1
13644 (save-excursion
13645 (erase-buffer)
13646 (gnus-kill-all-overlays)
13647 (setq group (or group gnus-newsgroup-name))
13649 ;; Open server if it has closed.
13650 (gnus-check-server (gnus-find-method-for-group group))
13652 ;; Using `gnus-request-article' directly will insert the article into
13653 ;; `nntp-server-buffer' - so we'll save some time by not having to
13654 ;; copy it from the server buffer into the article buffer.
13656 ;; We only request an article by message-id when we do not have the
13657 ;; headers for it, so we'll have to get those.
13658 (when (stringp article)
13659 (let ((gnus-override-method gnus-refer-article-method))
13660 (gnus-read-header article)))
13662 ;; If the article number is negative, that means that this article
13663 ;; doesn't belong in this newsgroup (possibly), so we find its
13664 ;; message-id and request it by id instead of number.
13665 (when (and (numberp article)
13666 gnus-summary-buffer
13667 (get-buffer gnus-summary-buffer)
13668 (buffer-name (get-buffer gnus-summary-buffer)))
13669 (save-excursion
13670 (set-buffer gnus-summary-buffer)
13671 (let ((header (gnus-summary-article-header article)))
13672 (if (< article 0)
13673 (cond
13674 ((memq article gnus-newsgroup-sparse)
13675 ;; This is a sparse gap article.
13676 (setq do-update-line article)
13677 (setq article (mail-header-id header))
13678 (let ((gnus-override-method gnus-refer-article-method))
13679 (gnus-read-header article))
13680 (setq gnus-newsgroup-sparse
13681 (delq article gnus-newsgroup-sparse)))
13682 ((vectorp header)
13683 ;; It's a real article.
13684 (setq article (mail-header-id header)))
13686 ;; It is an extracted pseudo-article.
13687 (setq article 'pseudo)
13688 (gnus-request-pseudo-article header))))
13690 (let ((method (gnus-find-method-for-group
13691 gnus-newsgroup-name)))
13692 (if (not (eq (car method) 'nneething))
13694 (let ((dir (concat (file-name-as-directory (nth 1 method))
13695 (mail-header-subject header))))
13696 (if (file-directory-p dir)
13697 (progn
13698 (setq article 'nneething)
13699 (gnus-group-enter-directory dir)))))))))
13701 (cond
13702 ;; Refuse to select canceled articles.
13703 ((and (numberp article)
13704 gnus-summary-buffer
13705 (get-buffer gnus-summary-buffer)
13706 (buffer-name (get-buffer gnus-summary-buffer))
13707 (eq (cdr (save-excursion
13708 (set-buffer gnus-summary-buffer)
13709 (assq article gnus-newsgroup-reads)))
13710 gnus-canceled-mark))
13711 nil)
13712 ;; We first check `gnus-original-article-buffer'.
13713 ((and (get-buffer gnus-original-article-buffer)
13714 (numberp article)
13715 (save-excursion
13716 (set-buffer gnus-original-article-buffer)
13717 (and (equal (car gnus-original-article) group)
13718 (eq (cdr gnus-original-article) article))))
13719 (insert-buffer-substring gnus-original-article-buffer)
13720 'article)
13721 ;; Check the backlog.
13722 ((and gnus-keep-backlog
13723 (gnus-backlog-request-article group article (current-buffer)))
13724 'article)
13725 ;; Check the cache.
13726 ((and gnus-use-cache
13727 (numberp article)
13728 (gnus-cache-request-article article group))
13729 'article)
13730 ;; Get the article and put into the article buffer.
13731 ((or (stringp article) (numberp article))
13732 (let ((gnus-override-method
13733 (and (stringp article) gnus-refer-article-method))
13734 (buffer-read-only nil))
13735 (erase-buffer)
13736 (gnus-kill-all-overlays)
13737 (if (gnus-request-article article group (current-buffer))
13738 (progn
13739 (and gnus-keep-backlog
13740 (numberp article)
13741 (gnus-backlog-enter-article
13742 group article (current-buffer)))
13743 'article))))
13744 ;; It was a pseudo.
13745 (t article)))
13747 ;; Take the article from the original article buffer
13748 ;; and place it in the buffer it's supposed to be in.
13749 (when (and (get-buffer gnus-article-buffer)
13750 ;;(numberp article)
13751 (equal (buffer-name (current-buffer))
13752 (buffer-name (get-buffer gnus-article-buffer))))
13753 (save-excursion
13754 (if (get-buffer gnus-original-article-buffer)
13755 (set-buffer (get-buffer gnus-original-article-buffer))
13756 (set-buffer (get-buffer-create gnus-original-article-buffer))
13757 (buffer-disable-undo (current-buffer))
13758 (setq major-mode 'gnus-original-article-mode)
13759 (setq buffer-read-only t)
13760 (gnus-add-current-to-buffer-list))
13761 (let (buffer-read-only)
13762 (erase-buffer)
13763 (insert-buffer-substring gnus-article-buffer))
13764 (setq gnus-original-article (cons group article))))
13766 ;; Update sparse articles.
13767 (when (and do-update-line
13768 (or (numberp article)
13769 (stringp article)))
13770 (let ((buf (current-buffer)))
13771 (set-buffer gnus-summary-buffer)
13772 (gnus-summary-update-article do-update-line)
13773 (gnus-summary-goto-subject do-update-line nil t)
13774 (set-window-point (get-buffer-window (current-buffer) t)
13775 (point))
13776 (set-buffer buf))))))
13778 (defun gnus-read-header (id &optional header)
13779 "Read the headers of article ID and enter them into the Gnus system."
13780 (let ((group gnus-newsgroup-name)
13781 (gnus-override-method
13782 (and (gnus-news-group-p gnus-newsgroup-name)
13783 gnus-refer-article-method))
13784 where)
13785 ;; First we check to see whether the header in question is already
13786 ;; fetched.
13787 (if (stringp id)
13788 ;; This is a Message-ID.
13789 (setq header (or header (gnus-id-to-header id)))
13790 ;; This is an article number.
13791 (setq header (or header (gnus-summary-article-header id))))
13792 (if (and header
13793 (not (memq (mail-header-number header) gnus-newsgroup-sparse)))
13794 ;; We have found the header.
13795 header
13796 ;; We have to really fetch the header to this article.
13797 (when (setq where (gnus-request-head id group))
13798 (save-excursion
13799 (set-buffer nntp-server-buffer)
13800 (goto-char (point-max))
13801 (insert ".\n")
13802 (goto-char (point-min))
13803 (insert "211 ")
13804 (princ (cond
13805 ((numberp id) id)
13806 ((cdr where) (cdr where))
13807 (header (mail-header-number header))
13808 (t gnus-reffed-article-number))
13809 (current-buffer))
13810 (insert " Article retrieved.\n"))
13811 ;(when (and header
13812 ; (memq (mail-header-number header) gnus-newsgroup-sparse))
13813 ; (setcar (gnus-id-to-thread id) nil))
13814 (if (not (setq header (car (gnus-get-newsgroup-headers))))
13815 () ; Malformed head.
13816 (unless (memq (mail-header-number header) gnus-newsgroup-sparse)
13817 (if (and (stringp id)
13818 (not (string= (gnus-group-real-name group)
13819 (car where))))
13820 ;; If we fetched by Message-ID and the article came
13821 ;; from a different group, we fudge some bogus article
13822 ;; numbers for this article.
13823 (mail-header-set-number header gnus-reffed-article-number))
13824 (decf gnus-reffed-article-number)
13825 (gnus-remove-header (mail-header-number header))
13826 (push header gnus-newsgroup-headers)
13827 (setq gnus-current-headers header)
13828 (push (mail-header-number header) gnus-newsgroup-limit))
13829 header)))))
13831 (defun gnus-remove-header (number)
13832 "Remove header NUMBER from `gnus-newsgroup-headers'."
13833 (if (and gnus-newsgroup-headers
13834 (= number (mail-header-number (car gnus-newsgroup-headers))))
13835 (pop gnus-newsgroup-headers)
13836 (let ((headers gnus-newsgroup-headers))
13837 (while (and (cdr headers)
13838 (not (= number (mail-header-number (cadr headers)))))
13839 (pop headers))
13840 (when (cdr headers)
13841 (setcdr headers (cddr headers))))))
13843 (defun gnus-article-prepare (article &optional all-headers header)
13844 "Prepare ARTICLE in article mode buffer.
13845 ARTICLE should either be an article number or a Message-ID.
13846 If ARTICLE is an id, HEADER should be the article headers.
13847 If ALL-HEADERS is non-nil, no headers are hidden."
13848 (save-excursion
13849 ;; Make sure we start in a summary buffer.
13850 (unless (eq major-mode 'gnus-summary-mode)
13851 (set-buffer gnus-summary-buffer))
13852 (setq gnus-summary-buffer (current-buffer))
13853 ;; Make sure the connection to the server is alive.
13854 (unless (gnus-server-opened
13855 (gnus-find-method-for-group gnus-newsgroup-name))
13856 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
13857 (gnus-request-group gnus-newsgroup-name t))
13858 (let* ((article (if header (mail-header-number header) article))
13859 (summary-buffer (current-buffer))
13860 (internal-hook gnus-article-internal-prepare-hook)
13861 (group gnus-newsgroup-name)
13862 result)
13863 (save-excursion
13864 (gnus-article-setup-buffer)
13865 (set-buffer gnus-article-buffer)
13866 ;; Deactivate active regions.
13867 (when (and (boundp 'transient-mark-mode)
13868 transient-mark-mode)
13869 (setq mark-active nil))
13870 (if (not (setq result (let ((buffer-read-only nil))
13871 (gnus-request-article-this-buffer
13872 article group))))
13873 ;; There is no such article.
13874 (save-excursion
13875 (when (and (numberp article)
13876 (not (memq article gnus-newsgroup-sparse)))
13877 (setq gnus-article-current
13878 (cons gnus-newsgroup-name article))
13879 (set-buffer gnus-summary-buffer)
13880 (setq gnus-current-article article)
13881 (gnus-summary-mark-article article gnus-canceled-mark))
13882 (unless (memq article gnus-newsgroup-sparse)
13883 (gnus-error
13884 1 "No such article (may have expired or been canceled)")))
13885 (if (or (eq result 'pseudo) (eq result 'nneething))
13886 (progn
13887 (save-excursion
13888 (set-buffer summary-buffer)
13889 (setq gnus-last-article gnus-current-article
13890 gnus-newsgroup-history (cons gnus-current-article
13891 gnus-newsgroup-history)
13892 gnus-current-article 0
13893 gnus-current-headers nil
13894 gnus-article-current nil)
13895 (if (eq result 'nneething)
13896 (gnus-configure-windows 'summary)
13897 (gnus-configure-windows 'article))
13898 (gnus-set-global-variables))
13899 (gnus-set-mode-line 'article))
13900 ;; The result from the `request' was an actual article -
13901 ;; or at least some text that is now displayed in the
13902 ;; article buffer.
13903 (if (and (numberp article)
13904 (not (eq article gnus-current-article)))
13905 ;; Seems like a new article has been selected.
13906 ;; `gnus-current-article' must be an article number.
13907 (save-excursion
13908 (set-buffer summary-buffer)
13909 (setq gnus-last-article gnus-current-article
13910 gnus-newsgroup-history (cons gnus-current-article
13911 gnus-newsgroup-history)
13912 gnus-current-article article
13913 gnus-current-headers
13914 (gnus-summary-article-header gnus-current-article)
13915 gnus-article-current
13916 (cons gnus-newsgroup-name gnus-current-article))
13917 (unless (vectorp gnus-current-headers)
13918 (setq gnus-current-headers nil))
13919 (gnus-summary-show-thread)
13920 (run-hooks 'gnus-mark-article-hook)
13921 (gnus-set-mode-line 'summary)
13922 (and (gnus-visual-p 'article-highlight 'highlight)
13923 (run-hooks 'gnus-visual-mark-article-hook))
13924 ;; Set the global newsgroup variables here.
13925 ;; Suggested by Jim Sisolak
13926 ;; <sisolak@trans4.neep.wisc.edu>.
13927 (gnus-set-global-variables)
13928 (setq gnus-have-all-headers
13929 (or all-headers gnus-show-all-headers))
13930 (and gnus-use-cache
13931 (vectorp (gnus-summary-article-header article))
13932 (gnus-cache-possibly-enter-article
13933 group article
13934 (gnus-summary-article-header article)
13935 (memq article gnus-newsgroup-marked)
13936 (memq article gnus-newsgroup-dormant)
13937 (memq article gnus-newsgroup-unreads)))))
13938 (when (or (numberp article)
13939 (stringp article))
13940 ;; Hooks for getting information from the article.
13941 ;; This hook must be called before being narrowed.
13942 (let (buffer-read-only)
13943 (run-hooks 'internal-hook)
13944 (run-hooks 'gnus-article-prepare-hook)
13945 ;; Decode MIME message.
13946 (if gnus-show-mime
13947 (if (or (not gnus-strict-mime)
13948 (gnus-fetch-field "Mime-Version"))
13949 (funcall gnus-show-mime-method)
13950 (funcall gnus-decode-encoded-word-method)))
13951 ;; Perform the article display hooks.
13952 (run-hooks 'gnus-article-display-hook))
13953 ;; Do page break.
13954 (goto-char (point-min))
13955 (and gnus-break-pages (gnus-narrow-to-page)))
13956 (gnus-set-mode-line 'article)
13957 (gnus-configure-windows 'article)
13958 (goto-char (point-min))
13959 t))))))
13961 (defun gnus-article-show-all-headers ()
13962 "Show all article headers in article mode buffer."
13963 (save-excursion
13964 (gnus-article-setup-buffer)
13965 (set-buffer gnus-article-buffer)
13966 (let ((buffer-read-only nil))
13967 (gnus-unhide-text (point-min) (point-max)))))
13969 (defun gnus-article-hide-headers-if-wanted ()
13970 "Hide unwanted headers if `gnus-have-all-headers' is nil.
13971 Provided for backwards compatibility."
13972 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers)
13973 gnus-inhibit-hiding
13974 (gnus-article-hide-headers)))
13976 (defsubst gnus-article-header-rank ()
13977 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
13978 (let ((list gnus-sorted-header-list)
13979 (i 0))
13980 (while list
13981 (when (looking-at (car list))
13982 (setq list nil))
13983 (setq list (cdr list))
13984 (incf i))
13987 (defun gnus-article-hide-headers (&optional arg delete)
13988 "Toggle whether to hide unwanted headers and possibly sort them as well.
13989 If given a negative prefix, always show; if given a positive prefix,
13990 always hide."
13991 (interactive (gnus-hidden-arg))
13992 (if (gnus-article-check-hidden-text 'headers arg)
13993 ;; Show boring headers as well.
13994 (gnus-article-show-hidden-text 'boring-headers)
13995 ;; This function might be inhibited.
13996 (unless gnus-inhibit-hiding
13997 (save-excursion
13998 (set-buffer gnus-article-buffer)
13999 (save-restriction
14000 (let ((buffer-read-only nil)
14001 (props (nconc (list 'gnus-type 'headers)
14002 gnus-hidden-properties))
14003 (max (1+ (length gnus-sorted-header-list)))
14004 (ignored (when (not (stringp gnus-visible-headers))
14005 (cond ((stringp gnus-ignored-headers)
14006 gnus-ignored-headers)
14007 ((listp gnus-ignored-headers)
14008 (mapconcat 'identity gnus-ignored-headers
14009 "\\|")))))
14010 (visible
14011 (cond ((stringp gnus-visible-headers)
14012 gnus-visible-headers)
14013 ((and gnus-visible-headers
14014 (listp gnus-visible-headers))
14015 (mapconcat 'identity gnus-visible-headers "\\|"))))
14016 (inhibit-point-motion-hooks t)
14017 want-list beg)
14018 ;; First we narrow to just the headers.
14019 (widen)
14020 (goto-char (point-min))
14021 ;; Hide any "From " lines at the beginning of (mail) articles.
14022 (while (looking-at "From ")
14023 (forward-line 1))
14024 (unless (bobp)
14025 (if delete
14026 (delete-region (point-min) (point))
14027 (gnus-hide-text (point-min) (point) props)))
14028 ;; Then treat the rest of the header lines.
14029 (narrow-to-region
14030 (point)
14031 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
14032 ;; Then we use the two regular expressions
14033 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
14034 ;; select which header lines is to remain visible in the
14035 ;; article buffer.
14036 (goto-char (point-min))
14037 (while (re-search-forward "^[^ \t]*:" nil t)
14038 (beginning-of-line)
14039 ;; We add the headers we want to keep to a list and delete
14040 ;; them from the buffer.
14041 (gnus-put-text-property
14042 (point) (1+ (point)) 'message-rank
14043 (if (or (and visible (looking-at visible))
14044 (and ignored
14045 (not (looking-at ignored))))
14046 (gnus-article-header-rank)
14047 (+ 2 max)))
14048 (forward-line 1))
14049 (message-sort-headers-1)
14050 (when (setq beg (text-property-any
14051 (point-min) (point-max) 'message-rank (+ 2 max)))
14052 ;; We make the unwanted headers invisible.
14053 (if delete
14054 (delete-region beg (point-max))
14055 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
14056 (gnus-hide-text-type beg (point-max) 'headers))
14057 ;; Work around XEmacs lossage.
14058 (gnus-put-text-property (point-min) beg 'invisible nil))))))))
14060 (defun gnus-article-hide-boring-headers (&optional arg)
14061 "Toggle hiding of headers that aren't very interesting.
14062 If given a negative prefix, always show; if given a positive prefix,
14063 always hide."
14064 (interactive (gnus-hidden-arg))
14065 (unless (gnus-article-check-hidden-text 'boring-headers arg)
14066 (save-excursion
14067 (set-buffer gnus-article-buffer)
14068 (save-restriction
14069 (let ((buffer-read-only nil)
14070 (list gnus-boring-article-headers)
14071 (inhibit-point-motion-hooks t)
14072 elem)
14073 (nnheader-narrow-to-headers)
14074 (while list
14075 (setq elem (pop list))
14076 (goto-char (point-min))
14077 (cond
14078 ;; Hide empty headers.
14079 ((eq elem 'empty)
14080 (while (re-search-forward "^[^:]+:[ \t]\n[^ \t]" nil t)
14081 (forward-line -1)
14082 (gnus-hide-text-type
14083 (progn (beginning-of-line) (point))
14084 (progn
14085 (end-of-line)
14086 (if (re-search-forward "^[^ \t]" nil t)
14087 (match-beginning 0)
14088 (point-max)))
14089 'boring-headers)))
14090 ;; Hide boring Newsgroups header.
14091 ((eq elem 'newsgroups)
14092 (when (equal (message-fetch-field "newsgroups")
14093 (gnus-group-real-name gnus-newsgroup-name))
14094 (gnus-article-hide-header "newsgroups")))
14095 ((eq elem 'followup-to)
14096 (when (equal (message-fetch-field "followup-to")
14097 (message-fetch-field "newsgroups"))
14098 (gnus-article-hide-header "followup-to")))
14099 ((eq elem 'reply-to)
14100 (let ((from (message-fetch-field "from"))
14101 (reply-to (message-fetch-field "reply-to")))
14102 (when (and
14103 from reply-to
14104 (equal
14105 (nth 1 (funcall gnus-extract-address-components from))
14106 (nth 1 (funcall gnus-extract-address-components
14107 reply-to))))
14108 (gnus-article-hide-header "reply-to"))))
14109 ((eq elem 'date)
14110 (let ((date (message-fetch-field "date")))
14111 (when (and date
14112 (< (gnus-days-between date (current-time-string))
14114 (gnus-article-hide-header "date")))))))))))
14116 (defun gnus-article-hide-header (header)
14117 (save-excursion
14118 (goto-char (point-min))
14119 (when (re-search-forward (concat "^" header ":") nil t)
14120 (gnus-hide-text-type
14121 (progn (beginning-of-line) (point))
14122 (progn
14123 (end-of-line)
14124 (if (re-search-forward "^[^ \t]" nil t)
14125 (match-beginning 0)
14126 (point-max)))
14127 'boring-headers))))
14129 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
14130 (defun gnus-article-treat-overstrike ()
14131 "Translate overstrikes into bold text."
14132 (interactive)
14133 (save-excursion
14134 (set-buffer gnus-article-buffer)
14135 (let ((buffer-read-only nil))
14136 (while (search-forward "\b" nil t)
14137 (let ((next (following-char))
14138 (previous (char-after (- (point) 2))))
14139 (cond
14140 ((eq next previous)
14141 (gnus-put-text-property (- (point) 2) (point) 'invisible t)
14142 (gnus-put-text-property (point) (1+ (point)) 'face 'bold))
14143 ((eq next ?_)
14144 (gnus-put-text-property (1- (point)) (1+ (point)) 'invisible t)
14145 (gnus-put-text-property
14146 (- (point) 2) (1- (point)) 'face 'underline))
14147 ((eq previous ?_)
14148 (gnus-put-text-property (- (point) 2) (point) 'invisible t)
14149 (gnus-put-text-property
14150 (point) (1+ (point)) 'face 'underline))))))))
14152 (defun gnus-article-word-wrap ()
14153 "Format too long lines."
14154 (interactive)
14155 (save-excursion
14156 (set-buffer gnus-article-buffer)
14157 (let ((buffer-read-only nil))
14158 (widen)
14159 (goto-char (point-min))
14160 (search-forward "\n\n" nil t)
14161 (end-of-line 1)
14162 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
14163 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
14164 (adaptive-fill-mode t))
14165 (while (not (eobp))
14166 (and (>= (current-column) (min fill-column (window-width)))
14167 (/= (preceding-char) ?:)
14168 (fill-paragraph nil))
14169 (end-of-line 2))))))
14171 (defun gnus-article-remove-cr ()
14172 "Remove carriage returns from an article."
14173 (interactive)
14174 (save-excursion
14175 (set-buffer gnus-article-buffer)
14176 (let ((buffer-read-only nil))
14177 (goto-char (point-min))
14178 (while (search-forward "\r" nil t)
14179 (replace-match "" t t)))))
14181 (defun gnus-article-remove-trailing-blank-lines ()
14182 "Remove all trailing blank lines from the article."
14183 (interactive)
14184 (save-excursion
14185 (set-buffer gnus-article-buffer)
14186 (let ((buffer-read-only nil))
14187 (goto-char (point-max))
14188 (delete-region
14189 (point)
14190 (progn
14191 (while (looking-at "^[ \t]*$")
14192 (forward-line -1))
14193 (forward-line 1)
14194 (point))))))
14196 (defun gnus-article-display-x-face (&optional force)
14197 "Look for an X-Face header and display it if present."
14198 (interactive (list 'force))
14199 (save-excursion
14200 (set-buffer gnus-article-buffer)
14201 ;; Delete the old process, if any.
14202 (when (process-status "gnus-x-face")
14203 (delete-process "gnus-x-face"))
14204 (let ((inhibit-point-motion-hooks t)
14205 (case-fold-search nil)
14206 from)
14207 (save-restriction
14208 (nnheader-narrow-to-headers)
14209 (setq from (message-fetch-field "from"))
14210 (goto-char (point-min))
14211 (when (and gnus-article-x-face-command
14212 (or force
14213 ;; Check whether this face is censored.
14214 (not gnus-article-x-face-too-ugly)
14215 (and gnus-article-x-face-too-ugly from
14216 (not (string-match gnus-article-x-face-too-ugly
14217 from))))
14218 ;; Has to be present.
14219 (re-search-forward "^X-Face: " nil t))
14220 ;; We now have the area of the buffer where the X-Face is stored.
14221 (let ((beg (point))
14222 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
14223 ;; We display the face.
14224 (if (symbolp gnus-article-x-face-command)
14225 ;; The command is a lisp function, so we call it.
14226 (if (gnus-functionp gnus-article-x-face-command)
14227 (funcall gnus-article-x-face-command beg end)
14228 (error "%s is not a function" gnus-article-x-face-command))
14229 ;; The command is a string, so we interpret the command
14230 ;; as a, well, command, and fork it off.
14231 (let ((process-connection-type nil))
14232 (process-kill-without-query
14233 (start-process
14234 "gnus-x-face" nil shell-file-name shell-command-switch
14235 gnus-article-x-face-command))
14236 (process-send-region "gnus-x-face" beg end)
14237 (process-send-eof "gnus-x-face")))))))))
14239 (defalias 'gnus-headers-decode-quoted-printable 'gnus-decode-rfc1522)
14240 (defun gnus-decode-rfc1522 ()
14241 "Hack to remove QP encoding from headers."
14242 (let ((case-fold-search t)
14243 (inhibit-point-motion-hooks t)
14244 (buffer-read-only nil)
14245 string)
14246 (save-restriction
14247 (narrow-to-region
14248 (goto-char (point-min))
14249 (or (search-forward "\n\n" nil t) (point-max)))
14251 (while (re-search-forward
14252 "=\\?iso-8859-1\\?q\\?\\([^?\t\n]*\\)\\?=" nil t)
14253 (setq string (match-string 1))
14254 (narrow-to-region (match-beginning 0) (match-end 0))
14255 (delete-region (point-min) (point-max))
14256 (insert string)
14257 (gnus-mime-decode-quoted-printable (goto-char (point-min)) (point-max))
14258 (subst-char-in-region (point-min) (point-max) ?_ ? )
14259 (widen)
14260 (goto-char (point-min))))))
14262 (defun gnus-article-de-quoted-unreadable (&optional force)
14263 "Do a naive translation of a quoted-printable-encoded article.
14264 This is in no way, shape or form meant as a replacement for real MIME
14265 processing, but is simply a stop-gap measure until MIME support is
14266 written.
14267 If FORCE, decode the article whether it is marked as quoted-printable
14268 or not."
14269 (interactive (list 'force))
14270 (save-excursion
14271 (set-buffer gnus-article-buffer)
14272 (let ((case-fold-search t)
14273 (buffer-read-only nil)
14274 (type (gnus-fetch-field "content-transfer-encoding")))
14275 (gnus-decode-rfc1522)
14276 (when (or force
14277 (and type (string-match "quoted-printable" (downcase type))))
14278 (goto-char (point-min))
14279 (search-forward "\n\n" nil 'move)
14280 (gnus-mime-decode-quoted-printable (point) (point-max))))))
14282 (defun gnus-mime-decode-quoted-printable (from to)
14283 "Decode Quoted-Printable in the region between FROM and TO."
14284 (interactive "r")
14285 (goto-char from)
14286 (while (search-forward "=" to t)
14287 (cond ((eq (following-char) ?\n)
14288 (delete-char -1)
14289 (delete-char 1))
14290 ((looking-at "[0-9A-F][0-9A-F]")
14291 (subst-char-in-region
14292 (1- (point)) (point) ?=
14293 (hexl-hex-string-to-integer
14294 (buffer-substring (point) (+ 2 (point)))))
14295 (delete-char 2))
14296 ((looking-at "=")
14297 (delete-char 1))
14298 ((gnus-message 3 "Malformed MIME quoted-printable message")))))
14300 (defun gnus-article-hide-pgp (&optional arg)
14301 "Toggle hiding of any PGP headers and signatures in the current article.
14302 If given a negative prefix, always show; if given a positive prefix,
14303 always hide."
14304 (interactive (gnus-hidden-arg))
14305 (unless (gnus-article-check-hidden-text 'pgp arg)
14306 (save-excursion
14307 (set-buffer gnus-article-buffer)
14308 (let ((props (nconc (list 'gnus-type 'pgp) gnus-hidden-properties))
14309 buffer-read-only beg end)
14310 (widen)
14311 (goto-char (point-min))
14312 ;; Hide the "header".
14313 (and (search-forward "\n-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
14314 (gnus-hide-text (match-beginning 0) (match-end 0) props))
14315 (setq beg (point))
14316 ;; Hide the actual signature.
14317 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
14318 (setq end (1+ (match-beginning 0)))
14319 (gnus-hide-text
14321 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
14322 (match-end 0)
14323 ;; Perhaps we shouldn't hide to the end of the buffer
14324 ;; if there is no end to the signature?
14325 (point-max))
14326 props))
14327 ;; Hide "- " PGP quotation markers.
14328 (when (and beg end)
14329 (narrow-to-region beg end)
14330 (goto-char (point-min))
14331 (while (re-search-forward "^- " nil t)
14332 (gnus-hide-text (match-beginning 0) (match-end 0) props))
14333 (widen))))))
14335 (defun gnus-article-hide-signature (&optional arg)
14336 "Hide the signature in the current article.
14337 If given a negative prefix, always show; if given a positive prefix,
14338 always hide."
14339 (interactive (gnus-hidden-arg))
14340 (unless (gnus-article-check-hidden-text 'signature arg)
14341 (save-excursion
14342 (set-buffer gnus-article-buffer)
14343 (save-restriction
14344 (let ((buffer-read-only nil))
14345 (when (gnus-narrow-to-signature)
14346 (gnus-hide-text-type (point-min) (point-max) 'signature)))))))
14348 (defun gnus-article-strip-leading-blank-lines ()
14349 "Remove all blank lines from the beginning of the article."
14350 (interactive)
14351 (save-excursion
14352 (set-buffer gnus-article-buffer)
14353 (let (buffer-read-only)
14354 (goto-char (point-min))
14355 (when (search-forward "\n\n" nil t)
14356 (while (looking-at "[ \t]$")
14357 (gnus-delete-line))))))
14359 (defvar mime::preview/content-list)
14360 (defvar mime::preview-content-info/point-min)
14361 (defun gnus-narrow-to-signature ()
14362 "Narrow to the signature."
14363 (widen)
14364 (if (and (boundp 'mime::preview/content-list)
14365 mime::preview/content-list)
14366 (let ((pcinfo (car (last mime::preview/content-list))))
14367 (condition-case ()
14368 (narrow-to-region
14369 (funcall (intern "mime::preview-content-info/point-min") pcinfo)
14370 (point-max))
14371 (error nil))))
14372 (goto-char (point-max))
14373 (when (re-search-backward gnus-signature-separator nil t)
14374 (forward-line 1)
14375 (when (or (null gnus-signature-limit)
14376 (and (numberp gnus-signature-limit)
14377 (< (- (point-max) (point)) gnus-signature-limit))
14378 (and (gnus-functionp gnus-signature-limit)
14379 (funcall gnus-signature-limit))
14380 (and (stringp gnus-signature-limit)
14381 (not (re-search-forward gnus-signature-limit nil t))))
14382 (narrow-to-region (point) (point-max))
14383 t)))
14385 (defun gnus-hidden-arg ()
14386 "Return the current prefix arg as a number, or 0 if no prefix."
14387 (list (if current-prefix-arg
14388 (prefix-numeric-value current-prefix-arg)
14389 0)))
14391 (defun gnus-article-check-hidden-text (type arg)
14392 "Return nil if hiding is necessary.
14393 Arg can be nil or a number. Nil and positive means hide, negative
14394 means show, 0 means toggle."
14395 (save-excursion
14396 (set-buffer gnus-article-buffer)
14397 (let ((hide (gnus-article-hidden-text-p type)))
14398 (cond
14399 ((or (null arg)
14400 (> arg 0))
14401 nil)
14402 ((< arg 0)
14403 (gnus-article-show-hidden-text type))
14405 (if (eq hide 'hidden)
14406 (gnus-article-show-hidden-text type)
14407 nil))))))
14409 (defun gnus-article-hidden-text-p (type)
14410 "Say whether the current buffer contains hidden text of type TYPE."
14411 (let ((pos (text-property-any (point-min) (point-max) 'gnus-type type)))
14412 (when pos
14413 (if (get-text-property pos 'invisible)
14414 'hidden
14415 'shown))))
14417 (defun gnus-article-hide (&optional arg force)
14418 "Hide all the gruft in the current article.
14419 This means that PGP stuff, signatures, cited text and (some)
14420 headers will be hidden.
14421 If given a prefix, show the hidden text instead."
14422 (interactive (list current-prefix-arg 'force))
14423 (gnus-article-hide-headers arg)
14424 (gnus-article-hide-pgp arg)
14425 (gnus-article-hide-citation-maybe arg force)
14426 (gnus-article-hide-signature arg))
14428 (defun gnus-article-show-hidden-text (type &optional hide)
14429 "Show all hidden text of type TYPE.
14430 If HIDE, hide the text instead."
14431 (save-excursion
14432 (set-buffer gnus-article-buffer)
14433 (let ((buffer-read-only nil)
14434 (inhibit-point-motion-hooks t)
14435 (beg (point-min)))
14436 (while (gnus-goto-char (text-property-any
14437 beg (point-max) 'gnus-type type))
14438 (setq beg (point))
14439 (forward-char)
14440 (if hide
14441 (gnus-hide-text beg (point) gnus-hidden-properties)
14442 (gnus-unhide-text beg (point)))
14443 (setq beg (point)))
14444 t)))
14446 (defvar gnus-article-time-units
14447 `((year . ,(* 365.25 24 60 60))
14448 (week . ,(* 7 24 60 60))
14449 (day . ,(* 24 60 60))
14450 (hour . ,(* 60 60))
14451 (minute . 60)
14452 (second . 1))
14453 "Mapping from time units to seconds.")
14455 (defun gnus-article-date-ut (&optional type highlight)
14456 "Convert DATE date to universal time in the current article.
14457 If TYPE is `local', convert to local time; if it is `lapsed', output
14458 how much time has lapsed since DATE."
14459 (interactive (list 'ut t))
14460 (let* ((header (or gnus-current-headers
14461 (gnus-summary-article-header) ""))
14462 (date (and (vectorp header) (mail-header-date header)))
14463 (date-regexp "^Date: \\|^X-Sent: ")
14464 (now (current-time))
14465 (inhibit-point-motion-hooks t)
14466 bface eface)
14467 (when (and date (not (string= date "")))
14468 (save-excursion
14469 (set-buffer gnus-article-buffer)
14470 (save-restriction
14471 (nnheader-narrow-to-headers)
14472 (let ((buffer-read-only nil))
14473 ;; Delete any old Date headers.
14474 (if (re-search-forward date-regexp nil t)
14475 (progn
14476 (setq bface (get-text-property (gnus-point-at-bol) 'face)
14477 eface (get-text-property (1- (gnus-point-at-eol))
14478 'face))
14479 (message-remove-header date-regexp t)
14480 (beginning-of-line))
14481 (goto-char (point-max)))
14482 (insert (gnus-make-date-line date type))
14483 ;; Do highlighting.
14484 (forward-line -1)
14485 (when (and (gnus-visual-p 'article-highlight 'highlight)
14486 (looking-at "\\([^:]+\\): *\\(.*\\)$"))
14487 (gnus-put-text-property (match-beginning 1) (match-end 1)
14488 'face bface)
14489 (gnus-put-text-property (match-beginning 2) (match-end 2)
14490 'face eface))))))))
14492 (defun gnus-make-date-line (date type)
14493 "Return a DATE line of TYPE."
14494 (cond
14495 ;; Convert to the local timezone. We have to slap a
14496 ;; `condition-case' round the calls to the timezone
14497 ;; functions since they aren't particularly resistant to
14498 ;; buggy dates.
14499 ((eq type 'local)
14500 (concat "Date: " (condition-case ()
14501 (timezone-make-date-arpa-standard date)
14502 (error date))
14503 "\n"))
14504 ;; Convert to Universal Time.
14505 ((eq type 'ut)
14506 (concat "Date: "
14507 (condition-case ()
14508 (timezone-make-date-arpa-standard date nil "UT")
14509 (error date))
14510 "\n"))
14511 ;; Get the original date from the article.
14512 ((eq type 'original)
14513 (concat "Date: " date "\n"))
14514 ;; Do an X-Sent lapsed format.
14515 ((eq type 'lapsed)
14516 ;; If the date is seriously mangled, the timezone
14517 ;; functions are liable to bug out, so we condition-case
14518 ;; the entire thing.
14519 (let* ((now (current-time))
14520 (real-time
14521 (condition-case ()
14522 (gnus-time-minus
14523 (gnus-encode-date
14524 (timezone-make-date-arpa-standard
14525 (current-time-string now)
14526 (current-time-zone now) "UT"))
14527 (gnus-encode-date
14528 (timezone-make-date-arpa-standard
14529 date nil "UT")))
14530 (error '(0 0))))
14531 (real-sec (+ (* (float (car real-time)) 65536)
14532 (cadr real-time)))
14533 (sec (abs real-sec))
14534 num prev)
14535 (cond
14536 ((equal real-time '(0 0))
14537 "X-Sent: Unknown\n")
14538 ((zerop sec)
14539 "X-Sent: Now\n")
14541 (concat
14542 "X-Sent: "
14543 ;; This is a bit convoluted, but basically we go
14544 ;; through the time units for years, weeks, etc,
14545 ;; and divide things to see whether that results
14546 ;; in positive answers.
14547 (mapconcat
14548 (lambda (unit)
14549 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
14550 ;; The (remaining) seconds are too few to
14551 ;; be divided into this time unit.
14553 ;; It's big enough, so we output it.
14554 (setq sec (- sec (* num (cdr unit))))
14555 (prog1
14556 (concat (if prev ", " "") (int-to-string
14557 (floor num))
14558 " " (symbol-name (car unit))
14559 (if (> num 1) "s" ""))
14560 (setq prev t))))
14561 gnus-article-time-units "")
14562 ;; If dates are odd, then it might appear like the
14563 ;; article was sent in the future.
14564 (if (> real-sec 0)
14565 " ago\n"
14566 " in the future\n"))))))
14568 (error "Unknown conversion type: %s" type))))
14570 (defun gnus-article-date-local (&optional highlight)
14571 "Convert the current article date to the local timezone."
14572 (interactive (list t))
14573 (gnus-article-date-ut 'local highlight))
14575 (defun gnus-article-date-original (&optional highlight)
14576 "Convert the current article date to what it was originally.
14577 This is only useful if you have used some other date conversion
14578 function and want to see what the date was before converting."
14579 (interactive (list t))
14580 (gnus-article-date-ut 'original highlight))
14582 (defun gnus-article-date-lapsed (&optional highlight)
14583 "Convert the current article date to time lapsed since it was sent."
14584 (interactive (list t))
14585 (gnus-article-date-ut 'lapsed highlight))
14587 (defun gnus-article-maybe-highlight ()
14588 "Do some article highlighting if `gnus-visual' is non-nil."
14589 (if (gnus-visual-p 'article-highlight 'highlight)
14590 (gnus-article-highlight-some)))
14592 ;;; Article savers.
14594 (defun gnus-output-to-rmail (file-name)
14595 "Append the current article to an Rmail file named FILE-NAME."
14596 (require 'rmail)
14597 ;; Most of these codes are borrowed from rmailout.el.
14598 (setq file-name (expand-file-name file-name))
14599 (setq rmail-default-rmail-file file-name)
14600 (let ((artbuf (current-buffer))
14601 (tmpbuf (get-buffer-create " *Gnus-output*")))
14602 (save-excursion
14603 (or (get-file-buffer file-name)
14604 (file-exists-p file-name)
14605 (if (gnus-yes-or-no-p
14606 (concat "\"" file-name "\" does not exist, create it? "))
14607 (let ((file-buffer (create-file-buffer file-name)))
14608 (save-excursion
14609 (set-buffer file-buffer)
14610 (rmail-insert-rmail-file-header)
14611 (let ((require-final-newline nil))
14612 (write-region (point-min) (point-max) file-name t 1)))
14613 (kill-buffer file-buffer))
14614 (error "Output file does not exist")))
14615 (set-buffer tmpbuf)
14616 (buffer-disable-undo (current-buffer))
14617 (erase-buffer)
14618 (insert-buffer-substring artbuf)
14619 (gnus-convert-article-to-rmail)
14620 ;; Decide whether to append to a file or to an Emacs buffer.
14621 (let ((outbuf (get-file-buffer file-name)))
14622 (if (not outbuf)
14623 (append-to-file (point-min) (point-max) file-name)
14624 ;; File has been visited, in buffer OUTBUF.
14625 (set-buffer outbuf)
14626 (let ((buffer-read-only nil)
14627 (msg (and (boundp 'rmail-current-message)
14628 (symbol-value 'rmail-current-message))))
14629 ;; If MSG is non-nil, buffer is in RMAIL mode.
14630 (if msg
14631 (progn (widen)
14632 (narrow-to-region (point-max) (point-max))))
14633 (insert-buffer-substring tmpbuf)
14634 (if msg
14635 (progn
14636 (goto-char (point-min))
14637 (widen)
14638 (search-backward "\^_")
14639 (narrow-to-region (point) (point-max))
14640 (goto-char (1+ (point-min)))
14641 (rmail-count-new-messages t)
14642 (rmail-show-message msg)))))))
14643 (kill-buffer tmpbuf)))
14645 (defun gnus-output-to-file (file-name)
14646 "Append the current article to a file named FILE-NAME."
14647 (let ((artbuf (current-buffer)))
14648 (nnheader-temp-write nil
14649 (insert-buffer-substring artbuf)
14650 ;; Append newline at end of the buffer as separator, and then
14651 ;; save it to file.
14652 (goto-char (point-max))
14653 (insert "\n")
14654 (append-to-file (point-min) (point-max) file-name))))
14656 (defun gnus-convert-article-to-rmail ()
14657 "Convert article in current buffer to Rmail message format."
14658 (let ((buffer-read-only nil))
14659 ;; Convert article directly into Babyl format.
14660 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
14661 (goto-char (point-min))
14662 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
14663 (while (search-forward "\n\^_" nil t) ;single char
14664 (replace-match "\n^_" t t)) ;2 chars: "^" and "_"
14665 (goto-char (point-max))
14666 (insert "\^_")))
14668 (defun gnus-narrow-to-page (&optional arg)
14669 "Narrow the article buffer to a page.
14670 If given a numerical ARG, move forward ARG pages."
14671 (interactive "P")
14672 (setq arg (if arg (prefix-numeric-value arg) 0))
14673 (save-excursion
14674 (set-buffer gnus-article-buffer)
14675 (goto-char (point-min))
14676 (widen)
14677 (when (gnus-visual-p 'page-marker)
14678 (let ((buffer-read-only nil))
14679 (gnus-remove-text-with-property 'gnus-prev)
14680 (gnus-remove-text-with-property 'gnus-next)))
14681 (when
14682 (cond ((< arg 0)
14683 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
14684 ((> arg 0)
14685 (re-search-forward page-delimiter nil 'move arg)))
14686 (goto-char (match-end 0)))
14687 (narrow-to-region
14688 (point)
14689 (if (re-search-forward page-delimiter nil 'move)
14690 (match-beginning 0)
14691 (point)))
14692 (when (and (gnus-visual-p 'page-marker)
14693 (not (= (point-min) 1)))
14694 (save-excursion
14695 (goto-char (point-min))
14696 (gnus-insert-prev-page-button)))
14697 (when (and (gnus-visual-p 'page-marker)
14698 (not (= (1- (point-max)) (buffer-size))))
14699 (save-excursion
14700 (goto-char (point-max))
14701 (gnus-insert-next-page-button)))))
14703 ;; Article mode commands
14705 (defun gnus-article-goto-next-page ()
14706 "Show the next page of the article."
14707 (interactive)
14708 (when (gnus-article-next-page)
14709 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
14711 (defun gnus-article-goto-prev-page ()
14712 "Show the next page of the article."
14713 (interactive)
14714 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))
14715 (gnus-article-prev-page nil)))
14717 (defun gnus-article-next-page (&optional lines)
14718 "Show the next page of the current article.
14719 If end of article, return non-nil. Otherwise return nil.
14720 Argument LINES specifies lines to be scrolled up."
14721 (interactive "p")
14722 (move-to-window-line -1)
14723 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
14724 (if (save-excursion
14725 (end-of-line)
14726 (and (pos-visible-in-window-p) ;Not continuation line.
14727 (eobp)))
14728 ;; Nothing in this page.
14729 (if (or (not gnus-break-pages)
14730 (save-excursion
14731 (save-restriction
14732 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
14733 t ;Nothing more.
14734 (gnus-narrow-to-page 1) ;Go to next page.
14735 nil)
14736 ;; More in this page.
14737 (condition-case ()
14738 (scroll-up lines)
14739 (end-of-buffer
14740 ;; Long lines may cause an end-of-buffer error.
14741 (goto-char (point-max))))
14742 (move-to-window-line 0)
14743 nil))
14745 (defun gnus-article-prev-page (&optional lines)
14746 "Show previous page of current article.
14747 Argument LINES specifies lines to be scrolled down."
14748 (interactive "p")
14749 (move-to-window-line 0)
14750 (if (and gnus-break-pages
14751 (bobp)
14752 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
14753 (progn
14754 (gnus-narrow-to-page -1) ;Go to previous page.
14755 (goto-char (point-max))
14756 (recenter -1))
14757 (prog1
14758 (condition-case ()
14759 (scroll-down lines)
14760 (error nil))
14761 (move-to-window-line 0))))
14763 (defun gnus-article-refer-article ()
14764 "Read article specified by message-id around point."
14765 (interactive)
14766 (let ((point (point)))
14767 (search-forward ">" nil t) ;Move point to end of "<....>".
14768 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
14769 (let ((message-id (match-string 1)))
14770 (goto-char point)
14771 (set-buffer gnus-summary-buffer)
14772 (gnus-summary-refer-article message-id))
14773 (goto-char (point))
14774 (error "No references around point"))))
14776 (defun gnus-article-show-summary ()
14777 "Reconfigure windows to show summary buffer."
14778 (interactive)
14779 (gnus-configure-windows 'article)
14780 (gnus-summary-goto-subject gnus-current-article))
14782 (defun gnus-article-describe-briefly ()
14783 "Describe article mode commands briefly."
14784 (interactive)
14785 (gnus-message 6
14786 (substitute-command-keys "\\<gnus-article-mode-map>\\[gnus-article-goto-next-page]:Next page \\[gnus-article-goto-prev-page]:Prev page \\[gnus-article-show-summary]:Show summary \\[gnus-info-find-node]:Run Info \\[gnus-article-describe-briefly]:This help")))
14788 (defun gnus-article-summary-command ()
14789 "Execute the last keystroke in the summary buffer."
14790 (interactive)
14791 (let ((obuf (current-buffer))
14792 (owin (current-window-configuration))
14793 func)
14794 (switch-to-buffer gnus-summary-buffer 'norecord)
14795 (setq func (lookup-key (current-local-map) (this-command-keys)))
14796 (call-interactively func)
14797 (set-buffer obuf)
14798 (set-window-configuration owin)
14799 (set-window-point (get-buffer-window (current-buffer)) (point))))
14801 (defun gnus-article-summary-command-nosave ()
14802 "Execute the last keystroke in the summary buffer."
14803 (interactive)
14804 (let (func)
14805 (pop-to-buffer gnus-summary-buffer 'norecord)
14806 (setq func (lookup-key (current-local-map) (this-command-keys)))
14807 (call-interactively func)))
14809 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
14810 "Read a summary buffer key sequence and execute it from the article buffer."
14811 (interactive "P")
14812 (let ((nosaves
14813 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
14814 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
14815 "=" "^" "\M-^" "|"))
14816 (nosave-but-article
14817 '("A\r"))
14818 keys)
14819 (save-excursion
14820 (set-buffer gnus-summary-buffer)
14821 (push (or key last-command-event) unread-command-events)
14822 (setq keys (read-key-sequence nil)))
14823 (message "")
14825 (if (or (member keys nosaves)
14826 (member keys nosave-but-article))
14827 (let (func)
14828 (save-window-excursion
14829 (pop-to-buffer gnus-summary-buffer 'norecord)
14830 (setq func (lookup-key (current-local-map) keys)))
14831 (if (not func)
14832 (ding)
14833 (set-buffer gnus-summary-buffer)
14834 (call-interactively func))
14835 (when (member keys nosave-but-article)
14836 (pop-to-buffer gnus-article-buffer 'norecord)))
14837 (let ((obuf (current-buffer))
14838 (owin (current-window-configuration))
14839 (opoint (point))
14840 func in-buffer)
14841 (if not-restore-window
14842 (pop-to-buffer gnus-summary-buffer 'norecord)
14843 (switch-to-buffer gnus-summary-buffer 'norecord))
14844 (setq in-buffer (current-buffer))
14845 (if (setq func (lookup-key (current-local-map) keys))
14846 (call-interactively func)
14847 (ding))
14848 (when (eq in-buffer (current-buffer))
14849 (set-buffer obuf)
14850 (unless not-restore-window
14851 (set-window-configuration owin))
14852 (set-window-point (get-buffer-window (current-buffer)) opoint))))))
14856 ;;; Kill file handling.
14859 ;;;###autoload
14860 (defalias 'gnus-batch-kill 'gnus-batch-score)
14861 ;;;###autoload
14862 (defun gnus-batch-score ()
14863 "Run batched scoring.
14864 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
14865 Newsgroups is a list of strings in Bnews format. If you want to score
14866 the comp hierarchy, you'd say \"comp.all\". If you would not like to
14867 score the alt hierarchy, you'd say \"!alt.all\"."
14868 (interactive)
14869 (let* ((yes-and-no
14870 (gnus-newsrc-parse-options
14871 (apply (function concat)
14872 (mapcar (lambda (g) (concat g " "))
14873 command-line-args-left))))
14874 (gnus-expert-user t)
14875 (nnmail-spool-file nil)
14876 (gnus-use-dribble-file nil)
14877 (yes (car yes-and-no))
14878 (no (cdr yes-and-no))
14879 group newsrc entry
14880 ;; Disable verbose message.
14881 gnus-novice-user gnus-large-newsgroup)
14882 ;; Eat all arguments.
14883 (setq command-line-args-left nil)
14884 ;; Start Gnus.
14885 (gnus)
14886 ;; Apply kills to specified newsgroups in command line arguments.
14887 (setq newsrc (cdr gnus-newsrc-alist))
14888 (while newsrc
14889 (setq group (caar newsrc))
14890 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
14891 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed)
14892 (and (car entry)
14893 (or (eq (car entry) t)
14894 (not (zerop (car entry)))))
14895 (if yes (string-match yes group) t)
14896 (or (null no) (not (string-match no group))))
14897 (progn
14898 (gnus-summary-read-group group nil t nil t)
14899 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
14900 (gnus-summary-exit))))
14901 (setq newsrc (cdr newsrc)))
14902 ;; Exit Emacs.
14903 (switch-to-buffer gnus-group-buffer)
14904 (gnus-group-save-newsrc)))
14906 (defun gnus-apply-kill-file ()
14907 "Apply a kill file to the current newsgroup.
14908 Returns the number of articles marked as read."
14909 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
14910 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14911 (gnus-apply-kill-file-internal)
14914 (defun gnus-kill-save-kill-buffer ()
14915 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14916 (when (get-file-buffer file)
14917 (save-excursion
14918 (set-buffer (get-file-buffer file))
14919 (and (buffer-modified-p) (save-buffer))
14920 (kill-buffer (current-buffer))))))
14922 (defvar gnus-kill-file-name "KILL"
14923 "Suffix of the kill files.")
14925 (defun gnus-newsgroup-kill-file (newsgroup)
14926 "Return the name of a kill file name for NEWSGROUP.
14927 If NEWSGROUP is nil, return the global kill file name instead."
14928 (cond
14929 ;; The global KILL file is placed at top of the directory.
14930 ((or (null newsgroup)
14931 (string-equal newsgroup ""))
14932 (expand-file-name gnus-kill-file-name
14933 gnus-kill-files-directory))
14934 ;; Append ".KILL" to newsgroup name.
14935 ((gnus-use-long-file-name 'not-kill)
14936 (expand-file-name (concat (gnus-newsgroup-savable-name newsgroup)
14937 "." gnus-kill-file-name)
14938 gnus-kill-files-directory))
14939 ;; Place "KILL" under the hierarchical directory.
14941 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
14942 "/" gnus-kill-file-name)
14943 gnus-kill-files-directory))))
14947 ;;; Dribble file
14950 (defvar gnus-dribble-ignore nil)
14951 (defvar gnus-dribble-eval-file nil)
14953 (defun gnus-dribble-file-name ()
14954 "Return the dribble file for the current .newsrc."
14955 (concat
14956 (if gnus-dribble-directory
14957 (concat (file-name-as-directory gnus-dribble-directory)
14958 (file-name-nondirectory gnus-current-startup-file))
14959 gnus-current-startup-file)
14960 "-dribble"))
14962 (defun gnus-dribble-enter (string)
14963 "Enter STRING into the dribble buffer."
14964 (if (and (not gnus-dribble-ignore)
14965 gnus-dribble-buffer
14966 (buffer-name gnus-dribble-buffer))
14967 (let ((obuf (current-buffer)))
14968 (set-buffer gnus-dribble-buffer)
14969 (insert string "\n")
14970 (set-window-point (get-buffer-window (current-buffer)) (point-max))
14971 (bury-buffer gnus-dribble-buffer)
14972 (set-buffer obuf))))
14974 (defun gnus-dribble-read-file ()
14975 "Read the dribble file from disk."
14976 (let ((dribble-file (gnus-dribble-file-name)))
14977 (save-excursion
14978 (set-buffer (setq gnus-dribble-buffer
14979 (get-buffer-create
14980 (file-name-nondirectory dribble-file))))
14981 (gnus-add-current-to-buffer-list)
14982 (erase-buffer)
14983 (setq buffer-file-name dribble-file)
14984 (auto-save-mode t)
14985 (buffer-disable-undo (current-buffer))
14986 (bury-buffer (current-buffer))
14987 (set-buffer-modified-p nil)
14988 (let ((auto (make-auto-save-file-name))
14989 (gnus-dribble-ignore t)
14990 modes)
14991 (when (or (file-exists-p auto) (file-exists-p dribble-file))
14992 ;; Load whichever file is newest -- the auto save file
14993 ;; or the "real" file.
14994 (if (file-newer-than-file-p auto dribble-file)
14995 (insert-file-contents auto)
14996 (insert-file-contents dribble-file))
14997 (unless (zerop (buffer-size))
14998 (set-buffer-modified-p t))
14999 ;; Set the file modes to reflect the .newsrc file modes.
15000 (save-buffer)
15001 (when (and (file-exists-p gnus-current-startup-file)
15002 (setq modes (file-modes gnus-current-startup-file)))
15003 (set-file-modes dribble-file modes))
15004 ;; Possibly eval the file later.
15005 (when (gnus-y-or-n-p
15006 "Auto-save file exists. Do you want to read it? ")
15007 (setq gnus-dribble-eval-file t)))))))
15009 (defun gnus-dribble-eval-file ()
15010 (when gnus-dribble-eval-file
15011 (setq gnus-dribble-eval-file nil)
15012 (save-excursion
15013 (let ((gnus-dribble-ignore t))
15014 (set-buffer gnus-dribble-buffer)
15015 (eval-buffer (current-buffer))))))
15017 (defun gnus-dribble-delete-file ()
15018 (when (file-exists-p (gnus-dribble-file-name))
15019 (delete-file (gnus-dribble-file-name)))
15020 (when gnus-dribble-buffer
15021 (save-excursion
15022 (set-buffer gnus-dribble-buffer)
15023 (let ((auto (make-auto-save-file-name)))
15024 (if (file-exists-p auto)
15025 (delete-file auto))
15026 (erase-buffer)
15027 (set-buffer-modified-p nil)))))
15029 (defun gnus-dribble-save ()
15030 (when (and gnus-dribble-buffer
15031 (buffer-name gnus-dribble-buffer))
15032 (save-excursion
15033 (set-buffer gnus-dribble-buffer)
15034 (save-buffer))))
15036 (defun gnus-dribble-clear ()
15037 (when (gnus-buffer-exists-p gnus-dribble-buffer)
15038 (save-excursion
15039 (set-buffer gnus-dribble-buffer)
15040 (erase-buffer)
15041 (set-buffer-modified-p nil)
15042 (setq buffer-saved-size (buffer-size)))))
15046 ;;; Server Communication
15049 (defun gnus-start-news-server (&optional confirm)
15050 "Open a method for getting news.
15051 If CONFIRM is non-nil, the user will be asked for an NNTP server."
15052 (let (how)
15053 (if gnus-current-select-method
15054 ;; Stream is already opened.
15056 ;; Open NNTP server.
15057 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
15058 (if confirm
15059 (progn
15060 ;; Read server name with completion.
15061 (setq gnus-nntp-server
15062 (completing-read "NNTP server: "
15063 (mapcar (lambda (server) (list server))
15064 (cons (list gnus-nntp-server)
15065 gnus-secondary-servers))
15066 nil nil gnus-nntp-server))))
15068 (if (and gnus-nntp-server
15069 (stringp gnus-nntp-server)
15070 (not (string= gnus-nntp-server "")))
15071 (setq gnus-select-method
15072 (cond ((or (string= gnus-nntp-server "")
15073 (string= gnus-nntp-server "::"))
15074 (list 'nnspool (system-name)))
15075 ((string-match "^:" gnus-nntp-server)
15076 (list 'nnmh gnus-nntp-server
15077 (list 'nnmh-directory
15078 (file-name-as-directory
15079 (expand-file-name
15080 (concat "~/" (substring
15081 gnus-nntp-server 1)))))
15082 (list 'nnmh-get-new-mail nil)))
15084 (list 'nntp gnus-nntp-server)))))
15086 (setq how (car gnus-select-method))
15087 (cond ((eq how 'nnspool)
15088 (require 'nnspool)
15089 (gnus-message 5 "Looking up local news spool..."))
15090 ((eq how 'nnmh)
15091 (require 'nnmh)
15092 (gnus-message 5 "Looking up mh spool..."))
15094 (require 'nntp)))
15095 (setq gnus-current-select-method gnus-select-method)
15096 (run-hooks 'gnus-open-server-hook)
15098 ;; gnus-open-server-hook might have opened it
15099 (gnus-server-opened gnus-select-method)
15100 (gnus-open-server gnus-select-method)
15101 (gnus-y-or-n-p
15102 (format
15103 "%s (%s) open error: '%s'. Continue? "
15104 (car gnus-select-method) (cadr gnus-select-method)
15105 (gnus-status-message gnus-select-method)))
15106 (gnus-error 1 "Couldn't open server on %s"
15107 (nth 1 gnus-select-method))))))
15109 (defun gnus-check-group (group)
15110 "Try to make sure that the server where GROUP exists is alive."
15111 (let ((method (gnus-find-method-for-group group)))
15112 (or (gnus-server-opened method)
15113 (gnus-open-server method))))
15115 (defun gnus-check-server (&optional method silent)
15116 "Check whether the connection to METHOD is down.
15117 If METHOD is nil, use `gnus-select-method'.
15118 If it is down, start it up (again)."
15119 (let ((method (or method gnus-select-method)))
15120 ;; Transform virtual server names into select methods.
15121 (when (stringp method)
15122 (setq method (gnus-server-to-method method)))
15123 (if (gnus-server-opened method)
15124 ;; The stream is already opened.
15126 ;; Open the server.
15127 (unless silent
15128 (gnus-message 5 "Opening %s server%s..." (car method)
15129 (if (equal (nth 1 method) "") ""
15130 (format " on %s" (nth 1 method)))))
15131 (run-hooks 'gnus-open-server-hook)
15132 (prog1
15133 (gnus-open-server method)
15134 (unless silent
15135 (message ""))))))
15137 (defun gnus-get-function (method function &optional noerror)
15138 "Return a function symbol based on METHOD and FUNCTION."
15139 ;; Translate server names into methods.
15140 (unless method
15141 (error "Attempted use of a nil select method"))
15142 (when (stringp method)
15143 (setq method (gnus-server-to-method method)))
15144 (let ((func (intern (format "%s-%s" (car method) function))))
15145 ;; If the functions isn't bound, we require the backend in
15146 ;; question.
15147 (unless (fboundp func)
15148 (require (car method))
15149 (when (and (not (fboundp func))
15150 (not noerror))
15151 ;; This backend doesn't implement this function.
15152 (error "No such function: %s" func)))
15153 func))
15157 ;;; Interface functions to the backends.
15160 (defun gnus-open-server (method)
15161 "Open a connection to METHOD."
15162 (when (stringp method)
15163 (setq method (gnus-server-to-method method)))
15164 (let ((elem (assoc method gnus-opened-servers)))
15165 ;; If this method was previously denied, we just return nil.
15166 (if (eq (nth 1 elem) 'denied)
15167 (progn
15168 (gnus-message 1 "Denied server")
15169 nil)
15170 ;; Open the server.
15171 (let ((result
15172 (funcall (gnus-get-function method 'open-server)
15173 (nth 1 method) (nthcdr 2 method))))
15174 ;; If this hasn't been opened before, we add it to the list.
15175 (unless elem
15176 (setq elem (list method nil)
15177 gnus-opened-servers (cons elem gnus-opened-servers)))
15178 ;; Set the status of this server.
15179 (setcar (cdr elem) (if result 'ok 'denied))
15180 ;; Return the result from the "open" call.
15181 result))))
15183 (defun gnus-close-server (method)
15184 "Close the connection to METHOD."
15185 (when (stringp method)
15186 (setq method (gnus-server-to-method method)))
15187 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
15189 (defun gnus-request-list (method)
15190 "Request the active file from METHOD."
15191 (when (stringp method)
15192 (setq method (gnus-server-to-method method)))
15193 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
15195 (defun gnus-request-list-newsgroups (method)
15196 "Request the newsgroups file from METHOD."
15197 (when (stringp method)
15198 (setq method (gnus-server-to-method method)))
15199 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
15201 (defun gnus-request-newgroups (date method)
15202 "Request all new groups since DATE from METHOD."
15203 (when (stringp method)
15204 (setq method (gnus-server-to-method method)))
15205 (funcall (gnus-get-function method 'request-newgroups)
15206 date (nth 1 method)))
15208 (defun gnus-server-opened (method)
15209 "Check whether a connection to METHOD has been opened."
15210 (when (stringp method)
15211 (setq method (gnus-server-to-method method)))
15212 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
15214 (defun gnus-status-message (method)
15215 "Return the status message from METHOD.
15216 If METHOD is a string, it is interpreted as a group name. The method
15217 this group uses will be queried."
15218 (let ((method (if (stringp method) (gnus-find-method-for-group method)
15219 method)))
15220 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
15222 (defun gnus-request-group (group &optional dont-check method)
15223 "Request GROUP. If DONT-CHECK, no information is required."
15224 (let ((method (or method (gnus-find-method-for-group group))))
15225 (when (stringp method)
15226 (setq method (gnus-server-to-method method)))
15227 (funcall (gnus-get-function method 'request-group)
15228 (gnus-group-real-name group) (nth 1 method) dont-check)))
15230 (defun gnus-request-asynchronous (group &optional articles)
15231 "Request that GROUP behave asynchronously.
15232 ARTICLES is the `data' of the group."
15233 (let ((method (gnus-find-method-for-group group)))
15234 (funcall (gnus-get-function method 'request-asynchronous)
15235 (gnus-group-real-name group) (nth 1 method) articles)))
15237 (defun gnus-list-active-group (group)
15238 "Request active information on GROUP."
15239 (let ((method (gnus-find-method-for-group group))
15240 (func 'list-active-group))
15241 (when (gnus-check-backend-function func group)
15242 (funcall (gnus-get-function method func)
15243 (gnus-group-real-name group) (nth 1 method)))))
15245 (defun gnus-request-group-description (group)
15246 "Request a description of GROUP."
15247 (let ((method (gnus-find-method-for-group group))
15248 (func 'request-group-description))
15249 (when (gnus-check-backend-function func group)
15250 (funcall (gnus-get-function method func)
15251 (gnus-group-real-name group) (nth 1 method)))))
15253 (defun gnus-close-group (group)
15254 "Request the GROUP be closed."
15255 (let ((method (gnus-find-method-for-group group)))
15256 (funcall (gnus-get-function method 'close-group)
15257 (gnus-group-real-name group) (nth 1 method))))
15259 (defun gnus-retrieve-headers (articles group &optional fetch-old)
15260 "Request headers for ARTICLES in GROUP.
15261 If FETCH-OLD, retrieve all headers (or some subset thereof) in the group."
15262 (let ((method (gnus-find-method-for-group group)))
15263 (if (and gnus-use-cache (numberp (car articles)))
15264 (gnus-cache-retrieve-headers articles group fetch-old)
15265 (funcall (gnus-get-function method 'retrieve-headers)
15266 articles (gnus-group-real-name group) (nth 1 method)
15267 fetch-old))))
15269 (defun gnus-retrieve-groups (groups method)
15270 "Request active information on GROUPS from METHOD."
15271 (when (stringp method)
15272 (setq method (gnus-server-to-method method)))
15273 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method)))
15275 (defun gnus-request-type (group &optional article)
15276 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
15277 (let ((method (gnus-find-method-for-group group)))
15278 (if (not (gnus-check-backend-function 'request-type (car method)))
15279 'unknown
15280 (funcall (gnus-get-function method 'request-type)
15281 (gnus-group-real-name group) article))))
15283 (defun gnus-request-update-mark (group article mark)
15284 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
15285 (let ((method (gnus-find-method-for-group group)))
15286 (if (not (gnus-check-backend-function 'request-update-mark (car method)))
15287 mark
15288 (funcall (gnus-get-function method 'request-update-mark)
15289 (gnus-group-real-name group) article mark))))
15291 (defun gnus-request-article (article group &optional buffer)
15292 "Request the ARTICLE in GROUP.
15293 ARTICLE can either be an article number or an article Message-ID.
15294 If BUFFER, insert the article in that group."
15295 (let ((method (gnus-find-method-for-group group)))
15296 (funcall (gnus-get-function method 'request-article)
15297 article (gnus-group-real-name group) (nth 1 method) buffer)))
15299 (defun gnus-request-head (article group)
15300 "Request the head of ARTICLE in GROUP."
15301 (let* ((method (gnus-find-method-for-group group))
15302 (head (gnus-get-function method 'request-head t)))
15303 (if (fboundp head)
15304 (funcall head article (gnus-group-real-name group) (nth 1 method))
15305 (let ((res (gnus-request-article article group)))
15306 (when res
15307 (save-excursion
15308 (set-buffer nntp-server-buffer)
15309 (goto-char (point-min))
15310 (when (search-forward "\n\n" nil t)
15311 (delete-region (1- (point)) (point-max)))
15312 (nnheader-fold-continuation-lines)))
15313 res))))
15315 (defun gnus-request-body (article group)
15316 "Request the body of ARTICLE in GROUP."
15317 (let ((method (gnus-find-method-for-group group)))
15318 (funcall (gnus-get-function method 'request-body)
15319 article (gnus-group-real-name group) (nth 1 method))))
15321 (defun gnus-request-post (method)
15322 "Post the current buffer using METHOD."
15323 (when (stringp method)
15324 (setq method (gnus-server-to-method method)))
15325 (funcall (gnus-get-function method 'request-post) (nth 1 method)))
15327 (defun gnus-request-scan (group method)
15328 "Request a SCAN being performed in GROUP from METHOD.
15329 If GROUP is nil, all groups on METHOD are scanned."
15330 (let ((method (if group (gnus-find-method-for-group group) method)))
15331 (funcall (gnus-get-function method 'request-scan)
15332 (and group (gnus-group-real-name group)) (nth 1 method))))
15334 (defsubst gnus-request-update-info (info method)
15335 "Request that METHOD update INFO."
15336 (when (stringp method)
15337 (setq method (gnus-server-to-method method)))
15338 (when (gnus-check-backend-function 'request-update-info (car method))
15339 (funcall (gnus-get-function method 'request-update-info)
15340 (gnus-group-real-name (gnus-info-group info))
15341 info (nth 1 method))))
15343 (defun gnus-request-expire-articles (articles group &optional force)
15344 (let ((method (gnus-find-method-for-group group)))
15345 (funcall (gnus-get-function method 'request-expire-articles)
15346 articles (gnus-group-real-name group) (nth 1 method)
15347 force)))
15349 (defun gnus-request-move-article
15350 (article group server accept-function &optional last)
15351 (let ((method (gnus-find-method-for-group group)))
15352 (funcall (gnus-get-function method 'request-move-article)
15353 article (gnus-group-real-name group)
15354 (nth 1 method) accept-function last)))
15356 (defun gnus-request-accept-article (group method &optional last)
15357 ;; Make sure there's a newline at the end of the article.
15358 (when (stringp method)
15359 (setq method (gnus-server-to-method method)))
15360 (when (and (not method)
15361 (stringp group))
15362 (setq method (gnus-group-name-to-method group)))
15363 (goto-char (point-max))
15364 (unless (bolp)
15365 (insert "\n"))
15366 (let ((func (car (or method (gnus-find-method-for-group group)))))
15367 (funcall (intern (format "%s-request-accept-article" func))
15368 (if (stringp group) (gnus-group-real-name group) group)
15369 (cadr method)
15370 last)))
15372 (defun gnus-request-replace-article (article group buffer)
15373 (let ((func (car (gnus-find-method-for-group group))))
15374 (funcall (intern (format "%s-request-replace-article" func))
15375 article (gnus-group-real-name group) buffer)))
15377 (defun gnus-request-associate-buffer (group)
15378 (let ((method (gnus-find-method-for-group group)))
15379 (funcall (gnus-get-function method 'request-associate-buffer)
15380 (gnus-group-real-name group))))
15382 (defun gnus-request-restore-buffer (article group)
15383 "Request a new buffer restored to the state of ARTICLE."
15384 (let ((method (gnus-find-method-for-group group)))
15385 (funcall (gnus-get-function method 'request-restore-buffer)
15386 article (gnus-group-real-name group) (nth 1 method))))
15388 (defun gnus-request-create-group (group &optional method)
15389 (when (stringp method)
15390 (setq method (gnus-server-to-method method)))
15391 (let ((method (or method (gnus-find-method-for-group group))))
15392 (funcall (gnus-get-function method 'request-create-group)
15393 (gnus-group-real-name group) (nth 1 method))))
15395 (defun gnus-request-delete-group (group &optional force)
15396 (let ((method (gnus-find-method-for-group group)))
15397 (funcall (gnus-get-function method 'request-delete-group)
15398 (gnus-group-real-name group) force (nth 1 method))))
15400 (defun gnus-request-rename-group (group new-name)
15401 (let ((method (gnus-find-method-for-group group)))
15402 (funcall (gnus-get-function method 'request-rename-group)
15403 (gnus-group-real-name group)
15404 (gnus-group-real-name new-name) (nth 1 method))))
15406 (defun gnus-member-of-valid (symbol group)
15407 "Find out if GROUP has SYMBOL as part of its \"valid\" spec."
15408 (memq symbol (assoc
15409 (symbol-name (car (gnus-find-method-for-group group)))
15410 gnus-valid-select-methods)))
15412 (defun gnus-method-option-p (method option)
15413 "Return non-nil if select METHOD has OPTION as a parameter."
15414 (when (stringp method)
15415 (setq method (gnus-server-to-method method)))
15416 (memq option (assoc (format "%s" (car method))
15417 gnus-valid-select-methods)))
15419 (defun gnus-server-extend-method (group method)
15420 ;; This function "extends" a virtual server. If the server is
15421 ;; "hello", and the select method is ("hello" (my-var "something"))
15422 ;; in the group "alt.alt", this will result in a new virtual server
15423 ;; called "hello+alt.alt".
15424 (let ((entry
15425 (gnus-copy-sequence
15426 (if (equal (car method) "native") gnus-select-method
15427 (cdr (assoc (car method) gnus-server-alist))))))
15428 (setcar (cdr entry) (concat (nth 1 entry) "+" group))
15429 (nconc entry (cdr method))))
15431 (defun gnus-server-status (method)
15432 "Return the status of METHOD."
15433 (nth 1 (assoc method gnus-opened-servers)))
15435 (defun gnus-group-name-to-method (group)
15436 "Return a select method suitable for GROUP."
15437 (if (string-match ":" group)
15438 (let ((server (substring group 0 (match-beginning 0))))
15439 (if (string-match "\\+" server)
15440 (list (intern (substring server 0 (match-beginning 0)))
15441 (substring server (match-end 0)))
15442 (list (intern server) "")))
15443 gnus-select-method))
15445 (defun gnus-find-method-for-group (group &optional info)
15446 "Find the select method that GROUP uses."
15447 (or gnus-override-method
15448 (and (not group)
15449 gnus-select-method)
15450 (let ((info (or info (gnus-get-info group)))
15451 method)
15452 (if (or (not info)
15453 (not (setq method (gnus-info-method info)))
15454 (equal method "native"))
15455 gnus-select-method
15456 (setq method
15457 (cond ((stringp method)
15458 (gnus-server-to-method method))
15459 ((stringp (car method))
15460 (gnus-server-extend-method group method))
15462 method)))
15463 (cond ((equal (cadr method) "")
15464 method)
15465 ((null (cadr method))
15466 (list (car method) ""))
15468 (gnus-server-add-address method)))))))
15470 (defun gnus-check-backend-function (func group)
15471 "Check whether GROUP supports function FUNC."
15472 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
15473 group)))
15474 (fboundp (intern (format "%s-%s" method func)))))
15476 (defun gnus-methods-using (feature)
15477 "Find all methods that have FEATURE."
15478 (let ((valids gnus-valid-select-methods)
15479 outs)
15480 (while valids
15481 (if (memq feature (car valids))
15482 (setq outs (cons (car valids) outs)))
15483 (setq valids (cdr valids)))
15484 outs))
15488 ;;; Active & Newsrc File Handling
15491 (defun gnus-setup-news (&optional rawfile level dont-connect)
15492 "Setup news information.
15493 If RAWFILE is non-nil, the .newsrc file will also be read.
15494 If LEVEL is non-nil, the news will be set up at level LEVEL."
15495 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile)))))
15497 (when init
15498 ;; Clear some variables to re-initialize news information.
15499 (setq gnus-newsrc-alist nil
15500 gnus-active-hashtb nil)
15501 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
15502 (gnus-read-newsrc-file rawfile))
15504 (when (and (not (assoc "archive" gnus-server-alist))
15505 (gnus-archive-server-wanted-p))
15506 (push (cons "archive" gnus-message-archive-method)
15507 gnus-server-alist))
15509 ;; If we don't read the complete active file, we fill in the
15510 ;; hashtb here.
15511 (if (or (null gnus-read-active-file)
15512 (eq gnus-read-active-file 'some))
15513 (gnus-update-active-hashtb-from-killed))
15515 ;; Read the active file and create `gnus-active-hashtb'.
15516 ;; If `gnus-read-active-file' is nil, then we just create an empty
15517 ;; hash table. The partial filling out of the hash table will be
15518 ;; done in `gnus-get-unread-articles'.
15519 (and gnus-read-active-file
15520 (not level)
15521 (gnus-read-active-file))
15523 (or gnus-active-hashtb
15524 (setq gnus-active-hashtb (make-vector 4095 0)))
15526 ;; Initialize the cache.
15527 (when gnus-use-cache
15528 (gnus-cache-open))
15530 ;; Possibly eval the dribble file.
15531 (and init (or gnus-use-dribble-file gnus-slave) (gnus-dribble-eval-file))
15533 ;; Slave Gnusii should then clear the dribble buffer.
15534 (when (and init gnus-slave)
15535 (gnus-dribble-clear))
15537 (gnus-update-format-specifications)
15539 ;; See whether we need to read the description file.
15540 (if (and (string-match "%[-,0-9]*D" gnus-group-line-format)
15541 (not gnus-description-hashtb)
15542 (not dont-connect)
15543 gnus-read-active-file)
15544 (gnus-read-all-descriptions-files))
15546 ;; Find new newsgroups and treat them.
15547 (if (and init gnus-check-new-newsgroups (not level)
15548 (gnus-check-server gnus-select-method))
15549 (gnus-find-new-newsgroups))
15551 ;; We might read in new NoCeM messages here.
15552 (when (and gnus-use-nocem
15553 (not level)
15554 (not dont-connect))
15555 (gnus-nocem-scan-groups))
15557 ;; Find the number of unread articles in each non-dead group.
15558 (let ((gnus-read-active-file (and (not level) gnus-read-active-file)))
15559 (gnus-get-unread-articles level))
15561 (if (and init gnus-check-bogus-newsgroups
15562 gnus-read-active-file (not level)
15563 (gnus-server-opened gnus-select-method))
15564 (gnus-check-bogus-newsgroups))))
15566 (defun gnus-find-new-newsgroups (&optional arg)
15567 "Search for new newsgroups and add them.
15568 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
15569 The `-n' option line from .newsrc is respected.
15570 If ARG (the prefix), use the `ask-server' method to query
15571 the server for new groups."
15572 (interactive "P")
15573 (let ((check (if (or (and arg (not (listp gnus-check-new-newsgroups)))
15574 (null gnus-read-active-file)
15575 (eq gnus-read-active-file 'some))
15576 'ask-server gnus-check-new-newsgroups)))
15577 (unless (gnus-check-first-time-used)
15578 (if (or (consp check)
15579 (eq check 'ask-server))
15580 ;; Ask the server for new groups.
15581 (gnus-ask-server-for-new-groups)
15582 ;; Go through the active hashtb and look for new groups.
15583 (let ((groups 0)
15584 group new-newsgroups)
15585 (gnus-message 5 "Looking for new newsgroups...")
15586 (unless gnus-have-read-active-file
15587 (gnus-read-active-file))
15588 (setq gnus-newsrc-last-checked-date (current-time-string))
15589 (unless gnus-killed-hashtb
15590 (gnus-make-hashtable-from-killed))
15591 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
15592 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
15593 (mapatoms
15594 (lambda (sym)
15595 (if (or (null (setq group (symbol-name sym)))
15596 (not (boundp sym))
15597 (null (symbol-value sym))
15598 (gnus-gethash group gnus-killed-hashtb)
15599 (gnus-gethash group gnus-newsrc-hashtb))
15601 (let ((do-sub (gnus-matches-options-n group)))
15602 (cond
15603 ((eq do-sub 'subscribe)
15604 (setq groups (1+ groups))
15605 (gnus-sethash group group gnus-killed-hashtb)
15606 (funcall gnus-subscribe-options-newsgroup-method group))
15607 ((eq do-sub 'ignore)
15608 nil)
15610 (setq groups (1+ groups))
15611 (gnus-sethash group group gnus-killed-hashtb)
15612 (if gnus-subscribe-hierarchical-interactive
15613 (setq new-newsgroups (cons group new-newsgroups))
15614 (funcall gnus-subscribe-newsgroup-method group)))))))
15615 gnus-active-hashtb)
15616 (when new-newsgroups
15617 (gnus-subscribe-hierarchical-interactive new-newsgroups))
15618 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
15619 (if (> groups 0)
15620 (gnus-message 6 "%d new newsgroup%s arrived."
15621 groups (if (> groups 1) "s have" " has"))
15622 (gnus-message 6 "No new newsgroups.")))))))
15624 (defun gnus-matches-options-n (group)
15625 ;; Returns `subscribe' if the group is to be unconditionally
15626 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
15627 ;; no match for the group.
15629 ;; First we check the two user variables.
15630 (cond
15631 ((and gnus-options-subscribe
15632 (string-match gnus-options-subscribe group))
15633 'subscribe)
15634 ((and gnus-auto-subscribed-groups
15635 (string-match gnus-auto-subscribed-groups group))
15636 'subscribe)
15637 ((and gnus-options-not-subscribe
15638 (string-match gnus-options-not-subscribe group))
15639 'ignore)
15640 ;; Then we go through the list that was retrieved from the .newsrc
15641 ;; file. This list has elements on the form
15642 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
15643 ;; is in the reverse order of the options line) is returned.
15645 (let ((regs gnus-newsrc-options-n))
15646 (while (and regs
15647 (not (string-match (caar regs) group)))
15648 (setq regs (cdr regs)))
15649 (and regs (cdar regs))))))
15651 (defun gnus-ask-server-for-new-groups ()
15652 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
15653 (methods (cons gnus-select-method
15654 (nconc
15655 (when (gnus-archive-server-wanted-p)
15656 (list "archive"))
15657 (append
15658 (and (consp gnus-check-new-newsgroups)
15659 gnus-check-new-newsgroups)
15660 gnus-secondary-select-methods))))
15661 (groups 0)
15662 (new-date (current-time-string))
15663 group new-newsgroups got-new method hashtb
15664 gnus-override-subscribe-method)
15665 ;; Go through both primary and secondary select methods and
15666 ;; request new newsgroups.
15667 (while (setq method (gnus-server-get-method nil (pop methods)))
15668 (setq new-newsgroups nil)
15669 (setq gnus-override-subscribe-method method)
15670 (when (and (gnus-check-server method)
15671 (gnus-request-newgroups date method))
15672 (save-excursion
15673 (setq got-new t)
15674 (setq hashtb (gnus-make-hashtable 100))
15675 (set-buffer nntp-server-buffer)
15676 ;; Enter all the new groups into a hashtable.
15677 (gnus-active-to-gnus-format method hashtb 'ignore))
15678 ;; Now all new groups from `method' are in `hashtb'.
15679 (mapatoms
15680 (lambda (group-sym)
15681 (if (or (null (setq group (symbol-name group-sym)))
15682 (not (boundp group-sym))
15683 (null (symbol-value group-sym))
15684 (gnus-gethash group gnus-newsrc-hashtb)
15685 (member group gnus-zombie-list)
15686 (member group gnus-killed-list))
15687 ;; The group is already known.
15689 ;; Make this group active.
15690 (when (symbol-value group-sym)
15691 (gnus-set-active group (symbol-value group-sym)))
15692 ;; Check whether we want it or not.
15693 (let ((do-sub (gnus-matches-options-n group)))
15694 (cond
15695 ((eq do-sub 'subscribe)
15696 (incf groups)
15697 (gnus-sethash group group gnus-killed-hashtb)
15698 (funcall gnus-subscribe-options-newsgroup-method group))
15699 ((eq do-sub 'ignore)
15700 nil)
15702 (incf groups)
15703 (gnus-sethash group group gnus-killed-hashtb)
15704 (if gnus-subscribe-hierarchical-interactive
15705 (push group new-newsgroups)
15706 (funcall gnus-subscribe-newsgroup-method group)))))))
15707 hashtb))
15708 (when new-newsgroups
15709 (gnus-subscribe-hierarchical-interactive new-newsgroups)))
15710 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
15711 (when (> groups 0)
15712 (gnus-message 6 "%d new newsgroup%s arrived."
15713 groups (if (> groups 1) "s have" " has")))
15714 (and got-new (setq gnus-newsrc-last-checked-date new-date))
15715 got-new))
15717 (defun gnus-check-first-time-used ()
15718 (if (or (> (length gnus-newsrc-alist) 1)
15719 (file-exists-p gnus-startup-file)
15720 (file-exists-p (concat gnus-startup-file ".el"))
15721 (file-exists-p (concat gnus-startup-file ".eld")))
15723 (gnus-message 6 "First time user; subscribing you to default groups")
15724 (unless (gnus-read-active-file-p)
15725 (gnus-read-active-file))
15726 (setq gnus-newsrc-last-checked-date (current-time-string))
15727 (let ((groups gnus-default-subscribed-newsgroups)
15728 group)
15729 (if (eq groups t)
15731 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
15732 (mapatoms
15733 (lambda (sym)
15734 (if (null (setq group (symbol-name sym)))
15736 (let ((do-sub (gnus-matches-options-n group)))
15737 (cond
15738 ((eq do-sub 'subscribe)
15739 (gnus-sethash group group gnus-killed-hashtb)
15740 (funcall gnus-subscribe-options-newsgroup-method group))
15741 ((eq do-sub 'ignore)
15742 nil)
15744 (setq gnus-killed-list (cons group gnus-killed-list)))))))
15745 gnus-active-hashtb)
15746 (while groups
15747 (if (gnus-active (car groups))
15748 (gnus-group-change-level
15749 (car groups) gnus-level-default-subscribed gnus-level-killed))
15750 (setq groups (cdr groups)))
15751 (gnus-group-make-help-group)
15752 (and gnus-novice-user
15753 (gnus-message 7 "`A k' to list killed groups"))))))
15755 (defun gnus-subscribe-group (group previous &optional method)
15756 (gnus-group-change-level
15757 (if method
15758 (list t group gnus-level-default-subscribed nil nil method)
15759 group)
15760 gnus-level-default-subscribed gnus-level-killed previous t))
15762 ;; `gnus-group-change-level' is the fundamental function for changing
15763 ;; subscription levels of newsgroups. This might mean just changing
15764 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
15765 ;; again, which subscribes/unsubscribes a group, which is equally
15766 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
15767 ;; from 8-9 to 1-7 means that you remove the group from the list of
15768 ;; killed (or zombie) groups and add them to the (kinda) subscribed
15769 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
15770 ;; which is trivial.
15771 ;; ENTRY can either be a string (newsgroup name) or a list (if
15772 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
15773 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
15774 ;; entries.
15775 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
15776 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
15777 ;; after.
15778 (defun gnus-group-change-level (entry level &optional oldlevel
15779 previous fromkilled)
15780 (let (group info active num)
15781 ;; Glean what info we can from the arguments
15782 (if (consp entry)
15783 (if fromkilled (setq group (nth 1 entry))
15784 (setq group (car (nth 2 entry))))
15785 (setq group entry))
15786 (if (and (stringp entry)
15787 oldlevel
15788 (< oldlevel gnus-level-zombie))
15789 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
15790 (if (and (not oldlevel)
15791 (consp entry))
15792 (setq oldlevel (gnus-info-level (nth 2 entry)))
15793 (setq oldlevel (or oldlevel 9)))
15794 (if (stringp previous)
15795 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
15797 (if (and (>= oldlevel gnus-level-zombie)
15798 (gnus-gethash group gnus-newsrc-hashtb))
15799 ;; We are trying to subscribe a group that is already
15800 ;; subscribed.
15801 () ; Do nothing.
15803 (or (gnus-ephemeral-group-p group)
15804 (gnus-dribble-enter
15805 (format "(gnus-group-change-level %S %S %S %S %S)"
15806 group level oldlevel (car (nth 2 previous)) fromkilled)))
15808 ;; Then we remove the newgroup from any old structures, if needed.
15809 ;; If the group was killed, we remove it from the killed or zombie
15810 ;; list. If not, and it is in fact going to be killed, we remove
15811 ;; it from the newsrc hash table and assoc.
15812 (cond
15813 ((>= oldlevel gnus-level-zombie)
15814 (if (= oldlevel gnus-level-zombie)
15815 (setq gnus-zombie-list (delete group gnus-zombie-list))
15816 (setq gnus-killed-list (delete group gnus-killed-list))))
15818 (if (and (>= level gnus-level-zombie)
15819 entry)
15820 (progn
15821 (gnus-sethash (car (nth 2 entry)) nil gnus-newsrc-hashtb)
15822 (if (nth 3 entry)
15823 (setcdr (gnus-gethash (car (nth 3 entry))
15824 gnus-newsrc-hashtb)
15825 (cdr entry)))
15826 (setcdr (cdr entry) (cdddr entry))))))
15828 ;; Finally we enter (if needed) the list where it is supposed to
15829 ;; go, and change the subscription level. If it is to be killed,
15830 ;; we enter it into the killed or zombie list.
15831 (cond
15832 ((>= level gnus-level-zombie)
15833 ;; Remove from the hash table.
15834 (gnus-sethash group nil gnus-newsrc-hashtb)
15835 ;; We do not enter foreign groups into the list of dead
15836 ;; groups.
15837 (unless (gnus-group-foreign-p group)
15838 (if (= level gnus-level-zombie)
15839 (setq gnus-zombie-list (cons group gnus-zombie-list))
15840 (setq gnus-killed-list (cons group gnus-killed-list)))))
15842 ;; If the list is to be entered into the newsrc assoc, and
15843 ;; it was killed, we have to create an entry in the newsrc
15844 ;; hashtb format and fix the pointers in the newsrc assoc.
15845 (if (< oldlevel gnus-level-zombie)
15846 ;; It was alive, and it is going to stay alive, so we
15847 ;; just change the level and don't change any pointers or
15848 ;; hash table entries.
15849 (setcar (cdaddr entry) level)
15850 (if (listp entry)
15851 (setq info (cdr entry)
15852 num (car entry))
15853 (setq active (gnus-active group))
15854 (setq num
15855 (if active (- (1+ (cdr active)) (car active)) t))
15856 ;; Check whether the group is foreign. If so, the
15857 ;; foreign select method has to be entered into the
15858 ;; info.
15859 (let ((method (or gnus-override-subscribe-method
15860 (gnus-group-method group))))
15861 (if (eq method gnus-select-method)
15862 (setq info (list group level nil))
15863 (setq info (list group level nil nil method)))))
15864 (unless previous
15865 (setq previous
15866 (let ((p gnus-newsrc-alist))
15867 (while (cddr p)
15868 (setq p (cdr p)))
15869 p)))
15870 (setq entry (cons info (cddr previous)))
15871 (if (cdr previous)
15872 (progn
15873 (setcdr (cdr previous) entry)
15874 (gnus-sethash group (cons num (cdr previous))
15875 gnus-newsrc-hashtb))
15876 (setcdr previous entry)
15877 (gnus-sethash group (cons num previous)
15878 gnus-newsrc-hashtb))
15879 (when (cdr entry)
15880 (setcdr (gnus-gethash (caadr entry) gnus-newsrc-hashtb) entry)))))
15881 (when gnus-group-change-level-function
15882 (funcall gnus-group-change-level-function group level oldlevel)))))
15884 (defun gnus-kill-newsgroup (newsgroup)
15885 "Obsolete function. Kills a newsgroup."
15886 (gnus-group-change-level
15887 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed))
15889 (defun gnus-check-bogus-newsgroups (&optional confirm)
15890 "Remove bogus newsgroups.
15891 If CONFIRM is non-nil, the user has to confirm the deletion of every
15892 newsgroup."
15893 (let ((newsrc (cdr gnus-newsrc-alist))
15894 bogus group entry info)
15895 (gnus-message 5 "Checking bogus newsgroups...")
15896 (unless (gnus-read-active-file-p)
15897 (gnus-read-active-file))
15898 (when (gnus-read-active-file-p)
15899 ;; Find all bogus newsgroup that are subscribed.
15900 (while newsrc
15901 (setq info (pop newsrc)
15902 group (gnus-info-group info))
15903 (unless (or (gnus-active group) ; Active
15904 (gnus-info-method info) ; Foreign
15905 (and confirm
15906 (not (gnus-y-or-n-p
15907 (format "Remove bogus newsgroup: %s " group)))))
15908 ;; Found a bogus newsgroup.
15909 (push group bogus)))
15910 ;; Remove all bogus subscribed groups by first killing them, and
15911 ;; then removing them from the list of killed groups.
15912 (while bogus
15913 (when (setq entry (gnus-gethash (setq group (pop bogus))
15914 gnus-newsrc-hashtb))
15915 (gnus-group-change-level entry gnus-level-killed)
15916 (setq gnus-killed-list (delete group gnus-killed-list))))
15917 ;; Then we remove all bogus groups from the list of killed and
15918 ;; zombie groups. They are are removed without confirmation.
15919 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
15920 killed)
15921 (while dead-lists
15922 (setq killed (symbol-value (car dead-lists)))
15923 (while killed
15924 (unless (gnus-active (setq group (pop killed)))
15925 ;; The group is bogus.
15926 ;; !!!Slow as hell.
15927 (set (car dead-lists)
15928 (delete group (symbol-value (car dead-lists))))))
15929 (setq dead-lists (cdr dead-lists))))
15930 (gnus-message 5 "Checking bogus newsgroups...done"))))
15932 (defun gnus-check-duplicate-killed-groups ()
15933 "Remove duplicates from the list of killed groups."
15934 (interactive)
15935 (let ((killed gnus-killed-list))
15936 (while killed
15937 (gnus-message 9 "%d" (length killed))
15938 (setcdr killed (delete (car killed) (cdr killed)))
15939 (setq killed (cdr killed)))))
15941 ;; We want to inline a function from gnus-cache, so we cheat here:
15942 (eval-when-compile
15943 (provide 'gnus)
15944 (setq gnus-directory (or (getenv "SAVEDIR") "~/News/"))
15945 (require 'gnus-cache))
15947 (defun gnus-get-unread-articles-in-group (info active &optional update)
15948 (when active
15949 ;; Allow the backend to update the info in the group.
15950 (when (and update
15951 (gnus-request-update-info
15952 info (gnus-find-method-for-group (gnus-info-group info))))
15953 (gnus-activate-group (gnus-info-group info) nil t))
15954 (let* ((range (gnus-info-read info))
15955 (num 0))
15956 ;; If a cache is present, we may have to alter the active info.
15957 (when (and gnus-use-cache info)
15958 (inline (gnus-cache-possibly-alter-active
15959 (gnus-info-group info) active)))
15960 ;; Modify the list of read articles according to what articles
15961 ;; are available; then tally the unread articles and add the
15962 ;; number to the group hash table entry.
15963 (cond
15964 ((zerop (cdr active))
15965 (setq num 0))
15966 ((not range)
15967 (setq num (- (1+ (cdr active)) (car active))))
15968 ((not (listp (cdr range)))
15969 ;; Fix a single (num . num) range according to the
15970 ;; active hash table.
15971 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
15972 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
15973 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
15974 ;; Compute number of unread articles.
15975 (setq num (max 0 (- (cdr active) (- (1+ (cdr range)) (car range))))))
15977 ;; The read list is a list of ranges. Fix them according to
15978 ;; the active hash table.
15979 ;; First peel off any elements that are below the lower
15980 ;; active limit.
15981 (while (and (cdr range)
15982 (>= (car active)
15983 (or (and (atom (cadr range)) (cadr range))
15984 (caadr range))))
15985 (if (numberp (car range))
15986 (setcar range
15987 (cons (car range)
15988 (or (and (numberp (cadr range))
15989 (cadr range))
15990 (cdadr range))))
15991 (setcdr (car range)
15992 (or (and (numberp (nth 1 range)) (nth 1 range))
15993 (cdadr range))))
15994 (setcdr range (cddr range)))
15995 ;; Adjust the first element to be the same as the lower limit.
15996 (if (and (not (atom (car range)))
15997 (< (cdar range) (car active)))
15998 (setcdr (car range) (1- (car active))))
15999 ;; Then we want to peel off any elements that are higher
16000 ;; than the upper active limit.
16001 (let ((srange range))
16002 ;; Go past all legal elements.
16003 (while (and (cdr srange)
16004 (<= (or (and (atom (cadr srange))
16005 (cadr srange))
16006 (caadr srange)) (cdr active)))
16007 (setq srange (cdr srange)))
16008 (if (cdr srange)
16009 ;; Nuke all remaining illegal elements.
16010 (setcdr srange nil))
16012 ;; Adjust the final element.
16013 (if (and (not (atom (car srange)))
16014 (> (cdar srange) (cdr active)))
16015 (setcdr (car srange) (cdr active))))
16016 ;; Compute the number of unread articles.
16017 (while range
16018 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
16019 (cdar range)))
16020 (or (and (atom (car range)) (car range))
16021 (caar range)))))
16022 (setq range (cdr range)))
16023 (setq num (max 0 (- (cdr active) num)))))
16024 ;; Set the number of unread articles.
16025 (when info
16026 (setcar (gnus-gethash (gnus-info-group info) gnus-newsrc-hashtb) num))
16027 num)))
16029 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
16030 ;; and compute how many unread articles there are in each group.
16031 (defun gnus-get-unread-articles (&optional level)
16032 (let* ((newsrc (cdr gnus-newsrc-alist))
16033 (level (or level gnus-activate-level (1+ gnus-level-subscribed)))
16034 (foreign-level
16035 (min
16036 (cond ((and gnus-activate-foreign-newsgroups
16037 (not (numberp gnus-activate-foreign-newsgroups)))
16038 (1+ gnus-level-subscribed))
16039 ((numberp gnus-activate-foreign-newsgroups)
16040 gnus-activate-foreign-newsgroups)
16041 (t 0))
16042 level))
16043 info group active method)
16044 (gnus-message 5 "Checking new news...")
16046 (while newsrc
16047 (setq active (gnus-active (setq group (gnus-info-group
16048 (setq info (pop newsrc))))))
16050 ;; Check newsgroups. If the user doesn't want to check them, or
16051 ;; they can't be checked (for instance, if the news server can't
16052 ;; be reached) we just set the number of unread articles in this
16053 ;; newsgroup to t. This means that Gnus thinks that there are
16054 ;; unread articles, but it has no idea how many.
16055 (if (and (setq method (gnus-info-method info))
16056 (not (gnus-server-equal
16057 gnus-select-method
16058 (setq method (gnus-server-get-method nil method))))
16059 (not (gnus-secondary-method-p method)))
16060 ;; These groups are foreign. Check the level.
16061 (when (<= (gnus-info-level info) foreign-level)
16062 (setq active (gnus-activate-group group 'scan))
16063 (unless (inline (gnus-virtual-group-p group))
16064 (inline (gnus-close-group group)))
16065 (when (fboundp (intern (concat (symbol-name (car method))
16066 "-request-update-info")))
16067 (inline (gnus-request-update-info info method))))
16068 ;; These groups are native or secondary.
16069 (when (and (<= (gnus-info-level info) level)
16070 (not gnus-read-active-file))
16071 (setq active (gnus-activate-group group 'scan))
16072 (inline (gnus-close-group group))))
16074 ;; Get the number of unread articles in the group.
16075 (if active
16076 (inline (gnus-get-unread-articles-in-group info active))
16077 ;; The group couldn't be reached, so we nix out the number of
16078 ;; unread articles and stuff.
16079 (gnus-set-active group nil)
16080 (setcar (gnus-gethash group gnus-newsrc-hashtb) t)))
16082 (gnus-message 5 "Checking new news...done")))
16084 ;; Create a hash table out of the newsrc alist. The `car's of the
16085 ;; alist elements are used as keys.
16086 (defun gnus-make-hashtable-from-newsrc-alist ()
16087 (let ((alist gnus-newsrc-alist)
16088 (ohashtb gnus-newsrc-hashtb)
16089 prev)
16090 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
16091 (setq alist
16092 (setq prev (setq gnus-newsrc-alist
16093 (if (equal (caar gnus-newsrc-alist)
16094 "dummy.group")
16095 gnus-newsrc-alist
16096 (cons (list "dummy.group" 0 nil) alist)))))
16097 (while alist
16098 (gnus-sethash
16099 (caar alist)
16100 (cons (and ohashtb (car (gnus-gethash (caar alist) ohashtb)))
16101 prev)
16102 gnus-newsrc-hashtb)
16103 (setq prev alist
16104 alist (cdr alist)))))
16106 (defun gnus-make-hashtable-from-killed ()
16107 "Create a hash table from the killed and zombie lists."
16108 (let ((lists '(gnus-killed-list gnus-zombie-list))
16109 list)
16110 (setq gnus-killed-hashtb
16111 (gnus-make-hashtable
16112 (+ (length gnus-killed-list) (length gnus-zombie-list))))
16113 (while (setq list (pop lists))
16114 (setq list (symbol-value list))
16115 (while list
16116 (gnus-sethash (car list) (pop list) gnus-killed-hashtb)))))
16118 (defun gnus-activate-group (group &optional scan dont-check method)
16119 ;; Check whether a group has been activated or not.
16120 ;; If SCAN, request a scan of that group as well.
16121 (let ((method (or method (gnus-find-method-for-group group)))
16122 active)
16123 (and (gnus-check-server method)
16124 ;; We escape all bugs and quit here to make it possible to
16125 ;; continue if a group is so out-there that it reports bugs
16126 ;; and stuff.
16127 (progn
16128 (and scan
16129 (gnus-check-backend-function 'request-scan (car method))
16130 (gnus-request-scan group method))
16132 (condition-case ()
16133 (gnus-request-group group dont-check method)
16134 ; (error nil)
16135 (quit nil))
16136 (save-excursion
16137 (set-buffer nntp-server-buffer)
16138 (goto-char (point-min))
16139 ;; Parse the result we got from `gnus-request-group'.
16140 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
16141 (progn
16142 (goto-char (match-beginning 1))
16143 (gnus-set-active
16144 group (setq active (cons (read (current-buffer))
16145 (read (current-buffer)))))
16146 ;; Return the new active info.
16147 active))))))
16149 (defun gnus-update-read-articles (group unread)
16150 "Update the list of read and ticked articles in GROUP using the
16151 UNREAD and TICKED lists.
16152 Note: UNSELECTED has to be sorted over `<'.
16153 Returns whether the updating was successful."
16154 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
16155 (entry (gnus-gethash group gnus-newsrc-hashtb))
16156 (info (nth 2 entry))
16157 (prev 1)
16158 (unread (sort (copy-sequence unread) '<))
16159 read)
16160 (if (or (not info) (not active))
16161 ;; There is no info on this group if it was, in fact,
16162 ;; killed. Gnus stores no information on killed groups, so
16163 ;; there's nothing to be done.
16164 ;; One could store the information somewhere temporarily,
16165 ;; perhaps... Hmmm...
16167 ;; Remove any negative articles numbers.
16168 (while (and unread (< (car unread) 0))
16169 (setq unread (cdr unread)))
16170 ;; Remove any expired article numbers
16171 (while (and unread (< (car unread) (car active)))
16172 (setq unread (cdr unread)))
16173 ;; Compute the ranges of read articles by looking at the list of
16174 ;; unread articles.
16175 (while unread
16176 (if (/= (car unread) prev)
16177 (setq read (cons (if (= prev (1- (car unread))) prev
16178 (cons prev (1- (car unread)))) read)))
16179 (setq prev (1+ (car unread)))
16180 (setq unread (cdr unread)))
16181 (when (<= prev (cdr active))
16182 (setq read (cons (cons prev (cdr active)) read)))
16183 ;; Enter this list into the group info.
16184 (gnus-info-set-read
16185 info (if (> (length read) 1) (nreverse read) read))
16186 ;; Set the number of unread articles in gnus-newsrc-hashtb.
16187 (gnus-get-unread-articles-in-group info (gnus-active group))
16188 t)))
16190 (defun gnus-make-articles-unread (group articles)
16191 "Mark ARTICLES in GROUP as unread."
16192 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
16193 (gnus-gethash (gnus-group-real-name group)
16194 gnus-newsrc-hashtb))))
16195 (ranges (gnus-info-read info))
16196 news article)
16197 (while articles
16198 (when (gnus-member-of-range
16199 (setq article (pop articles)) ranges)
16200 (setq news (cons article news))))
16201 (when news
16202 (gnus-info-set-read
16203 info (gnus-remove-from-range (gnus-info-read info) (nreverse news)))
16204 (gnus-group-update-group group t))))
16206 ;; Enter all dead groups into the hashtb.
16207 (defun gnus-update-active-hashtb-from-killed ()
16208 (let ((hashtb (setq gnus-active-hashtb (make-vector 4095 0)))
16209 (lists (list gnus-killed-list gnus-zombie-list))
16210 killed)
16211 (while lists
16212 (setq killed (car lists))
16213 (while killed
16214 (gnus-sethash (car killed) nil hashtb)
16215 (setq killed (cdr killed)))
16216 (setq lists (cdr lists)))))
16218 (defun gnus-get-killed-groups ()
16219 "Go through the active hashtb and all all unknown groups as killed."
16220 ;; First make sure active file has been read.
16221 (unless (gnus-read-active-file-p)
16222 (let ((gnus-read-active-file t))
16223 (gnus-read-active-file)))
16224 (or gnus-killed-hashtb (gnus-make-hashtable-from-killed))
16225 ;; Go through all newsgroups that are known to Gnus - enlarge kill list.
16226 (mapatoms
16227 (lambda (sym)
16228 (let ((groups 0)
16229 (group (symbol-name sym)))
16230 (if (or (null group)
16231 (gnus-gethash group gnus-killed-hashtb)
16232 (gnus-gethash group gnus-newsrc-hashtb))
16234 (let ((do-sub (gnus-matches-options-n group)))
16235 (if (or (eq do-sub 'subscribe) (eq do-sub 'ignore))
16237 (setq groups (1+ groups))
16238 (setq gnus-killed-list
16239 (cons group gnus-killed-list))
16240 (gnus-sethash group group gnus-killed-hashtb))))))
16241 gnus-active-hashtb))
16243 ;; Get the active file(s) from the backend(s).
16244 (defun gnus-read-active-file ()
16245 (gnus-group-set-mode-line)
16246 (let ((methods
16247 (append
16248 (if (gnus-check-server gnus-select-method)
16249 ;; The native server is available.
16250 (cons gnus-select-method gnus-secondary-select-methods)
16251 ;; The native server is down, so we just do the
16252 ;; secondary ones.
16253 gnus-secondary-select-methods)
16254 ;; Also read from the archive server.
16255 (when (gnus-archive-server-wanted-p)
16256 (list "archive"))))
16257 list-type)
16258 (setq gnus-have-read-active-file nil)
16259 (save-excursion
16260 (set-buffer nntp-server-buffer)
16261 (while methods
16262 (let* ((method (if (stringp (car methods))
16263 (gnus-server-get-method nil (car methods))
16264 (car methods)))
16265 (where (nth 1 method))
16266 (mesg (format "Reading active file%s via %s..."
16267 (if (and where (not (zerop (length where))))
16268 (concat " from " where) "")
16269 (car method))))
16270 (gnus-message 5 mesg)
16271 (when (gnus-check-server method)
16272 ;; Request that the backend scan its incoming messages.
16273 (and (gnus-check-backend-function 'request-scan (car method))
16274 (gnus-request-scan nil method))
16275 (cond
16276 ((and (eq gnus-read-active-file 'some)
16277 (gnus-check-backend-function 'retrieve-groups (car method)))
16278 (let ((newsrc (cdr gnus-newsrc-alist))
16279 (gmethod (gnus-server-get-method nil method))
16280 groups info)
16281 (while (setq info (pop newsrc))
16282 (when (gnus-server-equal
16283 (gnus-find-method-for-group
16284 (gnus-info-group info) info)
16285 gmethod)
16286 (push (gnus-group-real-name (gnus-info-group info))
16287 groups)))
16288 (when groups
16289 (gnus-check-server method)
16290 (setq list-type (gnus-retrieve-groups groups method))
16291 (cond
16292 ((not list-type)
16293 (gnus-error
16294 1.2 "Cannot read partial active file from %s server."
16295 (car method)))
16296 ((eq list-type 'active)
16297 (gnus-active-to-gnus-format method gnus-active-hashtb))
16299 (gnus-groups-to-gnus-format method gnus-active-hashtb))))))
16301 (if (not (gnus-request-list method))
16302 (unless (equal method gnus-message-archive-method)
16303 (gnus-error 1 "Cannot read active file from %s server."
16304 (car method)))
16305 (gnus-message 5 mesg)
16306 (gnus-active-to-gnus-format method gnus-active-hashtb)
16307 ;; We mark this active file as read.
16308 (push method gnus-have-read-active-file)
16309 (gnus-message 5 "%sdone" mesg))))))
16310 (setq methods (cdr methods))))))
16312 ;; Read an active file and place the results in `gnus-active-hashtb'.
16313 (defun gnus-active-to-gnus-format (&optional method hashtb ignore-errors)
16314 (unless method
16315 (setq method gnus-select-method))
16316 (let ((cur (current-buffer))
16317 (hashtb (or hashtb
16318 (if (and gnus-active-hashtb
16319 (not (equal method gnus-select-method)))
16320 gnus-active-hashtb
16321 (setq gnus-active-hashtb
16322 (if (equal method gnus-select-method)
16323 (gnus-make-hashtable
16324 (count-lines (point-min) (point-max)))
16325 (gnus-make-hashtable 4096)))))))
16326 ;; Delete unnecessary lines.
16327 (goto-char (point-min))
16328 (while (search-forward "\nto." nil t)
16329 (delete-region (1+ (match-beginning 0))
16330 (progn (forward-line 1) (point))))
16331 (or (string= gnus-ignored-newsgroups "")
16332 (progn
16333 (goto-char (point-min))
16334 (delete-matching-lines gnus-ignored-newsgroups)))
16335 ;; Make the group names readable as a lisp expression even if they
16336 ;; contain special characters.
16337 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
16338 (goto-char (point-max))
16339 (while (re-search-backward "[][';?()#]" nil t)
16340 (insert ?\\))
16341 ;; If these are groups from a foreign select method, we insert the
16342 ;; group prefix in front of the group names.
16343 (and method (not (gnus-server-equal
16344 (gnus-server-get-method nil method)
16345 (gnus-server-get-method nil gnus-select-method)))
16346 (let ((prefix (gnus-group-prefixed-name "" method)))
16347 (goto-char (point-min))
16348 (while (and (not (eobp))
16349 (progn (insert prefix)
16350 (zerop (forward-line 1)))))))
16351 ;; Store the active file in a hash table.
16352 (goto-char (point-min))
16353 (if (string-match "%[oO]" gnus-group-line-format)
16354 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
16355 ;; If we want information on moderated groups, we use this
16356 ;; loop...
16357 (let* ((mod-hashtb (make-vector 7 0))
16358 (m (intern "m" mod-hashtb))
16359 group max min)
16360 (while (not (eobp))
16361 (condition-case nil
16362 (progn
16363 (narrow-to-region (point) (gnus-point-at-eol))
16364 (setq group (let ((obarray hashtb)) (read cur)))
16365 (if (and (numberp (setq max (read cur)))
16366 (numberp (setq min (read cur)))
16367 (progn
16368 (skip-chars-forward " \t")
16369 (not
16370 (or (= (following-char) ?=)
16371 (= (following-char) ?x)
16372 (= (following-char) ?j)))))
16373 (set group (cons min max))
16374 (set group nil))
16375 ;; Enter moderated groups into a list.
16376 (if (eq (let ((obarray mod-hashtb)) (read cur)) m)
16377 (setq gnus-moderated-list
16378 (cons (symbol-name group) gnus-moderated-list))))
16379 (error
16380 (and group
16381 (symbolp group)
16382 (set group nil))))
16383 (widen)
16384 (forward-line 1)))
16385 ;; And if we do not care about moderation, we use this loop,
16386 ;; which is faster.
16387 (let (group max min)
16388 (while (not (eobp))
16389 (condition-case ()
16390 (progn
16391 (narrow-to-region (point) (gnus-point-at-eol))
16392 ;; group gets set to a symbol interned in the hash table
16393 ;; (what a hack!!) - jwz
16394 (setq group (let ((obarray hashtb)) (read cur)))
16395 (if (and (numberp (setq max (read cur)))
16396 (numberp (setq min (read cur)))
16397 (progn
16398 (skip-chars-forward " \t")
16399 (not
16400 (or (= (following-char) ?=)
16401 (= (following-char) ?x)
16402 (= (following-char) ?j)))))
16403 (set group (cons min max))
16404 (set group nil)))
16405 (error
16406 (progn
16407 (and group
16408 (symbolp group)
16409 (set group nil))
16410 (or ignore-errors
16411 (gnus-message 3 "Warning - illegal active: %s"
16412 (buffer-substring
16413 (gnus-point-at-bol) (gnus-point-at-eol)))))))
16414 (widen)
16415 (forward-line 1))))))
16417 (defun gnus-groups-to-gnus-format (method &optional hashtb)
16418 ;; Parse a "groups" active file.
16419 (let ((cur (current-buffer))
16420 (hashtb (or hashtb
16421 (if (and method gnus-active-hashtb)
16422 gnus-active-hashtb
16423 (setq gnus-active-hashtb
16424 (gnus-make-hashtable
16425 (count-lines (point-min) (point-max)))))))
16426 (prefix (and method
16427 (not (gnus-server-equal
16428 (gnus-server-get-method nil method)
16429 (gnus-server-get-method nil gnus-select-method)))
16430 (gnus-group-prefixed-name "" method))))
16432 (goto-char (point-min))
16433 ;; We split this into to separate loops, one with the prefix
16434 ;; and one without to speed the reading up somewhat.
16435 (if prefix
16436 (let (min max opoint group)
16437 (while (not (eobp))
16438 (condition-case ()
16439 (progn
16440 (read cur) (read cur)
16441 (setq min (read cur)
16442 max (read cur)
16443 opoint (point))
16444 (skip-chars-forward " \t")
16445 (insert prefix)
16446 (goto-char opoint)
16447 (set (let ((obarray hashtb)) (read cur))
16448 (cons min max)))
16449 (error (and group (symbolp group) (set group nil))))
16450 (forward-line 1)))
16451 (let (min max group)
16452 (while (not (eobp))
16453 (condition-case ()
16454 (if (= (following-char) ?2)
16455 (progn
16456 (read cur) (read cur)
16457 (setq min (read cur)
16458 max (read cur))
16459 (set (setq group (let ((obarray hashtb)) (read cur)))
16460 (cons min max))))
16461 (error (and group (symbolp group) (set group nil))))
16462 (forward-line 1))))))
16464 (defun gnus-read-newsrc-file (&optional force)
16465 "Read startup file.
16466 If FORCE is non-nil, the .newsrc file is read."
16467 ;; Reset variables that might be defined in the .newsrc.eld file.
16468 (let ((variables gnus-variable-list))
16469 (while variables
16470 (set (car variables) nil)
16471 (setq variables (cdr variables))))
16472 (let* ((newsrc-file gnus-current-startup-file)
16473 (quick-file (concat newsrc-file ".el")))
16474 (save-excursion
16475 ;; We always load the .newsrc.eld file. If always contains
16476 ;; much information that can not be gotten from the .newsrc
16477 ;; file (ticked articles, killed groups, foreign methods, etc.)
16478 (gnus-read-newsrc-el-file quick-file)
16480 (if (and (file-exists-p gnus-current-startup-file)
16481 (or force
16482 (and (file-newer-than-file-p newsrc-file quick-file)
16483 (file-newer-than-file-p newsrc-file
16484 (concat quick-file "d")))
16485 (not gnus-newsrc-alist)))
16486 ;; We read the .newsrc file. Note that if there if a
16487 ;; .newsrc.eld file exists, it has already been read, and
16488 ;; the `gnus-newsrc-hashtb' has been created. While reading
16489 ;; the .newsrc file, Gnus will only use the information it
16490 ;; can find there for changing the data already read -
16491 ;; ie. reading the .newsrc file will not trash the data
16492 ;; already read (except for read articles).
16493 (save-excursion
16494 (gnus-message 5 "Reading %s..." newsrc-file)
16495 (set-buffer (find-file-noselect newsrc-file))
16496 (buffer-disable-undo (current-buffer))
16497 (gnus-newsrc-to-gnus-format)
16498 (kill-buffer (current-buffer))
16499 (gnus-message 5 "Reading %s...done" newsrc-file)))
16501 ;; Read any slave files.
16502 (unless gnus-slave
16503 (gnus-master-read-slave-newsrc))
16505 ;; Convert old to new.
16506 (gnus-convert-old-newsrc))))
16508 (defun gnus-continuum-version (version)
16509 "Return VERSION as a floating point number."
16510 (when (or (string-match "^\\([^ ]+\\)? ?Gnus v?\\([0-9.]+\\)$" version)
16511 (string-match "^\\(.?\\)gnus-\\([0-9.]+\\)$" version))
16512 (let* ((alpha (and (match-beginning 1) (match-string 1 version)))
16513 (number (match-string 2 version))
16514 major minor least)
16515 (string-match "\\([0-9]\\)\\.\\([0-9]+\\)\\.?\\([0-9]+\\)?" number)
16516 (setq major (string-to-number (match-string 1 number)))
16517 (setq minor (string-to-number (match-string 2 number)))
16518 (setq least (if (match-beginning 3)
16519 (string-to-number (match-string 3 number))
16521 (string-to-number
16522 (if (zerop major)
16523 (format "%s00%02d%02d"
16524 (cond
16525 ((member alpha '("(ding)" "d")) "4.99")
16526 ((member alpha '("September" "s")) "5.01")
16527 ((member alpha '("Red" "r")) "5.03"))
16528 minor least)
16529 (format "%d.%02d%02d" major minor least))))))
16531 (defun gnus-convert-old-newsrc ()
16532 "Convert old newsrc into the new format, if needed."
16533 (let ((fcv (and gnus-newsrc-file-version
16534 (gnus-continuum-version gnus-newsrc-file-version))))
16535 (cond
16536 ;; No .newsrc.eld file was loaded.
16537 ((null fcv) nil)
16538 ;; Gnus 5 .newsrc.eld was loaded.
16539 ((< fcv (gnus-continuum-version "September Gnus v0.1"))
16540 (gnus-convert-old-ticks)))))
16542 (defun gnus-convert-old-ticks ()
16543 (let ((newsrc (cdr gnus-newsrc-alist))
16544 marks info dormant ticked)
16545 (while (setq info (pop newsrc))
16546 (when (setq marks (gnus-info-marks info))
16547 (setq dormant (cdr (assq 'dormant marks))
16548 ticked (cdr (assq 'tick marks)))
16549 (when (or dormant ticked)
16550 (gnus-info-set-read
16551 info
16552 (gnus-add-to-range
16553 (gnus-info-read info)
16554 (nconc (gnus-uncompress-range dormant)
16555 (gnus-uncompress-range ticked)))))))))
16557 (defun gnus-read-newsrc-el-file (file)
16558 (let ((ding-file (concat file "d")))
16559 ;; We always, always read the .eld file.
16560 (gnus-message 5 "Reading %s..." ding-file)
16561 (let (gnus-newsrc-assoc)
16562 (condition-case nil
16563 (load ding-file t t t)
16564 (error
16565 (gnus-error 1 "Error in %s" ding-file)))
16566 (when gnus-newsrc-assoc
16567 (setq gnus-newsrc-alist gnus-newsrc-assoc)))
16568 (gnus-make-hashtable-from-newsrc-alist)
16569 (when (file-newer-than-file-p file ding-file)
16570 ;; Old format quick file
16571 (gnus-message 5 "Reading %s..." file)
16572 ;; The .el file is newer than the .eld file, so we read that one
16573 ;; as well.
16574 (gnus-read-old-newsrc-el-file file))))
16576 ;; Parse the old-style quick startup file
16577 (defun gnus-read-old-newsrc-el-file (file)
16578 (let (newsrc killed marked group m info)
16579 (prog1
16580 (let ((gnus-killed-assoc nil)
16581 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc)
16582 (prog1
16583 (condition-case nil
16584 (load file t t t)
16585 (error nil))
16586 (setq newsrc gnus-newsrc-assoc
16587 killed gnus-killed-assoc
16588 marked gnus-marked-assoc)))
16589 (setq gnus-newsrc-alist nil)
16590 (while (setq group (pop newsrc))
16591 (if (setq info (gnus-get-info (car group)))
16592 (progn
16593 (gnus-info-set-read info (cddr group))
16594 (gnus-info-set-level
16595 info (if (nth 1 group) gnus-level-default-subscribed
16596 gnus-level-default-unsubscribed))
16597 (setq gnus-newsrc-alist (cons info gnus-newsrc-alist)))
16598 (push (setq info
16599 (list (car group)
16600 (if (nth 1 group) gnus-level-default-subscribed
16601 gnus-level-default-unsubscribed)
16602 (cddr group)))
16603 gnus-newsrc-alist))
16604 ;; Copy marks into info.
16605 (when (setq m (assoc (car group) marked))
16606 (unless (nthcdr 3 info)
16607 (nconc info (list nil)))
16608 (gnus-info-set-marks
16609 info (list (cons 'tick (gnus-compress-sequence
16610 (sort (cdr m) '<) t))))))
16611 (setq newsrc killed)
16612 (while newsrc
16613 (setcar newsrc (caar newsrc))
16614 (setq newsrc (cdr newsrc)))
16615 (setq gnus-killed-list killed))
16616 ;; The .el file version of this variable does not begin with
16617 ;; "options", while the .eld version does, so we just add it if it
16618 ;; isn't there.
16619 (and
16620 gnus-newsrc-options
16621 (progn
16622 (and (not (string-match "^ *options" gnus-newsrc-options))
16623 (setq gnus-newsrc-options (concat "options " gnus-newsrc-options)))
16624 (and (not (string-match "\n$" gnus-newsrc-options))
16625 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n")))
16626 ;; Finally, if we read some options lines, we parse them.
16627 (or (string= gnus-newsrc-options "")
16628 (gnus-newsrc-parse-options gnus-newsrc-options))))
16630 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))
16631 (gnus-make-hashtable-from-newsrc-alist)))
16633 (defun gnus-make-newsrc-file (file)
16634 "Make server dependent file name by catenating FILE and server host name."
16635 (let* ((file (expand-file-name file nil))
16636 (real-file (concat file "-" (nth 1 gnus-select-method))))
16637 (if (or (file-exists-p real-file)
16638 (file-exists-p (concat real-file ".el"))
16639 (file-exists-p (concat real-file ".eld")))
16640 real-file file)))
16642 (defun gnus-newsrc-to-gnus-format ()
16643 (setq gnus-newsrc-options "")
16644 (setq gnus-newsrc-options-n nil)
16646 (or gnus-active-hashtb
16647 (setq gnus-active-hashtb (make-vector 4095 0)))
16648 (let ((buf (current-buffer))
16649 (already-read (> (length gnus-newsrc-alist) 1))
16650 group subscribed options-symbol newsrc Options-symbol
16651 symbol reads num1)
16652 (goto-char (point-min))
16653 ;; We intern the symbol `options' in the active hashtb so that we
16654 ;; can `eq' against it later.
16655 (set (setq options-symbol (intern "options" gnus-active-hashtb)) nil)
16656 (set (setq Options-symbol (intern "Options" gnus-active-hashtb)) nil)
16658 (while (not (eobp))
16659 ;; We first read the first word on the line by narrowing and
16660 ;; then reading into `gnus-active-hashtb'. Most groups will
16661 ;; already exist in that hashtb, so this will save some string
16662 ;; space.
16663 (narrow-to-region
16664 (point)
16665 (progn (skip-chars-forward "^ \t!:\n") (point)))
16666 (goto-char (point-min))
16667 (setq symbol
16668 (and (/= (point-min) (point-max))
16669 (let ((obarray gnus-active-hashtb)) (read buf))))
16670 (widen)
16671 ;; Now, the symbol we have read is either `options' or a group
16672 ;; name. If it is an options line, we just add it to a string.
16673 (cond
16674 ((or (eq symbol options-symbol)
16675 (eq symbol Options-symbol))
16676 (setq gnus-newsrc-options
16677 ;; This concating is quite inefficient, but since our
16678 ;; thorough studies show that approx 99.37% of all
16679 ;; .newsrc files only contain a single options line, we
16680 ;; don't give a damn, frankly, my dear.
16681 (concat gnus-newsrc-options
16682 (buffer-substring
16683 (gnus-point-at-bol)
16684 ;; Options may continue on the next line.
16685 (or (and (re-search-forward "^[^ \t]" nil 'move)
16686 (progn (beginning-of-line) (point)))
16687 (point)))))
16688 (forward-line -1))
16689 (symbol
16690 ;; Group names can be just numbers.
16691 (when (numberp symbol)
16692 (setq symbol (intern (int-to-string symbol) gnus-active-hashtb)))
16693 (or (boundp symbol) (set symbol nil))
16694 ;; It was a group name.
16695 (setq subscribed (= (following-char) ?:)
16696 group (symbol-name symbol)
16697 reads nil)
16698 (if (eolp)
16699 ;; If the line ends here, this is clearly a buggy line, so
16700 ;; we put point a the beginning of line and let the cond
16701 ;; below do the error handling.
16702 (beginning-of-line)
16703 ;; We skip to the beginning of the ranges.
16704 (skip-chars-forward "!: \t"))
16705 ;; We are now at the beginning of the list of read articles.
16706 ;; We read them range by range.
16707 (while
16708 (cond
16709 ((looking-at "[0-9]+")
16710 ;; We narrow and read a number instead of buffer-substring/
16711 ;; string-to-int because it's faster. narrow/widen is
16712 ;; faster than save-restriction/narrow, and save-restriction
16713 ;; produces a garbage object.
16714 (setq num1 (progn
16715 (narrow-to-region (match-beginning 0) (match-end 0))
16716 (read buf)))
16717 (widen)
16718 ;; If the next character is a dash, then this is a range.
16719 (if (= (following-char) ?-)
16720 (progn
16721 ;; We read the upper bound of the range.
16722 (forward-char 1)
16723 (if (not (looking-at "[0-9]+"))
16724 ;; This is a buggy line, by we pretend that
16725 ;; it's kinda OK. Perhaps the user should be
16726 ;; dinged?
16727 (setq reads (cons num1 reads))
16728 (setq reads
16729 (cons
16730 (cons num1
16731 (progn
16732 (narrow-to-region (match-beginning 0)
16733 (match-end 0))
16734 (read buf)))
16735 reads))
16736 (widen)))
16737 ;; It was just a simple number, so we add it to the
16738 ;; list of ranges.
16739 (setq reads (cons num1 reads)))
16740 ;; If the next char in ?\n, then we have reached the end
16741 ;; of the line and return nil.
16742 (/= (following-char) ?\n))
16743 ((= (following-char) ?\n)
16744 ;; End of line, so we end.
16745 nil)
16747 ;; Not numbers and not eol, so this might be a buggy
16748 ;; line...
16749 (or (eobp)
16750 ;; If it was eob instead of ?\n, we allow it.
16751 (progn
16752 ;; The line was buggy.
16753 (setq group nil)
16754 (gnus-error 3.1 "Mangled line: %s"
16755 (buffer-substring (gnus-point-at-bol)
16756 (gnus-point-at-eol)))))
16757 nil))
16758 ;; Skip past ", ". Spaces are illegal in these ranges, but
16759 ;; we allow them, because it's a common mistake to put a
16760 ;; space after the comma.
16761 (skip-chars-forward ", "))
16763 ;; We have already read .newsrc.eld, so we gently update the
16764 ;; data in the hash table with the information we have just
16765 ;; read.
16766 (when group
16767 (let ((info (gnus-get-info group))
16768 level)
16769 (if info
16770 ;; There is an entry for this file in the alist.
16771 (progn
16772 (gnus-info-set-read info (nreverse reads))
16773 ;; We update the level very gently. In fact, we
16774 ;; only change it if there's been a status change
16775 ;; from subscribed to unsubscribed, or vice versa.
16776 (setq level (gnus-info-level info))
16777 (cond ((and (<= level gnus-level-subscribed)
16778 (not subscribed))
16779 (setq level (if reads
16780 gnus-level-default-unsubscribed
16781 (1+ gnus-level-default-unsubscribed))))
16782 ((and (> level gnus-level-subscribed) subscribed)
16783 (setq level gnus-level-default-subscribed)))
16784 (gnus-info-set-level info level))
16785 ;; This is a new group.
16786 (setq info (list group
16787 (if subscribed
16788 gnus-level-default-subscribed
16789 (if reads
16790 (1+ gnus-level-subscribed)
16791 gnus-level-default-unsubscribed))
16792 (nreverse reads))))
16793 (setq newsrc (cons info newsrc))))))
16794 (forward-line 1))
16796 (setq newsrc (nreverse newsrc))
16798 (if (not already-read)
16800 ;; We now have two newsrc lists - `newsrc', which is what we
16801 ;; have read from .newsrc, and `gnus-newsrc-alist', which is
16802 ;; what we've read from .newsrc.eld. We have to merge these
16803 ;; lists. We do this by "attaching" any (foreign) groups in the
16804 ;; gnus-newsrc-alist to the (native) group that precedes them.
16805 (let ((rc (cdr gnus-newsrc-alist))
16806 (prev gnus-newsrc-alist)
16807 entry mentry)
16808 (while rc
16809 (or (null (nth 4 (car rc))) ; It's a native group.
16810 (assoc (caar rc) newsrc) ; It's already in the alist.
16811 (if (setq entry (assoc (caar prev) newsrc))
16812 (setcdr (setq mentry (memq entry newsrc))
16813 (cons (car rc) (cdr mentry)))
16814 (setq newsrc (cons (car rc) newsrc))))
16815 (setq prev rc
16816 rc (cdr rc)))))
16818 (setq gnus-newsrc-alist newsrc)
16819 ;; We make the newsrc hashtb.
16820 (gnus-make-hashtable-from-newsrc-alist)
16822 ;; Finally, if we read some options lines, we parse them.
16823 (or (string= gnus-newsrc-options "")
16824 (gnus-newsrc-parse-options gnus-newsrc-options))))
16826 ;; Parse options lines to find "options -n !all rec.all" and stuff.
16827 ;; The return value will be a list on the form
16828 ;; ((regexp1 . ignore)
16829 ;; (regexp2 . subscribe)...)
16830 ;; When handling new newsgroups, groups that match a `ignore' regexp
16831 ;; will be ignored, and groups that match a `subscribe' regexp will be
16832 ;; subscribed. A line like
16833 ;; options -n !all rec.all
16834 ;; will lead to a list that looks like
16835 ;; (("^rec\\..+" . subscribe)
16836 ;; ("^.+" . ignore))
16837 ;; So all "rec.*" groups will be subscribed, while all the other
16838 ;; groups will be ignored. Note that "options -n !all rec.all" is very
16839 ;; different from "options -n rec.all !all".
16840 (defun gnus-newsrc-parse-options (options)
16841 (let (out eol)
16842 (save-excursion
16843 (gnus-set-work-buffer)
16844 (insert (regexp-quote options))
16845 ;; First we treat all continuation lines.
16846 (goto-char (point-min))
16847 (while (re-search-forward "\n[ \t]+" nil t)
16848 (replace-match " " t t))
16849 ;; Then we transform all "all"s into ".+"s.
16850 (goto-char (point-min))
16851 (while (re-search-forward "\\ball\\b" nil t)
16852 (replace-match ".+" t t))
16853 (goto-char (point-min))
16854 ;; We remove all other options than the "-n" ones.
16855 (while (re-search-forward "[ \t]-[^n][^-]*" nil t)
16856 (replace-match " ")
16857 (forward-char -1))
16858 (goto-char (point-min))
16860 ;; We are only interested in "options -n" lines - we
16861 ;; ignore the other option lines.
16862 (while (re-search-forward "[ \t]-n" nil t)
16863 (setq eol
16864 (or (save-excursion
16865 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t)
16866 (- (point) 2)))
16867 (gnus-point-at-eol)))
16868 ;; Search for all "words"...
16869 (while (re-search-forward "[^ \t,\n]+" eol t)
16870 (if (= (char-after (match-beginning 0)) ?!)
16871 ;; If the word begins with a bang (!), this is a "not"
16872 ;; spec. We put this spec (minus the bang) and the
16873 ;; symbol `ignore' into the list.
16874 (setq out (cons (cons (concat
16875 "^" (buffer-substring
16876 (1+ (match-beginning 0))
16877 (match-end 0)))
16878 'ignore) out))
16879 ;; There was no bang, so this is a "yes" spec.
16880 (setq out (cons (cons (concat "^" (match-string 0))
16881 'subscribe) out)))))
16883 (setq gnus-newsrc-options-n out))))
16885 (defun gnus-save-newsrc-file (&optional force)
16886 "Save .newsrc file."
16887 ;; Note: We cannot save .newsrc file if all newsgroups are removed
16888 ;; from the variable gnus-newsrc-alist.
16889 (when (and (or gnus-newsrc-alist gnus-killed-list)
16890 gnus-current-startup-file)
16891 (save-excursion
16892 (if (and (or gnus-use-dribble-file gnus-slave)
16893 (not force)
16894 (or (not gnus-dribble-buffer)
16895 (not (buffer-name gnus-dribble-buffer))
16896 (zerop (save-excursion
16897 (set-buffer gnus-dribble-buffer)
16898 (buffer-size)))))
16899 (gnus-message 4 "(No changes need to be saved)")
16900 (run-hooks 'gnus-save-newsrc-hook)
16901 (if gnus-slave
16902 (gnus-slave-save-newsrc)
16903 ;; Save .newsrc.
16904 (when gnus-save-newsrc-file
16905 (gnus-message 5 "Saving %s..." gnus-current-startup-file)
16906 (gnus-gnus-to-newsrc-format)
16907 (gnus-message 5 "Saving %s...done" gnus-current-startup-file))
16908 ;; Save .newsrc.eld.
16909 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
16910 (make-local-variable 'version-control)
16911 (setq version-control 'never)
16912 (setq buffer-file-name
16913 (concat gnus-current-startup-file ".eld"))
16914 (setq default-directory (file-name-directory buffer-file-name))
16915 (gnus-add-current-to-buffer-list)
16916 (buffer-disable-undo (current-buffer))
16917 (erase-buffer)
16918 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file)
16919 (gnus-gnus-to-quick-newsrc-format)
16920 (run-hooks 'gnus-save-quick-newsrc-hook)
16921 (save-buffer)
16922 (kill-buffer (current-buffer))
16923 (gnus-message
16924 5 "Saving %s.eld...done" gnus-current-startup-file))
16925 (gnus-dribble-delete-file)
16926 (gnus-group-set-mode-line)))))
16928 (defun gnus-gnus-to-quick-newsrc-format ()
16929 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
16930 (insert ";; Gnus startup file.\n")
16931 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
16932 (insert ";; to read .newsrc.\n")
16933 (insert "(setq gnus-newsrc-file-version "
16934 (prin1-to-string gnus-version) ")\n")
16935 (let ((variables
16936 (if gnus-save-killed-list gnus-variable-list
16937 ;; Remove the `gnus-killed-list' from the list of variables
16938 ;; to be saved, if required.
16939 (delq 'gnus-killed-list (copy-sequence gnus-variable-list))))
16940 ;; Peel off the "dummy" group.
16941 (gnus-newsrc-alist (cdr gnus-newsrc-alist))
16942 variable)
16943 ;; Insert the variables into the file.
16944 (while variables
16945 (when (and (boundp (setq variable (pop variables)))
16946 (symbol-value variable))
16947 (insert "(setq " (symbol-name variable) " '")
16948 (prin1 (symbol-value variable) (current-buffer))
16949 (insert ")\n")))))
16951 (defun gnus-gnus-to-newsrc-format ()
16952 ;; Generate and save the .newsrc file.
16953 (save-excursion
16954 (set-buffer (create-file-buffer gnus-current-startup-file))
16955 (let ((newsrc (cdr gnus-newsrc-alist))
16956 (standard-output (current-buffer))
16957 info ranges range method)
16958 (setq buffer-file-name gnus-current-startup-file)
16959 (setq default-directory (file-name-directory buffer-file-name))
16960 (buffer-disable-undo (current-buffer))
16961 (erase-buffer)
16962 ;; Write options.
16963 (if gnus-newsrc-options (insert gnus-newsrc-options))
16964 ;; Write subscribed and unsubscribed.
16965 (while (setq info (pop newsrc))
16966 ;; Don't write foreign groups to .newsrc.
16967 (when (or (null (setq method (gnus-info-method info)))
16968 (equal method "native")
16969 (gnus-server-equal method gnus-select-method))
16970 (insert (gnus-info-group info)
16971 (if (> (gnus-info-level info) gnus-level-subscribed)
16972 "!" ":"))
16973 (when (setq ranges (gnus-info-read info))
16974 (insert " ")
16975 (if (not (listp (cdr ranges)))
16976 (if (= (car ranges) (cdr ranges))
16977 (princ (car ranges))
16978 (princ (car ranges))
16979 (insert "-")
16980 (princ (cdr ranges)))
16981 (while (setq range (pop ranges))
16982 (if (or (atom range) (= (car range) (cdr range)))
16983 (princ (or (and (atom range) range) (car range)))
16984 (princ (car range))
16985 (insert "-")
16986 (princ (cdr range)))
16987 (if ranges (insert ",")))))
16988 (insert "\n")))
16989 (make-local-variable 'version-control)
16990 (setq version-control 'never)
16991 ;; It has been reported that sometime the modtime on the .newsrc
16992 ;; file seems to be off. We really do want to overwrite it, so
16993 ;; we clear the modtime here before saving. It's a bit odd,
16994 ;; though...
16995 ;; sometimes the modtime clear isn't sufficient. most brute force:
16996 ;; delete the silly thing entirely first. but this fails to provide
16997 ;; such niceties as .newsrc~ creation.
16998 (if gnus-modtime-botch
16999 (delete-file gnus-startup-file)
17000 (clear-visited-file-modtime))
17001 (run-hooks 'gnus-save-standard-newsrc-hook)
17002 (save-buffer)
17003 (kill-buffer (current-buffer)))))
17007 ;;; Slave functions.
17010 (defun gnus-slave-save-newsrc ()
17011 (save-excursion
17012 (set-buffer gnus-dribble-buffer)
17013 (let ((slave-name
17014 (make-temp-name (concat gnus-current-startup-file "-slave-"))))
17015 (write-region (point-min) (point-max) slave-name nil 'nomesg))))
17017 (defun gnus-master-read-slave-newsrc ()
17018 (let ((slave-files
17019 (directory-files
17020 (file-name-directory gnus-current-startup-file)
17021 t (concat
17022 "^" (regexp-quote
17023 (concat
17024 (file-name-nondirectory gnus-current-startup-file)
17025 "-slave-")))
17027 file)
17028 (if (not slave-files)
17029 () ; There are no slave files to read.
17030 (gnus-message 7 "Reading slave newsrcs...")
17031 (save-excursion
17032 (set-buffer (get-buffer-create " *gnus slave*"))
17033 (buffer-disable-undo (current-buffer))
17034 (setq slave-files
17035 (sort (mapcar (lambda (file)
17036 (list (nth 5 (file-attributes file)) file))
17037 slave-files)
17038 (lambda (f1 f2)
17039 (or (< (caar f1) (caar f2))
17040 (< (nth 1 (car f1)) (nth 1 (car f2)))))))
17041 (while slave-files
17042 (erase-buffer)
17043 (setq file (nth 1 (car slave-files)))
17044 (insert-file-contents file)
17045 (if (condition-case ()
17046 (progn
17047 (eval-buffer (current-buffer))
17049 (error
17050 (gnus-error 3.2 "Possible error in %s" file)
17051 nil))
17052 (or gnus-slave ; Slaves shouldn't delete these files.
17053 (condition-case ()
17054 (delete-file file)
17055 (error nil))))
17056 (setq slave-files (cdr slave-files))))
17057 (gnus-message 7 "Reading slave newsrcs...done"))))
17061 ;;; Group description.
17064 (defun gnus-read-all-descriptions-files ()
17065 (let ((methods (cons gnus-select-method
17066 (nconc
17067 (when (gnus-archive-server-wanted-p)
17068 (list "archive"))
17069 gnus-secondary-select-methods))))
17070 (while methods
17071 (gnus-read-descriptions-file (car methods))
17072 (setq methods (cdr methods)))
17075 (defun gnus-read-descriptions-file (&optional method)
17076 (let ((method (or method gnus-select-method))
17077 group)
17078 (when (stringp method)
17079 (setq method (gnus-server-to-method method)))
17080 ;; We create the hashtable whether we manage to read the desc file
17081 ;; to avoid trying to re-read after a failed read.
17082 (or gnus-description-hashtb
17083 (setq gnus-description-hashtb
17084 (gnus-make-hashtable (length gnus-active-hashtb))))
17085 ;; Mark this method's desc file as read.
17086 (gnus-sethash (gnus-group-prefixed-name "" method) "Has read"
17087 gnus-description-hashtb)
17089 (gnus-message 5 "Reading descriptions file via %s..." (car method))
17090 (cond
17091 ((not (gnus-check-server method))
17092 (gnus-message 1 "Couldn't open server")
17093 nil)
17094 ((not (gnus-request-list-newsgroups method))
17095 (gnus-message 1 "Couldn't read newsgroups descriptions")
17096 nil)
17098 (save-excursion
17099 (save-restriction
17100 (set-buffer nntp-server-buffer)
17101 (goto-char (point-min))
17102 (when (or (search-forward "\n.\n" nil t)
17103 (goto-char (point-max)))
17104 (beginning-of-line)
17105 (narrow-to-region (point-min) (point)))
17106 ;; If these are groups from a foreign select method, we insert the
17107 ;; group prefix in front of the group names.
17108 (and method (not (gnus-server-equal
17109 (gnus-server-get-method nil method)
17110 (gnus-server-get-method nil gnus-select-method)))
17111 (let ((prefix (gnus-group-prefixed-name "" method)))
17112 (goto-char (point-min))
17113 (while (and (not (eobp))
17114 (progn (insert prefix)
17115 (zerop (forward-line 1)))))))
17116 (goto-char (point-min))
17117 (while (not (eobp))
17118 ;; If we get an error, we set group to 0, which is not a
17119 ;; symbol...
17120 (setq group
17121 (condition-case ()
17122 (let ((obarray gnus-description-hashtb))
17123 ;; Group is set to a symbol interned in this
17124 ;; hash table.
17125 (read nntp-server-buffer))
17126 (error 0)))
17127 (skip-chars-forward " \t")
17128 ;; ... which leads to this line being effectively ignored.
17129 (and (symbolp group)
17130 (set group (buffer-substring
17131 (point) (progn (end-of-line) (point)))))
17132 (forward-line 1))))
17133 (gnus-message 5 "Reading descriptions file...done")
17134 t))))
17136 (defun gnus-group-get-description (group)
17137 "Get the description of a group by sending XGTITLE to the server."
17138 (when (gnus-request-group-description group)
17139 (save-excursion
17140 (set-buffer nntp-server-buffer)
17141 (goto-char (point-min))
17142 (when (looking-at "[^ \t]+[ \t]+\\(.*\\)")
17143 (match-string 1)))))
17147 ;;; Buffering of read articles.
17150 (defvar gnus-backlog-buffer " *Gnus Backlog*")
17151 (defvar gnus-backlog-articles nil)
17152 (defvar gnus-backlog-hashtb nil)
17154 (defun gnus-backlog-buffer ()
17155 "Return the backlog buffer."
17156 (or (get-buffer gnus-backlog-buffer)
17157 (save-excursion
17158 (set-buffer (get-buffer-create gnus-backlog-buffer))
17159 (buffer-disable-undo (current-buffer))
17160 (setq buffer-read-only t)
17161 (gnus-add-current-to-buffer-list)
17162 (get-buffer gnus-backlog-buffer))))
17164 (defun gnus-backlog-setup ()
17165 "Initialize backlog variables."
17166 (unless gnus-backlog-hashtb
17167 (setq gnus-backlog-hashtb (make-vector 1023 0))))
17169 (gnus-add-shutdown 'gnus-backlog-shutdown 'gnus)
17171 (defun gnus-backlog-shutdown ()
17172 "Clear all backlog variables and buffers."
17173 (when (get-buffer gnus-backlog-buffer)
17174 (kill-buffer gnus-backlog-buffer))
17175 (setq gnus-backlog-hashtb nil
17176 gnus-backlog-articles nil))
17178 (defun gnus-backlog-enter-article (group number buffer)
17179 (gnus-backlog-setup)
17180 (let ((ident (intern (concat group ":" (int-to-string number))
17181 gnus-backlog-hashtb))
17183 (if (memq ident gnus-backlog-articles)
17184 () ; It's already kept.
17185 ;; Remove the oldest article, if necessary.
17186 (and (numberp gnus-keep-backlog)
17187 (>= (length gnus-backlog-articles) gnus-keep-backlog)
17188 (gnus-backlog-remove-oldest-article))
17189 (setq gnus-backlog-articles (cons ident gnus-backlog-articles))
17190 ;; Insert the new article.
17191 (save-excursion
17192 (set-buffer (gnus-backlog-buffer))
17193 (let (buffer-read-only)
17194 (goto-char (point-max))
17195 (or (bolp) (insert "\n"))
17196 (setq b (point))
17197 (insert-buffer-substring buffer)
17198 ;; Tag the beginning of the article with the ident.
17199 (gnus-put-text-property b (1+ b) 'gnus-backlog ident))))))
17201 (defun gnus-backlog-remove-oldest-article ()
17202 (save-excursion
17203 (set-buffer (gnus-backlog-buffer))
17204 (goto-char (point-min))
17205 (if (zerop (buffer-size))
17206 () ; The buffer is empty.
17207 (let ((ident (get-text-property (point) 'gnus-backlog))
17208 buffer-read-only)
17209 ;; Remove the ident from the list of articles.
17210 (when ident
17211 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
17212 ;; Delete the article itself.
17213 (delete-region
17214 (point) (next-single-property-change
17215 (1+ (point)) 'gnus-backlog nil (point-max)))))))
17217 (defun gnus-backlog-remove-article (group number)
17218 "Remove article NUMBER in GROUP from the backlog."
17219 (when (numberp number)
17220 (gnus-backlog-setup)
17221 (let ((ident (intern (concat group ":" (int-to-string number))
17222 gnus-backlog-hashtb))
17223 beg end)
17224 (when (memq ident gnus-backlog-articles)
17225 ;; It was in the backlog.
17226 (save-excursion
17227 (set-buffer (gnus-backlog-buffer))
17228 (let (buffer-read-only)
17229 (when (setq beg (text-property-any
17230 (point-min) (point-max) 'gnus-backlog
17231 ident))
17232 ;; Find the end (i. e., the beginning of the next article).
17233 (setq end
17234 (next-single-property-change
17235 (1+ beg) 'gnus-backlog (current-buffer) (point-max)))
17236 (delete-region beg end)
17237 ;; Return success.
17238 t)))))))
17240 (defun gnus-backlog-request-article (group number buffer)
17241 (when (numberp number)
17242 (gnus-backlog-setup)
17243 (let ((ident (intern (concat group ":" (int-to-string number))
17244 gnus-backlog-hashtb))
17245 beg end)
17246 (when (memq ident gnus-backlog-articles)
17247 ;; It was in the backlog.
17248 (save-excursion
17249 (set-buffer (gnus-backlog-buffer))
17250 (if (not (setq beg (text-property-any
17251 (point-min) (point-max) 'gnus-backlog
17252 ident)))
17253 ;; It wasn't in the backlog after all.
17254 (ignore
17255 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
17256 ;; Find the end (i. e., the beginning of the next article).
17257 (setq end
17258 (next-single-property-change
17259 (1+ beg) 'gnus-backlog (current-buffer) (point-max)))))
17260 (let ((buffer-read-only nil))
17261 (erase-buffer)
17262 (insert-buffer-substring gnus-backlog-buffer beg end)
17263 t)))))
17265 ;; Allow redefinition of Gnus functions.
17267 (gnus-ems-redefine)
17269 (provide 'gnus)
17271 ;;; gnus.el ends here