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>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval '(run-hooks 'gnus-load-hook))
38 (eval-when-compile (require 'cl))
41 (defvar gnus-directory (or (getenv "SAVEDIR") "~/News/")
42 "*Directory variable from which all other Gnus file variables are derived.")
44 ;; Site dependent variables. These variables should be defined in
47 (defvar gnus-default-nntp-server nil
48 "Specify a default NNTP server.
49 This variable should be defined in paths.el, and should never be set
51 If you want to change servers, you should use `gnus-select-method'.
52 See the documentation to that variable.")
54 (defvar gnus-backup-default-subscribed-newsgroups
55 '("news.announce.newusers" "news.groups.questions" "gnu.emacs.gnus")
56 "Default default new newsgroups the first time Gnus is run.
57 Should be set in paths.el, and shouldn't be touched by the user.")
59 (defvar gnus-local-domain nil
60 "Local domain name without a host name.
61 The DOMAINNAME environment variable is used instead if it is defined.
62 If the `system-name' function returns the full Internet name, there is
63 no need to set this variable.")
65 (defvar gnus-local-organization nil
66 "String with a description of what organization (if any) the user belongs to.
67 The ORGANIZATION environment variable is used instead if it is defined.
68 If this variable contains a function, this function will be called
69 with the current newsgroup name as the argument. The function should
72 In any case, if the string (either in the variable, in the environment
73 variable, or returned by the function) is a file name, the contents of
74 this file will be used as the organization.")
76 ;; Customization variables
78 ;; Don't touch this variable.
79 (defvar gnus-nntp-service "nntp"
80 "*NNTP service name (\"nntp\" or 119).
81 This is an obsolete variable, which is scarcely used. If you use an
82 nntp server for your newsgroup and want to change the port number
83 used to 899, you would say something along these lines:
85 (setq gnus-select-method '(nntp \"my.nntp.server\" (nntp-port-number 899)))")
87 (defvar gnus-nntpserver-file "/etc/nntpserver"
88 "*A file with only the name of the nntp server in it.")
90 ;; This function is used to check both the environment variable
91 ;; NNTPSERVER and the /etc/nntpserver file to see whether one can find
92 ;; an nntp server name default.
93 (defun gnus-getenv-nntpserver ()
94 (or (getenv "NNTPSERVER")
95 (and (file-readable-p gnus-nntpserver-file)
97 (set-buffer (get-buffer-create " *gnus nntp*"))
98 (buffer-disable-undo (current-buffer))
99 (insert-file-contents gnus-nntpserver-file)
100 (let ((name (buffer-string)))
102 (if (string-match "^[ \t\n]*$" name)
105 (kill-buffer (current-buffer))))))))
107 (defvar gnus-select-method
109 (list 'nntp (or (condition-case ()
110 (gnus-getenv-nntpserver)
112 (if (and gnus-default-nntp-server
113 (not (string= gnus-default-nntp-server "")))
114 gnus-default-nntp-server)
116 (if (or (null gnus-nntp-service)
117 (equal gnus-nntp-service "nntp"))
119 (list gnus-nntp-service)))
120 "*Default method for selecting a newsgroup.
121 This variable should be a list, where the first element is how the
122 news is to be fetched, the second is the address.
124 For instance, if you want to get your news via NNTP from
125 \"flab.flab.edu\", you could say:
127 (setq gnus-select-method '(nntp \"flab.flab.edu\"))
129 If you want to use your local spool, say:
131 (setq gnus-select-method (list 'nnspool (system-name)))
133 If you use this variable, you must set `gnus-nntp-server' to nil.
135 There is a lot more to know about select methods and virtual servers -
136 see the manual for details.")
138 (defvar gnus-message-archive-method
141 (nnfolder-directory ,(nnheader-concat message-directory "archive"))
142 (nnfolder-active-file
143 ,(nnheader-concat message-directory "archive/active"))
144 (nnfolder-get-new-mail nil)
145 (nnfolder-inhibit-expiry t))
146 "*Method used for archiving messages you've sent.
147 This should be a mail method.
149 It's probably not a very effective to change this variable once you've
150 run Gnus once. After doing that, you must edit this server from the
153 (defvar gnus-refer-article-method nil
154 "*Preferred method for fetching an article by Message-ID.
155 If you are reading news from the local spool (with nnspool), fetching
156 articles by Message-ID is painfully slow. By setting this method to an
157 nntp method, you might get acceptable results.
159 The value of this variable must be a valid select method as discussed
160 in the documentation of `gnus-select-method'.")
162 (defvar gnus-secondary-select-methods nil
163 "*A list of secondary methods that will be used for reading news.
164 This is a list where each element is a complete select method (see
165 `gnus-select-method').
167 If, for instance, you want to read your mail with the nnml backend,
168 you could set this variable:
170 (setq gnus-secondary-select-methods '((nnml \"\")))")
172 (defvar gnus-secondary-servers nil
173 "*List of NNTP servers that the user can choose between interactively.
174 To make Gnus query you for a server, you have to give `gnus' a
175 non-numeric prefix - `C-u M-x gnus', in short.")
177 (defvar gnus-nntp-server nil
178 "*The name of the host running the NNTP server.
179 This variable is semi-obsolete. Use the `gnus-select-method'
182 (defvar gnus-startup-file "~/.newsrc"
183 "*Your `.newsrc' file.
184 `.newsrc-SERVER' will be used instead if that exists.")
186 (defvar gnus-init-file "~/.gnus"
187 "*Your Gnus elisp startup file.
188 If a file with the .el or .elc suffixes exist, it will be read
191 (defvar gnus-group-faq-directory
192 '("/ftp@mirrors.aol.com:/pub/rtfm/usenet/"
193 "/ftp@sunsite.auc.dk:/pub/usenet/"
194 "/ftp@src.doc.ic.ac.uk:/usenet/news-FAQS/"
195 "/ftp@ftp.seas.gwu.edu:/pub/rtfm/"
196 "/ftp@rtfm.mit.edu:/pub/usenet/"
197 "/ftp@ftp.uni-paderborn.de:/pub/FAQ/"
198 "/ftp@ftp.sunet.se:/pub/usenet/"
199 "/ftp@nctuccca.edu.tw:/USENET/FAQ/"
200 "/ftp@hwarang.postech.ac.kr:/pub/usenet/"
201 "/ftp@ftp.hk.super.net:/mirror/faqs/")
202 "*Directory where the group FAQs are stored.
203 This will most commonly be on a remote machine, and the file will be
206 This variable can also be a list of directories. In that case, the
207 first element in the list will be used by default, and the others will
208 be used as backup sites.
210 Note that Gnus uses an aol machine as the default directory. If this
211 feels fundamentally unclean, just think of it as a way to finally get
212 something of value back from them.
214 If the default site is too slow, try one of these:
216 North America: mirrors.aol.com /pub/rtfm/usenet
217 ftp.seas.gwu.edu /pub/rtfm
218 rtfm.mit.edu /pub/usenet
219 Europe: ftp.uni-paderborn.de /pub/FAQ
220 src.doc.ic.ac.uk /usenet/news-FAQS
221 ftp.sunet.se /pub/usenet
222 sunsite.auc.dk /pub/usenet
223 Asia: nctuccca.edu.tw /USENET/FAQ
224 hwarang.postech.ac.kr /pub/usenet
225 ftp.hk.super.net /mirror/faqs")
227 (defvar gnus-group-archive-directory
228 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
229 "*The address of the (ding) archives.")
231 (defvar gnus-group-recent-archive-directory
232 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
233 "*The address of the most recent (ding) articles.")
235 (defvar gnus-default-subscribed-newsgroups nil
236 "*This variable lists what newsgroups should be subscribed the first time Gnus is used.
237 It should be a list of strings.
238 If it is `t', Gnus will not do anything special the first time it is
239 started; it'll just use the normal newsgroups subscription methods.")
241 (defvar gnus-use-cross-reference t
242 "*Non-nil means that cross referenced articles will be marked as read.
243 If nil, ignore cross references. If t, mark articles as read in
244 subscribed newsgroups. If neither t nor nil, mark as read in all
247 (defvar gnus-single-article-buffer t
248 "*If non-nil, display all articles in the same buffer.
249 If nil, each group will get its own article buffer.")
251 (defvar gnus-use-dribble-file t
252 "*Non-nil means that Gnus will use a dribble file to store user updates.
253 If Emacs should crash without saving the .newsrc files, complete
254 information can be restored from the dribble file.")
256 (defvar gnus-dribble-directory nil
257 "*The directory where dribble files will be saved.
258 If this variable is nil, the directory where the .newsrc files are
259 saved will be used.")
261 (defvar gnus-asynchronous nil
262 "*If non-nil, Gnus will supply backends with data needed for async article fetching.")
264 (defvar gnus-kill-summary-on-exit t
265 "*If non-nil, kill the summary buffer when you exit from it.
266 If nil, the summary will become a \"*Dead Summary*\" buffer, and
267 it will be killed sometime later.")
269 (defvar gnus-large-newsgroup 200
270 "*The number of articles which indicates a large newsgroup.
271 If the number of articles in a newsgroup is greater than this value,
272 confirmation is required for selecting the newsgroup.")
274 ;; Suggested by Andrew Eskilsson <pi92ae@lelle.pt.hk-r.se>.
275 (defvar gnus-no-groups-message "No news is horrible news"
276 "*Message displayed by Gnus when no groups are available.")
278 (defvar gnus-use-long-file-name (not (memq system-type '(usg-unix-v xenix)))
279 "*Non-nil means that the default name of a file to save articles in is the group name.
280 If it's nil, the directory form of the group name is used instead.
282 If this variable is a list, and the list contains the element
283 `not-score', long file names will not be used for score files; if it
284 contains the element `not-save', long file names will not be used for
285 saving; and if it contains the element `not-kill', long file names
286 will not be used for kill files.")
288 (defvar gnus-article-save-directory gnus-directory
289 "*Name of the directory articles will be saved in (default \"~/News\").")
291 (defvar gnus-kill-files-directory gnus-directory
292 "*Name of the directory where kill files will be stored (default \"~/News\").")
294 (defvar gnus-default-article-saver 'gnus-summary-save-in-rmail
295 "*A function to save articles in your favorite format.
296 The function must be interactively callable (in other words, it must
297 be an Emacs command).
299 Gnus provides the following functions:
301 * gnus-summary-save-in-rmail (Rmail format)
302 * gnus-summary-save-in-mail (Unix mail format)
303 * gnus-summary-save-in-folder (MH folder)
304 * gnus-summary-save-in-file (article format).
305 * gnus-summary-save-in-vm (use VM's folder format).")
307 (defvar gnus-prompt-before-saving 'always
308 "*This variable says how much prompting is to be done when saving articles.
309 If it is nil, no prompting will be done, and the articles will be
310 saved to the default files. If this variable is `always', each and
311 every article that is saved will be preceded by a prompt, even when
312 saving large batches of articles. If this variable is neither nil not
313 `always', there the user will be prompted once for a file name for
314 each invocation of the saving commands.")
316 (defvar gnus-rmail-save-name (function gnus-plain-save-name)
317 "*A function generating a file name to save articles in Rmail format.
318 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
320 (defvar gnus-mail-save-name (function gnus-plain-save-name)
321 "*A function generating a file name to save articles in Unix mail format.
322 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
324 (defvar gnus-folder-save-name (function gnus-folder-save-name)
325 "*A function generating a file name to save articles in MH folder.
326 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER.")
328 (defvar gnus-file-save-name (function gnus-numeric-save-name)
329 "*A function generating a file name to save articles in article format.
330 The function is called with NEWSGROUP, HEADERS, and optional
333 (defvar gnus-split-methods
334 '((gnus-article-archive-name))
335 "*Variable used to suggest where articles are to be saved.
336 For instance, if you would like to save articles related to Gnus in
337 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
338 you could set this variable to something like:
340 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
341 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
343 This variable is an alist where the where the key is the match and the
344 value is a list of possible files to save in if the match is non-nil.
346 If the match is a string, it is used as a regexp match on the
347 article. If the match is a symbol, that symbol will be funcalled
348 from the buffer of the article to be saved with the newsgroup as the
349 parameter. If it is a list, it will be evaled in the same buffer.
351 If this form or function returns a string, this string will be used as
352 a possible file name; and if it returns a non-nil list, that list will
353 be used as possible file names.")
355 (defvar gnus-move-split-methods nil
356 "*Variable used to suggest where articles are to be moved to.
357 It uses the same syntax as the `gnus-split-methods' variable.")
359 (defvar gnus-save-score nil
360 "*If non-nil, save group scoring info.")
362 (defvar gnus-use-adaptive-scoring nil
363 "*If non-nil, use some adaptive scoring scheme.")
365 (defvar gnus-use-cache 'passive
366 "*If nil, Gnus will ignore the article cache.
367 If `passive', it will allow entering (and reading) articles
368 explicitly entered into the cache. If anything else, use the
369 cache to the full extent of the law.")
371 (defvar gnus-use-trees nil
372 "*If non-nil, display a thread tree buffer.")
374 (defvar gnus-use-grouplens nil
375 "*If non-nil, use GroupLens ratings.")
377 (defvar gnus-keep-backlog nil
378 "*If non-nil, Gnus will keep read articles for later re-retrieval.
379 If it is a number N, then Gnus will only keep the last N articles
380 read. If it is neither nil nor a number, Gnus will keep all read
381 articles. This is not a good idea.")
383 (defvar gnus-use-nocem nil
384 "*If non-nil, Gnus will read NoCeM cancel messages.")
386 (defvar gnus-use-demon nil
387 "If non-nil, Gnus might use some demons.")
389 (defvar gnus-use-scoring t
390 "*If non-nil, enable scoring.")
392 (defvar gnus-use-picons nil
393 "*If non-nil, display picons.")
395 (defvar gnus-fetch-old-headers nil
396 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
397 If an unread article in the group refers to an older, already read (or
398 just marked as read) article, the old article will not normally be
399 displayed in the Summary buffer. If this variable is non-nil, Gnus
400 will attempt to grab the headers to the old articles, and thereby
401 build complete threads. If it has the value `some', only enough
402 headers to connect otherwise loose threads will be displayed.
403 This variable can also be a number. In that case, no more than that
404 number of old headers will be fetched.
406 The server has to support NOV for any of this to work.")
409 ;(defvar gnus-visual t
410 ; "*If non-nil, will do various highlighting.
411 ;If nil, no mouse highlights (or any other highlights) will be
412 ;performed. This might speed up Gnus some when generating large group
413 ;and summary buffers.")
415 (defvar gnus-novice-user t
416 "*Non-nil means that you are a usenet novice.
417 If non-nil, verbose messages may be displayed and confirmations may be
420 (defvar gnus-expert-user nil
421 "*Non-nil means that you will never be asked for confirmation about anything.
422 And that means *anything*.")
424 (defvar gnus-verbose 7
425 "*Integer that says how verbose Gnus should be.
426 The higher the number, the more messages Gnus will flash to say what
427 it's doing. At zero, Gnus will be totally mute; at five, Gnus will
428 display most important messages; and at ten, Gnus will keep on
429 jabbering all the time.")
431 (defvar gnus-keep-same-level nil
432 "*Non-nil means that the next newsgroup after the current will be on the same level.
433 When you type, for instance, `n' after reading the last article in the
434 current newsgroup, you will go to the next newsgroup. If this variable
435 is nil, the next newsgroup will be the next from the group
437 If this variable is non-nil, Gnus will either put you in the
438 next newsgroup with the same level, or, if no such newsgroup is
439 available, the next newsgroup with the lowest possible level higher
440 than the current level.
441 If this variable is `best', Gnus will make the next newsgroup the one
442 with the best level.")
444 (defvar gnus-summary-make-false-root 'adopt
445 "*nil means that Gnus won't gather loose threads.
446 If the root of a thread has expired or been read in a previous
447 session, the information necessary to build a complete thread has been
448 lost. Instead of having many small sub-threads from this original thread
449 scattered all over the summary buffer, Gnus can gather them.
451 If non-nil, Gnus will try to gather all loose sub-threads from an
452 original thread into one large thread.
454 If this variable is non-nil, it should be one of `none', `adopt',
457 If this variable is `none', Gnus will not make a false root, but just
458 present the sub-threads after another.
459 If this variable is `dummy', Gnus will create a dummy root that will
460 have all the sub-threads as children.
461 If this variable is `adopt', Gnus will make one of the \"children\"
462 the parent and mark all the step-children as such.
463 If this variable is `empty', the \"children\" are printed with empty
464 subject fields. (Or rather, they will be printed with a string
465 given by the `gnus-summary-same-subject' variable.)")
467 (defvar gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
468 "*A regexp to match subjects to be excluded from loose thread gathering.
469 As loose thread gathering is done on subjects only, that means that
470 there can be many false gatherings performed. By rooting out certain
471 common subjects, gathering might become saner.")
473 (defvar gnus-summary-gather-subject-limit nil
474 "*Maximum length of subject comparisons when gathering loose threads.
475 Use nil to compare full subjects. Setting this variable to a low
476 number will help gather threads that have been corrupted by
477 newsreaders chopping off subject lines, but it might also mean that
478 unrelated articles that have subject that happen to begin with the
479 same few characters will be incorrectly gathered.
481 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
482 comparing subjects.")
484 (defvar gnus-simplify-ignored-prefixes nil
485 "*Regexp, matches for which are removed from subject lines when simplifying.")
487 (defvar gnus-build-sparse-threads nil
488 "*If non-nil, fill in the gaps in threads.
489 If `some', only fill in the gaps that are needed to tie loose threads
490 together. If `more', fill in all leaf nodes that Gnus can find. If
491 non-nil and non-`some', fill in all gaps that Gnus manages to guess.")
493 (defvar gnus-summary-thread-gathering-function 'gnus-gather-threads-by-subject
494 "Function used for gathering loose threads.
495 There are two pre-defined functions: `gnus-gather-threads-by-subject',
496 which only takes Subjects into consideration; and
497 `gnus-gather-threads-by-references', which compared the References
498 headers of the articles to find matches.")
500 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
501 (defvar gnus-summary-same-subject ""
502 "*String indicating that the current article has the same subject as the previous.
503 This variable will only be used if the value of
504 `gnus-summary-make-false-root' is `empty'.")
506 (defvar gnus-summary-goto-unread t
507 "*If non-nil, marking commands will go to the next unread article.
508 If `never', \\<gnus-summary-mode-map>\\[gnus-summary-next-page] will go to the next article,
509 whether it is read or not.")
511 (defvar gnus-group-goto-unread t
512 "*If non-nil, movement commands will go to the next unread and subscribed group.")
514 (defvar gnus-goto-next-group-when-activating t
515 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group.")
517 (defvar gnus-check-new-newsgroups t
518 "*Non-nil means that Gnus will add new newsgroups at startup.
519 If this variable is `ask-server', Gnus will ask the server for new
520 groups since the last time it checked. This means that the killed list
521 is no longer necessary, so you could set `gnus-save-killed-list' to
524 A variant is to have this variable be a list of select methods. Gnus
525 will then use the `ask-server' method on all these select methods to
526 query for new groups from all those servers.
529 (setq gnus-check-new-newsgroups
530 '((nntp \"some.server\") (nntp \"other.server\")))
532 If this variable is nil, then you have to tell Gnus explicitly to
533 check for new newsgroups with \\<gnus-group-mode-map>\\[gnus-find-new-newsgroups].")
535 (defvar gnus-check-bogus-newsgroups nil
536 "*Non-nil means that Gnus will check and remove bogus newsgroup at startup.
537 If this variable is nil, then you have to tell Gnus explicitly to
538 check for bogus newsgroups with \\<gnus-group-mode-map>\\[gnus-group-check-bogus-groups].")
540 (defvar gnus-read-active-file t
541 "*Non-nil means that Gnus will read the entire active file at startup.
542 If this variable is nil, Gnus will only know about the groups in your
545 If this variable is `some', Gnus will try to only read the relevant
546 parts of the active file from the server. Not all servers support
547 this, and it might be quite slow with other servers, but this should
548 generally be faster than both the t and nil value.
550 If you set this variable to nil or `some', you probably still want to
551 be told about new newsgroups that arrive. To do that, set
552 `gnus-check-new-newsgroups' to `ask-server'. This may not work
553 properly with all servers.")
555 (defvar gnus-level-subscribed 5
556 "*Groups with levels less than or equal to this variable are subscribed.")
558 (defvar gnus-level-unsubscribed 7
559 "*Groups with levels less than or equal to this variable are unsubscribed.
560 Groups with levels less than `gnus-level-subscribed', which should be
561 less than this variable, are subscribed.")
563 (defvar gnus-level-zombie 8
564 "*Groups with this level are zombie groups.")
566 (defvar gnus-level-killed 9
567 "*Groups with this level are killed.")
569 (defvar gnus-level-default-subscribed 3
570 "*New subscribed groups will be subscribed at this level.")
572 (defvar gnus-level-default-unsubscribed 6
573 "*New unsubscribed groups will be unsubscribed at this level.")
575 (defvar gnus-activate-level (1+ gnus-level-subscribed)
576 "*Groups higher than this level won't be activated on startup.
577 Setting this variable to something log might save lots of time when
578 you have many groups that you aren't interested in.")
580 (defvar gnus-activate-foreign-newsgroups 4
581 "*If nil, Gnus will not check foreign newsgroups at startup.
582 If it is non-nil, it should be a number between one and nine. Foreign
583 newsgroups that have a level lower or equal to this number will be
584 activated on startup. For instance, if you want to active all
585 subscribed newsgroups, but not the rest, you'd set this variable to
586 `gnus-level-subscribed'.
588 If you subscribe to lots of newsgroups from different servers, startup
589 might take a while. By setting this variable to nil, you'll save time,
590 but you won't be told how many unread articles there are in the
593 (defvar gnus-save-newsrc-file t
594 "*Non-nil means that Gnus will save the `.newsrc' file.
595 Gnus always saves its own startup file, which is called
596 \".newsrc.eld\". The file called \".newsrc\" is in a format that can
597 be readily understood by other newsreaders. If you don't plan on
598 using other newsreaders, set this variable to nil to save some time on
601 (defvar gnus-save-killed-list t
602 "*If non-nil, save the list of killed groups to the startup file.
603 If you set this variable to nil, you'll save both time (when starting
604 and quitting) and space (both memory and disk), but it will also mean
605 that Gnus has no record of which groups are new and which are old, so
606 the automatic new newsgroups subscription methods become meaningless.
608 You should always set `gnus-check-new-newsgroups' to `ask-server' or
609 nil if you set this variable to nil.")
611 (defvar gnus-interactive-catchup t
612 "*If non-nil, require your confirmation when catching up a group.")
614 (defvar gnus-interactive-exit t
615 "*If non-nil, require your confirmation when exiting Gnus.")
617 (defvar gnus-kill-killed t
618 "*If non-nil, Gnus will apply kill files to already killed articles.
619 If it is nil, Gnus will never apply kill files to articles that have
620 already been through the scoring process, which might very well save lots
623 (defvar gnus-extract-address-components 'gnus-extract-address-components
624 "*Function for extracting address components from a From header.
625 Two pre-defined function exist: `gnus-extract-address-components',
626 which is the default, quite fast, and too simplistic solution, and
627 `mail-extract-address-components', which works much better, but is
630 (defvar gnus-summary-default-score 0
631 "*Default article score level.
632 If this variable is nil, scoring will be disabled.")
634 (defvar gnus-summary-zcore-fuzz 0
635 "*Fuzziness factor for the zcore in the summary buffer.
636 Articles with scores closer than this to `gnus-summary-default-score'
637 will not be marked.")
639 (defvar gnus-simplify-subject-fuzzy-regexp nil
640 "*Strings to be removed when doing fuzzy matches.
641 This can either be a regular expression or list of regular expressions
642 that will be removed from subject strings if fuzzy subject
643 simplification is selected.")
645 (defvar gnus-permanently-visible-groups nil
646 "*Regexp to match groups that should always be listed in the group buffer.
647 This means that they will still be listed when there are no unread
648 articles in the groups.")
650 (defvar gnus-list-groups-with-ticked-articles t
651 "*If non-nil, list groups that have only ticked articles.
652 If nil, only list groups that have unread articles.")
654 (defvar gnus-group-default-list-level gnus-level-subscribed
655 "*Default listing level.
656 Ignored if `gnus-group-use-permanent-levels' is non-nil.")
658 (defvar gnus-group-use-permanent-levels nil
659 "*If non-nil, once you set a level, Gnus will use this level.")
661 (defvar gnus-group-list-inactive-groups t
662 "*If non-nil, inactive groups will be listed.")
664 (defvar gnus-show-mime nil
665 "*If non-nil, do mime processing of articles.
666 The articles will simply be fed to the function given by
667 `gnus-show-mime-method'.")
669 (defvar gnus-strict-mime t
670 "*If nil, MIME-decode even if there is no Mime-Version header in the article.")
672 (defvar gnus-show-mime-method 'metamail-buffer
673 "*Function to process a MIME message.
674 The function is called from the article buffer.")
676 (defvar gnus-decode-encoded-word-method (lambda ())
677 "*Function to decode a MIME encoded-words.
678 The function is called from the article buffer.")
680 (defvar gnus-show-threads t
681 "*If non-nil, display threads in summary mode.")
683 (defvar gnus-thread-hide-subtree nil
684 "*If non-nil, hide all threads initially.
685 If threads are hidden, you have to run the command
686 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
687 to expose hidden threads.")
689 (defvar gnus-thread-hide-killed t
690 "*If non-nil, hide killed threads automatically.")
692 (defvar gnus-thread-ignore-subject nil
693 "*If non-nil, ignore subjects and do all threading based on the Reference header.
694 If nil, which is the default, articles that have different subjects
695 from their parents will start separate threads.")
697 (defvar gnus-thread-operation-ignore-subject t
698 "*If non-nil, subjects will be ignored when doing thread commands.
699 This affects commands like `gnus-summary-kill-thread' and
700 `gnus-summary-lower-thread'.
702 If this variable is nil, articles in the same thread with different
703 subjects will not be included in the operation in question. If this
704 variable is `fuzzy', only articles that have subjects that are fuzzily
705 equal will be included.")
707 (defvar gnus-thread-indent-level 4
708 "*Number that says how much each sub-thread should be indented.")
710 (defvar gnus-ignored-newsgroups
711 (purecopy (mapconcat 'identity
712 '("^to\\." ; not "real" groups
713 "^[0-9. \t]+ " ; all digits in name
714 "[][\"#'()]" ; bogus characters
717 "*A regexp to match uninteresting newsgroups in the active file.
718 Any lines in the active file matching this regular expression are
719 removed from the newsgroup list before anything else is done to it,
720 thus making them effectively non-existent.")
722 (defvar gnus-ignored-headers
723 "^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:"
724 "*All headers that match this regexp will be hidden.
725 This variable can also be a list of regexps of headers to be ignored.
726 If `gnus-visible-headers' is non-nil, this variable will be ignored.")
728 (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-"
729 "*All headers that do not match this regexp will be hidden.
730 This variable can also be a list of regexp of headers to remain visible.
731 If this variable is non-nil, `gnus-ignored-headers' will be ignored.")
733 (defvar gnus-sorted-header-list
734 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^To:"
735 "^Cc:" "^Date:" "^Organization:")
736 "*This variable is a list of regular expressions.
737 If it is non-nil, headers that match the regular expressions will
738 be placed first in the article buffer in the sequence specified by
741 (defvar gnus-boring-article-headers
742 '(empty followup-to reply-to)
743 "*Headers that are only to be displayed if they have interesting data.
744 Possible values in this list are `empty', `newsgroups', `followup-to',
745 `reply-to', and `date'.")
747 (defvar gnus-show-all-headers nil
748 "*If non-nil, don't hide any headers.")
750 (defvar gnus-save-all-headers t
751 "*If non-nil, don't remove any headers before saving.")
753 (defvar gnus-saved-headers gnus-visible-headers
754 "*Headers to keep if `gnus-save-all-headers' is nil.
755 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
756 If that variable is nil, however, all headers that match this regexp
757 will be kept while the rest will be deleted before saving.")
759 (defvar gnus-inhibit-startup-message nil
760 "*If non-nil, the startup message will not be displayed.")
762 (defvar gnus-signature-separator "^-- *$"
763 "Regexp matching signature separator.")
765 (defvar gnus-signature-limit nil
766 "Provide a limit to what is considered a signature.
767 If it is a number, no signature may not be longer (in characters) than
768 that number. If it is a function, the function will be called without
769 any parameters, and if it returns nil, there is no signature in the
770 buffer. If it is a string, it will be used as a regexp. If it
771 matches, the text in question is not a signature.")
773 (defvar gnus-auto-extend-newsgroup t
774 "*If non-nil, extend newsgroup forward and backward when requested.")
776 (defvar gnus-auto-select-first t
777 "*If nil, don't select the first unread article when entering a group.
778 If this variable is `best', select the highest-scored unread article
779 in the group. If neither nil nor `best', select the first unread
782 If you want to prevent automatic selection of the first unread article
783 in some newsgroups, set the variable to nil in
784 `gnus-select-group-hook'.")
786 (defvar gnus-auto-select-next t
787 "*If non-nil, offer to go to the next group from the end of the previous.
788 If the value is t and the next newsgroup is empty, Gnus will exit
789 summary mode and go back to group mode. If the value is neither nil
790 nor t, Gnus will select the following unread newsgroup. In
791 particular, if the value is the symbol `quietly', the next unread
792 newsgroup will be selected without any confirmation, and if it is
793 `almost-quietly', the next group will be selected without any
794 confirmation if you are located on the last article in the group.
795 Finally, if this variable is `slightly-quietly', the `Z n' command
796 will go to the next group without confirmation.")
798 (defvar gnus-auto-select-same nil
799 "*If non-nil, select the next article with the same subject.")
801 (defvar gnus-summary-check-current nil
802 "*If non-nil, consider the current article when moving.
803 The \"unread\" movement commands will stay on the same line if the
804 current article is unread.")
806 (defvar gnus-auto-center-summary t
807 "*If non-nil, always center the current summary buffer.
808 In particular, if `vertical' do only vertical recentering. If non-nil
809 and non-`vertical', do both horizontal and vertical recentering.")
811 (defvar gnus-break-pages t
812 "*If non-nil, do page breaking on articles.
813 The page delimiter is specified by the `gnus-page-delimiter'
816 (defvar gnus-page-delimiter "^\^L"
817 "*Regexp describing what to use as article page delimiters.
818 The default value is \"^\^L\", which is a form linefeed at the
819 beginning of a line.")
821 (defvar gnus-use-full-window t
822 "*If non-nil, use the entire Emacs screen.")
824 (defvar gnus-window-configuration nil
825 "Obsolete variable. See `gnus-buffer-configuration'.")
827 (defvar gnus-window-min-width 2
828 "*Minimum width of Gnus buffers.")
830 (defvar gnus-window-min-height 1
831 "*Minimum height of Gnus buffers.")
833 (defvar gnus-buffer-configuration
837 (if gnus-carpal '(group-carpal 4))))
841 (if gnus-carpal '(summary-carpal 4))))
848 (if gnus-carpal '(summary-carpal 4))
850 (vertical ((height . 5) (width . 15)
852 (left . -1) (top . 1))
862 (if gnus-carpal '(summary-carpal 4))
863 (if gnus-use-trees '(tree 0.25))
868 (if gnus-carpal '(server-carpal 2))))
872 (if gnus-carpal '(browse-carpal 2))))
875 (message 1.0 point)))
878 (article 1.0 point)))
889 (edit-group 1.0 point)))
893 (edit-server 1.0 point)))
897 (edit-score 1.0 point)))
904 (message 1.0 point)))
907 (message 1.0 point)))
910 (message 1.0 point)))
914 (message 1.0 point)))
921 (if gnus-carpal '(summary-carpal 4))
922 ("*Shell Command Output*" 1.0)))
925 ("*Gnus Help Bug*" 0.5)
926 ("*Gnus Bug*" 1.0 point)))
930 (message 1.0 point))))
931 "Window configuration for all possible Gnus buffers.
932 This variable is a list of lists. Each of these lists has a NAME and
933 a RULE. The NAMEs are commonsense names like `group', which names a
934 rule used when displaying the group buffer; `summary', which names a
935 rule for what happens when you enter a group and do not display an
936 article buffer; and so on. See the value of this variable for a
937 complete list of NAMEs.
939 Each RULE is a list of vectors. The first element in this vector is
940 the name of the buffer to be displayed; the second element is the
941 percentage of the screen this buffer is to occupy (a number in the
942 0.0-0.99 range); the optional third element is `point', which should
943 be present to denote which buffer point is to go to after making this
944 buffer configuration.")
946 (defvar gnus-window-to-buffer
947 '((group . gnus-group-buffer)
948 (summary . gnus-summary-buffer)
949 (article . gnus-article-buffer)
950 (server . gnus-server-buffer)
951 (browse . "*Gnus Browse Server*")
952 (edit-group . gnus-group-edit-buffer)
953 (edit-server . gnus-server-edit-buffer)
954 (group-carpal . gnus-carpal-group-buffer)
955 (summary-carpal . gnus-carpal-summary-buffer)
956 (server-carpal . gnus-carpal-server-buffer)
957 (browse-carpal . gnus-carpal-browse-buffer)
958 (edit-score . gnus-score-edit-buffer)
959 (message . gnus-message-buffer)
960 (mail . gnus-message-buffer)
961 (post-news . gnus-message-buffer)
962 (faq . gnus-faq-buffer)
963 (picons . "*Picons*")
964 (tree . gnus-tree-buffer)
965 (info . gnus-info-buffer)
966 (article-copy . gnus-article-copy)
967 (draft . gnus-draft-buffer))
968 "Mapping from short symbols to buffer names or buffer variables.")
970 (defvar gnus-carpal nil
971 "*If non-nil, display clickable icons.")
973 (defvar gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies
974 "*Function called with a group name when new group is detected.
975 A few pre-made functions are supplied: `gnus-subscribe-randomly'
976 inserts new groups at the beginning of the list of groups;
977 `gnus-subscribe-alphabetically' inserts new groups in strict
978 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
979 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
980 for your decision; `gnus-subscribe-killed' kills all new groups;
981 `gnus-subscribe-zombies' will make all new groups into zombies.")
983 ;; Suggested by a bug report by Hallvard B Furuseth.
984 ;; <h.b.furuseth@usit.uio.no>.
985 (defvar gnus-subscribe-options-newsgroup-method
986 (function gnus-subscribe-alphabetically)
987 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines.
988 If, for instance, you want to subscribe to all newsgroups in the
989 \"no\" and \"alt\" hierarchies, you'd put the following in your
992 options -n no.all alt.all
994 Gnus will the subscribe all new newsgroups in these hierarchies with
995 the subscription method in this variable.")
997 (defvar gnus-subscribe-hierarchical-interactive nil
998 "*If non-nil, Gnus will offer to subscribe hierarchically.
999 When a new hierarchy appears, Gnus will ask the user:
1001 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
1003 If the user pressed `d', Gnus will descend the hierarchy, `y' will
1004 subscribe to all newsgroups in the hierarchy and `s' will skip this
1005 hierarchy in its entirety.")
1007 (defvar gnus-group-sort-function 'gnus-group-sort-by-alphabet
1008 "*Function used for sorting the group buffer.
1009 This function will be called with group info entries as the arguments
1010 for the groups to be sorted. Pre-made functions include
1011 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-unread',
1012 `gnus-group-sort-by-level', `gnus-group-sort-by-score', and
1013 `gnus-group-sort-by-rank'.
1015 This variable can also be a list of sorting functions. In that case,
1016 the most significant sort function should be the last function in the
1019 ;; Mark variables suggested by Thomas Michanek
1020 ;; <Thomas.Michanek@telelogic.se>.
1021 (defvar gnus-unread-mark ?
1022 "*Mark used for unread articles.")
1023 (defvar gnus-ticked-mark ?!
1024 "*Mark used for ticked articles.")
1025 (defvar gnus-dormant-mark ??
1026 "*Mark used for dormant articles.")
1027 (defvar gnus-del-mark ?r
1028 "*Mark used for del'd articles.")
1029 (defvar gnus-read-mark ?R
1030 "*Mark used for read articles.")
1031 (defvar gnus-expirable-mark ?E
1032 "*Mark used for expirable articles.")
1033 (defvar gnus-killed-mark ?K
1034 "*Mark used for killed articles.")
1035 (defvar gnus-souped-mark ?F
1036 "*Mark used for killed articles.")
1037 (defvar gnus-kill-file-mark ?X
1038 "*Mark used for articles killed by kill files.")
1039 (defvar gnus-low-score-mark ?Y
1040 "*Mark used for articles with a low score.")
1041 (defvar gnus-catchup-mark ?C
1042 "*Mark used for articles that are caught up.")
1043 (defvar gnus-replied-mark ?A
1044 "*Mark used for articles that have been replied to.")
1045 (defvar gnus-cached-mark ?*
1046 "*Mark used for articles that are in the cache.")
1047 (defvar gnus-saved-mark ?S
1048 "*Mark used for articles that have been saved to.")
1049 (defvar gnus-process-mark ?#
1051 (defvar gnus-ancient-mark ?O
1052 "*Mark used for ancient articles.")
1053 (defvar gnus-sparse-mark ?Q
1054 "*Mark used for sparsely reffed articles.")
1055 (defvar gnus-canceled-mark ?G
1056 "*Mark used for canceled articles.")
1057 (defvar gnus-score-over-mark ?+
1058 "*Score mark used for articles with high scores.")
1059 (defvar gnus-score-below-mark ?-
1060 "*Score mark used for articles with low scores.")
1061 (defvar gnus-empty-thread-mark ?
1062 "*There is no thread under the article.")
1063 (defvar gnus-not-empty-thread-mark ?=
1064 "*There is a thread under the article.")
1066 (defvar gnus-view-pseudo-asynchronously nil
1067 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
1069 (defvar gnus-view-pseudos nil
1070 "*If `automatic', pseudo-articles will be viewed automatically.
1071 If `not-confirm', pseudos will be viewed automatically, and the user
1072 will not be asked to confirm the command.")
1074 (defvar gnus-view-pseudos-separately t
1075 "*If non-nil, one pseudo-article will be created for each file to be viewed.
1076 If nil, all files that use the same viewing command will be given as a
1077 list of parameters to that command.")
1079 (defvar gnus-insert-pseudo-articles t
1080 "*If non-nil, insert pseudo-articles when decoding articles.")
1082 (defvar gnus-group-line-format "%M%S%p%P%5y: %(%g%)%l\n"
1083 "*Format of group lines.
1084 It works along the same lines as a normal formatting string,
1085 with some simple extensions.
1087 %M Only marked articles (character, \"*\" or \" \")
1088 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
1089 %L Level of subscribedness (integer)
1090 %N Number of unread articles (integer)
1091 %I Number of dormant articles (integer)
1092 %i Number of ticked and dormant (integer)
1093 %T Number of ticked articles (integer)
1094 %R Number of read articles (integer)
1095 %t Total number of articles (integer)
1096 %y Number of unread, unticked articles (integer)
1097 %G Group name (string)
1098 %g Qualified group name (string)
1099 %D Group description (string)
1100 %s Select method (string)
1101 %o Moderated group (char, \"m\")
1102 %p Process mark (char)
1103 %O Moderated group (string, \"(m)\" or \"\")
1104 %P Topic indentation (string)
1105 %l Whether there are GroupLens predictions for this group (string)
1106 %n Select from where (string)
1107 %z A string that look like `<%s:%n>' if a foreign select method is used
1108 %u User defined specifier. The next character in the format string should
1109 be a letter. Gnus will call the function gnus-user-format-function-X,
1110 where X is the letter following %u. The function will be passed the
1111 current header as argument. The function should return a string, which
1112 will be inserted into the buffer just like information from any other
1115 Text between %( and %) will be highlighted with `gnus-mouse-face' when
1116 the mouse point move inside the area. There can only be one such area.
1118 Note that this format specification is not always respected. For
1119 reasons of efficiency, when listing killed groups, this specification
1120 is ignored altogether. If the spec is changed considerably, your
1121 output may end up looking strange when listing both alive and killed
1124 If you use %o or %O, reading the active file will be slower and quite
1125 a bit of extra memory will be used. %D will also worsen performance.
1126 Also note that if you change the format specification to include any
1127 of these specs, you must probably re-start Gnus to see them go into
1130 (defvar gnus-summary-line-format "%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n"
1131 "*The format specification of the lines in the summary buffer.
1133 It works along the same lines as a normal formatting string,
1134 with some simple extensions.
1136 %N Article number, left padded with spaces (string)
1138 %s Subject if it is at the root of a thread, and \"\" otherwise (string)
1139 %n Name of the poster (string)
1140 %a Extracted name of the poster (string)
1141 %A Extracted address of the poster (string)
1142 %F Contents of the From: header (string)
1143 %x Contents of the Xref: header (string)
1144 %D Date of the article (string)
1145 %d Date of the article (string) in DD-MMM format
1146 %M Message-id of the article (string)
1147 %r References of the article (string)
1148 %c Number of characters in the article (integer)
1149 %L Number of lines in the article (integer)
1150 %I Indentation based on thread level (a string of spaces)
1151 %T A string with two possible values: 80 spaces if the article
1152 is on thread level two or larger and 0 spaces on level one
1153 %R \"A\" if this article has been replied to, \" \" otherwise (character)
1154 %U Status of this article (character, \"R\", \"K\", \"-\" or \" \")
1155 %[ Opening bracket (character, \"[\" or \"<\")
1156 %] Closing bracket (character, \"]\" or \">\")
1157 %> Spaces of length thread-level (string)
1158 %< Spaces of length (- 20 thread-level) (string)
1159 %i Article score (number)
1160 %z Article zcore (character)
1161 %t Number of articles under the current thread (number).
1162 %e Whether the thread is empty or not (character).
1163 %l GroupLens score (string).
1164 %u User defined specifier. The next character in the format string should
1165 be a letter. Gnus will call the function gnus-user-format-function-X,
1166 where X is the letter following %u. The function will be passed the
1167 current header as argument. The function should return a string, which
1168 will be inserted into the summary just like information from any other
1171 Text between %( and %) will be highlighted with `gnus-mouse-face'
1172 when the mouse point is placed inside the area. There can only be one
1175 The %U (status), %R (replied) and %z (zcore) specs have to be handled
1176 with care. For reasons of efficiency, Gnus will compute what column
1177 these characters will end up in, and \"hard-code\" that. This means that
1178 it is illegal to have these specs after a variable-length spec. Well,
1179 you might not be arrested, but your summary buffer will look strange,
1180 which is bad enough.
1182 The smart choice is to have these specs as for to the left as
1185 This restriction may disappear in later versions of Gnus.")
1187 (defvar gnus-summary-dummy-line-format
1189 "*The format specification for the dummy roots in the summary buffer.
1190 It works along the same lines as a normal formatting string,
1191 with some simple extensions.
1195 (defvar gnus-summary-mode-line-format "Gnus: %%b [%A] %Z"
1196 "*The format specification for the summary mode line.
1197 It works along the same lines as a normal formatting string,
1198 with some simple extensions:
1201 %p Unprefixed group name
1202 %A Current article number
1204 %U Number of unread articles in the group
1205 %e Number of unselected articles in the group
1206 %Z A string with unread/unselected article counts
1207 %g Shortish group name
1208 %S Subject of the current article
1209 %u User-defined spec
1210 %s Current score file name
1211 %d Number of dormant articles
1212 %r Number of articles that have been marked as read in this session
1213 %E Number of articles expunged by the score files")
1215 (defvar gnus-article-mode-line-format "Gnus: %%b %S"
1216 "*The format specification for the article mode line.
1217 See `gnus-summary-mode-line-format' for a closer description.")
1219 (defvar gnus-group-mode-line-format "Gnus: %%b {%M%:%S}"
1220 "*The format specification for the group mode line.
1221 It works along the same lines as a normal formatting string,
1222 with some simple extensions:
1224 %S The native news server.
1225 %M The native select method.
1226 %: \":\" if %S isn't \"\".")
1228 (defvar gnus-valid-select-methods
1229 '(("nntp" post address prompt-address)
1230 ("nnspool" post address)
1231 ("nnvirtual" post-mail virtual prompt-address)
1232 ("nnmbox" mail respool address)
1233 ("nnml" mail respool address)
1234 ("nnmh" mail respool address)
1235 ("nndir" post-mail prompt-address address)
1236 ("nneething" none address prompt-address)
1237 ("nndoc" none address prompt-address)
1238 ("nnbabyl" mail address respool)
1239 ("nnkiboze" post address virtual)
1240 ("nnsoup" post-mail address)
1241 ("nndraft" post-mail)
1242 ("nnfolder" mail respool address))
1243 "An alist of valid select methods.
1244 The first element of each list lists should be a string with the name
1245 of the select method. The other elements may be be the category of
1246 this method (ie. `post', `mail', `none' or whatever) or other
1247 properties that this method has (like being respoolable).
1248 If you implement a new select method, all you should have to change is
1249 this variable. I think.")
1251 (defvar gnus-updated-mode-lines '(group article summary tree)
1252 "*List of buffers that should update their mode lines.
1253 The list may contain the symbols `group', `article' and `summary'. If
1254 the corresponding symbol is present, Gnus will keep that mode line
1255 updated with information that may be pertinent.
1256 If this variable is nil, screen refresh may be quicker.")
1258 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>.
1259 (defvar gnus-mode-non-string-length nil
1260 "*Max length of mode-line non-string contents.
1261 If this is nil, Gnus will take space as is needed, leaving the rest
1262 of the modeline intact.")
1265 ;(defvar gnus-mouse-face 'highlight
1266 ; "*Face used for mouse highlighting in Gnus.
1267 ;No mouse highlights will be done if `gnus-visual' is nil.")
1269 (defvar gnus-summary-mark-below 0
1270 "*Mark all articles with a score below this variable as read.
1271 This variable is local to each summary buffer and usually set by the
1274 (defvar gnus-article-sort-functions '(gnus-article-sort-by-number)
1275 "*List of functions used for sorting articles in the summary buffer.
1276 This variable is only used when not using a threaded display.")
1278 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number)
1279 "*List of functions used for sorting threads in the summary buffer.
1280 By default, threads are sorted by article number.
1282 Each function takes two threads and return non-nil if the first thread
1283 should be sorted before the other. If you use more than one function,
1284 the primary sort function should be the last. You should probably
1285 always include `gnus-thread-sort-by-number' in the list of sorting
1286 functions -- preferably first.
1288 Ready-mady functions include `gnus-thread-sort-by-number',
1289 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
1290 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
1291 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').")
1293 (defvar gnus-thread-score-function '+
1294 "*Function used for calculating the total score of a thread.
1296 The function is called with the scores of the article and each
1297 subthread and should then return the score of the thread.
1299 Some functions you can use are `+', `max', or `min'.")
1301 (defvar gnus-summary-expunge-below nil
1302 "All articles that have a score less than this variable will be expunged.")
1304 (defvar gnus-thread-expunge-below nil
1305 "All threads that have a total score less than this variable will be expunged.
1306 See `gnus-thread-score-function' for en explanation of what a
1307 \"thread score\" is.")
1309 (defvar gnus-auto-subscribed-groups
1310 "^nnml\\|^nnfolder\\|^nnmbox\\|^nnmh\\|^nnbabyl"
1311 "*All new groups that match this regexp will be subscribed automatically.
1312 Note that this variable only deals with new groups. It has no effect
1313 whatsoever on old groups.")
1315 (defvar gnus-options-subscribe nil
1316 "*All new groups matching this regexp will be subscribed unconditionally.
1317 Note that this variable deals only with new newsgroups. This variable
1318 does not affect old newsgroups.")
1320 (defvar gnus-options-not-subscribe nil
1321 "*All new groups matching this regexp will be ignored.
1322 Note that this variable deals only with new newsgroups. This variable
1323 does not affect old (already subscribed) newsgroups.")
1325 (defvar gnus-auto-expirable-newsgroups nil
1326 "*Groups in which to automatically mark read articles as expirable.
1327 If non-nil, this should be a regexp that should match all groups in
1328 which to perform auto-expiry. This only makes sense for mail groups.")
1330 (defvar gnus-total-expirable-newsgroups nil
1331 "*Groups in which to perform expiry of all read articles.
1332 Use with extreme caution. All groups that match this regexp will be
1333 expiring - which means that all read articles will be deleted after
1334 (say) one week. (This only goes for mail groups and the like, of
1337 (defvar gnus-group-uncollapsed-levels 1
1338 "Number of group name elements to leave alone when making a short group name.")
1340 (defvar gnus-hidden-properties '(invisible t intangible t)
1341 "Property list to use for hiding text.")
1343 (defvar gnus-modtime-botch nil
1344 "*Non-nil means .newsrc should be deleted prior to save.
1345 Its use is due to the bogus appearance that .newsrc was modified on
1350 (defvar gnus-group-mode-hook nil
1351 "*A hook for Gnus group mode.")
1353 (defvar gnus-summary-mode-hook nil
1354 "*A hook for Gnus summary mode.
1355 This hook is run before any variables are set in the summary buffer.")
1357 (defvar gnus-article-mode-hook nil
1358 "*A hook for Gnus article mode.")
1360 (defvar gnus-summary-prepare-exit-hook nil
1361 "*A hook called when preparing to exit from the summary buffer.
1362 It calls `gnus-summary-expire-articles' by default.")
1363 (add-hook 'gnus-summary-prepare-exit-hook 'gnus-summary-expire-articles)
1365 (defvar gnus-summary-exit-hook nil
1366 "*A hook called on exit from the summary buffer.")
1368 (defvar gnus-group-catchup-group-hook nil
1369 "*A hook run when catching up a group from the group buffer.")
1371 (defvar gnus-group-update-group-hook nil
1372 "*A hook called when updating group lines.")
1374 (defvar gnus-open-server-hook nil
1375 "*A hook called just before opening connection to the news server.")
1377 (defvar gnus-load-hook nil
1378 "*A hook run while Gnus is loaded.")
1380 (defvar gnus-startup-hook nil
1381 "*A hook called at startup.
1382 This hook is called after Gnus is connected to the NNTP server.")
1384 (defvar gnus-get-new-news-hook nil
1385 "*A hook run just before Gnus checks for new news.")
1387 (defvar gnus-after-getting-new-news-hook nil
1388 "*A hook run after Gnus checks for new news.")
1390 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat
1391 "*A function that is called to generate the group buffer.
1392 The function is called with three arguments: The first is a number;
1393 all group with a level less or equal to that number should be listed,
1394 if the second is non-nil, empty groups should also be displayed. If
1395 the third is non-nil, it is a number. No groups with a level lower
1396 than this number should be displayed.
1398 The only current function implemented is `gnus-group-prepare-flat'.")
1400 (defvar gnus-group-prepare-hook nil
1401 "*A hook called after the group buffer has been generated.
1402 If you want to modify the group buffer, you can use this hook.")
1404 (defvar gnus-summary-prepare-hook nil
1405 "*A hook called after the summary buffer has been generated.
1406 If you want to modify the summary buffer, you can use this hook.")
1408 (defvar gnus-summary-generate-hook nil
1409 "*A hook run just before generating the summary buffer.
1410 This hook is commonly used to customize threading variables and the
1413 (defvar gnus-article-prepare-hook nil
1414 "*A hook called after an article has been prepared in the article buffer.
1415 If you want to run a special decoding program like nkf, use this hook.")
1417 ;(defvar gnus-article-display-hook nil
1418 ; "*A hook called after the article is displayed in the article buffer.
1419 ;The hook is designed to change the contents of the article
1420 ;buffer. Typical functions that this hook may contain are
1421 ;`gnus-article-hide-headers' (hide selected headers),
1422 ;`gnus-article-maybe-highlight' (perform fancy article highlighting),
1423 ;`gnus-article-hide-signature' (hide signature) and
1424 ;`gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).")
1425 ;(add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted)
1426 ;(add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike)
1427 ;(add-hook 'gnus-article-display-hook 'gnus-article-maybe-highlight)
1429 (defvar gnus-article-x-face-command
1430 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | xv -quit -"
1431 "String or function to be executed to display an X-Face header.
1432 If it is a string, the command will be executed in a sub-shell
1433 asynchronously. The compressed face will be piped to this command.")
1435 (defvar gnus-article-x-face-too-ugly nil
1436 "Regexp matching posters whose face shouldn't be shown automatically.")
1438 (defvar gnus-select-group-hook nil
1439 "*A hook called when a newsgroup is selected.
1441 If you'd like to simplify subjects like the
1442 `gnus-summary-next-same-subject' command does, you can use the
1445 (setq gnus-select-group-hook
1448 (mapcar (lambda (header)
1449 (mail-header-set-subject
1451 (gnus-simplify-subject
1452 (mail-header-subject header) 're-only)))
1453 gnus-newsgroup-headers))))")
1455 (defvar gnus-select-article-hook nil
1456 "*A hook called when an article is selected.")
1458 (defvar gnus-apply-kill-hook '(gnus-apply-kill-file)
1459 "*A hook called to apply kill files to a group.
1460 This hook is intended to apply a kill file to the selected newsgroup.
1461 The function `gnus-apply-kill-file' is called by default.
1463 Since a general kill file is too heavy to use only for a few
1464 newsgroups, I recommend you to use a lighter hook function. For
1465 example, if you'd like to apply a kill file to articles which contains
1466 a string `rmgroup' in subject in newsgroup `control', you can use the
1469 (setq gnus-apply-kill-hook
1472 (cond ((string-match \"control\" gnus-newsgroup-name)
1473 (gnus-kill \"Subject\" \"rmgroup\")
1474 (gnus-expunge \"X\"))))))")
1476 (defvar gnus-visual-mark-article-hook
1477 (list 'gnus-highlight-selected-summary)
1478 "*Hook run after selecting an article in the summary buffer.
1479 It is meant to be used for highlighting the article in some way. It
1480 is not run if `gnus-visual' is nil.")
1482 (defvar gnus-parse-headers-hook nil
1483 "*A hook called before parsing the headers.")
1484 (add-hook 'gnus-parse-headers-hook 'gnus-decode-rfc1522)
1486 (defvar gnus-exit-group-hook nil
1487 "*A hook called when exiting (not quitting) summary mode.")
1489 (defvar gnus-suspend-gnus-hook nil
1490 "*A hook called when suspending (not exiting) Gnus.")
1492 (defvar gnus-exit-gnus-hook nil
1493 "*A hook called when exiting Gnus.")
1495 (defvar gnus-after-exiting-gnus-hook nil
1496 "*A hook called after exiting Gnus.")
1498 (defvar gnus-save-newsrc-hook nil
1499 "*A hook called before saving any of the newsrc files.")
1501 (defvar gnus-save-quick-newsrc-hook nil
1502 "*A hook called just before saving the quick newsrc file.
1503 Can be used to turn version control on or off.")
1505 (defvar gnus-save-standard-newsrc-hook nil
1506 "*A hook called just before saving the standard newsrc file.
1507 Can be used to turn version control on or off.")
1509 (defvar gnus-summary-update-hook
1510 (list 'gnus-summary-highlight-line)
1511 "*A hook called when a summary line is changed.
1512 The hook will not be called if `gnus-visual' is nil.
1514 The default function `gnus-summary-highlight-line' will
1515 highlight the line according to the `gnus-summary-highlight'
1518 (defvar gnus-group-update-hook '(gnus-group-highlight-line)
1519 "*A hook called when a group line is changed.
1520 The hook will not be called if `gnus-visual' is nil.
1522 The default function `gnus-group-highlight-line' will
1523 highlight the line according to the `gnus-group-highlight'
1526 (defvar gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
1527 "*A hook called when an article is selected for the first time.
1528 The hook is intended to mark an article as read (or unread)
1529 automatically when it is selected.")
1531 (defvar gnus-group-change-level-function nil
1532 "Function run when a group level is changed.
1533 It is called with three parameters -- GROUP, LEVEL and OLDLEVEL.")
1535 ;; Remove any hilit infestation.
1536 (add-hook 'gnus-startup-hook
1538 (remove-hook 'gnus-summary-prepare-hook
1539 'hilit-rehighlight-buffer-quietly)
1540 (remove-hook 'gnus-summary-prepare-hook 'hilit-install-line-hooks)
1541 (setq gnus-mark-article-hook
1542 '(gnus-summary-mark-read-and-unread-as-read))
1543 (remove-hook 'gnus-article-prepare-hook
1544 'hilit-rehighlight-buffer-quietly)))
1547 ;; Internal variables
1549 (defvar gnus-tree-buffer "*Tree*"
1550 "Buffer where Gnus thread trees are displayed.")
1553 (defvar gnus-use-generic-from nil)
1555 (defvar gnus-thread-indent-array nil)
1556 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1558 (defvar gnus-newsrc-file-version nil)
1560 (defvar gnus-method-history nil)
1561 ;; Variable holding the user answers to all method prompts.
1563 (defvar gnus-group-history nil)
1564 ;; Variable holding the user answers to all group prompts.
1566 (defvar gnus-server-alist nil
1567 "List of available servers.")
1569 (defvar gnus-group-indentation-function nil)
1571 (defvar gnus-topic-indentation "") ;; Obsolete variable.
1573 (defvar gnus-goto-missing-group-function nil)
1575 (defvar gnus-override-subscribe-method nil)
1577 (defvar gnus-group-goto-next-group-function nil
1578 "Function to override finding the next group after listing groups.")
1580 (defconst gnus-article-mark-lists
1581 '((marked . tick) (replied . reply)
1582 (expirable . expire) (killed . killed)
1583 (bookmarks . bookmark) (dormant . dormant)
1584 (scored . score) (saved . save)
1588 ;; Avoid highlighting in kill files.
1589 (defvar gnus-summary-inhibit-highlight nil)
1590 (defvar gnus-newsgroup-selected-overlay nil)
1592 (defvar gnus-inhibit-hiding nil)
1593 (defvar gnus-group-indentation "")
1594 (defvar gnus-inhibit-limiting nil)
1595 (defvar gnus-created-frames nil)
1597 (defvar gnus-article-mode-map nil)
1598 (defvar gnus-dribble-buffer nil)
1599 (defvar gnus-headers-retrieved-by nil)
1600 (defvar gnus-article-reply nil)
1601 (defvar gnus-override-method nil)
1602 (defvar gnus-article-check-size nil)
1604 (defvar gnus-current-score-file nil)
1605 (defvar gnus-newsgroup-adaptive-score-file nil)
1606 (defvar gnus-scores-exclude-files nil)
1608 (defvar gnus-opened-servers nil)
1610 (defvar gnus-current-move-group nil)
1611 (defvar gnus-current-copy-group nil)
1612 (defvar gnus-current-crosspost-group nil)
1614 (defvar gnus-newsgroup-dependencies nil)
1615 (defvar gnus-newsgroup-async nil)
1616 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*")
1618 (defvar gnus-newsgroup-adaptive nil)
1620 (defvar gnus-summary-display-table nil)
1621 (defvar gnus-summary-display-article-function nil)
1623 (defvar gnus-summary-highlight-line-function nil
1624 "Function called after highlighting a summary line.")
1626 (defvar gnus-group-line-format-alist
1627 `((?M gnus-tmp-marked-mark ?c)
1628 (?S gnus-tmp-subscribed ?c)
1629 (?L gnus-tmp-level ?d)
1630 (?N (cond ((eq number t) "*" )
1634 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1635 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
1637 (?R gnus-tmp-number-of-read ?s)
1638 (?t gnus-tmp-number-total ?d)
1639 (?y gnus-tmp-number-of-unread ?s)
1640 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
1641 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
1642 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1643 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
1644 (?g gnus-tmp-group ?s)
1645 (?G gnus-tmp-qualified-group ?s)
1646 (?c (gnus-short-group-name gnus-tmp-group) ?s)
1647 (?D gnus-tmp-newsgroup-description ?s)
1648 (?o gnus-tmp-moderated ?c)
1649 (?O gnus-tmp-moderated-string ?s)
1650 (?p gnus-tmp-process-marked ?c)
1651 (?s gnus-tmp-news-server ?s)
1652 (?n gnus-tmp-news-method ?s)
1653 (?P gnus-group-indentation ?s)
1654 (?l gnus-tmp-grouplens ?s)
1655 (?z gnus-tmp-news-method-string ?s)
1656 (?u gnus-tmp-user-defined ?s)))
1658 (defvar gnus-summary-line-format-alist
1659 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1660 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1661 (?s gnus-tmp-subject-or-nil ?s)
1662 (?n gnus-tmp-name ?s)
1663 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1665 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1667 (?F gnus-tmp-from ?s)
1668 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1669 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1670 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1671 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1672 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1673 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1674 (?L gnus-tmp-lines ?d)
1675 (?I gnus-tmp-indentation ?s)
1676 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1677 (?R gnus-tmp-replied ?c)
1678 (?\[ gnus-tmp-opening-bracket ?c)
1679 (?\] gnus-tmp-closing-bracket ?c)
1680 (?\> (make-string gnus-tmp-level ? ) ?s)
1681 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1682 (?i gnus-tmp-score ?d)
1683 (?z gnus-tmp-score-char ?c)
1684 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1685 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1686 (?U gnus-tmp-unread ?c)
1687 (?t (gnus-summary-number-of-articles-in-thread
1688 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1690 (?e (gnus-summary-number-of-articles-in-thread
1691 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1693 (?u gnus-tmp-user-defined ?s))
1694 "An alist of format specifications that can appear in summary lines,
1695 and what variables they correspond with, along with the type of the
1696 variable (string, integer, character, etc).")
1698 (defvar gnus-summary-dummy-line-format-alist
1699 `((?S gnus-tmp-subject ?s)
1700 (?N gnus-tmp-number ?d)
1701 (?u gnus-tmp-user-defined ?s)))
1703 (defvar gnus-summary-mode-line-format-alist
1704 `((?G gnus-tmp-group-name ?s)
1705 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1706 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1707 (?A gnus-tmp-article-number ?d)
1708 (?Z gnus-tmp-unread-and-unselected ?s)
1709 (?V gnus-version ?s)
1710 (?U gnus-tmp-unread ?d)
1711 (?S gnus-tmp-subject ?s)
1712 (?e gnus-tmp-unselected ?d)
1713 (?u gnus-tmp-user-defined ?s)
1714 (?d (length gnus-newsgroup-dormant) ?d)
1715 (?t (length gnus-newsgroup-marked) ?d)
1716 (?r (length gnus-newsgroup-reads) ?d)
1717 (?E gnus-newsgroup-expunged-tally ?d)
1718 (?s (gnus-current-score-file-nondirectory) ?s)))
1720 (defvar gnus-article-mode-line-format-alist
1721 gnus-summary-mode-line-format-alist)
1723 (defvar gnus-group-mode-line-format-alist
1724 `((?S gnus-tmp-news-server ?s)
1725 (?M gnus-tmp-news-method ?s)
1726 (?u gnus-tmp-user-defined ?s)
1727 (?: gnus-tmp-colon ?s)))
1729 (defvar gnus-have-read-active-file nil)
1731 (defconst gnus-maintainer
1732 "gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls + Boys)"
1733 "The mail address of the Gnus maintainers.")
1735 (defconst gnus-version-number "5.2.13"
1736 "Version number for this version of Gnus.")
1738 (defconst gnus-version (format "Gnus v%s" gnus-version-number)
1739 "Version string for this version of Gnus.")
1741 (defvar gnus-info-nodes
1742 '((gnus-group-mode "(gnus)The Group Buffer")
1743 (gnus-summary-mode "(gnus)The Summary Buffer")
1744 (gnus-article-mode "(gnus)The Article Buffer"))
1745 "Alist of major modes and related Info nodes.")
1747 (defvar gnus-group-buffer "*Group*")
1748 (defvar gnus-summary-buffer "*Summary*")
1749 (defvar gnus-article-buffer "*Article*")
1750 (defvar gnus-server-buffer "*Server*")
1752 (defvar gnus-work-buffer " *gnus work*")
1754 (defvar gnus-original-article-buffer " *Original Article*")
1755 (defvar gnus-original-article nil)
1757 (defvar gnus-buffer-list nil
1758 "Gnus buffers that should be killed on exit.")
1760 (defvar gnus-slave nil
1761 "Whether this Gnus is a slave or not.")
1763 (defvar gnus-variable-list
1764 '(gnus-newsrc-options gnus-newsrc-options-n
1765 gnus-newsrc-last-checked-date
1766 gnus-newsrc-alist gnus-server-alist
1767 gnus-killed-list gnus-zombie-list
1768 gnus-topic-topology gnus-topic-alist
1770 "Gnus variables saved in the quick startup file.")
1772 (defvar gnus-newsrc-options nil
1773 "Options line in the .newsrc file.")
1775 (defvar gnus-newsrc-options-n nil
1776 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1778 (defvar gnus-newsrc-last-checked-date nil
1779 "Date Gnus last asked server for new newsgroups.")
1781 (defvar gnus-topic-topology nil
1782 "The complete topic hierarchy.")
1784 (defvar gnus-topic-alist nil
1785 "The complete topic-group alist.")
1787 (defvar gnus-newsrc-alist nil
1788 "Assoc list of read articles.
1789 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1791 (defvar gnus-newsrc-hashtb nil
1792 "Hashtable of gnus-newsrc-alist.")
1794 (defvar gnus-killed-list nil
1795 "List of killed newsgroups.")
1797 (defvar gnus-killed-hashtb nil
1798 "Hash table equivalent of gnus-killed-list.")
1800 (defvar gnus-zombie-list nil
1801 "List of almost dead newsgroups.")
1803 (defvar gnus-description-hashtb nil
1804 "Descriptions of newsgroups.")
1806 (defvar gnus-list-of-killed-groups nil
1807 "List of newsgroups that have recently been killed by the user.")
1809 (defvar gnus-active-hashtb nil
1810 "Hashtable of active articles.")
1812 (defvar gnus-moderated-list nil
1813 "List of moderated newsgroups.")
1815 (defvar gnus-group-marked nil)
1817 (defvar gnus-current-startup-file nil
1818 "Startup file for the current host.")
1820 (defvar gnus-last-search-regexp nil
1821 "Default regexp for article search command.")
1823 (defvar gnus-last-shell-command nil
1824 "Default shell command on article.")
1826 (defvar gnus-current-select-method nil
1827 "The current method for selecting a newsgroup.")
1829 (defvar gnus-group-list-mode nil)
1831 (defvar gnus-article-internal-prepare-hook nil)
1833 (defvar gnus-newsgroup-name nil)
1834 (defvar gnus-newsgroup-begin nil)
1835 (defvar gnus-newsgroup-end nil)
1836 (defvar gnus-newsgroup-last-rmail nil)
1837 (defvar gnus-newsgroup-last-mail nil)
1838 (defvar gnus-newsgroup-last-folder nil)
1839 (defvar gnus-newsgroup-last-file nil)
1840 (defvar gnus-newsgroup-auto-expire nil)
1841 (defvar gnus-newsgroup-active nil)
1843 (defvar gnus-newsgroup-data nil)
1844 (defvar gnus-newsgroup-data-reverse nil)
1845 (defvar gnus-newsgroup-limit nil)
1846 (defvar gnus-newsgroup-limits nil)
1848 (defvar gnus-newsgroup-unreads nil
1849 "List of unread articles in the current newsgroup.")
1851 (defvar gnus-newsgroup-unselected nil
1852 "List of unselected unread articles in the current newsgroup.")
1854 (defvar gnus-newsgroup-reads nil
1855 "Alist of read articles and article marks in the current newsgroup.")
1857 (defvar gnus-newsgroup-expunged-tally nil)
1859 (defvar gnus-newsgroup-marked nil
1860 "List of ticked articles in the current newsgroup (a subset of unread art).")
1862 (defvar gnus-newsgroup-killed nil
1863 "List of ranges of articles that have been through the scoring process.")
1865 (defvar gnus-newsgroup-cached nil
1866 "List of articles that come from the article cache.")
1868 (defvar gnus-newsgroup-saved nil
1869 "List of articles that have been saved.")
1871 (defvar gnus-newsgroup-kill-headers nil)
1873 (defvar gnus-newsgroup-replied nil
1874 "List of articles that have been replied to in the current newsgroup.")
1876 (defvar gnus-newsgroup-expirable nil
1877 "List of articles in the current newsgroup that can be expired.")
1879 (defvar gnus-newsgroup-processable nil
1880 "List of articles in the current newsgroup that can be processed.")
1882 (defvar gnus-newsgroup-bookmarks nil
1883 "List of articles in the current newsgroup that have bookmarks.")
1885 (defvar gnus-newsgroup-dormant nil
1886 "List of dormant articles in the current newsgroup.")
1888 (defvar gnus-newsgroup-scored nil
1889 "List of scored articles in the current newsgroup.")
1891 (defvar gnus-newsgroup-headers nil
1892 "List of article headers in the current newsgroup.")
1894 (defvar gnus-newsgroup-threads nil)
1896 (defvar gnus-newsgroup-prepared nil
1897 "Whether the current group has been prepared properly.")
1899 (defvar gnus-newsgroup-ancient nil
1900 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1902 (defvar gnus-newsgroup-sparse nil)
1904 (defvar gnus-current-article nil)
1905 (defvar gnus-article-current nil)
1906 (defvar gnus-current-headers nil)
1907 (defvar gnus-have-all-headers nil)
1908 (defvar gnus-last-article nil)
1909 (defvar gnus-newsgroup-history nil)
1910 (defvar gnus-current-kill-article nil)
1912 ;; Save window configuration.
1913 (defvar gnus-prev-winconf nil)
1915 (defvar gnus-summary-mark-positions nil)
1916 (defvar gnus-group-mark-positions nil)
1918 (defvar gnus-reffed-article-number nil)
1920 ;;; Let the byte-compiler know that we know about this variable.
1921 (defvar rmail-default-rmail-file)
1923 (defvar gnus-cache-removable-articles nil)
1925 (defvar gnus-dead-summary nil)
1927 (defconst gnus-summary-local-variables
1928 '(gnus-newsgroup-name
1929 gnus-newsgroup-begin gnus-newsgroup-end
1930 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1931 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1932 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1933 gnus-newsgroup-unselected gnus-newsgroup-marked
1934 gnus-newsgroup-reads gnus-newsgroup-saved
1935 gnus-newsgroup-replied gnus-newsgroup-expirable
1936 gnus-newsgroup-processable gnus-newsgroup-killed
1937 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1938 gnus-newsgroup-headers gnus-newsgroup-threads
1939 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1940 gnus-current-article gnus-current-headers gnus-have-all-headers
1941 gnus-last-article gnus-article-internal-prepare-hook
1942 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1943 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1944 gnus-newsgroup-async gnus-thread-expunge-below
1945 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1946 (gnus-summary-mark-below . global)
1947 gnus-newsgroup-active gnus-scores-exclude-files
1948 gnus-newsgroup-history gnus-newsgroup-ancient
1949 gnus-newsgroup-sparse
1950 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1951 gnus-newsgroup-adaptive-score-file
1952 (gnus-newsgroup-expunged-tally . 0)
1953 gnus-cache-removable-articles gnus-newsgroup-cached
1954 gnus-newsgroup-data gnus-newsgroup-data-reverse
1955 gnus-newsgroup-limit gnus-newsgroup-limits)
1956 "Variables that are buffer-local to the summary buffers.")
1958 (defconst gnus-bug-message
1959 "Sending a bug report to the Gnus Towers.
1960 ========================================
1962 The buffer below is a mail buffer. When you press `C-c C-c', it will
1963 be sent to the Gnus Bug Exterminators.
1965 At the bottom of the buffer you'll see lots of variable settings.
1966 Please do not delete those. They will tell the Bug People what your
1967 environment is, so that it will be easier to locate the bugs.
1969 If you have found a bug that makes Emacs go \"beep\", set
1970 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
1971 and include the backtrace in your bug report.
1973 Please describe the bug in annoying, painstaking detail.
1975 Thank you for your help in stamping out bugs.
1978 ;;; End of variables.
1980 ;; Define some autoload functions Gnus might use.
1983 ;; This little mapcar goes through the list below and marks the
1984 ;; symbols in question as autoloaded functions.
1987 (let ((interactive (nth 1 (memq ':interactive package))))
1991 (when (consp function)
1992 (setq keymap (car (memq 'keymap function)))
1993 (setq function (car function)))
1994 (autoload function (car package) nil interactive keymap)))
1995 (if (eq (nth 1 package) ':interactive)
1998 '(("metamail" metamail-buffer)
1999 ("info" Info-goto-node)
2000 ("hexl" hexl-hex-string-to-integer)
2001 ("pp" pp pp-to-string pp-eval-expression)
2002 ("mail-extr" mail-extract-address-components)
2003 ("nnmail" nnmail-split-fancy nnmail-article-group)
2004 ("nnvirtual" nnvirtual-catchup-group)
2005 ("timezone" timezone-make-date-arpa-standard timezone-fix-time
2006 timezone-make-sortable-date timezone-make-time-string)
2007 ("rmailout" rmail-output)
2008 ("rmail" rmail-insert-rmail-file-header rmail-count-new-messages
2010 ("gnus-soup" :interactive t
2011 gnus-group-brew-soup gnus-brew-soup gnus-soup-add-article
2012 gnus-soup-send-replies gnus-soup-save-areas gnus-soup-pack-packet)
2013 ("nnsoup" nnsoup-pack-replies)
2014 ("gnus-scomo" :interactive t gnus-score-mode)
2015 ("gnus-mh" gnus-mh-mail-setup gnus-summary-save-article-folder
2016 gnus-Folder-save-name gnus-folder-save-name)
2017 ("gnus-mh" :interactive t gnus-summary-save-in-folder)
2018 ("gnus-vis" gnus-group-make-menu-bar gnus-summary-make-menu-bar
2019 gnus-server-make-menu-bar gnus-article-make-menu-bar
2020 gnus-browse-make-menu-bar gnus-highlight-selected-summary
2021 gnus-summary-highlight-line gnus-carpal-setup-buffer
2022 gnus-group-highlight-line
2023 gnus-article-add-button gnus-insert-next-page-button
2024 gnus-insert-prev-page-button gnus-visual-turn-off-edit-menu)
2025 ("gnus-vis" :interactive t
2026 gnus-article-push-button gnus-article-press-button
2027 gnus-article-highlight gnus-article-highlight-some
2028 gnus-article-highlight-headers gnus-article-highlight-signature
2029 gnus-article-add-buttons gnus-article-add-buttons-to-head
2030 gnus-article-next-button gnus-article-prev-button)
2031 ("gnus-demon" gnus-demon-add-nocem gnus-demon-add-scanmail
2032 gnus-demon-add-disconnection gnus-demon-add-handler
2033 gnus-demon-remove-handler)
2034 ("gnus-demon" :interactive t
2035 gnus-demon-init gnus-demon-cancel)
2036 ("gnus-salt" gnus-highlight-selected-tree gnus-possibly-generate-tree
2037 gnus-tree-open gnus-tree-close)
2038 ("gnus-nocem" gnus-nocem-scan-groups gnus-nocem-close
2039 gnus-nocem-unwanted-article-p)
2040 ("gnus-srvr" gnus-enter-server-buffer gnus-server-set-info)
2041 ("gnus-srvr" gnus-browse-foreign-server)
2042 ("gnus-cite" :interactive t
2043 gnus-article-highlight-citation gnus-article-hide-citation-maybe
2044 gnus-article-hide-citation gnus-article-fill-cited-article
2045 gnus-article-hide-citation-in-followups)
2046 ("gnus-kill" gnus-kill gnus-apply-kill-file-internal
2047 gnus-kill-file-edit-file gnus-kill-file-raise-followups-to-author
2048 gnus-execute gnus-expunge)
2049 ("gnus-cache" gnus-cache-possibly-enter-article gnus-cache-save-buffers
2050 gnus-cache-possibly-remove-articles gnus-cache-request-article
2051 gnus-cache-retrieve-headers gnus-cache-possibly-alter-active
2052 gnus-cache-enter-remove-article gnus-cached-article-p
2053 gnus-cache-open gnus-cache-close gnus-cache-update-article)
2054 ("gnus-cache" :interactive t gnus-jog-cache gnus-cache-enter-article
2055 gnus-cache-remove-article)
2056 ("gnus-score" :interactive t
2057 gnus-summary-increase-score gnus-summary-lower-score
2058 gnus-score-flush-cache gnus-score-close
2059 gnus-score-raise-same-subject-and-select
2060 gnus-score-raise-same-subject gnus-score-default
2061 gnus-score-raise-thread gnus-score-lower-same-subject-and-select
2062 gnus-score-lower-same-subject gnus-score-lower-thread
2063 gnus-possibly-score-headers gnus-summary-raise-score
2064 gnus-summary-set-score gnus-summary-current-score)
2066 (gnus-summary-score-map keymap) gnus-score-save gnus-score-headers
2067 gnus-current-score-file-nondirectory gnus-score-adaptive
2068 gnus-score-find-trace gnus-score-file-name)
2069 ("gnus-edit" :interactive t gnus-score-customize)
2070 ("gnus-topic" :interactive t gnus-topic-mode)
2071 ("gnus-topic" gnus-topic-remove-group)
2072 ("gnus-salt" :interactive t gnus-pick-mode gnus-binary-mode)
2073 ("gnus-uu" (gnus-uu-extract-map keymap) (gnus-uu-mark-map keymap))
2074 ("gnus-uu" :interactive t
2075 gnus-uu-digest-mail-forward gnus-uu-digest-post-forward
2076 gnus-uu-mark-series gnus-uu-mark-region gnus-uu-mark-buffer
2077 gnus-uu-mark-by-regexp gnus-uu-mark-all
2078 gnus-uu-mark-sparse gnus-uu-mark-thread gnus-uu-decode-uu
2079 gnus-uu-decode-uu-and-save gnus-uu-decode-unshar
2080 gnus-uu-decode-unshar-and-save gnus-uu-decode-save
2081 gnus-uu-decode-binhex gnus-uu-decode-uu-view
2082 gnus-uu-decode-uu-and-save-view gnus-uu-decode-unshar-view
2083 gnus-uu-decode-unshar-and-save-view gnus-uu-decode-save-view
2084 gnus-uu-decode-binhex-view)
2085 ("gnus-msg" (gnus-summary-send-map keymap)
2086 gnus-mail-yank-original gnus-mail-send-and-exit
2087 gnus-sendmail-setup-mail gnus-article-mail
2088 gnus-inews-message-id gnus-new-mail gnus-mail-reply)
2089 ("gnus-msg" :interactive t
2090 gnus-group-post-news gnus-group-mail gnus-summary-post-news
2091 gnus-summary-followup gnus-summary-followup-with-original
2092 gnus-summary-cancel-article gnus-summary-supersede-article
2093 gnus-post-news gnus-inews-news gnus-cancel-news
2094 gnus-summary-reply gnus-summary-reply-with-original
2095 gnus-summary-mail-forward gnus-summary-mail-other-window
2097 ("gnus-picon" :interactive t gnus-article-display-picons
2098 gnus-group-display-picons gnus-picons-article-display-x-face)
2099 ("gnus-gl" bbb-login bbb-logout bbb-grouplens-group-p
2100 gnus-grouplens-mode)
2101 ("gnus-vm" gnus-vm-mail-setup)
2102 ("gnus-vm" :interactive t gnus-summary-save-in-vm
2103 gnus-summary-save-article-vm))))
2107 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2108 ;; If you want the cursor to go somewhere else, set these two
2109 ;; functions in some startup hook to whatever you want.
2110 (defalias 'gnus-summary-position-point 'gnus-goto-colon)
2111 (defalias 'gnus-group-position-point 'gnus-goto-colon)
2113 ;;; Various macros and substs.
2115 (defun gnus-header-from (header)
2116 (mail-header-from header))
2118 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
2119 "Pop to BUFFER, evaluate FORMS, and then return to the original window."
2120 (let ((tempvar (make-symbol "GnusStartBufferWindow"))
2121 (w (make-symbol "w"))
2122 (buf (make-symbol "buf")))
2123 `(let* ((,tempvar (selected-window))
2125 (,w (get-buffer-window ,buf 'visible)))
2130 (pop-to-buffer ,buf))
2132 (select-window ,tempvar)))))
2134 (put 'gnus-eval-in-buffer-window 'lisp-indent-function 1)
2135 (put 'gnus-eval-in-buffer-window 'lisp-indent-hook 1)
2136 (put 'gnus-eval-in-buffer-window 'edebug-form-spec '(form body))
2138 (defmacro gnus-gethash (string hashtable)
2139 "Get hash value of STRING in HASHTABLE."
2140 `(symbol-value (intern-soft ,string ,hashtable)))
2142 (defmacro gnus-sethash (string value hashtable)
2143 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2144 `(set (intern ,string ,hashtable) ,value))
2146 (defmacro gnus-intern-safe (string hashtable)
2147 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2148 `(let ((symbol (intern ,string ,hashtable)))
2153 (defmacro gnus-group-unread (group)
2154 "Get the currently computed number of unread articles in GROUP."
2155 `(car (gnus-gethash ,group gnus-newsrc-hashtb)))
2157 (defmacro gnus-group-entry (group)
2158 "Get the newsrc entry for GROUP."
2159 `(gnus-gethash ,group gnus-newsrc-hashtb))
2161 (defmacro gnus-active (group)
2162 "Get active info on GROUP."
2163 `(gnus-gethash ,group gnus-active-hashtb))
2165 (defmacro gnus-set-active (group active)
2166 "Set GROUP's active info."
2167 `(gnus-sethash ,group ,active gnus-active-hashtb))
2169 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2170 ;; function `substring' might cut on a middle of multi-octet
2172 (defun gnus-truncate-string (str width)
2173 (substring str 0 width))
2175 ;; Added by Geoffrey T. Dairiki <dairiki@u.washington.edu>. A safe way
2176 ;; to limit the length of a string. This function is necessary since
2177 ;; `(substr "abc" 0 30)' pukes with "Args out of range".
2178 (defsubst gnus-limit-string (str width)
2179 (if (> (length str) width)
2180 (substring str 0 width)
2183 (defsubst gnus-simplify-subject-re (subject)
2184 "Remove \"Re:\" from subject lines."
2185 (if (string-match "^[Rr][Ee]: *" subject)
2186 (substring subject (match-end 0))
2189 (defsubst gnus-functionp (form)
2190 "Return non-nil if FORM is funcallable."
2191 (or (and (symbolp form) (fboundp form))
2192 (and (listp form) (eq (car form) 'lambda))))
2194 (defsubst gnus-goto-char (point)
2195 (and point (goto-char point)))
2197 (defmacro gnus-buffer-exists-p (buffer)
2198 `(let ((buffer ,buffer))
2200 (funcall (if (stringp buffer) 'get-buffer 'buffer-name)
2203 (defmacro gnus-kill-buffer (buffer)
2204 `(let ((buf ,buffer))
2205 (if (gnus-buffer-exists-p buf)
2206 (kill-buffer buf))))
2208 (defsubst gnus-point-at-bol ()
2209 "Return point at the beginning of the line."
2216 (defsubst gnus-point-at-eol ()
2217 "Return point at the end of the line."
2224 (defun gnus-alive-p ()
2225 "Say whether Gnus is running or not."
2226 (and gnus-group-buffer
2227 (get-buffer gnus-group-buffer)))
2229 (defun gnus-delete-first (elt list)
2230 "Delete by side effect the first occurrence of ELT as a member of LIST."
2231 (if (equal (car list) elt)
2234 (while (and (cdr list)
2235 (not (equal (cadr list) elt)))
2236 (setq list (cdr list)))
2238 (setcdr list (cddr list)))
2241 ;; Delete the current line (and the next N lines.);
2242 (defmacro gnus-delete-line (&optional n)
2243 `(delete-region (progn (beginning-of-line) (point))
2244 (progn (forward-line ,(or n 1)) (point))))
2246 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
2247 (defvar gnus-init-inhibit nil)
2248 (defun gnus-read-init-file (&optional inhibit-next)
2249 (if gnus-init-inhibit
2250 (setq gnus-init-inhibit nil)
2251 (setq gnus-init-inhibit inhibit-next)
2253 (or (and (file-exists-p gnus-init-file)
2254 ;; Don't try to load a directory.
2255 (not (file-directory-p gnus-init-file)))
2256 (file-exists-p (concat gnus-init-file ".el"))
2257 (file-exists-p (concat gnus-init-file ".elc")))
2259 (load gnus-init-file nil t)
2261 (error "Error in %s: %s" gnus-init-file var))))))
2263 ;; Info access macros.
2265 (defmacro gnus-info-group (info)
2267 (defmacro gnus-info-rank (info)
2269 (defmacro gnus-info-read (info)
2271 (defmacro gnus-info-marks (info)
2273 (defmacro gnus-info-method (info)
2275 (defmacro gnus-info-params (info)
2278 (defmacro gnus-info-level (info)
2279 `(let ((rank (gnus-info-rank ,info)))
2283 (defmacro gnus-info-score (info)
2284 `(let ((rank (gnus-info-rank ,info)))
2285 (or (and (consp rank) (cdr rank)) 0)))
2287 (defmacro gnus-info-set-group (info group)
2288 `(setcar ,info ,group))
2289 (defmacro gnus-info-set-rank (info rank)
2290 `(setcar (nthcdr 1 ,info) ,rank))
2291 (defmacro gnus-info-set-read (info read)
2292 `(setcar (nthcdr 2 ,info) ,read))
2293 (defmacro gnus-info-set-marks (info marks)
2294 `(setcar (nthcdr 3 ,info) ,marks))
2295 (defmacro gnus-info-set-method (info method)
2296 `(setcar (nthcdr 4 ,info) ,method))
2297 (defmacro gnus-info-set-params (info params)
2298 `(setcar (nthcdr 5 ,info) ,params))
2300 (defmacro gnus-info-set-level (info level)
2301 `(let ((rank (cdr ,info)))
2302 (if (consp (car rank))
2303 (setcar (car rank) ,level)
2304 (setcar rank ,level))))
2305 (defmacro gnus-info-set-score (info score)
2306 `(let ((rank (cdr ,info)))
2307 (if (consp (car rank))
2308 (setcdr (car rank) ,score)
2309 (setcar rank (cons (car rank) ,score)))))
2311 (defmacro gnus-get-info (group)
2312 `(nth 2 (gnus-gethash ,group gnus-newsrc-hashtb)))
2314 (defun gnus-byte-code (func)
2315 "Return a form that can be `eval'ed based on FUNC."
2316 (let ((fval (symbol-function func)))
2317 (if (byte-code-function-p fval)
2318 (let ((flist (append fval nil)))
2319 (setcar flist 'byte-code)
2321 (cons 'progn (cddr fval)))))
2323 ;; Find out whether the gnus-visual TYPE is wanted.
2324 (defun gnus-visual-p (&optional type class)
2325 (and gnus-visual ; Has to be non-nil, at least.
2326 (if (not type) ; We don't care about type.
2328 (if (listp gnus-visual) ; It's a list, so we check it.
2329 (or (memq type gnus-visual)
2330 (memq class gnus-visual))
2333 ;;; Load the compatability functions.
2343 (defvar gnus-shutdown-alist nil)
2345 (defun gnus-add-shutdown (function &rest symbols)
2346 "Run FUNCTION whenever one of SYMBOLS is shut down."
2347 (push (cons function symbols) gnus-shutdown-alist))
2349 (defun gnus-shutdown (symbol)
2350 "Shut down everything that waits for SYMBOL."
2351 (let ((alist gnus-shutdown-alist)
2353 (while (setq entry (pop alist))
2354 (when (memq symbol (cdr entry))
2355 (funcall (car entry))))))
2359 ;; Format specs. The chunks below are the machine-generated forms
2360 ;; that are to be evaled as the result of the default format strings.
2361 ;; We write them in here to get them byte-compiled. That way the
2362 ;; default actions will be quite fast, while still retaining the full
2363 ;; flexibility of the user-defined format specs.
2365 ;; First we have lots of dummy defvars to let the compiler know these
2366 ;; are really dynamic variables.
2368 (defvar gnus-tmp-unread)
2369 (defvar gnus-tmp-replied)
2370 (defvar gnus-tmp-score-char)
2371 (defvar gnus-tmp-indentation)
2372 (defvar gnus-tmp-opening-bracket)
2373 (defvar gnus-tmp-lines)
2374 (defvar gnus-tmp-name)
2375 (defvar gnus-tmp-closing-bracket)
2376 (defvar gnus-tmp-subject-or-nil)
2377 (defvar gnus-tmp-subject)
2378 (defvar gnus-tmp-marked)
2379 (defvar gnus-tmp-marked-mark)
2380 (defvar gnus-tmp-subscribed)
2381 (defvar gnus-tmp-process-marked)
2382 (defvar gnus-tmp-number-of-unread)
2383 (defvar gnus-tmp-group-name)
2384 (defvar gnus-tmp-group)
2385 (defvar gnus-tmp-article-number)
2386 (defvar gnus-tmp-unread-and-unselected)
2387 (defvar gnus-tmp-news-method)
2388 (defvar gnus-tmp-news-server)
2389 (defvar gnus-tmp-article-number)
2390 (defvar gnus-mouse-face)
2391 (defvar gnus-mouse-face-prop)
2393 (defun gnus-summary-line-format-spec ()
2394 (insert gnus-tmp-unread gnus-tmp-replied
2395 gnus-tmp-score-char gnus-tmp-indentation)
2396 (gnus-put-text-property
2400 gnus-tmp-opening-bracket
2401 (format "%4d: %-20s"
2403 (if (> (length gnus-tmp-name) 20)
2404 (substring gnus-tmp-name 0 20)
2406 gnus-tmp-closing-bracket)
2408 gnus-mouse-face-prop gnus-mouse-face)
2409 (insert " " gnus-tmp-subject-or-nil "\n"))
2411 (defvar gnus-summary-line-format-spec
2412 (gnus-byte-code 'gnus-summary-line-format-spec))
2414 (defun gnus-summary-dummy-line-format-spec ()
2416 (gnus-put-text-property
2421 gnus-mouse-face-prop gnus-mouse-face)
2422 (insert " " gnus-tmp-subject "\n"))
2424 (defvar gnus-summary-dummy-line-format-spec
2425 (gnus-byte-code 'gnus-summary-dummy-line-format-spec))
2427 (defun gnus-group-line-format-spec ()
2428 (insert gnus-tmp-marked-mark gnus-tmp-subscribed
2429 gnus-tmp-process-marked
2430 gnus-group-indentation
2431 (format "%5s: " gnus-tmp-number-of-unread))
2432 (gnus-put-text-property
2435 (insert gnus-tmp-group "\n")
2437 gnus-mouse-face-prop gnus-mouse-face))
2438 (defvar gnus-group-line-format-spec
2439 (gnus-byte-code 'gnus-group-line-format-spec))
2441 (defvar gnus-format-specs
2442 `((version . ,emacs-version)
2443 (group ,gnus-group-line-format ,gnus-group-line-format-spec)
2444 (summary-dummy ,gnus-summary-dummy-line-format
2445 ,gnus-summary-dummy-line-format-spec)
2446 (summary ,gnus-summary-line-format ,gnus-summary-line-format-spec)))
2448 (defvar gnus-article-mode-line-format-spec nil)
2449 (defvar gnus-summary-mode-line-format-spec nil)
2450 (defvar gnus-group-mode-line-format-spec nil)
2452 ;;; Phew. All that gruft is over, fortunately.
2456 ;;; Gnus Utility Functions
2459 (defun gnus-extract-address-components (from)
2461 ;; First find the address - the thing with the @ in it. This may
2462 ;; not be accurate in mail addresses, but does the trick most of
2463 ;; the time in news messages.
2464 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
2465 (setq address (substring from (match-beginning 0) (match-end 0))))
2466 ;; Then we check whether the "name <address>" format is used.
2468 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2469 ;; Linear white space is not required.
2470 (string-match (concat "[ \t]*<" (regexp-quote address) ">") from)
2471 (and (setq name (substring from 0 (match-beginning 0)))
2472 ;; Strip any quotes from the name.
2473 (string-match "\".*\"" name)
2474 (setq name (substring name 1 (1- (match-end 0))))))
2475 ;; If not, then "address (name)" is used.
2477 (and (string-match "(.+)" from)
2478 (setq name (substring from (1+ (match-beginning 0))
2479 (1- (match-end 0)))))
2480 (and (string-match "()" from)
2481 (setq name address))
2482 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>.
2483 ;; XOVER might not support folded From headers.
2484 (and (string-match "(.*" from)
2485 (setq name (substring from (1+ (match-beginning 0))
2487 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2488 (list (or name from) (or address from))))
2490 (defun gnus-fetch-field (field)
2491 "Return the value of the header FIELD of current article."
2494 (let ((case-fold-search t)
2495 (inhibit-point-motion-hooks t))
2496 (nnheader-narrow-to-headers)
2497 (message-fetch-field field)))))
2499 (defun gnus-goto-colon ()
2501 (search-forward ":" (gnus-point-at-eol) t))
2504 (defun gnus-update-format (var)
2505 "Update the format specification near point."
2510 ;; Find the end of the current word.
2511 (re-search-forward "[ \t\n]" nil t)
2513 (when (re-search-backward "\\(gnus-[-a-z]+-line-format\\)" nil t)
2514 (match-string 1)))))
2515 (let* ((type (intern (progn (string-match "gnus-\\([-a-z]+\\)-line" var)
2516 (match-string 1 var))))
2517 (entry (assq type gnus-format-specs))
2520 (setq gnus-format-specs (delq entry gnus-format-specs)))
2522 (intern (format "%s-spec" var))
2523 (gnus-parse-format (setq value (symbol-value (intern var)))
2524 (symbol-value (intern (format "%s-alist" var)))
2525 (not (string-match "mode" var))))
2526 (setq spec (symbol-value (intern (format "%s-spec" var))))
2527 (push (list type value spec) gnus-format-specs)
2529 (pop-to-buffer "*Gnus Format*")
2531 (lisp-interaction-mode)
2532 (insert (pp-to-string spec))))
2534 (defun gnus-update-format-specifications (&optional force)
2535 "Update all (necessary) format specifications."
2536 ;; Make the indentation array.
2537 (gnus-make-thread-indent-array)
2539 ;; See whether all the stored info needs to be flushed.
2541 (not (equal emacs-version
2542 (cdr (assq 'version gnus-format-specs)))))
2543 (setq gnus-format-specs nil))
2545 ;; Go through all the formats and see whether they need updating.
2546 (let ((types '(summary summary-dummy group
2547 summary-mode group-mode article-mode))
2548 new-format entry type val)
2549 (while (setq type (pop types))
2550 ;; Jump to the proper buffer to find out the value of
2551 ;; the variable, if possible. (It may be buffer-local.)
2553 (let ((buffer (intern (format "gnus-%s-buffer" type)))
2555 (when (and (boundp buffer)
2556 (setq val (symbol-value buffer))
2558 (buffer-name (get-buffer val)))
2559 (set-buffer (get-buffer val)))
2560 (setq new-format (symbol-value
2561 (intern (format "gnus-%s-line-format" type))))))
2562 (setq entry (cdr (assq type gnus-format-specs)))
2564 (equal (car entry) new-format))
2565 ;; Use the old format.
2566 (set (intern (format "gnus-%s-line-format-spec" type))
2568 ;; This is a new format.
2570 (if (not (stringp new-format))
2571 ;; This is a function call or something.
2573 ;; This is a "real" format.
2577 (intern (format "gnus-%s-line-format-alist"
2578 (if (eq type 'article-mode)
2579 'summary-mode type))))
2580 (not (string-match "mode$" (symbol-name type))))))
2581 ;; Enter the new format spec into the list.
2584 (setcar (cdr entry) val)
2585 (setcar entry new-format))
2586 (push (list type new-format val) gnus-format-specs))
2587 (set (intern (format "gnus-%s-line-format-spec" type)) val))))
2589 (unless (assq 'version gnus-format-specs)
2590 (push (cons 'version emacs-version) gnus-format-specs))
2592 (gnus-update-group-mark-positions)
2593 (gnus-update-summary-mark-positions))
2595 (defun gnus-update-summary-mark-positions ()
2596 "Compute where the summary marks are to go."
2598 (when (and gnus-summary-buffer
2599 (get-buffer gnus-summary-buffer)
2600 (buffer-name (get-buffer gnus-summary-buffer)))
2601 (set-buffer gnus-summary-buffer))
2602 (let ((gnus-replied-mark 129)
2603 (gnus-score-below-mark 130)
2604 (gnus-score-over-mark 130)
2607 (spec gnus-summary-line-format-spec)
2610 (gnus-set-work-buffer)
2611 (let ((gnus-summary-line-format-spec spec))
2612 (gnus-summary-insert-line
2613 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2614 (goto-char (point-min))
2615 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2617 (goto-char (point-min))
2618 (push (cons 'replied (and (search-forward "\201" nil t)
2621 (goto-char (point-min))
2622 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2624 (setq gnus-summary-mark-positions pos))))
2626 (defun gnus-update-group-mark-positions ()
2628 (let ((gnus-process-mark 128)
2629 (gnus-group-marked '("dummy.group"))
2630 (gnus-active-hashtb (make-vector 10 0)))
2631 (gnus-set-active "dummy.group" '(0 . 0))
2632 (gnus-set-work-buffer)
2633 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
2634 (goto-char (point-min))
2635 (setq gnus-group-mark-positions
2636 (list (cons 'process (and (search-forward "\200" nil t)
2637 (- (point) 2))))))))
2639 (defvar gnus-mouse-face-0 'highlight)
2640 (defvar gnus-mouse-face-1 'highlight)
2641 (defvar gnus-mouse-face-2 'highlight)
2642 (defvar gnus-mouse-face-3 'highlight)
2643 (defvar gnus-mouse-face-4 'highlight)
2645 (defun gnus-mouse-face-function (form type)
2646 `(gnus-put-text-property
2647 (point) (progn ,@form (point))
2648 gnus-mouse-face-prop
2651 `(quote ,(symbol-value (intern (format "gnus-mouse-face-%d" type)))))))
2653 (defvar gnus-face-0 'bold)
2654 (defvar gnus-face-1 'italic)
2655 (defvar gnus-face-2 'bold-italic)
2656 (defvar gnus-face-3 'bold)
2657 (defvar gnus-face-4 'bold)
2659 (defun gnus-face-face-function (form type)
2660 `(gnus-put-text-property
2661 (point) (progn ,@form (point))
2662 'face ',(symbol-value (intern (format "gnus-face-%d" type)))))
2664 (defun gnus-max-width-function (el max-width)
2665 (or (numberp max-width) (signal 'wrong-type-argument '(numberp max-width)))
2667 `(if (> (length ,el) ,max-width)
2668 (substring ,el 0 ,max-width)
2670 `(let ((val (eval ,el)))
2672 (setq val (int-to-string val)))
2673 (if (> (length val) ,max-width)
2674 (substring val 0 ,max-width)
2677 (defun gnus-parse-format (format spec-alist &optional insert)
2678 ;; This function parses the FORMAT string with the help of the
2679 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
2680 ;; string. If the FORMAT string contains the specifiers %( and %)
2681 ;; the text between them will have the mouse-face text property.
2683 "\\`\\(.*\\)%[0-9]?[{(]\\(.*\\)%[0-9]?[})]\\(.*\n?\\)\\'"
2685 (gnus-parse-complex-format format spec-alist)
2686 ;; This is a simple format.
2687 (gnus-parse-simple-format format spec-alist insert)))
2689 (defun gnus-parse-complex-format (format spec-alist)
2691 (gnus-set-work-buffer)
2693 (goto-char (point-min))
2694 (while (re-search-forward "\"" nil t)
2695 (replace-match "\\\"" nil t))
2696 (goto-char (point-min))
2698 (while (re-search-forward "%\\([0-9]+\\)?\\([{}()]\\)" nil t)
2699 (let ((number (if (match-beginning 1)
2700 (match-string 1) "0"))
2701 (delim (aref (match-string 2) 0)))
2702 (if (or (= delim ?\() (= delim ?\{))
2703 (replace-match (concat "\"(" (if (= delim ?\() "mouse" "face")
2705 (replace-match "\")\""))))
2706 (goto-char (point-max))
2708 (goto-char (point-min))
2709 (let ((form (read (current-buffer))))
2710 (cons 'progn (gnus-complex-form-to-spec form spec-alist)))))
2712 (defun gnus-complex-form-to-spec (form spec-alist)
2717 (gnus-parse-simple-format sform spec-alist t)
2718 (funcall (intern (format "gnus-%s-face-function" (car sform)))
2719 (gnus-complex-form-to-spec (cddr sform) spec-alist)
2723 (defun gnus-parse-simple-format (format spec-alist &optional insert)
2724 ;; This function parses the FORMAT string with the help of the
2725 ;; SPEC-ALIST and returns a list that can be eval'ed to return a
2728 spec flist fstring newspec elem beg result dontinsert)
2730 (gnus-set-work-buffer)
2732 (goto-char (point-min))
2733 (while (re-search-forward "%[-0-9]*\\(,[0-9]+\\)?\\([^0-9]\\)\\(.\\)?"
2735 (if (= (setq spec (string-to-char (match-string 2))) ?%)
2737 beg (1+ (match-beginning 0)))
2738 ;; First check if there are any specs that look anything like
2739 ;; "%12,12A", ie. with a "max width specification". These have
2740 ;; to be treated specially.
2741 (if (setq beg (match-beginning 1))
2745 (1+ (match-beginning 1)) (match-end 1))))
2747 (setq beg (match-beginning 2)))
2748 ;; Find the specification from `spec-alist'.
2749 (unless (setq elem (cdr (assq spec spec-alist)))
2750 (setq elem '("*" ?s)))
2751 ;; Treat user defined format specifiers specially.
2752 (when (eq (car elem) 'gnus-tmp-user-defined)
2755 (list (intern (concat "gnus-user-format-function-"
2757 'gnus-tmp-header) ?s))
2758 (delete-region (match-beginning 3) (match-end 3)))
2759 (if (not (zerop max-width))
2760 (let ((el (car elem)))
2761 (cond ((= (cadr elem) ?c)
2762 (setq el (list 'char-to-string el)))
2764 (setq el (list 'int-to-string el))))
2765 (setq flist (cons (gnus-max-width-function el max-width)
2769 (setq flist (cons (car elem) flist))
2770 (setq newspec (cadr elem)))))
2771 ;; Remove the old specification (and possibly a ",12" string).
2772 (delete-region beg (match-end 2))
2773 ;; Insert the new specification.
2776 (setq fstring (buffer-substring 1 (point-max))))
2777 ;; Do some postprocessing to increase efficiency.
2782 ((string= fstring "")
2784 ;; Not a format string.
2785 ((not (string-match "%" fstring))
2787 ;; A format string with just a single string spec.
2788 ((string= fstring "%s")
2790 ;; A single character.
2791 ((string= fstring "%c")
2794 ((string= fstring "%d")
2797 (list `(princ ,(car flist)))
2798 (list `(int-to-string ,(car flist)))))
2799 ;; Just lots of chars and strings.
2800 ((string-match "\\`\\(%[cs]\\)+\\'" fstring)
2802 ;; A single string spec at the beginning of the spec.
2803 ((string-match "\\`%[sc][^%]+\\'" fstring)
2804 (list (car flist) (substring fstring 2)))
2805 ;; A single string spec in the middle of the spec.
2806 ((string-match "\\`\\([^%]+\\)%[sc]\\([^%]+\\)\\'" fstring)
2807 (list (match-string 1 fstring) (car flist) (match-string 2 fstring)))
2808 ;; A single string spec in the end of the spec.
2809 ((string-match "\\`\\([^%]+\\)%[sc]\\'" fstring)
2810 (list (match-string 1 fstring) (car flist)))
2811 ;; A more complex spec.
2813 (list (cons 'format (cons fstring (nreverse flist)))))))
2819 (cons 'insert result)))
2820 (cond ((stringp result)
2823 (cons 'concat result))
2826 (defun gnus-eval-format (format &optional alist props)
2827 "Eval the format variable FORMAT, using ALIST.
2828 If PROPS, insert the result."
2829 (let ((form (gnus-parse-format format alist props)))
2831 (gnus-add-text-properties (point) (progn (eval form) (point)) props)
2834 (defun gnus-remove-text-with-property (prop)
2835 "Delete all text in the current buffer with text property PROP."
2837 (goto-char (point-min))
2839 (while (get-text-property (point) prop)
2841 (goto-char (next-single-property-change (point) prop nil (point-max))))))
2843 (defun gnus-set-work-buffer ()
2844 (if (get-buffer gnus-work-buffer)
2846 (set-buffer gnus-work-buffer)
2848 (set-buffer (get-buffer-create gnus-work-buffer))
2849 (kill-all-local-variables)
2850 (buffer-disable-undo (current-buffer))
2851 (gnus-add-current-to-buffer-list)))
2853 ;; Article file names when saving.
2855 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2856 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2857 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
2858 Otherwise, it is like ~/News/news/group/num."
2861 (concat (if (gnus-use-long-file-name 'not-save)
2862 (gnus-capitalize-newsgroup newsgroup)
2863 (gnus-newsgroup-directory-form newsgroup))
2864 "/" (int-to-string (mail-header-number headers)))
2865 gnus-article-save-directory)))
2867 (string-equal (file-name-directory default)
2868 (file-name-directory last-file))
2869 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2871 (or last-file default))))
2873 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2874 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2875 If variable `gnus-use-long-file-name' is non-nil, it is
2876 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2879 (concat (if (gnus-use-long-file-name 'not-save)
2881 (gnus-newsgroup-directory-form newsgroup))
2882 "/" (int-to-string (mail-header-number headers)))
2883 gnus-article-save-directory)))
2885 (string-equal (file-name-directory default)
2886 (file-name-directory last-file))
2887 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2889 (or last-file default))))
2891 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2892 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2893 If variable `gnus-use-long-file-name' is non-nil, it is
2894 ~/News/News.group. Otherwise, it is like ~/News/news/group/news."
2897 (if (gnus-use-long-file-name 'not-save)
2898 (gnus-capitalize-newsgroup newsgroup)
2899 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2900 gnus-article-save-directory)))
2902 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2903 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2904 If variable `gnus-use-long-file-name' is non-nil, it is
2905 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2908 (if (gnus-use-long-file-name 'not-save)
2910 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2911 gnus-article-save-directory)))
2913 ;; For subscribing new newsgroup
2915 (defun gnus-subscribe-hierarchical-interactive (groups)
2916 (let ((groups (sort groups 'string<))
2917 prefixes prefix start ans group starts)
2919 (setq prefixes (list "^"))
2920 (while (and groups prefixes)
2921 (while (not (string-match (car prefixes) (car groups)))
2922 (setq prefixes (cdr prefixes)))
2923 (setq prefix (car prefixes))
2924 (setq start (1- (length prefix)))
2925 (if (and (string-match "[^\\.]\\." (car groups) start)
2928 (concat "^" (substring (car groups) 0 (match-end 0))))
2929 (string-match prefix (cadr groups)))
2931 (setq prefixes (cons prefix prefixes))
2932 (message "Descend hierarchy %s? ([y]nsq): "
2933 (substring prefix 1 (1- (length prefix))))
2934 (while (not (memq (setq ans (read-char)) '(?y ?\n ?n ?s ?q)))
2936 (message "Descend hierarchy %s? ([y]nsq): "
2937 (substring prefix 1 (1- (length prefix)))))
2940 (string-match prefix
2941 (setq group (car groups))))
2942 (setq gnus-killed-list
2943 (cons group gnus-killed-list))
2944 (gnus-sethash group group gnus-killed-hashtb)
2945 (setq groups (cdr groups)))
2946 (setq starts (cdr starts)))
2949 (string-match prefix
2950 (setq group (car groups))))
2951 (gnus-sethash group group gnus-killed-hashtb)
2952 (gnus-subscribe-alphabetically (car groups))
2953 (setq groups (cdr groups)))
2954 (setq starts (cdr starts)))
2957 (setq group (car groups))
2958 (setq gnus-killed-list (cons group gnus-killed-list))
2959 (gnus-sethash group group gnus-killed-hashtb)
2960 (setq groups (cdr groups))))
2962 (message "Subscribe %s? ([n]yq)" (car groups))
2963 (while (not (memq (setq ans (read-char)) '(?y ?\n ?q ?n)))
2965 (message "Subscribe %s? ([n]yq)" (car groups)))
2966 (setq group (car groups))
2968 (gnus-subscribe-alphabetically (car groups))
2969 (gnus-sethash group group gnus-killed-hashtb))
2972 (setq group (car groups))
2973 (setq gnus-killed-list (cons group gnus-killed-list))
2974 (gnus-sethash group group gnus-killed-hashtb)
2975 (setq groups (cdr groups))))
2977 (setq gnus-killed-list (cons group gnus-killed-list))
2978 (gnus-sethash group group gnus-killed-hashtb)))
2979 (setq groups (cdr groups)))))))
2981 (defun gnus-subscribe-randomly (newsgroup)
2982 "Subscribe new NEWSGROUP by making it the first newsgroup."
2983 (gnus-subscribe-newsgroup newsgroup))
2985 (defun gnus-subscribe-alphabetically (newgroup)
2986 "Subscribe new NEWSGROUP and insert it in alphabetical order."
2987 (let ((groups (cdr gnus-newsrc-alist))
2989 (while (and (not before) groups)
2990 (if (string< newgroup (caar groups))
2991 (setq before (caar groups))
2992 (setq groups (cdr groups))))
2993 (gnus-subscribe-newsgroup newgroup before)))
2995 (defun gnus-subscribe-hierarchically (newgroup)
2996 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
2997 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2999 (set-buffer (find-file-noselect gnus-current-startup-file))
3000 (let ((groupkey newgroup)
3002 (while (and (not before) groupkey)
3003 (goto-char (point-min))
3005 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
3006 (while (and (re-search-forward groupkey-re nil t)
3008 (setq before (match-string 1))
3009 (string< before newgroup)))))
3010 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
3012 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
3013 (substring groupkey (match-beginning 1) (match-end 1)))))
3014 (gnus-subscribe-newsgroup newgroup before))))
3016 (defun gnus-subscribe-interactively (group)
3017 "Subscribe the new GROUP interactively.
3018 It is inserted in hierarchical newsgroup order if subscribed. If not,
3020 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " group))
3021 (gnus-subscribe-hierarchically group)
3022 (push group gnus-killed-list)))
3024 (defun gnus-subscribe-zombies (group)
3025 "Make the new GROUP into a zombie group."
3026 (push group gnus-zombie-list))
3028 (defun gnus-subscribe-killed (group)
3029 "Make the new GROUP a killed group."
3030 (push group gnus-killed-list))
3032 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
3033 "Subscribe new NEWSGROUP.
3034 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
3035 the first newsgroup."
3036 ;; We subscribe the group by changing its level to `subscribed'.
3037 (gnus-group-change-level
3038 newsgroup gnus-level-default-subscribed
3039 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
3040 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))
3044 (defun gnus-newsgroup-directory-form (newsgroup)
3045 "Make hierarchical directory name from NEWSGROUP name."
3046 (let ((newsgroup (gnus-newsgroup-savable-name newsgroup))
3047 (len (length newsgroup))
3049 ;; If this is a foreign group, we don't want to translate the
3051 (if (setq idx (string-match ":" newsgroup))
3052 (aset newsgroup idx ?/)
3054 ;; Replace all occurrences of `.' with `/'.
3056 (if (= (aref newsgroup idx) ?.)
3057 (aset newsgroup idx ?/))
3058 (setq idx (1+ idx)))
3061 (defun gnus-newsgroup-savable-name (group)
3062 ;; Replace any slashes in a group name (eg. an ange-ftp nndoc group)
3064 (nnheader-replace-chars-in-string group ?/ ?.))
3066 (defun gnus-make-directory (dir)
3067 "Make DIRECTORY recursively."
3068 ;; Why don't we use `(make-directory dir 'parents)'? That's just one
3069 ;; of the many mysteries of the universe.
3070 (let* ((dir (expand-file-name dir default-directory))
3072 (if (string-match "/$" dir)
3073 (setq dir (substring dir 0 (match-beginning 0))))
3074 ;; First go down the path until we find a directory that exists.
3075 (while (not (file-exists-p dir))
3076 (setq dirs (cons dir dirs))
3077 (string-match "/[^/]+$" dir)
3078 (setq dir (substring dir 0 (match-beginning 0))))
3079 ;; Then create all the subdirs.
3080 (while (and dirs (not err))
3082 (make-directory (car dirs))
3083 (error (setq err t)))
3084 (setq dirs (cdr dirs)))
3085 ;; We return whether we were successful or not.
3088 (defun gnus-capitalize-newsgroup (newsgroup)
3089 "Capitalize NEWSGROUP name."
3090 (and (not (zerop (length newsgroup)))
3091 (concat (char-to-string (upcase (aref newsgroup 0)))
3092 (substring newsgroup 1))))
3094 ;; Various... things.
3096 (defun gnus-simplify-subject (subject &optional re-only)
3097 "Remove `Re:' and words in parentheses.
3098 If RE-ONLY is non-nil, strip leading `Re:'s only."
3099 (let ((case-fold-search t)) ;Ignore case.
3100 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
3101 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
3102 (setq subject (substring subject (match-end 0))))
3103 ;; Remove uninteresting prefixes.
3104 (if (and (not re-only)
3105 gnus-simplify-ignored-prefixes
3106 (string-match gnus-simplify-ignored-prefixes subject))
3107 (setq subject (substring subject (match-end 0))))
3108 ;; Remove words in parentheses from end.
3110 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
3111 (setq subject (substring subject 0 (match-beginning 0)))))
3112 ;; Return subject string.
3115 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
3117 ;; Written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
3118 (defun gnus-simplify-buffer-fuzzy ()
3119 (goto-char (point-min))
3120 (while (search-forward "\t" nil t)
3121 (replace-match " " t t))
3122 (goto-char (point-min))
3123 (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *" nil t)
3124 (goto-char (match-beginning 0))
3126 (looking-at "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
3127 (looking-at "^[[].*: .*[]]$"))
3128 (goto-char (point-min))
3129 (while (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *"
3131 (replace-match "" t t))
3132 (goto-char (point-min))
3133 (while (re-search-forward "^[[].*: .*[]]$" nil t)
3134 (goto-char (match-end 0))
3137 (progn (goto-char (match-beginning 0)))
3138 (re-search-forward ":"))))
3139 (goto-char (point-min))
3140 (while (re-search-forward " *[[{(][^()\n]*[]})] *$" nil t)
3141 (replace-match "" t t))
3142 (goto-char (point-min))
3143 (while (re-search-forward " +" nil t)
3144 (replace-match " " t t))
3145 (goto-char (point-min))
3146 (while (re-search-forward " $" nil t)
3147 (replace-match "" t t))
3148 (goto-char (point-min))
3149 (while (re-search-forward "^ +" nil t)
3150 (replace-match "" t t))
3151 (goto-char (point-min))
3152 (when gnus-simplify-subject-fuzzy-regexp
3153 (if (listp gnus-simplify-subject-fuzzy-regexp)
3154 (let ((list gnus-simplify-subject-fuzzy-regexp))
3156 (goto-char (point-min))
3157 (while (re-search-forward (car list) nil t)
3158 (replace-match "" t t))
3159 (setq list (cdr list))))
3160 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
3161 (replace-match "" t t)))))
3163 (defun gnus-simplify-subject-fuzzy (subject)
3164 "Siplify a subject string fuzzily."
3166 (gnus-set-work-buffer)
3167 (let ((case-fold-search t))
3169 (inline (gnus-simplify-buffer-fuzzy))
3172 ;; Add the current buffer to the list of buffers to be killed on exit.
3173 (defun gnus-add-current-to-buffer-list ()
3174 (or (memq (current-buffer) gnus-buffer-list)
3175 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list))))
3177 (defun gnus-string> (s1 s2)
3178 (not (or (string< s1 s2)
3181 (defun gnus-read-active-file-p ()
3182 "Say whether the active file has been read from `gnus-select-method'."
3183 (memq gnus-select-method gnus-have-read-active-file))
3185 ;;; General various misc type functions.
3187 (defun gnus-clear-system ()
3188 "Clear all variables and buffers."
3189 ;; Clear Gnus variables.
3190 (let ((variables gnus-variable-list))
3192 (set (car variables) nil)
3193 (setq variables (cdr variables))))
3194 ;; Clear other internal variables.
3195 (setq gnus-list-of-killed-groups nil
3196 gnus-have-read-active-file nil
3197 gnus-newsrc-alist nil
3198 gnus-newsrc-hashtb nil
3199 gnus-killed-list nil
3200 gnus-zombie-list nil
3201 gnus-killed-hashtb nil
3202 gnus-active-hashtb nil
3203 gnus-moderated-list nil
3204 gnus-description-hashtb nil
3205 gnus-current-headers nil
3206 gnus-thread-indent-array nil
3207 gnus-newsgroup-headers nil
3208 gnus-newsgroup-name nil
3209 gnus-server-alist nil
3210 gnus-group-list-mode nil
3211 gnus-opened-servers nil
3212 gnus-current-select-method nil)
3213 (gnus-shutdown 'gnus)
3214 ;; Kill the startup file.
3215 (and gnus-current-startup-file
3216 (get-file-buffer gnus-current-startup-file)
3217 (kill-buffer (get-file-buffer gnus-current-startup-file)))
3218 ;; Clear the dribble buffer.
3219 (gnus-dribble-clear)
3220 ;; Kill global KILL file buffer.
3221 (when (get-file-buffer (gnus-newsgroup-kill-file nil))
3222 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
3223 (gnus-kill-buffer nntp-server-buffer)
3224 ;; Kill Gnus buffers.
3225 (while gnus-buffer-list
3226 (gnus-kill-buffer (pop gnus-buffer-list)))
3227 ;; Remove Gnus frames.
3228 (while gnus-created-frames
3229 (when (frame-live-p (car gnus-created-frames))
3230 ;; We slap a condition-case around this `delete-frame' to ensure
3231 ;; agains errors if we try do delete the single frame that's left.
3233 (delete-frame (car gnus-created-frames))
3235 (pop gnus-created-frames)))
3237 (defun gnus-windows-old-to-new (setting)
3238 ;; First we take care of the really, really old Gnus 3 actions.
3239 (when (symbolp setting)
3241 ;; Take care of ooold GNUS 3.x values.
3242 (cond ((eq setting 'SelectArticle) 'article)
3243 ((memq setting '(SelectSubject ExpandSubject)) 'summary)
3244 ((memq setting '(SelectNewsgroup ExitNewsgroup)) 'group)
3246 (if (or (listp setting)
3247 (not (and gnus-window-configuration
3248 (memq setting '(group summary article)))))
3250 (let* ((setting (if (eq setting 'group)
3251 (if (assq 'newsgroup gnus-window-configuration)
3253 'newsgroups) setting))
3254 (elem (cadr (assq setting gnus-window-configuration)))
3255 (total (apply '+ elem))
3256 (types '(group summary article))
3257 (pbuf (if (eq setting 'newsgroups) 'group 'summary))
3262 (or (not (numberp (nth i elem)))
3263 (zerop (nth i elem))
3265 (setq perc (/ (float (nth 0 elem)) total))
3266 (setq out (cons (if (eq pbuf (nth i types))
3267 (vector (nth i types) perc 'point)
3268 (vector (nth i types) perc))
3271 (list (nreverse out)))))
3274 (defun gnus-add-configuration (conf)
3275 "Add the window configuration CONF to `gnus-buffer-configuration'."
3276 (setq gnus-buffer-configuration
3277 (cons conf (delq (assq (car conf) gnus-buffer-configuration)
3278 gnus-buffer-configuration))))
3280 (defvar gnus-frame-list nil)
3282 (defun gnus-configure-frame (split &optional window)
3283 "Split WINDOW according to SPLIT."
3285 (setq window (get-buffer-window (current-buffer))))
3286 (select-window window)
3287 ;; This might be an old-stylee buffer config.
3288 (when (vectorp split)
3289 (setq split (append split nil)))
3290 (when (or (consp (car split))
3291 (vectorp (car split)))
3293 (push 'vertical split))
3294 ;; The SPLIT might be something that is to be evaled to
3295 ;; return a new SPLIT.
3296 (while (and (not (assq (car split) gnus-window-to-buffer))
3297 (gnus-functionp (car split)))
3298 (setq split (eval split)))
3299 (let* ((type (car split))
3301 (len (if (eq type 'horizontal) (window-width) (window-height)))
3303 (window-min-width (or gnus-window-min-width window-min-width))
3304 (window-min-height (or gnus-window-min-height window-min-height))
3305 s result new-win rest comp-subs size sub)
3307 ;; Nothing to do here.
3309 ;; Don't switch buffers.
3311 (and (memq 'point split) window))
3312 ;; This is a buffer to be selected.
3313 ((not (memq type '(frame horizontal vertical)))
3314 (let ((buffer (cond ((stringp type) type)
3315 (t (cdr (assq type gnus-window-to-buffer)))))
3318 (error "Illegal buffer type: %s" type))
3319 (unless (setq buf (get-buffer (if (symbolp buffer)
3320 (symbol-value buffer) buffer)))
3321 (setq buf (get-buffer-create (if (symbolp buffer)
3322 (symbol-value buffer) buffer))))
3323 (switch-to-buffer buf)
3324 ;; We return the window if it has the `point' spec.
3325 (and (memq 'point split) window)))
3326 ;; This is a frame split.
3328 (unless gnus-frame-list
3329 (setq gnus-frame-list (list (window-frame
3330 (get-buffer-window (current-buffer))))))
3332 params frame fresult)
3333 (while (< i (length subs))
3334 ;; Frame parameter is gotten from the sub-split.
3335 (setq params (cadr (elt subs i)))
3336 ;; It should be a list.
3337 (unless (listp params)
3339 ;; Create a new frame?
3340 (unless (setq frame (elt gnus-frame-list i))
3341 (nconc gnus-frame-list (list (setq frame (make-frame params))))
3342 (push frame gnus-created-frames))
3343 ;; Is the old frame still alive?
3344 (unless (frame-live-p frame)
3345 (setcar (nthcdr i gnus-frame-list)
3346 (setq frame (make-frame params))))
3347 ;; Select the frame in question and do more splits there.
3348 (select-frame frame)
3349 (setq fresult (or (gnus-configure-frame (elt subs i)) fresult))
3351 ;; Select the frame that has the selected buffer.
3353 (select-frame (window-frame fresult)))))
3354 ;; This is a normal split.
3356 (when (> (length subs) 0)
3357 ;; First we have to compute the sizes of all new windows.
3359 (setq sub (append (pop subs) nil))
3360 (while (and (not (assq (car sub) gnus-window-to-buffer))
3361 (gnus-functionp (car sub)))
3362 (setq sub (eval sub)))
3364 (push sub comp-subs)
3365 (setq size (cadar comp-subs))
3366 (cond ((equal size 1.0)
3367 (setq rest (car comp-subs))
3370 (setq s (floor (* size len))))
3374 (error "Illegal size: %s" size)))
3375 ;; Try to make sure that we are inside the safe limits.
3377 ((eq type 'horizontal)
3378 (setq s (max s window-min-width)))
3379 ((eq type 'vertical)
3380 (setq s (max s window-min-height))))
3381 (setcar (cdar comp-subs) s)
3383 ;; Take care of the "1.0" spec.
3385 (setcar (cdr rest) (- len total))
3386 (error "No 1.0 specs in %s" split))
3387 ;; The we do the actual splitting in a nice recursive
3389 (setq comp-subs (nreverse comp-subs))
3391 (if (null (cdr comp-subs))
3392 (setq new-win window)
3394 (split-window window (cadar comp-subs)
3395 (eq type 'horizontal))))
3396 (setq result (or (gnus-configure-frame
3397 (car comp-subs) window) result))
3398 (select-window new-win)
3399 (setq window new-win)
3400 (setq comp-subs (cdr comp-subs))))
3401 ;; Return the proper window, if any.
3403 (select-window result))))))
3405 (defvar gnus-frame-split-p nil)
3407 (defun gnus-configure-windows (setting &optional force)
3408 (setq setting (gnus-windows-old-to-new setting))
3409 (let ((split (if (symbolp setting)
3410 (cadr (assq setting gnus-buffer-configuration))
3414 (setq gnus-frame-split-p nil)
3417 (error "No such setting: %s" setting))
3419 (if (and (setq all-visible (gnus-all-windows-visible-p split))
3421 ;; All the windows mentioned are already visible, so we just
3422 ;; put point in the assigned buffer, and do not touch the
3424 (select-window all-visible)
3426 ;; Either remove all windows or just remove all Gnus windows.
3427 (let ((frame (selected-frame)))
3429 (if gnus-use-full-window
3430 ;; We want to remove all other windows.
3431 (if (not gnus-frame-split-p)
3432 ;; This is not a `frame' split, so we ignore the
3434 (delete-other-windows)
3435 ;; This is a `frame' split, so we delete all windows
3439 (unless (eq (cdr (assq 'minibuffer
3440 (frame-parameters frame)))
3442 (select-frame frame)
3443 (delete-other-windows)))
3445 ;; Just remove some windows.
3446 (gnus-remove-some-windows)
3447 (switch-to-buffer nntp-server-buffer))
3448 (select-frame frame)))
3450 (switch-to-buffer nntp-server-buffer)
3451 (gnus-configure-frame split (get-buffer-window (current-buffer))))))
3453 (defun gnus-all-windows-visible-p (split)
3454 "Say whether all buffers in SPLIT are currently visible.
3455 In particular, the value returned will be the window that
3457 (let ((stack (list split))
3459 type buffer win buf)
3460 (while (and (setq split (pop stack))
3462 ;; Be backwards compatible.
3463 (when (vectorp split)
3464 (setq split (append split nil)))
3465 (when (or (consp (car split))
3466 (vectorp (car split)))
3468 (push 'vertical split))
3469 ;; The SPLIT might be something that is to be evaled to
3470 ;; return a new SPLIT.
3471 (while (and (not (assq (car split) gnus-window-to-buffer))
3472 (gnus-functionp (car split)))
3473 (setq split (eval split)))
3475 (setq type (elt split 0))
3480 ((not (memq type '(horizontal vertical frame)))
3481 (setq buffer (cond ((stringp type) type)
3482 (t (cdr (assq type gnus-window-to-buffer)))))
3484 (error "Illegal buffer type: %s" type))
3485 (when (setq buf (get-buffer (if (symbolp buffer)
3486 (symbol-value buffer)
3488 (setq win (get-buffer-window buf t)))
3490 (when (memq 'point split)
3491 (setq all-visible win))
3492 (setq all-visible nil)))
3494 (when (eq type 'frame)
3495 (setq gnus-frame-split-p t))
3496 (setq stack (append (cddr split) stack)))))
3497 (unless (eq all-visible t)
3500 (defun gnus-window-top-edge (&optional window)
3501 (nth 1 (window-edges window)))
3503 (defun gnus-remove-some-windows ()
3504 (let ((buffers gnus-window-to-buffer)
3505 buf bufs lowest-buf lowest)
3507 ;; Remove windows on all known Gnus buffers.
3509 (setq buf (cdar buffers))
3511 (setq buf (and (boundp buf) (symbol-value buf))))
3513 (get-buffer-window buf)
3515 (setq bufs (cons buf bufs))
3517 (if (or (not lowest)
3518 (< (gnus-window-top-edge) lowest))
3520 (setq lowest (gnus-window-top-edge))
3521 (setq lowest-buf buf)))))
3522 (setq buffers (cdr buffers)))
3523 ;; Remove windows on *all* summary buffers.
3526 (let ((buf (window-buffer win)))
3527 (if (string-match "^\\*Summary" (buffer-name buf))
3529 (setq bufs (cons buf bufs))
3531 (if (or (not lowest)
3532 (< (gnus-window-top-edge) lowest))
3534 (setq lowest-buf buf)
3535 (setq lowest (gnus-window-top-edge)))))))))
3538 (pop-to-buffer lowest-buf)
3539 (switch-to-buffer nntp-server-buffer)))
3541 (and (not (eq (car bufs) lowest-buf))
3542 (delete-windows-on (car bufs)))
3543 (setq bufs (cdr bufs))))))
3545 (defun gnus-version (&optional arg)
3546 "Version number of this version of Gnus.
3547 If ARG, insert string at point."
3549 (let ((methods gnus-valid-select-methods)
3552 ;; Go through all the legal select methods and add their version
3553 ;; numbers to the total version string. Only the backends that are
3554 ;; currently in use will have their message numbers taken into
3557 (setq meth (intern (concat (caar methods) "-version")))
3559 (stringp (symbol-value meth))
3560 (setq mess (concat mess "; " (symbol-value meth))))
3561 (setq methods (cdr methods)))
3563 (insert (message mess))
3566 (defun gnus-info-find-node ()
3567 "Find Info documentation of Gnus."
3569 ;; Enlarge info window if needed.
3570 (let ((mode major-mode)
3572 (Info-goto-node (cadr (assq mode gnus-info-nodes)))
3573 (setq gnus-info-buffer (current-buffer))
3574 (gnus-configure-windows 'info)))
3576 (defun gnus-days-between (date1 date2)
3577 ;; Return the number of days between date1 and date2.
3578 (- (gnus-day-number date1) (gnus-day-number date2)))
3580 (defun gnus-day-number (date)
3581 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
3582 (timezone-parse-date date))))
3583 (timezone-absolute-from-gregorian
3584 (nth 1 dat) (nth 2 dat) (car dat))))
3586 (defun gnus-encode-date (date)
3587 "Convert DATE to internal time."
3588 (let* ((parse (timezone-parse-date date))
3589 (date (mapcar (lambda (d) (and d (string-to-int d))) parse))
3590 (time (mapcar 'string-to-int (timezone-parse-time (aref parse 3)))))
3591 (encode-time (caddr time) (cadr time) (car time)
3592 (caddr date) (cadr date) (car date) (nth 4 date))))
3594 (defun gnus-time-minus (t1 t2)
3595 "Subtract two internal times."
3596 (let ((borrow (< (cadr t1) (cadr t2))))
3597 (list (- (car t1) (car t2) (if borrow 1 0))
3598 (- (+ (if borrow 65536 0) (cadr t1)) (cadr t2)))))
3600 (defun gnus-file-newer-than (file date)
3601 (let ((fdate (nth 5 (file-attributes file))))
3602 (or (> (car fdate) (car date))
3603 (and (= (car fdate) (car date))
3604 (> (nth 1 fdate) (nth 1 date))))))
3606 (defmacro gnus-local-set-keys (&rest plist)
3607 "Set the keys in PLIST in the current keymap."
3608 `(gnus-define-keys-1 (current-local-map) ',plist))
3610 (defmacro gnus-define-keys (keymap &rest plist)
3611 "Define all keys in PLIST in KEYMAP."
3612 `(gnus-define-keys-1 (quote ,keymap) (quote ,plist)))
3614 (put 'gnus-define-keys 'lisp-indent-function 1)
3615 (put 'gnus-define-keys 'lisp-indent-hook 1)
3616 (put 'gnus-define-keymap 'lisp-indent-function 1)
3617 (put 'gnus-define-keymap 'lisp-indent-hook 1)
3619 (defmacro gnus-define-keymap (keymap &rest plist)
3620 "Define all keys in PLIST in KEYMAP."
3621 `(gnus-define-keys-1 ,keymap (quote ,plist)))
3623 (defun gnus-define-keys-1 (keymap plist)
3625 (error "Can't set keys in a null keymap"))
3626 (cond ((symbolp keymap)
3627 (setq keymap (symbol-value keymap)))
3630 (set (car keymap) nil)
3631 (define-prefix-command (car keymap))
3632 (define-key (symbol-value (caddr keymap)) (cadr keymap) (car keymap))
3633 (setq keymap (symbol-value (car keymap)))))
3636 (when (symbolp (setq key (pop plist)))
3637 (setq key (symbol-value key)))
3638 (define-key keymap key (pop plist)))))
3640 (defun gnus-group-read-only-p (&optional group)
3641 "Check whether GROUP supports editing or not.
3642 If GROUP is nil, `gnus-newsgroup-name' will be checked instead. Note
3643 that that variable is buffer-local to the summary buffers."
3644 (let ((group (or group gnus-newsgroup-name)))
3645 (not (gnus-check-backend-function 'request-replace-article group))))
3647 (defun gnus-group-total-expirable-p (group)
3648 "Check whether GROUP is total-expirable or not."
3649 (let ((params (gnus-info-params (gnus-get-info group))))
3650 (or (memq 'total-expire params)
3651 (cdr (assq 'total-expire params)) ; (total-expire . t)
3652 (and gnus-total-expirable-newsgroups ; Check var.
3653 (string-match gnus-total-expirable-newsgroups group)))))
3655 (defun gnus-group-auto-expirable-p (group)
3656 "Check whether GROUP is total-expirable or not."
3657 (let ((params (gnus-info-params (gnus-get-info group))))
3658 (or (memq 'auto-expire params)
3659 (cdr (assq 'auto-expire params)) ; (auto-expire . t)
3660 (and gnus-auto-expirable-newsgroups ; Check var.
3661 (string-match gnus-auto-expirable-newsgroups group)))))
3663 (defun gnus-virtual-group-p (group)
3664 "Say whether GROUP is virtual or not."
3665 (memq 'virtual (assoc (symbol-name (car (gnus-find-method-for-group group)))
3666 gnus-valid-select-methods)))
3668 (defun gnus-news-group-p (group &optional article)
3669 "Return non-nil if GROUP (and ARTICLE) come from a news server."
3670 (or (gnus-member-of-valid 'post group) ; Ordinary news group.
3671 (and (gnus-member-of-valid 'post-mail group) ; Combined group.
3672 (eq (gnus-request-type group article) 'news))))
3674 (defsubst gnus-simplify-subject-fully (subject)
3675 "Simplify a subject string according to the user's wishes."
3677 ((null gnus-summary-gather-subject-limit)
3678 (gnus-simplify-subject-re subject))
3679 ((eq gnus-summary-gather-subject-limit 'fuzzy)
3680 (gnus-simplify-subject-fuzzy subject))
3681 ((numberp gnus-summary-gather-subject-limit)
3682 (gnus-limit-string (gnus-simplify-subject-re subject)
3683 gnus-summary-gather-subject-limit))
3687 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
3688 "Check whether two subjects are equal. If optional argument
3689 simple-first is t, first argument is already simplified."
3691 ((null simple-first)
3692 (equal (gnus-simplify-subject-fully s1)
3693 (gnus-simplify-subject-fully s2)))
3696 (gnus-simplify-subject-fully s2)))))
3698 ;; Returns a list of writable groups.
3699 (defun gnus-writable-groups ()
3700 (let ((alist gnus-newsrc-alist)
3702 (while (setq group (car (pop alist)))
3703 (unless (gnus-group-read-only-p group)
3704 (push group groups)))
3707 (defun gnus-completing-read (default prompt &rest args)
3708 ;; Like `completing-read', except that DEFAULT is the default argument.
3709 (let* ((prompt (if default
3710 (concat prompt " (default " default ") ")
3711 (concat prompt " ")))
3712 (answer (apply 'completing-read prompt args)))
3713 (if (or (null answer) (zerop (length answer)))
3717 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
3719 (defun gnus-y-or-n-p (prompt)
3724 (defun gnus-yes-or-no-p (prompt)
3726 (yes-or-no-p prompt)
3729 ;; Check whether to use long file names.
3730 (defun gnus-use-long-file-name (symbol)
3731 ;; The variable has to be set...
3732 (and gnus-use-long-file-name
3733 ;; If it isn't a list, then we return t.
3734 (or (not (listp gnus-use-long-file-name))
3735 ;; If it is a list, and the list contains `symbol', we
3737 (not (memq symbol gnus-use-long-file-name)))))
3739 ;; I suspect there's a better way, but I haven't taken the time to do
3740 ;; it yet. -erik selberg@cs.washington.edu
3741 (defun gnus-dd-mmm (messy-date)
3742 "Return a string like DD-MMM from a big messy string"
3743 (let ((datevec (condition-case () (timezone-parse-date messy-date)
3749 ;; Make sure leading zeroes are stripped.
3750 (number-to-string (string-to-number (aref datevec 2)))
3754 (nth (1- (string-to-number (aref datevec 1)))
3755 timezone-months-assoc))
3758 (defun gnus-mode-string-quote (string)
3759 "Quote all \"%\" in STRING."
3761 (gnus-set-work-buffer)
3763 (goto-char (point-min))
3764 (while (search-forward "%" nil t)
3768 ;; Make a hash table (default and minimum size is 255).
3769 ;; Optional argument HASHSIZE specifies the table size.
3770 (defun gnus-make-hashtable (&optional hashsize)
3771 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0))
3773 ;; Make a number that is suitable for hashing; bigger than MIN and one
3775 (defun gnus-create-hash-size (min)
3781 ;; Show message if message has a lower level than `gnus-verbose'.
3782 ;; Guideline for numbers:
3783 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages
3784 ;; for things that take a long time, 7 - not very important messages
3785 ;; on stuff, 9 - messages inside loops.
3786 (defun gnus-message (level &rest args)
3787 (if (<= level gnus-verbose)
3788 (apply 'message args)
3789 ;; We have to do this format thingy here even if the result isn't
3790 ;; shown - the return value has to be the same as the return value
3792 (apply 'format args)))
3794 (defun gnus-error (level &rest args)
3795 "Beep an error if `gnus-verbose' is on LEVEL or less."
3796 (when (<= (floor level) gnus-verbose)
3797 (apply 'message args)
3800 (when (and (floatp level)
3801 (not (zerop (setq duration (* 10 (- level (floor level)))))))
3802 (sit-for duration))))
3805 ;; Generate a unique new group name.
3806 (defun gnus-generate-new-group-name (leaf)
3809 (while (gnus-gethash name gnus-newsrc-hashtb)
3810 (setq name (concat leaf "<" (int-to-string (setq num (1+ num))) ">")))
3813 (defsubst gnus-hide-text (b e props)
3814 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
3815 (gnus-add-text-properties b e props)
3816 (when (memq 'intangible props)
3817 (gnus-put-text-property (max (1- b) (point-min))
3818 b 'intangible (cddr (memq 'intangible props)))))
3820 (defsubst gnus-unhide-text (b e)
3821 "Remove hidden text properties from region between B and E."
3822 (remove-text-properties b e gnus-hidden-properties)
3823 (when (memq 'intangible gnus-hidden-properties)
3824 (gnus-put-text-property (max (1- b) (point-min))
3825 b 'intangible nil)))
3827 (defun gnus-hide-text-type (b e type)
3828 "Hide text of TYPE between B and E."
3829 (gnus-hide-text b e (cons 'gnus-type (cons type gnus-hidden-properties))))
3831 (defun gnus-parent-headers (headers &optional generation)
3832 "Return the headers of the GENERATIONeth parent of HEADERS."
3834 (setq generation 1))
3835 (let (references parent)
3836 (while (and headers (not (zerop generation)))
3837 (setq references (mail-header-references headers))
3838 (when (and references
3839 (setq parent (gnus-parent-id references))
3840 (setq headers (car (gnus-id-to-thread parent))))
3844 (defun gnus-parent-id (references)
3845 "Return the last Message-ID in REFERENCES."
3846 (when (and references
3847 (string-match "\\(<[^\n<>]+>\\)[ \t\n]*\\'" references))
3848 (substring references (match-beginning 1) (match-end 1))))
3850 (defun gnus-split-references (references)
3851 "Return a list of Message-IDs in REFERENCES."
3854 (while (string-match "<[^>]+>" references beg)
3855 (push (substring references (match-beginning 0) (setq beg (match-end 0)))
3859 (defun gnus-buffer-live-p (buffer)
3860 "Say whether BUFFER is alive or not."
3863 (buffer-name (get-buffer buffer))))
3865 (defun gnus-ephemeral-group-p (group)
3866 "Say whether GROUP is ephemeral or not."
3867 (gnus-group-get-parameter group 'quit-config))
3869 (defun gnus-group-quit-config (group)
3870 "Return the quit-config of GROUP."
3871 (gnus-group-get-parameter group 'quit-config))
3873 (defun gnus-simplify-mode-line ()
3874 "Make mode lines a bit simpler."
3875 (setq mode-line-modified "-- ")
3876 (when (listp mode-line-format)
3877 (make-local-variable 'mode-line-format)
3878 (setq mode-line-format (copy-sequence mode-line-format))
3879 (when (equal (nth 3 mode-line-format) " ")
3880 (setcar (nthcdr 3 mode-line-format) " "))))
3882 ;;; List and range functions
3884 (defun gnus-last-element (list)
3885 "Return last element of LIST."
3887 (setq list (cdr list)))
3890 (defun gnus-copy-sequence (list)
3891 "Do a complete, total copy of a list."
3892 (if (and (consp list) (not (consp (cdr list))))
3893 (cons (car list) (cdr list))
3894 (mapcar (lambda (elem) (if (consp elem)
3895 (if (consp (cdr elem))
3896 (gnus-copy-sequence elem)
3897 (cons (car elem) (cdr elem)))
3901 (defun gnus-set-difference (list1 list2)
3902 "Return a list of elements of LIST1 that do not appear in LIST2."
3903 (let ((list1 (copy-sequence list1)))
3905 (setq list1 (delq (car list2) list1))
3906 (setq list2 (cdr list2)))
3909 (defun gnus-sorted-complement (list1 list2)
3910 "Return a list of elements of LIST1 that do not appear in LIST2.
3911 Both lists have to be sorted over <."
3913 (if (or (null list1) (null list2))
3915 (while (and list1 list2)
3916 (cond ((= (car list1) (car list2))
3917 (setq list1 (cdr list1)
3919 ((< (car list1) (car list2))
3920 (setq out (cons (car list1) out))
3921 (setq list1 (cdr list1)))
3923 (setq out (cons (car list2) out))
3924 (setq list2 (cdr list2)))))
3925 (nconc (nreverse out) (or list1 list2)))))
3927 (defun gnus-intersection (list1 list2)
3930 (if (memq (car list2) list1)
3931 (setq result (cons (car list2) result)))
3932 (setq list2 (cdr list2)))
3935 (defun gnus-sorted-intersection (list1 list2)
3936 ;; LIST1 and LIST2 have to be sorted over <.
3938 (while (and list1 list2)
3939 (cond ((= (car list1) (car list2))
3940 (setq out (cons (car list1) out)
3943 ((< (car list1) (car list2))
3944 (setq list1 (cdr list1)))
3946 (setq list2 (cdr list2)))))
3949 (defun gnus-set-sorted-intersection (list1 list2)
3950 ;; LIST1 and LIST2 have to be sorted over <.
3951 ;; This function modifies LIST1.
3952 (let* ((top (cons nil list1))
3954 (while (and list1 list2)
3955 (cond ((= (car list1) (car list2))
3959 ((< (car list1) (car list2))
3960 (setcdr prev (cdr list1))
3961 (setq list1 (cdr list1)))
3963 (setq list2 (cdr list2)))))
3967 (defun gnus-compress-sequence (numbers &optional always-list)
3968 "Convert list of numbers to a list of ranges or a single range.
3969 If ALWAYS-LIST is non-nil, this function will always release a list of
3971 (let* ((first (car numbers))
3972 (last (car numbers))
3976 (if (not (listp (cdr numbers)))
3979 (cond ((= last (car numbers)) nil) ;Omit duplicated number
3980 ((= (1+ last) (car numbers)) ;Still in sequence
3981 (setq last (car numbers)))
3982 (t ;End of one sequence
3984 (cons (if (= first last) first
3985 (cons first last)) result))
3986 (setq first (car numbers))
3987 (setq last (car numbers))))
3988 (setq numbers (cdr numbers)))
3989 (if (and (not always-list) (null result))
3990 (if (= first last) (list first) (cons first last))
3991 (nreverse (cons (if (= first last) first (cons first last))
3994 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
3995 (defun gnus-uncompress-range (ranges)
3996 "Expand a list of ranges into a list of numbers.
3997 RANGES is either a single range on the form `(num . num)' or a list of
3999 (let (first last result)
4003 ((not (listp (cdr ranges)))
4004 (setq first (car ranges))
4005 (setq last (cdr ranges))
4006 (while (<= first last)
4007 (setq result (cons first result))
4008 (setq first (1+ first)))
4012 (if (atom (car ranges))
4013 (if (numberp (car ranges))
4014 (setq result (cons (car ranges) result)))
4015 (setq first (caar ranges))
4016 (setq last (cdar ranges))
4017 (while (<= first last)
4018 (setq result (cons first result))
4019 (setq first (1+ first))))
4020 (setq ranges (cdr ranges)))
4021 (nreverse result)))))
4023 (defun gnus-add-to-range (ranges list)
4024 "Return a list of ranges that has all articles from both RANGES and LIST.
4025 Note: LIST has to be sorted over `<'."
4027 (gnus-compress-sequence list t)
4028 (setq list (copy-sequence list))
4029 (or (listp (cdr ranges))
4030 (setq ranges (list ranges)))
4032 ilist lowest highest temp)
4033 (while (and ranges list)
4035 (setq lowest (or (and (atom (car ranges)) (car ranges))
4037 (while (and list (cdr list) (< (cadr list) lowest))
4038 (setq list (cdr list)))
4039 (if (< (car ilist) lowest)
4042 (setq list (cdr list))
4044 (setq out (nconc (gnus-compress-sequence ilist t) out))))
4045 (setq highest (or (and (atom (car ranges)) (car ranges))
4047 (while (and list (<= (car list) highest))
4048 (setq list (cdr list)))
4049 (setq ranges (cdr ranges)))
4051 (setq out (nconc (gnus-compress-sequence list t) out)))
4052 (setq out (sort out (lambda (r1 r2)
4053 (< (or (and (atom r1) r1) (car r1))
4054 (or (and (atom r2) r2) (car r2))))))
4057 (if (atom (car ranges))
4059 (if (atom (cadr ranges))
4060 (if (= (1+ (car ranges)) (cadr ranges))
4062 (setcar ranges (cons (car ranges)
4064 (setcdr ranges (cddr ranges))))
4065 (if (= (1+ (car ranges)) (caadr ranges))
4067 (setcar (cadr ranges) (car ranges))
4068 (setcar ranges (cadr ranges))
4069 (setcdr ranges (cddr ranges))))))
4071 (if (atom (cadr ranges))
4072 (if (= (1+ (cdar ranges)) (cadr ranges))
4074 (setcdr (car ranges) (cadr ranges))
4075 (setcdr ranges (cddr ranges))))
4076 (if (= (1+ (cdar ranges)) (caadr ranges))
4078 (setcdr (car ranges) (cdadr ranges))
4079 (setcdr ranges (cddr ranges)))))))
4080 (setq ranges (cdr ranges)))
4083 (defun gnus-remove-from-range (ranges list)
4084 "Return a list of ranges that has all articles from LIST removed from RANGES.
4085 Note: LIST has to be sorted over `<'."
4086 ;; !!! This function shouldn't look like this, but I've got a headache.
4087 (gnus-compress-sequence
4088 (gnus-sorted-complement
4089 (gnus-uncompress-range ranges) list)))
4091 (defun gnus-member-of-range (number ranges)
4092 (if (not (listp (cdr ranges)))
4093 (and (>= number (car ranges))
4094 (<= number (cdr ranges)))
4097 (if (numberp (car ranges))
4098 (>= number (car ranges))
4099 (>= number (caar ranges)))
4101 (if (if (numberp (car ranges))
4102 (= number (car ranges))
4103 (and (>= number (caar ranges))
4104 (<= number (cdar ranges))))
4105 (setq not-stop nil))
4106 (setq ranges (cdr ranges)))
4109 (defun gnus-range-length (range)
4110 "Return the length RANGE would have if uncompressed."
4111 (length (gnus-uncompress-range range)))
4113 (defun gnus-sublist-p (list sublist)
4114 "Test whether all elements in SUBLIST are members of LIST."
4117 (unless (memq (pop sublist) list)
4127 (defvar gnus-group-mode-map nil)
4128 (put 'gnus-group-mode 'mode-class 'special)
4130 (unless gnus-group-mode-map
4131 (setq gnus-group-mode-map (make-keymap))
4132 (suppress-keymap gnus-group-mode-map)
4134 (gnus-define-keys gnus-group-mode-map
4135 " " gnus-group-read-group
4136 "=" gnus-group-select-group
4137 "\r" gnus-group-select-group
4138 "\M-\r" gnus-group-quick-select-group
4139 "j" gnus-group-jump-to-group
4140 "n" gnus-group-next-unread-group
4141 "p" gnus-group-prev-unread-group
4142 "\177" gnus-group-prev-unread-group
4143 [delete] gnus-group-prev-unread-group
4144 "N" gnus-group-next-group
4145 "P" gnus-group-prev-group
4146 "\M-n" gnus-group-next-unread-group-same-level
4147 "\M-p" gnus-group-prev-unread-group-same-level
4148 "," gnus-group-best-unread-group
4149 "." gnus-group-first-unread-group
4150 "u" gnus-group-unsubscribe-current-group
4151 "U" gnus-group-unsubscribe-group
4152 "c" gnus-group-catchup-current
4153 "C" gnus-group-catchup-current-all
4154 "l" gnus-group-list-groups
4155 "L" gnus-group-list-all-groups
4157 "g" gnus-group-get-new-news
4158 "\M-g" gnus-group-get-new-news-this-group
4159 "R" gnus-group-restart
4160 "r" gnus-group-read-init-file
4161 "B" gnus-group-browse-foreign-server
4162 "b" gnus-group-check-bogus-groups
4163 "F" gnus-find-new-newsgroups
4164 "\C-c\C-d" gnus-group-describe-group
4165 "\M-d" gnus-group-describe-all-groups
4166 "\C-c\C-a" gnus-group-apropos
4167 "\C-c\M-\C-a" gnus-group-description-apropos
4168 "a" gnus-group-post-news
4169 "\ek" gnus-group-edit-local-kill
4170 "\eK" gnus-group-edit-global-kill
4171 "\C-k" gnus-group-kill-group
4172 "\C-y" gnus-group-yank-group
4173 "\C-w" gnus-group-kill-region
4174 "\C-x\C-t" gnus-group-transpose-groups
4175 "\C-c\C-l" gnus-group-list-killed
4176 "\C-c\C-x" gnus-group-expire-articles
4177 "\C-c\M-\C-x" gnus-group-expire-all-groups
4179 "s" gnus-group-save-newsrc
4180 "z" gnus-group-suspend
4181 "Z" gnus-group-clear-dribble
4184 "?" gnus-group-describe-briefly
4185 "\C-c\C-i" gnus-info-find-node
4186 "\M-e" gnus-group-edit-group-method
4187 "^" gnus-group-enter-server-mode
4188 gnus-mouse-2 gnus-mouse-pick-group
4189 "<" beginning-of-buffer
4192 "\C-c\C-s" gnus-group-sort-groups
4194 "\C-c\M-g" gnus-activate-all-groups
4195 "\M-&" gnus-group-universal-argument
4196 "#" gnus-group-mark-group
4197 "\M-#" gnus-group-unmark-group)
4199 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
4200 "m" gnus-group-mark-group
4201 "u" gnus-group-unmark-group
4202 "w" gnus-group-mark-region
4203 "m" gnus-group-mark-buffer
4204 "r" gnus-group-mark-regexp
4205 "U" gnus-group-unmark-all-groups)
4207 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
4208 "d" gnus-group-make-directory-group
4209 "h" gnus-group-make-help-group
4210 "a" gnus-group-make-archive-group
4211 "k" gnus-group-make-kiboze-group
4212 "m" gnus-group-make-group
4213 "E" gnus-group-edit-group
4214 "e" gnus-group-edit-group-method
4215 "p" gnus-group-edit-group-parameters
4216 "v" gnus-group-add-to-virtual
4217 "V" gnus-group-make-empty-virtual
4218 "D" gnus-group-enter-directory
4219 "f" gnus-group-make-doc-group
4220 "r" gnus-group-rename-group
4221 "\177" gnus-group-delete-group
4222 [delete] gnus-group-delete-group)
4224 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
4225 "b" gnus-group-brew-soup
4226 "w" gnus-soup-save-areas
4227 "s" gnus-soup-send-replies
4228 "p" gnus-soup-pack-packet
4229 "r" nnsoup-pack-replies)
4231 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
4232 "s" gnus-group-sort-groups
4233 "a" gnus-group-sort-groups-by-alphabet
4234 "u" gnus-group-sort-groups-by-unread
4235 "l" gnus-group-sort-groups-by-level
4236 "v" gnus-group-sort-groups-by-score
4237 "r" gnus-group-sort-groups-by-rank
4238 "m" gnus-group-sort-groups-by-method)
4240 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
4241 "k" gnus-group-list-killed
4242 "z" gnus-group-list-zombies
4243 "s" gnus-group-list-groups
4244 "u" gnus-group-list-all-groups
4245 "A" gnus-group-list-active
4246 "a" gnus-group-apropos
4247 "d" gnus-group-description-apropos
4248 "m" gnus-group-list-matching
4249 "M" gnus-group-list-all-matching
4250 "l" gnus-group-list-level)
4252 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
4253 "f" gnus-score-flush-cache)
4255 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
4256 "f" gnus-group-fetch-faq)
4258 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
4259 "l" gnus-group-set-current-level
4260 "t" gnus-group-unsubscribe-current-group
4261 "s" gnus-group-unsubscribe-group
4262 "k" gnus-group-kill-group
4263 "y" gnus-group-yank-group
4264 "w" gnus-group-kill-region
4265 "\C-k" gnus-group-kill-level
4266 "z" gnus-group-kill-all-zombies))
4268 (defun gnus-group-mode ()
4269 "Major mode for reading news.
4271 All normal editing commands are switched off.
4272 \\<gnus-group-mode-map>
4273 The group buffer lists (some of) the groups available. For instance,
4274 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
4275 lists all zombie groups.
4277 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
4278 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
4280 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
4282 The following commands are available:
4284 \\{gnus-group-mode-map}"
4286 (when (and menu-bar-mode
4287 (gnus-visual-p 'group-menu 'menu))
4288 (gnus-group-make-menu-bar))
4289 (kill-all-local-variables)
4290 (gnus-simplify-mode-line)
4291 (setq major-mode 'gnus-group-mode)
4292 (setq mode-name "Group")
4293 (gnus-group-set-mode-line)
4294 (setq mode-line-process nil)
4295 (use-local-map gnus-group-mode-map)
4296 (buffer-disable-undo (current-buffer))
4297 (setq truncate-lines t)
4298 (setq buffer-read-only t)
4299 (gnus-make-local-hook 'post-command-hook)
4300 (gnus-add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
4301 (run-hooks 'gnus-group-mode-hook))
4303 (defun gnus-clear-inboxes-moved ()
4304 (setq nnmail-moved-inboxes nil))
4306 (defun gnus-mouse-pick-group (e)
4307 "Enter the group under the mouse pointer."
4310 (gnus-group-read-group nil))
4312 ;; Look at LEVEL and find out what the level is really supposed to be.
4313 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
4314 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
4315 (defun gnus-group-default-level (&optional level number-or-nil)
4317 (gnus-group-use-permanent-levels
4318 (or (setq gnus-group-use-permanent-levels
4319 (or level (if (numberp gnus-group-use-permanent-levels)
4320 gnus-group-use-permanent-levels
4321 (or gnus-group-default-list-level
4322 gnus-level-subscribed))))
4323 gnus-group-default-list-level gnus-level-subscribed))
4327 (or level gnus-group-default-list-level gnus-level-subscribed))))
4330 (defun gnus-slave-no-server (&optional arg)
4331 "Read network news as a slave, without connecting to local server"
4333 (gnus-no-server arg t))
4336 (defun gnus-no-server (&optional arg slave)
4338 If ARG is a positive number, Gnus will use that as the
4339 startup level. If ARG is nil, Gnus will be started at level 2.
4340 If ARG is non-nil and not a positive number, Gnus will
4341 prompt the user for the name of an NNTP server to use.
4342 As opposed to `gnus', this command will not connect to the local server."
4344 (let ((val (or arg (1- gnus-level-default-subscribed))))
4346 (make-local-variable 'gnus-group-use-permanent-levels)
4347 (setq gnus-group-use-permanent-levels val)))
4350 (defun gnus-slave (&optional arg)
4351 "Read news as a slave."
4353 (gnus arg nil 'slave))
4356 (defun gnus-other-frame (&optional arg)
4357 "Pop up a frame to read news."
4359 (if (get-buffer gnus-group-buffer)
4360 (let ((pop-up-frames t))
4362 (select-frame (make-frame))
4366 (defun gnus (&optional arg dont-connect slave)
4368 If ARG is non-nil and a positive number, Gnus will use that as the
4369 startup level. If ARG is non-nil and not a positive number, Gnus will
4370 prompt the user for the name of an NNTP server to use."
4373 (if (get-buffer gnus-group-buffer)
4375 (switch-to-buffer gnus-group-buffer)
4376 (gnus-group-get-new-news))
4379 (nnheader-init-server-buffer)
4380 (gnus-read-init-file)
4381 (setq gnus-slave slave)
4383 (gnus-group-setup-buffer)
4384 (let ((buffer-read-only nil))
4386 (if (not gnus-inhibit-startup-message)
4388 (gnus-group-startup-message)
4391 (let ((level (and (numberp arg) (> arg 0) arg))
4397 (gnus-start-news-server (and arg (not level))))))
4398 (if (and (not dont-connect)
4401 (run-hooks 'gnus-startup-hook)
4402 ;; NNTP server is successfully open.
4404 ;; Find the current startup file name.
4405 (setq gnus-current-startup-file
4406 (gnus-make-newsrc-file gnus-startup-file))
4408 ;; Read the dribble file.
4409 (when (or gnus-slave gnus-use-dribble-file)
4410 (gnus-dribble-read-file))
4412 ;; Allow using GroupLens predictions.
4413 (when gnus-use-grouplens
4415 (add-hook 'gnus-summary-mode-hook 'gnus-grouplens-mode))
4417 (gnus-summary-make-display-table)
4418 ;; Do the actual startup.
4419 (gnus-setup-news nil level dont-connect)
4420 ;; Generate the group buffer.
4421 (gnus-group-list-groups level)
4422 (gnus-group-first-unread-group)
4423 (gnus-configure-windows 'group)
4424 (gnus-group-set-mode-line))))))
4426 (defun gnus-unload ()
4427 "Unload all Gnus features."
4429 (or (boundp 'load-history)
4430 (error "Sorry, `gnus-unload' is not implemented in this Emacs version."))
4431 (let ((history load-history)
4434 (and (string-match "^\\(gnus\\|nn\\)" (caar history))
4435 (setq feature (cdr (assq 'provide (car history))))
4436 (unload-feature feature 'force))
4437 (setq history (cdr history)))))
4439 (defun gnus-compile ()
4440 "Byte-compile the user-defined format specs."
4442 (let ((entries gnus-format-specs)
4443 entry gnus-tmp-func)
4445 (gnus-message 7 "Compiling format specs...")
4448 (setq entry (pop entries))
4449 (if (eq (car entry) 'version)
4450 (setq gnus-format-specs (delq entry gnus-format-specs))
4451 (when (and (listp (caddr entry))
4452 (not (eq 'byte-code (caaddr entry))))
4453 (fset 'gnus-tmp-func
4454 `(lambda () ,(caddr entry)))
4455 (byte-compile 'gnus-tmp-func)
4456 (setcar (cddr entry) (gnus-byte-code 'gnus-tmp-func)))))
4458 (push (cons 'version emacs-version) gnus-format-specs)
4460 (gnus-message 7 "Compiling user specs...done"))))
4462 (defun gnus-indent-rigidly (start end arg)
4463 "Indent rigidly using only spaces and no tabs."
4466 (narrow-to-region start end)
4467 (indent-rigidly start end arg)
4468 (goto-char (point-min))
4469 (while (search-forward "\t" nil t)
4470 (replace-match " " t t)))))
4472 (defun gnus-group-startup-message (&optional x y)
4473 "Insert startup message in current buffer."
4474 ;; Insert the message.
4479 _ ___ __ ___ __ _ ___
4498 ;; And then hack it.
4499 (gnus-indent-rigidly (point-min) (point-max)
4500 (/ (max (- (window-width) (or x 46)) 0) 2))
4501 (goto-char (point-min))
4503 (let* ((pheight (count-lines (point-min) (point-max)))
4504 (wheight (window-height))
4505 (rest (- wheight pheight)))
4506 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
4508 (goto-char (point-min))
4509 (and (search-forward "Praxis" nil t)
4510 (gnus-put-text-property (match-beginning 0) (match-end 0) 'face 'bold))
4511 (goto-char (point-min))
4512 (let* ((mode-string (gnus-group-set-mode-line)))
4513 (setq mode-line-buffer-identification
4514 (list (concat gnus-version (substring (car mode-string) 4))))
4515 (set-buffer-modified-p t)))
4517 (defun gnus-group-setup-buffer ()
4518 (or (get-buffer gnus-group-buffer)
4520 (switch-to-buffer gnus-group-buffer)
4521 (gnus-add-current-to-buffer-list)
4523 (and gnus-carpal (gnus-carpal-setup-buffer 'group)))))
4525 (defun gnus-group-list-groups (&optional level unread lowest)
4526 "List newsgroups with level LEVEL or lower that have unread articles.
4527 Default is all subscribed groups.
4528 If argument UNREAD is non-nil, groups with no unread articles are also
4530 (interactive (list (if current-prefix-arg
4531 (prefix-numeric-value current-prefix-arg)
4533 (gnus-group-default-level nil t)
4534 gnus-group-default-list-level
4535 gnus-level-subscribed))))
4537 (setq level (car gnus-group-list-mode)
4538 unread (cdr gnus-group-list-mode)))
4539 (setq level (gnus-group-default-level level))
4540 (gnus-group-setup-buffer) ;May call from out of group buffer
4541 (gnus-update-format-specifications)
4542 (let ((case-fold-search nil)
4543 (props (text-properties-at (gnus-point-at-bol)))
4544 (group (gnus-group-group-name)))
4545 (set-buffer gnus-group-buffer)
4546 (funcall gnus-group-prepare-function level unread lowest)
4547 (if (zerop (buffer-size))
4548 (gnus-message 5 gnus-no-groups-message)
4549 (goto-char (point-max))
4550 (when (or (not gnus-group-goto-next-group-function)
4551 (not (funcall gnus-group-goto-next-group-function
4554 ;; Go to the first group with unread articles.
4555 (gnus-group-search-forward t)
4556 ;; Find the right group to put point on. If the current group
4557 ;; has disappeared in the new listing, try to find the next
4558 ;; one. If no next one can be found, just leave point at the
4559 ;; first newsgroup in the buffer.
4560 (if (not (gnus-goto-char
4562 (point-min) (point-max)
4563 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
4564 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
4566 (not (gnus-goto-char
4568 (point-min) (point-max) 'gnus-group
4570 (caar newsrc) gnus-active-hashtb)))))
4571 (setq newsrc (cdr newsrc)))
4572 (or newsrc (progn (goto-char (point-max))
4573 (forward-line -1)))))))
4574 ;; Adjust cursor point.
4575 (gnus-group-position-point))))
4577 (defun gnus-group-list-level (level &optional all)
4578 "List groups on LEVEL.
4579 If ALL (the prefix), also list groups that have no unread articles."
4580 (interactive "nList groups on level: \nP")
4581 (gnus-group-list-groups level all level))
4583 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
4584 "List all newsgroups with unread articles of level LEVEL or lower.
4585 If ALL is non-nil, list groups that have no unread articles.
4586 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
4587 If REGEXP, only list groups matching REGEXP."
4588 (set-buffer gnus-group-buffer)
4589 (let ((buffer-read-only nil)
4590 (newsrc (cdr gnus-newsrc-alist))
4591 (lowest (or lowest 1))
4592 info clevel unread group params)
4594 (if (< lowest gnus-level-zombie)
4595 ;; List living groups.
4597 (setq info (car newsrc)
4598 group (gnus-info-group info)
4599 params (gnus-info-params info)
4601 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
4602 (and unread ; This group might be bogus
4604 (string-match regexp group))
4605 (<= (setq clevel (gnus-info-level info)) level)
4607 (or all ; We list all groups?
4608 (if (eq unread t) ; Unactivated?
4609 gnus-group-list-inactive-groups ; We list unactivated
4610 (> unread 0)) ; We list groups with unread articles
4611 (and gnus-list-groups-with-ticked-articles
4612 (cdr (assq 'tick (gnus-info-marks info))))
4613 ; And groups with tickeds
4614 ;; Check for permanent visibility.
4615 (and gnus-permanently-visible-groups
4616 (string-match gnus-permanently-visible-groups
4618 (memq 'visible params)
4619 (cdr (assq 'visible params)))
4620 (gnus-group-insert-group-line
4621 group (gnus-info-level info)
4622 (gnus-info-marks info) unread (gnus-info-method info)))))
4624 ;; List dead groups.
4625 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
4626 (gnus-group-prepare-flat-list-dead
4627 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
4628 gnus-level-zombie ?Z
4630 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
4631 (gnus-group-prepare-flat-list-dead
4632 (setq gnus-killed-list (sort gnus-killed-list 'string<))
4633 gnus-level-killed ?K regexp))
4635 (gnus-group-set-mode-line)
4636 (setq gnus-group-list-mode (cons level all))
4637 (run-hooks 'gnus-group-prepare-hook)))
4639 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
4640 ;; List zombies and killed lists somewhat faster, which was
4641 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
4642 ;; this by ignoring the group format specification altogether.
4645 ;; This loop is used when listing groups that match some
4648 (setq group (pop groups))
4649 (when (string-match regexp group)
4650 (gnus-add-text-properties
4651 (point) (prog1 (1+ (point))
4652 (insert " " mark " *: " group "\n"))
4653 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4655 'gnus-level level))))
4656 ;; This loop is used when listing all groups.
4658 (gnus-add-text-properties
4659 (point) (prog1 (1+ (point))
4660 (insert " " mark " *: "
4661 (setq group (pop groups)) "\n"))
4662 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4664 'gnus-level level))))))
4666 (defmacro gnus-group-real-name (group)
4667 "Find the real name of a foreign newsgroup."
4668 `(let ((gname ,group))
4669 (if (string-match ":[^:]+$" gname)
4670 (substring gname (1+ (match-beginning 0)))
4673 (defsubst gnus-server-add-address (method)
4674 (let ((method-name (symbol-name (car method))))
4675 (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
4676 (not (assq (intern (concat method-name "-address")) method)))
4677 (append method (list (list (intern (concat method-name "-address"))
4681 (defsubst gnus-server-get-method (group method)
4682 ;; Input either a server name, and extended server name, or a
4683 ;; select method, and return a select method.
4684 (cond ((stringp method)
4685 (gnus-server-to-method method))
4686 ((equal method gnus-select-method)
4688 ((and (stringp (car method)) group)
4689 (gnus-server-extend-method group method))
4690 ((and method (not group)
4691 (equal (cadr method) ""))
4694 (gnus-server-add-address method))))
4696 (defun gnus-server-to-method (server)
4697 "Map virtual server names to select methods."
4699 ;; Is this a method, perhaps?
4700 (and server (listp server) server)
4701 ;; Perhaps this is the native server?
4702 (and (equal server "native") gnus-select-method)
4703 ;; It should be in the server alist.
4704 (cdr (assoc server gnus-server-alist))
4705 ;; If not, we look through all the opened server
4706 ;; to see whether we can find it there.
4707 (let ((opened gnus-opened-servers))
4709 (not (equal server (format "%s:%s" (caaar opened)
4714 (defmacro gnus-method-equal (ss1 ss2)
4715 "Say whether two servers are equal."
4719 (and (= (length s1) (length s2))
4721 (while (and s1 (member (car s1) s2))
4725 (defun gnus-server-equal (m1 m2)
4726 "Say whether two methods are equal."
4727 (let ((m1 (cond ((null m1) gnus-select-method)
4728 ((stringp m1) (gnus-server-to-method m1))
4730 (m2 (cond ((null m2) gnus-select-method)
4731 ((stringp m2) (gnus-server-to-method m2))
4733 (gnus-method-equal m1 m2)))
4735 (defun gnus-servers-using-backend (backend)
4736 "Return a list of known servers using BACKEND."
4737 (let ((opened gnus-opened-servers)
4740 (when (eq backend (caaar opened))
4741 (push (caar opened) out))
4745 (defun gnus-group-prefixed-name (group method)
4746 "Return the whole name from GROUP and METHOD."
4747 (and (stringp method) (setq method (gnus-server-to-method method)))
4748 (concat (format "%s" (car method))
4750 (or (assoc (format "%s" (car method))
4751 (gnus-methods-using 'address))
4752 (gnus-server-equal method gnus-message-archive-method))
4754 (not (string= (nth 1 method) "")))
4755 (concat "+" (nth 1 method)))
4758 (defun gnus-group-real-prefix (group)
4759 "Return the prefix of the current group name."
4760 (if (string-match "^[^:]+:" group)
4761 (substring group 0 (match-end 0))
4764 (defun gnus-group-method (group)
4765 "Return the server or method used for selecting GROUP."
4766 (let ((prefix (gnus-group-real-prefix group)))
4767 (if (equal prefix "")
4769 (let ((servers gnus-opened-servers)
4771 backend possible found)
4772 (if (string-match "^[^\\+]+\\+" prefix)
4773 (setq backend (intern (substring prefix 0 (1- (match-end 0))))
4774 server (substring prefix (match-end 0) (1- (length prefix))))
4775 (setq backend (intern (substring prefix 0 (1- (length prefix))))))
4777 (when (eq (caaar servers) backend)
4778 (setq possible (caar servers))
4779 (when (equal (cadaar servers) server)
4780 (setq found (caar servers))))
4782 (or (car (rassoc found gnus-server-alist))
4784 (car (rassoc possible gnus-server-alist))
4786 (list backend server))))))
4788 (defsubst gnus-secondary-method-p (method)
4789 "Return whether METHOD is a secondary select method."
4790 (let ((methods gnus-secondary-select-methods)
4791 (gmethod (gnus-server-get-method nil method)))
4793 (not (equal (gnus-server-get-method nil (car methods))
4795 (setq methods (cdr methods)))
4798 (defun gnus-group-foreign-p (group)
4799 "Say whether a group is foreign or not."
4800 (and (not (gnus-group-native-p group))
4801 (not (gnus-group-secondary-p group))))
4803 (defun gnus-group-native-p (group)
4804 "Say whether the group is native or not."
4805 (not (string-match ":" group)))
4807 (defun gnus-group-secondary-p (group)
4808 "Say whether the group is secondary or not."
4809 (gnus-secondary-method-p (gnus-find-method-for-group group)))
4811 (defun gnus-group-get-parameter (group &optional symbol)
4812 "Returns the group parameters for GROUP.
4813 If SYMBOL, return the value of that symbol in the group parameters."
4814 (let ((params (gnus-info-params (gnus-get-info group))))
4816 (gnus-group-parameter-value params symbol)
4819 (defun gnus-group-parameter-value (params symbol)
4820 "Return the value of SYMBOL in group PARAMS."
4821 (or (car (memq symbol params)) ; It's either a simple symbol
4822 (cdr (assq symbol params)))) ; or a cons.
4824 (defun gnus-group-add-parameter (group param)
4825 "Add parameter PARAM to GROUP."
4826 (let ((info (gnus-get-info group)))
4828 () ; This is a dead group. We just ignore it.
4829 ;; Cons the new param to the old one and update.
4830 (gnus-group-set-info (cons param (gnus-info-params info))
4833 (defun gnus-group-set-parameter (group name value)
4834 "Set parameter NAME to VALUE in GROUP."
4835 (let ((info (gnus-get-info group)))
4837 () ; This is a dead group. We just ignore it.
4838 (let ((old-params (gnus-info-params info))
4839 (new-params (list (cons name value))))
4841 (if (or (not (listp (car old-params)))
4842 (not (eq (caar old-params) name)))
4843 (setq new-params (append new-params (list (car old-params)))))
4844 (setq old-params (cdr old-params)))
4845 (gnus-group-set-info new-params group 'params)))))
4847 (defun gnus-group-add-score (group &optional score)
4848 "Add SCORE to the GROUP score.
4849 If SCORE is nil, add 1 to the score of GROUP."
4850 (let ((info (gnus-get-info group)))
4852 (gnus-info-set-score info (+ (gnus-info-score info) (or score 1))))))
4854 (defun gnus-summary-bubble-group ()
4855 "Increase the score of the current group.
4856 This is a handy function to add to `gnus-summary-exit-hook' to
4857 increase the score of each group you read."
4858 (gnus-group-add-score gnus-newsgroup-name))
4860 (defun gnus-group-set-info (info &optional method-only-group part)
4861 (let* ((entry (gnus-gethash
4862 (or method-only-group (gnus-info-group info))
4863 gnus-newsrc-hashtb))
4865 (info (if method-only-group (nth 2 entry) info))
4867 (when method-only-group
4869 (error "Trying to change non-existent group %s" method-only-group))
4870 ;; We have received parts of the actual group info - either the
4871 ;; select method or the group parameters. We first check
4872 ;; whether we have to extend the info, and if so, do that.
4873 (let ((len (length info))
4874 (total (if (eq part 'method) 5 6)))
4876 (setcdr (nthcdr (1- len) info)
4877 (make-list (- total len) nil)))
4878 ;; Then we enter the new info.
4879 (setcar (nthcdr (1- total) info) part-info)))
4881 ;; This is a new group, so we just create it.
4883 (set-buffer gnus-group-buffer)
4884 (setq method (gnus-info-method info))
4885 (when (gnus-server-equal method "native")
4888 (set-buffer gnus-group-buffer)
4890 ;; It's a foreign group...
4891 (gnus-group-make-group
4892 (gnus-group-real-name (gnus-info-group info))
4893 (if (stringp method) method
4894 (prin1-to-string (car method)))
4896 (nth 1 (gnus-info-method info))))
4897 ;; It's a native group.
4898 (gnus-group-make-group (gnus-info-group info))))
4899 (gnus-message 6 "Note: New group created")
4901 (gnus-gethash (gnus-group-prefixed-name
4902 (gnus-group-real-name (gnus-info-group info))
4903 (or (gnus-info-method info) gnus-select-method))
4904 gnus-newsrc-hashtb))))
4905 ;; Whether it was a new group or not, we now have the entry, so we
4906 ;; can do the update.
4909 (setcar (nthcdr 2 entry) info)
4910 (when (and (not (eq (car entry) t))
4911 (gnus-active (gnus-info-group info)))
4912 (setcar entry (length (gnus-list-of-unread-articles (car info))))))
4913 (error "No such group: %s" (gnus-info-group info)))))
4915 (defun gnus-group-set-method-info (group select-method)
4916 (gnus-group-set-info select-method group 'method))
4918 (defun gnus-group-set-params-info (group params)
4919 (gnus-group-set-info params group 'params))
4921 (defun gnus-group-update-group-line ()
4922 "Update the current line in the group buffer."
4923 (let* ((buffer-read-only nil)
4924 (group (gnus-group-group-name))
4925 (entry (and group (gnus-gethash group gnus-newsrc-hashtb)))
4926 gnus-group-indentation)
4928 (not (gnus-ephemeral-group-p group))
4930 (concat "(gnus-group-set-info '"
4931 (prin1-to-string (nth 2 entry)) ")")))
4932 (setq gnus-group-indentation (gnus-group-group-indentation))
4934 (gnus-group-insert-group-line-info group)
4936 (gnus-group-position-point)))
4938 (defun gnus-group-insert-group-line-info (group)
4939 "Insert GROUP on the current line."
4940 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
4944 ;; (Un)subscribed group.
4945 (setq info (nth 2 entry))
4946 (gnus-group-insert-group-line
4947 group (gnus-info-level info) (gnus-info-marks info)
4948 (or (car entry) t) (gnus-info-method info)))
4949 ;; This group is dead.
4950 (gnus-group-insert-group-line
4952 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
4954 (if (setq active (gnus-active group))
4955 (- (1+ (cdr active)) (car active)) 0)
4958 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
4959 gnus-tmp-marked number
4961 "Insert a group line in the group buffer."
4962 (let* ((gnus-tmp-active (gnus-active gnus-tmp-group))
4963 (gnus-tmp-number-total
4965 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
4967 (gnus-tmp-number-of-unread
4968 (if (numberp number) (int-to-string (max 0 number))
4970 (gnus-tmp-number-of-read
4971 (if (numberp number)
4972 (int-to-string (max 0 (- gnus-tmp-number-total number)))
4974 (gnus-tmp-subscribed
4975 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
4976 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
4977 ((= gnus-tmp-level gnus-level-zombie) ?Z)
4979 (gnus-tmp-qualified-group (gnus-group-real-name gnus-tmp-group))
4980 (gnus-tmp-newsgroup-description
4981 (if gnus-description-hashtb
4982 (or (gnus-gethash gnus-tmp-group gnus-description-hashtb) "")
4985 (if (member gnus-tmp-group gnus-moderated-list) ?m ? ))
4986 (gnus-tmp-moderated-string
4987 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
4989 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
4990 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
4991 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
4992 (gnus-tmp-news-method-string
4994 (format "(%s:%s)" (car gnus-tmp-method)
4995 (cadr gnus-tmp-method)) ""))
4996 (gnus-tmp-marked-mark
4997 (if (and (numberp number)
4999 (cdr (assq 'tick gnus-tmp-marked)))
5001 (gnus-tmp-process-marked
5002 (if (member gnus-tmp-group gnus-group-marked)
5003 gnus-process-mark ? ))
5005 (or (and gnus-use-grouplens
5006 (bbb-grouplens-group-p gnus-tmp-group))
5008 (buffer-read-only nil)
5009 header gnus-tmp-header) ; passed as parameter to user-funcs.
5011 (gnus-add-text-properties
5015 (eval gnus-group-line-format-spec))
5016 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
5017 gnus-unread ,(if (numberp number)
5018 (string-to-int gnus-tmp-number-of-unread)
5020 gnus-marked ,gnus-tmp-marked-mark
5021 gnus-indentation ,gnus-group-indentation
5022 gnus-level ,gnus-tmp-level))
5023 (when (inline (gnus-visual-p 'group-highlight 'highlight))
5025 (run-hooks 'gnus-group-update-hook)
5027 ;; Allow XEmacs to remove front-sticky text properties.
5028 (gnus-group-remove-excess-properties)))
5030 (defun gnus-group-update-group (group &optional visible-only)
5031 "Update all lines where GROUP appear.
5032 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
5035 (set-buffer gnus-group-buffer)
5036 ;; The buffer may be narrowed.
5039 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
5041 found buffer-read-only)
5042 ;; Enter the current status into the dribble buffer.
5043 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
5044 (if (and entry (not (gnus-ephemeral-group-p group)))
5046 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
5048 ;; Find all group instances. If topics are in use, each group
5049 ;; may be listed in more than once.
5050 (while (setq loc (text-property-any
5051 loc (point-max) 'gnus-group ident))
5054 (let ((gnus-group-indentation (gnus-group-group-indentation)))
5056 (gnus-group-insert-group-line-info group)
5059 (run-hooks 'gnus-group-update-group-hook)))
5060 (setq loc (1+ loc)))
5061 (unless (or found visible-only)
5062 ;; No such line in the buffer, find out where it's supposed to
5063 ;; go, and insert it there (or at the end of the buffer).
5064 (if gnus-goto-missing-group-function
5065 (funcall gnus-goto-missing-group-function group)
5066 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
5067 (while (and entry (car entry)
5071 (point-min) (point-max)
5072 'gnus-group (gnus-intern-safe
5073 (caar entry) gnus-active-hashtb)))))
5074 (setq entry (cdr entry)))
5075 (or entry (goto-char (point-max)))))
5076 ;; Finally insert the line.
5077 (let ((gnus-group-indentation (gnus-group-group-indentation)))
5078 (gnus-group-insert-group-line-info group)
5081 (run-hooks 'gnus-group-update-group-hook))))
5082 (gnus-group-set-mode-line)))))
5084 (defun gnus-group-set-mode-line ()
5085 "Update the mode line in the group buffer."
5086 (when (memq 'group gnus-updated-mode-lines)
5087 ;; Yes, we want to keep this mode line updated.
5089 (set-buffer gnus-group-buffer)
5090 (let* ((gformat (or gnus-group-mode-line-format-spec
5091 (setq gnus-group-mode-line-format-spec
5093 gnus-group-mode-line-format
5094 gnus-group-mode-line-format-alist))))
5095 (gnus-tmp-news-server (cadr gnus-select-method))
5096 (gnus-tmp-news-method (car gnus-select-method))
5097 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
5099 gnus-tmp-header ;Dummy binding for user-defined formats
5100 ;; Get the resulting string.
5101 (mode-string (eval gformat)))
5102 ;; Say whether the dribble buffer has been modified.
5103 (setq mode-line-modified
5104 (if (and gnus-dribble-buffer
5105 (buffer-name gnus-dribble-buffer)
5106 (buffer-modified-p gnus-dribble-buffer)
5108 (set-buffer gnus-dribble-buffer)
5109 (not (zerop (buffer-size)))))
5111 ;; If the line is too long, we chop it off.
5112 (when (> (length mode-string) max-len)
5113 (setq mode-string (substring mode-string 0 (- max-len 4))))
5115 (setq mode-line-buffer-identification
5117 (set-buffer-modified-p t))))))
5119 (defun gnus-group-group-name ()
5120 "Get the name of the newsgroup on the current line."
5121 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
5122 (and group (symbol-name group))))
5124 (defun gnus-group-group-level ()
5125 "Get the level of the newsgroup on the current line."
5126 (get-text-property (gnus-point-at-bol) 'gnus-level))
5128 (defun gnus-group-group-indentation ()
5129 "Get the indentation of the newsgroup on the current line."
5130 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
5131 (and gnus-group-indentation-function
5132 (funcall gnus-group-indentation-function))
5135 (defun gnus-group-group-unread ()
5136 "Get the number of unread articles of the newsgroup on the current line."
5137 (get-text-property (gnus-point-at-bol) 'gnus-unread))
5139 (defun gnus-group-search-forward (&optional backward all level first-too)
5140 "Find the next newsgroup with unread articles.
5141 If BACKWARD is non-nil, find the previous newsgroup instead.
5142 If ALL is non-nil, just find any newsgroup.
5143 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
5145 If FIRST-TOO, the current line is also eligible as a target."
5146 (let ((way (if backward -1 1))
5147 (low gnus-level-killed)
5150 (if (and backward (progn (beginning-of-line)) (bobp))
5152 (or first-too (forward-line way))
5160 (get-text-property (point) 'gnus-unread)))
5161 (and (numberp unread) (> unread 0)))
5162 (setq lev (get-text-property (point)
5164 (<= lev gnus-level-subscribed)))
5166 (and (setq lev (get-text-property (point)
5175 (zerop (forward-line way)))))
5177 (progn (gnus-group-position-point) t)
5178 (goto-char (or pos beg))
5181 ;;; Gnus group mode commands
5185 (defun gnus-group-mark-group (n &optional unmark no-advance)
5186 "Mark the current group."
5188 (let ((buffer-read-only nil)
5192 (when (setq group (gnus-group-group-name))
5196 (or (cdr (assq 'process gnus-group-mark-positions)) 2))
5201 (setq gnus-group-marked (delete group gnus-group-marked)))
5203 (setq gnus-group-marked
5204 (cons group (delete group gnus-group-marked)))))
5205 (or no-advance (gnus-group-next-group 1))
5207 (gnus-summary-position-point)
5210 (defun gnus-group-unmark-group (n)
5211 "Remove the mark from the current group."
5213 (gnus-group-mark-group n 'unmark)
5214 (gnus-group-position-point))
5216 (defun gnus-group-unmark-all-groups ()
5217 "Unmark all groups."
5219 (let ((groups gnus-group-marked))
5222 (gnus-group-remove-mark (pop groups)))))
5223 (gnus-group-position-point))
5225 (defun gnus-group-mark-region (unmark beg end)
5226 "Mark all groups between point and mark.
5227 If UNMARK, remove the mark instead."
5228 (interactive "P\nr")
5229 (let ((num (count-lines beg end)))
5232 (- num (gnus-group-mark-group num unmark)))))
5234 (defun gnus-group-mark-buffer (&optional unmark)
5235 "Mark all groups in the buffer.
5236 If UNMARK, remove the mark instead."
5238 (gnus-group-mark-region unmark (point-min) (point-max)))
5240 (defun gnus-group-mark-regexp (regexp)
5241 "Mark all groups that match some regexp."
5242 (interactive "sMark (regexp): ")
5243 (let ((alist (cdr gnus-newsrc-alist))
5246 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
5247 (gnus-group-set-mark group))))
5248 (gnus-group-position-point))
5250 (defun gnus-group-remove-mark (group)
5251 "Remove the process mark from GROUP and move point there.
5252 Return nil if the group isn't displayed."
5253 (if (gnus-group-goto-group group)
5255 (gnus-group-mark-group 1 'unmark t)
5257 (setq gnus-group-marked
5258 (delete group gnus-group-marked))
5261 (defun gnus-group-set-mark (group)
5262 "Set the process mark on GROUP."
5263 (if (gnus-group-goto-group group)
5265 (gnus-group-mark-group 1 nil t))
5266 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
5268 (defun gnus-group-universal-argument (arg &optional groups func)
5269 "Perform any command on all groups accoring to the process/prefix convention."
5271 (let ((groups (or groups (gnus-group-process-prefix arg)))
5273 (if (eq (setq func (or func
5276 (substitute-command-keys
5277 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
5279 (gnus-error 1 "Undefined key")
5281 (gnus-group-remove-mark (setq group (pop groups)))
5282 (command-execute func))))
5283 (gnus-group-position-point))
5285 (defun gnus-group-process-prefix (n)
5286 "Return a list of groups to work on.
5287 Take into consideration N (the prefix) and the list of marked groups."
5290 (setq n (prefix-numeric-value n))
5291 ;; There is a prefix, so we return a list of the N next
5293 (let ((way (if (< n 0) -1 1))
5298 (setq group (gnus-group-group-name)))
5299 (setq groups (cons group groups))
5301 (gnus-group-next-group way)))
5303 ((and (boundp 'transient-mark-mode)
5305 (boundp 'mark-active)
5307 ;; Work on the region between point and mark.
5308 (let ((max (max (point) (mark)))
5311 (goto-char (min (point) (mark)))
5314 (push (gnus-group-group-name) groups)
5315 (zerop (gnus-group-next-group 1))
5317 (nreverse groups))))
5319 ;; No prefix, but a list of marked articles.
5320 (reverse gnus-group-marked))
5322 ;; Neither marked articles or a prefix, so we return the
5324 (let ((group (gnus-group-group-name)))
5325 (and group (list group))))))
5327 ;; Selecting groups.
5329 (defun gnus-group-read-group (&optional all no-article group)
5330 "Read news in this newsgroup.
5331 If the prefix argument ALL is non-nil, already read articles become
5332 readable. IF ALL is a number, fetch this number of articles. If the
5333 optional argument NO-ARTICLE is non-nil, no article will be
5334 auto-selected upon group entry. If GROUP is non-nil, fetch that
5337 (let ((group (or group (gnus-group-group-name)))
5338 number active marked entry)
5339 (or group (error "No group on current line"))
5340 (setq marked (nth 3 (nth 2 (setq entry (gnus-gethash
5341 group gnus-newsrc-hashtb)))))
5342 ;; This group might be a dead group. In that case we have to get
5343 ;; the number of unread articles from `gnus-active-hashtb'.
5345 (cond ((numberp all) all)
5347 ((setq active (gnus-active group))
5348 (- (1+ (cdr active)) (car active)))))
5349 (gnus-summary-read-group
5350 group (or all (and (numberp number)
5351 (zerop (+ number (length (cdr (assq 'tick marked)))
5352 (length (cdr (assq 'dormant marked)))))))
5355 (defun gnus-group-select-group (&optional all)
5356 "Select this newsgroup.
5357 No article is selected automatically.
5358 If ALL is non-nil, already read articles become readable.
5359 If ALL is a number, fetch this number of articles."
5361 (gnus-group-read-group all t))
5363 (defun gnus-group-quick-select-group (&optional all)
5364 "Select the current group \"quickly\".
5365 This means that no highlighting or scoring will be performed."
5368 gnus-score-find-score-files-function
5369 gnus-apply-kill-hook
5370 gnus-summary-expunge-below)
5371 (gnus-group-read-group all t)))
5373 (defun gnus-group-visible-select-group (&optional all)
5374 "Select the current group without hiding any articles."
5376 (let ((gnus-inhibit-limiting t))
5377 (gnus-group-read-group all t)))
5380 (defun gnus-fetch-group (group)
5381 "Start Gnus if necessary and enter GROUP.
5382 Returns whether the fetching was successful or not."
5383 (interactive "sGroup name: ")
5384 (or (get-buffer gnus-group-buffer)
5386 (gnus-group-read-group nil nil group))
5388 ;; Enter a group that is not in the group buffer. Non-nil is returned
5389 ;; if selection was successful.
5390 (defun gnus-group-read-ephemeral-group
5391 (group method &optional activate quit-config)
5392 (let ((group (if (gnus-group-foreign-p group) group
5393 (gnus-group-prefixed-name group method))))
5396 `(t nil (,group ,gnus-level-default-subscribed nil nil ,method
5397 ((quit-config . ,(if quit-config quit-config
5398 (cons (current-buffer) 'summary))))))
5400 (set-buffer gnus-group-buffer)
5401 (or (gnus-check-server method)
5402 (error "Unable to contact server: %s" (gnus-status-message method)))
5403 (if activate (or (gnus-request-group group)
5404 (error "Couldn't request group")))
5406 (gnus-group-read-group t t group)
5410 (defun gnus-group-jump-to-group (group)
5411 "Jump to newsgroup GROUP."
5413 (list (completing-read
5414 "Group: " gnus-active-hashtb nil
5415 (gnus-read-active-file-p)
5417 'gnus-group-history)))
5419 (when (equal group "")
5420 (error "Empty group name"))
5422 (when (string-match "[\000-\032]" group)
5423 (error "Control characters in group: %s" group))
5425 (let ((b (text-property-any
5426 (point-min) (point-max)
5427 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
5428 (unless (gnus-ephemeral-group-p group)
5430 ;; Either go to the line in the group buffer...
5432 ;; ... or insert the line.
5435 (gnus-activate-group group)
5436 (error "%s error: %s" group (gnus-status-message group)))
5438 (gnus-group-update-group group)
5439 (goto-char (text-property-any
5440 (point-min) (point-max)
5441 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))
5442 ;; Adjust cursor point.
5443 (gnus-group-position-point)))
5445 (defun gnus-group-goto-group (group)
5446 "Goto to newsgroup GROUP."
5448 (let ((b (text-property-any (point-min) (point-max)
5449 'gnus-group (gnus-intern-safe
5450 group gnus-active-hashtb))))
5451 (and b (goto-char b)))))
5453 (defun gnus-group-next-group (n)
5454 "Go to next N'th newsgroup.
5455 If N is negative, search backward instead.
5456 Returns the difference between N and the number of skips actually
5459 (gnus-group-next-unread-group n t))
5461 (defun gnus-group-next-unread-group (n &optional all level)
5462 "Go to next N'th unread newsgroup.
5463 If N is negative, search backward instead.
5464 If ALL is non-nil, choose any newsgroup, unread or not.
5465 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
5466 such group can be found, the next group with a level higher than
5468 Returns the difference between N and the number of skips actually
5471 (let ((backward (< n 0))
5474 (gnus-group-search-forward
5475 backward (or (not gnus-group-goto-unread) all) level))
5477 (if (/= 0 n) (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
5478 (if level " on this level or higher" "")))
5481 (defun gnus-group-prev-group (n)
5482 "Go to previous N'th newsgroup.
5483 Returns the difference between N and the number of skips actually
5486 (gnus-group-next-unread-group (- n) t))
5488 (defun gnus-group-prev-unread-group (n)
5489 "Go to previous N'th unread newsgroup.
5490 Returns the difference between N and the number of skips actually
5493 (gnus-group-next-unread-group (- n)))
5495 (defun gnus-group-next-unread-group-same-level (n)
5496 "Go to next N'th unread newsgroup on the same level.
5497 If N is negative, search backward instead.
5498 Returns the difference between N and the number of skips actually
5501 (gnus-group-next-unread-group n t (gnus-group-group-level))
5502 (gnus-group-position-point))
5504 (defun gnus-group-prev-unread-group-same-level (n)
5505 "Go to next N'th unread newsgroup on the same level.
5506 Returns the difference between N and the number of skips actually
5509 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
5510 (gnus-group-position-point))
5512 (defun gnus-group-best-unread-group (&optional exclude-group)
5513 "Go to the group with the highest level.
5514 If EXCLUDE-GROUP, do not go to that group."
5516 (goto-char (point-min))
5520 (setq unread (get-text-property (point) 'gnus-unread))
5521 (if (and (numberp unread) (> unread 0))
5523 (if (and (get-text-property (point) 'gnus-level)
5524 (< (get-text-property (point) 'gnus-level) best)
5525 (or (not exclude-group)
5526 (not (equal exclude-group (gnus-group-group-name)))))
5528 (setq best (get-text-property (point) 'gnus-level))
5529 (setq best-point (point))))))
5531 (if best-point (goto-char best-point))
5532 (gnus-summary-position-point)
5533 (and best-point (gnus-group-group-name))))
5535 (defun gnus-group-first-unread-group ()
5536 "Go to the first group with unread articles."
5539 (let ((opoint (point))
5541 (goto-char (point-min))
5542 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
5543 (and (numberp unread) ; Not a topic.
5544 (not (zerop unread))) ; Has unread articles.
5545 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
5548 nil)) ; Not success.
5549 (gnus-group-position-point)))
5551 (defun gnus-group-enter-server-mode ()
5552 "Jump to the server buffer."
5554 (gnus-enter-server-buffer))
5556 (defun gnus-group-make-group (name &optional method address)
5557 "Add a new newsgroup.
5558 The user will be prompted for a NAME, for a select METHOD, and an
5562 (read-string "Group name: ")
5565 "Method: " (append gnus-valid-select-methods gnus-server-alist)
5566 nil t nil 'gnus-method-history)))
5567 (cond ((assoc method gnus-valid-select-methods)
5569 (if (memq 'prompt-address
5570 (assoc method gnus-valid-select-methods))
5571 (read-string "Address: ")
5573 ((assoc method gnus-server-alist)
5576 (list method ""))))))
5578 (let* ((meth (and method (if address (list (intern method) address)
5580 (nname (if method (gnus-group-prefixed-name name meth) name))
5582 (when (gnus-gethash nname gnus-newsrc-hashtb)
5583 (error "Group %s already exists" nname))
5584 ;; Subscribe to the new group.
5585 (gnus-group-change-level
5586 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
5587 gnus-level-default-subscribed gnus-level-killed
5588 (and (gnus-group-group-name)
5589 (gnus-gethash (gnus-group-group-name)
5590 gnus-newsrc-hashtb))
5593 (gnus-set-active nname (cons 1 0))
5594 (or (gnus-ephemeral-group-p name)
5596 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")")))
5598 (gnus-group-insert-group-line-info nname)
5600 (gnus-group-position-point)
5602 ;; Load the backend and try to make the backend create
5603 ;; the group as well.
5604 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
5606 gnus-valid-select-methods)
5608 (gnus-check-server meth)
5609 (and (gnus-check-backend-function 'request-create-group nname)
5610 (gnus-request-create-group nname))
5613 (defun gnus-group-delete-group (group &optional force)
5614 "Delete the current group.
5615 If FORCE (the prefix) is non-nil, all the articles in the group will
5616 be deleted. This is \"deleted\" as in \"removed forever from the face
5617 of the Earth\". There is no undo."
5619 (list (gnus-group-group-name)
5620 current-prefix-arg))
5621 (or group (error "No group to rename"))
5622 (or (gnus-check-backend-function 'request-delete-group group)
5623 (error "This backend does not support group deletion"))
5625 (if (not (gnus-yes-or-no-p
5627 "Do you really want to delete %s%s? "
5628 group (if force " and all its contents" ""))))
5630 (gnus-message 6 "Deleting group %s..." group)
5631 (if (not (gnus-request-delete-group group force))
5632 (gnus-error 3 "Couldn't delete group %s" group)
5633 (gnus-message 6 "Deleting group %s...done" group)
5634 (gnus-group-goto-group group)
5635 (gnus-group-kill-group 1 t)
5636 (gnus-sethash group nil gnus-active-hashtb)
5638 (gnus-group-position-point)))
5640 (defun gnus-group-rename-group (group new-name)
5643 (gnus-group-group-name)
5645 (or (gnus-check-backend-function
5646 'request-rename-group (gnus-group-group-name))
5647 (error "This backend does not support renaming groups"))
5648 (read-string "New group name: "))))
5650 (or (gnus-check-backend-function 'request-rename-group group)
5651 (error "This backend does not support renaming groups"))
5653 (or group (error "No group to rename"))
5654 (and (string-match "^[ \t]*$" new-name)
5655 (error "Not a valid group name"))
5657 ;; We find the proper prefixed name.
5659 (gnus-group-prefixed-name
5660 (gnus-group-real-name new-name)
5661 (gnus-info-method (gnus-get-info group))))
5663 (gnus-message 6 "Renaming group %s to %s..." group new-name)
5665 (if (not (gnus-request-rename-group group new-name))
5666 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
5667 ;; We rename the group internally by killing it...
5668 (gnus-group-goto-group group)
5669 (gnus-group-kill-group)
5670 ;; ... changing its name ...
5671 (setcar (cdar gnus-list-of-killed-groups) new-name)
5672 ;; ... and then yanking it. Magic!
5673 (gnus-group-yank-group)
5674 (gnus-set-active new-name (gnus-active group))
5675 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
5677 (gnus-group-position-point)))
5679 (defun gnus-group-edit-group (group &optional part)
5680 "Edit the group on the current line."
5681 (interactive (list (gnus-group-group-name)))
5682 (let* ((part (or part 'info))
5683 (done-func `(lambda ()
5684 "Exit editing mode and update the information."
5686 (gnus-group-edit-group-done ',part ,group)))
5687 (winconf (current-window-configuration))
5689 (or group (error "No group on current line"))
5690 (or (setq info (gnus-get-info group))
5691 (error "Killed group; can't be edited"))
5692 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5693 (gnus-configure-windows 'edit-group)
5694 (gnus-add-current-to-buffer-list)
5696 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
5697 (use-local-map (copy-keymap emacs-lisp-mode-map))
5698 (local-set-key "\C-c\C-c" done-func)
5699 (make-local-variable 'gnus-prev-winconf)
5700 (setq gnus-prev-winconf winconf)
5705 ";; Type `C-c C-c' after editing the select method.\n\n")
5707 ";; Type `C-c C-c' after editing the group parameters.\n\n")
5709 ";; Type `C-c C-c' after editing the group info.\n\n")))
5712 (cond ((eq part 'method)
5713 (or (gnus-info-method info) "native"))
5715 (gnus-info-params info))
5719 (defun gnus-group-edit-group-method (group)
5720 "Edit the select method of GROUP."
5721 (interactive (list (gnus-group-group-name)))
5722 (gnus-group-edit-group group 'method))
5724 (defun gnus-group-edit-group-parameters (group)
5725 "Edit the group parameters of GROUP."
5726 (interactive (list (gnus-group-group-name)))
5727 (gnus-group-edit-group group 'params))
5729 (defun gnus-group-edit-group-done (part group)
5730 "Get info from buffer, update variables and jump to the group buffer."
5731 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5732 (goto-char (point-min))
5733 (let* ((form (read (current-buffer)))
5734 (winconf gnus-prev-winconf)
5735 (method (cond ((eq part 'info) (nth 4 form))
5736 ((eq part 'method) form)
5738 (info (cond ((eq part 'info) form)
5739 ((eq part 'method) (gnus-get-info group))
5742 (if (or (not method)
5744 gnus-select-method method))
5745 (gnus-group-real-name (car info))
5746 (gnus-group-prefixed-name
5747 (gnus-group-real-name (car info)) method))
5749 (when (and new-group
5750 (not (equal new-group group)))
5751 (when (gnus-group-goto-group group)
5752 (gnus-group-kill-group 1))
5753 (gnus-activate-group new-group))
5755 (if (and info new-group)
5757 (setq info (gnus-copy-sequence info))
5758 (setcar info new-group)
5759 (unless (gnus-server-equal method "native")
5760 (unless (nthcdr 3 info)
5761 (nconc info (list nil nil)))
5762 (unless (nthcdr 4 info)
5763 (nconc info (list nil)))
5764 (gnus-info-set-method info method))
5765 (gnus-group-set-info info))
5766 (gnus-group-set-info form (or new-group group) part))
5767 (kill-buffer (current-buffer))
5768 (and winconf (set-window-configuration winconf))
5769 (set-buffer gnus-group-buffer)
5770 (gnus-group-update-group (or new-group group))
5771 (gnus-group-position-point)))
5773 (defun gnus-group-make-help-group ()
5774 "Create the Gnus documentation group."
5776 (let ((path load-path)
5777 (name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
5779 (and (gnus-gethash name gnus-newsrc-hashtb)
5780 (error "Documentation group already exists"))
5782 (setq dir (file-name-as-directory (expand-file-name (pop path)))
5784 (when (or (file-exists-p (setq file (concat dir "gnus-tut.txt")))
5786 (setq file (concat (file-name-directory
5787 (directory-file-name dir))
5788 "etc/gnus-tut.txt"))))
5791 (gnus-message 1 "Couldn't find doc group")
5792 (gnus-group-make-group
5793 (gnus-group-real-name name)
5794 (list 'nndoc "gnus-help"
5795 (list 'nndoc-address file)
5796 (list 'nndoc-article-type 'mbox)))))
5797 (gnus-group-position-point))
5799 (defun gnus-group-make-doc-group (file type)
5800 "Create a group that uses a single file as the source."
5802 (list (read-file-name "File name: ")
5803 (and current-prefix-arg 'ask)))
5804 (when (eq type 'ask)
5809 "%sFile type (mbox, babyl, digest, forward, mmfd, guess) [mbdfag]: "
5811 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
5812 ((= char ?b) 'babyl)
5813 ((= char ?d) 'digest)
5814 ((= char ?f) 'forward)
5816 (t (setq err (format "%c unknown. " char))
5819 (let* ((file (expand-file-name file))
5820 (name (gnus-generate-new-group-name
5821 (gnus-group-prefixed-name
5822 (file-name-nondirectory file) '(nndoc "")))))
5823 (gnus-group-make-group
5824 (gnus-group-real-name name)
5825 (list 'nndoc (file-name-nondirectory file)
5826 (list 'nndoc-address file)
5827 (list 'nndoc-article-type (or type 'guess))))))
5829 (defun gnus-group-make-archive-group (&optional all)
5830 "Create the (ding) Gnus archive group of the most recent articles.
5831 Given a prefix, create a full group."
5833 (let ((group (gnus-group-prefixed-name
5834 (if all "ding.archives" "ding.recent") '(nndir ""))))
5835 (and (gnus-gethash group gnus-newsrc-hashtb)
5836 (error "Archive group already exists"))
5837 (gnus-group-make-group
5838 (gnus-group-real-name group)
5839 (list 'nndir (if all "hpc" "edu")
5840 (list 'nndir-directory
5841 (if all gnus-group-archive-directory
5842 gnus-group-recent-archive-directory))))))
5844 (defun gnus-group-make-directory-group (dir)
5845 "Create an nndir group.
5846 The user will be prompted for a directory. The contents of this
5847 directory will be used as a newsgroup. The directory should contain
5848 mail messages or news articles in files that have numeric names."
5850 (list (read-file-name "Create group from directory: ")))
5851 (or (file-exists-p dir) (error "No such directory"))
5852 (or (file-directory-p dir) (error "Not a directory"))
5856 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
5858 (gnus-group-prefixed-name
5859 (concat (file-name-as-directory (directory-file-name dir))
5862 (setq ext (format "<%d>" (setq i (1+ i)))))
5863 (gnus-group-make-group
5864 (gnus-group-real-name group)
5865 (list 'nndir group (list 'nndir-directory dir)))))
5867 (defun gnus-group-make-kiboze-group (group address scores)
5868 "Create an nnkiboze group.
5869 The user will be prompted for a name, a regexp to match groups, and
5870 score file entries for articles to include in the group."
5873 (read-string "nnkiboze group name: ")
5874 (read-string "Source groups (regexp): ")
5875 (let ((headers (mapcar (lambda (group) (list group))
5876 '("subject" "from" "number" "date" "message-id"
5877 "references" "chars" "lines" "xref"
5878 "followup" "all" "body" "head")))
5879 scores header regexp regexps)
5880 (while (not (equal "" (setq header (completing-read
5881 "Match on header: " headers nil t))))
5883 (while (not (equal "" (setq regexp (read-string
5884 (format "Match on %s (string): "
5886 (setq regexps (cons (list regexp nil nil 'r) regexps)))
5887 (setq scores (cons (cons header regexps) scores)))
5889 (gnus-group-make-group group "nnkiboze" address)
5890 (nnheader-temp-write (gnus-score-file-name (concat "nnkiboze:" group))
5891 (let (emacs-lisp-mode-hook)
5892 (pp scores (current-buffer)))))
5894 (defun gnus-group-add-to-virtual (n vgroup)
5895 "Add the current group to a virtual group."
5897 (list current-prefix-arg
5898 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
5900 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
5901 (error "%s is not an nnvirtual group" vgroup))
5902 (let* ((groups (gnus-group-process-prefix n))
5903 (method (gnus-info-method (gnus-get-info vgroup))))
5904 (setcar (cdr method)
5906 (nth 1 method) "\\|"
5909 (gnus-group-remove-mark s)
5910 (concat "\\(^" (regexp-quote s) "$\\)"))
5912 (gnus-group-position-point))
5914 (defun gnus-group-make-empty-virtual (group)
5915 "Create a new, fresh, empty virtual group."
5916 (interactive "sCreate new, empty virtual group: ")
5917 (let* ((method (list 'nnvirtual "^$"))
5918 (pgroup (gnus-group-prefixed-name group method)))
5919 ;; Check whether it exists already.
5920 (and (gnus-gethash pgroup gnus-newsrc-hashtb)
5921 (error "Group %s already exists." pgroup))
5922 ;; Subscribe the new group after the group on the current line.
5923 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
5924 (gnus-group-update-group pgroup)
5926 (gnus-group-position-point)))
5928 (defun gnus-group-enter-directory (dir)
5929 "Enter an ephemeral nneething group."
5930 (interactive "DDirectory to read: ")
5931 (let* ((method (list 'nneething dir))
5932 (leaf (gnus-group-prefixed-name
5933 (file-name-nondirectory (directory-file-name dir))
5935 (name (gnus-generate-new-group-name leaf)))
5936 (let ((nneething-read-only t))
5937 (or (gnus-group-read-ephemeral-group
5939 (cons (current-buffer) (if (eq major-mode 'gnus-summary-mode)
5941 (error "Couldn't enter %s" dir)))))
5943 ;; Group sorting commands
5944 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
5946 (defun gnus-group-sort-groups (func &optional reverse)
5947 "Sort the group buffer according to FUNC.
5948 If REVERSE, reverse the sorting order."
5949 (interactive (list gnus-group-sort-function
5950 current-prefix-arg))
5952 ((not (listp func)) func)
5954 ((= 1 (length func)) (car func))
5956 ,(gnus-make-sort-function
5957 (reverse func)))))))
5958 ;; We peel off the dummy group from the alist.
5960 (when (equal (car (gnus-info-group gnus-newsrc-alist)) "dummy.group")
5961 (pop gnus-newsrc-alist))
5963 (setq gnus-newsrc-alist
5964 (sort gnus-newsrc-alist func))
5966 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
5967 ;; Regenerate the hash table.
5968 (gnus-make-hashtable-from-newsrc-alist)
5969 (gnus-group-list-groups))))
5971 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
5972 "Sort the group buffer alphabetically by group name.
5973 If REVERSE, sort in reverse order."
5975 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
5977 (defun gnus-group-sort-groups-by-unread (&optional reverse)
5978 "Sort the group buffer by number of unread articles.
5979 If REVERSE, sort in reverse order."
5981 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
5983 (defun gnus-group-sort-groups-by-level (&optional reverse)
5984 "Sort the group buffer by group level.
5985 If REVERSE, sort in reverse order."
5987 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
5989 (defun gnus-group-sort-groups-by-score (&optional reverse)
5990 "Sort the group buffer by group score.
5991 If REVERSE, sort in reverse order."
5993 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
5995 (defun gnus-group-sort-groups-by-rank (&optional reverse)
5996 "Sort the group buffer by group rank.
5997 If REVERSE, sort in reverse order."
5999 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
6001 (defun gnus-group-sort-groups-by-method (&optional reverse)
6002 "Sort the group buffer alphabetically by backend name.
6003 If REVERSE, sort in reverse order."
6005 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
6007 (defun gnus-group-sort-by-alphabet (info1 info2)
6008 "Sort alphabetically."
6009 (string< (gnus-info-group info1) (gnus-info-group info2)))
6011 (defun gnus-group-sort-by-unread (info1 info2)
6012 "Sort by number of unread articles."
6013 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
6014 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
6015 (< (or (and (numberp n1) n1) 0)
6016 (or (and (numberp n2) n2) 0))))
6018 (defun gnus-group-sort-by-level (info1 info2)
6020 (< (gnus-info-level info1) (gnus-info-level info2)))
6022 (defun gnus-group-sort-by-method (info1 info2)
6023 "Sort alphabetically by backend name."
6024 (string< (symbol-name (car (gnus-find-method-for-group
6025 (gnus-info-group info1) info1)))
6026 (symbol-name (car (gnus-find-method-for-group
6027 (gnus-info-group info2) info2)))))
6029 (defun gnus-group-sort-by-score (info1 info2)
6030 "Sort by group score."
6031 (< (gnus-info-score info1) (gnus-info-score info2)))
6033 (defun gnus-group-sort-by-rank (info1 info2)
6034 "Sort by level and score."
6035 (let ((level1 (gnus-info-level info1))
6036 (level2 (gnus-info-level info2)))
6037 (or (< level1 level2)
6038 (and (= level1 level2)
6039 (> (gnus-info-score info1) (gnus-info-score info2))))))
6041 ;; Group catching up.
6043 (defun gnus-group-clear-data (n)
6044 "Clear all marks and read ranges from the current group."
6046 (let ((groups (gnus-group-process-prefix n))
6048 (while (setq group (pop groups))
6049 (setq info (gnus-get-info group))
6050 (gnus-info-set-read info nil)
6051 (when (gnus-info-marks info)
6052 (gnus-info-set-marks info nil))
6053 (gnus-get-unread-articles-in-group info (gnus-active group) t)
6054 (when (gnus-group-goto-group group)
6055 (gnus-group-remove-mark group)
6056 (gnus-group-update-group-line)))))
6058 (defun gnus-group-catchup-current (&optional n all)
6059 "Mark all articles not marked as unread in current newsgroup as read.
6060 If prefix argument N is numeric, the ARG next newsgroups will be
6061 caught up. If ALL is non-nil, marked articles will also be marked as
6062 read. Cross references (Xref: header) of articles are ignored.
6063 The difference between N and actual number of newsgroups that were
6064 caught up is returned."
6066 (unless (gnus-group-group-name)
6067 (error "No group on the current line"))
6068 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
6072 "Do you really want to mark all articles as read? "
6073 "Mark all unread articles as read? "))))
6075 (let ((groups (gnus-group-process-prefix n))
6078 ;; Virtual groups have to be given special treatment.
6079 (let ((method (gnus-find-method-for-group (car groups))))
6080 (if (eq 'nnvirtual (car method))
6081 (nnvirtual-catchup-group
6082 (gnus-group-real-name (car groups)) (nth 1 method) all)))
6083 (gnus-group-remove-mark (car groups))
6084 (if (>= (gnus-group-group-level) gnus-level-zombie)
6085 (gnus-message 2 "Dead groups can't be caught up")
6087 (gnus-group-goto-group (car groups))
6088 (gnus-group-catchup (car groups) all))
6089 (gnus-group-update-group-line)
6090 (setq ret (1+ ret))))
6091 (setq groups (cdr groups)))
6092 (gnus-group-next-unread-group 1)
6095 (defun gnus-group-catchup-current-all (&optional n)
6096 "Mark all articles in current newsgroup as read.
6097 Cross references (Xref: header) of articles are ignored."
6099 (gnus-group-catchup-current n 'all))
6101 (defun gnus-group-catchup (group &optional all)
6102 "Mark all articles in GROUP as read.
6103 If ALL is non-nil, all articles are marked as read.
6104 The return value is the number of articles that were marked as read,
6105 or nil if no action could be taken."
6106 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
6108 ;; Do the updating only if the newsgroup isn't killed.
6109 (if (not (numberp (car entry)))
6110 (gnus-message 1 "Can't catch up; non-active group")
6111 ;; Do auto-expirable marks if that's required.
6112 (when (gnus-group-auto-expirable-p group)
6113 (gnus-add-marked-articles
6114 group 'expire (gnus-list-of-unread-articles group))
6116 (let ((marks (nth 3 (nth 2 entry))))
6117 (gnus-add-marked-articles
6118 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))
6119 (gnus-add-marked-articles
6120 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))))))
6122 (gnus-update-read-articles group nil)
6123 ;; Also nix out the lists of marks and dormants.
6125 (gnus-add-marked-articles group 'tick nil nil 'force)
6126 (gnus-add-marked-articles group 'dormant nil nil 'force))
6127 (run-hooks 'gnus-group-catchup-group-hook)
6130 (defun gnus-group-expire-articles (&optional n)
6131 "Expire all expirable articles in the current newsgroup."
6133 (let ((groups (gnus-group-process-prefix n))
6136 (error "No groups to expire"))
6137 (while (setq group (pop groups))
6138 (gnus-group-remove-mark group)
6139 (when (gnus-check-backend-function 'request-expire-articles group)
6140 (gnus-message 6 "Expiring articles in %s..." group)
6141 (let* ((info (gnus-get-info group))
6142 (expirable (if (gnus-group-total-expirable-p group)
6143 (cons nil (gnus-list-of-read-articles group))
6144 (assq 'expire (gnus-info-marks info))))
6145 (expiry-wait (gnus-group-get-parameter group 'expiry-wait)))
6149 (gnus-compress-sequence
6151 ;; We set the expiry variables to the groupp
6153 (let ((nnmail-expiry-wait-function nil)
6154 (nnmail-expiry-wait expiry-wait))
6155 (gnus-request-expire-articles
6156 (gnus-uncompress-sequence (cdr expirable)) group))
6157 ;; Just expire using the normal expiry values.
6158 (gnus-request-expire-articles
6159 (gnus-uncompress-sequence (cdr expirable)) group)))))
6160 (gnus-message 6 "Expiring articles in %s...done" group)))
6161 (gnus-group-position-point))))
6163 (defun gnus-group-expire-all-groups ()
6164 "Expire all expirable articles in all newsgroups."
6167 (gnus-message 5 "Expiring...")
6168 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
6169 (cdr gnus-newsrc-alist))))
6170 (gnus-group-expire-articles nil)))
6171 (gnus-group-position-point)
6172 (gnus-message 5 "Expiring...done"))
6174 (defun gnus-group-set-current-level (n level)
6175 "Set the level of the next N groups to LEVEL."
6180 (let ((s (read-string
6181 (format "Level (default %s): "
6182 (or (gnus-group-group-level)
6183 gnus-level-default-subscribed)))))
6184 (if (string-match "^\\s-*$" s)
6185 (int-to-string (or (gnus-group-group-level)
6186 gnus-level-default-subscribed))
6188 (or (and (>= level 1) (<= level gnus-level-killed))
6189 (error "Illegal level: %d" level))
6190 (let ((groups (gnus-group-process-prefix n))
6192 (while (setq group (pop groups))
6193 (gnus-group-remove-mark group)
6194 (gnus-message 6 "Changed level of %s from %d to %d"
6195 group (or (gnus-group-group-level) gnus-level-killed)
6197 (gnus-group-change-level
6198 group level (or (gnus-group-group-level) gnus-level-killed))
6199 (gnus-group-update-group-line)))
6200 (gnus-group-position-point))
6202 (defun gnus-group-unsubscribe-current-group (&optional n)
6203 "Toggle subscription of the current group.
6204 If given numerical prefix, toggle the N next groups."
6206 (let ((groups (gnus-group-process-prefix n))
6209 (setq group (car groups)
6210 groups (cdr groups))
6211 (gnus-group-remove-mark group)
6212 (gnus-group-unsubscribe-group
6213 group (if (<= (gnus-group-group-level) gnus-level-subscribed)
6214 gnus-level-default-unsubscribed
6215 gnus-level-default-subscribed) t)
6216 (gnus-group-update-group-line))
6217 (gnus-group-next-group 1)))
6219 (defun gnus-group-unsubscribe-group (group &optional level silent)
6220 "Toggle subscription to GROUP.
6221 Killed newsgroups are subscribed. If SILENT, don't try to update the
6224 (list (completing-read
6225 "Group: " gnus-active-hashtb nil
6226 (gnus-read-active-file-p)
6228 'gnus-group-history)))
6229 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
6231 ((string-match "^[ \t]$" group)
6232 (error "Empty group name"))
6234 ;; Toggle subscription flag.
6235 (gnus-group-change-level
6236 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
6237 gnus-level-subscribed)
6238 (1+ gnus-level-subscribed)
6239 gnus-level-default-subscribed)))
6241 (gnus-group-update-group group)))
6242 ((and (stringp group)
6243 (or (not (gnus-read-active-file-p))
6244 (gnus-active group)))
6245 ;; Add new newsgroup.
6246 (gnus-group-change-level
6248 (if level level gnus-level-default-subscribed)
6249 (or (and (member group gnus-zombie-list)
6252 (and (gnus-group-group-name)
6253 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
6255 (gnus-group-update-group group)))
6256 (t (error "No such newsgroup: %s" group)))
6257 (gnus-group-position-point)))
6259 (defun gnus-group-transpose-groups (n)
6260 "Move the current newsgroup up N places.
6261 If given a negative prefix, move down instead. The difference between
6262 N and the number of steps taken is returned."
6264 (or (gnus-group-group-name)
6265 (error "No group on current line"))
6266 (gnus-group-kill-group 1)
6268 (forward-line (- n))
6269 (gnus-group-yank-group)
6270 (gnus-group-position-point)))
6272 (defun gnus-group-kill-all-zombies ()
6273 "Kill all zombie newsgroups."
6275 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
6276 (setq gnus-zombie-list nil)
6277 (gnus-group-list-groups))
6279 (defun gnus-group-kill-region (begin end)
6280 "Kill newsgroups in current region (excluding current point).
6281 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
6296 (beginning-of-line) ;Important when LINES < 1
6297 (gnus-group-kill-group lines)))
6299 (defun gnus-group-kill-group (&optional n discard)
6300 "Kill the next N groups.
6301 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
6302 However, only groups that were alive can be yanked; already killed
6303 groups or zombie groups can't be yanked.
6304 The return value is the name of the group that was killed, or a list
6307 (let ((buffer-read-only nil)
6308 (groups (gnus-group-process-prefix n))
6309 group entry level out)
6310 (if (< (length groups) 10)
6311 ;; This is faster when there are few groups.
6313 (push (setq group (pop groups)) out)
6314 (gnus-group-remove-mark group)
6315 (setq level (gnus-group-group-level))
6317 (when (and (not discard)
6318 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
6319 (push (cons (car entry) (nth 2 entry))
6320 gnus-list-of-killed-groups))
6321 (gnus-group-change-level
6322 (if entry entry group) gnus-level-killed (if entry nil level)))
6323 ;; If there are lots and lots of groups to be killed, we use
6324 ;; this thing instead.
6326 (setq groups (nreverse groups))
6328 (gnus-group-remove-mark (setq group (pop groups)))
6331 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
6332 (push (cons (car entry) (nth 2 entry))
6333 gnus-list-of-killed-groups)
6334 (setcdr (cdr entry) (cdddr entry)))
6335 ((member group gnus-zombie-list)
6336 (setq gnus-zombie-list (delete group gnus-zombie-list)))))
6337 (gnus-make-hashtable-from-newsrc-alist)))
6339 (gnus-group-position-point)
6340 (if (< (length out) 2) (car out) (nreverse out))))
6342 (defun gnus-group-yank-group (&optional arg)
6343 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
6344 inserting it before the current newsgroup. The numeric ARG specifies
6345 how many newsgroups are to be yanked. The name of the newsgroup yanked
6346 is returned, or (if several groups are yanked) a list of yanked groups
6349 (setq arg (or arg 1))
6350 (let (info group prev out)
6351 (while (>= (decf arg) 0)
6352 (if (not (setq info (pop gnus-list-of-killed-groups)))
6353 (error "No more newsgroups to yank"))
6354 (push (setq group (nth 1 info)) out)
6355 ;; Find which newsgroup to insert this one before - search
6356 ;; backward until something suitable is found. If there are no
6357 ;; other newsgroups in this buffer, just make this newsgroup the
6359 (setq prev (gnus-group-group-name))
6360 (gnus-group-change-level
6361 info (gnus-info-level (cdr info)) gnus-level-killed
6362 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
6364 (gnus-group-insert-group-line-info group))
6366 (gnus-group-position-point)
6367 (if (< (length out) 2) (car out) (nreverse out))))
6369 (defun gnus-group-kill-level (level)
6370 "Kill all groups that is on a certain LEVEL."
6371 (interactive "nKill all groups on level: ")
6373 ((= level gnus-level-zombie)
6374 (setq gnus-killed-list
6375 (nconc gnus-zombie-list gnus-killed-list))
6376 (setq gnus-zombie-list nil))
6377 ((and (< level gnus-level-zombie)
6379 (or gnus-expert-user
6382 "Do you really want to kill all groups on level %d? "
6384 (let* ((prev gnus-newsrc-alist)
6387 (if (= (gnus-info-level level) level)
6388 (setcdr prev (cdr alist))
6390 (setq alist (cdr alist)))
6391 (gnus-make-hashtable-from-newsrc-alist)
6392 (gnus-group-list-groups)))
6394 (error "Can't kill; illegal level: %d" level))))
6396 (defun gnus-group-list-all-groups (&optional arg)
6397 "List all newsgroups with level ARG or lower.
6398 Default is gnus-level-unsubscribed, which lists all subscribed and most
6399 unsubscribed groups."
6401 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
6403 ;; Redefine this to list ALL killed groups if prefix arg used.
6404 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
6405 (defun gnus-group-list-killed (&optional arg)
6406 "List all killed newsgroups in the group buffer.
6407 If ARG is non-nil, list ALL killed groups known to Gnus. This may
6408 entail asking the server for the groups."
6410 ;; Find all possible killed newsgroups if arg.
6412 (gnus-get-killed-groups))
6413 (if (not gnus-killed-list)
6414 (gnus-message 6 "No killed groups")
6415 (let (gnus-group-list-mode)
6416 (funcall gnus-group-prepare-function
6417 gnus-level-killed t gnus-level-killed))
6418 (goto-char (point-min)))
6419 (gnus-group-position-point))
6421 (defun gnus-group-list-zombies ()
6422 "List all zombie newsgroups in the group buffer."
6424 (if (not gnus-zombie-list)
6425 (gnus-message 6 "No zombie groups")
6426 (let (gnus-group-list-mode)
6427 (funcall gnus-group-prepare-function
6428 gnus-level-zombie t gnus-level-zombie))
6429 (goto-char (point-min)))
6430 (gnus-group-position-point))
6432 (defun gnus-group-list-active ()
6433 "List all groups that are available from the server(s)."
6435 ;; First we make sure that we have really read the active file.
6436 (unless (gnus-read-active-file-p)
6437 (let ((gnus-read-active-file t))
6438 (gnus-read-active-file)))
6439 ;; Find all groups and sort them.
6447 (setq list (cons (symbol-name sym) list))))
6451 (buffer-read-only nil))
6454 (gnus-group-insert-group-line-info (pop groups)))
6455 (goto-char (point-min))))
6457 (defun gnus-activate-all-groups (level)
6458 "Activate absolutely all groups."
6459 (interactive (list 7))
6460 (let ((gnus-activate-level level)
6461 (gnus-activate-foreign-newsgroups level))
6462 (gnus-group-get-new-news)))
6464 (defun gnus-group-get-new-news (&optional arg)
6465 "Get newly arrived articles.
6466 If ARG is a number, it specifies which levels you are interested in
6467 re-scanning. If ARG is non-nil and not a number, this will force
6468 \"hard\" re-reading of the active files from all servers."
6470 (run-hooks 'gnus-get-new-news-hook)
6471 ;; We might read in new NoCeM messages here.
6472 (when (and gnus-use-nocem
6474 (gnus-nocem-scan-groups))
6475 ;; If ARG is not a number, then we read the active file.
6476 (when (and arg (not (numberp arg)))
6477 (let ((gnus-read-active-file t))
6478 (gnus-read-active-file))
6481 (setq arg (gnus-group-default-level arg t))
6482 (if (and gnus-read-active-file (not arg))
6484 (gnus-read-active-file)
6485 (gnus-get-unread-articles arg))
6486 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
6487 (gnus-get-unread-articles arg)))
6488 (run-hooks 'gnus-after-getting-new-news-hook)
6489 (gnus-group-list-groups))
6491 (defun gnus-group-get-new-news-this-group (&optional n)
6492 "Check for newly arrived news in the current group (and the N-1 next groups).
6493 The difference between N and the number of newsgroup checked is returned.
6494 If N is negative, this group and the N-1 previous groups will be checked."
6496 (let* ((groups (gnus-group-process-prefix n))
6497 (ret (if (numberp n) (- n (length groups)) 0))
6498 (beg (unless n (point)))
6500 (while (setq group (pop groups))
6501 (gnus-group-remove-mark group)
6502 (if (gnus-activate-group group 'scan)
6504 (gnus-get-unread-articles-in-group
6505 (gnus-get-info group) (gnus-active group) t)
6506 (unless (gnus-virtual-group-p group)
6507 (gnus-close-group group))
6508 (gnus-group-update-group group))
6509 (gnus-error 3 "%s error: %s" group (gnus-status-message group))))
6510 (when beg (goto-char beg))
6511 (when gnus-goto-next-group-when-activating
6512 (gnus-group-next-unread-group 1 t))
6513 (gnus-summary-position-point)
6516 (defun gnus-group-fetch-faq (group &optional faq-dir)
6517 "Fetch the FAQ for the current group."
6520 (gnus-group-real-name (gnus-group-group-name))
6521 (cond (current-prefix-arg
6523 "Faq dir: " (and (listp gnus-group-faq-directory)
6524 (mapcar (lambda (file) (list file))
6525 gnus-group-faq-directory)))))))
6527 (setq faq-dir (if (listp gnus-group-faq-directory)
6528 (car gnus-group-faq-directory)
6529 gnus-group-faq-directory)))
6530 (or group (error "No group name given"))
6531 (let ((file (concat (file-name-as-directory faq-dir)
6532 (gnus-group-real-name group))))
6533 (if (not (file-exists-p file))
6534 (error "No such file: %s" file)
6537 (defun gnus-group-describe-group (force &optional group)
6538 "Display a description of the current newsgroup."
6539 (interactive (list current-prefix-arg (gnus-group-group-name)))
6540 (and force (setq gnus-description-hashtb nil))
6541 (let ((method (gnus-find-method-for-group group))
6543 (or group (error "No group name given"))
6544 (and (or (and gnus-description-hashtb
6545 ;; We check whether this group's method has been
6546 ;; queried for a description file.
6548 (gnus-group-prefixed-name "" method)
6549 gnus-description-hashtb))
6550 (setq desc (gnus-group-get-description group))
6551 (gnus-read-descriptions-file method))
6553 (or desc (gnus-gethash group gnus-description-hashtb)
6554 "No description available")))))
6556 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6557 (defun gnus-group-describe-all-groups (&optional force)
6558 "Pop up a buffer with descriptions of all newsgroups."
6560 (and force (setq gnus-description-hashtb nil))
6561 (if (not (or gnus-description-hashtb
6562 (gnus-read-all-descriptions-files)))
6563 (error "Couldn't request descriptions file"))
6564 (let ((buffer-read-only nil)
6570 (insert (format " *: %-20s %s\n" (symbol-name group)
6571 (symbol-value group)))
6572 (gnus-add-text-properties
6573 b (1+ b) (list 'gnus-group group
6574 'gnus-unread t 'gnus-marked nil
6575 'gnus-level (1+ gnus-level-subscribed))))
6576 gnus-description-hashtb)
6577 (goto-char (point-min))
6578 (gnus-group-position-point)))
6580 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
6581 (defun gnus-group-apropos (regexp &optional search-description)
6582 "List all newsgroups that have names that match a regexp."
6583 (interactive "sGnus apropos (regexp): ")
6585 (obuf (current-buffer))
6587 ;; Go through all newsgroups that are known to Gnus.
6590 (and (symbol-name group)
6591 (string-match regexp (symbol-name group))
6592 (setq groups (cons (symbol-name group) groups))))
6594 ;; Also go through all descriptions that are known to Gnus.
6595 (when search-description
6598 (and (string-match regexp (symbol-value group))
6599 (gnus-active (symbol-name group))
6600 (setq groups (cons (symbol-name group) groups))))
6601 gnus-description-hashtb))
6603 (gnus-message 3 "No groups matched \"%s\"." regexp)
6604 ;; Print out all the groups.
6606 (pop-to-buffer "*Gnus Help*")
6607 (buffer-disable-undo (current-buffer))
6609 (setq groups (sort groups 'string<))
6611 ;; Groups may be entered twice into the list of groups.
6612 (if (not (string= (car groups) prev))
6614 (insert (setq prev (car groups)) "\n")
6615 (if (and gnus-description-hashtb
6616 (setq des (gnus-gethash (car groups)
6617 gnus-description-hashtb)))
6618 (insert " " des "\n"))))
6619 (setq groups (cdr groups)))
6620 (goto-char (point-min))))
6621 (pop-to-buffer obuf)))
6623 (defun gnus-group-description-apropos (regexp)
6624 "List all newsgroups that have names or descriptions that match a regexp."
6625 (interactive "sGnus description apropos (regexp): ")
6626 (if (not (or gnus-description-hashtb
6627 (gnus-read-all-descriptions-files)))
6628 (error "Couldn't request descriptions file"))
6629 (gnus-group-apropos regexp t))
6631 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6632 (defun gnus-group-list-matching (level regexp &optional all lowest)
6633 "List all groups with unread articles that match REGEXP.
6634 If the prefix LEVEL is non-nil, it should be a number that says which
6635 level to cut off listing groups.
6636 If ALL, also list groups with no unread articles.
6637 If LOWEST, don't list groups with level lower than LOWEST.
6639 This command may read the active file."
6640 (interactive "P\nsList newsgroups matching: ")
6641 ;; First make sure active file has been read.
6643 (> (prefix-numeric-value level) gnus-level-killed))
6644 (gnus-get-killed-groups))
6645 (gnus-group-prepare-flat (or level gnus-level-subscribed)
6646 all (or lowest 1) regexp)
6647 (goto-char (point-min))
6648 (gnus-group-position-point))
6650 (defun gnus-group-list-all-matching (level regexp &optional lowest)
6651 "List all groups that match REGEXP.
6652 If the prefix LEVEL is non-nil, it should be a number that says which
6653 level to cut off listing groups.
6654 If LOWEST, don't list groups with level lower than LOWEST."
6655 (interactive "P\nsList newsgroups matching: ")
6656 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
6658 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
6659 (defun gnus-group-save-newsrc (&optional force)
6660 "Save the Gnus startup files.
6661 If FORCE, force saving whether it is necessary or not."
6663 (gnus-save-newsrc-file force))
6665 (defun gnus-group-restart (&optional arg)
6666 "Force Gnus to read the .newsrc file."
6668 (when (gnus-yes-or-no-p
6669 (format "Are you sure you want to read %s? "
6670 gnus-current-startup-file))
6671 (gnus-save-newsrc-file)
6672 (gnus-setup-news 'force)
6673 (gnus-group-list-groups arg)))
6675 (defun gnus-group-read-init-file ()
6676 "Read the Gnus elisp init file."
6678 (gnus-read-init-file))
6680 (defun gnus-group-check-bogus-groups (&optional silent)
6681 "Check bogus newsgroups.
6682 If given a prefix, don't ask for confirmation before removing a bogus
6685 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
6686 (gnus-group-list-groups))
6688 (defun gnus-group-edit-global-kill (&optional article group)
6689 "Edit the global kill file.
6690 If GROUP, edit that local kill file instead."
6692 (setq gnus-current-kill-article article)
6693 (gnus-kill-file-edit-file group)
6696 (substitute-command-keys
6697 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
6698 (if group "local" "global")))))
6700 (defun gnus-group-edit-local-kill (article group)
6701 "Edit a local kill file."
6702 (interactive (list nil (gnus-group-group-name)))
6703 (gnus-group-edit-global-kill article group))
6705 (defun gnus-group-force-update ()
6706 "Update `.newsrc' file."
6708 (gnus-save-newsrc-file))
6710 (defun gnus-group-suspend ()
6711 "Suspend the current Gnus session.
6712 In fact, cleanup buffers except for group mode buffer.
6713 The hook gnus-suspend-gnus-hook is called before actually suspending."
6715 (run-hooks 'gnus-suspend-gnus-hook)
6716 ;; Kill Gnus buffers except for group mode buffer.
6717 (let ((group-buf (get-buffer gnus-group-buffer)))
6718 ;; Do this on a separate list in case the user does a ^G before we finish
6719 (let ((gnus-buffer-list
6720 (delq group-buf (delq gnus-dribble-buffer
6721 (append gnus-buffer-list nil)))))
6722 (while gnus-buffer-list
6723 (gnus-kill-buffer (car gnus-buffer-list))
6724 (setq gnus-buffer-list (cdr gnus-buffer-list))))
6727 (setq gnus-buffer-list (list group-buf))
6728 (bury-buffer group-buf)
6729 (delete-windows-on group-buf t)))))
6731 (defun gnus-group-clear-dribble ()
6732 "Clear all information from the dribble buffer."
6734 (gnus-dribble-clear)
6735 (gnus-message 7 "Cleared dribble buffer"))
6737 (defun gnus-group-exit ()
6738 "Quit reading news after updating .newsrc.eld and .newsrc.
6739 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6742 (or noninteractive ;For gnus-batch-kill
6743 (not gnus-interactive-exit) ;Without confirmation
6745 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
6746 (run-hooks 'gnus-exit-gnus-hook)
6747 ;; Offer to save data from non-quitted summary buffers.
6748 (gnus-offer-save-summaries)
6749 ;; Save the newsrc file(s).
6750 (gnus-save-newsrc-file)
6752 (gnus-close-backends)
6753 ;; Reset everything.
6755 ;; Allow the user to do things after cleaning up.
6756 (run-hooks 'gnus-after-exiting-gnus-hook)))
6758 (defun gnus-close-backends ()
6759 ;; Send a close request to all backends that support such a request.
6760 (let ((methods gnus-valid-select-methods)
6763 (if (fboundp (setq func (intern (concat (caar methods)
6764 "-request-close"))))
6766 (setq methods (cdr methods)))))
6768 (defun gnus-group-quit ()
6769 "Quit reading news without updating .newsrc.eld or .newsrc.
6770 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6772 (when (or noninteractive ;For gnus-batch-kill
6773 (zerop (buffer-size))
6774 (not (gnus-server-opened gnus-select-method))
6776 (not gnus-current-startup-file)
6778 (format "Quit reading news without saving %s? "
6779 (file-name-nondirectory gnus-current-startup-file))))
6780 (run-hooks 'gnus-exit-gnus-hook)
6781 (if gnus-use-full-window
6782 (delete-other-windows)
6783 (gnus-remove-some-windows))
6785 (gnus-close-backends)
6787 ;; Allow the user to do things after cleaning up.
6788 (run-hooks 'gnus-after-exiting-gnus-hook)))
6790 (defun gnus-offer-save-summaries ()
6791 "Offer to save all active summary buffers."
6793 (let ((buflist (buffer-list))
6795 ;; Go through all buffers and find all summaries.
6797 (and (setq bufname (buffer-name (car buflist)))
6798 (string-match "Summary" bufname)
6800 (set-buffer bufname)
6801 ;; We check that this is, indeed, a summary buffer.
6802 (and (eq major-mode 'gnus-summary-mode)
6803 ;; Also make sure this isn't bogus.
6804 gnus-newsgroup-prepared))
6805 (push bufname buffers))
6806 (setq buflist (cdr buflist)))
6807 ;; Go through all these summary buffers and offer to save them.
6810 "Update summary buffer %s? "
6811 (lambda (buf) (set-buffer buf) (gnus-summary-exit))
6814 (defun gnus-group-describe-briefly ()
6815 "Give a one line description of the group mode commands."
6817 (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")))
6819 (defun gnus-group-browse-foreign-server (method)
6820 "Browse a foreign news server.
6821 If called interactively, this function will ask for a select method
6822 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
6823 If not, METHOD should be a list where the first element is the method
6824 and the second element is the address."
6826 (list (let ((how (completing-read
6828 (append gnus-valid-select-methods gnus-server-alist)
6829 nil t (cons "nntp" 0) 'gnus-method-history)))
6830 ;; We either got a backend name or a virtual server name.
6831 ;; If the first, we also need an address.
6832 (if (assoc how gnus-valid-select-methods)
6834 ;; Suggested by mapjph@bath.ac.uk.
6837 (mapcar (lambda (server) (list server))
6838 gnus-secondary-servers)))
6839 ;; We got a server name, so we find the method.
6840 (gnus-server-to-method how)))))
6841 (gnus-browse-foreign-server method))
6845 ;;; Gnus summary mode
6848 (defvar gnus-summary-mode-map nil)
6850 (put 'gnus-summary-mode 'mode-class 'special)
6852 (unless gnus-summary-mode-map
6853 (setq gnus-summary-mode-map (make-keymap))
6854 (suppress-keymap gnus-summary-mode-map)
6856 ;; Non-orthogonal keys
6858 (gnus-define-keys gnus-summary-mode-map
6859 " " gnus-summary-next-page
6860 "\177" gnus-summary-prev-page
6861 [delete] gnus-summary-prev-page
6862 "\r" gnus-summary-scroll-up
6863 "n" gnus-summary-next-unread-article
6864 "p" gnus-summary-prev-unread-article
6865 "N" gnus-summary-next-article
6866 "P" gnus-summary-prev-article
6867 "\M-\C-n" gnus-summary-next-same-subject
6868 "\M-\C-p" gnus-summary-prev-same-subject
6869 "\M-n" gnus-summary-next-unread-subject
6870 "\M-p" gnus-summary-prev-unread-subject
6871 "." gnus-summary-first-unread-article
6872 "," gnus-summary-best-unread-article
6873 "\M-s" gnus-summary-search-article-forward
6874 "\M-r" gnus-summary-search-article-backward
6875 "<" gnus-summary-beginning-of-article
6876 ">" gnus-summary-end-of-article
6877 "j" gnus-summary-goto-article
6878 "^" gnus-summary-refer-parent-article
6879 "\M-^" gnus-summary-refer-article
6880 "u" gnus-summary-tick-article-forward
6881 "!" gnus-summary-tick-article-forward
6882 "U" gnus-summary-tick-article-backward
6883 "d" gnus-summary-mark-as-read-forward
6884 "D" gnus-summary-mark-as-read-backward
6885 "E" gnus-summary-mark-as-expirable
6886 "\M-u" gnus-summary-clear-mark-forward
6887 "\M-U" gnus-summary-clear-mark-backward
6888 "k" gnus-summary-kill-same-subject-and-select
6889 "\C-k" gnus-summary-kill-same-subject
6890 "\M-\C-k" gnus-summary-kill-thread
6891 "\M-\C-l" gnus-summary-lower-thread
6892 "e" gnus-summary-edit-article
6893 "#" gnus-summary-mark-as-processable
6894 "\M-#" gnus-summary-unmark-as-processable
6895 "\M-\C-t" gnus-summary-toggle-threads
6896 "\M-\C-s" gnus-summary-show-thread
6897 "\M-\C-h" gnus-summary-hide-thread
6898 "\M-\C-f" gnus-summary-next-thread
6899 "\M-\C-b" gnus-summary-prev-thread
6900 "\M-\C-u" gnus-summary-up-thread
6901 "\M-\C-d" gnus-summary-down-thread
6902 "&" gnus-summary-execute-command
6903 "c" gnus-summary-catchup-and-exit
6904 "\C-w" gnus-summary-mark-region-as-read
6905 "\C-t" gnus-summary-toggle-truncation
6906 "?" gnus-summary-mark-as-dormant
6907 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
6908 "\C-c\C-s\C-n" gnus-summary-sort-by-number
6909 "\C-c\C-s\C-a" gnus-summary-sort-by-author
6910 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
6911 "\C-c\C-s\C-d" gnus-summary-sort-by-date
6912 "\C-c\C-s\C-i" gnus-summary-sort-by-score
6913 "=" gnus-summary-expand-window
6914 "\C-x\C-s" gnus-summary-reselect-current-group
6915 "\M-g" gnus-summary-rescan-group
6916 "w" gnus-summary-stop-page-breaking
6917 "\C-c\C-r" gnus-summary-caesar-message
6918 "\M-t" gnus-summary-toggle-mime
6919 "f" gnus-summary-followup
6920 "F" gnus-summary-followup-with-original
6921 "C" gnus-summary-cancel-article
6922 "r" gnus-summary-reply
6923 "R" gnus-summary-reply-with-original
6924 "\C-c\C-f" gnus-summary-mail-forward
6925 "o" gnus-summary-save-article
6926 "\C-o" gnus-summary-save-article-mail
6927 "|" gnus-summary-pipe-output
6928 "\M-k" gnus-summary-edit-local-kill
6929 "\M-K" gnus-summary-edit-global-kill
6931 "\C-c\C-d" gnus-summary-describe-group
6932 "q" gnus-summary-exit
6933 "Q" gnus-summary-exit-no-update
6934 "\C-c\C-i" gnus-info-find-node
6935 gnus-mouse-2 gnus-mouse-pick-article
6936 "m" gnus-summary-mail-other-window
6937 "a" gnus-summary-post-news
6938 "x" gnus-summary-limit-to-unread
6939 "s" gnus-summary-isearch-article
6940 "t" gnus-article-hide-headers
6941 "g" gnus-summary-show-article
6942 "l" gnus-summary-goto-last-article
6943 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
6944 "\C-d" gnus-summary-enter-digest-group
6946 "*" gnus-cache-enter-article
6947 "\M-*" gnus-cache-remove-article
6948 "\M-&" gnus-summary-universal-argument
6949 "\C-l" gnus-recenter
6950 "I" gnus-summary-increase-score
6951 "L" gnus-summary-lower-score
6953 "V" gnus-summary-score-map
6954 "X" gnus-uu-extract-map
6955 "S" gnus-summary-send-map)
6957 ;; Sort of orthogonal keymap
6958 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
6959 "t" gnus-summary-tick-article-forward
6960 "!" gnus-summary-tick-article-forward
6961 "d" gnus-summary-mark-as-read-forward
6962 "r" gnus-summary-mark-as-read-forward
6963 "c" gnus-summary-clear-mark-forward
6964 " " gnus-summary-clear-mark-forward
6965 "e" gnus-summary-mark-as-expirable
6966 "x" gnus-summary-mark-as-expirable
6967 "?" gnus-summary-mark-as-dormant
6968 "b" gnus-summary-set-bookmark
6969 "B" gnus-summary-remove-bookmark
6970 "#" gnus-summary-mark-as-processable
6971 "\M-#" gnus-summary-unmark-as-processable
6972 "S" gnus-summary-limit-include-expunged
6973 "C" gnus-summary-catchup
6974 "H" gnus-summary-catchup-to-here
6975 "\C-c" gnus-summary-catchup-all
6976 "k" gnus-summary-kill-same-subject-and-select
6977 "K" gnus-summary-kill-same-subject
6978 "P" gnus-uu-mark-map)
6980 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mode-map)
6981 "c" gnus-summary-clear-above
6982 "u" gnus-summary-tick-above
6983 "m" gnus-summary-mark-above
6984 "k" gnus-summary-kill-below)
6986 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
6987 "/" gnus-summary-limit-to-subject
6988 "n" gnus-summary-limit-to-articles
6989 "w" gnus-summary-pop-limit
6990 "s" gnus-summary-limit-to-subject
6991 "a" gnus-summary-limit-to-author
6992 "u" gnus-summary-limit-to-unread
6993 "m" gnus-summary-limit-to-marks
6994 "v" gnus-summary-limit-to-score
6995 "D" gnus-summary-limit-include-dormant
6996 "d" gnus-summary-limit-exclude-dormant
6997 ;; "t" gnus-summary-limit-exclude-thread
6998 "E" gnus-summary-limit-include-expunged
6999 "c" gnus-summary-limit-exclude-childless-dormant
7000 "C" gnus-summary-limit-mark-excluded-as-read)
7002 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
7003 "n" gnus-summary-next-unread-article
7004 "p" gnus-summary-prev-unread-article
7005 "N" gnus-summary-next-article
7006 "P" gnus-summary-prev-article
7007 "\C-n" gnus-summary-next-same-subject
7008 "\C-p" gnus-summary-prev-same-subject
7009 "\M-n" gnus-summary-next-unread-subject
7010 "\M-p" gnus-summary-prev-unread-subject
7011 "f" gnus-summary-first-unread-article
7012 "b" gnus-summary-best-unread-article
7013 "j" gnus-summary-goto-article
7014 "g" gnus-summary-goto-subject
7015 "l" gnus-summary-goto-last-article
7016 "p" gnus-summary-pop-article)
7018 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
7019 "k" gnus-summary-kill-thread
7020 "l" gnus-summary-lower-thread
7021 "i" gnus-summary-raise-thread
7022 "T" gnus-summary-toggle-threads
7023 "t" gnus-summary-rethread-current
7024 "^" gnus-summary-reparent-thread
7025 "s" gnus-summary-show-thread
7026 "S" gnus-summary-show-all-threads
7027 "h" gnus-summary-hide-thread
7028 "H" gnus-summary-hide-all-threads
7029 "n" gnus-summary-next-thread
7030 "p" gnus-summary-prev-thread
7031 "u" gnus-summary-up-thread
7032 "o" gnus-summary-top-thread
7033 "d" gnus-summary-down-thread
7034 "#" gnus-uu-mark-thread
7035 "\M-#" gnus-uu-unmark-thread)
7037 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
7038 "c" gnus-summary-catchup-and-exit
7039 "C" gnus-summary-catchup-all-and-exit
7040 "E" gnus-summary-exit-no-update
7041 "Q" gnus-summary-exit
7042 "Z" gnus-summary-exit
7043 "n" gnus-summary-catchup-and-goto-next-group
7044 "R" gnus-summary-reselect-current-group
7045 "G" gnus-summary-rescan-group
7046 "N" gnus-summary-next-group
7047 "P" gnus-summary-prev-group)
7049 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
7050 " " gnus-summary-next-page
7051 "n" gnus-summary-next-page
7052 "\177" gnus-summary-prev-page
7053 [delete] gnus-summary-prev-page
7054 "p" gnus-summary-prev-page
7055 "\r" gnus-summary-scroll-up
7056 "<" gnus-summary-beginning-of-article
7057 ">" gnus-summary-end-of-article
7058 "b" gnus-summary-beginning-of-article
7059 "e" gnus-summary-end-of-article
7060 "^" gnus-summary-refer-parent-article
7061 "r" gnus-summary-refer-parent-article
7062 "R" gnus-summary-refer-references
7063 "g" gnus-summary-show-article
7064 "s" gnus-summary-isearch-article)
7066 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
7067 "b" gnus-article-add-buttons
7068 "B" gnus-article-add-buttons-to-head
7069 "o" gnus-article-treat-overstrike
7070 ;; "w" gnus-article-word-wrap
7071 "w" gnus-article-fill-cited-article
7072 "c" gnus-article-remove-cr
7073 "L" gnus-article-remove-trailing-blank-lines
7074 "q" gnus-article-de-quoted-unreadable
7075 "f" gnus-article-display-x-face
7076 "l" gnus-summary-stop-page-breaking
7077 "r" gnus-summary-caesar-message
7078 "t" gnus-article-hide-headers
7079 "v" gnus-summary-verbose-headers
7080 "m" gnus-summary-toggle-mime)
7082 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
7083 "a" gnus-article-hide
7084 "h" gnus-article-hide-headers
7085 "b" gnus-article-hide-boring-headers
7086 "s" gnus-article-hide-signature
7087 "c" gnus-article-hide-citation
7088 "p" gnus-article-hide-pgp
7089 "\C-c" gnus-article-hide-citation-maybe)
7091 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
7092 "a" gnus-article-highlight
7093 "h" gnus-article-highlight-headers
7094 "c" gnus-article-highlight-citation
7095 "s" gnus-article-highlight-signature)
7097 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
7098 "z" gnus-article-date-ut
7099 "u" gnus-article-date-ut
7100 "l" gnus-article-date-local
7101 "e" gnus-article-date-lapsed
7102 "o" gnus-article-date-original)
7104 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
7106 "f" gnus-summary-fetch-faq
7107 "d" gnus-summary-describe-group
7108 "h" gnus-summary-describe-briefly
7109 "i" gnus-info-find-node)
7111 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
7112 "e" gnus-summary-expire-articles
7113 "\M-\C-e" gnus-summary-expire-articles-now
7114 "\177" gnus-summary-delete-article
7115 [delete] gnus-summary-delete-article
7116 "m" gnus-summary-move-article
7117 "r" gnus-summary-respool-article
7118 "w" gnus-summary-edit-article
7119 "c" gnus-summary-copy-article
7120 "B" gnus-summary-crosspost-article
7121 "q" gnus-summary-respool-query
7122 "i" gnus-summary-import-article)
7124 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
7125 "o" gnus-summary-save-article
7126 "m" gnus-summary-save-article-mail
7127 "r" gnus-summary-save-article-rmail
7128 "f" gnus-summary-save-article-file
7129 "b" gnus-summary-save-article-body-file
7130 "h" gnus-summary-save-article-folder
7131 "v" gnus-summary-save-article-vm
7132 "p" gnus-summary-pipe-output
7133 "s" gnus-soup-add-article)
7138 (defun gnus-summary-mode (&optional group)
7139 "Major mode for reading articles.
7141 All normal editing commands are switched off.
7142 \\<gnus-summary-mode-map>
7143 Each line in this buffer represents one article. To read an
7144 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
7145 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
7148 You can also post articles and send mail from this buffer. To
7149 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
7150 of an article, type `\\[gnus-summary-reply]'.
7152 There are approx. one gazillion commands you can execute in this
7153 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
7155 The following commands are available:
7157 \\{gnus-summary-mode-map}"
7159 (when (and menu-bar-mode
7160 (gnus-visual-p 'summary-menu 'menu))
7161 (gnus-summary-make-menu-bar))
7162 (kill-all-local-variables)
7163 (gnus-summary-make-local-variables)
7164 (gnus-make-thread-indent-array)
7165 (gnus-simplify-mode-line)
7166 (setq major-mode 'gnus-summary-mode)
7167 (setq mode-name "Summary")
7168 (make-local-variable 'minor-mode-alist)
7169 (use-local-map gnus-summary-mode-map)
7170 (buffer-disable-undo (current-buffer))
7171 (setq buffer-read-only t) ;Disable modification
7172 (setq truncate-lines t)
7173 (setq selective-display t)
7174 (setq selective-display-ellipses t) ;Display `...'
7175 (setq buffer-display-table gnus-summary-display-table)
7176 (setq gnus-newsgroup-name group)
7177 (make-local-variable 'gnus-summary-line-format)
7178 (make-local-variable 'gnus-summary-line-format-spec)
7179 (make-local-variable 'gnus-summary-mark-positions)
7180 (run-hooks 'gnus-summary-mode-hook))
7182 (defun gnus-summary-make-local-variables ()
7183 "Make all the local summary buffer variables."
7184 (let ((locals gnus-summary-local-variables)
7186 (while (setq local (pop locals))
7189 (if (eq (cdr local) 'global)
7190 ;; Copy the global value of the variable.
7191 (setq global (symbol-value (car local)))
7192 ;; Use the value from the list.
7193 (setq global (eval (cdr local))))
7194 (make-local-variable (car local))
7195 (set (car local) global))
7196 ;; Simple nil-valued local variable.
7197 (make-local-variable local)
7200 (defun gnus-summary-make-display-table ()
7201 ;; Change the display table. Odd characters have a tendency to mess
7202 ;; up nicely formatted displays - we make all possible glyphs
7203 ;; display only a single character.
7205 ;; We start from the standard display table, if any.
7206 (setq gnus-summary-display-table
7207 (or (copy-sequence standard-display-table)
7208 (make-display-table)))
7209 ;; Nix out all the control chars...
7211 (while (>= (setq i (1- i)) 0)
7212 (aset gnus-summary-display-table i [??])))
7213 ;; ... but not newline and cr, of course. (cr is necessary for the
7214 ;; selective display).
7215 (aset gnus-summary-display-table ?\n nil)
7216 (aset gnus-summary-display-table ?\r nil)
7217 ;; We nix out any glyphs over 126 that are not set already.
7219 (while (>= (setq i (1- i)) 127)
7220 ;; Only modify if the entry is nil.
7221 (or (aref gnus-summary-display-table i)
7222 (aset gnus-summary-display-table i [??])))))
7224 (defun gnus-summary-clear-local-variables ()
7225 (let ((locals gnus-summary-local-variables))
7227 (if (consp (car locals))
7228 (and (vectorp (caar locals))
7229 (set (caar locals) nil))
7230 (and (vectorp (car locals))
7231 (set (car locals) nil)))
7232 (setq locals (cdr locals)))))
7234 ;; Summary data functions.
7236 (defmacro gnus-data-number (data)
7239 (defmacro gnus-data-set-number (data number)
7240 `(setcar ,data ,number))
7242 (defmacro gnus-data-mark (data)
7245 (defmacro gnus-data-set-mark (data mark)
7246 `(setcar (nthcdr 1 ,data) ,mark))
7248 (defmacro gnus-data-pos (data)
7251 (defmacro gnus-data-set-pos (data pos)
7252 `(setcar (nthcdr 2 ,data) ,pos))
7254 (defmacro gnus-data-header (data)
7257 (defmacro gnus-data-level (data)
7260 (defmacro gnus-data-unread-p (data)
7261 `(= (nth 1 ,data) gnus-unread-mark))
7263 (defmacro gnus-data-pseudo-p (data)
7264 `(consp (nth 3 ,data)))
7266 (defmacro gnus-data-find (number)
7267 `(assq ,number gnus-newsgroup-data))
7269 (defmacro gnus-data-find-list (number &optional data)
7270 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
7271 (memq (assq ,number bdata)
7274 (defmacro gnus-data-make (number mark pos header level)
7275 `(list ,number ,mark ,pos ,header ,level))
7277 (defun gnus-data-enter (after-article number mark pos header level offset)
7278 (let ((data (gnus-data-find-list after-article)))
7279 (or data (error "No such article: %d" after-article))
7280 (setcdr data (cons (gnus-data-make number mark pos header level)
7282 (setq gnus-newsgroup-data-reverse nil)
7283 (gnus-data-update-list (cddr data) offset)))
7285 (defun gnus-data-enter-list (after-article list &optional offset)
7287 (let ((data (and after-article (gnus-data-find-list after-article)))
7289 (or data (not after-article) (error "No such article: %d" after-article))
7290 ;; Find the last element in the list to be spliced into the main
7293 (setq list (cdr list)))
7296 (setcdr list gnus-newsgroup-data)
7297 (setq gnus-newsgroup-data ilist)
7298 (and offset (gnus-data-update-list (cdr list) offset)))
7299 (setcdr list (cdr data))
7301 (and offset (gnus-data-update-list (cdr data) offset)))
7302 (setq gnus-newsgroup-data-reverse nil))))
7304 (defun gnus-data-remove (article &optional offset)
7305 (let ((data gnus-newsgroup-data))
7306 (if (= (gnus-data-number (car data)) article)
7307 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
7308 gnus-newsgroup-data-reverse nil)
7310 (and (= (gnus-data-number (cadr data)) article)
7312 (setcdr data (cddr data))
7313 (and offset (gnus-data-update-list (cdr data) offset))
7315 gnus-newsgroup-data-reverse nil)))
7316 (setq data (cdr data))))))
7318 (defmacro gnus-data-list (backward)
7320 (or gnus-newsgroup-data-reverse
7321 (setq gnus-newsgroup-data-reverse
7322 (reverse gnus-newsgroup-data)))
7323 gnus-newsgroup-data))
7325 (defun gnus-data-update-list (data offset)
7326 "Add OFFSET to the POS of all data entries in DATA."
7328 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
7329 (setq data (cdr data))))
7331 (defun gnus-data-compute-positions ()
7332 "Compute the positions of all articles."
7333 (let ((data gnus-newsgroup-data)
7336 (when (setq pos (text-property-any
7337 (point-min) (point-max)
7338 'gnus-number (gnus-data-number (car data))))
7339 (gnus-data-set-pos (car data) (+ pos 3)))
7340 (setq data (cdr data)))))
7342 (defun gnus-summary-article-pseudo-p (article)
7343 "Say whether this article is a pseudo article or not."
7344 (not (vectorp (gnus-data-header (gnus-data-find article)))))
7346 (defun gnus-article-parent-p (number)
7347 "Say whether this article is a parent or not."
7348 (let ((data (gnus-data-find-list number)))
7349 (and (cdr data) ; There has to be an article after...
7350 (< (gnus-data-level (car data)) ; And it has to have a higher level.
7351 (gnus-data-level (nth 1 data))))))
7353 (defun gnus-article-children (number)
7354 "Return a list of all children to NUMBER."
7355 (let* ((data (gnus-data-find-list number))
7356 (level (gnus-data-level (car data)))
7358 (setq data (cdr data))
7360 (= (gnus-data-level (car data)) (1+ level)))
7361 (push (gnus-data-number (car data)) children)
7362 (setq data (cdr data)))
7365 (defmacro gnus-summary-skip-intangible ()
7366 "If the current article is intangible, then jump to a different article."
7367 '(let ((to (get-text-property (point) 'gnus-intangible)))
7368 (and to (gnus-summary-goto-subject to))))
7370 (defmacro gnus-summary-article-intangible-p ()
7371 "Say whether this article is intangible or not."
7372 '(get-text-property (point) 'gnus-intangible))
7374 ;; Some summary mode macros.
7376 (defmacro gnus-summary-article-number ()
7377 "The article number of the article on the current line.
7378 If there isn's an article number here, then we return the current
7381 (gnus-summary-skip-intangible)
7382 (or (get-text-property (point) 'gnus-number)
7383 (gnus-summary-last-subject))))
7385 (defmacro gnus-summary-article-header (&optional number)
7386 `(gnus-data-header (gnus-data-find
7387 ,(or number '(gnus-summary-article-number)))))
7389 (defmacro gnus-summary-thread-level (&optional number)
7390 `(if (and (eq gnus-summary-make-false-root 'dummy)
7391 (get-text-property (point) 'gnus-intangible))
7393 (gnus-data-level (gnus-data-find
7394 ,(or number '(gnus-summary-article-number))))))
7396 (defmacro gnus-summary-article-mark (&optional number)
7397 `(gnus-data-mark (gnus-data-find
7398 ,(or number '(gnus-summary-article-number)))))
7400 (defmacro gnus-summary-article-pos (&optional number)
7401 `(gnus-data-pos (gnus-data-find
7402 ,(or number '(gnus-summary-article-number)))))
7404 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
7405 (defmacro gnus-summary-article-subject (&optional number)
7406 "Return current subject string or nil if nothing."
7409 `(gnus-data-header (assq ,number gnus-newsgroup-data))
7410 '(gnus-data-header (assq (gnus-summary-article-number)
7411 gnus-newsgroup-data)))))
7414 (mail-header-subject headers))))
7416 (defmacro gnus-summary-article-score (&optional number)
7417 "Return current article score."
7418 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
7419 gnus-newsgroup-scored))
7420 gnus-summary-default-score 0))
7422 (defun gnus-summary-article-children (&optional number)
7423 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
7424 (level (gnus-data-level (car data)))
7426 (while (and (setq data (cdr data))
7427 (> (setq l (gnus-data-level (car data))) level))
7428 (and (= (1+ level) l)
7429 (setq children (cons (gnus-data-number (car data))
7431 (nreverse children)))
7433 (defun gnus-summary-article-parent (&optional number)
7434 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
7435 (gnus-data-list t)))
7436 (level (gnus-data-level (car data))))
7438 () ; This is a root.
7439 ;; We search until we find an article with a level less than
7440 ;; this one. That function has to be the parent.
7441 (while (and (setq data (cdr data))
7442 (not (< (gnus-data-level (car data)) level))))
7443 (and data (gnus-data-number (car data))))))
7445 (defun gnus-unread-mark-p (mark)
7446 "Say whether MARK is the unread mark."
7447 (= mark gnus-unread-mark))
7449 (defun gnus-read-mark-p (mark)
7450 "Say whether MARK is one of the marks that mark as read.
7451 This is all marks except unread, ticked, dormant, and expirable."
7452 (not (or (= mark gnus-unread-mark)
7453 (= mark gnus-ticked-mark)
7454 (= mark gnus-dormant-mark)
7455 (= mark gnus-expirable-mark))))
7457 ;; Saving hidden threads.
7459 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
7460 (put 'gnus-save-hidden-threads 'lisp-indent-hook 0)
7461 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
7463 (defmacro gnus-save-hidden-threads (&rest forms)
7464 "Save hidden threads, eval FORMS, and restore the hidden threads."
7465 (let ((config (make-symbol "config")))
7466 `(let ((,config (gnus-hidden-threads-configuration)))
7470 (gnus-restore-hidden-threads-configuration ,config)))))
7472 (defun gnus-hidden-threads-configuration ()
7473 "Return the current hidden threads configuration."
7476 (goto-char (point-min))
7477 (while (search-forward "\r" nil t)
7478 (push (1- (point)) config))
7481 (defun gnus-restore-hidden-threads-configuration (config)
7482 "Restore hidden threads configuration from CONFIG."
7483 (let (point buffer-read-only)
7484 (while (setq point (pop config))
7485 (when (and (< point (point-max))
7487 (= (following-char) ?\n))
7488 (subst-char-in-region point (1+ point) ?\n ?\r)))))
7490 ;; Various summary mode internalish functions.
7492 (defun gnus-mouse-pick-article (e)
7495 (gnus-summary-next-page nil t))
7497 (defun gnus-summary-setup-buffer (group)
7498 "Initialize summary buffer."
7499 (let ((buffer (concat "*Summary " group "*")))
7500 (if (get-buffer buffer)
7503 (setq gnus-summary-buffer (current-buffer))
7504 (not gnus-newsgroup-prepared))
7505 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
7506 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
7507 (gnus-add-current-to-buffer-list)
7508 (gnus-summary-mode group)
7510 (gnus-carpal-setup-buffer 'summary))
7511 (unless gnus-single-article-buffer
7512 (make-local-variable 'gnus-article-buffer)
7513 (make-local-variable 'gnus-article-current)
7514 (make-local-variable 'gnus-original-article-buffer))
7515 (setq gnus-newsgroup-name group)
7518 (defun gnus-set-global-variables ()
7519 ;; Set the global equivalents of the summary buffer-local variables
7520 ;; to the latest values they had. These reflect the summary buffer
7521 ;; that was in action when the last article was fetched.
7522 (when (eq major-mode 'gnus-summary-mode)
7523 (setq gnus-summary-buffer (current-buffer))
7524 (let ((name gnus-newsgroup-name)
7525 (marked gnus-newsgroup-marked)
7526 (unread gnus-newsgroup-unreads)
7527 (headers gnus-current-headers)
7528 (data gnus-newsgroup-data)
7529 (summary gnus-summary-buffer)
7530 (article-buffer gnus-article-buffer)
7531 (original gnus-original-article-buffer)
7532 (gac gnus-article-current)
7533 (score-file gnus-current-score-file))
7535 (set-buffer gnus-group-buffer)
7536 (setq gnus-newsgroup-name name)
7537 (setq gnus-newsgroup-marked marked)
7538 (setq gnus-newsgroup-unreads unread)
7539 (setq gnus-current-headers headers)
7540 (setq gnus-newsgroup-data data)
7541 (setq gnus-article-current gac)
7542 (setq gnus-summary-buffer summary)
7543 (setq gnus-article-buffer article-buffer)
7544 (setq gnus-original-article-buffer original)
7545 (setq gnus-current-score-file score-file)))))
7547 (defun gnus-summary-last-article-p (&optional article)
7548 "Return whether ARTICLE is the last article in the buffer."
7549 (if (not (setq article (or article (gnus-summary-article-number))))
7550 t ; All non-existant numbers are the last article. :-)
7551 (not (cdr (gnus-data-find-list article)))))
7553 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
7554 "Insert a dummy root in the summary buffer."
7556 (gnus-add-text-properties
7557 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
7558 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
7560 (defun gnus-make-thread-indent-array ()
7562 (unless (and gnus-thread-indent-array
7563 (= gnus-thread-indent-level gnus-thread-indent-array-level))
7564 (setq gnus-thread-indent-array (make-vector 201 "")
7565 gnus-thread-indent-array-level gnus-thread-indent-level)
7567 (aset gnus-thread-indent-array n
7568 (make-string (* n gnus-thread-indent-level) ? ))
7571 (defun gnus-summary-insert-line
7572 (gnus-tmp-header gnus-tmp-level gnus-tmp-current gnus-tmp-unread
7573 gnus-tmp-replied gnus-tmp-expirable gnus-tmp-subject-or-nil
7574 &optional gnus-tmp-dummy gnus-tmp-score gnus-tmp-process)
7575 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
7576 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
7577 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
7578 (gnus-tmp-score-char
7579 (if (or (null gnus-summary-default-score)
7580 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
7581 gnus-summary-zcore-fuzz)) ?
7582 (if (< gnus-tmp-score gnus-summary-default-score)
7583 gnus-score-below-mark gnus-score-over-mark)))
7584 (gnus-tmp-replied (cond (gnus-tmp-process gnus-process-mark)
7585 ((memq gnus-tmp-current gnus-newsgroup-cached)
7587 (gnus-tmp-replied gnus-replied-mark)
7588 ((memq gnus-tmp-current gnus-newsgroup-saved)
7590 (t gnus-unread-mark)))
7591 (gnus-tmp-from (mail-header-from gnus-tmp-header))
7594 ((string-match "(.+)" gnus-tmp-from)
7595 (substring gnus-tmp-from
7596 (1+ (match-beginning 0)) (1- (match-end 0))))
7597 ((string-match "<[^>]+> *$" gnus-tmp-from)
7598 (let ((beg (match-beginning 0)))
7599 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
7600 (substring gnus-tmp-from (1+ (match-beginning 0))
7601 (1- (match-end 0))))
7602 (substring gnus-tmp-from 0 beg))))
7604 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
7605 (gnus-tmp-number (mail-header-number gnus-tmp-header))
7606 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
7607 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
7608 (buffer-read-only nil))
7609 (when (string= gnus-tmp-name "")
7610 (setq gnus-tmp-name gnus-tmp-from))
7611 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
7612 (gnus-put-text-property
7614 (progn (eval gnus-summary-line-format-spec) (point))
7615 'gnus-number gnus-tmp-number)
7616 (when (gnus-visual-p 'summary-highlight 'highlight)
7618 (run-hooks 'gnus-summary-update-hook)
7621 (defun gnus-summary-update-line (&optional dont-update)
7622 ;; Update summary line after change.
7623 (when (and gnus-summary-default-score
7624 (not gnus-summary-inhibit-highlight))
7625 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
7626 (article (gnus-summary-article-number))
7627 (score (gnus-summary-article-score article)))
7629 (if (and gnus-summary-mark-below
7630 (< (gnus-summary-article-score)
7631 gnus-summary-mark-below))
7632 ;; This article has a low score, so we mark it as read.
7633 (when (memq article gnus-newsgroup-unreads)
7634 (gnus-summary-mark-article-as-read gnus-low-score-mark))
7635 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
7636 ;; This article was previously marked as read on account
7637 ;; of a low score, but now it has risen, so we mark it as
7639 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
7640 (gnus-summary-update-mark
7641 (if (or (null gnus-summary-default-score)
7642 (<= (abs (- score gnus-summary-default-score))
7643 gnus-summary-zcore-fuzz)) ?
7644 (if (< score gnus-summary-default-score)
7645 gnus-score-below-mark gnus-score-over-mark)) 'score))
7646 ;; Do visual highlighting.
7647 (when (gnus-visual-p 'summary-highlight 'highlight)
7648 (run-hooks 'gnus-summary-update-hook)))))
7650 (defvar gnus-tmp-new-adopts nil)
7652 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
7653 ;; Sum up all elements (and sub-elements) in a list.
7655 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
7657 ((and (consp thread) (cdr thread))
7660 'gnus-summary-number-of-articles-in-thread (cdr thread))))
7663 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
7666 (when (and level (zerop level) gnus-tmp-new-adopts)
7669 'gnus-summary-number-of-articles-in-thread
7670 gnus-tmp-new-adopts))))
7672 (if (> number 1) gnus-not-empty-thread-mark
7673 gnus-empty-thread-mark)
7676 (defun gnus-summary-set-local-parameters (group)
7677 "Go through the local params of GROUP and set all variable specs in that list."
7678 (let ((params (gnus-info-params (gnus-get-info group)))
7681 (setq elem (car params)
7682 params (cdr params))
7683 (and (consp elem) ; Has to be a cons.
7684 (consp (cdr elem)) ; The cdr has to be a list.
7685 (symbolp (car elem)) ; Has to be a symbol in there.
7686 (not (memq (car elem)
7687 '(quit-config to-address to-list to-group)))
7688 (progn ; So we set it.
7689 (make-local-variable (car elem))
7690 (set (car elem) (eval (nth 1 elem))))))))
7692 (defun gnus-summary-read-group (group &optional show-all no-article
7693 kill-buffer no-display)
7694 "Start reading news in newsgroup GROUP.
7695 If SHOW-ALL is non-nil, already read articles are also listed.
7696 If NO-ARTICLE is non-nil, no article is selected initially.
7697 If NO-DISPLAY, don't generate a summary buffer."
7698 (gnus-message 5 "Retrieving newsgroup: %s..." group)
7699 (let* ((new-group (gnus-summary-setup-buffer group))
7700 (quit-config (gnus-group-quit-config group))
7701 (did-select (and new-group (gnus-select-newsgroup group show-all))))
7703 ;; This summary buffer exists already, so we just select it.
7705 (gnus-set-global-variables)
7707 (gnus-kill-or-deaden-summary kill-buffer))
7708 (gnus-configure-windows 'summary 'force)
7709 (gnus-set-mode-line 'summary)
7710 (gnus-summary-position-point)
7713 ;; We couldn't select this group.
7715 (when (and (eq major-mode 'gnus-summary-mode)
7716 (not (equal (current-buffer) kill-buffer)))
7717 (kill-buffer (current-buffer))
7718 (if (not quit-config)
7720 (set-buffer gnus-group-buffer)
7721 (gnus-group-jump-to-group group)
7722 (gnus-group-next-unread-group 1))
7723 (if (not (buffer-name (car quit-config)))
7724 (gnus-configure-windows 'group 'force)
7725 (set-buffer (car quit-config))
7726 (and (eq major-mode 'gnus-summary-mode)
7727 (gnus-set-global-variables))
7728 (gnus-configure-windows (cdr quit-config)))))
7729 (gnus-message 3 "Can't select group")
7731 ;; The user did a `C-g' while prompting for number of articles,
7732 ;; so we exit this group.
7733 ((eq did-select 'quit)
7734 (and (eq major-mode 'gnus-summary-mode)
7735 (not (equal (current-buffer) kill-buffer))
7736 (kill-buffer (current-buffer)))
7738 (gnus-kill-or-deaden-summary kill-buffer))
7739 (if (not quit-config)
7741 (set-buffer gnus-group-buffer)
7742 (gnus-group-jump-to-group group)
7743 (gnus-group-next-unread-group 1)
7744 (gnus-configure-windows 'group 'force))
7745 (if (not (buffer-name (car quit-config)))
7746 (gnus-configure-windows 'group 'force)
7747 (set-buffer (car quit-config))
7748 (and (eq major-mode 'gnus-summary-mode)
7749 (gnus-set-global-variables))
7750 (gnus-configure-windows (cdr quit-config))))
7751 ;; Finally signal the quit.
7753 ;; The group was successfully selected.
7755 (gnus-set-global-variables)
7756 ;; Save the active value in effect when the group was entered.
7757 (setq gnus-newsgroup-active
7759 (gnus-active gnus-newsgroup-name)))
7760 ;; You can change the summary buffer in some way with this hook.
7761 (run-hooks 'gnus-select-group-hook)
7762 ;; Set any local variables in the group parameters.
7763 (gnus-summary-set-local-parameters gnus-newsgroup-name)
7764 (gnus-update-format-specifications)
7765 ;; Do score processing.
7766 (when gnus-use-scoring
7767 (gnus-possibly-score-headers))
7768 ;; Check whether to fill in the gaps in the threads.
7769 (when gnus-build-sparse-threads
7770 (gnus-build-sparse-threads))
7771 ;; Find the initial limit.
7772 (if gnus-show-threads
7774 (let ((gnus-newsgroup-dormant nil))
7775 (gnus-summary-initial-limit show-all))
7776 (gnus-summary-initial-limit show-all))
7777 (setq gnus-newsgroup-limit
7779 (lambda (header) (mail-header-number header))
7780 gnus-newsgroup-headers)))
7781 ;; Generate the summary buffer.
7783 (gnus-summary-prepare))
7784 (when gnus-use-trees
7785 (gnus-tree-open group)
7786 (setq gnus-summary-highlight-line-function
7787 'gnus-tree-highlight-article))
7788 ;; If the summary buffer is empty, but there are some low-scored
7789 ;; articles or some excluded dormants, we include these in the
7791 (when (and (zerop (buffer-size))
7793 (cond (gnus-newsgroup-dormant
7794 (gnus-summary-limit-include-dormant))
7795 ((and gnus-newsgroup-scored show-all)
7796 (gnus-summary-limit-include-expunged))))
7797 ;; Function `gnus-apply-kill-file' must be called in this hook.
7798 (run-hooks 'gnus-apply-kill-hook)
7799 (if (and (zerop (buffer-size))
7802 ;; This newsgroup is empty.
7803 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
7804 (gnus-message 6 "No unread news")
7806 (gnus-kill-or-deaden-summary kill-buffer))
7807 ;; Return nil from this function.
7809 ;; Hide conversation thread subtrees. We cannot do this in
7810 ;; gnus-summary-prepare-hook since kill processing may not
7811 ;; work with hidden articles.
7812 (and gnus-show-threads
7813 gnus-thread-hide-subtree
7814 (gnus-summary-hide-all-threads))
7815 ;; Show first unread article if requested.
7816 (if (and (not no-article)
7818 gnus-newsgroup-unreads
7819 gnus-auto-select-first)
7820 (unless (if (eq gnus-auto-select-first 'best)
7821 (gnus-summary-best-unread-article)
7822 (gnus-summary-first-unread-article))
7823 (gnus-configure-windows 'summary))
7824 ;; Don't select any articles, just move point to the first
7825 ;; article in the group.
7826 (goto-char (point-min))
7827 (gnus-summary-position-point)
7828 (gnus-set-mode-line 'summary)
7829 (gnus-configure-windows 'summary 'force))
7830 ;; If we are in async mode, we send some info to the backend.
7831 (when gnus-newsgroup-async
7832 (gnus-request-asynchronous gnus-newsgroup-name gnus-newsgroup-data))
7834 (gnus-kill-or-deaden-summary kill-buffer))
7835 (when (get-buffer-window gnus-group-buffer t)
7836 ;; Gotta use windows, because recenter does wierd stuff if
7837 ;; the current buffer ain't the displayed window.
7838 (let ((owin (selected-window)))
7839 (select-window (get-buffer-window gnus-group-buffer t))
7840 (when (gnus-group-goto-group group)
7842 (select-window owin))))
7843 ;; Mark this buffer as "prepared".
7844 (setq gnus-newsgroup-prepared t)
7847 (defun gnus-summary-prepare ()
7848 "Generate the summary buffer."
7849 (let ((buffer-read-only nil))
7851 (setq gnus-newsgroup-data nil
7852 gnus-newsgroup-data-reverse nil)
7853 (run-hooks 'gnus-summary-generate-hook)
7854 ;; Generate the buffer, either with threads or without.
7855 (when gnus-newsgroup-headers
7856 (gnus-summary-prepare-threads
7857 (if gnus-show-threads
7858 (gnus-sort-gathered-threads
7859 (funcall gnus-summary-thread-gathering-function
7861 (gnus-cut-threads (gnus-make-threads)))))
7862 ;; Unthreaded display.
7863 (gnus-sort-articles gnus-newsgroup-headers))))
7864 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
7865 ;; Call hooks for modifying summary buffer.
7866 (goto-char (point-min))
7867 (run-hooks 'gnus-summary-prepare-hook)))
7869 (defun gnus-gather-threads-by-subject (threads)
7870 "Gather threads by looking at Subject headers."
7871 (if (not gnus-summary-make-false-root)
7873 (let ((hashtb (gnus-make-hashtable 1023))
7876 subject hthread whole-subject)
7878 (setq whole-subject (mail-header-subject (caar threads)))
7881 ;; Truncate the subject.
7882 ((numberp gnus-summary-gather-subject-limit)
7883 (setq subject (gnus-simplify-subject-re whole-subject))
7884 (if (> (length subject) gnus-summary-gather-subject-limit)
7885 (substring subject 0 gnus-summary-gather-subject-limit)
7887 ;; Fuzzily simplify it.
7888 ((eq 'fuzzy gnus-summary-gather-subject-limit)
7889 (gnus-simplify-subject-fuzzy whole-subject))
7890 ;; Just remove the leading "Re:".
7892 (gnus-simplify-subject-re whole-subject))))
7894 (if (and gnus-summary-gather-exclude-subject
7895 (string-match gnus-summary-gather-exclude-subject
7897 () ; We don't want to do anything with this article.
7898 ;; We simplify the subject before looking it up in the
7901 (if (setq hthread (gnus-gethash subject hashtb))
7903 ;; We enter a dummy root into the thread, if we
7904 ;; haven't done that already.
7905 (unless (stringp (caar hthread))
7906 (setcar hthread (list whole-subject (car hthread))))
7907 ;; We add this new gathered thread to this gathered
7909 (setcdr (car hthread)
7910 (nconc (cdar hthread) (list (car threads))))
7911 ;; Remove it from the list of threads.
7912 (setcdr prev (cdr threads))
7913 (setq threads prev))
7914 ;; Enter this thread into the hash table.
7915 (gnus-sethash subject threads hashtb)))
7917 (setq threads (cdr threads)))
7920 (defun gnus-gather-threads-by-references (threads)
7921 "Gather threads by looking at References headers."
7922 (let ((idhashtb (gnus-make-hashtable 1023))
7923 (thhashtb (gnus-make-hashtable 1023))
7926 ids references id gthread gid entered)
7928 (when (setq references (mail-header-references (caar threads)))
7929 (setq id (mail-header-id (caar threads)))
7930 (setq ids (gnus-split-references references))
7933 (if (not (setq gid (gnus-gethash (car ids) idhashtb)))
7935 (gnus-sethash (car ids) id idhashtb)
7936 (gnus-sethash id threads thhashtb))
7937 (setq gthread (gnus-gethash gid thhashtb))
7939 ;; We enter a dummy root into the thread, if we
7940 ;; haven't done that already.
7941 (unless (stringp (caar gthread))
7942 (setcar gthread (list (mail-header-subject (caar gthread))
7944 ;; We add this new gathered thread to this gathered
7946 (setcdr (car gthread)
7947 (nconc (cdar gthread) (list (car threads)))))
7948 ;; Add it into the thread hash table.
7949 (gnus-sethash id gthread thhashtb)
7951 ;; Remove it from the list of threads.
7952 (setcdr prev (cdr threads))
7953 (setq threads prev))
7954 (setq ids (cdr ids))))
7956 (setq threads (cdr threads)))
7959 (defun gnus-sort-gathered-threads (threads)
7960 "Sort subtreads inside each gathered thread by article number."
7961 (let ((result threads))
7963 (when (stringp (caar threads))
7964 (setcdr (car threads)
7965 (sort (cdar threads) 'gnus-thread-sort-by-number)))
7966 (setq threads (cdr threads)))
7969 (defun gnus-make-threads ()
7970 "Go through the dependency hashtb and find the roots. Return all threads."
7974 (unless (car (symbol-value refs))
7975 ;; These threads do not refer back to any other articles,
7976 ;; so they're roots.
7977 (setq threads (append (cdr (symbol-value refs)) threads))))
7978 gnus-newsgroup-dependencies)
7981 (defun gnus-build-sparse-threads ()
7982 (let ((headers gnus-newsgroup-headers)
7983 (deps gnus-newsgroup-dependencies)
7984 header references generation relations
7985 cthread subject child end pthread relation)
7986 ;; First we create an alist of generations/relations, where
7987 ;; generations is how much we trust the ralation, and the relation
7989 (gnus-message 7 "Making sparse threads...")
7991 (nnheader-set-temp-buffer " *gnus sparse threads*")
7992 (while (setq header (pop headers))
7993 (when (and (setq references (mail-header-references header))
7994 (not (string= references "")))
7996 (setq child (mail-header-id header)
7997 subject (mail-header-subject header))
7999 (while (search-backward ">" nil t)
8000 (setq end (1+ (point)))
8001 (when (search-backward "<" nil t)
8002 (push (list (incf generation)
8003 child (setq child (buffer-substring (point) end))
8006 (push (list (1+ generation) child nil subject) relations)
8008 (kill-buffer (current-buffer)))
8009 ;; Sort over trustworthiness.
8010 (setq relations (sort relations (lambda (r1 r2) (< (car r1) (car r2)))))
8011 (while (setq relation (pop relations))
8012 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
8013 (unless (car (symbol-value cthread))
8014 ;; Make this article the parent of these threads.
8015 (setcar (symbol-value cthread)
8016 (vector gnus-reffed-article-number
8020 (or (caddr relation) "") 0 0 "")))
8021 (set cthread (list (vector gnus-reffed-article-number
8023 "" "" (cadr relation)
8024 (or (caddr relation) "") 0 0 ""))))
8025 (push gnus-reffed-article-number gnus-newsgroup-limit)
8026 (push gnus-reffed-article-number gnus-newsgroup-sparse)
8027 (push (cons gnus-reffed-article-number gnus-sparse-mark)
8028 gnus-newsgroup-reads)
8029 (decf gnus-reffed-article-number)
8030 ;; Make this new thread the child of its parent.
8031 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
8032 (setcdr (symbol-value pthread)
8033 (nconc (cdr (symbol-value pthread))
8034 (list (symbol-value cthread))))
8035 (set pthread (list nil (symbol-value cthread))))))
8036 (gnus-message 7 "Making sparse threads...done")))
8038 (defun gnus-build-old-threads ()
8039 ;; Look at all the articles that refer back to old articles, and
8040 ;; fetch the headers for the articles that aren't there. This will
8041 ;; build complete threads - if the roots haven't been expired by the
8046 (when (not (car (symbol-value refs)))
8047 (setq heads (cdr (symbol-value refs)))
8049 (if (memq (mail-header-number (caar heads))
8050 gnus-newsgroup-dormant)
8051 (setq heads (cdr heads))
8052 (setq id (symbol-name refs))
8053 (while (and (setq id (gnus-build-get-header id))
8054 (not (car (gnus-gethash
8055 id gnus-newsgroup-dependencies)))))
8056 (setq heads nil)))))
8057 gnus-newsgroup-dependencies)))
8059 (defun gnus-build-get-header (id)
8060 ;; Look through the buffer of NOV lines and find the header to
8061 ;; ID. Enter this line into the dependencies hash table, and return
8062 ;; the id of the parent article (if any).
8063 (let ((deps gnus-newsgroup-dependencies)
8067 (set-buffer nntp-server-buffer)
8068 (goto-char (point-min))
8069 (while (and (not found) (search-forward id nil t))
8071 (setq found (looking-at
8072 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
8073 (regexp-quote id))))
8074 (or found (beginning-of-line 2)))
8078 (setq header (gnus-nov-parse-line
8079 (read (current-buffer)) deps))
8080 (gnus-parent-id (mail-header-references header)))))
8082 (let ((number (mail-header-number header)))
8083 (push number gnus-newsgroup-limit)
8084 (push header gnus-newsgroup-headers)
8085 (if (memq number gnus-newsgroup-unselected)
8087 (push number gnus-newsgroup-unreads)
8088 (setq gnus-newsgroup-unselected
8089 (delq number gnus-newsgroup-unselected)))
8090 (push number gnus-newsgroup-ancient)))))))
8092 (defun gnus-summary-update-article (article &optional iheader)
8093 "Update ARTICLE in the summary buffer."
8094 (set-buffer gnus-summary-buffer)
8095 (let* ((header (or iheader (gnus-summary-article-header article)))
8096 (id (mail-header-id header))
8097 (data (gnus-data-find article))
8098 (thread (gnus-id-to-thread id))
8099 (references (mail-header-references header))
8104 (not (equal "" references)))
8107 (buffer-read-only nil)
8109 (number (mail-header-number header))
8112 ;; !!! Should this be in or not?
8114 (setcar thread nil))
8116 (delq thread parent))
8117 (if (gnus-summary-insert-subject id header iheader)
8118 ;; Set the (possibly) new article number in the data structure.
8119 (gnus-data-set-number data (gnus-id-to-article id))
8123 (defun gnus-rebuild-thread (id)
8124 "Rebuild the thread containing ID."
8125 (let ((buffer-read-only nil)
8126 current thread data)
8127 (if (not gnus-show-threads)
8128 (setq thread (list (car (gnus-id-to-thread id))))
8129 ;; Get the thread this article is part of.
8130 (setq thread (gnus-remove-thread id)))
8131 (setq current (save-excursion
8132 (and (zerop (forward-line -1))
8133 (gnus-summary-article-number))))
8134 ;; If this is a gathered thread, we have to go some re-gathering.
8135 (when (stringp (car thread))
8136 (let ((subject (car thread))
8138 (setq thread (cdr thread))
8140 (unless (memq (setq thr (gnus-id-to-thread
8142 (mail-header-id (caar thread)))))
8145 (setq thread (cdr thread)))
8146 ;; We now have all (unique) roots.
8147 (if (= (length roots) 1)
8148 ;; All the loose roots are now one solid root.
8149 (setq thread (car roots))
8150 (setq thread (cons subject (gnus-sort-threads roots))))))
8152 ;; We then insert this thread into the summary buffer.
8153 (let (gnus-newsgroup-data gnus-newsgroup-threads)
8154 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
8155 (setq data (nreverse gnus-newsgroup-data))
8156 (setq threads gnus-newsgroup-threads))
8157 ;; We splice the new data into the data structure.
8158 (gnus-data-enter-list current data)
8159 (gnus-data-compute-positions)
8160 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
8162 (defun gnus-number-to-header (number)
8163 "Return the header for article NUMBER."
8164 (let ((headers gnus-newsgroup-headers))
8166 (not (= number (mail-header-number (car headers)))))
8171 (defun gnus-id-to-thread (id)
8172 "Return the (sub-)thread where ID appears."
8173 (gnus-gethash id gnus-newsgroup-dependencies))
8175 (defun gnus-id-to-article (id)
8176 "Return the article number of ID."
8177 (let ((thread (gnus-id-to-thread id)))
8180 (mail-header-number (car thread)))))
8182 (defun gnus-id-to-header (id)
8183 "Return the article headers of ID."
8184 (car (gnus-id-to-thread id)))
8186 (defun gnus-article-displayed-root-p (article)
8187 "Say whether ARTICLE is a root(ish) article."
8188 (let ((level (gnus-summary-thread-level article))
8189 (refs (mail-header-references (gnus-summary-article-header article)))
8195 ((null (gnus-parent-id refs)) t)
8197 (null (setq particle (gnus-id-to-article
8198 (gnus-parent-id refs))))
8199 (null (gnus-summary-thread-level particle)))))))
8201 (defun gnus-root-id (id)
8202 "Return the id of the root of the thread where ID appears."
8204 (while (and id (setq prev (car (gnus-gethash
8205 id gnus-newsgroup-dependencies))))
8207 id (gnus-parent-id (mail-header-references prev))))
8210 (defun gnus-remove-thread (id &optional dont-remove)
8211 "Remove the thread that has ID in it."
8212 (let ((dep gnus-newsgroup-dependencies)
8213 headers thread last-id)
8214 ;; First go up in this thread until we find the root.
8215 (setq last-id (gnus-root-id id))
8216 (setq headers (list (car (gnus-id-to-thread last-id))
8217 (caadr (gnus-id-to-thread last-id))))
8218 ;; We have now found the real root of this thread. It might have
8219 ;; been gathered into some loose thread, so we have to search
8220 ;; through the threads to find the thread we wanted.
8221 (let ((threads gnus-newsgroup-threads)
8224 (setq sub (car threads))
8225 (if (stringp (car sub))
8226 ;; This is a gathered threads, so we look at the roots
8227 ;; below it to find whether this article in in this
8230 (setq sub (cdr sub))
8232 (when (member (caar sub) headers)
8233 (setq thread (car threads)
8236 (setq sub (cdr sub))))
8237 ;; It's an ordinary thread, so we check it.
8238 (when (eq (car sub) (car headers))
8241 (setq threads (cdr threads)))
8242 ;; If this article is in no thread, then it's a root.
8245 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
8246 (setq thread (gnus-gethash last-id dep)))
8249 thread ; We return this thread.
8251 (if (stringp (car thread))
8253 ;; If we use dummy roots, then we have to remove the
8254 ;; dummy root as well.
8255 (when (eq gnus-summary-make-false-root 'dummy)
8258 (setq thread (cdr thread))
8260 (gnus-remove-thread-1 (car thread))
8261 (setq thread (cdr thread))))
8262 (gnus-remove-thread-1 thread))))))))
8264 (defun gnus-remove-thread-1 (thread)
8265 "Remove the thread THREAD recursively."
8266 (let ((number (mail-header-number (car thread)))
8268 (when (setq pos (text-property-any
8269 (point-min) (point-max) 'gnus-number number))
8272 (gnus-data-remove number))
8273 (setq thread (cdr thread))
8275 (gnus-remove-thread-1 (pop thread)))))
8277 (defun gnus-sort-threads (threads)
8279 (if (not gnus-thread-sort-functions)
8281 (let ((func (if (= 1 (length gnus-thread-sort-functions))
8282 (car gnus-thread-sort-functions)
8284 ,(gnus-make-sort-function
8285 (reverse gnus-thread-sort-functions))))))
8286 (gnus-message 7 "Sorting threads...")
8289 (gnus-message 7 "Sorting threads...done")))))
8291 (defun gnus-sort-articles (articles)
8293 (when gnus-article-sort-functions
8294 (let ((func (if (= 1 (length gnus-article-sort-functions))
8295 (car gnus-article-sort-functions)
8297 ,(gnus-make-sort-function
8298 (reverse gnus-article-sort-functions))))))
8299 (gnus-message 7 "Sorting articles...")
8301 (setq gnus-newsgroup-headers (sort articles func))
8302 (gnus-message 7 "Sorting articles...done")))))
8304 (defun gnus-make-sort-function (funs)
8305 "Return a composite sort condition based on the functions in FUNC."
8307 `(or (,(car funs) t1 t2)
8308 (and (not (,(car funs) t2 t1))
8309 ,(gnus-make-sort-function (cdr funs))))
8310 `(,(car funs) t1 t2)))
8312 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
8313 (defmacro gnus-thread-header (thread)
8314 ;; Return header of first article in THREAD.
8315 ;; Note that THREAD must never, ever be anything else than a variable -
8316 ;; using some other form will lead to serious barfage.
8317 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
8318 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
8319 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
8322 (defsubst gnus-article-sort-by-number (h1 h2)
8323 "Sort articles by article number."
8324 (< (mail-header-number h1)
8325 (mail-header-number h2)))
8327 (defun gnus-thread-sort-by-number (h1 h2)
8328 "Sort threads by root article number."
8329 (gnus-article-sort-by-number
8330 (gnus-thread-header h1) (gnus-thread-header h2)))
8332 (defsubst gnus-article-sort-by-author (h1 h2)
8333 "Sort articles by root author."
8335 (let ((extract (funcall
8336 gnus-extract-address-components
8337 (mail-header-from h1))))
8338 (or (car extract) (cdr extract)))
8339 (let ((extract (funcall
8340 gnus-extract-address-components
8341 (mail-header-from h2))))
8342 (or (car extract) (cdr extract)))))
8344 (defun gnus-thread-sort-by-author (h1 h2)
8345 "Sort threads by root author."
8346 (gnus-article-sort-by-author
8347 (gnus-thread-header h1) (gnus-thread-header h2)))
8349 (defsubst gnus-article-sort-by-subject (h1 h2)
8350 "Sort articles by root subject."
8352 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
8353 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
8355 (defun gnus-thread-sort-by-subject (h1 h2)
8356 "Sort threads by root subject."
8357 (gnus-article-sort-by-subject
8358 (gnus-thread-header h1) (gnus-thread-header h2)))
8360 (defsubst gnus-article-sort-by-date (h1 h2)
8361 "Sort articles by root article date."
8363 (inline (gnus-sortable-date (mail-header-date h1)))
8364 (inline (gnus-sortable-date (mail-header-date h2)))))
8366 (defun gnus-thread-sort-by-date (h1 h2)
8367 "Sort threads by root article date."
8368 (gnus-article-sort-by-date
8369 (gnus-thread-header h1) (gnus-thread-header h2)))
8371 (defsubst gnus-article-sort-by-score (h1 h2)
8372 "Sort articles by root article score.
8373 Unscored articles will be counted as having a score of zero."
8374 (> (or (cdr (assq (mail-header-number h1)
8375 gnus-newsgroup-scored))
8376 gnus-summary-default-score 0)
8377 (or (cdr (assq (mail-header-number h2)
8378 gnus-newsgroup-scored))
8379 gnus-summary-default-score 0)))
8381 (defun gnus-thread-sort-by-score (h1 h2)
8382 "Sort threads by root article score."
8383 (gnus-article-sort-by-score
8384 (gnus-thread-header h1) (gnus-thread-header h2)))
8386 (defun gnus-thread-sort-by-total-score (h1 h2)
8387 "Sort threads by the sum of all scores in the thread.
8388 Unscored articles will be counted as having a score of zero."
8389 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
8391 (defun gnus-thread-total-score (thread)
8392 ;; This function find the total score of THREAD.
8393 (cond ((null thread)
8396 (if (stringp (car thread))
8397 (apply gnus-thread-score-function 0
8398 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
8399 (gnus-thread-total-score-1 thread)))
8401 (gnus-thread-total-score-1 (list thread)))))
8403 (defun gnus-thread-total-score-1 (root)
8404 ;; This function find the total score of the thread below ROOT.
8405 (setq root (car root))
8406 (apply gnus-thread-score-function
8407 (or (cdr (assq (mail-header-number root) gnus-newsgroup-scored))
8408 gnus-summary-default-score 0)
8409 (mapcar 'gnus-thread-total-score
8410 (cdr (gnus-gethash (mail-header-id root)
8411 gnus-newsgroup-dependencies)))))
8413 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8414 (defvar gnus-tmp-prev-subject nil)
8415 (defvar gnus-tmp-false-parent nil)
8416 (defvar gnus-tmp-root-expunged nil)
8417 (defvar gnus-tmp-dummy-line nil)
8419 (defun gnus-summary-prepare-threads (threads)
8420 "Prepare summary buffer from THREADS and indentation LEVEL.
8421 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
8422 or a straight list of headers."
8423 (gnus-message 7 "Generating summary...")
8425 (setq gnus-newsgroup-threads threads)
8428 (let ((gnus-tmp-level 0)
8429 (default-score (or gnus-summary-default-score 0))
8430 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
8431 thread number subject stack state gnus-tmp-gathered beg-match
8432 new-roots gnus-tmp-new-adopts thread-end
8433 gnus-tmp-header gnus-tmp-unread
8434 gnus-tmp-replied gnus-tmp-subject-or-nil
8435 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
8436 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
8437 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
8439 (setq gnus-tmp-prev-subject nil)
8441 (if (vectorp (car threads))
8442 ;; If this is a straight (sic) list of headers, then a
8443 ;; threaded summary display isn't required, so we just create
8444 ;; an unthreaded one.
8445 (gnus-summary-prepare-unthreaded threads)
8447 ;; Do the threaded display.
8449 (while (or threads stack gnus-tmp-new-adopts new-roots)
8451 (if (and (= gnus-tmp-level 0)
8452 (not (setq gnus-tmp-dummy-line nil))
8455 (not gnus-tmp-false-parent)
8456 (or gnus-tmp-new-adopts new-roots))
8457 (if gnus-tmp-new-adopts
8458 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
8459 thread (list (car gnus-tmp-new-adopts))
8460 gnus-tmp-header (caar thread)
8461 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
8463 (setq thread (list (car new-roots))
8464 gnus-tmp-header (caar thread)
8465 new-roots (cdr new-roots))))
8468 ;; If there are some threads, we do them before the
8469 ;; threads on the stack.
8470 (setq thread threads
8471 gnus-tmp-header (caar thread))
8472 ;; There were no current threads, so we pop something off
8474 (setq state (car stack)
8475 gnus-tmp-level (car state)
8478 gnus-tmp-header (caar thread))))
8480 (setq gnus-tmp-false-parent nil)
8481 (setq gnus-tmp-root-expunged nil)
8482 (setq thread-end nil)
8484 (if (stringp gnus-tmp-header)
8485 ;; The header is a dummy root.
8487 ((eq gnus-summary-make-false-root 'adopt)
8488 ;; We let the first article adopt the rest.
8489 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
8491 (setq gnus-tmp-gathered
8493 (lambda (h) (mail-header-number (car h)))
8496 (setq thread (cons (list (caar thread)
8499 (setq gnus-tmp-level -1
8500 gnus-tmp-false-parent t))
8501 ((eq gnus-summary-make-false-root 'empty)
8502 ;; We print adopted articles with empty subject fields.
8503 (setq gnus-tmp-gathered
8505 (lambda (h) (mail-header-number (car h)))
8508 (setq gnus-tmp-level -1))
8509 ((eq gnus-summary-make-false-root 'dummy)
8510 ;; We remember that we probably want to output a dummy
8512 (setq gnus-tmp-dummy-line gnus-tmp-header)
8513 (setq gnus-tmp-prev-subject gnus-tmp-header))
8515 ;; We do not make a root for the gathered
8516 ;; sub-threads at all.
8517 (setq gnus-tmp-level -1)))
8519 (setq number (mail-header-number gnus-tmp-header)
8520 subject (mail-header-subject gnus-tmp-header))
8523 ;; If the thread has changed subject, we might want to make
8524 ;; this subthread into a root.
8525 ((and (null gnus-thread-ignore-subject)
8526 (not (zerop gnus-tmp-level))
8527 gnus-tmp-prev-subject
8529 (gnus-subject-equal gnus-tmp-prev-subject subject))))
8530 (setq new-roots (nconc new-roots (list (car thread)))
8532 gnus-tmp-header nil))
8533 ;; If the article lies outside the current limit,
8534 ;; then we do not display it.
8535 ((and (not (memq number gnus-newsgroup-limit))
8536 (not gnus-tmp-dummy-line))
8537 (setq gnus-tmp-gathered
8539 (lambda (h) (mail-header-number (car h)))
8542 (setq gnus-tmp-new-adopts (if (cdar thread)
8543 (append gnus-tmp-new-adopts
8545 gnus-tmp-new-adopts)
8547 gnus-tmp-header nil)
8548 (when (zerop gnus-tmp-level)
8549 (setq gnus-tmp-root-expunged t)))
8550 ;; Perhaps this article is to be marked as read?
8551 ((and gnus-summary-mark-below
8552 (< (or (cdr (assq number gnus-newsgroup-scored))
8554 gnus-summary-mark-below)
8555 ;; Don't touch sparse articles.
8556 (not (memq number gnus-newsgroup-sparse))
8557 (not (memq number gnus-newsgroup-ancient)))
8558 (setq gnus-newsgroup-unreads
8559 (delq number gnus-newsgroup-unreads))
8560 (if gnus-newsgroup-auto-expire
8561 (push number gnus-newsgroup-expirable)
8562 (push (cons number gnus-low-score-mark)
8563 gnus-newsgroup-reads))))
8565 (when gnus-tmp-header
8566 ;; We may have an old dummy line to output before this
8568 (when gnus-tmp-dummy-line
8569 (gnus-summary-insert-dummy-line
8570 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
8571 (setq gnus-tmp-dummy-line nil))
8573 ;; Compute the mark.
8577 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8578 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8579 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8580 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8581 (t (or (cdr (assq number gnus-newsgroup-reads))
8582 gnus-ancient-mark))))
8584 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
8585 gnus-tmp-header gnus-tmp-level)
8586 gnus-newsgroup-data)
8588 ;; Actually insert the line.
8590 gnus-tmp-subject-or-nil
8592 ((and gnus-thread-ignore-subject
8593 gnus-tmp-prev-subject
8594 (not (inline (gnus-subject-equal
8595 gnus-tmp-prev-subject subject))))
8597 ((zerop gnus-tmp-level)
8598 (if (and (eq gnus-summary-make-false-root 'empty)
8599 (memq number gnus-tmp-gathered)
8600 gnus-tmp-prev-subject
8601 (inline (gnus-subject-equal
8602 gnus-tmp-prev-subject subject)))
8603 gnus-summary-same-subject
8605 (t gnus-summary-same-subject)))
8606 (if (and (eq gnus-summary-make-false-root 'adopt)
8607 (= gnus-tmp-level 1)
8608 (memq number gnus-tmp-gathered))
8609 (setq gnus-tmp-opening-bracket ?\<
8610 gnus-tmp-closing-bracket ?\>)
8611 (setq gnus-tmp-opening-bracket ?\[
8612 gnus-tmp-closing-bracket ?\]))
8614 gnus-tmp-indentation
8615 (aref gnus-thread-indent-array gnus-tmp-level)
8616 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
8617 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
8618 gnus-summary-default-score 0)
8620 (if (or (null gnus-summary-default-score)
8621 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
8622 gnus-summary-zcore-fuzz)) ?
8623 (if (< gnus-tmp-score gnus-summary-default-score)
8624 gnus-score-below-mark gnus-score-over-mark))
8626 (cond ((memq number gnus-newsgroup-processable)
8628 ((memq number gnus-newsgroup-cached)
8630 ((memq number gnus-newsgroup-replied)
8632 (t gnus-unread-mark))
8633 gnus-tmp-from (mail-header-from gnus-tmp-header)
8636 ((string-match "(.+)" gnus-tmp-from)
8637 (substring gnus-tmp-from
8638 (1+ (match-beginning 0)) (1- (match-end 0))))
8639 ((string-match "<[^>]+> *$" gnus-tmp-from)
8640 (setq beg-match (match-beginning 0))
8641 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
8642 (substring gnus-tmp-from (1+ (match-beginning 0))
8643 (1- (match-end 0))))
8644 (substring gnus-tmp-from 0 beg-match)))
8646 (when (string= gnus-tmp-name "")
8647 (setq gnus-tmp-name gnus-tmp-from))
8648 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
8649 (gnus-put-text-property
8651 (progn (eval gnus-summary-line-format-spec) (point))
8652 'gnus-number number)
8655 (run-hooks 'gnus-summary-update-hook)
8658 (setq gnus-tmp-prev-subject subject)))
8660 (when (nth 1 thread)
8661 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
8662 (incf gnus-tmp-level)
8663 (setq threads (if thread-end nil (cdar thread)))
8665 (setq gnus-tmp-level 0)))))
8666 (gnus-message 7 "Generating summary...done"))
8668 (defun gnus-summary-prepare-unthreaded (headers)
8669 "Generate an unthreaded summary buffer based on HEADERS."
8670 (let (header number mark)
8673 ;; We may have to root out some bad articles...
8674 (when (memq (setq number (mail-header-number
8675 (setq header (pop headers))))
8676 gnus-newsgroup-limit)
8677 ;; Mark article as read when it has a low score.
8678 (when (and gnus-summary-mark-below
8679 (< (or (cdr (assq number gnus-newsgroup-scored))
8680 gnus-summary-default-score 0)
8681 gnus-summary-mark-below)
8682 (not (memq number gnus-newsgroup-ancient)))
8683 (setq gnus-newsgroup-unreads
8684 (delq number gnus-newsgroup-unreads))
8685 (if gnus-newsgroup-auto-expire
8686 (push number gnus-newsgroup-expirable)
8687 (push (cons number gnus-low-score-mark)
8688 gnus-newsgroup-reads)))
8692 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8693 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8694 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8695 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8696 (t (or (cdr (assq number gnus-newsgroup-reads))
8697 gnus-ancient-mark))))
8698 (setq gnus-newsgroup-data
8699 (cons (gnus-data-make number mark (1+ (point)) header 0)
8700 gnus-newsgroup-data))
8701 (gnus-summary-insert-line
8702 header 0 nil mark (memq number gnus-newsgroup-replied)
8703 (memq number gnus-newsgroup-expirable)
8704 (mail-header-subject header) nil
8705 (cdr (assq number gnus-newsgroup-scored))
8706 (memq number gnus-newsgroup-processable))))))
8708 (defun gnus-select-newsgroup (group &optional read-all)
8709 "Select newsgroup GROUP.
8710 If READ-ALL is non-nil, all articles in the group are selected."
8711 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
8712 (info (nth 2 entry))
8713 articles fetched-articles cached)
8715 (or (gnus-check-server
8716 (setq gnus-current-select-method (gnus-find-method-for-group group)))
8717 (error "Couldn't open server"))
8719 (or (and entry (not (eq (car entry) t))) ; Either it's active...
8720 (gnus-activate-group group) ; Or we can activate it...
8721 (progn ; Or we bug out.
8722 (when (equal major-mode 'gnus-summary-mode)
8723 (kill-buffer (current-buffer)))
8724 (error "Couldn't request group %s: %s"
8725 group (gnus-status-message group))))
8727 (unless (gnus-request-group group t)
8728 (when (equal major-mode 'gnus-summary-mode)
8729 (kill-buffer (current-buffer)))
8730 (error "Couldn't request group %s: %s"
8731 group (gnus-status-message group)))
8733 (setq gnus-newsgroup-name group)
8734 (setq gnus-newsgroup-unselected nil)
8735 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
8737 (and gnus-asynchronous
8738 (gnus-check-backend-function
8739 'request-asynchronous gnus-newsgroup-name)
8740 (setq gnus-newsgroup-async
8741 (gnus-request-asynchronous gnus-newsgroup-name)))
8743 ;; Adjust and set lists of article marks.
8745 (gnus-adjust-marked-articles info))
8747 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8748 (when (gnus-virtual-group-p group)
8749 (setq cached gnus-newsgroup-cached))
8751 (setq gnus-newsgroup-unreads
8752 (gnus-set-difference
8753 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
8754 gnus-newsgroup-dormant))
8756 (setq gnus-newsgroup-processable nil)
8758 (setq articles (gnus-articles-to-read group read-all))
8762 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
8764 ((eq articles 0) nil)
8766 ;; Init the dependencies hash table.
8767 (setq gnus-newsgroup-dependencies
8768 (gnus-make-hashtable (length articles)))
8769 ;; Retrieve the headers and read them in.
8770 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8771 (setq gnus-newsgroup-headers
8773 (setq gnus-headers-retrieved-by
8774 (gnus-retrieve-headers
8775 articles gnus-newsgroup-name
8776 ;; We might want to fetch old headers, but
8777 ;; not if there is only 1 article.
8778 (and gnus-fetch-old-headers
8780 (not (eq gnus-fetch-old-headers 'some))
8781 (not (numberp gnus-fetch-old-headers)))
8782 (> (length articles) 1))))))
8783 (gnus-get-newsgroup-headers-xover articles)
8784 (gnus-get-newsgroup-headers)))
8785 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
8787 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8789 (setq gnus-newsgroup-cached cached))
8791 ;; Set the initial limit.
8792 (setq gnus-newsgroup-limit (copy-sequence articles))
8793 ;; Remove canceled articles from the list of unread articles.
8794 (setq gnus-newsgroup-unreads
8795 (gnus-set-sorted-intersection
8796 gnus-newsgroup-unreads
8797 (setq fetched-articles
8798 (mapcar (lambda (headers) (mail-header-number headers))
8799 gnus-newsgroup-headers))))
8800 ;; Removed marked articles that do not exist.
8801 (gnus-update-missing-marks
8802 (gnus-sorted-complement fetched-articles articles))
8803 ;; We might want to build some more threads first.
8804 (and gnus-fetch-old-headers
8805 (eq gnus-headers-retrieved-by 'nov)
8806 (gnus-build-old-threads))
8807 ;; Check whether auto-expire is to be done in this group.
8808 (setq gnus-newsgroup-auto-expire
8809 (gnus-group-auto-expirable-p group))
8810 ;; Set up the article buffer now, if necessary.
8811 (unless gnus-single-article-buffer
8812 (gnus-article-setup-buffer))
8813 ;; First and last article in this newsgroup.
8814 (when gnus-newsgroup-headers
8815 (setq gnus-newsgroup-begin
8816 (mail-header-number (car gnus-newsgroup-headers))
8819 (gnus-last-element gnus-newsgroup-headers))))
8820 (setq gnus-reffed-article-number -1)
8821 ;; GROUP is successfully selected.
8822 (or gnus-newsgroup-headers t)))))
8824 (defun gnus-articles-to-read (group read-all)
8825 ;; Find out what articles the user wants to read.
8827 ;; Select all articles if `read-all' is non-nil, or if there
8828 ;; are no unread articles.
8830 (and (zerop (length gnus-newsgroup-marked))
8831 (zerop (length gnus-newsgroup-unreads))))
8832 (gnus-uncompress-range (gnus-active group))
8833 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
8834 (copy-sequence gnus-newsgroup-unreads))
8836 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
8837 (scored (length scored-list))
8838 (number (length articles))
8839 (marked (+ (length gnus-newsgroup-marked)
8840 (length gnus-newsgroup-dormant)))
8848 ((and (or (<= scored marked) (= scored number))
8849 (numberp gnus-large-newsgroup)
8850 (> number gnus-large-newsgroup))
8854 "How many articles from %s (default %d): "
8855 gnus-newsgroup-name number))))
8856 (if (string-match "^[ \t]*$" input) number input)))
8857 ((and (> scored marked) (< scored number))
8860 (format "%s %s (%d scored, %d total): "
8861 "How many articles from"
8862 group scored number))))
8863 (if (string-match "^[ \t]*$" input)
8867 (setq select (if (stringp select) (string-to-number select) select))
8868 (if (or (null select) (zerop select))
8870 (if (and (not (zerop scored)) (<= (abs select) scored))
8872 (setq articles (sort scored-list '<))
8873 (setq number (length articles)))
8874 (setq articles (copy-sequence articles)))
8876 (if (< (abs select) number)
8878 ;; Select the N oldest articles.
8879 (setcdr (nthcdr (1- (abs select)) articles) nil)
8880 ;; Select the N most recent articles.
8881 (setq articles (nthcdr (- number select) articles))))
8882 (setq gnus-newsgroup-unselected
8883 (gnus-sorted-intersection
8884 gnus-newsgroup-unreads
8885 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
8888 (defun gnus-killed-articles (killed articles)
8891 (if (inline (gnus-member-of-range (car articles) killed))
8892 (setq out (cons (car articles) out)))
8893 (setq articles (cdr articles)))
8896 (defun gnus-uncompress-marks (marks)
8897 "Uncompress the mark ranges in MARKS."
8898 (let ((uncompressed '(score bookmark))
8901 (if (memq (caar marks) uncompressed)
8902 (push (car marks) out)
8903 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
8904 (setq marks (cdr marks)))
8907 (defun gnus-adjust-marked-articles (info)
8908 "Set all article lists and remove all marks that are no longer legal."
8909 (let* ((marked-lists (gnus-info-marks info))
8910 (active (gnus-active (gnus-info-group info)))
8913 (types gnus-article-mark-lists)
8914 (uncompressed '(score bookmark))
8915 marks var articles article mark)
8918 (setq marks (pop marked-lists))
8919 (set (setq var (intern (format "gnus-newsgroup-%s"
8920 (car (rassq (setq mark (car marks))
8922 (if (memq (car marks) uncompressed) (cdr marks)
8923 (gnus-uncompress-range (cdr marks))))
8925 (setq articles (symbol-value var))
8927 ;; All articles have to be subsets of the active articles.
8929 ;; Adjust "simple" lists.
8930 ((memq mark '(tick dormant expirable reply killed save))
8932 (when (or (< (setq article (pop articles)) min) (> article max))
8933 (set var (delq article (symbol-value var))))))
8935 ((memq mark '(score bookmark))
8937 (when (or (< (car (setq article (pop articles))) min)
8938 (> (car article) max))
8939 (set var (delq article (symbol-value var))))))))))
8941 (defun gnus-update-missing-marks (missing)
8942 "Go through the list of MISSING articles and remove them mark lists."
8944 (let ((types gnus-article-mark-lists)
8946 ;; Go through all types.
8948 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
8949 (when (symbol-value var)
8950 ;; This list has articles. So we delete all missing articles
8954 (set var (delq (pop m) (symbol-value var)))))))))
8956 (defun gnus-update-marks ()
8957 "Enter the various lists of marked articles into the newsgroup info list."
8958 (let ((types gnus-article-mark-lists)
8959 (info (gnus-get-info gnus-newsgroup-name))
8960 (uncompressed '(score bookmark killed))
8961 type list newmarked symbol)
8963 ;; Add all marks lists that are non-nil to the list of marks lists.
8965 (setq type (pop types))
8966 (when (setq list (symbol-value
8968 (intern (format "gnus-newsgroup-%s"
8970 (push (cons (cdr type)
8971 (if (memq (cdr type) uncompressed) list
8972 (gnus-compress-sequence (set symbol (sort list '<)) t)))
8975 ;; Enter these new marks into the info of the group.
8977 (setcar (nthcdr 3 info) newmarked)
8978 ;; Add the marks lists to the end of the info.
8980 (setcdr (nthcdr 2 info) (list newmarked))))
8982 ;; Cut off the end of the info if there's nothing else there.
8986 (when (nthcdr (decf i) info)
8987 (setcdr (nthcdr i info) nil)))))))
8989 (defun gnus-add-marked-articles (group type articles &optional info force)
8990 ;; Add ARTICLES of TYPE to the info of GROUP.
8991 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
8992 ;; add, but replace marked articles of TYPE with ARTICLES.
8993 (let ((info (or info (gnus-get-info group)))
8994 (uncompressed '(score bookmark killed))
8997 (and (not (setq marked (nthcdr 3 info)))
8999 (setcdr (nthcdr 2 info)
9000 (list (list (cons type (gnus-compress-sequence
9002 (and (not (setq m (assq type (car marked))))
9005 (cons (cons type (gnus-compress-sequence articles t) )
9009 (setcar (nthcdr 3 info)
9010 (delq (assq type (car marked)) (car marked)))
9011 (setcdr m (gnus-compress-sequence articles t)))
9012 (setcdr m (gnus-compress-sequence
9013 (sort (nconc (gnus-uncompress-range (cdr m))
9014 (copy-sequence articles)) '<) t))))))
9016 (defun gnus-set-mode-line (where)
9017 "This function sets the mode line of the article or summary buffers.
9018 If WHERE is `summary', the summary mode line format will be used."
9019 ;; Is this mode line one we keep updated?
9020 (when (memq where gnus-updated-mode-lines)
9023 ;; We evaluate this in the summary buffer since these
9024 ;; variables are buffer-local to that buffer.
9025 (set-buffer gnus-summary-buffer)
9026 ;; We bind all these variables that are used in the `eval' form
9028 (let* ((mformat (symbol-value
9030 (format "gnus-%s-mode-line-format-spec" where))))
9031 (gnus-tmp-group-name gnus-newsgroup-name)
9032 (gnus-tmp-article-number (or gnus-current-article 0))
9033 (gnus-tmp-unread gnus-newsgroup-unreads)
9034 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
9035 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
9036 (gnus-tmp-unread-and-unselected
9037 (cond ((and (zerop gnus-tmp-unread-and-unticked)
9038 (zerop gnus-tmp-unselected)) "")
9039 ((zerop gnus-tmp-unselected)
9040 (format "{%d more}" gnus-tmp-unread-and-unticked))
9041 (t (format "{%d(+%d) more}"
9042 gnus-tmp-unread-and-unticked
9043 gnus-tmp-unselected))))
9045 (if (and gnus-current-headers
9046 (vectorp gnus-current-headers))
9047 (gnus-mode-string-quote
9048 (mail-header-subject gnus-current-headers)) ""))
9050 gnus-tmp-header);; passed as argument to any user-format-funcs
9051 (setq mode-string (eval mformat))
9052 (setq max-len (max 4 (if gnus-mode-non-string-length
9054 gnus-mode-non-string-length)
9055 (length mode-string))))
9056 ;; We might have to chop a bit of the string off...
9057 (when (> (length mode-string) max-len)
9059 (concat (gnus-truncate-string mode-string (- max-len 3))
9061 ;; Pad the mode string a bit.
9062 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
9063 ;; Update the mode line.
9064 (setq mode-line-buffer-identification (list mode-string))
9065 (set-buffer-modified-p t))))
9067 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
9068 "Go through the HEADERS list and add all Xrefs to a hash table.
9069 The resulting hash table is returned, or nil if no Xrefs were found."
9070 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
9071 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
9072 (xref-hashtb (make-vector 63 0))
9073 start group entry number xrefs header)
9075 (setq header (pop headers))
9076 (when (and (setq xrefs (mail-header-xref header))
9077 (not (memq (setq number (mail-header-number header))
9080 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
9081 (setq start (match-end 0))
9082 (setq group (if prefix
9083 (concat prefix (substring xrefs (match-beginning 1)
9085 (substring xrefs (match-beginning 1) (match-end 1))))
9087 (string-to-int (substring xrefs (match-beginning 2)
9089 (if (setq entry (gnus-gethash group xref-hashtb))
9090 (setcdr entry (cons number (cdr entry)))
9091 (gnus-sethash group (cons number nil) xref-hashtb)))))
9092 (and start xref-hashtb)))
9094 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
9095 "Look through all the headers and mark the Xrefs as read."
9096 (let ((virtual (gnus-virtual-group-p from-newsgroup))
9097 name entry info xref-hashtb idlist method nth4)
9099 (set-buffer gnus-group-buffer)
9100 (when (setq xref-hashtb
9101 (gnus-create-xref-hashtb from-newsgroup headers unreads))
9104 (unless (string= from-newsgroup (setq name (symbol-name group)))
9105 (setq idlist (symbol-value group))
9106 ;; Dead groups are not updated.
9108 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
9110 (if (stringp (setq nth4 (gnus-info-method info)))
9111 (setq nth4 (gnus-server-to-method nth4))))
9112 ;; Only do the xrefs if the group has the same
9113 ;; select method as the group we have just read.
9114 (or (gnus-methods-equal-p
9115 nth4 (gnus-find-method-for-group from-newsgroup))
9117 (equal nth4 (setq method (gnus-find-method-for-group
9119 (and (equal (car nth4) (car method))
9120 (equal (nth 1 nth4) (nth 1 method))))
9121 gnus-use-cross-reference
9122 (or (not (eq gnus-use-cross-reference t))
9124 ;; Only do cross-references on subscribed
9125 ;; groups, if that is what is wanted.
9126 (<= (gnus-info-level info) gnus-level-subscribed))
9127 (gnus-group-make-articles-read name idlist))))
9130 (defun gnus-group-make-articles-read (group articles)
9132 (entry (gnus-gethash group gnus-newsrc-hashtb))
9133 (info (nth 2 entry))
9134 (active (gnus-active group))
9136 ;; First peel off all illegal article numbers.
9138 (let ((ids articles)
9142 (if (and first (> id (cdr active)))
9144 ;; We'll end up in this situation in one particular
9145 ;; obscure situation. If you re-scan a group and get
9146 ;; a new article that is cross-posted to a different
9147 ;; group that has not been re-scanned, you might get
9148 ;; crossposted article that has a higher number than
9149 ;; Gnus believes possible. So we re-activate this
9150 ;; group as well. This might mean doing the
9151 ;; crossposting thingy will *increase* the number
9152 ;; of articles in some groups. Tsk, tsk.
9153 (setq active (or (gnus-activate-group group) active))))
9154 (if (or (> id (cdr active))
9155 (< id (car active)))
9156 (setq articles (delq id articles)))
9157 (setq ids (cdr ids)))))
9158 ;; If the read list is nil, we init it.
9160 (null (gnus-info-read info))
9162 (gnus-info-set-read info (cons 1 (1- (car active)))))
9163 ;; Then we add the read articles to the range.
9168 (gnus-info-read info) (setq articles (sort articles '<)))))
9169 ;; Then we have to re-compute how many unread
9170 ;; articles there are in this group.
9175 (setq num (- (1+ (cdr active)) (car active))))
9176 ((not (listp (cdr range)))
9177 (setq num (- (cdr active) (- (1+ (cdr range))
9181 (if (numberp (car range))
9183 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
9184 (setq range (cdr range)))
9185 (setq num (- (cdr active) num))))
9186 ;; Update the number of unread articles.
9188 ;; Update the group buffer.
9189 (gnus-group-update-group group t)))))
9191 (defun gnus-methods-equal-p (m1 m2)
9192 (let ((m1 (or m1 gnus-select-method))
9193 (m2 (or m2 gnus-select-method)))
9195 (and (eq (car m1) (car m2))
9196 (or (not (memq 'address (assoc (symbol-name (car m1))
9197 gnus-valid-select-methods)))
9198 (equal (nth 1 m1) (nth 1 m2)))))))
9200 (defsubst gnus-header-value ()
9203 (if (re-search-forward "^[^ \t]" nil t)
9207 (gnus-point-at-eol))))
9209 (defvar gnus-newsgroup-none-id 0)
9211 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
9212 (let ((cur nntp-server-buffer)
9215 (save-excursion (set-buffer gnus-summary-buffer)
9216 gnus-newsgroup-dependencies)))
9217 headers id id-dep ref-dep end ref)
9219 (set-buffer nntp-server-buffer)
9220 (run-hooks 'gnus-parse-headers-hook)
9221 (let ((case-fold-search t)
9222 in-reply-to header p lines)
9223 (goto-char (point-min))
9224 ;; Search to the beginning of the next header. Error messages
9225 ;; do not begin with 2 or 3.
9226 (while (re-search-forward "^[23][0-9]+ " nil t)
9229 ;; This implementation of this function, with nine
9230 ;; search-forwards instead of the one re-search-forward and
9231 ;; a case (which basically was the old function) is actually
9232 ;; about twice as fast, even though it looks messier. You
9233 ;; can't have everything, I guess. Speed and elegance
9234 ;; doesn't always go hand in hand.
9243 (narrow-to-region (point)
9244 (or (and (search-forward "\n.\n" nil t)
9250 (if (search-forward "\nsubject: " nil t)
9251 (gnus-header-value) "(none)"))
9255 (if (search-forward "\nfrom: " nil t)
9256 (gnus-header-value) "(nobody)"))
9260 (if (search-forward "\ndate: " nil t)
9261 (gnus-header-value) ""))
9265 (if (search-forward "\nmessage-id: " nil t)
9266 (setq id (gnus-header-value))
9267 ;; If there was no message-id, we just fake one to make
9268 ;; subsequent routines simpler.
9269 (setq id (concat "none+"
9271 (setq gnus-newsgroup-none-id
9272 (1+ gnus-newsgroup-none-id)))))))
9276 (if (search-forward "\nreferences: " nil t)
9285 (search-backward ">" end t)
9288 (search-backward "<" end t)
9290 ;; Get the references from the in-reply-to header if there
9291 ;; were no references and the in-reply-to header looks
9293 (if (and (search-forward "\nin-reply-to: " nil t)
9294 (setq in-reply-to (gnus-header-value))
9295 (string-match "<[^>]+>" in-reply-to))
9296 (setq ref (substring in-reply-to (match-beginning 0)
9304 (if (search-forward "\nlines: " nil t)
9305 (if (numberp (setq lines (read cur)))
9311 (and (search-forward "\nxref: " nil t)
9312 (gnus-header-value)))))
9313 ;; We do the threading while we read the headers. The
9314 ;; message-id and the last reference are both entered into
9315 ;; the same hash table. Some tippy-toeing around has to be
9316 ;; done in case an article has arrived before the article
9317 ;; which it refers to.
9318 (if (boundp (setq id-dep (intern id dependencies)))
9319 (if (and (car (symbol-value id-dep))
9321 ;; An article with this Message-ID has already
9322 ;; been seen, so we ignore this one, except we add
9323 ;; any additional Xrefs (in case the two articles
9324 ;; came from different servers).
9326 (mail-header-set-xref
9327 (car (symbol-value id-dep))
9328 (concat (or (mail-header-xref
9329 (car (symbol-value id-dep))) "")
9330 (or (mail-header-xref header) "")))
9332 (setcar (symbol-value id-dep) header))
9333 (set id-dep (list header)))
9335 (if (boundp (setq ref-dep (intern ref dependencies)))
9336 (setcdr (symbol-value ref-dep)
9337 (nconc (cdr (symbol-value ref-dep))
9338 (list (symbol-value id-dep))))
9339 (set ref-dep (list nil (symbol-value id-dep))))
9340 (setq headers (cons header headers)))
9341 (goto-char (point-max))
9343 (nreverse headers)))))
9345 ;; The following macros and functions were written by Felix Lee
9346 ;; <flee@cse.psu.edu>.
9348 (defmacro gnus-nov-read-integer ()
9350 (if (= (following-char) ?\t)
9352 (let ((num (condition-case nil (read buffer) (error nil))))
9353 (if (numberp num) num 0)))
9354 (or (eobp) (forward-char 1))))
9356 (defmacro gnus-nov-skip-field ()
9357 '(search-forward "\t" eol 'move))
9359 (defmacro gnus-nov-field ()
9360 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
9362 ;; Goes through the xover lines and returns a list of vectors
9363 (defun gnus-get-newsgroup-headers-xover (sequence &optional
9364 force-new dependencies)
9365 "Parse the news overview data in the server buffer, and return a
9366 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
9367 ;; Get the Xref when the users reads the articles since most/some
9368 ;; NNTP servers do not include Xrefs when using XOVER.
9369 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
9370 (let ((cur nntp-server-buffer)
9371 (dependencies (or dependencies gnus-newsgroup-dependencies))
9372 number headers header)
9374 (set-buffer nntp-server-buffer)
9375 ;; Allow the user to mangle the headers before parsing them.
9376 (run-hooks 'gnus-parse-headers-hook)
9377 (goto-char (point-min))
9378 (while (and sequence (not (eobp)))
9379 (setq number (read cur))
9380 (while (and sequence (< (car sequence) number))
9381 (setq sequence (cdr sequence)))
9383 (eq number (car sequence))
9385 (setq sequence (cdr sequence))
9387 (inline (gnus-nov-parse-line
9388 number dependencies force-new)))
9389 (setq headers (cons header headers)))))
9391 (setq headers (nreverse headers)))
9394 ;; This function has to be called with point after the article number
9395 ;; on the beginning of the line.
9396 (defun gnus-nov-parse-line (number dependencies &optional force-new)
9398 (eol (gnus-point-at-eol))
9399 (buffer (current-buffer))
9400 header ref id id-dep ref-dep)
9402 ;; overview: [num subject from date id refs chars lines misc]
9403 (narrow-to-region (point) eol)
9404 (or (eobp) (forward-char))
9410 (gnus-nov-field) ; subject
9411 (gnus-nov-field) ; from
9412 (gnus-nov-field) ; date
9413 (setq id (or (gnus-nov-field)
9416 (setq none (1+ none)))))) ; id
9419 (let ((beg (point)))
9420 (search-forward "\t" eol)
9421 (if (search-backward ">" beg t)
9425 (search-backward "<" beg t)))
9427 (gnus-nov-field)) ; refs
9428 (gnus-nov-read-integer) ; chars
9429 (gnus-nov-read-integer) ; lines
9430 (if (= (following-char) ?\n)
9432 (gnus-nov-field)) ; misc
9435 (gnus-error 4 "Strange nov line")
9441 ;; We build the thread tree.
9443 (if (boundp (setq id-dep (intern id dependencies)))
9444 (if (and (car (symbol-value id-dep))
9446 ;; An article with this Message-ID has already been seen,
9447 ;; so we ignore this one, except we add any additional
9448 ;; Xrefs (in case the two articles came from different
9451 (mail-header-set-xref
9452 (car (symbol-value id-dep))
9453 (concat (or (mail-header-xref
9454 (car (symbol-value id-dep))) "")
9455 (or (mail-header-xref header) "")))
9457 (setcar (symbol-value id-dep) header))
9458 (set id-dep (list header))))
9460 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
9461 (setcdr (symbol-value ref-dep)
9462 (nconc (cdr (symbol-value ref-dep))
9463 (list (symbol-value id-dep))))
9464 (set ref-dep (list nil (symbol-value id-dep)))))
9467 (defun gnus-article-get-xrefs ()
9468 "Fill in the Xref value in `gnus-current-headers', if necessary.
9469 This is meant to be called in `gnus-article-internal-prepare-hook'."
9470 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
9471 gnus-current-headers)))
9472 (or (not gnus-use-cross-reference)
9474 (and (mail-header-xref headers)
9475 (not (string= (mail-header-xref headers) "")))
9476 (let ((case-fold-search t)
9479 (nnheader-narrow-to-headers)
9480 (goto-char (point-min))
9481 (if (or (and (eq (downcase (following-char)) ?x)
9482 (looking-at "Xref:"))
9483 (search-forward "\nXref:" nil t))
9485 (goto-char (1+ (match-end 0)))
9486 (setq xref (buffer-substring (point)
9487 (progn (end-of-line) (point))))
9488 (mail-header-set-xref headers xref))))))))
9490 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
9491 "Find article ID and insert the summary line for that article."
9492 (let ((header (if (and old-header use-old-header)
9493 old-header (gnus-read-header id)))
9494 (number (and (numberp id) id))
9497 ;; Rebuild the thread that this article is part of and go to the
9498 ;; article we have fetched.
9499 (when (and (not gnus-show-threads)
9501 (when (setq pos (text-property-any
9502 (point-min) (point-max) 'gnus-number
9503 (mail-header-number old-header)))
9506 (gnus-data-remove (mail-header-number old-header))))
9508 (mail-header-set-number header (mail-header-number old-header)))
9509 (setq gnus-newsgroup-sparse
9510 (delq (setq number (mail-header-number header))
9511 gnus-newsgroup-sparse))
9512 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
9513 (gnus-rebuild-thread (mail-header-id header))
9514 (gnus-summary-goto-subject number nil t))
9515 (when (and (numberp number)
9517 ;; We have to update the boundaries even if we can't fetch the
9518 ;; article if ID is a number -- so that the next `P' or `N'
9519 ;; command will fetch the previous (or next) article even
9520 ;; if the one we tried to fetch this time has been canceled.
9521 (and (> number gnus-newsgroup-end)
9522 (setq gnus-newsgroup-end number))
9523 (and (< number gnus-newsgroup-begin)
9524 (setq gnus-newsgroup-begin number))
9525 (setq gnus-newsgroup-unselected
9526 (delq number gnus-newsgroup-unselected)))
9527 ;; Report back a success?
9528 (and header (mail-header-number header))))
9530 (defun gnus-summary-work-articles (n)
9531 "Return a list of articles to be worked upon. The prefix argument,
9532 the list of process marked articles, and the current article will be
9533 taken into consideration."
9535 ((and n (numberp n))
9536 ;; A numerical prefix has been given.
9537 (let ((backward (< n 0))
9543 (push (setq article (gnus-summary-article-number))
9546 (gnus-summary-find-prev nil article)
9547 (gnus-summary-find-next nil article)))
9549 (nreverse articles)))
9550 ((and (boundp 'transient-mark-mode)
9553 ;; Work on the region between point and mark.
9554 (let ((max (max (point) (mark)))
9557 (goto-char (min (point) (mark)))
9560 (push (setq article (gnus-summary-article-number)) articles)
9561 (gnus-summary-find-next nil article)
9563 (nreverse articles))))
9564 (gnus-newsgroup-processable
9565 ;; There are process-marked articles present.
9566 (reverse gnus-newsgroup-processable))
9568 ;; Just return the current article.
9569 (list (gnus-summary-article-number)))))
9571 (defun gnus-summary-search-group (&optional backward use-level)
9572 "Search for next unread newsgroup.
9573 If optional argument BACKWARD is non-nil, search backward instead."
9575 (set-buffer gnus-group-buffer)
9576 (if (gnus-group-search-forward
9577 backward nil (if use-level (gnus-group-group-level) nil))
9578 (gnus-group-group-name))))
9580 (defun gnus-summary-best-group (&optional exclude-group)
9581 "Find the name of the best unread group.
9582 If EXCLUDE-GROUP, do not go to this group."
9584 (set-buffer gnus-group-buffer)
9586 (gnus-group-best-unread-group exclude-group))))
9588 (defun gnus-summary-find-next (&optional unread article backward)
9589 (if backward (gnus-summary-find-prev)
9590 (let* ((dummy (gnus-summary-article-intangible-p))
9591 (article (or article (gnus-summary-article-number)))
9592 (arts (gnus-data-find-list article))
9594 (when (and (not dummy)
9595 (or (not gnus-summary-check-current)
9597 (not (gnus-data-unread-p (car arts)))))
9598 (setq arts (cdr arts)))
9603 (when (gnus-data-unread-p (car arts))
9604 (setq result (car arts)
9606 (setq arts (cdr arts)))
9609 (goto-char (gnus-data-pos result))
9610 (gnus-data-number result)))))
9612 (defun gnus-summary-find-prev (&optional unread article)
9613 (let* ((eobp (eobp))
9614 (article (or article (gnus-summary-article-number)))
9615 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
9617 (when (and (not eobp)
9618 (or (not gnus-summary-check-current)
9620 (not (gnus-data-unread-p (car arts)))))
9621 (setq arts (cdr arts)))
9626 (and (gnus-data-unread-p (car arts))
9627 (setq result (car arts)
9629 (setq arts (cdr arts)))
9633 (goto-char (gnus-data-pos result))
9634 (gnus-data-number result)))))
9636 (defun gnus-summary-find-subject (subject &optional unread backward article)
9637 (let* ((simp-subject (gnus-simplify-subject-fully subject))
9638 (article (or article (gnus-summary-article-number)))
9639 (articles (gnus-data-list backward))
9640 (arts (gnus-data-find-list article articles))
9642 (when (or (not gnus-summary-check-current)
9644 (not (gnus-data-unread-p (car arts))))
9645 (setq arts (cdr arts)))
9647 (and (or (not unread)
9648 (gnus-data-unread-p (car arts)))
9649 (vectorp (gnus-data-header (car arts)))
9651 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
9652 (setq result (car arts)
9654 (setq arts (cdr arts)))
9656 (goto-char (gnus-data-pos result))
9657 (gnus-data-number result))))
9659 (defun gnus-summary-search-forward (&optional unread subject backward)
9660 "Search forward for an article.
9661 If UNREAD, look for unread articles. If SUBJECT, look for
9662 articles with that subject. If BACKWARD, search backward instead."
9663 (cond (subject (gnus-summary-find-subject subject unread backward))
9664 (backward (gnus-summary-find-prev unread))
9665 (t (gnus-summary-find-next unread))))
9667 (defun gnus-recenter (&optional n)
9668 "Center point in window and redisplay frame.
9669 Also do horizontal recentering."
9671 (when (and gnus-auto-center-summary
9672 (not (eq gnus-auto-center-summary 'vertical)))
9673 (gnus-horizontal-recenter))
9676 (defun gnus-summary-recenter ()
9677 "Center point in the summary window.
9678 If `gnus-auto-center-summary' is nil, or the article buffer isn't
9679 displayed, no centering will be performed."
9680 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
9681 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
9682 (let* ((top (cond ((< (window-height) 4) 0)
9683 ((< (window-height) 7) 1)
9685 (height (1- (window-height)))
9686 (bottom (save-excursion (goto-char (point-max))
9687 (forward-line (- height))
9689 (window (get-buffer-window (current-buffer))))
9690 ;; The user has to want it.
9691 (when gnus-auto-center-summary
9692 (when (get-buffer-window gnus-article-buffer)
9693 ;; Only do recentering when the article buffer is displayed,
9694 ;; Set the window start to either `bottom', which is the biggest
9695 ;; possible valid number, or the second line from the top,
9696 ;; whichever is the least.
9698 window (min bottom (save-excursion
9699 (forward-line (- top)) (point)))))
9700 ;; Do horizontal recentering while we're at it.
9701 (when (and (get-buffer-window (current-buffer) t)
9702 (not (eq gnus-auto-center-summary 'vertical)))
9703 (let ((selected (selected-window)))
9704 (select-window (get-buffer-window (current-buffer) t))
9705 (gnus-summary-position-point)
9706 (gnus-horizontal-recenter)
9707 (select-window selected))))))
9709 (defun gnus-horizontal-recenter ()
9710 "Recenter the current buffer horizontally."
9711 (if (< (current-column) (/ (window-width) 2))
9712 (set-window-hscroll (get-buffer-window (current-buffer) t) 0)
9713 (let* ((orig (point))
9714 (end (window-end (get-buffer-window (current-buffer) t)))
9716 ;; Find the longest line currently displayed in the window.
9717 (goto-char (window-start))
9718 (while (and (not (eobp))
9721 (setq max (max max (current-column)))
9724 ;; Scroll horizontally to center (sort of) the point.
9725 (if (> max (window-width))
9727 (get-buffer-window (current-buffer) t)
9728 (min (- (current-column) (/ (window-width) 3))
9729 (+ 2 (- max (window-width)))))
9730 (set-window-hscroll (get-buffer-window (current-buffer) t) 0))
9733 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
9734 (defun gnus-short-group-name (group &optional levels)
9735 "Collapse GROUP name LEVELS."
9742 (while (string-match "\\." group skip)
9743 (setq skip (match-end 0)
9746 (if (string-match ":" group)
9747 (setq foreign (substring group 0 (match-end 0))
9748 group (substring group (match-end 0))))
9750 (if (and (string-match "\\." group)
9751 (> levels (- gnus-group-uncollapsed-levels 1)))
9752 (setq name (concat name (substring group 0 1))
9753 group (substring group (match-end 0))
9755 name (concat name "."))
9756 (setq name (concat foreign name group)
9760 (defun gnus-summary-jump-to-group (newsgroup)
9761 "Move point to NEWSGROUP in group mode buffer."
9762 ;; Keep update point of group mode buffer if visible.
9763 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
9764 (save-window-excursion
9765 ;; Take care of tree window mode.
9766 (if (get-buffer-window gnus-group-buffer)
9767 (pop-to-buffer gnus-group-buffer))
9768 (gnus-group-jump-to-group newsgroup))
9770 ;; Take care of tree window mode.
9771 (if (get-buffer-window gnus-group-buffer)
9772 (pop-to-buffer gnus-group-buffer)
9773 (set-buffer gnus-group-buffer))
9774 (gnus-group-jump-to-group newsgroup))))
9776 ;; This function returns a list of article numbers based on the
9777 ;; difference between the ranges of read articles in this group and
9778 ;; the range of active articles.
9779 (defun gnus-list-of-unread-articles (group)
9780 (let* ((read (gnus-info-read (gnus-get-info group)))
9781 (active (gnus-active group))
9784 ;; If none are read, then all are unread.
9786 (setq first (car active))
9787 ;; If the range of read articles is a single range, then the
9788 ;; first unread article is the article after the last read
9789 ;; article. Sounds logical, doesn't it?
9790 (if (not (listp (cdr read)))
9791 (setq first (1+ (cdr read)))
9792 ;; `read' is a list of ranges.
9793 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
9798 (while (< first nlast)
9799 (setq unread (cons first unread))
9800 (setq first (1+ first))))
9801 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
9802 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
9803 (setq read (cdr read)))))
9804 ;; And add the last unread articles.
9805 (while (<= first last)
9806 (setq unread (cons first unread))
9807 (setq first (1+ first)))
9808 ;; Return the list of unread articles.
9811 (defun gnus-list-of-read-articles (group)
9812 "Return a list of unread, unticked and non-dormant articles."
9813 (let* ((info (gnus-get-info group))
9814 (marked (gnus-info-marks info))
9815 (active (gnus-active group)))
9817 (gnus-set-difference
9818 (gnus-sorted-complement
9819 (gnus-uncompress-range active)
9820 (gnus-list-of-unread-articles group))
9822 (gnus-uncompress-range (cdr (assq 'dormant marked)))
9823 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
9825 ;; Various summary commands
9827 (defun gnus-summary-universal-argument (arg)
9828 "Perform any operation on all articles that are process/prefixed."
9830 (gnus-set-global-variables)
9831 (let ((articles (gnus-summary-work-articles arg))
9838 (substitute-command-keys
9839 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
9842 (gnus-error 1 "Undefined key")
9845 (gnus-summary-goto-subject (setq article (pop articles)))
9846 (command-execute func)
9847 (gnus-summary-remove-process-mark article)))))
9848 (gnus-summary-position-point))
9850 (defun gnus-summary-toggle-truncation (&optional arg)
9851 "Toggle truncation of summary lines.
9852 With arg, turn line truncation on iff arg is positive."
9854 (setq truncate-lines
9855 (if (null arg) (not truncate-lines)
9856 (> (prefix-numeric-value arg) 0)))
9859 (defun gnus-summary-reselect-current-group (&optional all rescan)
9860 "Exit and then reselect the current newsgroup.
9861 The prefix argument ALL means to select all articles."
9863 (gnus-set-global-variables)
9864 (let ((current-subject (gnus-summary-article-number))
9865 (group gnus-newsgroup-name))
9866 (setq gnus-newsgroup-begin nil)
9868 ;; We have to adjust the point of group mode buffer because the
9869 ;; current point was moved to the next unread newsgroup by
9871 (gnus-summary-jump-to-group group)
9874 (gnus-group-get-new-news-this-group 1)))
9875 (gnus-group-read-group all t)
9876 (gnus-summary-goto-subject current-subject)))
9878 (defun gnus-summary-rescan-group (&optional all)
9879 "Exit the newsgroup, ask for new articles, and select the newsgroup."
9881 (gnus-summary-reselect-current-group all t))
9883 (defun gnus-summary-update-info ()
9884 (let* ((group gnus-newsgroup-name))
9885 (when gnus-newsgroup-kill-headers
9886 (setq gnus-newsgroup-killed
9887 (gnus-compress-sequence
9889 (gnus-set-sorted-intersection
9890 (gnus-uncompress-range gnus-newsgroup-killed)
9891 (setq gnus-newsgroup-unselected
9892 (sort gnus-newsgroup-unselected '<)))
9893 (setq gnus-newsgroup-unreads
9894 (sort gnus-newsgroup-unreads '<))) t)))
9895 (unless (listp (cdr gnus-newsgroup-killed))
9896 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
9897 (let ((headers gnus-newsgroup-headers))
9898 (run-hooks 'gnus-exit-group-hook)
9899 (unless gnus-save-score
9900 (setq gnus-newsgroup-scored nil))
9901 ;; Set the new ranges of read articles.
9902 (gnus-update-read-articles
9903 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
9904 ;; Set the current article marks.
9906 ;; Do the cross-ref thing.
9907 (when gnus-use-cross-reference
9908 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
9909 ;; Do adaptive scoring, and possibly save score files.
9910 (when gnus-newsgroup-adaptive
9911 (gnus-score-adaptive))
9912 (when gnus-use-scoring
9914 ;; Do not switch windows but change the buffer to work.
9915 (set-buffer gnus-group-buffer)
9916 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
9917 (gnus-group-update-group group)))))
9919 (defun gnus-summary-exit (&optional temporary)
9920 "Exit reading current newsgroup, and then return to group selection mode.
9921 gnus-exit-group-hook is called with no arguments if that value is non-nil."
9923 (gnus-set-global-variables)
9924 (gnus-kill-save-kill-buffer)
9925 (let* ((group gnus-newsgroup-name)
9926 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
9928 (buf (current-buffer)))
9929 (run-hooks 'gnus-summary-prepare-exit-hook)
9930 ;; If we have several article buffers, we kill them at exit.
9931 (unless gnus-single-article-buffer
9932 (gnus-kill-buffer gnus-original-article-buffer)
9933 (setq gnus-article-current nil))
9934 (when gnus-use-cache
9935 (gnus-cache-possibly-remove-articles)
9936 (gnus-cache-save-buffers))
9937 (when gnus-use-trees
9938 (gnus-tree-close group))
9939 ;; Make all changes in this group permanent.
9941 (gnus-summary-update-info))
9942 (gnus-close-group group)
9943 ;; Make sure where I was, and go to next newsgroup.
9944 (set-buffer gnus-group-buffer)
9946 (gnus-group-jump-to-group group))
9947 (run-hooks 'gnus-summary-exit-hook)
9949 (gnus-group-next-unread-group 1))
9952 ;; If we have several article buffers, we kill them at exit.
9953 (unless gnus-single-article-buffer
9954 (gnus-kill-buffer gnus-article-buffer)
9955 (gnus-kill-buffer gnus-original-article-buffer)
9956 (setq gnus-article-current nil))
9958 (if (not gnus-kill-summary-on-exit)
9959 (gnus-deaden-summary)
9960 ;; We set all buffer-local variables to nil. It is unclear why
9961 ;; this is needed, but if we don't, buffer-local variables are
9962 ;; not garbage-collected, it seems. This would the lead to en
9963 ;; ever-growing Emacs.
9964 (gnus-summary-clear-local-variables)
9965 (when (get-buffer gnus-article-buffer)
9966 (bury-buffer gnus-article-buffer))
9967 ;; We clear the global counterparts of the buffer-local
9968 ;; variables as well, just to be on the safe side.
9969 (gnus-configure-windows 'group 'force)
9970 (gnus-summary-clear-local-variables)
9971 ;; Return to group mode buffer.
9972 (if (eq mode 'gnus-summary-mode)
9973 (gnus-kill-buffer buf)))
9974 (setq gnus-current-select-method gnus-select-method)
9975 (pop-to-buffer gnus-group-buffer)
9976 ;; Clear the current group name.
9977 (if (not quit-config)
9979 (gnus-group-jump-to-group group)
9980 (gnus-group-next-unread-group 1)
9981 (gnus-configure-windows 'group 'force))
9982 (if (not (buffer-name (car quit-config)))
9983 (gnus-configure-windows 'group 'force)
9984 (set-buffer (car quit-config))
9985 (and (eq major-mode 'gnus-summary-mode)
9986 (gnus-set-global-variables))
9987 (gnus-configure-windows (cdr quit-config))))
9989 (setq gnus-newsgroup-name nil)))))
9991 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
9992 (defun gnus-summary-exit-no-update (&optional no-questions)
9993 "Quit reading current newsgroup without updating read article info."
9995 (gnus-set-global-variables)
9996 (let* ((group gnus-newsgroup-name)
9997 (quit-config (gnus-group-quit-config group)))
9998 (when (or no-questions
10000 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
10001 ;; If we have several article buffers, we kill them at exit.
10002 (unless gnus-single-article-buffer
10003 (gnus-kill-buffer gnus-article-buffer)
10004 (gnus-kill-buffer gnus-original-article-buffer)
10005 (setq gnus-article-current nil))
10006 (if (not gnus-kill-summary-on-exit)
10007 (gnus-deaden-summary)
10008 (gnus-close-group group)
10009 (gnus-summary-clear-local-variables)
10010 (set-buffer gnus-group-buffer)
10011 (gnus-summary-clear-local-variables)
10012 (when (get-buffer gnus-summary-buffer)
10013 (kill-buffer gnus-summary-buffer)))
10014 (unless gnus-single-article-buffer
10015 (setq gnus-article-current nil))
10016 (when gnus-use-trees
10017 (gnus-tree-close group))
10018 (when (get-buffer gnus-article-buffer)
10019 (bury-buffer gnus-article-buffer))
10020 ;; Return to the group buffer.
10021 (gnus-configure-windows 'group 'force)
10022 ;; Clear the current group name.
10023 (setq gnus-newsgroup-name nil)
10024 (when (equal (gnus-group-group-name) group)
10025 (gnus-group-next-unread-group 1))
10027 (if (not (buffer-name (car quit-config)))
10028 (gnus-configure-windows 'group 'force)
10029 (set-buffer (car quit-config))
10030 (when (eq major-mode 'gnus-summary-mode)
10031 (gnus-set-global-variables))
10032 (gnus-configure-windows (cdr quit-config)))))))
10034 ;;; Dead summaries.
10036 (defvar gnus-dead-summary-mode-map nil)
10038 (if gnus-dead-summary-mode-map
10040 (setq gnus-dead-summary-mode-map (make-keymap))
10041 (suppress-keymap gnus-dead-summary-mode-map)
10042 (substitute-key-definition
10043 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
10044 (let ((keys '("\C-d" "\r" "\177")))
10046 (define-key gnus-dead-summary-mode-map
10047 (pop keys) 'gnus-summary-wake-up-the-dead))))
10049 (defvar gnus-dead-summary-mode nil
10050 "Minor mode for Gnus summary buffers.")
10052 (defun gnus-dead-summary-mode (&optional arg)
10053 "Minor mode for Gnus summary buffers."
10055 (when (eq major-mode 'gnus-summary-mode)
10056 (make-local-variable 'gnus-dead-summary-mode)
10057 (setq gnus-dead-summary-mode
10058 (if (null arg) (not gnus-dead-summary-mode)
10059 (> (prefix-numeric-value arg) 0)))
10060 (when gnus-dead-summary-mode
10061 (unless (assq 'gnus-dead-summary-mode minor-mode-alist)
10062 (push '(gnus-dead-summary-mode " Dead") minor-mode-alist))
10063 (unless (assq 'gnus-dead-summary-mode minor-mode-map-alist)
10064 (push (cons 'gnus-dead-summary-mode gnus-dead-summary-mode-map)
10065 minor-mode-map-alist)))))
10067 (defun gnus-deaden-summary ()
10068 "Make the current summary buffer into a dead summary buffer."
10069 ;; Kill any previous dead summary buffer.
10070 (when (and gnus-dead-summary
10071 (buffer-name gnus-dead-summary))
10073 (set-buffer gnus-dead-summary)
10074 (when gnus-dead-summary-mode
10075 (kill-buffer (current-buffer)))))
10076 ;; Make this the current dead summary.
10077 (setq gnus-dead-summary (current-buffer))
10078 (gnus-dead-summary-mode 1)
10079 (let ((name (buffer-name)))
10080 (when (string-match "Summary" name)
10082 (concat (substring name 0 (match-beginning 0)) "Dead "
10083 (substring name (match-beginning 0))) t))))
10085 (defun gnus-kill-or-deaden-summary (buffer)
10086 "Kill or deaden the summary BUFFER."
10087 (when (and (buffer-name buffer)
10088 (not gnus-single-article-buffer))
10090 (set-buffer buffer)
10091 (gnus-kill-buffer gnus-article-buffer)
10092 (gnus-kill-buffer gnus-original-article-buffer)))
10093 (cond (gnus-kill-summary-on-exit
10094 (when (and gnus-use-trees
10095 (and (get-buffer buffer)
10096 (buffer-name (get-buffer buffer))))
10098 (set-buffer (get-buffer buffer))
10099 (gnus-tree-close gnus-newsgroup-name)))
10100 (gnus-kill-buffer buffer))
10101 ((and (get-buffer buffer)
10102 (buffer-name (get-buffer buffer)))
10104 (set-buffer buffer)
10105 (gnus-deaden-summary)))))
10107 (defun gnus-summary-wake-up-the-dead (&rest args)
10108 "Wake up the dead summary buffer."
10110 (gnus-dead-summary-mode -1)
10111 (let ((name (buffer-name)))
10112 (when (string-match "Dead " name)
10114 (concat (substring name 0 (match-beginning 0))
10115 (substring name (match-end 0))) t)))
10116 (gnus-message 3 "This dead summary is now alive again"))
10118 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
10119 (defun gnus-summary-fetch-faq (&optional faq-dir)
10120 "Fetch the FAQ for the current group.
10121 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
10125 (if current-prefix-arg
10127 "Faq dir: " (and (listp gnus-group-faq-directory)
10128 gnus-group-faq-directory)))))
10129 (let (gnus-faq-buffer)
10130 (and (setq gnus-faq-buffer
10131 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
10132 (gnus-configure-windows 'summary-faq))))
10134 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
10135 (defun gnus-summary-describe-group (&optional force)
10136 "Describe the current newsgroup."
10138 (gnus-group-describe-group force gnus-newsgroup-name))
10140 (defun gnus-summary-describe-briefly ()
10141 "Describe summary mode commands briefly."
10144 (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")))
10146 ;; Walking around group mode buffer from summary mode.
10148 (defun gnus-summary-next-group (&optional no-article target-group backward)
10149 "Exit current newsgroup and then select next unread newsgroup.
10150 If prefix argument NO-ARTICLE is non-nil, no article is selected
10151 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
10152 previous group instead."
10154 (gnus-set-global-variables)
10155 (let ((current-group gnus-newsgroup-name)
10156 (current-buffer (current-buffer))
10158 ;; First we semi-exit this group to update Xrefs and all variables.
10159 ;; We can't do a real exit, because the window conf must remain
10160 ;; the same in case the user is prompted for info, and we don't
10161 ;; want the window conf to change before that...
10162 (gnus-summary-exit t)
10163 (while (not entered)
10164 ;; Then we find what group we are supposed to enter.
10165 (set-buffer gnus-group-buffer)
10166 (gnus-group-jump-to-group current-group)
10169 (if (eq gnus-keep-same-level 'best)
10170 (gnus-summary-best-group gnus-newsgroup-name)
10171 (gnus-summary-search-group backward gnus-keep-same-level))))
10172 (if (not target-group)
10173 ;; There are no further groups, so we return to the group
10176 (gnus-message 5 "Returning to the group buffer")
10178 (set-buffer current-buffer)
10179 (gnus-summary-exit))
10180 ;; We try to enter the target group.
10181 (gnus-group-jump-to-group target-group)
10182 (let ((unreads (gnus-group-group-unread)))
10183 (if (and (or (eq t unreads)
10184 (and unreads (not (zerop unreads))))
10185 (gnus-summary-read-group
10186 target-group nil no-article current-buffer))
10188 (setq current-group target-group
10189 target-group nil)))))))
10191 (defun gnus-summary-prev-group (&optional no-article)
10192 "Exit current newsgroup and then select previous unread newsgroup.
10193 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
10195 (gnus-summary-next-group no-article nil t))
10197 ;; Walking around summary lines.
10199 (defun gnus-summary-first-subject (&optional unread)
10200 "Go to the first unread subject.
10201 If UNREAD is non-nil, go to the first unread article.
10202 Returns the article selected or nil if there are no unread articles."
10207 ((null gnus-newsgroup-data)
10208 (gnus-message 3 "No articles in the group")
10210 ;; Pick the first article.
10212 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
10213 (gnus-data-number (car gnus-newsgroup-data)))
10214 ;; No unread articles.
10215 ((null gnus-newsgroup-unreads)
10216 (gnus-message 3 "No more unread articles")
10218 ;; Find the first unread article.
10220 (let ((data gnus-newsgroup-data))
10222 (not (gnus-data-unread-p (car data))))
10223 (setq data (cdr data)))
10226 (goto-char (gnus-data-pos (car data)))
10227 (gnus-data-number (car data)))))))
10228 (gnus-summary-position-point)))
10230 (defun gnus-summary-next-subject (n &optional unread dont-display)
10231 "Go to next N'th summary line.
10232 If N is negative, go to the previous N'th subject line.
10233 If UNREAD is non-nil, only unread articles are selected.
10234 The difference between N and the actual number of steps taken is
10237 (let ((backward (< n 0))
10239 (while (and (> n 0)
10241 (gnus-summary-find-prev unread)
10242 (gnus-summary-find-next unread)))
10244 (if (/= 0 n) (gnus-message 7 "No more%s articles"
10245 (if unread " unread" "")))
10246 (unless dont-display
10247 (gnus-summary-recenter)
10248 (gnus-summary-position-point))
10251 (defun gnus-summary-next-unread-subject (n)
10252 "Go to next N'th unread summary line."
10254 (gnus-summary-next-subject n t))
10256 (defun gnus-summary-prev-subject (n &optional unread)
10257 "Go to previous N'th summary line.
10258 If optional argument UNREAD is non-nil, only unread article is selected."
10260 (gnus-summary-next-subject (- n) unread))
10262 (defun gnus-summary-prev-unread-subject (n)
10263 "Go to previous N'th unread summary line."
10265 (gnus-summary-next-subject (- n) t))
10267 (defun gnus-summary-goto-subject (article &optional force silent)
10268 "Go the subject line of ARTICLE.
10269 If FORCE, also allow jumping to articles not currently shown."
10271 (data (gnus-data-find article)))
10272 ;; We read in the article if we have to.
10275 (gnus-summary-insert-subject article (and (vectorp force) force) t)
10276 (setq data (gnus-data-find article)))
10281 (gnus-message 3 "Can't find article %d" article))
10283 (goto-char (gnus-data-pos data))
10286 ;; Walking around summary lines with displaying articles.
10288 (defun gnus-summary-expand-window (&optional arg)
10289 "Make the summary buffer take up the entire Emacs frame.
10290 Given a prefix, will force an `article' buffer configuration."
10292 (gnus-set-global-variables)
10294 (gnus-configure-windows 'article 'force)
10295 (gnus-configure-windows 'summary 'force)))
10297 (defun gnus-summary-display-article (article &optional all-header)
10298 "Display ARTICLE in article buffer."
10299 (gnus-set-global-variables)
10303 (if gnus-summary-display-article-function
10304 (funcall gnus-summary-display-article-function article all-header)
10305 (gnus-article-prepare article all-header))
10306 (run-hooks 'gnus-select-article-hook)
10307 (unless (zerop gnus-current-article)
10308 (gnus-summary-goto-subject gnus-current-article))
10309 (gnus-summary-recenter)
10310 (when gnus-use-trees
10311 (gnus-possibly-generate-tree article)
10312 (gnus-highlight-selected-tree article))
10313 ;; Successfully display article.
10314 (gnus-article-set-window-start
10315 (cdr (assq article gnus-newsgroup-bookmarks))))))
10317 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
10318 "Select the current article.
10319 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
10320 non-nil, the article will be re-fetched even if it already present in
10321 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
10323 ;; Make sure we are in the summary buffer to work around bbdb bug.
10324 (unless (eq major-mode 'gnus-summary-mode)
10325 (set-buffer gnus-summary-buffer))
10326 (let ((article (or article (gnus-summary-article-number)))
10327 (all-headers (not (not all-headers))) ;Must be T or NIL.
10328 gnus-summary-display-article-function
10331 (gnus-summary-article-pseudo-p article)
10332 (error "This is a pseudo-article."))
10335 (set-buffer gnus-summary-buffer)
10336 (if (or (and gnus-single-article-buffer
10337 (or (null gnus-current-article)
10338 (null gnus-article-current)
10339 (null (get-buffer gnus-article-buffer))
10340 (not (eq article (cdr gnus-article-current)))
10341 (not (equal (car gnus-article-current)
10342 gnus-newsgroup-name))))
10343 (and (not gnus-single-article-buffer)
10344 (or (null gnus-current-article)
10345 (not (eq gnus-current-article article))))
10347 ;; The requested article is different from the current article.
10349 (gnus-summary-display-article article all-headers)
10350 (setq did article))
10351 (if (or all-headers gnus-show-all-headers)
10352 (gnus-article-show-all-headers))
10355 (gnus-article-set-window-start
10356 (cdr (assq article gnus-newsgroup-bookmarks)))))))
10358 (defun gnus-summary-set-current-mark (&optional current-mark)
10359 "Obsolete function."
10362 (defun gnus-summary-next-article (&optional unread subject backward push)
10363 "Select the next article.
10364 If UNREAD, only unread articles are selected.
10365 If SUBJECT, only articles with SUBJECT are selected.
10366 If BACKWARD, the previous article is selected instead of the next."
10368 (gnus-set-global-variables)
10370 ;; Is there such an article?
10371 ((and (gnus-summary-search-forward unread subject backward)
10372 (or (gnus-summary-display-article (gnus-summary-article-number))
10373 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
10374 (gnus-summary-position-point))
10375 ;; If not, we try the first unread, if that is wanted.
10377 gnus-auto-select-same
10378 (or (gnus-summary-first-unread-article)
10379 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
10380 (gnus-summary-position-point)
10381 (gnus-message 6 "Wrapped"))
10382 ;; Try to get next/previous article not displayed in this group.
10383 ((and gnus-auto-extend-newsgroup
10384 (not unread) (not subject))
10385 (gnus-summary-goto-article
10386 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
10388 ;; Go to next/previous group.
10390 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
10391 (gnus-summary-jump-to-group gnus-newsgroup-name))
10392 (let ((cmd last-command-char)
10394 (if (eq gnus-keep-same-level 'best)
10395 (gnus-summary-best-group gnus-newsgroup-name)
10396 (gnus-summary-search-group backward gnus-keep-same-level))))
10397 ;; For some reason, the group window gets selected. We change
10399 (select-window (get-buffer-window (current-buffer)))
10400 ;; Select next unread newsgroup automagically.
10402 ((not gnus-auto-select-next)
10403 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
10404 ((or (eq gnus-auto-select-next 'quietly)
10405 (and (eq gnus-auto-select-next 'slightly-quietly)
10407 (and (eq gnus-auto-select-next 'almost-quietly)
10408 (gnus-summary-last-article-p)))
10410 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
10411 (gnus-summary-exit)
10412 (gnus-message 7 "No more%s articles (%s)..."
10413 (if unread " unread" "")
10414 (if group (concat "selecting " group)
10416 (gnus-summary-next-group nil group backward)))
10418 (gnus-summary-walk-group-buffer
10419 gnus-newsgroup-name cmd unread backward)))))))
10421 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward)
10422 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
10423 (?\C-p (gnus-group-prev-unread-group 1))))
10424 keve key group ended)
10426 (set-buffer gnus-group-buffer)
10427 (gnus-summary-jump-to-group from-group)
10429 (if (eq gnus-keep-same-level 'best)
10430 (gnus-summary-best-group gnus-newsgroup-name)
10431 (gnus-summary-search-group backward gnus-keep-same-level))))
10434 5 "No more%s articles%s" (if unread " unread" "")
10436 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
10437 (format " (Type %s for %s [%s])"
10438 (single-key-description cmd) group
10439 (car (gnus-gethash group gnus-newsrc-hashtb)))
10440 (format " (Type %s to exit %s)"
10441 (single-key-description cmd)
10442 gnus-newsgroup-name)))
10443 ;; Confirm auto selection.
10444 (setq key (car (setq keve (gnus-read-event-char))))
10447 ((assq key keystrokes)
10448 (let ((obuf (current-buffer)))
10449 (switch-to-buffer gnus-group-buffer)
10451 (gnus-group-jump-to-group group))
10452 (eval (cadr (assq key keystrokes)))
10453 (setq group (gnus-group-group-name))
10454 (switch-to-buffer obuf))
10457 (if (or (not group)
10458 (gnus-ephemeral-group-p gnus-newsgroup-name))
10459 (gnus-summary-exit)
10460 (gnus-summary-next-group nil group backward)))
10462 (push (cdr keve) unread-command-events))))))
10464 (defun gnus-read-event-char ()
10465 "Get the next event."
10466 (let ((event (read-event)))
10467 (cons (and (numberp event) event) event)))
10469 (defun gnus-summary-next-unread-article ()
10470 "Select unread article after current one."
10472 (gnus-summary-next-article t (and gnus-auto-select-same
10473 (gnus-summary-article-subject))))
10475 (defun gnus-summary-prev-article (&optional unread subject)
10476 "Select the article after the current one.
10477 If UNREAD is non-nil, only unread articles are selected."
10479 (gnus-summary-next-article unread subject t))
10481 (defun gnus-summary-prev-unread-article ()
10482 "Select unred article before current one."
10484 (gnus-summary-prev-article t (and gnus-auto-select-same
10485 (gnus-summary-article-subject))))
10487 (defun gnus-summary-next-page (&optional lines circular)
10488 "Show next page of the selected article.
10489 If at the end of the current article, select the next article.
10490 LINES says how many lines should be scrolled up.
10492 If CIRCULAR is non-nil, go to the start of the article instead of
10493 selecting the next article when reaching the end of the current
10496 (setq gnus-summary-buffer (current-buffer))
10497 (gnus-set-global-variables)
10498 (let ((article (gnus-summary-article-number))
10500 (gnus-configure-windows 'article)
10501 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
10502 (if (and (eq gnus-summary-goto-unread 'never)
10503 (not (gnus-summary-last-article-p article)))
10504 (gnus-summary-next-article)
10505 (gnus-summary-next-unread-article))
10506 (if (or (null gnus-current-article)
10507 (null gnus-article-current)
10508 (/= article (cdr gnus-article-current))
10509 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10510 ;; Selected subject is different from current article's.
10511 (gnus-summary-display-article article)
10512 (gnus-eval-in-buffer-window gnus-article-buffer
10513 (setq endp (gnus-article-next-page lines)))
10516 (gnus-summary-beginning-of-article))
10518 (gnus-message 3 "End of message"))
10520 (if (and (eq gnus-summary-goto-unread 'never)
10521 (not (gnus-summary-last-article-p article)))
10522 (gnus-summary-next-article)
10523 (gnus-summary-next-unread-article)))))))
10524 (gnus-summary-recenter)
10525 (gnus-summary-position-point)))
10527 (defun gnus-summary-prev-page (&optional lines)
10528 "Show previous page of selected article.
10529 Argument LINES specifies lines to be scrolled down."
10531 (gnus-set-global-variables)
10532 (let ((article (gnus-summary-article-number)))
10533 (gnus-configure-windows 'article)
10534 (if (or (null gnus-current-article)
10535 (null gnus-article-current)
10536 (/= article (cdr gnus-article-current))
10537 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10538 ;; Selected subject is different from current article's.
10539 (gnus-summary-display-article article)
10540 (gnus-summary-recenter)
10541 (gnus-eval-in-buffer-window gnus-article-buffer
10542 (gnus-article-prev-page lines))))
10543 (gnus-summary-position-point))
10545 (defun gnus-summary-scroll-up (lines)
10546 "Scroll up (or down) one line current article.
10547 Argument LINES specifies lines to be scrolled up (or down if negative)."
10549 (gnus-set-global-variables)
10550 (gnus-configure-windows 'article)
10551 (gnus-summary-show-thread)
10552 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
10553 (gnus-eval-in-buffer-window gnus-article-buffer
10555 (if (gnus-article-next-page lines)
10556 (gnus-message 3 "End of message")))
10558 (gnus-article-prev-page (- lines))))))
10559 (gnus-summary-recenter)
10560 (gnus-summary-position-point))
10562 (defun gnus-summary-next-same-subject ()
10563 "Select next article which has the same subject as current one."
10565 (gnus-set-global-variables)
10566 (gnus-summary-next-article nil (gnus-summary-article-subject)))
10568 (defun gnus-summary-prev-same-subject ()
10569 "Select previous article which has the same subject as current one."
10571 (gnus-set-global-variables)
10572 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
10574 (defun gnus-summary-next-unread-same-subject ()
10575 "Select next unread article which has the same subject as current one."
10577 (gnus-set-global-variables)
10578 (gnus-summary-next-article t (gnus-summary-article-subject)))
10580 (defun gnus-summary-prev-unread-same-subject ()
10581 "Select previous unread article which has the same subject as current one."
10583 (gnus-set-global-variables)
10584 (gnus-summary-prev-article t (gnus-summary-article-subject)))
10586 (defun gnus-summary-first-unread-article ()
10587 "Select the first unread article.
10588 Return nil if there are no unread articles."
10590 (gnus-set-global-variables)
10592 (if (gnus-summary-first-subject t)
10594 (gnus-summary-show-thread)
10595 (gnus-summary-first-subject t)
10596 (gnus-summary-display-article (gnus-summary-article-number))))
10597 (gnus-summary-position-point)))
10599 (defun gnus-summary-best-unread-article ()
10600 "Select the unread article with the highest score."
10602 (gnus-set-global-variables)
10603 (let ((best -1000000)
10604 (data gnus-newsgroup-data)
10607 (and (gnus-data-unread-p (car data))
10609 (gnus-summary-article-score (gnus-data-number (car data))))
10612 article (gnus-data-number (car data))))
10613 (setq data (cdr data)))
10616 (gnus-summary-goto-article article)
10617 (error "No unread articles"))
10618 (gnus-summary-position-point))))
10620 (defun gnus-summary-last-subject ()
10621 "Go to the last displayed subject line in the group."
10622 (let ((article (gnus-data-number (car (gnus-data-list t)))))
10624 (gnus-summary-goto-subject article))))
10626 (defun gnus-summary-goto-article (article &optional all-headers force)
10627 "Fetch ARTICLE and display it if it exists.
10628 If ALL-HEADERS is non-nil, no header lines are hidden."
10634 (mapcar (lambda (number) (list (int-to-string number)))
10635 gnus-newsgroup-limit)))
10639 (if (gnus-summary-goto-subject article force)
10640 (gnus-summary-display-article article all-headers)
10641 (gnus-message 4 "Couldn't go to article %s" article) nil)
10642 (gnus-summary-position-point)))
10644 (defun gnus-summary-goto-last-article ()
10645 "Go to the previously read article."
10648 (and gnus-last-article
10649 (gnus-summary-goto-article gnus-last-article))
10650 (gnus-summary-position-point)))
10652 (defun gnus-summary-pop-article (number)
10653 "Pop one article off the history and go to the previous.
10654 NUMBER articles will be popped off."
10657 (setq gnus-newsgroup-history
10658 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
10660 (gnus-summary-goto-article (car to))
10661 (error "Article history empty")))
10662 (gnus-summary-position-point))
10664 ;; Summary commands and functions for limiting the summary buffer.
10666 (defun gnus-summary-limit-to-articles (n)
10667 "Limit the summary buffer to the next N articles.
10668 If not given a prefix, use the process marked articles instead."
10670 (gnus-set-global-variables)
10672 (let ((articles (gnus-summary-work-articles n)))
10673 (setq gnus-newsgroup-processable nil)
10674 (gnus-summary-limit articles))
10675 (gnus-summary-position-point)))
10677 (defun gnus-summary-pop-limit (&optional total)
10678 "Restore the previous limit.
10679 If given a prefix, remove all limits."
10681 (gnus-set-global-variables)
10683 (setq gnus-newsgroup-limits
10684 (list (mapcar (lambda (h) (mail-header-number h))
10685 gnus-newsgroup-headers))))
10686 (unless gnus-newsgroup-limits
10687 (error "No limit to pop"))
10689 (gnus-summary-limit nil 'pop)
10690 (gnus-summary-position-point)))
10692 (defun gnus-summary-limit-to-subject (subject &optional header)
10693 "Limit the summary buffer to articles that have subjects that match a regexp."
10694 (interactive "sRegexp: ")
10696 (setq header "subject"))
10697 (when (not (equal "" subject))
10699 (let ((articles (gnus-summary-find-matching
10700 (or header "subject") subject 'all)))
10701 (or articles (error "Found no matches for \"%s\"" subject))
10702 (gnus-summary-limit articles))
10703 (gnus-summary-position-point))))
10705 (defun gnus-summary-limit-to-author (from)
10706 "Limit the summary buffer to articles that have authors that match a regexp."
10707 (interactive "sRegexp: ")
10708 (gnus-summary-limit-to-subject from "from"))
10710 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10712 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10714 (defun gnus-summary-limit-to-unread (&optional all)
10715 "Limit the summary buffer to articles that are not marked as read.
10716 If ALL is non-nil, limit strictly to unread articles."
10719 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
10720 (gnus-summary-limit-to-marks
10721 ;; Concat all the marks that say that an article is read and have
10723 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
10724 gnus-killed-mark gnus-kill-file-mark
10725 gnus-low-score-mark gnus-expirable-mark
10726 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark)
10729 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10730 (make-obsolete 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10732 (defun gnus-summary-limit-to-marks (marks &optional reverse)
10733 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
10734 If REVERSE, limit the summary buffer to articles that are not marked
10735 with MARKS. MARKS can either be a string of marks or a list of marks.
10736 Returns how many articles were removed."
10737 (interactive "sMarks: ")
10738 (gnus-set-global-variables)
10740 (let ((data gnus-newsgroup-data)
10741 (marks (if (listp marks) marks
10742 (append marks nil))) ; Transform to list.
10745 (and (if reverse (not (memq (gnus-data-mark (car data)) marks))
10746 (memq (gnus-data-mark (car data)) marks))
10747 (setq articles (cons (gnus-data-number (car data)) articles)))
10748 (setq data (cdr data)))
10749 (gnus-summary-limit articles))
10750 (gnus-summary-position-point)))
10752 (defun gnus-summary-limit-to-score (&optional score)
10753 "Limit to articles with score at or above SCORE."
10755 (gnus-set-global-variables)
10756 (setq score (if score
10757 (prefix-numeric-value score)
10758 (or gnus-summary-default-score 0)))
10759 (let ((data gnus-newsgroup-data)
10762 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
10764 (push (gnus-data-number (car data)) articles))
10765 (setq data (cdr data)))
10767 (gnus-summary-limit articles)
10768 (gnus-summary-position-point))))
10770 (defun gnus-summary-limit-include-dormant ()
10771 "Display all the hidden articles that are marked as dormant."
10773 (gnus-set-global-variables)
10774 (or gnus-newsgroup-dormant
10775 (error "There are no dormant articles in this group"))
10777 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
10778 (gnus-summary-position-point)))
10780 (defun gnus-summary-limit-exclude-dormant ()
10781 "Hide all dormant articles."
10783 (gnus-set-global-variables)
10785 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
10786 (gnus-summary-position-point)))
10788 (defun gnus-summary-limit-exclude-childless-dormant ()
10789 "Hide all dormant articles that have no children."
10791 (gnus-set-global-variables)
10792 (let ((data (gnus-data-list t))
10793 articles d children)
10794 ;; Find all articles that are either not dormant or have
10796 (while (setq d (pop data))
10797 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
10798 (and (setq children
10799 (gnus-article-children (gnus-data-number d)))
10802 (when (memq (car children) articles)
10807 (push (gnus-data-number d) articles)))
10808 ;; Do the limiting.
10810 (gnus-summary-limit articles)
10811 (gnus-summary-position-point))))
10813 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
10814 "Mark all unread excluded articles as read.
10815 If ALL, mark even excluded ticked and dormants as read."
10817 (let ((articles (gnus-sorted-complement
10819 (mapcar (lambda (h) (mail-header-number h))
10820 gnus-newsgroup-headers)
10822 (sort gnus-newsgroup-limit '<)))
10824 (setq gnus-newsgroup-unreads nil)
10826 (setq gnus-newsgroup-dormant nil
10827 gnus-newsgroup-marked nil
10828 gnus-newsgroup-reads
10830 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
10831 gnus-newsgroup-reads))
10832 (while (setq article (pop articles))
10833 (unless (or (memq article gnus-newsgroup-dormant)
10834 (memq article gnus-newsgroup-marked))
10835 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
10837 (defun gnus-summary-limit (articles &optional pop)
10839 ;; We pop the previous limit off the stack and use that.
10840 (setq articles (car gnus-newsgroup-limits)
10841 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
10842 ;; We use the new limit, so we push the old limit on the stack.
10843 (setq gnus-newsgroup-limits
10844 (cons gnus-newsgroup-limit gnus-newsgroup-limits)))
10846 (setq gnus-newsgroup-limit articles)
10847 (let ((total (length gnus-newsgroup-data))
10848 (data (gnus-data-find-list (gnus-summary-article-number)))
10850 ;; This will do all the work of generating the new summary buffer
10851 ;; according to the new limit.
10852 (gnus-summary-prepare)
10853 ;; Hide any threads, possibly.
10854 (and gnus-show-threads
10855 gnus-thread-hide-subtree
10856 (gnus-summary-hide-all-threads))
10857 ;; Try to return to the article you were at, or one in the
10860 ;; We try to find some article after the current one.
10862 (and (gnus-summary-goto-subject
10863 (gnus-data-number (car data)) nil t)
10866 (setq data (cdr data))))
10868 ;; If there is no data, that means that we were after the last
10869 ;; article. The same goes when we can't find any articles
10870 ;; after the current one.
10872 (goto-char (point-max))
10873 (gnus-summary-find-prev)))
10874 ;; We return how many articles were removed from the summary
10875 ;; buffer as a result of the new limit.
10876 (- total (length gnus-newsgroup-data))))
10878 (defsubst gnus-invisible-cut-children (threads)
10881 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
10886 (defsubst gnus-cut-thread (thread)
10887 "Go forwards in the thread until we find an article that we want to display."
10888 (when (or (eq gnus-fetch-old-headers 'some)
10889 (eq gnus-build-sparse-threads 'some)
10890 (eq gnus-build-sparse-threads 'more))
10891 ;; Deal with old-fetched headers and sparse threads.
10895 (memq (mail-header-number (car thread)) gnus-newsgroup-sparse)
10896 (memq (mail-header-number (car thread)) gnus-newsgroup-ancient))
10897 (or (<= (length (cdr thread)) 1)
10898 (gnus-invisible-cut-children (cdr thread))))
10899 (setq thread (cadr thread))))
10902 (defun gnus-cut-threads (threads)
10903 "Cut off all uninteresting articles from the beginning of threads."
10904 (when (or (eq gnus-fetch-old-headers 'some)
10905 (eq gnus-build-sparse-threads 'some)
10906 (eq gnus-build-sparse-threads 'more))
10907 (let ((th threads))
10909 (setcar th (gnus-cut-thread (car th)))
10910 (setq th (cdr th)))))
10911 ;; Remove nixed out threads.
10912 (delq nil threads))
10914 (defun gnus-summary-initial-limit (&optional show-if-empty)
10915 "Figure out what the initial limit is supposed to be on group entry.
10916 This entails weeding out unwanted dormants, low-scored articles,
10917 fetch-old-headers verbiage, and so on."
10918 ;; Most groups have nothing to remove.
10919 (if (or gnus-inhibit-limiting
10920 (and (null gnus-newsgroup-dormant)
10921 (not (eq gnus-fetch-old-headers 'some))
10922 (null gnus-summary-expunge-below)
10923 (not (eq gnus-build-sparse-threads 'some))
10924 (not (eq gnus-build-sparse-threads 'more))
10925 (null gnus-thread-expunge-below)
10926 (not gnus-use-nocem)))
10928 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10929 (setq gnus-newsgroup-limit nil)
10932 (unless (car (symbol-value node))
10933 ;; These threads have no parents -- they are roots.
10934 (let ((nodes (cdr (symbol-value node)))
10937 (if (and gnus-thread-expunge-below
10938 (< (gnus-thread-total-score (car nodes))
10939 gnus-thread-expunge-below))
10940 (gnus-expunge-thread (pop nodes))
10941 (setq thread (pop nodes))
10942 (gnus-summary-limit-children thread))))))
10943 gnus-newsgroup-dependencies)
10944 ;; If this limitation resulted in an empty group, we might
10945 ;; pop the previous limit and use it instead.
10946 (when (and (not gnus-newsgroup-limit)
10948 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
10949 gnus-newsgroup-limit))
10951 (defun gnus-summary-limit-children (thread)
10952 "Return 1 if this subthread is visible and 0 if it is not."
10953 ;; First we get the number of visible children to this thread. This
10954 ;; is done by recursing down the thread using this function, so this
10955 ;; will really go down to a leaf article first, before slowly
10956 ;; working its way up towards the root.
10960 (apply '+ (mapcar 'gnus-summary-limit-children
10963 (number (mail-header-number (car thread)))
10966 ;; If this article is dormant and has absolutely no visible
10967 ;; children, then this article isn't visible.
10968 (and (memq number gnus-newsgroup-dormant)
10970 ;; If this is "fetch-old-headered" and there is only one
10971 ;; visible child (or less), then we don't want this article.
10972 (and (eq gnus-fetch-old-headers 'some)
10973 (memq number gnus-newsgroup-ancient)
10975 ;; If this is a sparsely inserted article with no children,
10976 ;; we don't want it.
10977 (and (eq gnus-build-sparse-threads 'some)
10978 (memq number gnus-newsgroup-sparse)
10980 ;; If we use expunging, and this article is really
10981 ;; low-scored, then we don't want this article.
10982 (when (and gnus-summary-expunge-below
10984 (or (cdr (assq number gnus-newsgroup-scored))
10985 gnus-summary-default-score))
10986 gnus-summary-expunge-below))
10987 ;; We increase the expunge-tally here, but that has
10988 ;; nothing to do with the limits, really.
10989 (incf gnus-newsgroup-expunged-tally)
10990 ;; We also mark as read here, if that's wanted.
10991 (when (and gnus-summary-mark-below
10992 (< score gnus-summary-mark-below))
10993 (setq gnus-newsgroup-unreads
10994 (delq number gnus-newsgroup-unreads))
10995 (if gnus-newsgroup-auto-expire
10996 (push number gnus-newsgroup-expirable)
10997 (push (cons number gnus-low-score-mark)
10998 gnus-newsgroup-reads)))
11000 (and gnus-use-nocem
11001 (gnus-nocem-unwanted-article-p (mail-header-id (car thread)))))
11002 ;; Nope, invisible article.
11004 ;; Ok, this article is to be visible, so we add it to the limit
11006 (setq gnus-newsgroup-limit (cons number gnus-newsgroup-limit))
11009 (defun gnus-expunge-thread (thread)
11010 "Mark all articles in THREAD as read."
11011 (let* ((number (mail-header-number (car thread))))
11012 (incf gnus-newsgroup-expunged-tally)
11013 ;; We also mark as read here, if that's wanted.
11014 (setq gnus-newsgroup-unreads
11015 (delq number gnus-newsgroup-unreads))
11016 (if gnus-newsgroup-auto-expire
11017 (push number gnus-newsgroup-expirable)
11018 (push (cons number gnus-low-score-mark)
11019 gnus-newsgroup-reads)))
11020 ;; Go recursively through all subthreads.
11021 (mapcar 'gnus-expunge-thread (cdr thread)))
11023 ;; Summary article oriented commands
11025 (defun gnus-summary-refer-parent-article (n)
11026 "Refer parent article N times.
11027 The difference between N and the number of articles fetched is returned."
11029 (gnus-set-global-variables)
11033 (let* ((header (gnus-summary-article-header))
11035 ;; If we try to find the parent of the currently
11036 ;; displayed article, then we take a look at the actual
11037 ;; References header, since this is slightly more
11038 ;; reliable than the References field we got from the
11040 (if (and (eq (mail-header-number header)
11041 (cdr gnus-article-current))
11042 (equal gnus-newsgroup-name
11043 (car gnus-article-current)))
11045 (set-buffer gnus-original-article-buffer)
11046 (nnheader-narrow-to-headers)
11048 (message-fetch-field "references")
11050 ;; It's not the current article, so we take a bet on
11051 ;; the value we got from the server.
11052 (mail-header-references header))))
11053 (if (setq ref (or ref (mail-header-references header)))
11054 (or (gnus-summary-refer-article (gnus-parent-id ref))
11055 (gnus-message 1 "Couldn't find parent"))
11056 (gnus-message 1 "No references in article %d"
11057 (gnus-summary-article-number))
11060 (gnus-summary-position-point)
11063 (defun gnus-summary-refer-references ()
11064 "Fetch all articles mentioned in the References header.
11065 Return how many articles were fetched."
11067 (gnus-set-global-variables)
11068 (let ((ref (mail-header-references (gnus-summary-article-header)))
11069 (current (gnus-summary-article-number))
11071 ;; For each Message-ID in the References header...
11072 (while (string-match "<[^>]*>" ref)
11074 ;; ... fetch that article.
11075 (gnus-summary-refer-article
11076 (prog1 (match-string 0 ref)
11077 (setq ref (substring ref (match-end 0))))))
11078 (gnus-summary-goto-subject current)
11079 (gnus-summary-position-point)
11082 (defun gnus-summary-refer-article (message-id)
11083 "Fetch an article specified by MESSAGE-ID."
11084 (interactive "sMessage-ID: ")
11085 (when (and (stringp message-id)
11086 (not (zerop (length message-id))))
11087 ;; Construct the correct Message-ID if necessary.
11088 ;; Suggested by tale@pawl.rpi.edu.
11089 (unless (string-match "^<" message-id)
11090 (setq message-id (concat "<" message-id)))
11091 (unless (string-match ">$" message-id)
11092 (setq message-id (concat message-id ">")))
11093 (let* ((header (gnus-id-to-header message-id))
11094 (sparse (and header
11095 (memq (mail-header-number header)
11096 gnus-newsgroup-sparse))))
11099 ;; The article is present in the buffer, to we just go to it.
11100 (gnus-summary-goto-article
11101 (mail-header-number header) nil header)
11103 (gnus-summary-update-article (mail-header-number header))))
11104 ;; We fetch the article
11105 (let ((gnus-override-method
11106 (and (gnus-news-group-p gnus-newsgroup-name)
11107 gnus-refer-article-method))
11109 ;; Start the special refer-article method, if necessary.
11110 (when (and gnus-refer-article-method
11111 (gnus-news-group-p gnus-newsgroup-name))
11112 (gnus-check-server gnus-refer-article-method))
11113 ;; Fetch the header, and display the article.
11114 (if (setq number (gnus-summary-insert-subject message-id))
11115 (gnus-summary-select-article nil nil nil number)
11116 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
11118 (defun gnus-summary-enter-digest-group (&optional force)
11119 "Enter a digest group based on the current article."
11121 (gnus-set-global-variables)
11122 (gnus-summary-select-article)
11123 (let ((name (format "%s-%d"
11124 (gnus-group-prefixed-name
11125 gnus-newsgroup-name (list 'nndoc ""))
11126 gnus-current-article))
11127 (ogroup gnus-newsgroup-name)
11128 (case-fold-search t)
11129 (buf (current-buffer))
11132 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
11133 (insert-buffer-substring gnus-original-article-buffer)
11135 (goto-char (point-min))
11136 (or (search-forward "\n\n" nil t) (point)))
11137 (goto-char (point-min))
11138 (delete-matching-lines "^\\(Path\\):\\|^From ")
11141 (if (gnus-group-read-ephemeral-group
11142 name `(nndoc ,name (nndoc-address
11144 (nndoc-article-type ,(if force 'digest 'guess))) t)
11145 ;; Make all postings to this group go to the parent group.
11146 (nconc (gnus-info-params (gnus-get-info name))
11147 (list (cons 'to-group ogroup)))
11148 ;; Couldn't select this doc group.
11149 (switch-to-buffer buf)
11150 (gnus-set-global-variables)
11151 (gnus-configure-windows 'summary)
11152 (gnus-message 3 "Article couldn't be entered?"))
11153 (kill-buffer dig))))
11155 (defun gnus-summary-isearch-article (&optional regexp-p)
11156 "Do incremental search forward on the current article.
11157 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
11159 (gnus-set-global-variables)
11160 (gnus-summary-select-article)
11161 (gnus-configure-windows 'article)
11162 (gnus-eval-in-buffer-window gnus-article-buffer
11163 (goto-char (point-min))
11164 (isearch-forward regexp-p)))
11166 (defun gnus-summary-search-article-forward (regexp &optional backward)
11167 "Search for an article containing REGEXP forward.
11168 If BACKWARD, search backward instead."
11171 (format "Search article %s (regexp%s): "
11172 (if current-prefix-arg "backward" "forward")
11173 (if gnus-last-search-regexp
11174 (concat ", default " gnus-last-search-regexp)
11176 current-prefix-arg))
11177 (gnus-set-global-variables)
11178 (if (string-equal regexp "")
11179 (setq regexp (or gnus-last-search-regexp ""))
11180 (setq gnus-last-search-regexp regexp))
11181 (unless (gnus-summary-search-article regexp backward)
11182 (error "Search failed: \"%s\"" regexp)))
11184 (defun gnus-summary-search-article-backward (regexp)
11185 "Search for an article containing REGEXP backward."
11188 (format "Search article backward (regexp%s): "
11189 (if gnus-last-search-regexp
11190 (concat ", default " gnus-last-search-regexp)
11192 (gnus-summary-search-article-forward regexp 'backward))
11194 (defun gnus-summary-search-article (regexp &optional backward)
11195 "Search for an article containing REGEXP.
11196 Optional argument BACKWARD means do search for backward.
11197 `gnus-select-article-hook' is not called during the search."
11198 (let ((gnus-select-article-hook nil) ;Disable hook.
11199 (gnus-article-display-hook nil)
11200 (gnus-mark-article-hook nil) ;Inhibit marking as read.
11203 're-search-backward 're-search-forward))
11204 (sum (current-buffer))
11206 (gnus-save-hidden-threads
11207 (gnus-summary-select-article)
11208 (set-buffer gnus-article-buffer)
11210 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
11212 (re-search-backward regexp nil t)
11213 (re-search-forward regexp nil t))
11214 ;; We found the regexp.
11216 (setq found 'found)
11217 (beginning-of-line)
11219 (get-buffer-window (current-buffer))
11223 ;; We didn't find it, so we go to the next article.
11225 (if (not (if backward (gnus-summary-find-prev)
11226 (gnus-summary-find-next)))
11227 ;; No more articles.
11229 ;; Select the next article and adjust point.
11230 (gnus-summary-select-article)
11231 (set-buffer gnus-article-buffer)
11233 (goto-char (if backward (point-max) (point-min))))))
11234 (gnus-message 7 ""))
11235 ;; Return whether we found the regexp.
11236 (when (eq found 'found)
11237 (gnus-summary-show-thread)
11238 (gnus-summary-goto-subject gnus-current-article)
11239 (gnus-summary-position-point)
11242 (defun gnus-summary-find-matching (header regexp &optional backward unread
11244 "Return a list of all articles that match REGEXP on HEADER.
11245 The search stars on the current article and goes forwards unless
11246 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
11247 If UNREAD is non-nil, only unread articles will
11248 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
11249 in the comparisons."
11250 (let ((data (if (eq backward 'all) gnus-newsgroup-data
11251 (gnus-data-find-list
11252 (gnus-summary-article-number) (gnus-data-list backward))))
11253 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
11254 (case-fold-search (not not-case-fold))
11256 (or (fboundp (intern (concat "mail-header-" header)))
11257 (error "%s is not a valid header" header))
11259 (setq d (car data))
11260 (and (or (not unread) ; We want all articles...
11261 (gnus-data-unread-p d)) ; Or just unreads.
11262 (vectorp (gnus-data-header d)) ; It's not a pseudo.
11263 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
11264 (setq articles (cons (gnus-data-number d) articles))) ; Success!
11265 (setq data (cdr data)))
11266 (nreverse articles)))
11268 (defun gnus-summary-execute-command (header regexp command &optional backward)
11269 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
11270 If HEADER is an empty string (or nil), the match is done on the entire
11271 article. If BACKWARD (the prefix) is non-nil, search backward instead."
11273 (list (let ((completion-ignore-case t))
11276 (mapcar (lambda (string) (list string))
11277 '("Number" "Subject" "From" "Lines" "Date"
11278 "Message-ID" "Xref" "References" "Body"))
11279 nil 'require-match))
11280 (read-string "Regexp: ")
11281 (read-key-sequence "Command: ")
11282 current-prefix-arg))
11283 (when (equal header "Body")
11285 (gnus-set-global-variables)
11286 ;; Hidden thread subtrees must be searched as well.
11287 (gnus-summary-show-all-threads)
11288 ;; We don't want to change current point nor window configuration.
11290 (save-window-excursion
11291 (gnus-message 6 "Executing %s..." (key-description command))
11292 ;; We'd like to execute COMMAND interactively so as to give arguments.
11293 (gnus-execute header regexp
11294 `(lambda () (call-interactively ',(key-binding command)))
11296 (gnus-message 6 "Executing %s...done" (key-description command)))))
11298 (defun gnus-summary-beginning-of-article ()
11299 "Scroll the article back to the beginning."
11301 (gnus-set-global-variables)
11302 (gnus-summary-select-article)
11303 (gnus-configure-windows 'article)
11304 (gnus-eval-in-buffer-window gnus-article-buffer
11306 (goto-char (point-min))
11307 (and gnus-break-pages (gnus-narrow-to-page))))
11309 (defun gnus-summary-end-of-article ()
11310 "Scroll to the end of the article."
11312 (gnus-set-global-variables)
11313 (gnus-summary-select-article)
11314 (gnus-configure-windows 'article)
11315 (gnus-eval-in-buffer-window gnus-article-buffer
11317 (goto-char (point-max))
11319 (and gnus-break-pages (gnus-narrow-to-page))))
11321 (defun gnus-summary-show-article (&optional arg)
11322 "Force re-fetching of the current article.
11323 If ARG (the prefix) is non-nil, show the raw article without any
11324 article massaging functions being run."
11326 (gnus-set-global-variables)
11328 ;; Select the article the normal way.
11329 (gnus-summary-select-article nil 'force)
11330 ;; Bind the article treatment functions to nil.
11331 (let ((gnus-have-all-headers t)
11332 gnus-article-display-hook
11333 gnus-article-prepare-hook
11336 (gnus-summary-select-article nil 'force)))
11337 (gnus-summary-goto-subject gnus-current-article)
11338 ; (gnus-configure-windows 'article)
11339 (gnus-summary-position-point))
11341 (defun gnus-summary-verbose-headers (&optional arg)
11342 "Toggle permanent full header display.
11343 If ARG is a positive number, turn header display on.
11344 If ARG is a negative number, turn header display off."
11346 (gnus-set-global-variables)
11347 (gnus-summary-toggle-header arg)
11348 (setq gnus-show-all-headers
11349 (cond ((or (not (numberp arg))
11351 (not gnus-show-all-headers))
11355 (defun gnus-summary-toggle-header (&optional arg)
11356 "Show the headers if they are hidden, or hide them if they are shown.
11357 If ARG is a positive number, show the entire header.
11358 If ARG is a negative number, hide the unwanted header lines."
11360 (gnus-set-global-variables)
11362 (set-buffer gnus-article-buffer)
11363 (let* ((buffer-read-only nil)
11364 (inhibit-point-motion-hooks t)
11365 (hidden (text-property-any
11366 (goto-char (point-min)) (search-forward "\n\n")
11369 (goto-char (point-min))
11370 (when (search-forward "\n\n" nil t)
11371 (delete-region (point-min) (1- (point))))
11372 (goto-char (point-min))
11374 (set-buffer gnus-original-article-buffer)
11375 (goto-char (point-min))
11376 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
11377 (insert-buffer-substring gnus-original-article-buffer 1 e)
11378 (let ((gnus-inhibit-hiding t))
11379 (run-hooks 'gnus-article-display-hook))
11380 (if (or (not hidden) (and (numberp arg) (< arg 0)))
11381 (gnus-article-hide-headers)))))
11383 (defun gnus-summary-show-all-headers ()
11384 "Make all header lines visible."
11386 (gnus-set-global-variables)
11387 (gnus-article-show-all-headers))
11389 (defun gnus-summary-toggle-mime (&optional arg)
11390 "Toggle MIME processing.
11391 If ARG is a positive number, turn MIME processing on."
11393 (gnus-set-global-variables)
11394 (setq gnus-show-mime
11395 (if (null arg) (not gnus-show-mime)
11396 (> (prefix-numeric-value arg) 0)))
11397 (gnus-summary-select-article t 'force))
11399 (defun gnus-summary-caesar-message (&optional arg)
11400 "Caesar rotate the current article by 13.
11401 The numerical prefix specifies how manu places to rotate each letter
11404 (gnus-set-global-variables)
11405 (gnus-summary-select-article)
11406 (let ((mail-header-separator ""))
11407 (gnus-eval-in-buffer-window gnus-article-buffer
11410 (let ((start (window-start))
11412 (message-caesar-buffer-body arg)
11413 (set-window-start (get-buffer-window (current-buffer)) start))))))
11415 (defun gnus-summary-stop-page-breaking ()
11416 "Stop page breaking in the current article."
11418 (gnus-set-global-variables)
11419 (gnus-summary-select-article)
11420 (gnus-eval-in-buffer-window gnus-article-buffer
11423 (defun gnus-summary-move-article (&optional n to-newsgroup select-method action)
11424 "Move the current article to a different newsgroup.
11425 If N is a positive number, move the N next articles.
11426 If N is a negative number, move the N previous articles.
11427 If N is nil and any articles have been marked with the process mark,
11428 move those articles instead.
11429 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11430 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
11431 re-spool using this method.
11433 For this function to work, both the current newsgroup and the
11434 newsgroup that you want to move to have to support the `request-move'
11435 and `request-accept' functions."
11437 (unless action (setq action 'move))
11438 (gnus-set-global-variables)
11439 ;; Check whether the source group supports the required functions.
11440 (cond ((and (eq action 'move)
11441 (not (gnus-check-backend-function
11442 'request-move-article gnus-newsgroup-name)))
11443 (error "The current group does not support article moving"))
11444 ((and (eq action 'crosspost)
11445 (not (gnus-check-backend-function
11446 'request-replace-article gnus-newsgroup-name)))
11447 (error "The current group does not support article editing")))
11448 (let ((articles (gnus-summary-work-articles n))
11449 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
11450 (names '((move "Move" "Moving")
11451 (copy "Copy" "Copying")
11452 (crosspost "Crosspost" "Crossposting")))
11453 (copy-buf (save-excursion
11454 (nnheader-set-temp-buffer " *copy article*")))
11455 art-group to-method new-xref article to-groups)
11456 (unless (assq action names)
11457 (error "Unknown action %s" action))
11458 ;; Read the newsgroup name.
11459 (when (and (not to-newsgroup)
11460 (not select-method))
11462 (gnus-read-move-group-name
11463 (cadr (assq action names))
11464 (symbol-value (intern (format "gnus-current-%s-group" action)))
11466 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
11467 (setq to-method (or select-method
11468 (gnus-find-method-for-group to-newsgroup)))
11469 ;; Check the method we are to move this article to...
11470 (or (gnus-check-backend-function 'request-accept-article (car to-method))
11471 (error "%s does not support article copying" (car to-method)))
11472 (or (gnus-check-server to-method)
11473 (error "Can't open server %s" (car to-method)))
11474 (gnus-message 6 "%s to %s: %s..."
11475 (caddr (assq action names))
11476 (or (car select-method) to-newsgroup) articles)
11478 (setq article (pop articles))
11482 ;; Move the article.
11484 (gnus-request-move-article
11485 article ; Article to move
11486 gnus-newsgroup-name ; From newsgrouo
11487 (nth 1 (gnus-find-method-for-group
11488 gnus-newsgroup-name)) ; Server
11489 (list 'gnus-request-accept-article
11490 to-newsgroup (list 'quote select-method)
11491 (not articles)) ; Accept form
11492 (not articles))) ; Only save nov last time
11493 ;; Copy the article.
11496 (set-buffer copy-buf)
11497 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11498 (gnus-request-accept-article
11499 to-newsgroup select-method (not articles))))
11500 ;; Crosspost the article.
11501 ((eq action 'crosspost)
11502 (let ((xref (mail-header-xref (gnus-summary-article-header article))))
11503 (setq new-xref (concat gnus-newsgroup-name ":" article))
11504 (if (and xref (not (string= xref "")))
11506 (when (string-match "^Xref: " xref)
11507 (setq xref (substring xref (match-end 0))))
11508 (setq new-xref (concat xref " " new-xref)))
11509 (setq new-xref (concat (system-name) " " new-xref)))
11511 (set-buffer copy-buf)
11512 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11513 (nnheader-replace-header "xref" new-xref)
11514 (gnus-request-accept-article
11515 to-newsgroup select-method (not articles)))))))
11516 (if (not art-group)
11517 (gnus-message 1 "Couldn't %s article %s"
11518 (cadr (assq action names)) article)
11521 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
11523 (gnus-group-prefixed-name
11526 (gnus-find-method-for-group to-newsgroup)))
11527 gnus-newsrc-hashtb)))
11528 (info (nth 2 entry))
11529 (to-group (gnus-info-group info)))
11530 ;; Update the group that has been moved to.
11532 (memq action '(move copy)))
11533 (unless (member to-group to-groups)
11534 (push to-group to-groups))
11536 (unless (memq article gnus-newsgroup-unreads)
11537 (gnus-info-set-read
11538 info (gnus-add-to-range (gnus-info-read info)
11539 (list (cdr art-group)))))
11541 ;; Copy any marks over to the new group.
11542 (let ((marks gnus-article-mark-lists)
11543 (to-article (cdr art-group)))
11545 ;; See whether the article is to be put in the cache.
11546 (when gnus-use-cache
11547 (gnus-cache-possibly-enter-article
11548 to-group to-article
11549 (let ((header (copy-sequence
11550 (gnus-summary-article-header article))))
11551 (mail-header-set-number header to-article)
11553 (memq article gnus-newsgroup-marked)
11554 (memq article gnus-newsgroup-dormant)
11555 (memq article gnus-newsgroup-unreads)))
11558 (when (memq article (symbol-value
11559 (intern (format "gnus-newsgroup-%s"
11561 ;; If the other group is the same as this group,
11562 ;; then we have to add the mark to the list.
11563 (when (equal to-group gnus-newsgroup-name)
11564 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
11567 (intern (format "gnus-newsgroup-%s"
11569 ;; Copy mark to other group.
11570 (gnus-add-marked-articles
11571 to-group (cdar marks) (list to-article) info))
11572 (setq marks (cdr marks)))))
11574 ;; Update the Xref header in this article to point to
11575 ;; the new crossposted article we have just created.
11576 (when (eq action 'crosspost)
11578 (set-buffer copy-buf)
11579 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11580 (nnheader-replace-header
11581 "xref" (concat new-xref " " (gnus-group-prefixed-name
11582 (car art-group) to-method)
11583 ":" (cdr art-group)))
11584 (gnus-request-replace-article
11585 article gnus-newsgroup-name (current-buffer)))))
11587 (gnus-summary-goto-subject article)
11588 (when (eq action 'move)
11589 (gnus-summary-mark-article article gnus-canceled-mark)))
11590 (gnus-summary-remove-process-mark article))
11591 ;; Re-activate all groups that have been moved to.
11593 (gnus-activate-group (pop to-groups)))
11595 (gnus-kill-buffer copy-buf)
11596 (gnus-summary-position-point)
11597 (gnus-set-mode-line 'summary)))
11599 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
11600 "Move the current article to a different newsgroup.
11601 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11602 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
11603 re-spool using this method."
11605 (gnus-summary-move-article n nil select-method 'copy))
11607 (defun gnus-summary-crosspost-article (&optional n)
11608 "Crosspost the current article to some other group."
11610 (gnus-summary-move-article n nil nil 'crosspost))
11612 (defvar gnus-summary-respool-default-method nil
11613 "Default method for respooling an article.
11614 If nil, use to the current newsgroup method.")
11616 (defun gnus-summary-respool-article (&optional n method)
11617 "Respool the current article.
11618 The article will be squeezed through the mail spooling process again,
11619 which means that it will be put in some mail newsgroup or other
11620 depending on `nnmail-split-methods'.
11621 If N is a positive number, respool the N next articles.
11622 If N is a negative number, respool the N previous articles.
11623 If N is nil and any articles have been marked with the process mark,
11624 respool those articles instead.
11626 Respooling can be done both from mail groups and \"real\" newsgroups.
11627 In the former case, the articles in question will be moved from the
11628 current group into whatever groups they are destined to. In the
11629 latter case, they will be copied into the relevant groups."
11631 (list current-prefix-arg
11632 (let* ((methods (gnus-methods-using 'respool))
11634 (symbol-name (or gnus-summary-respool-default-method
11635 (car (gnus-find-method-for-group
11636 gnus-newsgroup-name)))))
11638 (gnus-completing-read
11639 methname "What backend do you want to use when? "
11640 methods nil t nil 'gnus-method-history))
11643 ((zerop (length (setq ms (gnus-servers-using-backend method))))
11644 (list (intern method) ""))
11648 (cdr (completing-read
11650 (mapcar (lambda (m) (cons (cadr m) m)) ms) nil t)))))))
11651 (gnus-set-global-variables)
11653 (error "No method given for respooling"))
11654 (if (assoc (symbol-name
11655 (car (gnus-find-method-for-group gnus-newsgroup-name)))
11656 (gnus-methods-using 'respool))
11657 (gnus-summary-move-article n nil method)
11658 (gnus-summary-copy-article n nil method)))
11660 (defun gnus-summary-import-article (file)
11661 "Import a random file into a mail newsgroup."
11662 (interactive "fImport file: ")
11663 (gnus-set-global-variables)
11664 (let ((group gnus-newsgroup-name)
11665 (now (current-time))
11667 (or (gnus-check-backend-function 'request-accept-article group)
11668 (error "%s does not support article importing" group))
11669 (or (file-readable-p file)
11670 (not (file-regular-p file))
11671 (error "Can't read %s" file))
11673 (set-buffer (get-buffer-create " *import file*"))
11674 (buffer-disable-undo (current-buffer))
11676 (insert-file-contents file)
11677 (goto-char (point-min))
11678 (unless (nnheader-article-p)
11679 ;; This doesn't look like an article, so we fudge some headers.
11680 (setq atts (file-attributes file)
11681 lines (count-lines (point-min) (point-max)))
11682 (insert "From: " (read-string "From: ") "\n"
11683 "Subject: " (read-string "Subject: ") "\n"
11684 "Date: " (timezone-make-date-arpa-standard
11685 (current-time-string (nth 5 atts))
11686 (current-time-zone now)
11687 (current-time-zone now)) "\n"
11688 "Message-ID: " (gnus-inews-message-id) "\n"
11689 "Lines: " (int-to-string lines) "\n"
11690 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
11691 (gnus-request-accept-article group nil t)
11692 (kill-buffer (current-buffer)))))
11694 (defun gnus-summary-expire-articles (&optional now)
11695 "Expire all articles that are marked as expirable in the current group."
11697 (gnus-set-global-variables)
11698 (when (gnus-check-backend-function
11699 'request-expire-articles gnus-newsgroup-name)
11700 ;; This backend supports expiry.
11701 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
11702 (expirable (if total
11703 (gnus-list-of-read-articles gnus-newsgroup-name)
11704 (setq gnus-newsgroup-expirable
11705 (sort gnus-newsgroup-expirable '<))))
11706 (expiry-wait (if now 'immediate
11707 (gnus-group-get-parameter
11708 gnus-newsgroup-name 'expiry-wait)))
11711 ;; There are expirable articles in this group, so we run them
11712 ;; through the expiry process.
11713 (gnus-message 6 "Expiring articles...")
11714 ;; The list of articles that weren't expired is returned.
11716 (let ((nnmail-expiry-wait-function nil)
11717 (nnmail-expiry-wait expiry-wait))
11718 (setq es (gnus-request-expire-articles
11719 expirable gnus-newsgroup-name)))
11720 (setq es (gnus-request-expire-articles
11721 expirable gnus-newsgroup-name)))
11722 (or total (setq gnus-newsgroup-expirable es))
11723 ;; We go through the old list of expirable, and mark all
11724 ;; really expired articles as nonexistent.
11725 (unless (eq es expirable) ;If nothing was expired, we don't mark.
11726 (let ((gnus-use-cache nil))
11728 (unless (memq (car expirable) es)
11729 (when (gnus-data-find (car expirable))
11730 (gnus-summary-mark-article
11731 (car expirable) gnus-canceled-mark)))
11732 (setq expirable (cdr expirable)))))
11733 (gnus-message 6 "Expiring articles...done")))))
11735 (defun gnus-summary-expire-articles-now ()
11736 "Expunge all expirable articles in the current group.
11737 This means that *all* articles that are marked as expirable will be
11738 deleted forever, right now."
11740 (gnus-set-global-variables)
11741 (or gnus-expert-user
11743 "Are you really, really, really sure you want to delete all these messages? ")
11745 (gnus-summary-expire-articles t))
11747 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
11748 (defun gnus-summary-delete-article (&optional n)
11749 "Delete the N next (mail) articles.
11750 This command actually deletes articles. This is not a marking
11751 command. The article will disappear forever from your life, never to
11753 If N is negative, delete backwards.
11754 If N is nil and articles have been marked with the process mark,
11755 delete these instead."
11757 (gnus-set-global-variables)
11758 (or (gnus-check-backend-function 'request-expire-articles
11759 gnus-newsgroup-name)
11760 (error "The current newsgroup does not support article deletion."))
11761 ;; Compute the list of articles to delete.
11762 (let ((articles (gnus-summary-work-articles n))
11764 (if (and gnus-novice-user
11765 (not (gnus-y-or-n-p
11766 (format "Do you really want to delete %s forever? "
11767 (if (> (length articles) 1)
11768 (format "these %s articles" (length articles))
11769 "this article")))))
11771 ;; Delete the articles.
11772 (setq not-deleted (gnus-request-expire-articles
11773 articles gnus-newsgroup-name 'force))
11775 (gnus-summary-remove-process-mark (car articles))
11776 ;; The backend might not have been able to delete the article
11778 (or (memq (car articles) not-deleted)
11779 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
11780 (setq articles (cdr articles))))
11781 (gnus-summary-position-point)
11782 (gnus-set-mode-line 'summary)
11785 (defun gnus-summary-edit-article (&optional force)
11786 "Enter into a buffer and edit the current article.
11787 This will have permanent effect only in mail groups.
11788 If FORCE is non-nil, allow editing of articles even in read-only
11792 (set-buffer gnus-summary-buffer)
11793 (gnus-set-global-variables)
11794 (when (and (not force)
11795 (gnus-group-read-only-p))
11796 (error "The current newsgroup does not support article editing."))
11797 (gnus-summary-select-article t nil t)
11798 (gnus-configure-windows 'article)
11799 (select-window (get-buffer-window gnus-article-buffer))
11800 (gnus-message 6 "C-c C-c to end edits")
11801 (setq buffer-read-only nil)
11803 (use-local-map (copy-keymap (current-local-map)))
11804 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
11805 (buffer-enable-undo)
11807 (goto-char (point-min))
11808 (search-forward "\n\n" nil t)))
11810 (defun gnus-summary-edit-article-done ()
11811 "Make edits to the current article permanent."
11813 (if (gnus-group-read-only-p)
11815 (gnus-summary-edit-article-postpone)
11817 1 "The current newsgroup does not support article editing."))
11818 (let ((buf (format "%s" (buffer-string))))
11821 (if (not (gnus-request-replace-article
11822 (cdr gnus-article-current) (car gnus-article-current)
11824 (error "Couldn't replace article.")
11825 (gnus-article-mode)
11826 (use-local-map gnus-article-mode-map)
11827 (setq buffer-read-only t)
11828 (buffer-disable-undo (current-buffer))
11829 (gnus-configure-windows 'summary)
11830 (gnus-summary-update-article (cdr gnus-article-current))
11831 (when gnus-use-cache
11832 (gnus-cache-update-article
11833 (cdr gnus-article-current) (car gnus-article-current)))
11834 (when gnus-keep-backlog
11835 (gnus-backlog-remove-article
11836 (car gnus-article-current) (cdr gnus-article-current))))
11838 (when (get-buffer gnus-original-article-buffer)
11839 (set-buffer gnus-original-article-buffer)
11840 (setq gnus-original-article nil)))
11841 (setq gnus-article-current nil
11842 gnus-current-article nil)
11843 (run-hooks 'gnus-article-display-hook)
11844 (and (gnus-visual-p 'summary-highlight 'highlight)
11845 (run-hooks 'gnus-visual-mark-article-hook)))))
11847 (defun gnus-summary-edit-article-postpone ()
11848 "Postpone changes to the current article."
11850 (gnus-article-mode)
11851 (use-local-map gnus-article-mode-map)
11852 (setq buffer-read-only t)
11853 (buffer-disable-undo (current-buffer))
11854 (gnus-configure-windows 'summary)
11855 (and (gnus-visual-p 'summary-highlight 'highlight)
11856 (run-hooks 'gnus-visual-mark-article-hook)))
11858 (defun gnus-summary-respool-query ()
11859 "Query where the respool algorithm would put this article."
11861 (gnus-set-global-variables)
11862 (gnus-summary-select-article)
11864 (set-buffer gnus-article-buffer)
11866 (goto-char (point-min))
11867 (search-forward "\n\n")
11868 (narrow-to-region (point-min) (point))
11869 (pp-eval-expression
11870 (list 'quote (mapcar 'car (nnmail-article-group 'identity)))))))
11872 ;; Summary marking commands.
11874 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
11875 "Mark articles which has the same subject as read, and then select the next.
11876 If UNMARK is positive, remove any kind of mark.
11877 If UNMARK is negative, tick articles."
11879 (gnus-set-global-variables)
11881 (setq unmark (prefix-numeric-value unmark)))
11883 (gnus-summary-mark-same-subject
11884 (gnus-summary-article-subject) unmark)))
11885 ;; Select next unread article. If auto-select-same mode, should
11886 ;; select the first unread article.
11887 (gnus-summary-next-article t (and gnus-auto-select-same
11888 (gnus-summary-article-subject)))
11889 (gnus-message 7 "%d article%s marked as %s"
11890 count (if (= count 1) " is" "s are")
11891 (if unmark "unread" "read"))))
11893 (defun gnus-summary-kill-same-subject (&optional unmark)
11894 "Mark articles which has the same subject as read.
11895 If UNMARK is positive, remove any kind of mark.
11896 If UNMARK is negative, tick articles."
11898 (gnus-set-global-variables)
11900 (setq unmark (prefix-numeric-value unmark)))
11902 (gnus-summary-mark-same-subject
11903 (gnus-summary-article-subject) unmark)))
11904 ;; If marked as read, go to next unread subject.
11906 ;; Go to next unread subject.
11907 (gnus-summary-next-subject 1 t))
11908 (gnus-message 7 "%d articles are marked as %s"
11909 count (if unmark "unread" "read"))))
11911 (defun gnus-summary-mark-same-subject (subject &optional unmark)
11912 "Mark articles with same SUBJECT as read, and return marked number.
11913 If optional argument UNMARK is positive, remove any kinds of marks.
11914 If optional argument UNMARK is negative, mark articles as unread instead."
11918 ((null unmark) ; Mark as read.
11921 (gnus-summary-mark-article-as-read gnus-killed-mark)
11922 (gnus-summary-show-thread) t)
11923 (gnus-summary-find-subject subject))
11924 (setq count (1+ count))))
11925 ((> unmark 0) ; Tick.
11928 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
11929 (gnus-summary-show-thread) t)
11930 (gnus-summary-find-subject subject))
11931 (setq count (1+ count))))
11932 (t ; Mark as unread.
11935 (gnus-summary-mark-article-as-unread gnus-unread-mark)
11936 (gnus-summary-show-thread) t)
11937 (gnus-summary-find-subject subject))
11938 (setq count (1+ count)))))
11939 (gnus-set-mode-line 'summary)
11940 ;; Return the number of marked articles.
11943 (defun gnus-summary-mark-as-processable (n &optional unmark)
11944 "Set the process mark on the next N articles.
11945 If N is negative, mark backward instead. If UNMARK is non-nil, remove
11946 the process mark instead. The difference between N and the actual
11947 number of articles marked is returned."
11949 (gnus-set-global-variables)
11950 (let ((backward (< n 0))
11955 (gnus-summary-remove-process-mark
11956 (gnus-summary-article-number))
11957 (gnus-summary-set-process-mark (gnus-summary-article-number)))
11958 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
11960 (if (/= 0 n) (gnus-message 7 "No more articles"))
11961 (gnus-summary-recenter)
11962 (gnus-summary-position-point)
11965 (defun gnus-summary-unmark-as-processable (n)
11966 "Remove the process mark from the next N articles.
11967 If N is negative, mark backward instead. The difference between N and
11968 the actual number of articles marked is returned."
11970 (gnus-set-global-variables)
11971 (gnus-summary-mark-as-processable n t))
11973 (defun gnus-summary-unmark-all-processable ()
11974 "Remove the process mark from all articles."
11976 (gnus-set-global-variables)
11978 (while gnus-newsgroup-processable
11979 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
11980 (gnus-summary-position-point))
11982 (defun gnus-summary-mark-as-expirable (n)
11983 "Mark N articles forward as expirable.
11984 If N is negative, mark backward instead. The difference between N and
11985 the actual number of articles marked is returned."
11987 (gnus-set-global-variables)
11988 (gnus-summary-mark-forward n gnus-expirable-mark))
11990 (defun gnus-summary-mark-article-as-replied (article)
11991 "Mark ARTICLE replied and update the summary line."
11992 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
11993 (let ((buffer-read-only nil))
11994 (when (gnus-summary-goto-subject article)
11995 (gnus-summary-update-secondary-mark article))))
11997 (defun gnus-summary-set-bookmark (article)
11998 "Set a bookmark in current article."
11999 (interactive (list (gnus-summary-article-number)))
12000 (gnus-set-global-variables)
12001 (if (or (not (get-buffer gnus-article-buffer))
12002 (not gnus-current-article)
12003 (not gnus-article-current)
12004 (not (equal gnus-newsgroup-name (car gnus-article-current))))
12005 (error "No current article selected"))
12006 ;; Remove old bookmark, if one exists.
12007 (let ((old (assq article gnus-newsgroup-bookmarks)))
12008 (if old (setq gnus-newsgroup-bookmarks
12009 (delq old gnus-newsgroup-bookmarks))))
12010 ;; Set the new bookmark, which is on the form
12011 ;; (article-number . line-number-in-body).
12012 (setq gnus-newsgroup-bookmarks
12016 (set-buffer gnus-article-buffer)
12020 (goto-char (point-min))
12021 (search-forward "\n\n" nil t)
12024 gnus-newsgroup-bookmarks))
12025 (gnus-message 6 "A bookmark has been added to the current article."))
12027 (defun gnus-summary-remove-bookmark (article)
12028 "Remove the bookmark from the current article."
12029 (interactive (list (gnus-summary-article-number)))
12030 (gnus-set-global-variables)
12031 ;; Remove old bookmark, if one exists.
12032 (let ((old (assq article gnus-newsgroup-bookmarks)))
12035 (setq gnus-newsgroup-bookmarks
12036 (delq old gnus-newsgroup-bookmarks))
12037 (gnus-message 6 "Removed bookmark."))
12038 (gnus-message 6 "No bookmark in current article."))))
12040 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
12041 (defun gnus-summary-mark-as-dormant (n)
12042 "Mark N articles forward as dormant.
12043 If N is negative, mark backward instead. The difference between N and
12044 the actual number of articles marked is returned."
12046 (gnus-set-global-variables)
12047 (gnus-summary-mark-forward n gnus-dormant-mark))
12049 (defun gnus-summary-set-process-mark (article)
12050 "Set the process mark on ARTICLE and update the summary line."
12051 (setq gnus-newsgroup-processable
12053 (delq article gnus-newsgroup-processable)))
12054 (when (gnus-summary-goto-subject article)
12055 (gnus-summary-show-thread)
12056 (gnus-summary-update-secondary-mark article)))
12058 (defun gnus-summary-remove-process-mark (article)
12059 "Remove the process mark from ARTICLE and update the summary line."
12060 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
12061 (when (gnus-summary-goto-subject article)
12062 (gnus-summary-show-thread)
12063 (gnus-summary-update-secondary-mark article)))
12065 (defun gnus-summary-set-saved-mark (article)
12066 "Set the process mark on ARTICLE and update the summary line."
12067 (push article gnus-newsgroup-saved)
12068 (when (gnus-summary-goto-subject article)
12069 (gnus-summary-update-secondary-mark article)))
12071 (defun gnus-summary-mark-forward (n &optional mark no-expire)
12072 "Mark N articles as read forwards.
12073 If N is negative, mark backwards instead.
12074 Mark with MARK. If MARK is ? , ?! or ??, articles will be
12076 The difference between N and the actual number of articles marked is
12079 (gnus-set-global-variables)
12080 (let ((backward (< n 0))
12081 (gnus-summary-goto-unread
12082 (and gnus-summary-goto-unread
12083 (not (eq gnus-summary-goto-unread 'never))
12084 (not (memq mark (list gnus-unread-mark
12085 gnus-ticked-mark gnus-dormant-mark)))))
12087 (mark (or mark gnus-del-mark)))
12088 (while (and (> n 0)
12089 (gnus-summary-mark-article nil mark no-expire)
12090 (zerop (gnus-summary-next-subject
12092 (and gnus-summary-goto-unread
12093 (not (eq gnus-summary-goto-unread 'never)))
12096 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
12097 (gnus-summary-recenter)
12098 (gnus-summary-position-point)
12099 (gnus-set-mode-line 'summary)
12102 (defun gnus-summary-mark-article-as-read (mark)
12103 "Mark the current article quickly as read with MARK."
12104 (let ((article (gnus-summary-article-number)))
12105 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12106 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12107 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12108 (setq gnus-newsgroup-reads
12109 (cons (cons article mark) gnus-newsgroup-reads))
12110 ;; Possibly remove from cache, if that is used.
12111 (and gnus-use-cache (gnus-cache-enter-remove-article article))
12112 ;; Allow the backend to change the mark.
12113 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
12114 ;; Check for auto-expiry.
12115 (when (and gnus-newsgroup-auto-expire
12116 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
12117 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
12118 (= mark gnus-ancient-mark)
12119 (= mark gnus-read-mark) (= mark gnus-souped-mark)))
12120 (setq mark gnus-expirable-mark)
12121 (push article gnus-newsgroup-expirable))
12122 ;; Set the mark in the buffer.
12123 (gnus-summary-update-mark mark 'unread)
12126 (defun gnus-summary-mark-article-as-unread (mark)
12127 "Mark the current article quickly as unread with MARK."
12128 (let ((article (gnus-summary-article-number)))
12129 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12130 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12131 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
12132 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
12133 (cond ((= mark gnus-ticked-mark)
12134 (push article gnus-newsgroup-marked))
12135 ((= mark gnus-dormant-mark)
12136 (push article gnus-newsgroup-dormant))
12138 (push article gnus-newsgroup-unreads)))
12139 (setq gnus-newsgroup-reads
12140 (delq (assq article gnus-newsgroup-reads)
12141 gnus-newsgroup-reads))
12143 ;; See whether the article is to be put in the cache.
12144 (and gnus-use-cache
12145 (vectorp (gnus-summary-article-header article))
12147 (gnus-cache-possibly-enter-article
12148 gnus-newsgroup-name article
12149 (gnus-summary-article-header article)
12150 (= mark gnus-ticked-mark)
12151 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
12154 (gnus-summary-update-mark mark 'unread)
12157 (defun gnus-summary-mark-article (&optional article mark no-expire)
12158 "Mark ARTICLE with MARK. MARK can be any character.
12159 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
12160 `??' (dormant) and `?E' (expirable).
12161 If MARK is nil, then the default character `?D' is used.
12162 If ARTICLE is nil, then the article on the current line will be
12164 ;; The mark might be a string.
12165 (and (stringp mark)
12166 (setq mark (aref mark 0)))
12167 ;; If no mark is given, then we check auto-expiring.
12168 (and (not no-expire)
12169 gnus-newsgroup-auto-expire
12171 (and (numberp mark)
12172 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
12173 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
12174 (= mark gnus-read-mark) (= mark gnus-souped-mark))))
12175 (setq mark gnus-expirable-mark))
12176 (let* ((mark (or mark gnus-del-mark))
12177 (article (or article (gnus-summary-article-number))))
12178 (or article (error "No article on current line"))
12179 (if (or (= mark gnus-unread-mark)
12180 (= mark gnus-ticked-mark)
12181 (= mark gnus-dormant-mark))
12182 (gnus-mark-article-as-unread article mark)
12183 (gnus-mark-article-as-read article mark))
12185 ;; See whether the article is to be put in the cache.
12186 (and gnus-use-cache
12187 (not (= mark gnus-canceled-mark))
12188 (vectorp (gnus-summary-article-header article))
12190 (gnus-cache-possibly-enter-article
12191 gnus-newsgroup-name article
12192 (gnus-summary-article-header article)
12193 (= mark gnus-ticked-mark)
12194 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
12196 (if (gnus-summary-goto-subject article nil t)
12197 (let ((buffer-read-only nil))
12198 (gnus-summary-show-thread)
12200 (gnus-summary-update-mark mark 'unread)
12203 (defun gnus-summary-update-secondary-mark (article)
12204 "Update the secondary (read, process, cache) mark."
12205 (gnus-summary-update-mark
12206 (cond ((memq article gnus-newsgroup-processable)
12208 ((memq article gnus-newsgroup-cached)
12210 ((memq article gnus-newsgroup-replied)
12212 ((memq article gnus-newsgroup-saved)
12214 (t gnus-unread-mark))
12216 (when (gnus-visual-p 'summary-highlight 'highlight)
12217 (run-hooks 'gnus-summary-update-hook))
12220 (defun gnus-summary-update-mark (mark type)
12221 (beginning-of-line)
12222 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
12223 (buffer-read-only nil))
12225 (<= (+ forward (point)) (point-max)))
12226 ;; Go to the right position on the line.
12227 (goto-char (+ forward (point)))
12228 ;; Replace the old mark with the new mark.
12229 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
12230 ;; Optionally update the marks by some user rule.
12231 (when (eq type 'unread)
12232 (gnus-data-set-mark
12233 (gnus-data-find (gnus-summary-article-number)) mark)
12234 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
12236 (defun gnus-mark-article-as-read (article &optional mark)
12237 "Enter ARTICLE in the pertinent lists and remove it from others."
12238 ;; Make the article expirable.
12239 (let ((mark (or mark gnus-del-mark)))
12240 (if (= mark gnus-expirable-mark)
12241 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
12242 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
12243 ;; Remove from unread and marked lists.
12244 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12245 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12246 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12247 (push (cons article mark) gnus-newsgroup-reads)
12248 ;; Possibly remove from cache, if that is used.
12249 (when gnus-use-cache
12250 (gnus-cache-enter-remove-article article))))
12252 (defun gnus-mark-article-as-unread (article &optional mark)
12253 "Enter ARTICLE in the pertinent lists and remove it from others."
12254 (let ((mark (or mark gnus-ticked-mark)))
12255 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12256 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12257 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
12258 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12259 (cond ((= mark gnus-ticked-mark)
12260 (push article gnus-newsgroup-marked))
12261 ((= mark gnus-dormant-mark)
12262 (push article gnus-newsgroup-dormant))
12264 (push article gnus-newsgroup-unreads)))
12265 (setq gnus-newsgroup-reads
12266 (delq (assq article gnus-newsgroup-reads)
12267 gnus-newsgroup-reads))))
12269 (defalias 'gnus-summary-mark-as-unread-forward
12270 'gnus-summary-tick-article-forward)
12271 (make-obsolete 'gnus-summary-mark-as-unread-forward
12272 'gnus-summary-tick-article-forward)
12273 (defun gnus-summary-tick-article-forward (n)
12274 "Tick N articles forwards.
12275 If N is negative, tick backwards instead.
12276 The difference between N and the number of articles ticked is returned."
12278 (gnus-summary-mark-forward n gnus-ticked-mark))
12280 (defalias 'gnus-summary-mark-as-unread-backward
12281 'gnus-summary-tick-article-backward)
12282 (make-obsolete 'gnus-summary-mark-as-unread-backward
12283 'gnus-summary-tick-article-backward)
12284 (defun gnus-summary-tick-article-backward (n)
12285 "Tick N articles backwards.
12286 The difference between N and the number of articles ticked is returned."
12288 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
12290 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
12291 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
12292 (defun gnus-summary-tick-article (&optional article clear-mark)
12293 "Mark current article as unread.
12294 Optional 1st argument ARTICLE specifies article number to be marked as unread.
12295 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
12297 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
12298 gnus-ticked-mark)))
12300 (defun gnus-summary-mark-as-read-forward (n)
12301 "Mark N articles as read forwards.
12302 If N is negative, mark backwards instead.
12303 The difference between N and the actual number of articles marked is
12306 (gnus-summary-mark-forward n gnus-del-mark t))
12308 (defun gnus-summary-mark-as-read-backward (n)
12309 "Mark the N articles as read backwards.
12310 The difference between N and the actual number of articles marked is
12313 (gnus-summary-mark-forward (- n) gnus-del-mark t))
12315 (defun gnus-summary-mark-as-read (&optional article mark)
12316 "Mark current article as read.
12317 ARTICLE specifies the article to be marked as read.
12318 MARK specifies a string to be inserted at the beginning of the line."
12319 (gnus-summary-mark-article article mark))
12321 (defun gnus-summary-clear-mark-forward (n)
12322 "Clear marks from N articles forward.
12323 If N is negative, clear backward instead.
12324 The difference between N and the number of marks cleared is returned."
12326 (gnus-summary-mark-forward n gnus-unread-mark))
12328 (defun gnus-summary-clear-mark-backward (n)
12329 "Clear marks from N articles backward.
12330 The difference between N and the number of marks cleared is returned."
12332 (gnus-summary-mark-forward (- n) gnus-unread-mark))
12334 (defun gnus-summary-mark-unread-as-read ()
12335 "Intended to be used by `gnus-summary-mark-article-hook'."
12336 (when (memq gnus-current-article gnus-newsgroup-unreads)
12337 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
12339 (defun gnus-summary-mark-read-and-unread-as-read ()
12340 "Intended to be used by `gnus-summary-mark-article-hook'."
12341 (let ((mark (gnus-summary-article-mark)))
12342 (when (or (gnus-unread-mark-p mark)
12343 (gnus-read-mark-p mark))
12344 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
12346 (defun gnus-summary-mark-region-as-read (point mark all)
12347 "Mark all unread articles between point and mark as read.
12348 If given a prefix, mark all articles between point and mark as read,
12349 even ticked and dormant ones."
12350 (interactive "r\nP")
12354 (beginning-of-line)
12359 (memq (setq article (gnus-summary-article-number))
12360 gnus-newsgroup-unreads))
12361 (gnus-summary-mark-article article gnus-del-mark))
12363 (gnus-summary-find-next))))))
12365 (defun gnus-summary-mark-below (score mark)
12366 "Mark articles with score less than SCORE with MARK."
12367 (interactive "P\ncMark: ")
12368 (gnus-set-global-variables)
12369 (setq score (if score
12370 (prefix-numeric-value score)
12371 (or gnus-summary-default-score 0)))
12373 (set-buffer gnus-summary-buffer)
12374 (goto-char (point-min))
12377 (and (< (gnus-summary-article-score) score)
12378 (gnus-summary-mark-article nil mark))
12379 (gnus-summary-find-next)))))
12381 (defun gnus-summary-kill-below (&optional score)
12382 "Mark articles with score below SCORE as read."
12384 (gnus-set-global-variables)
12385 (gnus-summary-mark-below score gnus-killed-mark))
12387 (defun gnus-summary-clear-above (&optional score)
12388 "Clear all marks from articles with score above SCORE."
12390 (gnus-set-global-variables)
12391 (gnus-summary-mark-above score gnus-unread-mark))
12393 (defun gnus-summary-tick-above (&optional score)
12394 "Tick all articles with score above SCORE."
12396 (gnus-set-global-variables)
12397 (gnus-summary-mark-above score gnus-ticked-mark))
12399 (defun gnus-summary-mark-above (score mark)
12400 "Mark articles with score over SCORE with MARK."
12401 (interactive "P\ncMark: ")
12402 (gnus-set-global-variables)
12403 (setq score (if score
12404 (prefix-numeric-value score)
12405 (or gnus-summary-default-score 0)))
12407 (set-buffer gnus-summary-buffer)
12408 (goto-char (point-min))
12410 (if (> (gnus-summary-article-score) score)
12411 (gnus-summary-mark-article nil mark))
12413 (gnus-summary-find-next)))))
12415 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
12416 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
12417 (defun gnus-summary-limit-include-expunged ()
12418 "Display all the hidden articles that were expunged for low scores."
12420 (gnus-set-global-variables)
12421 (let ((buffer-read-only nil))
12422 (let ((scored gnus-newsgroup-scored)
12425 (or (gnus-summary-goto-subject (caar scored))
12426 (and (setq h (gnus-summary-article-header (caar scored)))
12427 (< (cdar scored) gnus-summary-expunge-below)
12428 (setq headers (cons h headers))))
12429 (setq scored (cdr scored)))
12430 (or headers (error "No expunged articles hidden."))
12431 (goto-char (point-min))
12432 (gnus-summary-prepare-unthreaded (nreverse headers)))
12433 (goto-char (point-min))
12434 (gnus-summary-position-point)))
12436 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
12437 "Mark all articles not marked as unread in this newsgroup as read.
12438 If prefix argument ALL is non-nil, all articles are marked as read.
12439 If QUIETLY is non-nil, no questions will be asked.
12440 If TO-HERE is non-nil, it should be a point in the buffer. All
12441 articles before this point will be marked as read.
12442 The number of articles marked as read is returned."
12444 (gnus-set-global-variables)
12447 (not gnus-interactive-catchup) ;Without confirmation?
12451 "Mark absolutely all articles as read? "
12452 "Mark all unread articles as read? ")))
12454 (not gnus-newsgroup-adaptive)
12455 (not gnus-newsgroup-auto-expire))
12458 (setq gnus-newsgroup-marked nil
12459 gnus-newsgroup-dormant nil))
12460 (setq gnus-newsgroup-unreads nil))
12461 ;; We actually mark all articles as canceled, which we
12462 ;; have to do when using auto-expiry or adaptive scoring.
12463 (gnus-summary-show-all-threads)
12464 (if (gnus-summary-first-subject (not all))
12466 (if to-here (< (point) to-here) t)
12467 (gnus-summary-mark-article-as-read gnus-catchup-mark)
12468 (gnus-summary-find-next (not all)))))
12470 (setq gnus-newsgroup-unreads nil))
12471 (gnus-set-mode-line 'summary)))
12472 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
12473 (if (and (not to-here) (eq 'nnvirtual (car method)))
12474 (nnvirtual-catchup-group
12475 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
12476 (gnus-summary-position-point)))
12478 (defun gnus-summary-catchup-to-here (&optional all)
12479 "Mark all unticked articles before the current one as read.
12480 If ALL is non-nil, also mark ticked and dormant articles as read."
12482 (gnus-set-global-variables)
12484 (gnus-save-hidden-threads
12485 (let ((beg (point)))
12486 ;; We check that there are unread articles.
12487 (when (or all (gnus-summary-find-prev))
12488 (gnus-summary-catchup all t beg)))))
12489 (gnus-summary-position-point))
12491 (defun gnus-summary-catchup-all (&optional quietly)
12492 "Mark all articles in this newsgroup as read."
12494 (gnus-set-global-variables)
12495 (gnus-summary-catchup t quietly))
12497 (defun gnus-summary-catchup-and-exit (&optional all quietly)
12498 "Mark all articles not marked as unread in this newsgroup as read, then exit.
12499 If prefix argument ALL is non-nil, all articles are marked as read."
12501 (gnus-set-global-variables)
12502 (gnus-summary-catchup all quietly nil 'fast)
12503 ;; Select next newsgroup or exit.
12504 (if (eq gnus-auto-select-next 'quietly)
12505 (gnus-summary-next-group nil)
12506 (gnus-summary-exit)))
12508 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
12509 "Mark all articles in this newsgroup as read, and then exit."
12511 (gnus-set-global-variables)
12512 (gnus-summary-catchup-and-exit t quietly))
12514 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
12515 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
12516 "Mark all articles in this group as read and select the next group.
12517 If given a prefix, mark all articles, unread as well as ticked, as
12520 (gnus-set-global-variables)
12522 (gnus-summary-catchup all))
12523 (gnus-summary-next-article t nil nil t))
12525 ;; Thread-based commands.
12527 (defun gnus-summary-articles-in-thread (&optional article)
12528 "Return a list of all articles in the current thread.
12529 If ARTICLE is non-nil, return all articles in the thread that starts
12530 with that article."
12531 (let* ((article (or article (gnus-summary-article-number)))
12532 (data (gnus-data-find-list article))
12533 (top-level (gnus-data-level (car data)))
12535 (cond ((null gnus-thread-operation-ignore-subject)
12536 (gnus-simplify-subject-re
12537 (mail-header-subject (gnus-data-header (car data)))))
12538 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
12539 (gnus-simplify-subject-fuzzy
12540 (mail-header-subject (gnus-data-header (car data)))))
12542 (end-point (save-excursion
12543 (if (gnus-summary-go-to-next-thread)
12544 (point) (point-max))))
12547 (< (gnus-data-pos (car data)) end-point))
12548 (when (or (not top-subject)
12549 (string= top-subject
12550 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
12551 (gnus-simplify-subject-fuzzy
12552 (mail-header-subject
12553 (gnus-data-header (car data))))
12554 (gnus-simplify-subject-re
12555 (mail-header-subject
12556 (gnus-data-header (car data)))))))
12557 (push (gnus-data-number (car data)) articles))
12558 (unless (and (setq data (cdr data))
12559 (> (gnus-data-level (car data)) top-level))
12561 ;; Return the list of articles.
12562 (nreverse articles)))
12564 (defun gnus-summary-rethread-current ()
12565 "Rethread the thread the current article is part of."
12567 (gnus-set-global-variables)
12568 (let* ((gnus-show-threads t)
12569 (article (gnus-summary-article-number))
12570 (id (mail-header-id (gnus-summary-article-header)))
12571 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
12573 (error "No article on the current line"))
12574 (gnus-rebuild-thread id)
12575 (gnus-summary-goto-subject article)))
12577 (defun gnus-summary-reparent-thread ()
12578 "Make current article child of the marked (or previous) article.
12580 Note that the re-threading will only work if `gnus-thread-ignore-subject'
12581 is non-nil or the Subject: of both articles are the same."
12583 (or (not (gnus-group-read-only-p))
12584 (error "The current newsgroup does not support article editing."))
12585 (or (<= (length gnus-newsgroup-processable) 1)
12586 (error "No more than one article may be marked."))
12587 (save-window-excursion
12588 (let ((gnus-article-buffer " *reparent*")
12589 (current-article (gnus-summary-article-number))
12590 ; first grab the marked article, otherwise one line up.
12591 (parent-article (if (not (null gnus-newsgroup-processable))
12592 (car gnus-newsgroup-processable)
12594 (if (eq (forward-line -1) 0)
12595 (gnus-summary-article-number)
12596 (error "Beginning of summary buffer."))))))
12597 (or (not (eq current-article parent-article))
12598 (error "An article may not be self-referential."))
12599 (let ((message-id (mail-header-id
12600 (gnus-summary-article-header parent-article))))
12601 (or (and message-id (not (equal message-id "")))
12602 (error "No message-id in desired parent."))
12603 (gnus-summary-select-article t t nil current-article)
12604 (set-buffer gnus-article-buffer)
12605 (setq buffer-read-only nil)
12606 (let ((buf (format "%s" (buffer-string))))
12609 (goto-char (point-min))
12610 (if (search-forward-regexp "^References: " nil t)
12611 (insert message-id " " )
12612 (insert "References: " message-id "\n"))
12613 (or (gnus-request-replace-article current-article
12614 (car gnus-article-current)
12615 gnus-article-buffer)
12616 (error "Couldn't replace article."))
12617 (set-buffer gnus-summary-buffer)
12618 (gnus-summary-unmark-all-processable)
12619 (gnus-summary-rethread-current)
12620 (gnus-message 3 "Article %d is now the child of article %d."
12621 current-article parent-article)))))
12623 (defun gnus-summary-toggle-threads (&optional arg)
12624 "Toggle showing conversation threads.
12625 If ARG is positive number, turn showing conversation threads on."
12627 (gnus-set-global-variables)
12628 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
12629 (setq gnus-show-threads
12630 (if (null arg) (not gnus-show-threads)
12631 (> (prefix-numeric-value arg) 0)))
12632 (gnus-summary-prepare)
12633 (gnus-summary-goto-subject current)
12634 (gnus-summary-position-point)))
12636 (defun gnus-summary-show-all-threads ()
12637 "Show all threads."
12639 (gnus-set-global-variables)
12641 (let ((buffer-read-only nil))
12642 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
12643 (gnus-summary-position-point))
12645 (defun gnus-summary-show-thread ()
12646 "Show thread subtrees.
12647 Returns nil if no thread was there to be shown."
12649 (gnus-set-global-variables)
12650 (let ((buffer-read-only nil)
12652 ;; first goto end then to beg, to have point at beg after let
12653 (end (progn (end-of-line) (point)))
12654 (beg (progn (beginning-of-line) (point))))
12656 ;; Any hidden lines here?
12657 (search-forward "\r" end t)
12658 (subst-char-in-region beg end ?\^M ?\n t)
12660 (gnus-summary-position-point))))
12662 (defun gnus-summary-hide-all-threads ()
12663 "Hide all thread subtrees."
12665 (gnus-set-global-variables)
12667 (goto-char (point-min))
12668 (gnus-summary-hide-thread)
12669 (while (zerop (gnus-summary-next-thread 1 t))
12670 (gnus-summary-hide-thread)))
12671 (gnus-summary-position-point))
12673 (defun gnus-summary-hide-thread ()
12674 "Hide thread subtrees.
12675 Returns nil if no threads were there to be hidden."
12677 (gnus-set-global-variables)
12678 (let ((buffer-read-only nil)
12680 (article (gnus-summary-article-number)))
12682 ;; Go forward until either the buffer ends or the subthread
12684 (when (and (not (eobp))
12685 (or (zerop (gnus-summary-next-thread 1 t))
12686 (goto-char (point-max))))
12688 (if (and (> (point) start)
12689 (search-backward "\n" start t))
12691 (subst-char-in-region start (point) ?\n ?\^M)
12692 (gnus-summary-goto-subject article))
12695 ;;(gnus-summary-position-point)
12698 (defun gnus-summary-go-to-next-thread (&optional previous)
12699 "Go to the same level (or less) next thread.
12700 If PREVIOUS is non-nil, go to previous thread instead.
12701 Return the article number moved to, or nil if moving was impossible."
12702 (let ((level (gnus-summary-thread-level))
12703 (way (if previous -1 1))
12706 (while (and (not (eobp))
12707 (< level (gnus-summary-thread-level)))
12708 (forward-line way))
12715 (gnus-summary-article-number)
12716 (goto-char beg)))))
12718 (defun gnus-summary-go-to-next-thread-old (&optional previous)
12719 "Go to the same level (or less) next thread.
12720 If PREVIOUS is non-nil, go to previous thread instead.
12721 Return the article number moved to, or nil if moving was impossible."
12722 (if (and (eq gnus-summary-make-false-root 'dummy)
12723 (gnus-summary-article-intangible-p))
12724 (let ((beg (point)))
12725 (while (and (zerop (forward-line 1))
12726 (not (gnus-summary-article-intangible-p))
12727 (not (zerop (save-excursion
12728 (gnus-summary-thread-level))))))
12734 (let* ((level (gnus-summary-thread-level))
12735 (article (gnus-summary-article-number))
12736 (data (cdr (gnus-data-find-list article (gnus-data-list previous))))
12739 (if (<= (gnus-data-level (car data)) level)
12740 (setq oart (gnus-data-number (car data))
12742 (setq data (cdr data))))
12744 (gnus-summary-goto-subject oart)))))
12746 (defun gnus-summary-next-thread (n &optional silent)
12747 "Go to the same level next N'th thread.
12748 If N is negative, search backward instead.
12749 Returns the difference between N and the number of skips actually
12752 If SILENT, don't output messages."
12754 (gnus-set-global-variables)
12755 (let ((backward (< n 0))
12758 (while (and (> n 0)
12759 (gnus-summary-go-to-next-thread backward))
12762 (gnus-summary-position-point))
12763 (when (and (not silent) (/= 0 n))
12764 (gnus-message 7 "No more threads"))
12767 (defun gnus-summary-prev-thread (n)
12768 "Go to the same level previous N'th thread.
12769 Returns the difference between N and the number of skips actually
12772 (gnus-set-global-variables)
12773 (gnus-summary-next-thread (- n)))
12775 (defun gnus-summary-go-down-thread ()
12776 "Go down one level in the current thread."
12777 (let ((children (gnus-summary-article-children)))
12779 (gnus-summary-goto-subject (car children)))))
12781 (defun gnus-summary-go-up-thread ()
12782 "Go up one level in the current thread."
12783 (let ((parent (gnus-summary-article-parent)))
12785 (gnus-summary-goto-subject parent))))
12787 (defun gnus-summary-down-thread (n)
12788 "Go down thread N steps.
12789 If N is negative, go up instead.
12790 Returns the difference between N and how many steps down that were
12793 (gnus-set-global-variables)
12796 (while (and (> n 0)
12797 (if up (gnus-summary-go-up-thread)
12798 (gnus-summary-go-down-thread)))
12800 (gnus-summary-position-point)
12801 (if (/= 0 n) (gnus-message 7 "Can't go further"))
12804 (defun gnus-summary-up-thread (n)
12805 "Go up thread N steps.
12806 If N is negative, go up instead.
12807 Returns the difference between N and how many steps down that were
12810 (gnus-set-global-variables)
12811 (gnus-summary-down-thread (- n)))
12813 (defun gnus-summary-top-thread ()
12814 "Go to the top of the thread."
12816 (gnus-set-global-variables)
12817 (while (gnus-summary-go-up-thread))
12818 (gnus-summary-article-number))
12820 (defun gnus-summary-kill-thread (&optional unmark)
12821 "Mark articles under current thread as read.
12822 If the prefix argument is positive, remove any kinds of marks.
12823 If the prefix argument is negative, tick articles instead."
12825 (gnus-set-global-variables)
12827 (setq unmark (prefix-numeric-value unmark)))
12828 (let ((articles (gnus-summary-articles-in-thread)))
12830 ;; Expand the thread.
12831 (gnus-summary-show-thread)
12832 ;; Mark all the articles.
12834 (gnus-summary-goto-subject (car articles))
12835 (cond ((null unmark)
12836 (gnus-summary-mark-article-as-read gnus-killed-mark))
12838 (gnus-summary-mark-article-as-unread gnus-unread-mark))
12840 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
12841 (setq articles (cdr articles))))
12842 ;; Hide killed subtrees.
12844 gnus-thread-hide-killed
12845 (gnus-summary-hide-thread))
12846 ;; If marked as read, go to next unread subject.
12848 ;; Go to next unread subject.
12849 (gnus-summary-next-subject 1 t)))
12850 (gnus-set-mode-line 'summary))
12852 ;; Summary sorting commands
12854 (defun gnus-summary-sort-by-number (&optional reverse)
12855 "Sort summary buffer by article number.
12856 Argument REVERSE means reverse order."
12858 (gnus-summary-sort 'number reverse))
12860 (defun gnus-summary-sort-by-author (&optional reverse)
12861 "Sort summary buffer by author name alphabetically.
12862 If case-fold-search is non-nil, case of letters is ignored.
12863 Argument REVERSE means reverse order."
12865 (gnus-summary-sort 'author reverse))
12867 (defun gnus-summary-sort-by-subject (&optional reverse)
12868 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
12869 If case-fold-search is non-nil, case of letters is ignored.
12870 Argument REVERSE means reverse order."
12872 (gnus-summary-sort 'subject reverse))
12874 (defun gnus-summary-sort-by-date (&optional reverse)
12875 "Sort summary buffer by date.
12876 Argument REVERSE means reverse order."
12878 (gnus-summary-sort 'date reverse))
12880 (defun gnus-summary-sort-by-score (&optional reverse)
12881 "Sort summary buffer by score.
12882 Argument REVERSE means reverse order."
12884 (gnus-summary-sort 'score reverse))
12886 (defun gnus-summary-sort (predicate reverse)
12887 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
12888 (gnus-set-global-variables)
12889 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
12890 (article (intern (format "gnus-article-sort-by-%s" predicate)))
12891 (gnus-thread-sort-functions
12896 (,thread t2 t1)))))
12897 (gnus-article-sort-functions
12902 (,article t2 t1)))))
12904 (gnus-summary-prepare-hook nil))
12905 ;; We do the sorting by regenerating the threads.
12906 (gnus-summary-prepare)
12907 ;; Hide subthreads if needed.
12908 (when (and gnus-show-threads gnus-thread-hide-subtree)
12909 (gnus-summary-hide-all-threads)))
12910 ;; If in async mode, we send some info to the backend.
12911 (when gnus-newsgroup-async
12912 (gnus-request-asynchronous
12913 gnus-newsgroup-name gnus-newsgroup-data)))
12915 (defun gnus-sortable-date (date)
12916 "Make sortable string by string-lessp from DATE.
12917 Timezone package is used."
12920 (setq date (inline (timezone-fix-time
12922 (aref (inline (timezone-parse-date date)) 4))))
12924 (timezone-make-sortable-date
12925 (aref date 0) (aref date 1) (aref date 2)
12927 (timezone-make-time-string
12928 (aref date 3) (aref date 4) (aref date 5))))))
12931 ;; Summary saving commands.
12933 (defun gnus-summary-save-article (&optional n not-saved)
12934 "Save the current article using the default saver function.
12935 If N is a positive number, save the N next articles.
12936 If N is a negative number, save the N previous articles.
12937 If N is nil and any articles have been marked with the process mark,
12938 save those articles instead.
12939 The variable `gnus-default-article-saver' specifies the saver function."
12941 (gnus-set-global-variables)
12942 (let ((articles (gnus-summary-work-articles n))
12943 (save-buffer (save-excursion
12944 (nnheader-set-temp-buffer " *Gnus Save*")))
12945 file header article)
12947 (setq header (gnus-summary-article-header
12948 (setq article (pop articles))))
12949 (if (not (vectorp header))
12950 ;; This is a pseudo-article.
12951 (if (assq 'name header)
12952 (gnus-copy-file (cdr (assq 'name header)))
12953 (gnus-message 1 "Article %d is unsaveable" article))
12954 ;; This is a real article.
12955 (save-window-excursion
12956 (gnus-summary-select-article t nil nil article))
12958 (set-buffer save-buffer)
12959 (insert-buffer-substring gnus-original-article-buffer))
12960 (unless gnus-save-all-headers
12961 ;; Remove headers accoring to `gnus-saved-headers'.
12962 (let ((gnus-visible-headers
12963 (or gnus-saved-headers gnus-visible-headers))
12964 (gnus-article-buffer save-buffer))
12965 (gnus-article-hide-headers 1 t)))
12966 (save-window-excursion
12967 (if (not gnus-default-article-saver)
12968 (error "No default saver is defined.")
12969 ;; !!! Magic! The saving functions all save
12970 ;; `gnus-original-article-buffer' (or so they think),
12971 ;; but we bind that variable to out save-buffer.
12972 (set-buffer gnus-article-buffer)
12973 (let ((gnus-original-article-buffer save-buffer))
12974 (setq file (funcall
12975 gnus-default-article-saver
12977 ((not gnus-prompt-before-saving)
12979 ((eq gnus-prompt-before-saving 'always)
12982 (gnus-summary-remove-process-mark article)
12984 (gnus-summary-set-saved-mark article))))
12985 (gnus-kill-buffer save-buffer)
12986 (gnus-summary-position-point)
12989 (defun gnus-summary-pipe-output (&optional arg)
12990 "Pipe the current article to a subprocess.
12991 If N is a positive number, pipe the N next articles.
12992 If N is a negative number, pipe the N previous articles.
12993 If N is nil and any articles have been marked with the process mark,
12994 pipe those articles instead."
12996 (gnus-set-global-variables)
12997 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
12998 (gnus-summary-save-article arg t))
12999 (gnus-configure-windows 'pipe))
13001 (defun gnus-summary-save-article-mail (&optional arg)
13002 "Append the current article to an mail file.
13003 If N is a positive number, save the N next articles.
13004 If N is a negative number, save the N previous articles.
13005 If N is nil and any articles have been marked with the process mark,
13006 save those articles instead."
13008 (gnus-set-global-variables)
13009 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
13010 (gnus-summary-save-article arg)))
13012 (defun gnus-summary-save-article-rmail (&optional arg)
13013 "Append the current article to an rmail file.
13014 If N is a positive number, save the N next articles.
13015 If N is a negative number, save the N previous articles.
13016 If N is nil and any articles have been marked with the process mark,
13017 save those articles instead."
13019 (gnus-set-global-variables)
13020 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
13021 (gnus-summary-save-article arg)))
13023 (defun gnus-summary-save-article-file (&optional arg)
13024 "Append the current article to a file.
13025 If N is a positive number, save the N next articles.
13026 If N is a negative number, save the N previous articles.
13027 If N is nil and any articles have been marked with the process mark,
13028 save those articles instead."
13030 (gnus-set-global-variables)
13031 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
13032 (gnus-summary-save-article arg)))
13034 (defun gnus-summary-save-article-body-file (&optional arg)
13035 "Append the current article body to a file.
13036 If N is a positive number, save the N next articles.
13037 If N is a negative number, save the N previous articles.
13038 If N is nil and any articles have been marked with the process mark,
13039 save those articles instead."
13041 (gnus-set-global-variables)
13042 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
13043 (gnus-summary-save-article arg)))
13045 (defun gnus-get-split-value (methods)
13046 "Return a value based on the split METHODS."
13047 (let (split-name method result match)
13050 (set-buffer gnus-original-article-buffer)
13052 (nnheader-narrow-to-headers)
13054 (goto-char (point-min))
13055 (setq method (pop methods))
13056 (setq match (car method))
13059 ;; Regular expression.
13061 (re-search-forward match nil t)
13063 ((gnus-functionp match)
13067 (setq result (funcall match gnus-newsgroup-name))))
13072 (setq result (eval match)))))
13073 (setq split-name (append (cdr method) split-name))
13074 (cond ((stringp result)
13075 (push result split-name))
13077 (setq split-name (append result split-name)))))))))
13080 (defun gnus-read-move-group-name (prompt default articles prefix)
13081 "Read a group name."
13082 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
13083 (minibuffer-confirm-incomplete nil) ; XEmacs
13090 (assoc (symbol-name
13091 (car (gnus-find-method-for-group
13093 gnus-valid-select-methods))
13094 (push (list (symbol-name g)) group-map)))
13095 gnus-active-hashtb))
13097 (format "%s %s to:"
13099 (if (> (length articles) 1)
13100 (format "these %d articles" (length articles))
13105 (gnus-completing-read default prom
13106 group-map nil nil prefix
13107 'gnus-group-history))
13108 ((= 1 (length split-name))
13109 (gnus-completing-read (car split-name) prom group-map
13111 'gnus-group-history))
13113 (gnus-completing-read nil prom
13114 (mapcar (lambda (el) (list el))
13115 (nreverse split-name))
13117 'gnus-group-history)))))
13119 (if (or (string= to-newsgroup "")
13120 (string= to-newsgroup prefix))
13121 (setq to-newsgroup (or default "")))
13122 (or (gnus-active to-newsgroup)
13123 (gnus-activate-group to-newsgroup)
13124 (error "No such group: %s" to-newsgroup)))
13127 (defun gnus-read-save-file-name (prompt default-name)
13128 (let* ((split-name (gnus-get-split-value gnus-split-methods))
13130 ;; Let the split methods have their say.
13132 ;; No split name was found.
13135 (concat prompt " (default "
13136 (file-name-nondirectory default-name) ") ")
13137 (file-name-directory default-name)
13139 ;; A single split name was found
13140 ((= 1 (length split-name))
13142 (concat prompt " (default " (car split-name) ") ")
13143 gnus-article-save-directory
13144 (concat gnus-article-save-directory (car split-name))))
13145 ;; A list of splits was found.
13147 (setq split-name (nreverse split-name))
13149 (let ((file-name-history (nconc split-name file-name-history)))
13152 (concat prompt " (`M-p' for defaults) ")
13153 gnus-article-save-directory
13154 (car split-name))))
13155 (car (push result file-name-history)))))))
13156 ;; If we have read a directory, we append the default file name.
13157 (when (file-directory-p file)
13158 (setq file (concat (file-name-as-directory file)
13159 (file-name-nondirectory default-name))))
13160 ;; Possibly translate some charaters.
13161 (nnheader-translate-file-chars file)))
13163 (defun gnus-article-archive-name (group)
13164 "Return the first instance of an \"Archive-name\" in the current buffer."
13165 (let ((case-fold-search t))
13166 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
13167 (match-string 1))))
13169 (defun gnus-summary-save-in-rmail (&optional filename)
13170 "Append this article to Rmail file.
13171 Optional argument FILENAME specifies file name.
13172 Directory to save to is default to `gnus-article-save-directory'."
13174 (gnus-set-global-variables)
13175 (let ((default-name
13176 (funcall gnus-rmail-save-name gnus-newsgroup-name
13177 gnus-current-headers gnus-newsgroup-last-rmail)))
13179 (cond ((eq filename 'default)
13181 (filename filename)
13182 (t (gnus-read-save-file-name
13183 "Save in rmail file:" default-name))))
13184 (gnus-make-directory (file-name-directory filename))
13185 (gnus-eval-in-buffer-window gnus-original-article-buffer
13189 (gnus-output-to-rmail filename))))
13190 ;; Remember the directory name to save articles
13191 (setq gnus-newsgroup-last-rmail filename)))
13193 (defun gnus-summary-save-in-mail (&optional filename)
13194 "Append this article to Unix mail file.
13195 Optional argument FILENAME specifies file name.
13196 Directory to save to is default to `gnus-article-save-directory'."
13198 (gnus-set-global-variables)
13199 (let ((default-name
13200 (funcall gnus-mail-save-name gnus-newsgroup-name
13201 gnus-current-headers gnus-newsgroup-last-mail)))
13203 (cond ((eq filename 'default)
13205 (filename filename)
13206 (t (gnus-read-save-file-name
13207 "Save in Unix mail file:" default-name))))
13209 (expand-file-name filename
13211 (file-name-directory default-name))))
13212 (gnus-make-directory (file-name-directory filename))
13213 (gnus-eval-in-buffer-window gnus-original-article-buffer
13217 (if (and (file-readable-p filename) (mail-file-babyl-p filename))
13218 (gnus-output-to-rmail filename)
13219 (let ((mail-use-rfc822 t))
13220 (rmail-output filename 1 t t))))))
13221 ;; Remember the directory name to save articles.
13222 (setq gnus-newsgroup-last-mail filename)))
13224 (defun gnus-summary-save-in-file (&optional filename)
13225 "Append this article to file.
13226 Optional argument FILENAME specifies file name.
13227 Directory to save to is default to `gnus-article-save-directory'."
13229 (gnus-set-global-variables)
13230 (let ((default-name
13231 (funcall gnus-file-save-name gnus-newsgroup-name
13232 gnus-current-headers gnus-newsgroup-last-file)))
13234 (cond ((eq filename 'default)
13236 (filename filename)
13237 (t (gnus-read-save-file-name
13238 "Save in file:" default-name))))
13239 (gnus-make-directory (file-name-directory filename))
13240 (gnus-eval-in-buffer-window gnus-original-article-buffer
13244 (gnus-output-to-file filename))))
13245 ;; Remember the directory name to save articles.
13246 (setq gnus-newsgroup-last-file filename)))
13248 (defun gnus-summary-save-body-in-file (&optional filename)
13249 "Append this article body to a file.
13250 Optional argument FILENAME specifies file name.
13251 The directory to save in defaults to `gnus-article-save-directory'."
13253 (gnus-set-global-variables)
13254 (let ((default-name
13255 (funcall gnus-file-save-name gnus-newsgroup-name
13256 gnus-current-headers gnus-newsgroup-last-file)))
13258 (cond ((eq filename 'default)
13260 (filename filename)
13261 (t (gnus-read-save-file-name
13262 "Save body in file:" default-name))))
13263 (gnus-make-directory (file-name-directory filename))
13264 (gnus-eval-in-buffer-window gnus-article-buffer
13268 (goto-char (point-min))
13269 (and (search-forward "\n\n" nil t)
13270 (narrow-to-region (point) (point-max)))
13271 (gnus-output-to-file filename))))
13272 ;; Remember the directory name to save articles.
13273 (setq gnus-newsgroup-last-file filename)))
13275 (defun gnus-summary-save-in-pipe (&optional command)
13276 "Pipe this article to subprocess."
13278 (gnus-set-global-variables)
13280 (cond ((eq command 'default)
13281 gnus-last-shell-command)
13283 (t (read-string "Shell command on article: "
13284 gnus-last-shell-command))))
13285 (if (string-equal command "")
13286 (setq command gnus-last-shell-command))
13287 (gnus-eval-in-buffer-window gnus-article-buffer
13290 (shell-command-on-region (point-min) (point-max) command nil)))
13291 (setq gnus-last-shell-command command))
13293 ;; Summary extract commands
13295 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
13296 (let ((buffer-read-only nil)
13297 (article (gnus-summary-article-number))
13299 (or (gnus-summary-goto-subject article)
13300 (error (format "No such article: %d" article)))
13301 (gnus-summary-position-point)
13302 ;; If all commands are to be bunched up on one line, we collect
13304 (if gnus-view-pseudos-separately
13306 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
13309 (setq action (cdr (assq 'action (car ps))))
13310 (setq files (list (cdr (assq 'name (car ps)))))
13311 (while (and ps (cdr ps)
13312 (string= (or action "1")
13313 (or (cdr (assq 'action (cadr ps))) "2")))
13314 (setq files (cons (cdr (assq 'name (cadr ps))) files))
13315 (setcdr ps (cddr ps)))
13318 (if (not (string-match "%s" action))
13319 (setq files (cons " " files)))
13320 (setq files (cons " " files))
13321 (and (assq 'execute (car ps))
13322 (setcdr (assq 'execute (car ps))
13323 (funcall (if (string-match "%s" action)
13326 (mapconcat (lambda (f) f) files " ")))))
13327 (setq ps (cdr ps)))))
13328 (if (and gnus-view-pseudos (not not-view))
13330 (and (assq 'execute (car pslist))
13331 (gnus-execute-command (cdr (assq 'execute (car pslist)))
13332 (eq gnus-view-pseudos 'not-confirm)))
13333 (setq pslist (cdr pslist)))
13336 (setq after-article (or (cdr (assq 'article (car pslist)))
13337 (gnus-summary-article-number)))
13338 (gnus-summary-goto-subject after-article)
13341 (insert " " (file-name-nondirectory
13342 (cdr (assq 'name (car pslist))))
13343 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
13345 (forward-line -1) ; back to `b'
13346 (gnus-add-text-properties
13347 b (1- e) (list 'gnus-number gnus-reffed-article-number
13348 gnus-mouse-face-prop gnus-mouse-face))
13350 after-article gnus-reffed-article-number
13351 gnus-unread-mark b (car pslist) 0 (- e b))
13352 (push gnus-reffed-article-number gnus-newsgroup-unreads)
13353 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
13354 (setq pslist (cdr pslist)))))))
13356 (defun gnus-pseudos< (p1 p2)
13357 (let ((c1 (cdr (assq 'action p1)))
13358 (c2 (cdr (assq 'action p2))))
13359 (and c1 c2 (string< c1 c2))))
13361 (defun gnus-request-pseudo-article (props)
13362 (cond ((assq 'execute props)
13363 (gnus-execute-command (cdr (assq 'execute props)))))
13364 (let ((gnus-current-article (gnus-summary-article-number)))
13365 (run-hooks 'gnus-mark-article-hook)))
13367 (defun gnus-execute-command (command &optional automatic)
13369 (gnus-article-setup-buffer)
13370 (set-buffer gnus-article-buffer)
13371 (setq buffer-read-only nil)
13372 (let ((command (if automatic command (read-string "Command: " command)))
13373 ;; Just binding this here doesn't help, because there might
13374 ;; be output from the process after exiting the scope of
13376 ;; (buffer-read-only nil)
13379 (insert "$ " command "\n\n")
13380 (if gnus-view-pseudo-asynchronously
13381 (start-process "gnus-execute" nil "sh" "-c" command)
13382 (call-process "sh" nil t nil "-c" command)))))
13384 (defun gnus-copy-file (file &optional to)
13387 (list (read-file-name "Copy file: " default-directory)
13388 (read-file-name "Copy file to: " default-directory)))
13389 (gnus-set-global-variables)
13390 (or to (setq to (read-file-name "Copy file to: " default-directory)))
13391 (and (file-directory-p to)
13392 (setq to (concat (file-name-as-directory to)
13393 (file-name-nondirectory file))))
13394 (copy-file file to))
13396 ;; Summary kill commands.
13398 (defun gnus-summary-edit-global-kill (article)
13399 "Edit the \"global\" kill file."
13400 (interactive (list (gnus-summary-article-number)))
13401 (gnus-set-global-variables)
13402 (gnus-group-edit-global-kill article))
13404 (defun gnus-summary-edit-local-kill ()
13405 "Edit a local kill file applied to the current newsgroup."
13407 (gnus-set-global-variables)
13408 (setq gnus-current-headers (gnus-summary-article-header))
13409 (gnus-set-global-variables)
13410 (gnus-group-edit-local-kill
13411 (gnus-summary-article-number) gnus-newsgroup-name))
13415 ;;; Gnus article mode
13418 (put 'gnus-article-mode 'mode-class 'special)
13420 (if gnus-article-mode-map
13422 (setq gnus-article-mode-map (make-keymap))
13423 (suppress-keymap gnus-article-mode-map)
13425 (gnus-define-keys gnus-article-mode-map
13426 " " gnus-article-goto-next-page
13427 "\177" gnus-article-goto-prev-page
13428 [delete] gnus-article-goto-prev-page
13429 "\C-c^" gnus-article-refer-article
13430 "h" gnus-article-show-summary
13431 "s" gnus-article-show-summary
13432 "\C-c\C-m" gnus-article-mail
13433 "?" gnus-article-describe-briefly
13434 gnus-mouse-2 gnus-article-push-button
13435 "\r" gnus-article-press-button
13436 "\t" gnus-article-next-button
13437 "\M-\t" gnus-article-prev-button
13438 "\C-c\C-b" gnus-bug)
13440 (substitute-key-definition
13441 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map))
13443 (defun gnus-article-mode ()
13444 "Major mode for displaying an article.
13446 All normal editing commands are switched off.
13448 The following commands are available:
13450 \\<gnus-article-mode-map>
13451 \\[gnus-article-next-page]\t Scroll the article one page forwards
13452 \\[gnus-article-prev-page]\t Scroll the article one page backwards
13453 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
13454 \\[gnus-article-show-summary]\t Display the summary buffer
13455 \\[gnus-article-mail]\t Send a reply to the address near point
13456 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
13457 \\[gnus-info-find-node]\t Go to the Gnus info node"
13459 (when (and menu-bar-mode
13460 (gnus-visual-p 'article-menu 'menu))
13461 (gnus-article-make-menu-bar))
13462 (kill-all-local-variables)
13463 (gnus-simplify-mode-line)
13464 (setq mode-name "Article")
13465 (setq major-mode 'gnus-article-mode)
13466 (make-local-variable 'minor-mode-alist)
13467 (or (assq 'gnus-show-mime minor-mode-alist)
13468 (setq minor-mode-alist
13469 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
13470 (use-local-map gnus-article-mode-map)
13471 (make-local-variable 'page-delimiter)
13472 (setq page-delimiter gnus-page-delimiter)
13473 (buffer-disable-undo (current-buffer))
13474 (setq buffer-read-only t) ;Disable modification
13475 (run-hooks 'gnus-article-mode-hook))
13477 (defun gnus-article-setup-buffer ()
13478 "Initialize the article buffer."
13479 (let* ((name (if gnus-single-article-buffer "*Article*"
13480 (concat "*Article " gnus-newsgroup-name "*")))
13482 (progn (string-match "\\*Article" name)
13483 (concat " *Original Article"
13484 (substring name (match-end 0))))))
13485 (setq gnus-article-buffer name)
13486 (setq gnus-original-article-buffer original)
13487 ;; This might be a variable local to the summary buffer.
13488 (unless gnus-single-article-buffer
13490 (set-buffer gnus-summary-buffer)
13491 (setq gnus-article-buffer name)
13492 (setq gnus-original-article-buffer original)
13493 (gnus-set-global-variables))
13494 (make-local-variable 'gnus-summary-buffer))
13495 ;; Init original article buffer.
13497 (set-buffer (get-buffer-create gnus-original-article-buffer))
13498 (buffer-disable-undo (current-buffer))
13499 (setq major-mode 'gnus-original-article-mode)
13500 (make-local-variable 'gnus-original-article))
13501 (if (get-buffer name)
13504 (buffer-disable-undo (current-buffer))
13505 (setq buffer-read-only t)
13506 (gnus-add-current-to-buffer-list)
13507 (or (eq major-mode 'gnus-article-mode)
13508 (gnus-article-mode))
13511 (set-buffer (get-buffer-create name))
13512 (gnus-add-current-to-buffer-list)
13513 (gnus-article-mode)
13514 (current-buffer)))))
13516 ;; Set article window start at LINE, where LINE is the number of lines
13517 ;; from the head of the article.
13518 (defun gnus-article-set-window-start (&optional line)
13520 (get-buffer-window gnus-article-buffer t)
13522 (set-buffer gnus-article-buffer)
13523 (goto-char (point-min))
13526 (gnus-message 6 "Moved to bookmark")
13527 (search-forward "\n\n" nil t)
13528 (forward-line line)
13531 (defun gnus-kill-all-overlays ()
13532 "Delete all overlays in the current buffer."
13533 (when (fboundp 'overlay-lists)
13534 (let* ((overlayss (overlay-lists))
13535 (buffer-read-only nil)
13536 (overlays (nconc (car overlayss) (cdr overlayss))))
13538 (delete-overlay (pop overlays))))))
13540 (defun gnus-request-article-this-buffer (article group)
13541 "Get an article and insert it into this buffer."
13542 (let (do-update-line)
13546 (gnus-kill-all-overlays)
13547 (setq group (or group gnus-newsgroup-name))
13549 ;; Open server if it has closed.
13550 (gnus-check-server (gnus-find-method-for-group group))
13552 ;; Using `gnus-request-article' directly will insert the article into
13553 ;; `nntp-server-buffer' - so we'll save some time by not having to
13554 ;; copy it from the server buffer into the article buffer.
13556 ;; We only request an article by message-id when we do not have the
13557 ;; headers for it, so we'll have to get those.
13558 (when (stringp article)
13559 (let ((gnus-override-method gnus-refer-article-method))
13560 (gnus-read-header article)))
13562 ;; If the article number is negative, that means that this article
13563 ;; doesn't belong in this newsgroup (possibly), so we find its
13564 ;; message-id and request it by id instead of number.
13565 (when (and (numberp article)
13566 gnus-summary-buffer
13567 (get-buffer gnus-summary-buffer)
13568 (buffer-name (get-buffer gnus-summary-buffer)))
13570 (set-buffer gnus-summary-buffer)
13571 (let ((header (gnus-summary-article-header article)))
13574 ((memq article gnus-newsgroup-sparse)
13575 ;; This is a sparse gap article.
13576 (setq do-update-line article)
13577 (setq article (mail-header-id header))
13578 (let ((gnus-override-method gnus-refer-article-method))
13579 (gnus-read-header article))
13580 (setq gnus-newsgroup-sparse
13581 (delq article gnus-newsgroup-sparse)))
13583 ;; It's a real article.
13584 (setq article (mail-header-id header)))
13586 ;; It is an extracted pseudo-article.
13587 (setq article 'pseudo)
13588 (gnus-request-pseudo-article header))))
13590 (let ((method (gnus-find-method-for-group
13591 gnus-newsgroup-name)))
13592 (if (not (eq (car method) 'nneething))
13594 (let ((dir (concat (file-name-as-directory (nth 1 method))
13595 (mail-header-subject header))))
13596 (if (file-directory-p dir)
13598 (setq article 'nneething)
13599 (gnus-group-enter-directory dir)))))))))
13602 ;; Refuse to select canceled articles.
13603 ((and (numberp article)
13604 gnus-summary-buffer
13605 (get-buffer gnus-summary-buffer)
13606 (buffer-name (get-buffer gnus-summary-buffer))
13607 (eq (cdr (save-excursion
13608 (set-buffer gnus-summary-buffer)
13609 (assq article gnus-newsgroup-reads)))
13610 gnus-canceled-mark))
13612 ;; We first check `gnus-original-article-buffer'.
13613 ((and (get-buffer gnus-original-article-buffer)
13616 (set-buffer gnus-original-article-buffer)
13617 (and (equal (car gnus-original-article) group)
13618 (eq (cdr gnus-original-article) article))))
13619 (insert-buffer-substring gnus-original-article-buffer)
13621 ;; Check the backlog.
13622 ((and gnus-keep-backlog
13623 (gnus-backlog-request-article group article (current-buffer)))
13625 ;; Check the cache.
13626 ((and gnus-use-cache
13628 (gnus-cache-request-article article group))
13630 ;; Get the article and put into the article buffer.
13631 ((or (stringp article) (numberp article))
13632 (let ((gnus-override-method
13633 (and (stringp article) gnus-refer-article-method))
13634 (buffer-read-only nil))
13636 (gnus-kill-all-overlays)
13637 (if (gnus-request-article article group (current-buffer))
13639 (and gnus-keep-backlog
13641 (gnus-backlog-enter-article
13642 group article (current-buffer)))
13644 ;; It was a pseudo.
13647 ;; Take the article from the original article buffer
13648 ;; and place it in the buffer it's supposed to be in.
13649 (when (and (get-buffer gnus-article-buffer)
13650 ;;(numberp article)
13651 (equal (buffer-name (current-buffer))
13652 (buffer-name (get-buffer gnus-article-buffer))))
13654 (if (get-buffer gnus-original-article-buffer)
13655 (set-buffer (get-buffer gnus-original-article-buffer))
13656 (set-buffer (get-buffer-create gnus-original-article-buffer))
13657 (buffer-disable-undo (current-buffer))
13658 (setq major-mode 'gnus-original-article-mode)
13659 (setq buffer-read-only t)
13660 (gnus-add-current-to-buffer-list))
13661 (let (buffer-read-only)
13663 (insert-buffer-substring gnus-article-buffer))
13664 (setq gnus-original-article (cons group article))))
13666 ;; Update sparse articles.
13667 (when (and do-update-line
13668 (or (numberp article)
13669 (stringp article)))
13670 (let ((buf (current-buffer)))
13671 (set-buffer gnus-summary-buffer)
13672 (gnus-summary-update-article do-update-line)
13673 (gnus-summary-goto-subject do-update-line nil t)
13674 (set-window-point (get-buffer-window (current-buffer) t)
13676 (set-buffer buf))))))
13678 (defun gnus-read-header (id &optional header)
13679 "Read the headers of article ID and enter them into the Gnus system."
13680 (let ((group gnus-newsgroup-name)
13681 (gnus-override-method
13682 (and (gnus-news-group-p gnus-newsgroup-name)
13683 gnus-refer-article-method))
13685 ;; First we check to see whether the header in question is already
13688 ;; This is a Message-ID.
13689 (setq header (or header (gnus-id-to-header id)))
13690 ;; This is an article number.
13691 (setq header (or header (gnus-summary-article-header id))))
13693 (not (memq (mail-header-number header) gnus-newsgroup-sparse)))
13694 ;; We have found the header.
13696 ;; We have to really fetch the header to this article.
13698 (if (gnus-check-backend-function 'request-head group)
13699 (gnus-request-head id group)
13700 (gnus-request-article id group)))
13702 (set-buffer nntp-server-buffer)
13703 (and (search-forward "\n\n" nil t)
13704 (delete-region (1- (point)) (point-max)))
13705 (goto-char (point-max))
13707 (goto-char (point-min))
13711 ((cdr where) (cdr where))
13712 (header (mail-header-number header))
13713 (t gnus-reffed-article-number))
13715 (insert " Article retrieved.\n"))
13717 ; (memq (mail-header-number header) gnus-newsgroup-sparse))
13718 ; (setcar (gnus-id-to-thread id) nil))
13719 (if (not (setq header (car (gnus-get-newsgroup-headers))))
13720 () ; Malformed head.
13721 (unless (memq (mail-header-number header) gnus-newsgroup-sparse)
13722 (if (and (stringp id)
13723 (not (string= (gnus-group-real-name group)
13725 ;; If we fetched by Message-ID and the article came
13726 ;; from a different group, we fudge some bogus article
13727 ;; numbers for this article.
13728 (mail-header-set-number header gnus-reffed-article-number))
13729 (decf gnus-reffed-article-number)
13730 (gnus-remove-header (mail-header-number header))
13731 (push header gnus-newsgroup-headers)
13732 (setq gnus-current-headers header)
13733 (push (mail-header-number header) gnus-newsgroup-limit))
13736 (defun gnus-remove-header (number)
13737 "Remove header NUMBER from `gnus-newsgroup-headers'."
13738 (if (and gnus-newsgroup-headers
13739 (= number (mail-header-number (car gnus-newsgroup-headers))))
13740 (pop gnus-newsgroup-headers)
13741 (let ((headers gnus-newsgroup-headers))
13742 (while (and (cdr headers)
13743 (not (= number (mail-header-number (cadr headers)))))
13745 (when (cdr headers)
13746 (setcdr headers (cddr headers))))))
13748 (defun gnus-article-prepare (article &optional all-headers header)
13749 "Prepare ARTICLE in article mode buffer.
13750 ARTICLE should either be an article number or a Message-ID.
13751 If ARTICLE is an id, HEADER should be the article headers.
13752 If ALL-HEADERS is non-nil, no headers are hidden."
13754 ;; Make sure we start in a summary buffer.
13755 (unless (eq major-mode 'gnus-summary-mode)
13756 (set-buffer gnus-summary-buffer))
13757 (setq gnus-summary-buffer (current-buffer))
13758 ;; Make sure the connection to the server is alive.
13759 (unless (gnus-server-opened
13760 (gnus-find-method-for-group gnus-newsgroup-name))
13761 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
13762 (gnus-request-group gnus-newsgroup-name t))
13763 (let* ((article (if header (mail-header-number header) article))
13764 (summary-buffer (current-buffer))
13765 (internal-hook gnus-article-internal-prepare-hook)
13766 (group gnus-newsgroup-name)
13769 (gnus-article-setup-buffer)
13770 (set-buffer gnus-article-buffer)
13771 ;; Deactivate active regions.
13772 (when (and (boundp 'transient-mark-mode)
13773 transient-mark-mode)
13774 (setq mark-active nil))
13775 (if (not (setq result (let ((buffer-read-only nil))
13776 (gnus-request-article-this-buffer
13778 ;; There is no such article.
13780 (when (and (numberp article)
13781 (not (memq article gnus-newsgroup-sparse)))
13782 (setq gnus-article-current
13783 (cons gnus-newsgroup-name article))
13784 (set-buffer gnus-summary-buffer)
13785 (setq gnus-current-article article)
13786 (gnus-summary-mark-article article gnus-canceled-mark))
13787 (unless (memq article gnus-newsgroup-sparse)
13789 1 "No such article (may have expired or been canceled)")))
13790 (if (or (eq result 'pseudo) (eq result 'nneething))
13793 (set-buffer summary-buffer)
13794 (setq gnus-last-article gnus-current-article
13795 gnus-newsgroup-history (cons gnus-current-article
13796 gnus-newsgroup-history)
13797 gnus-current-article 0
13798 gnus-current-headers nil
13799 gnus-article-current nil)
13800 (if (eq result 'nneething)
13801 (gnus-configure-windows 'summary)
13802 (gnus-configure-windows 'article))
13803 (gnus-set-global-variables))
13804 (gnus-set-mode-line 'article))
13805 ;; The result from the `request' was an actual article -
13806 ;; or at least some text that is now displayed in the
13808 (if (and (numberp article)
13809 (not (eq article gnus-current-article)))
13810 ;; Seems like a new article has been selected.
13811 ;; `gnus-current-article' must be an article number.
13813 (set-buffer summary-buffer)
13814 (setq gnus-last-article gnus-current-article
13815 gnus-newsgroup-history (cons gnus-current-article
13816 gnus-newsgroup-history)
13817 gnus-current-article article
13818 gnus-current-headers
13819 (gnus-summary-article-header gnus-current-article)
13820 gnus-article-current
13821 (cons gnus-newsgroup-name gnus-current-article))
13822 (unless (vectorp gnus-current-headers)
13823 (setq gnus-current-headers nil))
13824 (gnus-summary-show-thread)
13825 (run-hooks 'gnus-mark-article-hook)
13826 (gnus-set-mode-line 'summary)
13827 (and (gnus-visual-p 'article-highlight 'highlight)
13828 (run-hooks 'gnus-visual-mark-article-hook))
13829 ;; Set the global newsgroup variables here.
13830 ;; Suggested by Jim Sisolak
13831 ;; <sisolak@trans4.neep.wisc.edu>.
13832 (gnus-set-global-variables)
13833 (setq gnus-have-all-headers
13834 (or all-headers gnus-show-all-headers))
13835 (and gnus-use-cache
13836 (vectorp (gnus-summary-article-header article))
13837 (gnus-cache-possibly-enter-article
13839 (gnus-summary-article-header article)
13840 (memq article gnus-newsgroup-marked)
13841 (memq article gnus-newsgroup-dormant)
13842 (memq article gnus-newsgroup-unreads)))))
13843 (when (or (numberp article)
13845 ;; Hooks for getting information from the article.
13846 ;; This hook must be called before being narrowed.
13847 (let (buffer-read-only)
13848 (run-hooks 'internal-hook)
13849 (run-hooks 'gnus-article-prepare-hook)
13850 ;; Decode MIME message.
13852 (if (or (not gnus-strict-mime)
13853 (gnus-fetch-field "Mime-Version"))
13854 (funcall gnus-show-mime-method)
13855 (funcall gnus-decode-encoded-word-method)))
13856 ;; Perform the article display hooks.
13857 (run-hooks 'gnus-article-display-hook))
13859 (goto-char (point-min))
13860 (and gnus-break-pages (gnus-narrow-to-page)))
13861 (gnus-set-mode-line 'article)
13862 (gnus-configure-windows 'article)
13863 (goto-char (point-min))
13866 (defun gnus-article-show-all-headers ()
13867 "Show all article headers in article mode buffer."
13869 (gnus-article-setup-buffer)
13870 (set-buffer gnus-article-buffer)
13871 (let ((buffer-read-only nil))
13872 (gnus-unhide-text (point-min) (point-max)))))
13874 (defun gnus-article-hide-headers-if-wanted ()
13875 "Hide unwanted headers if `gnus-have-all-headers' is nil.
13876 Provided for backwards compatibility."
13877 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers)
13878 gnus-inhibit-hiding
13879 (gnus-article-hide-headers)))
13881 (defsubst gnus-article-header-rank ()
13882 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
13883 (let ((list gnus-sorted-header-list)
13886 (when (looking-at (car list))
13888 (setq list (cdr list))
13892 (defun gnus-article-hide-headers (&optional arg delete)
13893 "Toggle whether to hide unwanted headers and possibly sort them as well.
13894 If given a negative prefix, always show; if given a positive prefix,
13896 (interactive (gnus-hidden-arg))
13897 (if (gnus-article-check-hidden-text 'headers arg)
13898 ;; Show boring headers as well.
13899 (gnus-article-show-hidden-text 'boring-headers)
13900 ;; This function might be inhibited.
13901 (unless gnus-inhibit-hiding
13903 (set-buffer gnus-article-buffer)
13905 (let ((buffer-read-only nil)
13906 (props (nconc (list 'gnus-type 'headers)
13907 gnus-hidden-properties))
13908 (max (1+ (length gnus-sorted-header-list)))
13909 (ignored (when (not (stringp gnus-visible-headers))
13910 (cond ((stringp gnus-ignored-headers)
13911 gnus-ignored-headers)
13912 ((listp gnus-ignored-headers)
13913 (mapconcat 'identity gnus-ignored-headers
13916 (cond ((stringp gnus-visible-headers)
13917 gnus-visible-headers)
13918 ((and gnus-visible-headers
13919 (listp gnus-visible-headers))
13920 (mapconcat 'identity gnus-visible-headers "\\|"))))
13922 ;; First we narrow to just the headers.
13924 (goto-char (point-min))
13925 ;; Hide any "From " lines at the beginning of (mail) articles.
13926 (while (looking-at "From ")
13930 (delete-region (point-min) (point))
13931 (gnus-hide-text (point-min) (point) props)))
13932 ;; Then treat the rest of the header lines.
13935 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
13936 ;; Then we use the two regular expressions
13937 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
13938 ;; select which header lines is to remain visible in the
13940 (goto-char (point-min))
13941 (while (re-search-forward "^[^ \t]*:" nil t)
13942 (beginning-of-line)
13943 ;; We add the headers we want to keep to a list and delete
13944 ;; them from the buffer.
13945 (gnus-put-text-property
13946 (point) (1+ (point)) 'message-rank
13947 (if (or (and visible (looking-at visible))
13949 (not (looking-at ignored))))
13950 (gnus-article-header-rank)
13953 (message-sort-headers-1)
13954 (when (setq beg (text-property-any
13955 (point-min) (point-max) 'message-rank (+ 2 max)))
13956 ;; We make the unwanted headers invisible.
13958 (delete-region beg (point-max))
13959 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
13960 (gnus-hide-text-type beg (point-max) 'headers))
13961 ;; Work around XEmacs lossage.
13962 (gnus-put-text-property (point-min) beg 'invisible nil))))))))
13964 (defun gnus-article-hide-boring-headers (&optional arg)
13965 "Toggle hiding of headers that aren't very interesting.
13966 If given a negative prefix, always show; if given a positive prefix,
13968 (interactive (gnus-hidden-arg))
13969 (unless (gnus-article-check-hidden-text 'boring-headers arg)
13971 (set-buffer gnus-article-buffer)
13973 (let ((buffer-read-only nil)
13974 (list gnus-boring-article-headers)
13975 (inhibit-point-motion-hooks t)
13977 (nnheader-narrow-to-headers)
13979 (setq elem (pop list))
13980 (goto-char (point-min))
13982 ;; Hide empty headers.
13984 (while (re-search-forward "^[^:]+:[ \t]\n[^ \t]" nil t)
13986 (gnus-hide-text-type
13987 (progn (beginning-of-line) (point))
13990 (if (re-search-forward "^[^ \t]" nil t)
13991 (match-beginning 0)
13994 ;; Hide boring Newsgroups header.
13995 ((eq elem 'newsgroups)
13996 (when (equal (message-fetch-field "newsgroups")
13997 (gnus-group-real-name gnus-newsgroup-name))
13998 (gnus-article-hide-header "newsgroups")))
13999 ((eq elem 'followup-to)
14000 (when (equal (message-fetch-field "followup-to")
14001 (message-fetch-field "newsgroups"))
14002 (gnus-article-hide-header "followup-to")))
14003 ((eq elem 'reply-to)
14004 (let ((from (message-fetch-field "from"))
14005 (reply-to (message-fetch-field "reply-to")))
14009 (nth 1 (funcall gnus-extract-address-components from))
14010 (nth 1 (funcall gnus-extract-address-components
14012 (gnus-article-hide-header "reply-to"))))
14014 (let ((date (message-fetch-field "date")))
14016 (< (gnus-days-between date (current-time-string))
14018 (gnus-article-hide-header "date")))))))))))
14020 (defun gnus-article-hide-header (header)
14022 (goto-char (point-min))
14023 (when (re-search-forward (concat "^" header ":") nil t)
14024 (gnus-hide-text-type
14025 (progn (beginning-of-line) (point))
14028 (if (re-search-forward "^[^ \t]" nil t)
14029 (match-beginning 0)
14031 'boring-headers))))
14033 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
14034 (defun gnus-article-treat-overstrike ()
14035 "Translate overstrikes into bold text."
14038 (set-buffer gnus-article-buffer)
14039 (let ((buffer-read-only nil))
14040 (while (search-forward "\b" nil t)
14041 (let ((next (following-char))
14042 (previous (char-after (- (point) 2))))
14044 ((eq next previous)
14045 (gnus-put-text-property (- (point) 2) (point) 'invisible t)
14046 (gnus-put-text-property (point) (1+ (point)) 'face 'bold))
14048 (gnus-put-text-property (1- (point)) (1+ (point)) 'invisible t)
14049 (gnus-put-text-property
14050 (- (point) 2) (1- (point)) 'face 'underline))
14052 (gnus-put-text-property (- (point) 2) (point) 'invisible t)
14053 (gnus-put-text-property
14054 (point) (1+ (point)) 'face 'underline))))))))
14056 (defun gnus-article-word-wrap ()
14057 "Format too long lines."
14060 (set-buffer gnus-article-buffer)
14061 (let ((buffer-read-only nil))
14063 (goto-char (point-min))
14064 (search-forward "\n\n" nil t)
14066 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
14067 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
14068 (adaptive-fill-mode t))
14069 (while (not (eobp))
14070 (and (>= (current-column) (min fill-column (window-width)))
14071 (/= (preceding-char) ?:)
14072 (fill-paragraph nil))
14073 (end-of-line 2))))))
14075 (defun gnus-article-remove-cr ()
14076 "Remove carriage returns from an article."
14079 (set-buffer gnus-article-buffer)
14080 (let ((buffer-read-only nil))
14081 (goto-char (point-min))
14082 (while (search-forward "\r" nil t)
14083 (replace-match "" t t)))))
14085 (defun gnus-article-remove-trailing-blank-lines ()
14086 "Remove all trailing blank lines from the article."
14089 (set-buffer gnus-article-buffer)
14090 (let ((buffer-read-only nil))
14091 (goto-char (point-max))
14095 (while (looking-at "^[ \t]*$")
14100 (defun gnus-article-display-x-face (&optional force)
14101 "Look for an X-Face header and display it if present."
14102 (interactive (list 'force))
14104 (set-buffer gnus-article-buffer)
14105 ;; Delete the old process, if any.
14106 (when (process-status "gnus-x-face")
14107 (delete-process "gnus-x-face"))
14108 (let ((inhibit-point-motion-hooks t)
14109 (case-fold-search nil)
14112 (nnheader-narrow-to-headers)
14113 (setq from (message-fetch-field "from"))
14114 (goto-char (point-min))
14115 (when (and gnus-article-x-face-command
14117 ;; Check whether this face is censored.
14118 (not gnus-article-x-face-too-ugly)
14119 (and gnus-article-x-face-too-ugly from
14120 (not (string-match gnus-article-x-face-too-ugly
14122 ;; Has to be present.
14123 (re-search-forward "^X-Face: " nil t))
14124 ;; We now have the area of the buffer where the X-Face is stored.
14125 (let ((beg (point))
14126 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
14127 ;; We display the face.
14128 (if (symbolp gnus-article-x-face-command)
14129 ;; The command is a lisp function, so we call it.
14130 (if (gnus-functionp gnus-article-x-face-command)
14131 (funcall gnus-article-x-face-command beg end)
14132 (error "%s is not a function" gnus-article-x-face-command))
14133 ;; The command is a string, so we interpret the command
14134 ;; as a, well, command, and fork it off.
14135 (let ((process-connection-type nil))
14136 (process-kill-without-query
14138 "gnus-x-face" nil "sh" "-c" gnus-article-x-face-command))
14139 (process-send-region "gnus-x-face" beg end)
14140 (process-send-eof "gnus-x-face")))))))))
14142 (defalias 'gnus-headers-decode-quoted-printable 'gnus-decode-rfc1522)
14143 (defun gnus-decode-rfc1522 ()
14144 "Hack to remove QP encoding from headers."
14145 (let ((case-fold-search t)
14146 (inhibit-point-motion-hooks t)
14147 (buffer-read-only nil)
14151 (goto-char (point-min))
14152 (or (search-forward "\n\n" nil t) (point-max)))
14154 (while (re-search-forward
14155 "=\\?iso-8859-1\\?q\\?\\([^?\t\n]*\\)\\?=" nil t)
14156 (setq string (match-string 1))
14157 (narrow-to-region (match-beginning 0) (match-end 0))
14158 (delete-region (point-min) (point-max))
14160 (gnus-mime-decode-quoted-printable (goto-char (point-min)) (point-max))
14161 (subst-char-in-region (point-min) (point-max) ?_ ? )
14163 (goto-char (point-min))))))
14165 (defun gnus-article-de-quoted-unreadable (&optional force)
14166 "Do a naive translation of a quoted-printable-encoded article.
14167 This is in no way, shape or form meant as a replacement for real MIME
14168 processing, but is simply a stop-gap measure until MIME support is
14170 If FORCE, decode the article whether it is marked as quoted-printable
14172 (interactive (list 'force))
14174 (set-buffer gnus-article-buffer)
14175 (let ((case-fold-search t)
14176 (buffer-read-only nil)
14177 (type (gnus-fetch-field "content-transfer-encoding")))
14178 (gnus-decode-rfc1522)
14180 (and type (string-match "quoted-printable" (downcase type))))
14181 (goto-char (point-min))
14182 (search-forward "\n\n" nil 'move)
14183 (gnus-mime-decode-quoted-printable (point) (point-max))))))
14185 (defun gnus-mime-decode-quoted-printable (from to)
14186 "Decode Quoted-Printable in the region between FROM and TO."
14189 (while (search-forward "=" to t)
14190 (cond ((eq (following-char) ?\n)
14193 ((looking-at "[0-9A-F][0-9A-F]")
14194 (subst-char-in-region
14195 (1- (point)) (point) ?=
14196 (hexl-hex-string-to-integer
14197 (buffer-substring (point) (+ 2 (point)))))
14201 ((gnus-message 3 "Malformed MIME quoted-printable message")))))
14203 (defun gnus-article-hide-pgp (&optional arg)
14204 "Toggle hiding of any PGP headers and signatures in the current article.
14205 If given a negative prefix, always show; if given a positive prefix,
14207 (interactive (gnus-hidden-arg))
14208 (unless (gnus-article-check-hidden-text 'pgp arg)
14210 (set-buffer gnus-article-buffer)
14211 (let ((props (nconc (list 'gnus-type 'pgp) gnus-hidden-properties))
14212 buffer-read-only beg end)
14214 (goto-char (point-min))
14215 ;; Hide the "header".
14216 (and (search-forward "\n-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
14217 (gnus-hide-text (match-beginning 0) (match-end 0) props))
14219 ;; Hide the actual signature.
14220 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
14221 (setq end (1+ (match-beginning 0)))
14224 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
14226 ;; Perhaps we shouldn't hide to the end of the buffer
14227 ;; if there is no end to the signature?
14230 ;; Hide "- " PGP quotation markers.
14231 (when (and beg end)
14232 (narrow-to-region beg end)
14233 (goto-char (point-min))
14234 (while (re-search-forward "^- " nil t)
14235 (gnus-hide-text (match-beginning 0) (match-end 0) props))
14238 (defun gnus-article-hide-signature (&optional arg)
14239 "Hide the signature in the current article.
14240 If given a negative prefix, always show; if given a positive prefix,
14242 (interactive (gnus-hidden-arg))
14243 (unless (gnus-article-check-hidden-text 'signature arg)
14245 (set-buffer gnus-article-buffer)
14247 (let ((buffer-read-only nil))
14248 (when (gnus-narrow-to-signature)
14249 (gnus-hide-text-type (point-min) (point-max) 'signature)))))))
14251 (defun gnus-article-strip-leading-blank-lines ()
14252 "Remove all blank lines from the beginning of the article."
14255 (set-buffer gnus-article-buffer)
14256 (let (buffer-read-only)
14257 (goto-char (point-min))
14258 (when (search-forward "\n\n" nil t)
14259 (while (looking-at "[ \t]$")
14260 (gnus-delete-line))))))
14262 (defvar mime::preview/content-list)
14263 (defvar mime::preview-content-info/point-min)
14264 (defun gnus-narrow-to-signature ()
14265 "Narrow to the signature."
14267 (if (and (boundp 'mime::preview/content-list)
14268 mime::preview/content-list)
14269 (let ((pcinfo (car (last mime::preview/content-list))))
14271 (funcall (intern "mime::preview-content-info/point-min") pcinfo)
14274 (goto-char (point-max))
14275 (when (re-search-backward gnus-signature-separator nil t)
14277 (when (or (null gnus-signature-limit)
14278 (and (numberp gnus-signature-limit)
14279 (< (- (point-max) (point)) gnus-signature-limit))
14280 (and (gnus-functionp gnus-signature-limit)
14281 (funcall gnus-signature-limit))
14282 (and (stringp gnus-signature-limit)
14283 (not (re-search-forward gnus-signature-limit nil t))))
14284 (narrow-to-region (point) (point-max))
14287 (defun gnus-hidden-arg ()
14288 "Return the current prefix arg as a number, or 0 if no prefix."
14289 (list (if current-prefix-arg
14290 (prefix-numeric-value current-prefix-arg)
14293 (defun gnus-article-check-hidden-text (type arg)
14294 "Return nil if hiding is necessary.
14295 Arg can be nil or a number. Nil and positive means hide, negative
14296 means show, 0 means toggle."
14298 (set-buffer gnus-article-buffer)
14299 (let ((hide (gnus-article-hidden-text-p type)))
14305 (gnus-article-show-hidden-text type))
14307 (if (eq hide 'hidden)
14308 (gnus-article-show-hidden-text type)
14311 (defun gnus-article-hidden-text-p (type)
14312 "Say whether the current buffer contains hidden text of type TYPE."
14313 (let ((pos (text-property-any (point-min) (point-max) 'gnus-type type)))
14315 (if (get-text-property pos 'invisible)
14319 (defun gnus-article-hide (&optional arg force)
14320 "Hide all the gruft in the current article.
14321 This means that PGP stuff, signatures, cited text and (some)
14322 headers will be hidden.
14323 If given a prefix, show the hidden text instead."
14324 (interactive (list current-prefix-arg 'force))
14325 (gnus-article-hide-headers arg)
14326 (gnus-article-hide-pgp arg)
14327 (gnus-article-hide-citation-maybe arg force)
14328 (gnus-article-hide-signature arg))
14330 (defun gnus-article-show-hidden-text (type &optional hide)
14331 "Show all hidden text of type TYPE.
14332 If HIDE, hide the text instead."
14334 (set-buffer gnus-article-buffer)
14335 (let ((buffer-read-only nil)
14336 (inhibit-point-motion-hooks t)
14338 (while (gnus-goto-char (text-property-any
14339 beg (point-max) 'gnus-type type))
14343 (gnus-hide-text beg (point) gnus-hidden-properties)
14344 (gnus-unhide-text beg (point)))
14345 (setq beg (point)))
14348 (defvar gnus-article-time-units
14349 `((year . ,(* 365.25 24 60 60))
14350 (week . ,(* 7 24 60 60))
14351 (day . ,(* 24 60 60))
14352 (hour . ,(* 60 60))
14355 "Mapping from time units to seconds.")
14357 (defun gnus-article-date-ut (&optional type highlight)
14358 "Convert DATE date to universal time in the current article.
14359 If TYPE is `local', convert to local time; if it is `lapsed', output
14360 how much time has lapsed since DATE."
14361 (interactive (list 'ut t))
14362 (let* ((header (or gnus-current-headers
14363 (gnus-summary-article-header) ""))
14364 (date (and (vectorp header) (mail-header-date header)))
14365 (date-regexp "^Date: \\|^X-Sent: ")
14366 (now (current-time))
14367 (inhibit-point-motion-hooks t)
14369 (when (and date (not (string= date "")))
14371 (set-buffer gnus-article-buffer)
14373 (nnheader-narrow-to-headers)
14374 (let ((buffer-read-only nil))
14375 ;; Delete any old Date headers.
14376 (if (re-search-forward date-regexp nil t)
14378 (setq bface (get-text-property (gnus-point-at-bol) 'face)
14379 eface (get-text-property (1- (gnus-point-at-eol))
14381 (message-remove-header date-regexp t)
14382 (beginning-of-line))
14383 (goto-char (point-max)))
14384 (insert (gnus-make-date-line date type))
14385 ;; Do highlighting.
14387 (when (and (gnus-visual-p 'article-highlight 'highlight)
14388 (looking-at "\\([^:]+\\): *\\(.*\\)$"))
14389 (gnus-put-text-property (match-beginning 1) (match-end 1)
14391 (gnus-put-text-property (match-beginning 2) (match-end 2)
14392 'face eface))))))))
14394 (defun gnus-make-date-line (date type)
14395 "Return a DATE line of TYPE."
14397 ;; Convert to the local timezone. We have to slap a
14398 ;; `condition-case' round the calls to the timezone
14399 ;; functions since they aren't particularly resistant to
14402 (concat "Date: " (condition-case ()
14403 (timezone-make-date-arpa-standard date)
14406 ;; Convert to Universal Time.
14410 (timezone-make-date-arpa-standard date nil "UT")
14413 ;; Get the original date from the article.
14414 ((eq type 'original)
14415 (concat "Date: " date "\n"))
14416 ;; Do an X-Sent lapsed format.
14418 ;; If the date is seriously mangled, the timezone
14419 ;; functions are liable to bug out, so we condition-case
14420 ;; the entire thing.
14421 (let* ((now (current-time))
14426 (timezone-make-date-arpa-standard
14427 (current-time-string now)
14428 (current-time-zone now) "UT"))
14430 (timezone-make-date-arpa-standard
14433 (real-sec (+ (* (float (car real-time)) 65536)
14435 (sec (abs real-sec))
14438 ((equal real-time '(0 0))
14439 "X-Sent: Unknown\n")
14445 ;; This is a bit convoluted, but basically we go
14446 ;; through the time units for years, weeks, etc,
14447 ;; and divide things to see whether that results
14448 ;; in positive answers.
14451 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
14452 ;; The (remaining) seconds are too few to
14453 ;; be divided into this time unit.
14455 ;; It's big enough, so we output it.
14456 (setq sec (- sec (* num (cdr unit))))
14458 (concat (if prev ", " "") (int-to-string
14460 " " (symbol-name (car unit))
14461 (if (> num 1) "s" ""))
14463 gnus-article-time-units "")
14464 ;; If dates are odd, then it might appear like the
14465 ;; article was sent in the future.
14468 " in the future\n"))))))
14470 (error "Unknown conversion type: %s" type))))
14472 (defun gnus-article-date-local (&optional highlight)
14473 "Convert the current article date to the local timezone."
14474 (interactive (list t))
14475 (gnus-article-date-ut 'local highlight))
14477 (defun gnus-article-date-original (&optional highlight)
14478 "Convert the current article date to what it was originally.
14479 This is only useful if you have used some other date conversion
14480 function and want to see what the date was before converting."
14481 (interactive (list t))
14482 (gnus-article-date-ut 'original highlight))
14484 (defun gnus-article-date-lapsed (&optional highlight)
14485 "Convert the current article date to time lapsed since it was sent."
14486 (interactive (list t))
14487 (gnus-article-date-ut 'lapsed highlight))
14489 (defun gnus-article-maybe-highlight ()
14490 "Do some article highlighting if `gnus-visual' is non-nil."
14491 (if (gnus-visual-p 'article-highlight 'highlight)
14492 (gnus-article-highlight-some)))
14494 ;;; Article savers.
14496 (defun gnus-output-to-rmail (file-name)
14497 "Append the current article to an Rmail file named FILE-NAME."
14499 ;; Most of these codes are borrowed from rmailout.el.
14500 (setq file-name (expand-file-name file-name))
14501 (setq rmail-default-rmail-file file-name)
14502 (let ((artbuf (current-buffer))
14503 (tmpbuf (get-buffer-create " *Gnus-output*")))
14505 (or (get-file-buffer file-name)
14506 (file-exists-p file-name)
14507 (if (gnus-yes-or-no-p
14508 (concat "\"" file-name "\" does not exist, create it? "))
14509 (let ((file-buffer (create-file-buffer file-name)))
14511 (set-buffer file-buffer)
14512 (rmail-insert-rmail-file-header)
14513 (let ((require-final-newline nil))
14514 (write-region (point-min) (point-max) file-name t 1)))
14515 (kill-buffer file-buffer))
14516 (error "Output file does not exist")))
14517 (set-buffer tmpbuf)
14518 (buffer-disable-undo (current-buffer))
14520 (insert-buffer-substring artbuf)
14521 (gnus-convert-article-to-rmail)
14522 ;; Decide whether to append to a file or to an Emacs buffer.
14523 (let ((outbuf (get-file-buffer file-name)))
14525 (append-to-file (point-min) (point-max) file-name)
14526 ;; File has been visited, in buffer OUTBUF.
14527 (set-buffer outbuf)
14528 (let ((buffer-read-only nil)
14529 (msg (and (boundp 'rmail-current-message)
14530 (symbol-value 'rmail-current-message))))
14531 ;; If MSG is non-nil, buffer is in RMAIL mode.
14534 (narrow-to-region (point-max) (point-max))))
14535 (insert-buffer-substring tmpbuf)
14538 (goto-char (point-min))
14540 (search-backward "\^_")
14541 (narrow-to-region (point) (point-max))
14542 (goto-char (1+ (point-min)))
14543 (rmail-count-new-messages t)
14544 (rmail-show-message msg)))))))
14545 (kill-buffer tmpbuf)))
14547 (defun gnus-output-to-file (file-name)
14548 "Append the current article to a file named FILE-NAME."
14549 (setq file-name (expand-file-name file-name))
14550 (let ((artbuf (current-buffer))
14551 (tmpbuf (get-buffer-create " *Gnus-output*")))
14553 (set-buffer tmpbuf)
14554 (buffer-disable-undo (current-buffer))
14556 (insert-buffer-substring artbuf)
14557 ;; Append newline at end of the buffer as separator, and then
14558 ;; save it to file.
14559 (goto-char (point-max))
14561 (append-to-file (point-min) (point-max) file-name))
14562 (kill-buffer tmpbuf)))
14564 (defun gnus-convert-article-to-rmail ()
14565 "Convert article in current buffer to Rmail message format."
14566 (let ((buffer-read-only nil))
14567 ;; Convert article directly into Babyl format.
14568 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
14569 (goto-char (point-min))
14570 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
14571 (while (search-forward "\n\^_" nil t) ;single char
14572 (replace-match "\n^_" t t)) ;2 chars: "^" and "_"
14573 (goto-char (point-max))
14576 (defun gnus-narrow-to-page (&optional arg)
14577 "Narrow the article buffer to a page.
14578 If given a numerical ARG, move forward ARG pages."
14580 (setq arg (if arg (prefix-numeric-value arg) 0))
14582 (set-buffer gnus-article-buffer)
14583 (goto-char (point-min))
14585 (when (gnus-visual-p 'page-marker)
14586 (let ((buffer-read-only nil))
14587 (gnus-remove-text-with-property 'gnus-prev)
14588 (gnus-remove-text-with-property 'gnus-next)))
14591 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
14593 (re-search-forward page-delimiter nil 'move arg)))
14594 (goto-char (match-end 0)))
14597 (if (re-search-forward page-delimiter nil 'move)
14598 (match-beginning 0)
14600 (when (and (gnus-visual-p 'page-marker)
14601 (not (= (point-min) 1)))
14603 (goto-char (point-min))
14604 (gnus-insert-prev-page-button)))
14605 (when (and (gnus-visual-p 'page-marker)
14606 (not (= (1- (point-max)) (buffer-size))))
14608 (goto-char (point-max))
14609 (gnus-insert-next-page-button)))))
14611 ;; Article mode commands
14613 (defun gnus-article-goto-next-page ()
14614 "Show the next page of the article."
14616 (when (gnus-article-next-page)
14617 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
14619 (defun gnus-article-goto-prev-page ()
14620 "Show the next page of the article."
14622 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))
14623 (gnus-article-prev-page nil)))
14625 (defun gnus-article-next-page (&optional lines)
14626 "Show the next page of the current article.
14627 If end of article, return non-nil. Otherwise return nil.
14628 Argument LINES specifies lines to be scrolled up."
14630 (move-to-window-line -1)
14631 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
14632 (if (save-excursion
14634 (and (pos-visible-in-window-p) ;Not continuation line.
14636 ;; Nothing in this page.
14637 (if (or (not gnus-break-pages)
14640 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
14642 (gnus-narrow-to-page 1) ;Go to next page.
14644 ;; More in this page.
14648 ;; Long lines may cause an end-of-buffer error.
14649 (goto-char (point-max))))
14650 (move-to-window-line 0)
14653 (defun gnus-article-prev-page (&optional lines)
14654 "Show previous page of current article.
14655 Argument LINES specifies lines to be scrolled down."
14657 (move-to-window-line 0)
14658 (if (and gnus-break-pages
14660 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
14662 (gnus-narrow-to-page -1) ;Go to previous page.
14663 (goto-char (point-max))
14667 (scroll-down lines)
14669 (move-to-window-line 0))))
14671 (defun gnus-article-refer-article ()
14672 "Read article specified by message-id around point."
14674 (let ((point (point)))
14675 (search-forward ">" nil t) ;Move point to end of "<....>".
14676 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
14677 (let ((message-id (match-string 1)))
14679 (set-buffer gnus-summary-buffer)
14680 (gnus-summary-refer-article message-id))
14681 (goto-char (point))
14682 (error "No references around point"))))
14684 (defun gnus-article-show-summary ()
14685 "Reconfigure windows to show summary buffer."
14687 (gnus-configure-windows 'article)
14688 (gnus-summary-goto-subject gnus-current-article))
14690 (defun gnus-article-describe-briefly ()
14691 "Describe article mode commands briefly."
14694 (substitute-command-keys "\\<gnus-article-mode-map>\\[gnus-article-next-page]:Next page \\[gnus-article-prev-page]:Prev page \\[gnus-article-show-summary]:Show summary \\[gnus-info-find-node]:Run Info \\[gnus-article-describe-briefly]:This help")))
14696 (defun gnus-article-summary-command ()
14697 "Execute the last keystroke in the summary buffer."
14699 (let ((obuf (current-buffer))
14700 (owin (current-window-configuration))
14702 (switch-to-buffer gnus-summary-buffer 'norecord)
14703 (setq func (lookup-key (current-local-map) (this-command-keys)))
14704 (call-interactively func)
14706 (set-window-configuration owin)
14707 (set-window-point (get-buffer-window (current-buffer)) (point))))
14709 (defun gnus-article-summary-command-nosave ()
14710 "Execute the last keystroke in the summary buffer."
14713 (pop-to-buffer gnus-summary-buffer 'norecord)
14714 (setq func (lookup-key (current-local-map) (this-command-keys)))
14715 (call-interactively func)))
14717 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
14718 "Read a summary buffer key sequence and execute it from the article buffer."
14721 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
14722 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
14723 "=" "^" "\M-^" "|"))
14726 (set-buffer gnus-summary-buffer)
14727 (push (or key last-command-event) unread-command-events)
14728 (setq keys (read-key-sequence nil)))
14731 (if (member keys nosaves)
14733 (pop-to-buffer gnus-summary-buffer 'norecord)
14734 (if (setq func (lookup-key (current-local-map) keys))
14735 (call-interactively func)
14737 (let ((obuf (current-buffer))
14738 (owin (current-window-configuration))
14741 (if not-restore-window
14742 (pop-to-buffer gnus-summary-buffer 'norecord)
14743 (switch-to-buffer gnus-summary-buffer 'norecord))
14744 (setq in-buffer (current-buffer))
14745 (if (setq func (lookup-key (current-local-map) keys))
14746 (call-interactively func)
14748 (when (eq in-buffer (current-buffer))
14750 (unless not-restore-window
14751 (set-window-configuration owin))
14752 (set-window-point (get-buffer-window (current-buffer)) opoint))))))
14756 ;;; Kill file handling.
14760 (defalias 'gnus-batch-kill 'gnus-batch-score)
14762 (defun gnus-batch-score ()
14763 "Run batched scoring.
14764 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
14765 Newsgroups is a list of strings in Bnews format. If you want to score
14766 the comp hierarchy, you'd say \"comp.all\". If you would not like to
14767 score the alt hierarchy, you'd say \"!alt.all\"."
14770 (gnus-newsrc-parse-options
14771 (apply (function concat)
14772 (mapcar (lambda (g) (concat g " "))
14773 command-line-args-left))))
14774 (gnus-expert-user t)
14775 (nnmail-spool-file nil)
14776 (gnus-use-dribble-file nil)
14777 (yes (car yes-and-no))
14778 (no (cdr yes-and-no))
14780 ;; Disable verbose message.
14781 gnus-novice-user gnus-large-newsgroup)
14782 ;; Eat all arguments.
14783 (setq command-line-args-left nil)
14786 ;; Apply kills to specified newsgroups in command line arguments.
14787 (setq newsrc (cdr gnus-newsrc-alist))
14789 (setq group (caar newsrc))
14790 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
14791 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed)
14793 (or (eq (car entry) t)
14794 (not (zerop (car entry)))))
14795 (if yes (string-match yes group) t)
14796 (or (null no) (not (string-match no group))))
14798 (gnus-summary-read-group group nil t nil t)
14799 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
14800 (gnus-summary-exit))))
14801 (setq newsrc (cdr newsrc)))
14803 (switch-to-buffer gnus-group-buffer)
14804 (gnus-group-save-newsrc)))
14806 (defun gnus-apply-kill-file ()
14807 "Apply a kill file to the current newsgroup.
14808 Returns the number of articles marked as read."
14809 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
14810 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14811 (gnus-apply-kill-file-internal)
14814 (defun gnus-kill-save-kill-buffer ()
14815 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14816 (when (get-file-buffer file)
14818 (set-buffer (get-file-buffer file))
14819 (and (buffer-modified-p) (save-buffer))
14820 (kill-buffer (current-buffer))))))
14822 (defvar gnus-kill-file-name "KILL"
14823 "Suffix of the kill files.")
14825 (defun gnus-newsgroup-kill-file (newsgroup)
14826 "Return the name of a kill file name for NEWSGROUP.
14827 If NEWSGROUP is nil, return the global kill file name instead."
14829 ;; The global KILL file is placed at top of the directory.
14830 ((or (null newsgroup)
14831 (string-equal newsgroup ""))
14832 (expand-file-name gnus-kill-file-name
14833 gnus-kill-files-directory))
14834 ;; Append ".KILL" to newsgroup name.
14835 ((gnus-use-long-file-name 'not-kill)
14836 (expand-file-name (concat (gnus-newsgroup-savable-name newsgroup)
14837 "." gnus-kill-file-name)
14838 gnus-kill-files-directory))
14839 ;; Place "KILL" under the hierarchical directory.
14841 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
14842 "/" gnus-kill-file-name)
14843 gnus-kill-files-directory))))
14850 (defvar gnus-dribble-ignore nil)
14851 (defvar gnus-dribble-eval-file nil)
14853 (defun gnus-dribble-file-name ()
14854 "Return the dribble file for the current .newsrc."
14856 (if gnus-dribble-directory
14857 (concat (file-name-as-directory gnus-dribble-directory)
14858 (file-name-nondirectory gnus-current-startup-file))
14859 gnus-current-startup-file)
14862 (defun gnus-dribble-enter (string)
14863 "Enter STRING into the dribble buffer."
14864 (if (and (not gnus-dribble-ignore)
14865 gnus-dribble-buffer
14866 (buffer-name gnus-dribble-buffer))
14867 (let ((obuf (current-buffer)))
14868 (set-buffer gnus-dribble-buffer)
14869 (insert string "\n")
14870 (set-window-point (get-buffer-window (current-buffer)) (point-max))
14871 (set-buffer obuf))))
14873 (defun gnus-dribble-read-file ()
14874 "Read the dribble file from disk."
14875 (let ((dribble-file (gnus-dribble-file-name)))
14877 (set-buffer (setq gnus-dribble-buffer
14879 (file-name-nondirectory dribble-file))))
14880 (gnus-add-current-to-buffer-list)
14882 (setq buffer-file-name dribble-file)
14884 (buffer-disable-undo (current-buffer))
14885 (bury-buffer (current-buffer))
14886 (set-buffer-modified-p nil)
14887 (let ((auto (make-auto-save-file-name))
14888 (gnus-dribble-ignore t)
14890 (when (or (file-exists-p auto) (file-exists-p dribble-file))
14891 ;; Load whichever file is newest -- the auto save file
14892 ;; or the "real" file.
14893 (if (file-newer-than-file-p auto dribble-file)
14894 (insert-file-contents auto)
14895 (insert-file-contents dribble-file))
14896 (unless (zerop (buffer-size))
14897 (set-buffer-modified-p t))
14898 ;; Set the file modes to reflect the .newsrc file modes.
14900 (when (and (file-exists-p gnus-current-startup-file)
14901 (setq modes (file-modes gnus-current-startup-file)))
14902 (set-file-modes dribble-file modes))
14903 ;; Possibly eval the file later.
14904 (when (gnus-y-or-n-p
14905 "Auto-save file exists. Do you want to read it? ")
14906 (setq gnus-dribble-eval-file t)))))))
14908 (defun gnus-dribble-eval-file ()
14909 (when gnus-dribble-eval-file
14910 (setq gnus-dribble-eval-file nil)
14912 (let ((gnus-dribble-ignore t))
14913 (set-buffer gnus-dribble-buffer)
14914 (eval-buffer (current-buffer))))))
14916 (defun gnus-dribble-delete-file ()
14917 (when (file-exists-p (gnus-dribble-file-name))
14918 (delete-file (gnus-dribble-file-name)))
14919 (when gnus-dribble-buffer
14921 (set-buffer gnus-dribble-buffer)
14922 (let ((auto (make-auto-save-file-name)))
14923 (if (file-exists-p auto)
14924 (delete-file auto))
14926 (set-buffer-modified-p nil)))))
14928 (defun gnus-dribble-save ()
14929 (when (and gnus-dribble-buffer
14930 (buffer-name gnus-dribble-buffer))
14932 (set-buffer gnus-dribble-buffer)
14935 (defun gnus-dribble-clear ()
14936 (when (gnus-buffer-exists-p gnus-dribble-buffer)
14938 (set-buffer gnus-dribble-buffer)
14940 (set-buffer-modified-p nil)
14941 (setq buffer-saved-size (buffer-size)))))
14945 ;;; Server Communication
14948 (defun gnus-start-news-server (&optional confirm)
14949 "Open a method for getting news.
14950 If CONFIRM is non-nil, the user will be asked for an NNTP server."
14952 (if gnus-current-select-method
14953 ;; Stream is already opened.
14955 ;; Open NNTP server.
14956 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
14959 ;; Read server name with completion.
14960 (setq gnus-nntp-server
14961 (completing-read "NNTP server: "
14962 (mapcar (lambda (server) (list server))
14963 (cons (list gnus-nntp-server)
14964 gnus-secondary-servers))
14965 nil nil gnus-nntp-server))))
14967 (if (and gnus-nntp-server
14968 (stringp gnus-nntp-server)
14969 (not (string= gnus-nntp-server "")))
14970 (setq gnus-select-method
14971 (cond ((or (string= gnus-nntp-server "")
14972 (string= gnus-nntp-server "::"))
14973 (list 'nnspool (system-name)))
14974 ((string-match "^:" gnus-nntp-server)
14975 (list 'nnmh gnus-nntp-server
14976 (list 'nnmh-directory
14977 (file-name-as-directory
14979 (concat "~/" (substring
14980 gnus-nntp-server 1)))))
14981 (list 'nnmh-get-new-mail nil)))
14983 (list 'nntp gnus-nntp-server)))))
14985 (setq how (car gnus-select-method))
14986 (cond ((eq how 'nnspool)
14988 (gnus-message 5 "Looking up local news spool..."))
14991 (gnus-message 5 "Looking up mh spool..."))
14994 (setq gnus-current-select-method gnus-select-method)
14995 (run-hooks 'gnus-open-server-hook)
14997 ;; gnus-open-server-hook might have opened it
14998 (gnus-server-opened gnus-select-method)
14999 (gnus-open-server gnus-select-method)
15002 "%s (%s) open error: '%s'. Continue? "
15003 (car gnus-select-method) (cadr gnus-select-method)
15004 (gnus-status-message gnus-select-method)))
15005 (gnus-error 1 "Couldn't open server on %s"
15006 (nth 1 gnus-select-method))))))
15008 (defun gnus-check-group (group)
15009 "Try to make sure that the server where GROUP exists is alive."
15010 (let ((method (gnus-find-method-for-group group)))
15011 (or (gnus-server-opened method)
15012 (gnus-open-server method))))
15014 (defun gnus-check-server (&optional method silent)
15015 "Check whether the connection to METHOD is down.
15016 If METHOD is nil, use `gnus-select-method'.
15017 If it is down, start it up (again)."
15018 (let ((method (or method gnus-select-method)))
15019 ;; Transform virtual server names into select methods.
15020 (when (stringp method)
15021 (setq method (gnus-server-to-method method)))
15022 (if (gnus-server-opened method)
15023 ;; The stream is already opened.
15025 ;; Open the server.
15027 (gnus-message 5 "Opening %s server%s..." (car method)
15028 (if (equal (nth 1 method) "") ""
15029 (format " on %s" (nth 1 method)))))
15030 (run-hooks 'gnus-open-server-hook)
15032 (gnus-open-server method)
15036 (defun gnus-get-function (method function)
15037 "Return a function symbol based on METHOD and FUNCTION."
15038 ;; Translate server names into methods.
15040 (error "Attempted use of a nil select method"))
15041 (when (stringp method)
15042 (setq method (gnus-server-to-method method)))
15043 (let ((func (intern (format "%s-%s" (car method) function))))
15044 ;; If the functions isn't bound, we require the backend in
15046 (unless (fboundp func)
15047 (require (car method))
15048 (unless (fboundp func)
15049 ;; This backend doesn't implement this function.
15050 (error "No such function: %s" func)))
15055 ;;; Interface functions to the backends.
15058 (defun gnus-open-server (method)
15059 "Open a connection to METHOD."
15060 (when (stringp method)
15061 (setq method (gnus-server-to-method method)))
15062 (let ((elem (assoc method gnus-opened-servers)))
15063 ;; If this method was previously denied, we just return nil.
15064 (if (eq (nth 1 elem) 'denied)
15066 (gnus-message 1 "Denied server")
15068 ;; Open the server.
15070 (funcall (gnus-get-function method 'open-server)
15071 (nth 1 method) (nthcdr 2 method))))
15072 ;; If this hasn't been opened before, we add it to the list.
15074 (setq elem (list method nil)
15075 gnus-opened-servers (cons elem gnus-opened-servers)))
15076 ;; Set the status of this server.
15077 (setcar (cdr elem) (if result 'ok 'denied))
15078 ;; Return the result from the "open" call.
15081 (defun gnus-close-server (method)
15082 "Close the connection to METHOD."
15083 (when (stringp method)
15084 (setq method (gnus-server-to-method method)))
15085 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
15087 (defun gnus-request-list (method)
15088 "Request the active file from METHOD."
15089 (when (stringp method)
15090 (setq method (gnus-server-to-method method)))
15091 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
15093 (defun gnus-request-list-newsgroups (method)
15094 "Request the newsgroups file from METHOD."
15095 (when (stringp method)
15096 (setq method (gnus-server-to-method method)))
15097 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
15099 (defun gnus-request-newgroups (date method)
15100 "Request all new groups since DATE from METHOD."
15101 (when (stringp method)
15102 (setq method (gnus-server-to-method method)))
15103 (funcall (gnus-get-function method 'request-newgroups)
15104 date (nth 1 method)))
15106 (defun gnus-server-opened (method)
15107 "Check whether a connection to METHOD has been opened."
15108 (when (stringp method)
15109 (setq method (gnus-server-to-method method)))
15110 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
15112 (defun gnus-status-message (method)
15113 "Return the status message from METHOD.
15114 If METHOD is a string, it is interpreted as a group name. The method
15115 this group uses will be queried."
15116 (let ((method (if (stringp method) (gnus-find-method-for-group method)
15118 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
15120 (defun gnus-request-group (group &optional dont-check method)
15121 "Request GROUP. If DONT-CHECK, no information is required."
15122 (let ((method (or method (gnus-find-method-for-group group))))
15123 (when (stringp method)
15124 (setq method (gnus-server-to-method method)))
15125 (funcall (gnus-get-function method 'request-group)
15126 (gnus-group-real-name group) (nth 1 method) dont-check)))
15128 (defun gnus-request-asynchronous (group &optional articles)
15129 "Request that GROUP behave asynchronously.
15130 ARTICLES is the `data' of the group."
15131 (let ((method (gnus-find-method-for-group group)))
15132 (funcall (gnus-get-function method 'request-asynchronous)
15133 (gnus-group-real-name group) (nth 1 method) articles)))
15135 (defun gnus-list-active-group (group)
15136 "Request active information on GROUP."
15137 (let ((method (gnus-find-method-for-group group))
15138 (func 'list-active-group))
15139 (when (gnus-check-backend-function func group)
15140 (funcall (gnus-get-function method func)
15141 (gnus-group-real-name group) (nth 1 method)))))
15143 (defun gnus-request-group-description (group)
15144 "Request a description of GROUP."
15145 (let ((method (gnus-find-method-for-group group))
15146 (func 'request-group-description))
15147 (when (gnus-check-backend-function func group)
15148 (funcall (gnus-get-function method func)
15149 (gnus-group-real-name group) (nth 1 method)))))
15151 (defun gnus-close-group (group)
15152 "Request the GROUP be closed."
15153 (let ((method (gnus-find-method-for-group group)))
15154 (funcall (gnus-get-function method 'close-group)
15155 (gnus-group-real-name group) (nth 1 method))))
15157 (defun gnus-retrieve-headers (articles group &optional fetch-old)
15158 "Request headers for ARTICLES in GROUP.
15159 If FETCH-OLD, retrieve all headers (or some subset thereof) in the group."
15160 (let ((method (gnus-find-method-for-group group)))
15161 (if (and gnus-use-cache (numberp (car articles)))
15162 (gnus-cache-retrieve-headers articles group fetch-old)
15163 (funcall (gnus-get-function method 'retrieve-headers)
15164 articles (gnus-group-real-name group) (nth 1 method)
15167 (defun gnus-retrieve-groups (groups method)
15168 "Request active information on GROUPS from METHOD."
15169 (when (stringp method)
15170 (setq method (gnus-server-to-method method)))
15171 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method)))
15173 (defun gnus-request-type (group &optional article)
15174 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
15175 (let ((method (gnus-find-method-for-group group)))
15176 (if (not (gnus-check-backend-function 'request-type (car method)))
15178 (funcall (gnus-get-function method 'request-type)
15179 (gnus-group-real-name group) article))))
15181 (defun gnus-request-update-mark (group article mark)
15182 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
15183 (let ((method (gnus-find-method-for-group group)))
15184 (if (not (gnus-check-backend-function 'request-update-mark (car method)))
15186 (funcall (gnus-get-function method 'request-update-mark)
15187 (gnus-group-real-name group) article mark))))
15189 (defun gnus-request-article (article group &optional buffer)
15190 "Request the ARTICLE in GROUP.
15191 ARTICLE can either be an article number or an article Message-ID.
15192 If BUFFER, insert the article in that group."
15193 (let ((method (gnus-find-method-for-group group)))
15194 (funcall (gnus-get-function method 'request-article)
15195 article (gnus-group-real-name group) (nth 1 method) buffer)))
15197 (defun gnus-request-head (article group)
15198 "Request the head of ARTICLE in GROUP."
15199 (let ((method (gnus-find-method-for-group group)))
15200 (funcall (gnus-get-function method 'request-head)
15201 article (gnus-group-real-name group) (nth 1 method))))
15203 (defun gnus-request-body (article group)
15204 "Request the body of ARTICLE in GROUP."
15205 (let ((method (gnus-find-method-for-group group)))
15206 (funcall (gnus-get-function method 'request-body)
15207 article (gnus-group-real-name group) (nth 1 method))))
15209 (defun gnus-request-post (method)
15210 "Post the current buffer using METHOD."
15211 (when (stringp method)
15212 (setq method (gnus-server-to-method method)))
15213 (funcall (gnus-get-function method 'request-post) (nth 1 method)))
15215 (defun gnus-request-scan (group method)
15216 "Request a SCAN being performed in GROUP from METHOD.
15217 If GROUP is nil, all groups on METHOD are scanned."
15218 (let ((method (if group (gnus-find-method-for-group group) method)))
15219 (funcall (gnus-get-function method 'request-scan)
15220 (and group (gnus-group-real-name group)) (nth 1 method))))
15222 (defsubst gnus-request-update-info (info method)
15223 "Request that METHOD update INFO."
15224 (when (stringp method)
15225 (setq method (gnus-server-to-method method)))
15226 (when (gnus-check-backend-function 'request-update-info (car method))
15227 (funcall (gnus-get-function method 'request-update-info)
15228 (gnus-group-real-name (gnus-info-group info))
15229 info (nth 1 method))))
15231 (defun gnus-request-expire-articles (articles group &optional force)
15232 (let ((method (gnus-find-method-for-group group)))
15233 (funcall (gnus-get-function method 'request-expire-articles)
15234 articles (gnus-group-real-name group) (nth 1 method)
15237 (defun gnus-request-move-article
15238 (article group server accept-function &optional last)
15239 (let ((method (gnus-find-method-for-group group)))
15240 (funcall (gnus-get-function method 'request-move-article)
15241 article (gnus-group-real-name group)
15242 (nth 1 method) accept-function last)))
15244 (defun gnus-request-accept-article (group method &optional last)
15245 ;; Make sure there's a newline at the end of the article.
15246 (when (stringp method)
15247 (setq method (gnus-server-to-method method)))
15248 (when (and (not method)
15250 (setq method (gnus-find-method-for-group group)))
15251 (goto-char (point-max))
15254 (let ((func (car (or method (gnus-find-method-for-group group)))))
15255 (funcall (intern (format "%s-request-accept-article" func))
15256 (if (stringp group) (gnus-group-real-name group) group)
15260 (defun gnus-request-replace-article (article group buffer)
15261 (let ((func (car (gnus-find-method-for-group group))))
15262 (funcall (intern (format "%s-request-replace-article" func))
15263 article (gnus-group-real-name group) buffer)))
15265 (defun gnus-request-associate-buffer (group)
15266 (let ((method (gnus-find-method-for-group group)))
15267 (funcall (gnus-get-function method 'request-associate-buffer)
15268 (gnus-group-real-name group))))
15270 (defun gnus-request-restore-buffer (article group)
15271 "Request a new buffer restored to the state of ARTICLE."
15272 (let ((method (gnus-find-method-for-group group)))
15273 (funcall (gnus-get-function method 'request-restore-buffer)
15274 article (gnus-group-real-name group) (nth 1 method))))
15276 (defun gnus-request-create-group (group &optional method)
15277 (when (stringp method)
15278 (setq method (gnus-server-to-method method)))
15279 (let ((method (or method (gnus-find-method-for-group group))))
15280 (funcall (gnus-get-function method 'request-create-group)
15281 (gnus-group-real-name group) (nth 1 method))))
15283 (defun gnus-request-delete-group (group &optional force)
15284 (let ((method (gnus-find-method-for-group group)))
15285 (funcall (gnus-get-function method 'request-delete-group)
15286 (gnus-group-real-name group) force (nth 1 method))))
15288 (defun gnus-request-rename-group (group new-name)
15289 (let ((method (gnus-find-method-for-group group)))
15290 (funcall (gnus-get-function method 'request-rename-group)
15291 (gnus-group-real-name group)
15292 (gnus-group-real-name new-name) (nth 1 method))))
15294 (defun gnus-member-of-valid (symbol group)
15295 "Find out if GROUP has SYMBOL as part of its \"valid\" spec."
15296 (memq symbol (assoc
15297 (symbol-name (car (gnus-find-method-for-group group)))
15298 gnus-valid-select-methods)))
15300 (defun gnus-method-option-p (method option)
15301 "Return non-nil if select METHOD has OPTION as a parameter."
15302 (when (stringp method)
15303 (setq method (gnus-server-to-method method)))
15304 (memq option (assoc (format "%s" (car method))
15305 gnus-valid-select-methods)))
15307 (defun gnus-server-extend-method (group method)
15308 ;; This function "extends" a virtual server. If the server is
15309 ;; "hello", and the select method is ("hello" (my-var "something"))
15310 ;; in the group "alt.alt", this will result in a new virtual server
15311 ;; called "hello+alt.alt".
15313 (gnus-copy-sequence
15314 (if (equal (car method) "native") gnus-select-method
15315 (cdr (assoc (car method) gnus-server-alist))))))
15316 (setcar (cdr entry) (concat (nth 1 entry) "+" group))
15317 (nconc entry (cdr method))))
15319 (defun gnus-find-method-for-group (group &optional info)
15320 "Find the select method that GROUP uses."
15321 (or gnus-override-method
15323 gnus-select-method)
15324 (let ((info (or info (gnus-get-info group)))
15327 (not (setq method (gnus-info-method info)))
15328 (equal method "native"))
15331 (cond ((stringp method)
15332 (gnus-server-to-method method))
15333 ((stringp (car method))
15334 (gnus-server-extend-method group method))
15337 (cond ((equal (cadr method) "")
15339 ((null (cadr method))
15340 (list (car method) ""))
15342 (gnus-server-add-address method)))))))
15344 (defun gnus-check-backend-function (func group)
15345 "Check whether GROUP supports function FUNC."
15346 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
15348 (fboundp (intern (format "%s-%s" method func)))))
15350 (defun gnus-methods-using (feature)
15351 "Find all methods that have FEATURE."
15352 (let ((valids gnus-valid-select-methods)
15355 (if (memq feature (car valids))
15356 (setq outs (cons (car valids) outs)))
15357 (setq valids (cdr valids)))
15362 ;;; Active & Newsrc File Handling
15365 (defun gnus-setup-news (&optional rawfile level dont-connect)
15366 "Setup news information.
15367 If RAWFILE is non-nil, the .newsrc file will also be read.
15368 If LEVEL is non-nil, the news will be set up at level LEVEL."
15369 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile)))))
15372 ;; Clear some variables to re-initialize news information.
15373 (setq gnus-newsrc-alist nil
15374 gnus-active-hashtb nil)
15375 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
15376 (gnus-read-newsrc-file rawfile))
15378 (when (and (not (assoc "archive" gnus-server-alist))
15379 gnus-message-archive-method)
15380 (push (cons "archive" gnus-message-archive-method)
15381 gnus-server-alist))
15383 ;; If we don't read the complete active file, we fill in the
15385 (if (or (null gnus-read-active-file)
15386 (eq gnus-read-active-file 'some))
15387 (gnus-update-active-hashtb-from-killed))
15389 ;; Read the active file and create `gnus-active-hashtb'.
15390 ;; If `gnus-read-active-file' is nil, then we just create an empty
15391 ;; hash table. The partial filling out of the hash table will be
15392 ;; done in `gnus-get-unread-articles'.
15393 (and gnus-read-active-file
15395 (gnus-read-active-file))
15397 (or gnus-active-hashtb
15398 (setq gnus-active-hashtb (make-vector 4095 0)))
15400 ;; Initialize the cache.
15401 (when gnus-use-cache
15404 ;; Possibly eval the dribble file.
15405 (and init (or gnus-use-dribble-file gnus-slave) (gnus-dribble-eval-file))
15407 ;; Slave Gnusii should then clear the dribble buffer.
15408 (when (and init gnus-slave)
15409 (gnus-dribble-clear))
15411 (gnus-update-format-specifications)
15413 ;; See whether we need to read the description file.
15414 (if (and (string-match "%[-,0-9]*D" gnus-group-line-format)
15415 (not gnus-description-hashtb)
15417 gnus-read-active-file)
15418 (gnus-read-all-descriptions-files))
15420 ;; Find new newsgroups and treat them.
15421 (if (and init gnus-check-new-newsgroups (not level)
15422 (gnus-check-server gnus-select-method))
15423 (gnus-find-new-newsgroups))
15425 ;; We might read in new NoCeM messages here.
15426 (when (and gnus-use-nocem
15428 (not dont-connect))
15429 (gnus-nocem-scan-groups))
15431 ;; Find the number of unread articles in each non-dead group.
15432 (let ((gnus-read-active-file (and (not level) gnus-read-active-file)))
15433 (gnus-get-unread-articles level))
15435 (if (and init gnus-check-bogus-newsgroups
15436 gnus-read-active-file (not level)
15437 (gnus-server-opened gnus-select-method))
15438 (gnus-check-bogus-newsgroups))))
15440 (defun gnus-find-new-newsgroups (&optional arg)
15441 "Search for new newsgroups and add them.
15442 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
15443 The `-n' option line from .newsrc is respected.
15444 If ARG (the prefix), use the `ask-server' method to query
15445 the server for new groups."
15447 (let ((check (if (or (and arg (not (listp gnus-check-new-newsgroups)))
15448 (null gnus-read-active-file)
15449 (eq gnus-read-active-file 'some))
15450 'ask-server gnus-check-new-newsgroups)))
15451 (unless (gnus-check-first-time-used)
15452 (if (or (consp check)
15453 (eq check 'ask-server))
15454 ;; Ask the server for new groups.
15455 (gnus-ask-server-for-new-groups)
15456 ;; Go through the active hashtb and look for new groups.
15458 group new-newsgroups)
15459 (gnus-message 5 "Looking for new newsgroups...")
15460 (unless gnus-have-read-active-file
15461 (gnus-read-active-file))
15462 (setq gnus-newsrc-last-checked-date (current-time-string))
15463 (unless gnus-killed-hashtb
15464 (gnus-make-hashtable-from-killed))
15465 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
15466 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
15469 (if (or (null (setq group (symbol-name sym)))
15471 (null (symbol-value sym))
15472 (gnus-gethash group gnus-killed-hashtb)
15473 (gnus-gethash group gnus-newsrc-hashtb))
15475 (let ((do-sub (gnus-matches-options-n group)))
15477 ((eq do-sub 'subscribe)
15478 (setq groups (1+ groups))
15479 (gnus-sethash group group gnus-killed-hashtb)
15480 (funcall gnus-subscribe-options-newsgroup-method group))
15481 ((eq do-sub 'ignore)
15484 (setq groups (1+ groups))
15485 (gnus-sethash group group gnus-killed-hashtb)
15486 (if gnus-subscribe-hierarchical-interactive
15487 (setq new-newsgroups (cons group new-newsgroups))
15488 (funcall gnus-subscribe-newsgroup-method group)))))))
15489 gnus-active-hashtb)
15490 (when new-newsgroups
15491 (gnus-subscribe-hierarchical-interactive new-newsgroups))
15492 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
15494 (gnus-message 6 "%d new newsgroup%s arrived."
15495 groups (if (> groups 1) "s have" " has"))
15496 (gnus-message 6 "No new newsgroups.")))))))
15498 (defun gnus-matches-options-n (group)
15499 ;; Returns `subscribe' if the group is to be unconditionally
15500 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
15501 ;; no match for the group.
15503 ;; First we check the two user variables.
15505 ((and gnus-options-subscribe
15506 (string-match gnus-options-subscribe group))
15508 ((and gnus-auto-subscribed-groups
15509 (string-match gnus-auto-subscribed-groups group))
15511 ((and gnus-options-not-subscribe
15512 (string-match gnus-options-not-subscribe group))
15514 ;; Then we go through the list that was retrieved from the .newsrc
15515 ;; file. This list has elements on the form
15516 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
15517 ;; is in the reverse order of the options line) is returned.
15519 (let ((regs gnus-newsrc-options-n))
15521 (not (string-match (caar regs) group)))
15522 (setq regs (cdr regs)))
15523 (and regs (cdar regs))))))
15525 (defun gnus-ask-server-for-new-groups ()
15526 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
15527 (methods (cons gnus-select-method
15529 (when gnus-message-archive-method
15532 (and (consp gnus-check-new-newsgroups)
15533 gnus-check-new-newsgroups)
15534 gnus-secondary-select-methods))))
15536 (new-date (current-time-string))
15537 group new-newsgroups got-new method hashtb
15538 gnus-override-subscribe-method)
15539 ;; Go through both primary and secondary select methods and
15540 ;; request new newsgroups.
15541 (while (setq method (gnus-server-get-method nil (pop methods)))
15542 (setq new-newsgroups nil)
15543 (setq gnus-override-subscribe-method method)
15544 (when (and (gnus-check-server method)
15545 (gnus-request-newgroups date method))
15548 (setq hashtb (gnus-make-hashtable 100))
15549 (set-buffer nntp-server-buffer)
15550 ;; Enter all the new groups into a hashtable.
15551 (gnus-active-to-gnus-format method hashtb 'ignore))
15552 ;; Now all new groups from `method' are in `hashtb'.
15554 (lambda (group-sym)
15555 (if (or (null (setq group (symbol-name group-sym)))
15556 (not (boundp group-sym))
15557 (null (symbol-value group-sym))
15558 (gnus-gethash group gnus-newsrc-hashtb)
15559 (member group gnus-zombie-list)
15560 (member group gnus-killed-list))
15561 ;; The group is already known.
15563 ;; Make this group active.
15564 (when (symbol-value group-sym)
15565 (gnus-set-active group (symbol-value group-sym)))
15566 ;; Check whether we want it or not.
15567 (let ((do-sub (gnus-matches-options-n group)))
15569 ((eq do-sub 'subscribe)
15571 (gnus-sethash group group gnus-killed-hashtb)
15572 (funcall gnus-subscribe-options-newsgroup-method group))
15573 ((eq do-sub 'ignore)
15577 (gnus-sethash group group gnus-killed-hashtb)
15578 (if gnus-subscribe-hierarchical-interactive
15579 (push group new-newsgroups)
15580 (funcall gnus-subscribe-newsgroup-method group)))))))
15582 (when new-newsgroups
15583 (gnus-subscribe-hierarchical-interactive new-newsgroups)))
15584 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
15586 (gnus-message 6 "%d new newsgroup%s arrived."
15587 groups (if (> groups 1) "s have" " has")))
15588 (and got-new (setq gnus-newsrc-last-checked-date new-date))
15591 (defun gnus-check-first-time-used ()
15592 (if (or (> (length gnus-newsrc-alist) 1)
15593 (file-exists-p gnus-startup-file)
15594 (file-exists-p (concat gnus-startup-file ".el"))
15595 (file-exists-p (concat gnus-startup-file ".eld")))
15597 (gnus-message 6 "First time user; subscribing you to default groups")
15598 (unless (gnus-read-active-file-p)
15599 (gnus-read-active-file))
15600 (setq gnus-newsrc-last-checked-date (current-time-string))
15601 (let ((groups gnus-default-subscribed-newsgroups)
15605 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
15608 (if (null (setq group (symbol-name sym)))
15610 (let ((do-sub (gnus-matches-options-n group)))
15612 ((eq do-sub 'subscribe)
15613 (gnus-sethash group group gnus-killed-hashtb)
15614 (funcall gnus-subscribe-options-newsgroup-method group))
15615 ((eq do-sub 'ignore)
15618 (setq gnus-killed-list (cons group gnus-killed-list)))))))
15619 gnus-active-hashtb)
15621 (if (gnus-active (car groups))
15622 (gnus-group-change-level
15623 (car groups) gnus-level-default-subscribed gnus-level-killed))
15624 (setq groups (cdr groups)))
15625 (gnus-group-make-help-group)
15626 (and gnus-novice-user
15627 (gnus-message 7 "`A k' to list killed groups"))))))
15629 (defun gnus-subscribe-group (group previous &optional method)
15630 (gnus-group-change-level
15632 (list t group gnus-level-default-subscribed nil nil method)
15634 gnus-level-default-subscribed gnus-level-killed previous t))
15636 ;; `gnus-group-change-level' is the fundamental function for changing
15637 ;; subscription levels of newsgroups. This might mean just changing
15638 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
15639 ;; again, which subscribes/unsubscribes a group, which is equally
15640 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
15641 ;; from 8-9 to 1-7 means that you remove the group from the list of
15642 ;; killed (or zombie) groups and add them to the (kinda) subscribed
15643 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
15644 ;; which is trivial.
15645 ;; ENTRY can either be a string (newsgroup name) or a list (if
15646 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
15647 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
15649 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
15650 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
15652 (defun gnus-group-change-level (entry level &optional oldlevel
15653 previous fromkilled)
15654 (let (group info active num)
15655 ;; Glean what info we can from the arguments
15657 (if fromkilled (setq group (nth 1 entry))
15658 (setq group (car (nth 2 entry))))
15659 (setq group entry))
15660 (if (and (stringp entry)
15662 (< oldlevel gnus-level-zombie))
15663 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
15664 (if (and (not oldlevel)
15666 (setq oldlevel (gnus-info-level (nth 2 entry)))
15667 (setq oldlevel (or oldlevel 9)))
15668 (if (stringp previous)
15669 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
15671 (if (and (>= oldlevel gnus-level-zombie)
15672 (gnus-gethash group gnus-newsrc-hashtb))
15673 ;; We are trying to subscribe a group that is already
15677 (or (gnus-ephemeral-group-p group)
15678 (gnus-dribble-enter
15679 (format "(gnus-group-change-level %S %S %S %S %S)"
15680 group level oldlevel (car (nth 2 previous)) fromkilled)))
15682 ;; Then we remove the newgroup from any old structures, if needed.
15683 ;; If the group was killed, we remove it from the killed or zombie
15684 ;; list. If not, and it is in fact going to be killed, we remove
15685 ;; it from the newsrc hash table and assoc.
15687 ((>= oldlevel gnus-level-zombie)
15688 (if (= oldlevel gnus-level-zombie)
15689 (setq gnus-zombie-list (delete group gnus-zombie-list))
15690 (setq gnus-killed-list (delete group gnus-killed-list))))
15692 (if (and (>= level gnus-level-zombie)
15695 (gnus-sethash (car (nth 2 entry)) nil gnus-newsrc-hashtb)
15697 (setcdr (gnus-gethash (car (nth 3 entry))
15698 gnus-newsrc-hashtb)
15700 (setcdr (cdr entry) (cdddr entry))))))
15702 ;; Finally we enter (if needed) the list where it is supposed to
15703 ;; go, and change the subscription level. If it is to be killed,
15704 ;; we enter it into the killed or zombie list.
15706 ((>= level gnus-level-zombie)
15707 ;; Remove from the hash table.
15708 (gnus-sethash group nil gnus-newsrc-hashtb)
15709 ;; We do not enter foreign groups into the list of dead
15711 (unless (gnus-group-foreign-p group)
15712 (if (= level gnus-level-zombie)
15713 (setq gnus-zombie-list (cons group gnus-zombie-list))
15714 (setq gnus-killed-list (cons group gnus-killed-list)))))
15716 ;; If the list is to be entered into the newsrc assoc, and
15717 ;; it was killed, we have to create an entry in the newsrc
15718 ;; hashtb format and fix the pointers in the newsrc assoc.
15719 (if (< oldlevel gnus-level-zombie)
15720 ;; It was alive, and it is going to stay alive, so we
15721 ;; just change the level and don't change any pointers or
15722 ;; hash table entries.
15723 (setcar (cdaddr entry) level)
15725 (setq info (cdr entry)
15727 (setq active (gnus-active group))
15729 (if active (- (1+ (cdr active)) (car active)) t))
15730 ;; Check whether the group is foreign. If so, the
15731 ;; foreign select method has to be entered into the
15733 (let ((method (or gnus-override-subscribe-method
15734 (gnus-group-method group))))
15735 (if (eq method gnus-select-method)
15736 (setq info (list group level nil))
15737 (setq info (list group level nil nil method)))))
15740 (let ((p gnus-newsrc-alist))
15744 (setq entry (cons info (cddr previous)))
15747 (setcdr (cdr previous) entry)
15748 (gnus-sethash group (cons num (cdr previous))
15749 gnus-newsrc-hashtb))
15750 (setcdr previous entry)
15751 (gnus-sethash group (cons num previous)
15752 gnus-newsrc-hashtb))
15754 (setcdr (gnus-gethash (caadr entry) gnus-newsrc-hashtb) entry)))))
15755 (when gnus-group-change-level-function
15756 (funcall gnus-group-change-level-function group level oldlevel)))))
15758 (defun gnus-kill-newsgroup (newsgroup)
15759 "Obsolete function. Kills a newsgroup."
15760 (gnus-group-change-level
15761 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed))
15763 (defun gnus-check-bogus-newsgroups (&optional confirm)
15764 "Remove bogus newsgroups.
15765 If CONFIRM is non-nil, the user has to confirm the deletion of every
15767 (let ((newsrc (cdr gnus-newsrc-alist))
15768 bogus group entry info)
15769 (gnus-message 5 "Checking bogus newsgroups...")
15770 (unless (gnus-read-active-file-p)
15771 (gnus-read-active-file))
15772 (when (gnus-read-active-file-p)
15773 ;; Find all bogus newsgroup that are subscribed.
15775 (setq info (pop newsrc)
15776 group (gnus-info-group info))
15777 (unless (or (gnus-active group) ; Active
15778 (gnus-info-method info) ; Foreign
15780 (not (gnus-y-or-n-p
15781 (format "Remove bogus newsgroup: %s " group)))))
15782 ;; Found a bogus newsgroup.
15783 (push group bogus)))
15784 ;; Remove all bogus subscribed groups by first killing them, and
15785 ;; then removing them from the list of killed groups.
15787 (when (setq entry (gnus-gethash (setq group (pop bogus))
15788 gnus-newsrc-hashtb))
15789 (gnus-group-change-level entry gnus-level-killed)
15790 (setq gnus-killed-list (delete group gnus-killed-list))))
15791 ;; Then we remove all bogus groups from the list of killed and
15792 ;; zombie groups. They are are removed without confirmation.
15793 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
15796 (setq killed (symbol-value (car dead-lists)))
15798 (unless (gnus-active (setq group (pop killed)))
15799 ;; The group is bogus.
15800 ;; !!!Slow as hell.
15801 (set (car dead-lists)
15802 (delete group (symbol-value (car dead-lists))))))
15803 (setq dead-lists (cdr dead-lists))))
15804 (gnus-message 5 "Checking bogus newsgroups...done"))))
15806 (defun gnus-check-duplicate-killed-groups ()
15807 "Remove duplicates from the list of killed groups."
15809 (let ((killed gnus-killed-list))
15811 (gnus-message 9 "%d" (length killed))
15812 (setcdr killed (delete (car killed) (cdr killed)))
15813 (setq killed (cdr killed)))))
15815 ;; We want to inline a function from gnus-cache, so we cheat here:
15818 (require 'gnus-cache))
15820 (defun gnus-get-unread-articles-in-group (info active &optional update)
15822 ;; Allow the backend to update the info in the group.
15824 (gnus-request-update-info
15825 info (gnus-find-method-for-group (gnus-info-group info))))
15826 (gnus-activate-group (gnus-info-group info) nil t))
15827 (let* ((range (gnus-info-read info))
15829 ;; If a cache is present, we may have to alter the active info.
15830 (when (and gnus-use-cache info)
15831 (inline (gnus-cache-possibly-alter-active
15832 (gnus-info-group info) active)))
15833 ;; Modify the list of read articles according to what articles
15834 ;; are available; then tally the unread articles and add the
15835 ;; number to the group hash table entry.
15837 ((zerop (cdr active))
15840 (setq num (- (1+ (cdr active)) (car active))))
15841 ((not (listp (cdr range)))
15842 ;; Fix a single (num . num) range according to the
15843 ;; active hash table.
15844 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
15845 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
15846 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
15847 ;; Compute number of unread articles.
15848 (setq num (max 0 (- (cdr active) (- (1+ (cdr range)) (car range))))))
15850 ;; The read list is a list of ranges. Fix them according to
15851 ;; the active hash table.
15852 ;; First peel off any elements that are below the lower
15854 (while (and (cdr range)
15856 (or (and (atom (cadr range)) (cadr range))
15858 (if (numberp (car range))
15861 (or (and (numberp (cadr range))
15864 (setcdr (car range)
15865 (or (and (numberp (nth 1 range)) (nth 1 range))
15867 (setcdr range (cddr range)))
15868 ;; Adjust the first element to be the same as the lower limit.
15869 (if (and (not (atom (car range)))
15870 (< (cdar range) (car active)))
15871 (setcdr (car range) (1- (car active))))
15872 ;; Then we want to peel off any elements that are higher
15873 ;; than the upper active limit.
15874 (let ((srange range))
15875 ;; Go past all legal elements.
15876 (while (and (cdr srange)
15877 (<= (or (and (atom (cadr srange))
15879 (caadr srange)) (cdr active)))
15880 (setq srange (cdr srange)))
15882 ;; Nuke all remaining illegal elements.
15883 (setcdr srange nil))
15885 ;; Adjust the final element.
15886 (if (and (not (atom (car srange)))
15887 (> (cdar srange) (cdr active)))
15888 (setcdr (car srange) (cdr active))))
15889 ;; Compute the number of unread articles.
15891 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
15893 (or (and (atom (car range)) (car range))
15895 (setq range (cdr range)))
15896 (setq num (max 0 (- (cdr active) num)))))
15897 ;; Set the number of unread articles.
15899 (setcar (gnus-gethash (gnus-info-group info) gnus-newsrc-hashtb) num))
15902 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
15903 ;; and compute how many unread articles there are in each group.
15904 (defun gnus-get-unread-articles (&optional level)
15905 (let* ((newsrc (cdr gnus-newsrc-alist))
15906 (level (or level gnus-activate-level (1+ gnus-level-subscribed)))
15909 (cond ((and gnus-activate-foreign-newsgroups
15910 (not (numberp gnus-activate-foreign-newsgroups)))
15911 (1+ gnus-level-subscribed))
15912 ((numberp gnus-activate-foreign-newsgroups)
15913 gnus-activate-foreign-newsgroups)
15916 info group active method)
15917 (gnus-message 5 "Checking new news...")
15920 (setq active (gnus-active (setq group (gnus-info-group
15921 (setq info (pop newsrc))))))
15923 ;; Check newsgroups. If the user doesn't want to check them, or
15924 ;; they can't be checked (for instance, if the news server can't
15925 ;; be reached) we just set the number of unread articles in this
15926 ;; newsgroup to t. This means that Gnus thinks that there are
15927 ;; unread articles, but it has no idea how many.
15928 (if (and (setq method (gnus-info-method info))
15929 (not (gnus-server-equal
15931 (setq method (gnus-server-get-method nil method))))
15932 (not (gnus-secondary-method-p method)))
15933 ;; These groups are foreign. Check the level.
15934 (when (<= (gnus-info-level info) foreign-level)
15935 (setq active (gnus-activate-group group 'scan))
15936 (unless (inline (gnus-virtual-group-p group))
15937 (inline (gnus-close-group group)))
15938 (when (fboundp (intern (concat (symbol-name (car method))
15939 "-request-update-info")))
15940 (inline (gnus-request-update-info info method))))
15941 ;; These groups are native or secondary.
15942 (when (and (<= (gnus-info-level info) level)
15943 (not gnus-read-active-file))
15944 (setq active (gnus-activate-group group 'scan))
15945 (inline (gnus-close-group group))))
15947 ;; Get the number of unread articles in the group.
15949 (inline (gnus-get-unread-articles-in-group info active))
15950 ;; The group couldn't be reached, so we nix out the number of
15951 ;; unread articles and stuff.
15952 (gnus-set-active group nil)
15953 (setcar (gnus-gethash group gnus-newsrc-hashtb) t)))
15955 (gnus-message 5 "Checking new news...done")))
15957 ;; Create a hash table out of the newsrc alist. The `car's of the
15958 ;; alist elements are used as keys.
15959 (defun gnus-make-hashtable-from-newsrc-alist ()
15960 (let ((alist gnus-newsrc-alist)
15961 (ohashtb gnus-newsrc-hashtb)
15963 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
15965 (setq prev (setq gnus-newsrc-alist
15966 (if (equal (caar gnus-newsrc-alist)
15969 (cons (list "dummy.group" 0 nil) alist)))))
15973 (cons (and ohashtb (car (gnus-gethash (caar alist) ohashtb)))
15975 gnus-newsrc-hashtb)
15977 alist (cdr alist)))))
15979 (defun gnus-make-hashtable-from-killed ()
15980 "Create a hash table from the killed and zombie lists."
15981 (let ((lists '(gnus-killed-list gnus-zombie-list))
15983 (setq gnus-killed-hashtb
15984 (gnus-make-hashtable
15985 (+ (length gnus-killed-list) (length gnus-zombie-list))))
15986 (while (setq list (pop lists))
15987 (setq list (symbol-value list))
15989 (gnus-sethash (car list) (pop list) gnus-killed-hashtb)))))
15991 (defun gnus-activate-group (group &optional scan dont-check)
15992 ;; Check whether a group has been activated or not.
15993 ;; If SCAN, request a scan of that group as well.
15994 (let ((method (gnus-find-method-for-group group))
15996 (and (gnus-check-server method)
15997 ;; We escape all bugs and quit here to make it possible to
15998 ;; continue if a group is so out-there that it reports bugs
16002 (gnus-check-backend-function 'request-scan (car method))
16003 (gnus-request-scan group method))
16006 (gnus-request-group group dont-check)
16010 (set-buffer nntp-server-buffer)
16011 (goto-char (point-min))
16012 ;; Parse the result we got from `gnus-request-group'.
16013 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
16015 (goto-char (match-beginning 1))
16017 group (setq active (cons (read (current-buffer))
16018 (read (current-buffer)))))
16019 ;; Return the new active info.
16022 (defun gnus-update-read-articles (group unread)
16023 "Update the list of read and ticked articles in GROUP using the
16024 UNREAD and TICKED lists.
16025 Note: UNSELECTED has to be sorted over `<'.
16026 Returns whether the updating was successful."
16027 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
16028 (entry (gnus-gethash group gnus-newsrc-hashtb))
16029 (info (nth 2 entry))
16031 (unread (sort (copy-sequence unread) '<))
16033 (if (or (not info) (not active))
16034 ;; There is no info on this group if it was, in fact,
16035 ;; killed. Gnus stores no information on killed groups, so
16036 ;; there's nothing to be done.
16037 ;; One could store the information somewhere temporarily,
16038 ;; perhaps... Hmmm...
16040 ;; Remove any negative articles numbers.
16041 (while (and unread (< (car unread) 0))
16042 (setq unread (cdr unread)))
16043 ;; Remove any expired article numbers
16044 (while (and unread (< (car unread) (car active)))
16045 (setq unread (cdr unread)))
16046 ;; Compute the ranges of read articles by looking at the list of
16047 ;; unread articles.
16049 (if (/= (car unread) prev)
16050 (setq read (cons (if (= prev (1- (car unread))) prev
16051 (cons prev (1- (car unread)))) read)))
16052 (setq prev (1+ (car unread)))
16053 (setq unread (cdr unread)))
16054 (when (<= prev (cdr active))
16055 (setq read (cons (cons prev (cdr active)) read)))
16056 ;; Enter this list into the group info.
16057 (gnus-info-set-read
16058 info (if (> (length read) 1) (nreverse read) read))
16059 ;; Set the number of unread articles in gnus-newsrc-hashtb.
16060 (gnus-get-unread-articles-in-group info (gnus-active group))
16063 (defun gnus-make-articles-unread (group articles)
16064 "Mark ARTICLES in GROUP as unread."
16065 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
16066 (gnus-gethash (gnus-group-real-name group)
16067 gnus-newsrc-hashtb))))
16068 (ranges (gnus-info-read info))
16071 (when (gnus-member-of-range
16072 (setq article (pop articles)) ranges)
16073 (setq news (cons article news))))
16075 (gnus-info-set-read
16076 info (gnus-remove-from-range (gnus-info-read info) (nreverse news)))
16077 (gnus-group-update-group group t))))
16079 ;; Enter all dead groups into the hashtb.
16080 (defun gnus-update-active-hashtb-from-killed ()
16081 (let ((hashtb (setq gnus-active-hashtb (make-vector 4095 0)))
16082 (lists (list gnus-killed-list gnus-zombie-list))
16085 (setq killed (car lists))
16087 (gnus-sethash (car killed) nil hashtb)
16088 (setq killed (cdr killed)))
16089 (setq lists (cdr lists)))))
16091 (defun gnus-get-killed-groups ()
16092 "Go through the active hashtb and all all unknown groups as killed."
16093 ;; First make sure active file has been read.
16094 (unless (gnus-read-active-file-p)
16095 (let ((gnus-read-active-file t))
16096 (gnus-read-active-file)))
16097 (or gnus-killed-hashtb (gnus-make-hashtable-from-killed))
16098 ;; Go through all newsgroups that are known to Gnus - enlarge kill list.
16102 (group (symbol-name sym)))
16103 (if (or (null group)
16104 (gnus-gethash group gnus-killed-hashtb)
16105 (gnus-gethash group gnus-newsrc-hashtb))
16107 (let ((do-sub (gnus-matches-options-n group)))
16108 (if (or (eq do-sub 'subscribe) (eq do-sub 'ignore))
16110 (setq groups (1+ groups))
16111 (setq gnus-killed-list
16112 (cons group gnus-killed-list))
16113 (gnus-sethash group group gnus-killed-hashtb))))))
16114 gnus-active-hashtb))
16116 ;; Get the active file(s) from the backend(s).
16117 (defun gnus-read-active-file ()
16118 (gnus-group-set-mode-line)
16121 (if (gnus-check-server gnus-select-method)
16122 ;; The native server is available.
16123 (cons gnus-select-method gnus-secondary-select-methods)
16124 ;; The native server is down, so we just do the
16126 gnus-secondary-select-methods)
16127 ;; Also read from the archive server.
16128 (when gnus-message-archive-method
16129 (list "archive"))))
16131 (setq gnus-have-read-active-file nil)
16133 (set-buffer nntp-server-buffer)
16135 (let* ((method (if (stringp (car methods))
16136 (gnus-server-get-method nil (car methods))
16138 (where (nth 1 method))
16139 (mesg (format "Reading active file%s via %s..."
16140 (if (and where (not (zerop (length where))))
16141 (concat " from " where) "")
16143 (gnus-message 5 mesg)
16144 (when (gnus-check-server method)
16145 ;; Request that the backend scan its incoming messages.
16146 (and (gnus-check-backend-function 'request-scan (car method))
16147 (gnus-request-scan nil method))
16149 ((and (eq gnus-read-active-file 'some)
16150 (gnus-check-backend-function 'retrieve-groups (car method)))
16151 (let ((newsrc (cdr gnus-newsrc-alist))
16152 (gmethod (gnus-server-get-method nil method))
16154 (while (setq info (pop newsrc))
16155 (when (gnus-server-equal
16156 (gnus-find-method-for-group
16157 (gnus-info-group info) info)
16159 (push (gnus-group-real-name (gnus-info-group info))
16162 (gnus-check-server method)
16163 (setq list-type (gnus-retrieve-groups groups method))
16167 1.2 "Cannot read partial active file from %s server."
16169 ((eq list-type 'active)
16170 (gnus-active-to-gnus-format method gnus-active-hashtb))
16172 (gnus-groups-to-gnus-format method gnus-active-hashtb))))))
16174 (if (not (gnus-request-list method))
16175 (unless (equal method gnus-message-archive-method)
16176 (gnus-error 1 "Cannot read active file from %s server."
16178 (gnus-message 5 mesg)
16179 (gnus-active-to-gnus-format method gnus-active-hashtb)
16180 ;; We mark this active file as read.
16181 (push method gnus-have-read-active-file)
16182 (gnus-message 5 "%sdone" mesg))))))
16183 (setq methods (cdr methods))))))
16185 ;; Read an active file and place the results in `gnus-active-hashtb'.
16186 (defun gnus-active-to-gnus-format (&optional method hashtb ignore-errors)
16188 (setq method gnus-select-method))
16189 (let ((cur (current-buffer))
16191 (if (and gnus-active-hashtb
16192 (not (equal method gnus-select-method)))
16194 (setq gnus-active-hashtb
16195 (if (equal method gnus-select-method)
16196 (gnus-make-hashtable
16197 (count-lines (point-min) (point-max)))
16198 (gnus-make-hashtable 4096)))))))
16199 ;; Delete unnecessary lines.
16200 (goto-char (point-min))
16201 (while (search-forward "\nto." nil t)
16202 (delete-region (1+ (match-beginning 0))
16203 (progn (forward-line 1) (point))))
16204 (or (string= gnus-ignored-newsgroups "")
16206 (goto-char (point-min))
16207 (delete-matching-lines gnus-ignored-newsgroups)))
16208 ;; Make the group names readable as a lisp expression even if they
16209 ;; contain special characters.
16210 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
16211 (goto-char (point-max))
16212 (while (re-search-backward "[][';?()#]" nil t)
16214 ;; If these are groups from a foreign select method, we insert the
16215 ;; group prefix in front of the group names.
16216 (and method (not (gnus-server-equal
16217 (gnus-server-get-method nil method)
16218 (gnus-server-get-method nil gnus-select-method)))
16219 (let ((prefix (gnus-group-prefixed-name "" method)))
16220 (goto-char (point-min))
16221 (while (and (not (eobp))
16222 (progn (insert prefix)
16223 (zerop (forward-line 1)))))))
16224 ;; Store the active file in a hash table.
16225 (goto-char (point-min))
16226 (if (string-match "%[oO]" gnus-group-line-format)
16227 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
16228 ;; If we want information on moderated groups, we use this
16230 (let* ((mod-hashtb (make-vector 7 0))
16231 (m (intern "m" mod-hashtb))
16233 (while (not (eobp))
16234 (condition-case nil
16236 (narrow-to-region (point) (gnus-point-at-eol))
16237 (setq group (let ((obarray hashtb)) (read cur)))
16238 (if (and (numberp (setq max (read cur)))
16239 (numberp (setq min (read cur)))
16241 (skip-chars-forward " \t")
16243 (or (= (following-char) ?=)
16244 (= (following-char) ?x)
16245 (= (following-char) ?j)))))
16246 (set group (cons min max))
16248 ;; Enter moderated groups into a list.
16249 (if (eq (let ((obarray mod-hashtb)) (read cur)) m)
16250 (setq gnus-moderated-list
16251 (cons (symbol-name group) gnus-moderated-list))))
16258 ;; And if we do not care about moderation, we use this loop,
16259 ;; which is faster.
16260 (let (group max min)
16261 (while (not (eobp))
16264 (narrow-to-region (point) (gnus-point-at-eol))
16265 ;; group gets set to a symbol interned in the hash table
16266 ;; (what a hack!!) - jwz
16267 (setq group (let ((obarray hashtb)) (read cur)))
16268 (if (and (numberp (setq max (read cur)))
16269 (numberp (setq min (read cur)))
16271 (skip-chars-forward " \t")
16273 (or (= (following-char) ?=)
16274 (= (following-char) ?x)
16275 (= (following-char) ?j)))))
16276 (set group (cons min max))
16284 (gnus-message 3 "Warning - illegal active: %s"
16286 (gnus-point-at-bol) (gnus-point-at-eol)))))))
16288 (forward-line 1))))))
16290 (defun gnus-groups-to-gnus-format (method &optional hashtb)
16291 ;; Parse a "groups" active file.
16292 (let ((cur (current-buffer))
16294 (if (and method gnus-active-hashtb)
16296 (setq gnus-active-hashtb
16297 (gnus-make-hashtable
16298 (count-lines (point-min) (point-max)))))))
16299 (prefix (and method
16300 (not (gnus-server-equal
16301 (gnus-server-get-method nil method)
16302 (gnus-server-get-method nil gnus-select-method)))
16303 (gnus-group-prefixed-name "" method))))
16305 (goto-char (point-min))
16306 ;; We split this into to separate loops, one with the prefix
16307 ;; and one without to speed the reading up somewhat.
16309 (let (min max opoint group)
16310 (while (not (eobp))
16313 (read cur) (read cur)
16314 (setq min (read cur)
16317 (skip-chars-forward " \t")
16320 (set (let ((obarray hashtb)) (read cur))
16322 (error (and group (symbolp group) (set group nil))))
16324 (let (min max group)
16325 (while (not (eobp))
16327 (if (= (following-char) ?2)
16329 (read cur) (read cur)
16330 (setq min (read cur)
16332 (set (setq group (let ((obarray hashtb)) (read cur)))
16334 (error (and group (symbolp group) (set group nil))))
16335 (forward-line 1))))))
16337 (defun gnus-read-newsrc-file (&optional force)
16338 "Read startup file.
16339 If FORCE is non-nil, the .newsrc file is read."
16340 ;; Reset variables that might be defined in the .newsrc.eld file.
16341 (let ((variables gnus-variable-list))
16343 (set (car variables) nil)
16344 (setq variables (cdr variables))))
16345 (let* ((newsrc-file gnus-current-startup-file)
16346 (quick-file (concat newsrc-file ".el")))
16348 ;; We always load the .newsrc.eld file. If always contains
16349 ;; much information that can not be gotten from the .newsrc
16350 ;; file (ticked articles, killed groups, foreign methods, etc.)
16351 (gnus-read-newsrc-el-file quick-file)
16353 (if (and (file-exists-p gnus-current-startup-file)
16355 (and (file-newer-than-file-p newsrc-file quick-file)
16356 (file-newer-than-file-p newsrc-file
16357 (concat quick-file "d")))
16358 (not gnus-newsrc-alist)))
16359 ;; We read the .newsrc file. Note that if there if a
16360 ;; .newsrc.eld file exists, it has already been read, and
16361 ;; the `gnus-newsrc-hashtb' has been created. While reading
16362 ;; the .newsrc file, Gnus will only use the information it
16363 ;; can find there for changing the data already read -
16364 ;; ie. reading the .newsrc file will not trash the data
16365 ;; already read (except for read articles).
16367 (gnus-message 5 "Reading %s..." newsrc-file)
16368 (set-buffer (find-file-noselect newsrc-file))
16369 (buffer-disable-undo (current-buffer))
16370 (gnus-newsrc-to-gnus-format)
16371 (kill-buffer (current-buffer))
16372 (gnus-message 5 "Reading %s...done" newsrc-file)))
16374 ;; Read any slave files.
16376 (gnus-master-read-slave-newsrc))
16378 ;; Convert old to new.
16379 (gnus-convert-old-newsrc))))
16381 (defun gnus-continuum-version (version)
16382 "Return VERSION as a floating point number."
16383 (when (or (string-match "^\\([^ ]+\\)? ?Gnus v?\\([0-9.]+\\)$" version)
16384 (string-match "^\\(.?\\)gnus-\\([0-9.]+\\)$" version))
16385 (let* ((alpha (and (match-beginning 1) (match-string 1 version)))
16386 (number (match-string 2 version))
16388 (string-match "\\([0-9]\\)\\.\\([0-9]+\\)\\.?\\([0-9]+\\)?" number)
16389 (setq major (string-to-number (match-string 1 number)))
16390 (setq minor (string-to-number (match-string 2 number)))
16391 (setq least (if (match-beginning 3)
16392 (string-to-number (match-string 3 number))
16396 (format "%s00%02d%02d"
16398 ((member alpha '("(ding)" "d")) "4.99")
16399 ((member alpha '("September" "s")) "5.01")
16400 ((member alpha '("Red" "r")) "5.03"))
16402 (format "%d.%02d%02d" major minor least))))))
16404 (defun gnus-convert-old-newsrc ()
16405 "Convert old newsrc into the new format, if needed."
16406 (let ((fcv (and gnus-newsrc-file-version
16407 (gnus-continuum-version gnus-newsrc-file-version))))
16409 ;; No .newsrc.eld file was loaded.
16411 ;; Gnus 5 .newsrc.eld was loaded.
16412 ((< fcv (gnus-continuum-version "September Gnus v0.1"))
16413 (gnus-convert-old-ticks)))))
16415 (defun gnus-convert-old-ticks ()
16416 (let ((newsrc (cdr gnus-newsrc-alist))
16417 marks info dormant ticked)
16418 (while (setq info (pop newsrc))
16419 (when (setq marks (gnus-info-marks info))
16420 (setq dormant (cdr (assq 'dormant marks))
16421 ticked (cdr (assq 'tick marks)))
16422 (when (or dormant ticked)
16423 (gnus-info-set-read
16426 (gnus-info-read info)
16427 (nconc (gnus-uncompress-range dormant)
16428 (gnus-uncompress-range ticked)))))))))
16430 (defun gnus-read-newsrc-el-file (file)
16431 (let ((ding-file (concat file "d")))
16432 ;; We always, always read the .eld file.
16433 (gnus-message 5 "Reading %s..." ding-file)
16434 (let (gnus-newsrc-assoc)
16435 (condition-case nil
16436 (load ding-file t t t)
16438 (gnus-error 1 "Error in %s" ding-file)))
16439 (when gnus-newsrc-assoc
16440 (setq gnus-newsrc-alist gnus-newsrc-assoc)))
16441 (gnus-make-hashtable-from-newsrc-alist)
16442 (when (file-newer-than-file-p file ding-file)
16443 ;; Old format quick file
16444 (gnus-message 5 "Reading %s..." file)
16445 ;; The .el file is newer than the .eld file, so we read that one
16447 (gnus-read-old-newsrc-el-file file))))
16449 ;; Parse the old-style quick startup file
16450 (defun gnus-read-old-newsrc-el-file (file)
16451 (let (newsrc killed marked group m info)
16453 (let ((gnus-killed-assoc nil)
16454 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc)
16456 (condition-case nil
16459 (setq newsrc gnus-newsrc-assoc
16460 killed gnus-killed-assoc
16461 marked gnus-marked-assoc)))
16462 (setq gnus-newsrc-alist nil)
16463 (while (setq group (pop newsrc))
16464 (if (setq info (gnus-get-info (car group)))
16466 (gnus-info-set-read info (cddr group))
16467 (gnus-info-set-level
16468 info (if (nth 1 group) gnus-level-default-subscribed
16469 gnus-level-default-unsubscribed))
16470 (setq gnus-newsrc-alist (cons info gnus-newsrc-alist)))
16473 (if (nth 1 group) gnus-level-default-subscribed
16474 gnus-level-default-unsubscribed)
16476 gnus-newsrc-alist))
16477 ;; Copy marks into info.
16478 (when (setq m (assoc (car group) marked))
16479 (unless (nthcdr 3 info)
16480 (nconc info (list nil)))
16481 (gnus-info-set-marks
16482 info (list (cons 'tick (gnus-compress-sequence
16483 (sort (cdr m) '<) t))))))
16484 (setq newsrc killed)
16486 (setcar newsrc (caar newsrc))
16487 (setq newsrc (cdr newsrc)))
16488 (setq gnus-killed-list killed))
16489 ;; The .el file version of this variable does not begin with
16490 ;; "options", while the .eld version does, so we just add it if it
16493 gnus-newsrc-options
16495 (and (not (string-match "^ *options" gnus-newsrc-options))
16496 (setq gnus-newsrc-options (concat "options " gnus-newsrc-options)))
16497 (and (not (string-match "\n$" gnus-newsrc-options))
16498 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n")))
16499 ;; Finally, if we read some options lines, we parse them.
16500 (or (string= gnus-newsrc-options "")
16501 (gnus-newsrc-parse-options gnus-newsrc-options))))
16503 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))
16504 (gnus-make-hashtable-from-newsrc-alist)))
16506 (defun gnus-make-newsrc-file (file)
16507 "Make server dependent file name by catenating FILE and server host name."
16508 (let* ((file (expand-file-name file nil))
16509 (real-file (concat file "-" (nth 1 gnus-select-method))))
16510 (if (or (file-exists-p real-file)
16511 (file-exists-p (concat real-file ".el"))
16512 (file-exists-p (concat real-file ".eld")))
16515 (defun gnus-newsrc-to-gnus-format ()
16516 (setq gnus-newsrc-options "")
16517 (setq gnus-newsrc-options-n nil)
16519 (or gnus-active-hashtb
16520 (setq gnus-active-hashtb (make-vector 4095 0)))
16521 (let ((buf (current-buffer))
16522 (already-read (> (length gnus-newsrc-alist) 1))
16523 group subscribed options-symbol newsrc Options-symbol
16525 (goto-char (point-min))
16526 ;; We intern the symbol `options' in the active hashtb so that we
16527 ;; can `eq' against it later.
16528 (set (setq options-symbol (intern "options" gnus-active-hashtb)) nil)
16529 (set (setq Options-symbol (intern "Options" gnus-active-hashtb)) nil)
16531 (while (not (eobp))
16532 ;; We first read the first word on the line by narrowing and
16533 ;; then reading into `gnus-active-hashtb'. Most groups will
16534 ;; already exist in that hashtb, so this will save some string
16538 (progn (skip-chars-forward "^ \t!:\n") (point)))
16539 (goto-char (point-min))
16541 (and (/= (point-min) (point-max))
16542 (let ((obarray gnus-active-hashtb)) (read buf))))
16544 ;; Now, the symbol we have read is either `options' or a group
16545 ;; name. If it is an options line, we just add it to a string.
16547 ((or (eq symbol options-symbol)
16548 (eq symbol Options-symbol))
16549 (setq gnus-newsrc-options
16550 ;; This concating is quite inefficient, but since our
16551 ;; thorough studies show that approx 99.37% of all
16552 ;; .newsrc files only contain a single options line, we
16553 ;; don't give a damn, frankly, my dear.
16554 (concat gnus-newsrc-options
16556 (gnus-point-at-bol)
16557 ;; Options may continue on the next line.
16558 (or (and (re-search-forward "^[^ \t]" nil 'move)
16559 (progn (beginning-of-line) (point)))
16563 ;; Group names can be just numbers.
16564 (when (numberp symbol)
16565 (setq symbol (intern (int-to-string symbol) gnus-active-hashtb)))
16566 (or (boundp symbol) (set symbol nil))
16567 ;; It was a group name.
16568 (setq subscribed (= (following-char) ?:)
16569 group (symbol-name symbol)
16572 ;; If the line ends here, this is clearly a buggy line, so
16573 ;; we put point a the beginning of line and let the cond
16574 ;; below do the error handling.
16575 (beginning-of-line)
16576 ;; We skip to the beginning of the ranges.
16577 (skip-chars-forward "!: \t"))
16578 ;; We are now at the beginning of the list of read articles.
16579 ;; We read them range by range.
16582 ((looking-at "[0-9]+")
16583 ;; We narrow and read a number instead of buffer-substring/
16584 ;; string-to-int because it's faster. narrow/widen is
16585 ;; faster than save-restriction/narrow, and save-restriction
16586 ;; produces a garbage object.
16588 (narrow-to-region (match-beginning 0) (match-end 0))
16591 ;; If the next character is a dash, then this is a range.
16592 (if (= (following-char) ?-)
16594 ;; We read the upper bound of the range.
16596 (if (not (looking-at "[0-9]+"))
16597 ;; This is a buggy line, by we pretend that
16598 ;; it's kinda OK. Perhaps the user should be
16600 (setq reads (cons num1 reads))
16605 (narrow-to-region (match-beginning 0)
16610 ;; It was just a simple number, so we add it to the
16612 (setq reads (cons num1 reads)))
16613 ;; If the next char in ?\n, then we have reached the end
16614 ;; of the line and return nil.
16615 (/= (following-char) ?\n))
16616 ((= (following-char) ?\n)
16617 ;; End of line, so we end.
16620 ;; Not numbers and not eol, so this might be a buggy
16623 ;; If it was eob instead of ?\n, we allow it.
16625 ;; The line was buggy.
16627 (gnus-error 3.1 "Mangled line: %s"
16628 (buffer-substring (gnus-point-at-bol)
16629 (gnus-point-at-eol)))))
16631 ;; Skip past ", ". Spaces are illegal in these ranges, but
16632 ;; we allow them, because it's a common mistake to put a
16633 ;; space after the comma.
16634 (skip-chars-forward ", "))
16636 ;; We have already read .newsrc.eld, so we gently update the
16637 ;; data in the hash table with the information we have just
16640 (let ((info (gnus-get-info group))
16643 ;; There is an entry for this file in the alist.
16645 (gnus-info-set-read info (nreverse reads))
16646 ;; We update the level very gently. In fact, we
16647 ;; only change it if there's been a status change
16648 ;; from subscribed to unsubscribed, or vice versa.
16649 (setq level (gnus-info-level info))
16650 (cond ((and (<= level gnus-level-subscribed)
16652 (setq level (if reads
16653 gnus-level-default-unsubscribed
16654 (1+ gnus-level-default-unsubscribed))))
16655 ((and (> level gnus-level-subscribed) subscribed)
16656 (setq level gnus-level-default-subscribed)))
16657 (gnus-info-set-level info level))
16658 ;; This is a new group.
16659 (setq info (list group
16661 gnus-level-default-subscribed
16663 (1+ gnus-level-subscribed)
16664 gnus-level-default-unsubscribed))
16665 (nreverse reads))))
16666 (setq newsrc (cons info newsrc))))))
16669 (setq newsrc (nreverse newsrc))
16671 (if (not already-read)
16673 ;; We now have two newsrc lists - `newsrc', which is what we
16674 ;; have read from .newsrc, and `gnus-newsrc-alist', which is
16675 ;; what we've read from .newsrc.eld. We have to merge these
16676 ;; lists. We do this by "attaching" any (foreign) groups in the
16677 ;; gnus-newsrc-alist to the (native) group that precedes them.
16678 (let ((rc (cdr gnus-newsrc-alist))
16679 (prev gnus-newsrc-alist)
16682 (or (null (nth 4 (car rc))) ; It's a native group.
16683 (assoc (caar rc) newsrc) ; It's already in the alist.
16684 (if (setq entry (assoc (caar prev) newsrc))
16685 (setcdr (setq mentry (memq entry newsrc))
16686 (cons (car rc) (cdr mentry)))
16687 (setq newsrc (cons (car rc) newsrc))))
16691 (setq gnus-newsrc-alist newsrc)
16692 ;; We make the newsrc hashtb.
16693 (gnus-make-hashtable-from-newsrc-alist)
16695 ;; Finally, if we read some options lines, we parse them.
16696 (or (string= gnus-newsrc-options "")
16697 (gnus-newsrc-parse-options gnus-newsrc-options))))
16699 ;; Parse options lines to find "options -n !all rec.all" and stuff.
16700 ;; The return value will be a list on the form
16701 ;; ((regexp1 . ignore)
16702 ;; (regexp2 . subscribe)...)
16703 ;; When handling new newsgroups, groups that match a `ignore' regexp
16704 ;; will be ignored, and groups that match a `subscribe' regexp will be
16705 ;; subscribed. A line like
16706 ;; options -n !all rec.all
16707 ;; will lead to a list that looks like
16708 ;; (("^rec\\..+" . subscribe)
16709 ;; ("^.+" . ignore))
16710 ;; So all "rec.*" groups will be subscribed, while all the other
16711 ;; groups will be ignored. Note that "options -n !all rec.all" is very
16712 ;; different from "options -n rec.all !all".
16713 (defun gnus-newsrc-parse-options (options)
16716 (gnus-set-work-buffer)
16717 (insert (regexp-quote options))
16718 ;; First we treat all continuation lines.
16719 (goto-char (point-min))
16720 (while (re-search-forward "\n[ \t]+" nil t)
16721 (replace-match " " t t))
16722 ;; Then we transform all "all"s into ".+"s.
16723 (goto-char (point-min))
16724 (while (re-search-forward "\\ball\\b" nil t)
16725 (replace-match ".+" t t))
16726 (goto-char (point-min))
16727 ;; We remove all other options than the "-n" ones.
16728 (while (re-search-forward "[ \t]-[^n][^-]*" nil t)
16729 (replace-match " ")
16731 (goto-char (point-min))
16733 ;; We are only interested in "options -n" lines - we
16734 ;; ignore the other option lines.
16735 (while (re-search-forward "[ \t]-n" nil t)
16737 (or (save-excursion
16738 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t)
16740 (gnus-point-at-eol)))
16741 ;; Search for all "words"...
16742 (while (re-search-forward "[^ \t,\n]+" eol t)
16743 (if (= (char-after (match-beginning 0)) ?!)
16744 ;; If the word begins with a bang (!), this is a "not"
16745 ;; spec. We put this spec (minus the bang) and the
16746 ;; symbol `ignore' into the list.
16747 (setq out (cons (cons (concat
16748 "^" (buffer-substring
16749 (1+ (match-beginning 0))
16752 ;; There was no bang, so this is a "yes" spec.
16753 (setq out (cons (cons (concat "^" (match-string 0))
16754 'subscribe) out)))))
16756 (setq gnus-newsrc-options-n out))))
16758 (defun gnus-save-newsrc-file (&optional force)
16759 "Save .newsrc file."
16760 ;; Note: We cannot save .newsrc file if all newsgroups are removed
16761 ;; from the variable gnus-newsrc-alist.
16762 (when (and (or gnus-newsrc-alist gnus-killed-list)
16763 gnus-current-startup-file)
16765 (if (and (or gnus-use-dribble-file gnus-slave)
16767 (or (not gnus-dribble-buffer)
16768 (not (buffer-name gnus-dribble-buffer))
16769 (zerop (save-excursion
16770 (set-buffer gnus-dribble-buffer)
16772 (gnus-message 4 "(No changes need to be saved)")
16773 (run-hooks 'gnus-save-newsrc-hook)
16775 (gnus-slave-save-newsrc)
16777 (when gnus-save-newsrc-file
16778 (gnus-message 5 "Saving %s..." gnus-current-startup-file)
16779 (gnus-gnus-to-newsrc-format)
16780 (gnus-message 5 "Saving %s...done" gnus-current-startup-file))
16781 ;; Save .newsrc.eld.
16782 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
16783 (make-local-variable 'version-control)
16784 (setq version-control 'never)
16785 (setq buffer-file-name
16786 (concat gnus-current-startup-file ".eld"))
16787 (setq default-directory (file-name-directory buffer-file-name))
16788 (gnus-add-current-to-buffer-list)
16789 (buffer-disable-undo (current-buffer))
16791 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file)
16792 (gnus-gnus-to-quick-newsrc-format)
16793 (run-hooks 'gnus-save-quick-newsrc-hook)
16795 (kill-buffer (current-buffer))
16797 5 "Saving %s.eld...done" gnus-current-startup-file))
16798 (gnus-dribble-delete-file)
16799 (gnus-group-set-mode-line)))))
16801 (defun gnus-gnus-to-quick-newsrc-format ()
16802 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
16803 (insert ";; Gnus startup file.\n")
16804 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
16805 (insert ";; to read .newsrc.\n")
16806 (insert "(setq gnus-newsrc-file-version "
16807 (prin1-to-string gnus-version) ")\n")
16809 (if gnus-save-killed-list gnus-variable-list
16810 ;; Remove the `gnus-killed-list' from the list of variables
16811 ;; to be saved, if required.
16812 (delq 'gnus-killed-list (copy-sequence gnus-variable-list))))
16813 ;; Peel off the "dummy" group.
16814 (gnus-newsrc-alist (cdr gnus-newsrc-alist))
16816 ;; Insert the variables into the file.
16818 (when (and (boundp (setq variable (pop variables)))
16819 (symbol-value variable))
16820 (insert "(setq " (symbol-name variable) " '")
16821 (prin1 (symbol-value variable) (current-buffer))
16824 (defun gnus-gnus-to-newsrc-format ()
16825 ;; Generate and save the .newsrc file.
16827 (set-buffer (create-file-buffer gnus-current-startup-file))
16828 (let ((newsrc (cdr gnus-newsrc-alist))
16829 (standard-output (current-buffer))
16830 info ranges range method)
16831 (setq buffer-file-name gnus-current-startup-file)
16832 (setq default-directory (file-name-directory buffer-file-name))
16833 (buffer-disable-undo (current-buffer))
16836 (if gnus-newsrc-options (insert gnus-newsrc-options))
16837 ;; Write subscribed and unsubscribed.
16838 (while (setq info (pop newsrc))
16839 ;; Don't write foreign groups to .newsrc.
16840 (when (or (null (setq method (gnus-info-method info)))
16841 (equal method "native")
16842 (gnus-server-equal method gnus-select-method))
16843 (insert (gnus-info-group info)
16844 (if (> (gnus-info-level info) gnus-level-subscribed)
16846 (when (setq ranges (gnus-info-read info))
16848 (if (not (listp (cdr ranges)))
16849 (if (= (car ranges) (cdr ranges))
16850 (princ (car ranges))
16851 (princ (car ranges))
16853 (princ (cdr ranges)))
16854 (while (setq range (pop ranges))
16855 (if (or (atom range) (= (car range) (cdr range)))
16856 (princ (or (and (atom range) range) (car range)))
16857 (princ (car range))
16859 (princ (cdr range)))
16860 (if ranges (insert ",")))))
16862 (make-local-variable 'version-control)
16863 (setq version-control 'never)
16864 ;; It has been reported that sometime the modtime on the .newsrc
16865 ;; file seems to be off. We really do want to overwrite it, so
16866 ;; we clear the modtime here before saving. It's a bit odd,
16868 ;; sometimes the modtime clear isn't sufficient. most brute force:
16869 ;; delete the silly thing entirely first. but this fails to provide
16870 ;; such niceties as .newsrc~ creation.
16871 (if gnus-modtime-botch
16872 (delete-file gnus-startup-file)
16873 (clear-visited-file-modtime))
16874 (run-hooks 'gnus-save-standard-newsrc-hook)
16876 (kill-buffer (current-buffer)))))
16880 ;;; Slave functions.
16883 (defun gnus-slave-save-newsrc ()
16885 (set-buffer gnus-dribble-buffer)
16887 (make-temp-name (concat gnus-current-startup-file "-slave-"))))
16888 (write-region (point-min) (point-max) slave-name nil 'nomesg))))
16890 (defun gnus-master-read-slave-newsrc ()
16893 (file-name-directory gnus-current-startup-file)
16897 (file-name-nondirectory gnus-current-startup-file)
16901 (if (not slave-files)
16902 () ; There are no slave files to read.
16903 (gnus-message 7 "Reading slave newsrcs...")
16905 (set-buffer (get-buffer-create " *gnus slave*"))
16906 (buffer-disable-undo (current-buffer))
16908 (sort (mapcar (lambda (file)
16909 (list (nth 5 (file-attributes file)) file))
16912 (or (< (caar f1) (caar f2))
16913 (< (nth 1 (car f1)) (nth 1 (car f2)))))))
16916 (setq file (nth 1 (car slave-files)))
16917 (insert-file-contents file)
16918 (if (condition-case ()
16920 (eval-buffer (current-buffer))
16923 (gnus-error 3.2 "Possible error in %s" file)
16925 (or gnus-slave ; Slaves shouldn't delete these files.
16929 (setq slave-files (cdr slave-files))))
16930 (gnus-message 7 "Reading slave newsrcs...done"))))
16934 ;;; Group description.
16937 (defun gnus-read-all-descriptions-files ()
16938 (let ((methods (cons gnus-select-method
16940 (when gnus-message-archive-method
16942 gnus-secondary-select-methods))))
16944 (gnus-read-descriptions-file (car methods))
16945 (setq methods (cdr methods)))
16948 (defun gnus-read-descriptions-file (&optional method)
16949 (let ((method (or method gnus-select-method)))
16950 (when (stringp method)
16951 (setq method (gnus-server-to-method method)))
16952 ;; We create the hashtable whether we manage to read the desc file
16953 ;; to avoid trying to re-read after a failed read.
16954 (or gnus-description-hashtb
16955 (setq gnus-description-hashtb
16956 (gnus-make-hashtable (length gnus-active-hashtb))))
16957 ;; Mark this method's desc file as read.
16958 (gnus-sethash (gnus-group-prefixed-name "" method) "Has read"
16959 gnus-description-hashtb)
16961 (gnus-message 5 "Reading descriptions file via %s..." (car method))
16963 ((not (gnus-check-server method))
16964 (gnus-message 1 "Couldn't open server")
16966 ((not (gnus-request-list-newsgroups method))
16967 (gnus-message 1 "Couldn't read newsgroups descriptions")
16973 (set-buffer nntp-server-buffer)
16974 (goto-char (point-min))
16975 (if (or (search-forward "\n.\n" nil t)
16976 (goto-char (point-max)))
16978 (beginning-of-line)
16979 (narrow-to-region (point-min) (point))))
16980 (goto-char (point-min))
16981 (while (not (eobp))
16982 ;; If we get an error, we set group to 0, which is not a
16986 (let ((obarray gnus-description-hashtb))
16987 ;; Group is set to a symbol interned in this
16989 (read nntp-server-buffer))
16991 (skip-chars-forward " \t")
16992 ;; ... which leads to this line being effectively ignored.
16993 (and (symbolp group)
16994 (set group (buffer-substring
16995 (point) (progn (end-of-line) (point)))))
16996 (forward-line 1))))
16997 (gnus-message 5 "Reading descriptions file...done")
17000 (defun gnus-group-get-description (group)
17001 "Get the description of a group by sending XGTITLE to the server."
17002 (when (gnus-request-group-description group)
17004 (set-buffer nntp-server-buffer)
17005 (goto-char (point-min))
17006 (when (looking-at "[^ \t]+[ \t]+\\(.*\\)")
17007 (match-string 1)))))
17011 ;;; Buffering of read articles.
17014 (defvar gnus-backlog-buffer " *Gnus Backlog*")
17015 (defvar gnus-backlog-articles nil)
17016 (defvar gnus-backlog-hashtb nil)
17018 (defun gnus-backlog-buffer ()
17019 "Return the backlog buffer."
17020 (or (get-buffer gnus-backlog-buffer)
17022 (set-buffer (get-buffer-create gnus-backlog-buffer))
17023 (buffer-disable-undo (current-buffer))
17024 (setq buffer-read-only t)
17025 (gnus-add-current-to-buffer-list)
17026 (get-buffer gnus-backlog-buffer))))
17028 (defun gnus-backlog-setup ()
17029 "Initialize backlog variables."
17030 (unless gnus-backlog-hashtb
17031 (setq gnus-backlog-hashtb (make-vector 1023 0))))
17033 (gnus-add-shutdown 'gnus-backlog-shutdown 'gnus)
17035 (defun gnus-backlog-shutdown ()
17036 "Clear all backlog variables and buffers."
17037 (when (get-buffer gnus-backlog-buffer)
17038 (kill-buffer gnus-backlog-buffer))
17039 (setq gnus-backlog-hashtb nil
17040 gnus-backlog-articles nil))
17042 (defun gnus-backlog-enter-article (group number buffer)
17043 (gnus-backlog-setup)
17044 (let ((ident (intern (concat group ":" (int-to-string number))
17045 gnus-backlog-hashtb))
17047 (if (memq ident gnus-backlog-articles)
17048 () ; It's already kept.
17049 ;; Remove the oldest article, if necessary.
17050 (and (numberp gnus-keep-backlog)
17051 (>= (length gnus-backlog-articles) gnus-keep-backlog)
17052 (gnus-backlog-remove-oldest-article))
17053 (setq gnus-backlog-articles (cons ident gnus-backlog-articles))
17054 ;; Insert the new article.
17056 (set-buffer (gnus-backlog-buffer))
17057 (let (buffer-read-only)
17058 (goto-char (point-max))
17059 (or (bolp) (insert "\n"))
17061 (insert-buffer-substring buffer)
17062 ;; Tag the beginning of the article with the ident.
17063 (gnus-put-text-property b (1+ b) 'gnus-backlog ident))))))
17065 (defun gnus-backlog-remove-oldest-article ()
17067 (set-buffer (gnus-backlog-buffer))
17068 (goto-char (point-min))
17069 (if (zerop (buffer-size))
17070 () ; The buffer is empty.
17071 (let ((ident (get-text-property (point) 'gnus-backlog))
17073 ;; Remove the ident from the list of articles.
17075 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
17076 ;; Delete the article itself.
17078 (point) (next-single-property-change
17079 (1+ (point)) 'gnus-backlog nil (point-max)))))))
17081 (defun gnus-backlog-remove-article (group number)
17082 "Remove article NUMBER in GROUP from the backlog."
17083 (when (numberp number)
17084 (gnus-backlog-setup)
17085 (let ((ident (intern (concat group ":" (int-to-string number))
17086 gnus-backlog-hashtb))
17088 (when (memq ident gnus-backlog-articles)
17089 ;; It was in the backlog.
17091 (set-buffer (gnus-backlog-buffer))
17092 (let (buffer-read-only)
17093 (when (setq beg (text-property-any
17094 (point-min) (point-max) 'gnus-backlog
17096 ;; Find the end (i. e., the beginning of the next article).
17098 (next-single-property-change
17099 (1+ beg) 'gnus-backlog (current-buffer) (point-max)))
17100 (delete-region beg end)
17104 (defun gnus-backlog-request-article (group number buffer)
17105 (when (numberp number)
17106 (gnus-backlog-setup)
17107 (let ((ident (intern (concat group ":" (int-to-string number))
17108 gnus-backlog-hashtb))
17110 (when (memq ident gnus-backlog-articles)
17111 ;; It was in the backlog.
17113 (set-buffer (gnus-backlog-buffer))
17114 (if (not (setq beg (text-property-any
17115 (point-min) (point-max) 'gnus-backlog
17117 ;; It wasn't in the backlog after all.
17119 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
17120 ;; Find the end (i. e., the beginning of the next article).
17122 (next-single-property-change
17123 (1+ beg) 'gnus-backlog (current-buffer) (point-max)))))
17124 (let ((buffer-read-only nil))
17126 (insert-buffer-substring gnus-backlog-buffer beg end)
17129 ;; Allow redefinition of Gnus functions.
17131 (gnus-ems-redefine)
17135 ;;; gnus.el ends here