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 Note that the default for this variable varies according to what system
289 type you're using. On `usg-unix-v' and `xenix' this variable defaults
290 to nil while on all other systems it defaults to t.")
292 (defvar gnus-article-save-directory gnus-directory
293 "*Name of the directory articles will be saved in (default \"~/News\").")
295 (defvar gnus-kill-files-directory gnus-directory
296 "*Name of the directory where kill files will be stored (default \"~/News\").")
298 (defvar gnus-default-article-saver 'gnus-summary-save-in-rmail
299 "*A function to save articles in your favorite format.
300 The function must be interactively callable (in other words, it must
301 be an Emacs command).
303 Gnus provides the following functions:
305 * gnus-summary-save-in-rmail (Rmail format)
306 * gnus-summary-save-in-mail (Unix mail format)
307 * gnus-summary-save-in-folder (MH folder)
308 * gnus-summary-save-in-file (article format).
309 * gnus-summary-save-in-vm (use VM's folder format).")
311 (defvar gnus-prompt-before-saving 'always
312 "*This variable says how much prompting is to be done when saving articles.
313 If it is nil, no prompting will be done, and the articles will be
314 saved to the default files. If this variable is `always', each and
315 every article that is saved will be preceded by a prompt, even when
316 saving large batches of articles. If this variable is neither nil not
317 `always', there the user will be prompted once for a file name for
318 each invocation of the saving commands.")
320 (defvar gnus-rmail-save-name (function gnus-plain-save-name)
321 "*A function generating a file name to save articles in Rmail format.
322 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
324 (defvar gnus-mail-save-name (function gnus-plain-save-name)
325 "*A function generating a file name to save articles in Unix mail format.
326 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
328 (defvar gnus-folder-save-name (function gnus-folder-save-name)
329 "*A function generating a file name to save articles in MH folder.
330 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER.")
332 (defvar gnus-file-save-name (function gnus-numeric-save-name)
333 "*A function generating a file name to save articles in article format.
334 The function is called with NEWSGROUP, HEADERS, and optional
337 (defvar gnus-split-methods
338 '((gnus-article-archive-name))
339 "*Variable used to suggest where articles are to be saved.
340 For instance, if you would like to save articles related to Gnus in
341 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
342 you could set this variable to something like:
344 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
345 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
347 This variable is an alist where the where the key is the match and the
348 value is a list of possible files to save in if the match is non-nil.
350 If the match is a string, it is used as a regexp match on the
351 article. If the match is a symbol, that symbol will be funcalled
352 from the buffer of the article to be saved with the newsgroup as the
353 parameter. If it is a list, it will be evaled in the same buffer.
355 If this form or function returns a string, this string will be used as
356 a possible file name; and if it returns a non-nil list, that list will
357 be used as possible file names.")
359 (defvar gnus-move-split-methods nil
360 "*Variable used to suggest where articles are to be moved to.
361 It uses the same syntax as the `gnus-split-methods' variable.")
363 (defvar gnus-save-score nil
364 "*If non-nil, save group scoring info.")
366 (defvar gnus-use-adaptive-scoring nil
367 "*If non-nil, use some adaptive scoring scheme.")
369 (defvar gnus-use-cache 'passive
370 "*If nil, Gnus will ignore the article cache.
371 If `passive', it will allow entering (and reading) articles
372 explicitly entered into the cache. If anything else, use the
373 cache to the full extent of the law.")
375 (defvar gnus-use-trees nil
376 "*If non-nil, display a thread tree buffer.")
378 (defvar gnus-use-grouplens nil
379 "*If non-nil, use GroupLens ratings.")
381 (defvar gnus-keep-backlog nil
382 "*If non-nil, Gnus will keep read articles for later re-retrieval.
383 If it is a number N, then Gnus will only keep the last N articles
384 read. If it is neither nil nor a number, Gnus will keep all read
385 articles. This is not a good idea.")
387 (defvar gnus-use-nocem nil
388 "*If non-nil, Gnus will read NoCeM cancel messages.")
390 (defvar gnus-use-demon nil
391 "If non-nil, Gnus might use some demons.")
393 (defvar gnus-use-scoring t
394 "*If non-nil, enable scoring.")
396 (defvar gnus-use-picons nil
397 "*If non-nil, display picons.")
399 (defvar gnus-fetch-old-headers nil
400 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
401 If an unread article in the group refers to an older, already read (or
402 just marked as read) article, the old article will not normally be
403 displayed in the Summary buffer. If this variable is non-nil, Gnus
404 will attempt to grab the headers to the old articles, and thereby
405 build complete threads. If it has the value `some', only enough
406 headers to connect otherwise loose threads will be displayed.
407 This variable can also be a number. In that case, no more than that
408 number of old headers will be fetched.
410 The server has to support NOV for any of this to work.")
413 ;(defvar gnus-visual t
414 ; "*If non-nil, will do various highlighting.
415 ;If nil, no mouse highlights (or any other highlights) will be
416 ;performed. This might speed up Gnus some when generating large group
417 ;and summary buffers.")
419 (defvar gnus-novice-user t
420 "*Non-nil means that you are a usenet novice.
421 If non-nil, verbose messages may be displayed and confirmations may be
424 (defvar gnus-expert-user nil
425 "*Non-nil means that you will never be asked for confirmation about anything.
426 And that means *anything*.")
428 (defvar gnus-verbose 7
429 "*Integer that says how verbose Gnus should be.
430 The higher the number, the more messages Gnus will flash to say what
431 it's doing. At zero, Gnus will be totally mute; at five, Gnus will
432 display most important messages; and at ten, Gnus will keep on
433 jabbering all the time.")
435 (defvar gnus-keep-same-level nil
436 "*Non-nil means that the next newsgroup after the current will be on the same level.
437 When you type, for instance, `n' after reading the last article in the
438 current newsgroup, you will go to the next newsgroup. If this variable
439 is nil, the next newsgroup will be the next from the group
441 If this variable is non-nil, Gnus will either put you in the
442 next newsgroup with the same level, or, if no such newsgroup is
443 available, the next newsgroup with the lowest possible level higher
444 than the current level.
445 If this variable is `best', Gnus will make the next newsgroup the one
446 with the best level.")
448 (defvar gnus-summary-make-false-root 'adopt
449 "*nil means that Gnus won't gather loose threads.
450 If the root of a thread has expired or been read in a previous
451 session, the information necessary to build a complete thread has been
452 lost. Instead of having many small sub-threads from this original thread
453 scattered all over the summary buffer, Gnus can gather them.
455 If non-nil, Gnus will try to gather all loose sub-threads from an
456 original thread into one large thread.
458 If this variable is non-nil, it should be one of `none', `adopt',
461 If this variable is `none', Gnus will not make a false root, but just
462 present the sub-threads after another.
463 If this variable is `dummy', Gnus will create a dummy root that will
464 have all the sub-threads as children.
465 If this variable is `adopt', Gnus will make one of the \"children\"
466 the parent and mark all the step-children as such.
467 If this variable is `empty', the \"children\" are printed with empty
468 subject fields. (Or rather, they will be printed with a string
469 given by the `gnus-summary-same-subject' variable.)")
471 (defvar gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
472 "*A regexp to match subjects to be excluded from loose thread gathering.
473 As loose thread gathering is done on subjects only, that means that
474 there can be many false gatherings performed. By rooting out certain
475 common subjects, gathering might become saner.")
477 (defvar gnus-summary-gather-subject-limit nil
478 "*Maximum length of subject comparisons when gathering loose threads.
479 Use nil to compare full subjects. Setting this variable to a low
480 number will help gather threads that have been corrupted by
481 newsreaders chopping off subject lines, but it might also mean that
482 unrelated articles that have subject that happen to begin with the
483 same few characters will be incorrectly gathered.
485 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
486 comparing subjects.")
488 (defvar gnus-simplify-ignored-prefixes nil
489 "*Regexp, matches for which are removed from subject lines when simplifying.")
491 (defvar gnus-build-sparse-threads nil
492 "*If non-nil, fill in the gaps in threads.
493 If `some', only fill in the gaps that are needed to tie loose threads
494 together. If `more', fill in all leaf nodes that Gnus can find. If
495 non-nil and non-`some', fill in all gaps that Gnus manages to guess.")
497 (defvar gnus-summary-thread-gathering-function 'gnus-gather-threads-by-subject
498 "Function used for gathering loose threads.
499 There are two pre-defined functions: `gnus-gather-threads-by-subject',
500 which only takes Subjects into consideration; and
501 `gnus-gather-threads-by-references', which compared the References
502 headers of the articles to find matches.")
504 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
505 (defvar gnus-summary-same-subject ""
506 "*String indicating that the current article has the same subject as the previous.
507 This variable will only be used if the value of
508 `gnus-summary-make-false-root' is `empty'.")
510 (defvar gnus-summary-goto-unread t
511 "*If non-nil, marking commands will go to the next unread article.
512 If `never', \\<gnus-summary-mode-map>\\[gnus-summary-next-page] will go to the next article,
513 whether it is read or not.")
515 (defvar gnus-group-goto-unread t
516 "*If non-nil, movement commands will go to the next unread and subscribed group.")
518 (defvar gnus-goto-next-group-when-activating t
519 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group.")
521 (defvar gnus-check-new-newsgroups t
522 "*Non-nil means that Gnus will add new newsgroups at startup.
523 If this variable is `ask-server', Gnus will ask the server for new
524 groups since the last time it checked. This means that the killed list
525 is no longer necessary, so you could set `gnus-save-killed-list' to
528 A variant is to have this variable be a list of select methods. Gnus
529 will then use the `ask-server' method on all these select methods to
530 query for new groups from all those servers.
533 (setq gnus-check-new-newsgroups
534 '((nntp \"some.server\") (nntp \"other.server\")))
536 If this variable is nil, then you have to tell Gnus explicitly to
537 check for new newsgroups with \\<gnus-group-mode-map>\\[gnus-find-new-newsgroups].")
539 (defvar gnus-check-bogus-newsgroups nil
540 "*Non-nil means that Gnus will check and remove bogus newsgroup at startup.
541 If this variable is nil, then you have to tell Gnus explicitly to
542 check for bogus newsgroups with \\<gnus-group-mode-map>\\[gnus-group-check-bogus-groups].")
544 (defvar gnus-read-active-file t
545 "*Non-nil means that Gnus will read the entire active file at startup.
546 If this variable is nil, Gnus will only know about the groups in your
549 If this variable is `some', Gnus will try to only read the relevant
550 parts of the active file from the server. Not all servers support
551 this, and it might be quite slow with other servers, but this should
552 generally be faster than both the t and nil value.
554 If you set this variable to nil or `some', you probably still want to
555 be told about new newsgroups that arrive. To do that, set
556 `gnus-check-new-newsgroups' to `ask-server'. This may not work
557 properly with all servers.")
559 (defvar gnus-level-subscribed 5
560 "*Groups with levels less than or equal to this variable are subscribed.")
562 (defvar gnus-level-unsubscribed 7
563 "*Groups with levels less than or equal to this variable are unsubscribed.
564 Groups with levels less than `gnus-level-subscribed', which should be
565 less than this variable, are subscribed.")
567 (defvar gnus-level-zombie 8
568 "*Groups with this level are zombie groups.")
570 (defvar gnus-level-killed 9
571 "*Groups with this level are killed.")
573 (defvar gnus-level-default-subscribed 3
574 "*New subscribed groups will be subscribed at this level.")
576 (defvar gnus-level-default-unsubscribed 6
577 "*New unsubscribed groups will be unsubscribed at this level.")
579 (defvar gnus-activate-level (1+ gnus-level-subscribed)
580 "*Groups higher than this level won't be activated on startup.
581 Setting this variable to something log might save lots of time when
582 you have many groups that you aren't interested in.")
584 (defvar gnus-activate-foreign-newsgroups 4
585 "*If nil, Gnus will not check foreign newsgroups at startup.
586 If it is non-nil, it should be a number between one and nine. Foreign
587 newsgroups that have a level lower or equal to this number will be
588 activated on startup. For instance, if you want to active all
589 subscribed newsgroups, but not the rest, you'd set this variable to
590 `gnus-level-subscribed'.
592 If you subscribe to lots of newsgroups from different servers, startup
593 might take a while. By setting this variable to nil, you'll save time,
594 but you won't be told how many unread articles there are in the
597 (defvar gnus-save-newsrc-file t
598 "*Non-nil means that Gnus will save the `.newsrc' file.
599 Gnus always saves its own startup file, which is called
600 \".newsrc.eld\". The file called \".newsrc\" is in a format that can
601 be readily understood by other newsreaders. If you don't plan on
602 using other newsreaders, set this variable to nil to save some time on
605 (defvar gnus-save-killed-list t
606 "*If non-nil, save the list of killed groups to the startup file.
607 If you set this variable to nil, you'll save both time (when starting
608 and quitting) and space (both memory and disk), but it will also mean
609 that Gnus has no record of which groups are new and which are old, so
610 the automatic new newsgroups subscription methods become meaningless.
612 You should always set `gnus-check-new-newsgroups' to `ask-server' or
613 nil if you set this variable to nil.")
615 (defvar gnus-interactive-catchup t
616 "*If non-nil, require your confirmation when catching up a group.")
618 (defvar gnus-interactive-exit t
619 "*If non-nil, require your confirmation when exiting Gnus.")
621 (defvar gnus-kill-killed t
622 "*If non-nil, Gnus will apply kill files to already killed articles.
623 If it is nil, Gnus will never apply kill files to articles that have
624 already been through the scoring process, which might very well save lots
627 (defvar gnus-extract-address-components 'gnus-extract-address-components
628 "*Function for extracting address components from a From header.
629 Two pre-defined function exist: `gnus-extract-address-components',
630 which is the default, quite fast, and too simplistic solution, and
631 `mail-extract-address-components', which works much better, but is
634 (defvar gnus-summary-default-score 0
635 "*Default article score level.
636 If this variable is nil, scoring will be disabled.")
638 (defvar gnus-summary-zcore-fuzz 0
639 "*Fuzziness factor for the zcore in the summary buffer.
640 Articles with scores closer than this to `gnus-summary-default-score'
641 will not be marked.")
643 (defvar gnus-simplify-subject-fuzzy-regexp nil
644 "*Strings to be removed when doing fuzzy matches.
645 This can either be a regular expression or list of regular expressions
646 that will be removed from subject strings if fuzzy subject
647 simplification is selected.")
649 (defvar gnus-permanently-visible-groups nil
650 "*Regexp to match groups that should always be listed in the group buffer.
651 This means that they will still be listed when there are no unread
652 articles in the groups.")
654 (defvar gnus-list-groups-with-ticked-articles t
655 "*If non-nil, list groups that have only ticked articles.
656 If nil, only list groups that have unread articles.")
658 (defvar gnus-group-default-list-level gnus-level-subscribed
659 "*Default listing level.
660 Ignored if `gnus-group-use-permanent-levels' is non-nil.")
662 (defvar gnus-group-use-permanent-levels nil
663 "*If non-nil, once you set a level, Gnus will use this level.")
665 (defvar gnus-group-list-inactive-groups t
666 "*If non-nil, inactive groups will be listed.")
668 (defvar gnus-show-mime nil
669 "*If non-nil, do mime processing of articles.
670 The articles will simply be fed to the function given by
671 `gnus-show-mime-method'.")
673 (defvar gnus-strict-mime t
674 "*If nil, MIME-decode even if there is no Mime-Version header in the article.")
676 (defvar gnus-show-mime-method 'metamail-buffer
677 "*Function to process a MIME message.
678 The function is called from the article buffer.")
680 (defvar gnus-decode-encoded-word-method (lambda ())
681 "*Function to decode a MIME encoded-words.
682 The function is called from the article buffer.")
684 (defvar gnus-show-threads t
685 "*If non-nil, display threads in summary mode.")
687 (defvar gnus-thread-hide-subtree nil
688 "*If non-nil, hide all threads initially.
689 If threads are hidden, you have to run the command
690 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
691 to expose hidden threads.")
693 (defvar gnus-thread-hide-killed t
694 "*If non-nil, hide killed threads automatically.")
696 (defvar gnus-thread-ignore-subject nil
697 "*If non-nil, ignore subjects and do all threading based on the Reference header.
698 If nil, which is the default, articles that have different subjects
699 from their parents will start separate threads.")
701 (defvar gnus-thread-operation-ignore-subject t
702 "*If non-nil, subjects will be ignored when doing thread commands.
703 This affects commands like `gnus-summary-kill-thread' and
704 `gnus-summary-lower-thread'.
706 If this variable is nil, articles in the same thread with different
707 subjects will not be included in the operation in question. If this
708 variable is `fuzzy', only articles that have subjects that are fuzzily
709 equal will be included.")
711 (defvar gnus-thread-indent-level 4
712 "*Number that says how much each sub-thread should be indented.")
714 (defvar gnus-ignored-newsgroups
715 (purecopy (mapconcat 'identity
716 '("^to\\." ; not "real" groups
717 "^[0-9. \t]+ " ; all digits in name
718 "[][\"#'()]" ; bogus characters
721 "*A regexp to match uninteresting newsgroups in the active file.
722 Any lines in the active file matching this regular expression are
723 removed from the newsgroup list before anything else is done to it,
724 thus making them effectively non-existent.")
726 (defvar gnus-ignored-headers
727 "^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:"
728 "*All headers that match this regexp will be hidden.
729 This variable can also be a list of regexps of headers to be ignored.
730 If `gnus-visible-headers' is non-nil, this variable will be ignored.")
732 (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-"
733 "*All headers that do not match this regexp will be hidden.
734 This variable can also be a list of regexp of headers to remain visible.
735 If this variable is non-nil, `gnus-ignored-headers' will be ignored.")
737 (defvar gnus-sorted-header-list
738 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^To:"
739 "^Cc:" "^Date:" "^Organization:")
740 "*This variable is a list of regular expressions.
741 If it is non-nil, headers that match the regular expressions will
742 be placed first in the article buffer in the sequence specified by
745 (defvar gnus-boring-article-headers
746 '(empty followup-to reply-to)
747 "*Headers that are only to be displayed if they have interesting data.
748 Possible values in this list are `empty', `newsgroups', `followup-to',
749 `reply-to', and `date'.")
751 (defvar gnus-show-all-headers nil
752 "*If non-nil, don't hide any headers.")
754 (defvar gnus-save-all-headers t
755 "*If non-nil, don't remove any headers before saving.")
757 (defvar gnus-saved-headers gnus-visible-headers
758 "*Headers to keep if `gnus-save-all-headers' is nil.
759 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
760 If that variable is nil, however, all headers that match this regexp
761 will be kept while the rest will be deleted before saving.")
763 (defvar gnus-inhibit-startup-message nil
764 "*If non-nil, the startup message will not be displayed.")
766 (defvar gnus-signature-separator "^-- *$"
767 "Regexp matching signature separator.")
769 (defvar gnus-signature-limit nil
770 "Provide a limit to what is considered a signature.
771 If it is a number, no signature may not be longer (in characters) than
772 that number. If it is a function, the function will be called without
773 any parameters, and if it returns nil, there is no signature in the
774 buffer. If it is a string, it will be used as a regexp. If it
775 matches, the text in question is not a signature.")
777 (defvar gnus-auto-extend-newsgroup t
778 "*If non-nil, extend newsgroup forward and backward when requested.")
780 (defvar gnus-auto-select-first t
781 "*If nil, don't select the first unread article when entering a group.
782 If this variable is `best', select the highest-scored unread article
783 in the group. If neither nil nor `best', select the first unread
786 If you want to prevent automatic selection of the first unread article
787 in some newsgroups, set the variable to nil in
788 `gnus-select-group-hook'.")
790 (defvar gnus-auto-select-next t
791 "*If non-nil, offer to go to the next group from the end of the previous.
792 If the value is t and the next newsgroup is empty, Gnus will exit
793 summary mode and go back to group mode. If the value is neither nil
794 nor t, Gnus will select the following unread newsgroup. In
795 particular, if the value is the symbol `quietly', the next unread
796 newsgroup will be selected without any confirmation, and if it is
797 `almost-quietly', the next group will be selected without any
798 confirmation if you are located on the last article in the group.
799 Finally, if this variable is `slightly-quietly', the `Z n' command
800 will go to the next group without confirmation.")
802 (defvar gnus-auto-select-same nil
803 "*If non-nil, select the next article with the same subject.")
805 (defvar gnus-summary-check-current nil
806 "*If non-nil, consider the current article when moving.
807 The \"unread\" movement commands will stay on the same line if the
808 current article is unread.")
810 (defvar gnus-auto-center-summary t
811 "*If non-nil, always center the current summary buffer.
812 In particular, if `vertical' do only vertical recentering. If non-nil
813 and non-`vertical', do both horizontal and vertical recentering.")
815 (defvar gnus-break-pages t
816 "*If non-nil, do page breaking on articles.
817 The page delimiter is specified by the `gnus-page-delimiter'
820 (defvar gnus-page-delimiter "^\^L"
821 "*Regexp describing what to use as article page delimiters.
822 The default value is \"^\^L\", which is a form linefeed at the
823 beginning of a line.")
825 (defvar gnus-use-full-window t
826 "*If non-nil, use the entire Emacs screen.")
828 (defvar gnus-window-configuration nil
829 "Obsolete variable. See `gnus-buffer-configuration'.")
831 (defvar gnus-window-min-width 2
832 "*Minimum width of Gnus buffers.")
834 (defvar gnus-window-min-height 1
835 "*Minimum height of Gnus buffers.")
837 (defvar gnus-buffer-configuration
841 (if gnus-carpal '(group-carpal 4))))
845 (if gnus-carpal '(summary-carpal 4))))
852 (if gnus-carpal '(summary-carpal 4))
854 (vertical ((height . 5) (width . 15)
856 (left . -1) (top . 1))
866 (if gnus-carpal '(summary-carpal 4))
867 (if gnus-use-trees '(tree 0.25))
872 (if gnus-carpal '(server-carpal 2))))
876 (if gnus-carpal '(browse-carpal 2))))
879 (message 1.0 point)))
882 (article 1.0 point)))
893 (edit-group 1.0 point)))
897 (edit-server 1.0 point)))
901 (edit-score 1.0 point)))
908 (message 1.0 point)))
911 (message 1.0 point)))
914 (message 1.0 point)))
918 (message 1.0 point)))
925 (if gnus-carpal '(summary-carpal 4))
926 ("*Shell Command Output*" 1.0)))
929 ("*Gnus Help Bug*" 0.5)
930 ("*Gnus Bug*" 1.0 point)))
934 (message 1.0 point))))
935 "Window configuration for all possible Gnus buffers.
936 This variable is a list of lists. Each of these lists has a NAME and
937 a RULE. The NAMEs are commonsense names like `group', which names a
938 rule used when displaying the group buffer; `summary', which names a
939 rule for what happens when you enter a group and do not display an
940 article buffer; and so on. See the value of this variable for a
941 complete list of NAMEs.
943 Each RULE is a list of vectors. The first element in this vector is
944 the name of the buffer to be displayed; the second element is the
945 percentage of the screen this buffer is to occupy (a number in the
946 0.0-0.99 range); the optional third element is `point', which should
947 be present to denote which buffer point is to go to after making this
948 buffer configuration.")
950 (defvar gnus-window-to-buffer
951 '((group . gnus-group-buffer)
952 (summary . gnus-summary-buffer)
953 (article . gnus-article-buffer)
954 (server . gnus-server-buffer)
955 (browse . "*Gnus Browse Server*")
956 (edit-group . gnus-group-edit-buffer)
957 (edit-server . gnus-server-edit-buffer)
958 (group-carpal . gnus-carpal-group-buffer)
959 (summary-carpal . gnus-carpal-summary-buffer)
960 (server-carpal . gnus-carpal-server-buffer)
961 (browse-carpal . gnus-carpal-browse-buffer)
962 (edit-score . gnus-score-edit-buffer)
963 (message . gnus-message-buffer)
964 (mail . gnus-message-buffer)
965 (post-news . gnus-message-buffer)
966 (faq . gnus-faq-buffer)
967 (picons . "*Picons*")
968 (tree . gnus-tree-buffer)
969 (info . gnus-info-buffer)
970 (article-copy . gnus-article-copy)
971 (draft . gnus-draft-buffer))
972 "Mapping from short symbols to buffer names or buffer variables.")
974 (defvar gnus-carpal nil
975 "*If non-nil, display clickable icons.")
977 (defvar gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies
978 "*Function called with a group name when new group is detected.
979 A few pre-made functions are supplied: `gnus-subscribe-randomly'
980 inserts new groups at the beginning of the list of groups;
981 `gnus-subscribe-alphabetically' inserts new groups in strict
982 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
983 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
984 for your decision; `gnus-subscribe-killed' kills all new groups;
985 `gnus-subscribe-zombies' will make all new groups into zombies.")
987 ;; Suggested by a bug report by Hallvard B Furuseth.
988 ;; <h.b.furuseth@usit.uio.no>.
989 (defvar gnus-subscribe-options-newsgroup-method
990 (function gnus-subscribe-alphabetically)
991 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines.
992 If, for instance, you want to subscribe to all newsgroups in the
993 \"no\" and \"alt\" hierarchies, you'd put the following in your
996 options -n no.all alt.all
998 Gnus will the subscribe all new newsgroups in these hierarchies with
999 the subscription method in this variable.")
1001 (defvar gnus-subscribe-hierarchical-interactive nil
1002 "*If non-nil, Gnus will offer to subscribe hierarchically.
1003 When a new hierarchy appears, Gnus will ask the user:
1005 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
1007 If the user pressed `d', Gnus will descend the hierarchy, `y' will
1008 subscribe to all newsgroups in the hierarchy and `s' will skip this
1009 hierarchy in its entirety.")
1011 (defvar gnus-group-sort-function 'gnus-group-sort-by-alphabet
1012 "*Function used for sorting the group buffer.
1013 This function will be called with group info entries as the arguments
1014 for the groups to be sorted. Pre-made functions include
1015 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-unread',
1016 `gnus-group-sort-by-level', `gnus-group-sort-by-score', and
1017 `gnus-group-sort-by-rank'.
1019 This variable can also be a list of sorting functions. In that case,
1020 the most significant sort function should be the last function in the
1023 ;; Mark variables suggested by Thomas Michanek
1024 ;; <Thomas.Michanek@telelogic.se>.
1025 (defvar gnus-unread-mark ?
1026 "*Mark used for unread articles.")
1027 (defvar gnus-ticked-mark ?!
1028 "*Mark used for ticked articles.")
1029 (defvar gnus-dormant-mark ??
1030 "*Mark used for dormant articles.")
1031 (defvar gnus-del-mark ?r
1032 "*Mark used for del'd articles.")
1033 (defvar gnus-read-mark ?R
1034 "*Mark used for read articles.")
1035 (defvar gnus-expirable-mark ?E
1036 "*Mark used for expirable articles.")
1037 (defvar gnus-killed-mark ?K
1038 "*Mark used for killed articles.")
1039 (defvar gnus-souped-mark ?F
1040 "*Mark used for killed articles.")
1041 (defvar gnus-kill-file-mark ?X
1042 "*Mark used for articles killed by kill files.")
1043 (defvar gnus-low-score-mark ?Y
1044 "*Mark used for articles with a low score.")
1045 (defvar gnus-catchup-mark ?C
1046 "*Mark used for articles that are caught up.")
1047 (defvar gnus-replied-mark ?A
1048 "*Mark used for articles that have been replied to.")
1049 (defvar gnus-cached-mark ?*
1050 "*Mark used for articles that are in the cache.")
1051 (defvar gnus-saved-mark ?S
1052 "*Mark used for articles that have been saved to.")
1053 (defvar gnus-process-mark ?#
1055 (defvar gnus-ancient-mark ?O
1056 "*Mark used for ancient articles.")
1057 (defvar gnus-sparse-mark ?Q
1058 "*Mark used for sparsely reffed articles.")
1059 (defvar gnus-canceled-mark ?G
1060 "*Mark used for canceled articles.")
1061 (defvar gnus-score-over-mark ?+
1062 "*Score mark used for articles with high scores.")
1063 (defvar gnus-score-below-mark ?-
1064 "*Score mark used for articles with low scores.")
1065 (defvar gnus-empty-thread-mark ?
1066 "*There is no thread under the article.")
1067 (defvar gnus-not-empty-thread-mark ?=
1068 "*There is a thread under the article.")
1070 (defvar gnus-view-pseudo-asynchronously nil
1071 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
1073 (defvar gnus-view-pseudos nil
1074 "*If `automatic', pseudo-articles will be viewed automatically.
1075 If `not-confirm', pseudos will be viewed automatically, and the user
1076 will not be asked to confirm the command.")
1078 (defvar gnus-view-pseudos-separately t
1079 "*If non-nil, one pseudo-article will be created for each file to be viewed.
1080 If nil, all files that use the same viewing command will be given as a
1081 list of parameters to that command.")
1083 (defvar gnus-insert-pseudo-articles t
1084 "*If non-nil, insert pseudo-articles when decoding articles.")
1086 (defvar gnus-group-line-format "%M%S%p%P%5y: %(%g%)%l\n"
1087 "*Format of group lines.
1088 It works along the same lines as a normal formatting string,
1089 with some simple extensions.
1091 %M Only marked articles (character, \"*\" or \" \")
1092 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
1093 %L Level of subscribedness (integer)
1094 %N Number of unread articles (integer)
1095 %I Number of dormant articles (integer)
1096 %i Number of ticked and dormant (integer)
1097 %T Number of ticked articles (integer)
1098 %R Number of read articles (integer)
1099 %t Total number of articles (integer)
1100 %y Number of unread, unticked articles (integer)
1101 %G Group name (string)
1102 %g Qualified group name (string)
1103 %D Group description (string)
1104 %s Select method (string)
1105 %o Moderated group (char, \"m\")
1106 %p Process mark (char)
1107 %O Moderated group (string, \"(m)\" or \"\")
1108 %P Topic indentation (string)
1109 %l Whether there are GroupLens predictions for this group (string)
1110 %n Select from where (string)
1111 %z A string that look like `<%s:%n>' if a foreign select method is used
1112 %u User defined specifier. The next character in the format string should
1113 be a letter. Gnus will call the function gnus-user-format-function-X,
1114 where X is the letter following %u. The function will be passed the
1115 current header as argument. The function should return a string, which
1116 will be inserted into the buffer just like information from any other
1119 Text between %( and %) will be highlighted with `gnus-mouse-face' when
1120 the mouse point move inside the area. There can only be one such area.
1122 Note that this format specification is not always respected. For
1123 reasons of efficiency, when listing killed groups, this specification
1124 is ignored altogether. If the spec is changed considerably, your
1125 output may end up looking strange when listing both alive and killed
1128 If you use %o or %O, reading the active file will be slower and quite
1129 a bit of extra memory will be used. %D will also worsen performance.
1130 Also note that if you change the format specification to include any
1131 of these specs, you must probably re-start Gnus to see them go into
1134 (defvar gnus-summary-line-format "%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n"
1135 "*The format specification of the lines in the summary buffer.
1137 It works along the same lines as a normal formatting string,
1138 with some simple extensions.
1140 %N Article number, left padded with spaces (string)
1142 %s Subject if it is at the root of a thread, and \"\" otherwise (string)
1143 %n Name of the poster (string)
1144 %a Extracted name of the poster (string)
1145 %A Extracted address of the poster (string)
1146 %F Contents of the From: header (string)
1147 %x Contents of the Xref: header (string)
1148 %D Date of the article (string)
1149 %d Date of the article (string) in DD-MMM format
1150 %M Message-id of the article (string)
1151 %r References of the article (string)
1152 %c Number of characters in the article (integer)
1153 %L Number of lines in the article (integer)
1154 %I Indentation based on thread level (a string of spaces)
1155 %T A string with two possible values: 80 spaces if the article
1156 is on thread level two or larger and 0 spaces on level one
1157 %R \"A\" if this article has been replied to, \" \" otherwise (character)
1158 %U Status of this article (character, \"R\", \"K\", \"-\" or \" \")
1159 %[ Opening bracket (character, \"[\" or \"<\")
1160 %] Closing bracket (character, \"]\" or \">\")
1161 %> Spaces of length thread-level (string)
1162 %< Spaces of length (- 20 thread-level) (string)
1163 %i Article score (number)
1164 %z Article zcore (character)
1165 %t Number of articles under the current thread (number).
1166 %e Whether the thread is empty or not (character).
1167 %l GroupLens score (string).
1168 %u User defined specifier. The next character in the format string should
1169 be a letter. Gnus will call the function gnus-user-format-function-X,
1170 where X is the letter following %u. The function will be passed the
1171 current header as argument. The function should return a string, which
1172 will be inserted into the summary just like information from any other
1175 Text between %( and %) will be highlighted with `gnus-mouse-face'
1176 when the mouse point is placed inside the area. There can only be one
1179 The %U (status), %R (replied) and %z (zcore) specs have to be handled
1180 with care. For reasons of efficiency, Gnus will compute what column
1181 these characters will end up in, and \"hard-code\" that. This means that
1182 it is illegal to have these specs after a variable-length spec. Well,
1183 you might not be arrested, but your summary buffer will look strange,
1184 which is bad enough.
1186 The smart choice is to have these specs as for to the left as
1189 This restriction may disappear in later versions of Gnus.")
1191 (defvar gnus-summary-dummy-line-format
1193 "*The format specification for the dummy roots in the summary buffer.
1194 It works along the same lines as a normal formatting string,
1195 with some simple extensions.
1199 (defvar gnus-summary-mode-line-format "Gnus: %%b [%A] %Z"
1200 "*The format specification for the summary mode line.
1201 It works along the same lines as a normal formatting string,
1202 with some simple extensions:
1205 %p Unprefixed group name
1206 %A Current article number
1208 %U Number of unread articles in the group
1209 %e Number of unselected articles in the group
1210 %Z A string with unread/unselected article counts
1211 %g Shortish group name
1212 %S Subject of the current article
1213 %u User-defined spec
1214 %s Current score file name
1215 %d Number of dormant articles
1216 %r Number of articles that have been marked as read in this session
1217 %E Number of articles expunged by the score files")
1219 (defvar gnus-article-mode-line-format "Gnus: %%b %S"
1220 "*The format specification for the article mode line.
1221 See `gnus-summary-mode-line-format' for a closer description.")
1223 (defvar gnus-group-mode-line-format "Gnus: %%b {%M%:%S}"
1224 "*The format specification for the group mode line.
1225 It works along the same lines as a normal formatting string,
1226 with some simple extensions:
1228 %S The native news server.
1229 %M The native select method.
1230 %: \":\" if %S isn't \"\".")
1232 (defvar gnus-valid-select-methods
1233 '(("nntp" post address prompt-address)
1234 ("nnspool" post address)
1235 ("nnvirtual" post-mail virtual prompt-address)
1236 ("nnmbox" mail respool address)
1237 ("nnml" mail respool address)
1238 ("nnmh" mail respool address)
1239 ("nndir" post-mail prompt-address address)
1240 ("nneething" none address prompt-address)
1241 ("nndoc" none address prompt-address)
1242 ("nnbabyl" mail address respool)
1243 ("nnkiboze" post address virtual)
1244 ("nnsoup" post-mail address)
1245 ("nndraft" post-mail)
1246 ("nnfolder" mail respool address))
1247 "An alist of valid select methods.
1248 The first element of each list lists should be a string with the name
1249 of the select method. The other elements may be be the category of
1250 this method (ie. `post', `mail', `none' or whatever) or other
1251 properties that this method has (like being respoolable).
1252 If you implement a new select method, all you should have to change is
1253 this variable. I think.")
1255 (defvar gnus-updated-mode-lines '(group article summary tree)
1256 "*List of buffers that should update their mode lines.
1257 The list may contain the symbols `group', `article' and `summary'. If
1258 the corresponding symbol is present, Gnus will keep that mode line
1259 updated with information that may be pertinent.
1260 If this variable is nil, screen refresh may be quicker.")
1262 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>.
1263 (defvar gnus-mode-non-string-length nil
1264 "*Max length of mode-line non-string contents.
1265 If this is nil, Gnus will take space as is needed, leaving the rest
1266 of the modeline intact.")
1269 ;(defvar gnus-mouse-face 'highlight
1270 ; "*Face used for mouse highlighting in Gnus.
1271 ;No mouse highlights will be done if `gnus-visual' is nil.")
1273 (defvar gnus-summary-mark-below 0
1274 "*Mark all articles with a score below this variable as read.
1275 This variable is local to each summary buffer and usually set by the
1278 (defvar gnus-article-sort-functions '(gnus-article-sort-by-number)
1279 "*List of functions used for sorting articles in the summary buffer.
1280 This variable is only used when not using a threaded display.")
1282 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number)
1283 "*List of functions used for sorting threads in the summary buffer.
1284 By default, threads are sorted by article number.
1286 Each function takes two threads and return non-nil if the first thread
1287 should be sorted before the other. If you use more than one function,
1288 the primary sort function should be the last. You should probably
1289 always include `gnus-thread-sort-by-number' in the list of sorting
1290 functions -- preferably first.
1292 Ready-mady functions include `gnus-thread-sort-by-number',
1293 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
1294 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
1295 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').")
1297 (defvar gnus-thread-score-function '+
1298 "*Function used for calculating the total score of a thread.
1300 The function is called with the scores of the article and each
1301 subthread and should then return the score of the thread.
1303 Some functions you can use are `+', `max', or `min'.")
1305 (defvar gnus-summary-expunge-below nil
1306 "All articles that have a score less than this variable will be expunged.")
1308 (defvar gnus-thread-expunge-below nil
1309 "All threads that have a total score less than this variable will be expunged.
1310 See `gnus-thread-score-function' for en explanation of what a
1311 \"thread score\" is.")
1313 (defvar gnus-auto-subscribed-groups
1314 "^nnml\\|^nnfolder\\|^nnmbox\\|^nnmh\\|^nnbabyl"
1315 "*All new groups that match this regexp will be subscribed automatically.
1316 Note that this variable only deals with new groups. It has no effect
1317 whatsoever on old groups.")
1319 (defvar gnus-options-subscribe nil
1320 "*All new groups matching this regexp will be subscribed unconditionally.
1321 Note that this variable deals only with new newsgroups. This variable
1322 does not affect old newsgroups.")
1324 (defvar gnus-options-not-subscribe nil
1325 "*All new groups matching this regexp will be ignored.
1326 Note that this variable deals only with new newsgroups. This variable
1327 does not affect old (already subscribed) newsgroups.")
1329 (defvar gnus-auto-expirable-newsgroups nil
1330 "*Groups in which to automatically mark read articles as expirable.
1331 If non-nil, this should be a regexp that should match all groups in
1332 which to perform auto-expiry. This only makes sense for mail groups.")
1334 (defvar gnus-total-expirable-newsgroups nil
1335 "*Groups in which to perform expiry of all read articles.
1336 Use with extreme caution. All groups that match this regexp will be
1337 expiring - which means that all read articles will be deleted after
1338 (say) one week. (This only goes for mail groups and the like, of
1341 (defvar gnus-group-uncollapsed-levels 1
1342 "Number of group name elements to leave alone when making a short group name.")
1344 (defvar gnus-hidden-properties '(invisible t intangible t)
1345 "Property list to use for hiding text.")
1347 (defvar gnus-modtime-botch nil
1348 "*Non-nil means .newsrc should be deleted prior to save.
1349 Its use is due to the bogus appearance that .newsrc was modified on
1354 (defvar gnus-group-mode-hook nil
1355 "*A hook for Gnus group mode.")
1357 (defvar gnus-summary-mode-hook nil
1358 "*A hook for Gnus summary mode.
1359 This hook is run before any variables are set in the summary buffer.")
1361 (defvar gnus-article-mode-hook nil
1362 "*A hook for Gnus article mode.")
1364 (defvar gnus-summary-prepare-exit-hook nil
1365 "*A hook called when preparing to exit from the summary buffer.
1366 It calls `gnus-summary-expire-articles' by default.")
1367 (add-hook 'gnus-summary-prepare-exit-hook 'gnus-summary-expire-articles)
1369 (defvar gnus-summary-exit-hook nil
1370 "*A hook called on exit from the summary buffer.")
1372 (defvar gnus-group-catchup-group-hook nil
1373 "*A hook run when catching up a group from the group buffer.")
1375 (defvar gnus-group-update-group-hook nil
1376 "*A hook called when updating group lines.")
1378 (defvar gnus-open-server-hook nil
1379 "*A hook called just before opening connection to the news server.")
1381 (defvar gnus-load-hook nil
1382 "*A hook run while Gnus is loaded.")
1384 (defvar gnus-startup-hook nil
1385 "*A hook called at startup.
1386 This hook is called after Gnus is connected to the NNTP server.")
1388 (defvar gnus-get-new-news-hook nil
1389 "*A hook run just before Gnus checks for new news.")
1391 (defvar gnus-after-getting-new-news-hook nil
1392 "*A hook run after Gnus checks for new news.")
1394 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat
1395 "*A function that is called to generate the group buffer.
1396 The function is called with three arguments: The first is a number;
1397 all group with a level less or equal to that number should be listed,
1398 if the second is non-nil, empty groups should also be displayed. If
1399 the third is non-nil, it is a number. No groups with a level lower
1400 than this number should be displayed.
1402 The only current function implemented is `gnus-group-prepare-flat'.")
1404 (defvar gnus-group-prepare-hook nil
1405 "*A hook called after the group buffer has been generated.
1406 If you want to modify the group buffer, you can use this hook.")
1408 (defvar gnus-summary-prepare-hook nil
1409 "*A hook called after the summary buffer has been generated.
1410 If you want to modify the summary buffer, you can use this hook.")
1412 (defvar gnus-summary-generate-hook nil
1413 "*A hook run just before generating the summary buffer.
1414 This hook is commonly used to customize threading variables and the
1417 (defvar gnus-article-prepare-hook nil
1418 "*A hook called after an article has been prepared in the article buffer.
1419 If you want to run a special decoding program like nkf, use this hook.")
1421 ;(defvar gnus-article-display-hook nil
1422 ; "*A hook called after the article is displayed in the article buffer.
1423 ;The hook is designed to change the contents of the article
1424 ;buffer. Typical functions that this hook may contain are
1425 ;`gnus-article-hide-headers' (hide selected headers),
1426 ;`gnus-article-maybe-highlight' (perform fancy article highlighting),
1427 ;`gnus-article-hide-signature' (hide signature) and
1428 ;`gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).")
1429 ;(add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted)
1430 ;(add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike)
1431 ;(add-hook 'gnus-article-display-hook 'gnus-article-maybe-highlight)
1433 (defvar gnus-article-x-face-too-ugly nil
1434 "Regexp matching posters whose face shouldn't be shown automatically.")
1436 (defvar gnus-select-group-hook nil
1437 "*A hook called when a newsgroup is selected.
1439 If you'd like to simplify subjects like the
1440 `gnus-summary-next-same-subject' command does, you can use the
1443 (setq gnus-select-group-hook
1446 (mapcar (lambda (header)
1447 (mail-header-set-subject
1449 (gnus-simplify-subject
1450 (mail-header-subject header) 're-only)))
1451 gnus-newsgroup-headers))))")
1453 (defvar gnus-select-article-hook nil
1454 "*A hook called when an article is selected.")
1456 (defvar gnus-apply-kill-hook '(gnus-apply-kill-file)
1457 "*A hook called to apply kill files to a group.
1458 This hook is intended to apply a kill file to the selected newsgroup.
1459 The function `gnus-apply-kill-file' is called by default.
1461 Since a general kill file is too heavy to use only for a few
1462 newsgroups, I recommend you to use a lighter hook function. For
1463 example, if you'd like to apply a kill file to articles which contains
1464 a string `rmgroup' in subject in newsgroup `control', you can use the
1467 (setq gnus-apply-kill-hook
1470 (cond ((string-match \"control\" gnus-newsgroup-name)
1471 (gnus-kill \"Subject\" \"rmgroup\")
1472 (gnus-expunge \"X\"))))))")
1474 (defvar gnus-visual-mark-article-hook
1475 (list 'gnus-highlight-selected-summary)
1476 "*Hook run after selecting an article in the summary buffer.
1477 It is meant to be used for highlighting the article in some way. It
1478 is not run if `gnus-visual' is nil.")
1480 (defvar gnus-parse-headers-hook nil
1481 "*A hook called before parsing the headers.")
1482 (add-hook 'gnus-parse-headers-hook 'gnus-decode-rfc1522)
1484 (defvar gnus-exit-group-hook nil
1485 "*A hook called when exiting (not quitting) summary mode.")
1487 (defvar gnus-suspend-gnus-hook nil
1488 "*A hook called when suspending (not exiting) Gnus.")
1490 (defvar gnus-exit-gnus-hook nil
1491 "*A hook called when exiting Gnus.")
1493 (defvar gnus-after-exiting-gnus-hook nil
1494 "*A hook called after exiting Gnus.")
1496 (defvar gnus-save-newsrc-hook nil
1497 "*A hook called before saving any of the newsrc files.")
1499 (defvar gnus-save-quick-newsrc-hook nil
1500 "*A hook called just before saving the quick newsrc file.
1501 Can be used to turn version control on or off.")
1503 (defvar gnus-save-standard-newsrc-hook nil
1504 "*A hook called just before saving the standard newsrc file.
1505 Can be used to turn version control on or off.")
1507 (defvar gnus-summary-update-hook
1508 (list 'gnus-summary-highlight-line)
1509 "*A hook called when a summary line is changed.
1510 The hook will not be called if `gnus-visual' is nil.
1512 The default function `gnus-summary-highlight-line' will
1513 highlight the line according to the `gnus-summary-highlight'
1516 (defvar gnus-group-update-hook '(gnus-group-highlight-line)
1517 "*A hook called when a group line is changed.
1518 The hook will not be called if `gnus-visual' is nil.
1520 The default function `gnus-group-highlight-line' will
1521 highlight the line according to the `gnus-group-highlight'
1524 (defvar gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
1525 "*A hook called when an article is selected for the first time.
1526 The hook is intended to mark an article as read (or unread)
1527 automatically when it is selected.")
1529 (defvar gnus-group-change-level-function nil
1530 "Function run when a group level is changed.
1531 It is called with three parameters -- GROUP, LEVEL and OLDLEVEL.")
1533 ;; Remove any hilit infestation.
1534 (add-hook 'gnus-startup-hook
1536 (remove-hook 'gnus-summary-prepare-hook
1537 'hilit-rehighlight-buffer-quietly)
1538 (remove-hook 'gnus-summary-prepare-hook 'hilit-install-line-hooks)
1539 (setq gnus-mark-article-hook
1540 '(gnus-summary-mark-read-and-unread-as-read))
1541 (remove-hook 'gnus-article-prepare-hook
1542 'hilit-rehighlight-buffer-quietly)))
1545 ;; Internal variables
1547 (defvar gnus-tree-buffer "*Tree*"
1548 "Buffer where Gnus thread trees are displayed.")
1551 (defvar gnus-use-generic-from nil)
1553 (defvar gnus-thread-indent-array nil)
1554 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1556 (defvar gnus-newsrc-file-version nil)
1558 (defvar gnus-method-history nil)
1559 ;; Variable holding the user answers to all method prompts.
1561 (defvar gnus-group-history nil)
1562 ;; Variable holding the user answers to all group prompts.
1564 (defvar gnus-server-alist nil
1565 "List of available servers.")
1567 (defvar gnus-group-indentation-function nil)
1569 (defvar gnus-topic-indentation "") ;; Obsolete variable.
1571 (defvar gnus-goto-missing-group-function nil)
1573 (defvar gnus-override-subscribe-method nil)
1575 (defvar gnus-group-goto-next-group-function nil
1576 "Function to override finding the next group after listing groups.")
1578 (defconst gnus-article-mark-lists
1579 '((marked . tick) (replied . reply)
1580 (expirable . expire) (killed . killed)
1581 (bookmarks . bookmark) (dormant . dormant)
1582 (scored . score) (saved . save)
1586 ;; Avoid highlighting in kill files.
1587 (defvar gnus-summary-inhibit-highlight nil)
1588 (defvar gnus-newsgroup-selected-overlay nil)
1590 (defvar gnus-inhibit-hiding nil)
1591 (defvar gnus-group-indentation "")
1592 (defvar gnus-inhibit-limiting nil)
1593 (defvar gnus-created-frames nil)
1595 (defvar gnus-article-mode-map nil)
1596 (defvar gnus-dribble-buffer nil)
1597 (defvar gnus-headers-retrieved-by nil)
1598 (defvar gnus-article-reply nil)
1599 (defvar gnus-override-method nil)
1600 (defvar gnus-article-check-size nil)
1602 (defvar gnus-current-score-file nil)
1603 (defvar gnus-newsgroup-adaptive-score-file nil)
1604 (defvar gnus-scores-exclude-files nil)
1606 (defvar gnus-opened-servers nil)
1608 (defvar gnus-current-move-group nil)
1609 (defvar gnus-current-copy-group nil)
1610 (defvar gnus-current-crosspost-group nil)
1612 (defvar gnus-newsgroup-dependencies nil)
1613 (defvar gnus-newsgroup-async nil)
1614 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*")
1616 (defvar gnus-newsgroup-adaptive nil)
1618 (defvar gnus-summary-display-table nil)
1619 (defvar gnus-summary-display-article-function nil)
1621 (defvar gnus-summary-highlight-line-function nil
1622 "Function called after highlighting a summary line.")
1624 (defvar gnus-group-line-format-alist
1625 `((?M gnus-tmp-marked-mark ?c)
1626 (?S gnus-tmp-subscribed ?c)
1627 (?L gnus-tmp-level ?d)
1628 (?N (cond ((eq number t) "*" )
1632 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1633 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
1635 (?R gnus-tmp-number-of-read ?s)
1636 (?t gnus-tmp-number-total ?d)
1637 (?y gnus-tmp-number-of-unread ?s)
1638 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
1639 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
1640 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1641 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
1642 (?g gnus-tmp-group ?s)
1643 (?G gnus-tmp-qualified-group ?s)
1644 (?c (gnus-short-group-name gnus-tmp-group) ?s)
1645 (?D gnus-tmp-newsgroup-description ?s)
1646 (?o gnus-tmp-moderated ?c)
1647 (?O gnus-tmp-moderated-string ?s)
1648 (?p gnus-tmp-process-marked ?c)
1649 (?s gnus-tmp-news-server ?s)
1650 (?n gnus-tmp-news-method ?s)
1651 (?P gnus-group-indentation ?s)
1652 (?l gnus-tmp-grouplens ?s)
1653 (?z gnus-tmp-news-method-string ?s)
1654 (?u gnus-tmp-user-defined ?s)))
1656 (defvar gnus-summary-line-format-alist
1657 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1658 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1659 (?s gnus-tmp-subject-or-nil ?s)
1660 (?n gnus-tmp-name ?s)
1661 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1663 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1665 (?F gnus-tmp-from ?s)
1666 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1667 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1668 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1669 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1670 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1671 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1672 (?L gnus-tmp-lines ?d)
1673 (?I gnus-tmp-indentation ?s)
1674 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1675 (?R gnus-tmp-replied ?c)
1676 (?\[ gnus-tmp-opening-bracket ?c)
1677 (?\] gnus-tmp-closing-bracket ?c)
1678 (?\> (make-string gnus-tmp-level ? ) ?s)
1679 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1680 (?i gnus-tmp-score ?d)
1681 (?z gnus-tmp-score-char ?c)
1682 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1683 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1684 (?U gnus-tmp-unread ?c)
1685 (?t (gnus-summary-number-of-articles-in-thread
1686 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1688 (?e (gnus-summary-number-of-articles-in-thread
1689 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1691 (?u gnus-tmp-user-defined ?s))
1692 "An alist of format specifications that can appear in summary lines,
1693 and what variables they correspond with, along with the type of the
1694 variable (string, integer, character, etc).")
1696 (defvar gnus-summary-dummy-line-format-alist
1697 `((?S gnus-tmp-subject ?s)
1698 (?N gnus-tmp-number ?d)
1699 (?u gnus-tmp-user-defined ?s)))
1701 (defvar gnus-summary-mode-line-format-alist
1702 `((?G gnus-tmp-group-name ?s)
1703 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1704 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1705 (?A gnus-tmp-article-number ?d)
1706 (?Z gnus-tmp-unread-and-unselected ?s)
1707 (?V gnus-version ?s)
1708 (?U gnus-tmp-unread-and-unticked ?d)
1709 (?S gnus-tmp-subject ?s)
1710 (?e gnus-tmp-unselected ?d)
1711 (?u gnus-tmp-user-defined ?s)
1712 (?d (length gnus-newsgroup-dormant) ?d)
1713 (?t (length gnus-newsgroup-marked) ?d)
1714 (?r (length gnus-newsgroup-reads) ?d)
1715 (?E gnus-newsgroup-expunged-tally ?d)
1716 (?s (gnus-current-score-file-nondirectory) ?s)))
1718 (defvar gnus-article-mode-line-format-alist
1719 gnus-summary-mode-line-format-alist)
1721 (defvar gnus-group-mode-line-format-alist
1722 `((?S gnus-tmp-news-server ?s)
1723 (?M gnus-tmp-news-method ?s)
1724 (?u gnus-tmp-user-defined ?s)
1725 (?: gnus-tmp-colon ?s)))
1727 (defvar gnus-have-read-active-file nil)
1729 (defconst gnus-maintainer
1730 "gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls + Boys)"
1731 "The mail address of the Gnus maintainers.")
1733 (defconst gnus-version-number "5.2.20"
1734 "Version number for this version of Gnus.")
1736 (defconst gnus-version (format "Gnus v%s" gnus-version-number)
1737 "Version string for this version of Gnus.")
1739 (defvar gnus-info-nodes
1740 '((gnus-group-mode "(gnus)The Group Buffer")
1741 (gnus-summary-mode "(gnus)The Summary Buffer")
1742 (gnus-article-mode "(gnus)The Article Buffer"))
1743 "Alist of major modes and related Info nodes.")
1745 (defvar gnus-group-buffer "*Group*")
1746 (defvar gnus-summary-buffer "*Summary*")
1747 (defvar gnus-article-buffer "*Article*")
1748 (defvar gnus-server-buffer "*Server*")
1750 (defvar gnus-work-buffer " *gnus work*")
1752 (defvar gnus-original-article-buffer " *Original Article*")
1753 (defvar gnus-original-article nil)
1755 (defvar gnus-buffer-list nil
1756 "Gnus buffers that should be killed on exit.")
1758 (defvar gnus-slave nil
1759 "Whether this Gnus is a slave or not.")
1761 (defvar gnus-variable-list
1762 '(gnus-newsrc-options gnus-newsrc-options-n
1763 gnus-newsrc-last-checked-date
1764 gnus-newsrc-alist gnus-server-alist
1765 gnus-killed-list gnus-zombie-list
1766 gnus-topic-topology gnus-topic-alist
1768 "Gnus variables saved in the quick startup file.")
1770 (defvar gnus-newsrc-options nil
1771 "Options line in the .newsrc file.")
1773 (defvar gnus-newsrc-options-n nil
1774 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1776 (defvar gnus-newsrc-last-checked-date nil
1777 "Date Gnus last asked server for new newsgroups.")
1779 (defvar gnus-topic-topology nil
1780 "The complete topic hierarchy.")
1782 (defvar gnus-topic-alist nil
1783 "The complete topic-group alist.")
1785 (defvar gnus-newsrc-alist nil
1786 "Assoc list of read articles.
1787 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1789 (defvar gnus-newsrc-hashtb nil
1790 "Hashtable of gnus-newsrc-alist.")
1792 (defvar gnus-killed-list nil
1793 "List of killed newsgroups.")
1795 (defvar gnus-killed-hashtb nil
1796 "Hash table equivalent of gnus-killed-list.")
1798 (defvar gnus-zombie-list nil
1799 "List of almost dead newsgroups.")
1801 (defvar gnus-description-hashtb nil
1802 "Descriptions of newsgroups.")
1804 (defvar gnus-list-of-killed-groups nil
1805 "List of newsgroups that have recently been killed by the user.")
1807 (defvar gnus-active-hashtb nil
1808 "Hashtable of active articles.")
1810 (defvar gnus-moderated-list nil
1811 "List of moderated newsgroups.")
1813 (defvar gnus-group-marked nil)
1815 (defvar gnus-current-startup-file nil
1816 "Startup file for the current host.")
1818 (defvar gnus-last-search-regexp nil
1819 "Default regexp for article search command.")
1821 (defvar gnus-last-shell-command nil
1822 "Default shell command on article.")
1824 (defvar gnus-current-select-method nil
1825 "The current method for selecting a newsgroup.")
1827 (defvar gnus-group-list-mode nil)
1829 (defvar gnus-article-internal-prepare-hook nil)
1831 (defvar gnus-newsgroup-name nil)
1832 (defvar gnus-newsgroup-begin nil)
1833 (defvar gnus-newsgroup-end nil)
1834 (defvar gnus-newsgroup-last-rmail nil)
1835 (defvar gnus-newsgroup-last-mail nil)
1836 (defvar gnus-newsgroup-last-folder nil)
1837 (defvar gnus-newsgroup-last-file nil)
1838 (defvar gnus-newsgroup-auto-expire nil)
1839 (defvar gnus-newsgroup-active nil)
1841 (defvar gnus-newsgroup-data nil)
1842 (defvar gnus-newsgroup-data-reverse nil)
1843 (defvar gnus-newsgroup-limit nil)
1844 (defvar gnus-newsgroup-limits nil)
1846 (defvar gnus-newsgroup-unreads nil
1847 "List of unread articles in the current newsgroup.")
1849 (defvar gnus-newsgroup-unselected nil
1850 "List of unselected unread articles in the current newsgroup.")
1852 (defvar gnus-newsgroup-reads nil
1853 "Alist of read articles and article marks in the current newsgroup.")
1855 (defvar gnus-newsgroup-expunged-tally nil)
1857 (defvar gnus-newsgroup-marked nil
1858 "List of ticked articles in the current newsgroup (a subset of unread art).")
1860 (defvar gnus-newsgroup-killed nil
1861 "List of ranges of articles that have been through the scoring process.")
1863 (defvar gnus-newsgroup-cached nil
1864 "List of articles that come from the article cache.")
1866 (defvar gnus-newsgroup-saved nil
1867 "List of articles that have been saved.")
1869 (defvar gnus-newsgroup-kill-headers nil)
1871 (defvar gnus-newsgroup-replied nil
1872 "List of articles that have been replied to in the current newsgroup.")
1874 (defvar gnus-newsgroup-expirable nil
1875 "List of articles in the current newsgroup that can be expired.")
1877 (defvar gnus-newsgroup-processable nil
1878 "List of articles in the current newsgroup that can be processed.")
1880 (defvar gnus-newsgroup-bookmarks nil
1881 "List of articles in the current newsgroup that have bookmarks.")
1883 (defvar gnus-newsgroup-dormant nil
1884 "List of dormant articles in the current newsgroup.")
1886 (defvar gnus-newsgroup-scored nil
1887 "List of scored articles in the current newsgroup.")
1889 (defvar gnus-newsgroup-headers nil
1890 "List of article headers in the current newsgroup.")
1892 (defvar gnus-newsgroup-threads nil)
1894 (defvar gnus-newsgroup-prepared nil
1895 "Whether the current group has been prepared properly.")
1897 (defvar gnus-newsgroup-ancient nil
1898 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1900 (defvar gnus-newsgroup-sparse nil)
1902 (defvar gnus-current-article nil)
1903 (defvar gnus-article-current nil)
1904 (defvar gnus-current-headers nil)
1905 (defvar gnus-have-all-headers nil)
1906 (defvar gnus-last-article nil)
1907 (defvar gnus-newsgroup-history nil)
1908 (defvar gnus-current-kill-article nil)
1910 ;; Save window configuration.
1911 (defvar gnus-prev-winconf nil)
1913 (defvar gnus-summary-mark-positions nil)
1914 (defvar gnus-group-mark-positions nil)
1916 (defvar gnus-reffed-article-number nil)
1918 ;;; Let the byte-compiler know that we know about this variable.
1919 (defvar rmail-default-rmail-file)
1921 (defvar gnus-cache-removable-articles nil)
1923 (defvar gnus-dead-summary nil)
1925 (defconst gnus-summary-local-variables
1926 '(gnus-newsgroup-name
1927 gnus-newsgroup-begin gnus-newsgroup-end
1928 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1929 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1930 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1931 gnus-newsgroup-unselected gnus-newsgroup-marked
1932 gnus-newsgroup-reads gnus-newsgroup-saved
1933 gnus-newsgroup-replied gnus-newsgroup-expirable
1934 gnus-newsgroup-processable gnus-newsgroup-killed
1935 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1936 gnus-newsgroup-headers gnus-newsgroup-threads
1937 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1938 gnus-current-article gnus-current-headers gnus-have-all-headers
1939 gnus-last-article gnus-article-internal-prepare-hook
1940 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1941 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1942 gnus-newsgroup-async gnus-thread-expunge-below
1943 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1944 (gnus-summary-mark-below . global)
1945 gnus-newsgroup-active gnus-scores-exclude-files
1946 gnus-newsgroup-history gnus-newsgroup-ancient
1947 gnus-newsgroup-sparse
1948 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1949 gnus-newsgroup-adaptive-score-file
1950 (gnus-newsgroup-expunged-tally . 0)
1951 gnus-cache-removable-articles gnus-newsgroup-cached
1952 gnus-newsgroup-data gnus-newsgroup-data-reverse
1953 gnus-newsgroup-limit gnus-newsgroup-limits)
1954 "Variables that are buffer-local to the summary buffers.")
1956 (defconst gnus-bug-message
1957 "Sending a bug report to the Gnus Towers.
1958 ========================================
1960 The buffer below is a mail buffer. When you press `C-c C-c', it will
1961 be sent to the Gnus Bug Exterminators.
1963 At the bottom of the buffer you'll see lots of variable settings.
1964 Please do not delete those. They will tell the Bug People what your
1965 environment is, so that it will be easier to locate the bugs.
1967 If you have found a bug that makes Emacs go \"beep\", set
1968 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
1969 and include the backtrace in your bug report.
1971 Please describe the bug in annoying, painstaking detail.
1973 Thank you for your help in stamping out bugs.
1976 ;;; End of variables.
1978 ;; Define some autoload functions Gnus might use.
1981 ;; This little mapcar goes through the list below and marks the
1982 ;; symbols in question as autoloaded functions.
1985 (let ((interactive (nth 1 (memq ':interactive package))))
1989 (when (consp function)
1990 (setq keymap (car (memq 'keymap function)))
1991 (setq function (car function)))
1992 (autoload function (car package) nil interactive keymap)))
1993 (if (eq (nth 1 package) ':interactive)
1996 '(("metamail" metamail-buffer)
1997 ("info" Info-goto-node)
1998 ("hexl" hexl-hex-string-to-integer)
1999 ("pp" pp pp-to-string pp-eval-expression)
2000 ("mail-extr" mail-extract-address-components)
2001 ("nnmail" nnmail-split-fancy nnmail-article-group)
2002 ("nnvirtual" nnvirtual-catchup-group)
2003 ("timezone" timezone-make-date-arpa-standard timezone-fix-time
2004 timezone-make-sortable-date timezone-make-time-string)
2005 ("rmailout" rmail-output)
2006 ("rmail" rmail-insert-rmail-file-header rmail-count-new-messages
2008 ("gnus-soup" :interactive t
2009 gnus-group-brew-soup gnus-brew-soup gnus-soup-add-article
2010 gnus-soup-send-replies gnus-soup-save-areas gnus-soup-pack-packet)
2011 ("nnsoup" nnsoup-pack-replies)
2012 ("gnus-scomo" :interactive t gnus-score-mode)
2013 ("gnus-mh" gnus-mh-mail-setup gnus-summary-save-article-folder
2014 gnus-Folder-save-name gnus-folder-save-name)
2015 ("gnus-mh" :interactive t gnus-summary-save-in-folder)
2016 ("gnus-vis" gnus-group-make-menu-bar gnus-summary-make-menu-bar
2017 gnus-server-make-menu-bar gnus-article-make-menu-bar
2018 gnus-browse-make-menu-bar gnus-highlight-selected-summary
2019 gnus-summary-highlight-line gnus-carpal-setup-buffer
2020 gnus-group-highlight-line
2021 gnus-article-add-button gnus-insert-next-page-button
2022 gnus-insert-prev-page-button gnus-visual-turn-off-edit-menu)
2023 ("gnus-vis" :interactive t
2024 gnus-article-push-button gnus-article-press-button
2025 gnus-article-highlight gnus-article-highlight-some
2026 gnus-article-highlight-headers gnus-article-highlight-signature
2027 gnus-article-add-buttons gnus-article-add-buttons-to-head
2028 gnus-article-next-button gnus-article-prev-button)
2029 ("gnus-demon" gnus-demon-add-nocem gnus-demon-add-scanmail
2030 gnus-demon-add-disconnection gnus-demon-add-handler
2031 gnus-demon-remove-handler)
2032 ("gnus-demon" :interactive t
2033 gnus-demon-init gnus-demon-cancel)
2034 ("gnus-salt" gnus-highlight-selected-tree gnus-possibly-generate-tree
2035 gnus-tree-open gnus-tree-close)
2036 ("gnus-nocem" gnus-nocem-scan-groups gnus-nocem-close
2037 gnus-nocem-unwanted-article-p)
2038 ("gnus-srvr" gnus-enter-server-buffer gnus-server-set-info)
2039 ("gnus-srvr" gnus-browse-foreign-server)
2040 ("gnus-cite" :interactive t
2041 gnus-article-highlight-citation gnus-article-hide-citation-maybe
2042 gnus-article-hide-citation gnus-article-fill-cited-article
2043 gnus-article-hide-citation-in-followups)
2044 ("gnus-kill" gnus-kill gnus-apply-kill-file-internal
2045 gnus-kill-file-edit-file gnus-kill-file-raise-followups-to-author
2046 gnus-execute gnus-expunge)
2047 ("gnus-cache" gnus-cache-possibly-enter-article gnus-cache-save-buffers
2048 gnus-cache-possibly-remove-articles gnus-cache-request-article
2049 gnus-cache-retrieve-headers gnus-cache-possibly-alter-active
2050 gnus-cache-enter-remove-article gnus-cached-article-p
2051 gnus-cache-open gnus-cache-close gnus-cache-update-article)
2052 ("gnus-cache" :interactive t gnus-jog-cache gnus-cache-enter-article
2053 gnus-cache-remove-article)
2054 ("gnus-score" :interactive t
2055 gnus-summary-increase-score gnus-summary-lower-score
2056 gnus-score-flush-cache gnus-score-close
2057 gnus-score-raise-same-subject-and-select
2058 gnus-score-raise-same-subject gnus-score-default
2059 gnus-score-raise-thread gnus-score-lower-same-subject-and-select
2060 gnus-score-lower-same-subject gnus-score-lower-thread
2061 gnus-possibly-score-headers gnus-summary-raise-score
2062 gnus-summary-set-score gnus-summary-current-score)
2064 (gnus-summary-score-map keymap) gnus-score-save gnus-score-headers
2065 gnus-current-score-file-nondirectory gnus-score-adaptive
2066 gnus-score-find-trace gnus-score-file-name)
2067 ("gnus-edit" :interactive t gnus-score-customize)
2068 ("gnus-topic" :interactive t gnus-topic-mode)
2069 ("gnus-topic" gnus-topic-remove-group)
2070 ("gnus-salt" :interactive t gnus-pick-mode gnus-binary-mode)
2071 ("gnus-uu" (gnus-uu-extract-map keymap) (gnus-uu-mark-map keymap))
2072 ("gnus-uu" :interactive t
2073 gnus-uu-digest-mail-forward gnus-uu-digest-post-forward
2074 gnus-uu-mark-series gnus-uu-mark-region gnus-uu-mark-buffer
2075 gnus-uu-mark-by-regexp gnus-uu-mark-all
2076 gnus-uu-mark-sparse gnus-uu-mark-thread gnus-uu-decode-uu
2077 gnus-uu-decode-uu-and-save gnus-uu-decode-unshar
2078 gnus-uu-decode-unshar-and-save gnus-uu-decode-save
2079 gnus-uu-decode-binhex gnus-uu-decode-uu-view
2080 gnus-uu-decode-uu-and-save-view gnus-uu-decode-unshar-view
2081 gnus-uu-decode-unshar-and-save-view gnus-uu-decode-save-view
2082 gnus-uu-decode-binhex-view)
2083 ("gnus-msg" (gnus-summary-send-map keymap)
2084 gnus-mail-yank-original gnus-mail-send-and-exit
2085 gnus-article-mail gnus-new-mail gnus-mail-reply)
2086 ("gnus-msg" :interactive t
2087 gnus-group-post-news gnus-group-mail gnus-summary-post-news
2088 gnus-summary-followup gnus-summary-followup-with-original
2089 gnus-summary-cancel-article gnus-summary-supersede-article
2090 gnus-post-news gnus-inews-news
2091 gnus-summary-reply gnus-summary-reply-with-original
2092 gnus-summary-mail-forward gnus-summary-mail-other-window
2094 ("gnus-picon" :interactive t gnus-article-display-picons
2095 gnus-group-display-picons gnus-picons-article-display-x-face)
2096 ("gnus-gl" bbb-login bbb-logout bbb-grouplens-group-p
2097 gnus-grouplens-mode)
2098 ("smiley" :interactive t gnus-smiley-display)
2099 ("gnus-vm" gnus-vm-mail-setup)
2100 ("gnus-vm" :interactive t gnus-summary-save-in-vm
2101 gnus-summary-save-article-vm))))
2105 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2106 ;; If you want the cursor to go somewhere else, set these two
2107 ;; functions in some startup hook to whatever you want.
2108 (defalias 'gnus-summary-position-point 'gnus-goto-colon)
2109 (defalias 'gnus-group-position-point 'gnus-goto-colon)
2111 ;;; Various macros and substs.
2113 (defun gnus-header-from (header)
2114 (mail-header-from header))
2116 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
2117 "Pop to BUFFER, evaluate FORMS, and then return to the original window."
2118 (let ((tempvar (make-symbol "GnusStartBufferWindow"))
2119 (w (make-symbol "w"))
2120 (buf (make-symbol "buf")))
2121 `(let* ((,tempvar (selected-window))
2123 (,w (get-buffer-window ,buf 'visible)))
2128 (pop-to-buffer ,buf))
2130 (select-window ,tempvar)))))
2132 (put 'gnus-eval-in-buffer-window 'lisp-indent-function 1)
2133 (put 'gnus-eval-in-buffer-window 'lisp-indent-hook 1)
2134 (put 'gnus-eval-in-buffer-window 'edebug-form-spec '(form body))
2136 (defmacro gnus-gethash (string hashtable)
2137 "Get hash value of STRING in HASHTABLE."
2138 `(symbol-value (intern-soft ,string ,hashtable)))
2140 (defmacro gnus-sethash (string value hashtable)
2141 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2142 `(set (intern ,string ,hashtable) ,value))
2144 (defmacro gnus-intern-safe (string hashtable)
2145 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2146 `(let ((symbol (intern ,string ,hashtable)))
2151 (defmacro gnus-group-unread (group)
2152 "Get the currently computed number of unread articles in GROUP."
2153 `(car (gnus-gethash ,group gnus-newsrc-hashtb)))
2155 (defmacro gnus-group-entry (group)
2156 "Get the newsrc entry for GROUP."
2157 `(gnus-gethash ,group gnus-newsrc-hashtb))
2159 (defmacro gnus-active (group)
2160 "Get active info on GROUP."
2161 `(gnus-gethash ,group gnus-active-hashtb))
2163 (defmacro gnus-set-active (group active)
2164 "Set GROUP's active info."
2165 `(gnus-sethash ,group ,active gnus-active-hashtb))
2167 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2168 ;; function `substring' might cut on a middle of multi-octet
2170 (defun gnus-truncate-string (str width)
2171 (substring str 0 width))
2173 ;; Added by Geoffrey T. Dairiki <dairiki@u.washington.edu>. A safe way
2174 ;; to limit the length of a string. This function is necessary since
2175 ;; `(substr "abc" 0 30)' pukes with "Args out of range".
2176 (defsubst gnus-limit-string (str width)
2177 (if (> (length str) width)
2178 (substring str 0 width)
2181 (defsubst gnus-simplify-subject-re (subject)
2182 "Remove \"Re:\" from subject lines."
2183 (if (string-match "^[Rr][Ee]: *" subject)
2184 (substring subject (match-end 0))
2187 (defsubst gnus-functionp (form)
2188 "Return non-nil if FORM is funcallable."
2189 (or (and (symbolp form) (fboundp form))
2190 (and (listp form) (eq (car form) 'lambda))))
2192 (defsubst gnus-goto-char (point)
2193 (and point (goto-char point)))
2195 (defmacro gnus-buffer-exists-p (buffer)
2196 `(let ((buffer ,buffer))
2198 (funcall (if (stringp buffer) 'get-buffer 'buffer-name)
2201 (defmacro gnus-kill-buffer (buffer)
2202 `(let ((buf ,buffer))
2203 (if (gnus-buffer-exists-p buf)
2204 (kill-buffer buf))))
2206 (defsubst gnus-point-at-bol ()
2207 "Return point at the beginning of the line."
2214 (defsubst gnus-point-at-eol ()
2215 "Return point at the end of the line."
2222 (defun gnus-alive-p ()
2223 "Say whether Gnus is running or not."
2224 (and gnus-group-buffer
2225 (get-buffer gnus-group-buffer)))
2227 (defun gnus-delete-first (elt list)
2228 "Delete by side effect the first occurrence of ELT as a member of LIST."
2229 (if (equal (car list) elt)
2232 (while (and (cdr list)
2233 (not (equal (cadr list) elt)))
2234 (setq list (cdr list)))
2236 (setcdr list (cddr list)))
2239 ;; Delete the current line (and the next N lines.);
2240 (defmacro gnus-delete-line (&optional n)
2241 `(delete-region (progn (beginning-of-line) (point))
2242 (progn (forward-line ,(or n 1)) (point))))
2244 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
2245 (defvar gnus-init-inhibit nil)
2246 (defun gnus-read-init-file (&optional inhibit-next)
2247 (if gnus-init-inhibit
2248 (setq gnus-init-inhibit nil)
2249 (setq gnus-init-inhibit inhibit-next)
2251 (or (and (file-exists-p gnus-init-file)
2252 ;; Don't try to load a directory.
2253 (not (file-directory-p gnus-init-file)))
2254 (file-exists-p (concat gnus-init-file ".el"))
2255 (file-exists-p (concat gnus-init-file ".elc")))
2257 (load gnus-init-file nil t)
2259 (error "Error in %s: %s" gnus-init-file var))))))
2261 ;; Info access macros.
2263 (defmacro gnus-info-group (info)
2265 (defmacro gnus-info-rank (info)
2267 (defmacro gnus-info-read (info)
2269 (defmacro gnus-info-marks (info)
2271 (defmacro gnus-info-method (info)
2273 (defmacro gnus-info-params (info)
2276 (defmacro gnus-info-level (info)
2277 `(let ((rank (gnus-info-rank ,info)))
2281 (defmacro gnus-info-score (info)
2282 `(let ((rank (gnus-info-rank ,info)))
2283 (or (and (consp rank) (cdr rank)) 0)))
2285 (defmacro gnus-info-set-group (info group)
2286 `(setcar ,info ,group))
2287 (defmacro gnus-info-set-rank (info rank)
2288 `(setcar (nthcdr 1 ,info) ,rank))
2289 (defmacro gnus-info-set-read (info read)
2290 `(setcar (nthcdr 2 ,info) ,read))
2291 (defmacro gnus-info-set-marks (info marks)
2292 `(setcar (nthcdr 3 ,info) ,marks))
2293 (defmacro gnus-info-set-method (info method)
2294 `(setcar (nthcdr 4 ,info) ,method))
2295 (defmacro gnus-info-set-params (info params)
2296 `(setcar (nthcdr 5 ,info) ,params))
2298 (defmacro gnus-info-set-level (info level)
2299 `(let ((rank (cdr ,info)))
2300 (if (consp (car rank))
2301 (setcar (car rank) ,level)
2302 (setcar rank ,level))))
2303 (defmacro gnus-info-set-score (info score)
2304 `(let ((rank (cdr ,info)))
2305 (if (consp (car rank))
2306 (setcdr (car rank) ,score)
2307 (setcar rank (cons (car rank) ,score)))))
2309 (defmacro gnus-get-info (group)
2310 `(nth 2 (gnus-gethash ,group gnus-newsrc-hashtb)))
2312 (defun gnus-byte-code (func)
2313 "Return a form that can be `eval'ed based on FUNC."
2314 (let ((fval (symbol-function func)))
2315 (if (byte-code-function-p fval)
2316 (let ((flist (append fval nil)))
2317 (setcar flist 'byte-code)
2319 (cons 'progn (cddr fval)))))
2321 ;; Find out whether the gnus-visual TYPE is wanted.
2322 (defun gnus-visual-p (&optional type class)
2323 (and gnus-visual ; Has to be non-nil, at least.
2324 (if (not type) ; We don't care about type.
2326 (if (listp gnus-visual) ; It's a list, so we check it.
2327 (or (memq type gnus-visual)
2328 (memq class gnus-visual))
2331 ;;; Load the compatability functions.
2341 (defvar gnus-shutdown-alist nil)
2343 (defun gnus-add-shutdown (function &rest symbols)
2344 "Run FUNCTION whenever one of SYMBOLS is shut down."
2345 (push (cons function symbols) gnus-shutdown-alist))
2347 (defun gnus-shutdown (symbol)
2348 "Shut down everything that waits for SYMBOL."
2349 (let ((alist gnus-shutdown-alist)
2351 (while (setq entry (pop alist))
2352 (when (memq symbol (cdr entry))
2353 (funcall (car entry))))))
2357 ;; Format specs. The chunks below are the machine-generated forms
2358 ;; that are to be evaled as the result of the default format strings.
2359 ;; We write them in here to get them byte-compiled. That way the
2360 ;; default actions will be quite fast, while still retaining the full
2361 ;; flexibility of the user-defined format specs.
2363 ;; First we have lots of dummy defvars to let the compiler know these
2364 ;; are really dynamic variables.
2366 (defvar gnus-tmp-unread)
2367 (defvar gnus-tmp-replied)
2368 (defvar gnus-tmp-score-char)
2369 (defvar gnus-tmp-indentation)
2370 (defvar gnus-tmp-opening-bracket)
2371 (defvar gnus-tmp-lines)
2372 (defvar gnus-tmp-name)
2373 (defvar gnus-tmp-closing-bracket)
2374 (defvar gnus-tmp-subject-or-nil)
2375 (defvar gnus-tmp-subject)
2376 (defvar gnus-tmp-marked)
2377 (defvar gnus-tmp-marked-mark)
2378 (defvar gnus-tmp-subscribed)
2379 (defvar gnus-tmp-process-marked)
2380 (defvar gnus-tmp-number-of-unread)
2381 (defvar gnus-tmp-group-name)
2382 (defvar gnus-tmp-group)
2383 (defvar gnus-tmp-article-number)
2384 (defvar gnus-tmp-unread-and-unselected)
2385 (defvar gnus-tmp-news-method)
2386 (defvar gnus-tmp-news-server)
2387 (defvar gnus-tmp-article-number)
2388 (defvar gnus-mouse-face)
2389 (defvar gnus-mouse-face-prop)
2391 (defun gnus-summary-line-format-spec ()
2392 (insert gnus-tmp-unread gnus-tmp-replied
2393 gnus-tmp-score-char gnus-tmp-indentation)
2394 (gnus-put-text-property
2398 gnus-tmp-opening-bracket
2399 (format "%4d: %-20s"
2401 (if (> (length gnus-tmp-name) 20)
2402 (substring gnus-tmp-name 0 20)
2404 gnus-tmp-closing-bracket)
2406 gnus-mouse-face-prop gnus-mouse-face)
2407 (insert " " gnus-tmp-subject-or-nil "\n"))
2409 (defvar gnus-summary-line-format-spec
2410 (gnus-byte-code 'gnus-summary-line-format-spec))
2412 (defun gnus-summary-dummy-line-format-spec ()
2414 (gnus-put-text-property
2419 gnus-mouse-face-prop gnus-mouse-face)
2420 (insert " " gnus-tmp-subject "\n"))
2422 (defvar gnus-summary-dummy-line-format-spec
2423 (gnus-byte-code 'gnus-summary-dummy-line-format-spec))
2425 (defun gnus-group-line-format-spec ()
2426 (insert gnus-tmp-marked-mark gnus-tmp-subscribed
2427 gnus-tmp-process-marked
2428 gnus-group-indentation
2429 (format "%5s: " gnus-tmp-number-of-unread))
2430 (gnus-put-text-property
2433 (insert gnus-tmp-group "\n")
2435 gnus-mouse-face-prop gnus-mouse-face))
2436 (defvar gnus-group-line-format-spec
2437 (gnus-byte-code 'gnus-group-line-format-spec))
2439 (defvar gnus-format-specs
2440 `((version . ,emacs-version)
2441 (group ,gnus-group-line-format ,gnus-group-line-format-spec)
2442 (summary-dummy ,gnus-summary-dummy-line-format
2443 ,gnus-summary-dummy-line-format-spec)
2444 (summary ,gnus-summary-line-format ,gnus-summary-line-format-spec)))
2446 (defvar gnus-article-mode-line-format-spec nil)
2447 (defvar gnus-summary-mode-line-format-spec nil)
2448 (defvar gnus-group-mode-line-format-spec nil)
2450 ;;; Phew. All that gruft is over, fortunately.
2454 ;;; Gnus Utility Functions
2457 (defun gnus-extract-address-components (from)
2459 ;; First find the address - the thing with the @ in it. This may
2460 ;; not be accurate in mail addresses, but does the trick most of
2461 ;; the time in news messages.
2462 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
2463 (setq address (substring from (match-beginning 0) (match-end 0))))
2464 ;; Then we check whether the "name <address>" format is used.
2466 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2467 ;; Linear white space is not required.
2468 (string-match (concat "[ \t]*<" (regexp-quote address) ">") from)
2469 (and (setq name (substring from 0 (match-beginning 0)))
2470 ;; Strip any quotes from the name.
2471 (string-match "\".*\"" name)
2472 (setq name (substring name 1 (1- (match-end 0))))))
2473 ;; If not, then "address (name)" is used.
2475 (and (string-match "(.+)" from)
2476 (setq name (substring from (1+ (match-beginning 0))
2477 (1- (match-end 0)))))
2478 (and (string-match "()" from)
2479 (setq name address))
2480 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>.
2481 ;; XOVER might not support folded From headers.
2482 (and (string-match "(.*" from)
2483 (setq name (substring from (1+ (match-beginning 0))
2485 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2486 (list (or name from) (or address from))))
2488 (defun gnus-fetch-field (field)
2489 "Return the value of the header FIELD of current article."
2492 (let ((case-fold-search t)
2493 (inhibit-point-motion-hooks t))
2494 (nnheader-narrow-to-headers)
2495 (message-fetch-field field)))))
2497 (defun gnus-goto-colon ()
2499 (search-forward ":" (gnus-point-at-eol) t))
2502 (defun gnus-update-format (var)
2503 "Update the format specification near point."
2508 ;; Find the end of the current word.
2509 (re-search-forward "[ \t\n]" nil t)
2511 (when (re-search-backward "\\(gnus-[-a-z]+-line-format\\)" nil t)
2512 (match-string 1)))))
2513 (let* ((type (intern (progn (string-match "gnus-\\([-a-z]+\\)-line" var)
2514 (match-string 1 var))))
2515 (entry (assq type gnus-format-specs))
2518 (setq gnus-format-specs (delq entry gnus-format-specs)))
2520 (intern (format "%s-spec" var))
2521 (gnus-parse-format (setq value (symbol-value (intern var)))
2522 (symbol-value (intern (format "%s-alist" var)))
2523 (not (string-match "mode" var))))
2524 (setq spec (symbol-value (intern (format "%s-spec" var))))
2525 (push (list type value spec) gnus-format-specs)
2527 (pop-to-buffer "*Gnus Format*")
2529 (lisp-interaction-mode)
2530 (insert (pp-to-string spec))))
2532 (defun gnus-update-format-specifications (&optional force)
2533 "Update all (necessary) format specifications."
2534 ;; Make the indentation array.
2535 (gnus-make-thread-indent-array)
2537 ;; See whether all the stored info needs to be flushed.
2539 (not (equal emacs-version
2540 (cdr (assq 'version gnus-format-specs)))))
2541 (setq gnus-format-specs nil))
2543 ;; Go through all the formats and see whether they need updating.
2544 (let ((types '(summary summary-dummy group
2545 summary-mode group-mode article-mode))
2546 new-format entry type val)
2547 (while (setq type (pop types))
2548 ;; Jump to the proper buffer to find out the value of
2549 ;; the variable, if possible. (It may be buffer-local.)
2551 (let ((buffer (intern (format "gnus-%s-buffer" type)))
2553 (when (and (boundp buffer)
2554 (setq val (symbol-value buffer))
2556 (buffer-name (get-buffer val)))
2557 (set-buffer (get-buffer val)))
2558 (setq new-format (symbol-value
2559 (intern (format "gnus-%s-line-format" type))))))
2560 (setq entry (cdr (assq type gnus-format-specs)))
2562 (equal (car entry) new-format))
2563 ;; Use the old format.
2564 (set (intern (format "gnus-%s-line-format-spec" type))
2566 ;; This is a new format.
2568 (if (not (stringp new-format))
2569 ;; This is a function call or something.
2571 ;; This is a "real" format.
2575 (intern (format "gnus-%s-line-format-alist"
2576 (if (eq type 'article-mode)
2577 'summary-mode type))))
2578 (not (string-match "mode$" (symbol-name type))))))
2579 ;; Enter the new format spec into the list.
2582 (setcar (cdr entry) val)
2583 (setcar entry new-format))
2584 (push (list type new-format val) gnus-format-specs))
2585 (set (intern (format "gnus-%s-line-format-spec" type)) val))))
2587 (unless (assq 'version gnus-format-specs)
2588 (push (cons 'version emacs-version) gnus-format-specs))
2590 (gnus-update-group-mark-positions)
2591 (gnus-update-summary-mark-positions))
2593 (defun gnus-update-summary-mark-positions ()
2594 "Compute where the summary marks are to go."
2596 (when (and gnus-summary-buffer
2597 (get-buffer gnus-summary-buffer)
2598 (buffer-name (get-buffer gnus-summary-buffer)))
2599 (set-buffer gnus-summary-buffer))
2600 (let ((gnus-replied-mark 129)
2601 (gnus-score-below-mark 130)
2602 (gnus-score-over-mark 130)
2605 (spec gnus-summary-line-format-spec)
2608 (gnus-set-work-buffer)
2609 (let ((gnus-summary-line-format-spec spec))
2610 (gnus-summary-insert-line
2611 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2612 (goto-char (point-min))
2613 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2615 (goto-char (point-min))
2616 (push (cons 'replied (and (search-forward "\201" nil t)
2619 (goto-char (point-min))
2620 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2622 (setq gnus-summary-mark-positions pos))))
2624 (defun gnus-update-group-mark-positions ()
2626 (let ((gnus-process-mark 128)
2627 (gnus-group-marked '("dummy.group"))
2628 (gnus-active-hashtb (make-vector 10 0)))
2629 (gnus-set-active "dummy.group" '(0 . 0))
2630 (gnus-set-work-buffer)
2631 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
2632 (goto-char (point-min))
2633 (setq gnus-group-mark-positions
2634 (list (cons 'process (and (search-forward "\200" nil t)
2635 (- (point) 2))))))))
2637 (defvar gnus-mouse-face-0 'highlight)
2638 (defvar gnus-mouse-face-1 'highlight)
2639 (defvar gnus-mouse-face-2 'highlight)
2640 (defvar gnus-mouse-face-3 'highlight)
2641 (defvar gnus-mouse-face-4 'highlight)
2643 (defun gnus-mouse-face-function (form type)
2644 `(gnus-put-text-property
2645 (point) (progn ,@form (point))
2646 gnus-mouse-face-prop
2649 `(quote ,(symbol-value (intern (format "gnus-mouse-face-%d" type)))))))
2651 (defvar gnus-face-0 'bold)
2652 (defvar gnus-face-1 'italic)
2653 (defvar gnus-face-2 'bold-italic)
2654 (defvar gnus-face-3 'bold)
2655 (defvar gnus-face-4 'bold)
2657 (defun gnus-face-face-function (form type)
2658 `(gnus-put-text-property
2659 (point) (progn ,@form (point))
2660 'face ',(symbol-value (intern (format "gnus-face-%d" type)))))
2662 (defun gnus-max-width-function (el max-width)
2663 (or (numberp max-width) (signal 'wrong-type-argument '(numberp max-width)))
2665 `(if (> (length ,el) ,max-width)
2666 (substring ,el 0 ,max-width)
2668 `(let ((val (eval ,el)))
2670 (setq val (int-to-string val)))
2671 (if (> (length val) ,max-width)
2672 (substring val 0 ,max-width)
2675 (defun gnus-parse-format (format spec-alist &optional insert)
2676 ;; This function parses the FORMAT string with the help of the
2677 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
2678 ;; string. If the FORMAT string contains the specifiers %( and %)
2679 ;; the text between them will have the mouse-face text property.
2681 "\\`\\(.*\\)%[0-9]?[{(]\\(.*\\)%[0-9]?[})]\\(.*\n?\\)\\'"
2683 (gnus-parse-complex-format format spec-alist)
2684 ;; This is a simple format.
2685 (gnus-parse-simple-format format spec-alist insert)))
2687 (defun gnus-parse-complex-format (format spec-alist)
2689 (gnus-set-work-buffer)
2691 (goto-char (point-min))
2692 (while (re-search-forward "\"" nil t)
2693 (replace-match "\\\"" nil t))
2694 (goto-char (point-min))
2696 (while (re-search-forward "%\\([0-9]+\\)?\\([{}()]\\)" nil t)
2697 (let ((number (if (match-beginning 1)
2698 (match-string 1) "0"))
2699 (delim (aref (match-string 2) 0)))
2700 (if (or (= delim ?\() (= delim ?\{))
2701 (replace-match (concat "\"(" (if (= delim ?\() "mouse" "face")
2703 (replace-match "\")\""))))
2704 (goto-char (point-max))
2706 (goto-char (point-min))
2707 (let ((form (read (current-buffer))))
2708 (cons 'progn (gnus-complex-form-to-spec form spec-alist)))))
2710 (defun gnus-complex-form-to-spec (form spec-alist)
2715 (gnus-parse-simple-format sform spec-alist t)
2716 (funcall (intern (format "gnus-%s-face-function" (car sform)))
2717 (gnus-complex-form-to-spec (cddr sform) spec-alist)
2721 (defun gnus-parse-simple-format (format spec-alist &optional insert)
2722 ;; This function parses the FORMAT string with the help of the
2723 ;; SPEC-ALIST and returns a list that can be eval'ed to return a
2726 spec flist fstring newspec elem beg result dontinsert)
2728 (gnus-set-work-buffer)
2730 (goto-char (point-min))
2731 (while (re-search-forward "%[-0-9]*\\(,[0-9]+\\)?\\([^0-9]\\)\\(.\\)?"
2733 (if (= (setq spec (string-to-char (match-string 2))) ?%)
2735 beg (1+ (match-beginning 0)))
2736 ;; First check if there are any specs that look anything like
2737 ;; "%12,12A", ie. with a "max width specification". These have
2738 ;; to be treated specially.
2739 (if (setq beg (match-beginning 1))
2743 (1+ (match-beginning 1)) (match-end 1))))
2745 (setq beg (match-beginning 2)))
2746 ;; Find the specification from `spec-alist'.
2747 (unless (setq elem (cdr (assq spec spec-alist)))
2748 (setq elem '("*" ?s)))
2749 ;; Treat user defined format specifiers specially.
2750 (when (eq (car elem) 'gnus-tmp-user-defined)
2753 (list (intern (concat "gnus-user-format-function-"
2755 'gnus-tmp-header) ?s))
2756 (delete-region (match-beginning 3) (match-end 3)))
2757 (if (not (zerop max-width))
2758 (let ((el (car elem)))
2759 (cond ((= (cadr elem) ?c)
2760 (setq el (list 'char-to-string el)))
2762 (setq el (list 'int-to-string el))))
2763 (setq flist (cons (gnus-max-width-function el max-width)
2767 (setq flist (cons (car elem) flist))
2768 (setq newspec (cadr elem)))))
2769 ;; Remove the old specification (and possibly a ",12" string).
2770 (delete-region beg (match-end 2))
2771 ;; Insert the new specification.
2774 (setq fstring (buffer-substring 1 (point-max))))
2775 ;; Do some postprocessing to increase efficiency.
2780 ((string= fstring "")
2782 ;; Not a format string.
2783 ((not (string-match "%" fstring))
2785 ;; A format string with just a single string spec.
2786 ((string= fstring "%s")
2788 ;; A single character.
2789 ((string= fstring "%c")
2792 ((string= fstring "%d")
2795 (list `(princ ,(car flist)))
2796 (list `(int-to-string ,(car flist)))))
2797 ;; Just lots of chars and strings.
2798 ((string-match "\\`\\(%[cs]\\)+\\'" fstring)
2800 ;; A single string spec at the beginning of the spec.
2801 ((string-match "\\`%[sc][^%]+\\'" fstring)
2802 (list (car flist) (substring fstring 2)))
2803 ;; A single string spec in the middle of the spec.
2804 ((string-match "\\`\\([^%]+\\)%[sc]\\([^%]+\\)\\'" fstring)
2805 (list (match-string 1 fstring) (car flist) (match-string 2 fstring)))
2806 ;; A single string spec in the end of the spec.
2807 ((string-match "\\`\\([^%]+\\)%[sc]\\'" fstring)
2808 (list (match-string 1 fstring) (car flist)))
2809 ;; A more complex spec.
2811 (list (cons 'format (cons fstring (nreverse flist)))))))
2817 (cons 'insert result)))
2818 (cond ((stringp result)
2821 (cons 'concat result))
2824 (defun gnus-eval-format (format &optional alist props)
2825 "Eval the format variable FORMAT, using ALIST.
2826 If PROPS, insert the result."
2827 (let ((form (gnus-parse-format format alist props)))
2829 (gnus-add-text-properties (point) (progn (eval form) (point)) props)
2832 (defun gnus-remove-text-with-property (prop)
2833 "Delete all text in the current buffer with text property PROP."
2835 (goto-char (point-min))
2837 (while (get-text-property (point) prop)
2839 (goto-char (next-single-property-change (point) prop nil (point-max))))))
2841 (defun gnus-set-work-buffer ()
2842 (if (get-buffer gnus-work-buffer)
2844 (set-buffer gnus-work-buffer)
2846 (set-buffer (get-buffer-create gnus-work-buffer))
2847 (kill-all-local-variables)
2848 (buffer-disable-undo (current-buffer))
2849 (gnus-add-current-to-buffer-list)))
2851 ;; Article file names when saving.
2853 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2854 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2855 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
2856 Otherwise, it is like ~/News/news/group/num."
2859 (concat (if (gnus-use-long-file-name 'not-save)
2860 (gnus-capitalize-newsgroup newsgroup)
2861 (gnus-newsgroup-directory-form newsgroup))
2862 "/" (int-to-string (mail-header-number headers)))
2863 gnus-article-save-directory)))
2865 (string-equal (file-name-directory default)
2866 (file-name-directory last-file))
2867 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2869 (or last-file default))))
2871 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2872 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2873 If variable `gnus-use-long-file-name' is non-nil, it is
2874 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2877 (concat (if (gnus-use-long-file-name 'not-save)
2879 (gnus-newsgroup-directory-form newsgroup))
2880 "/" (int-to-string (mail-header-number headers)))
2881 gnus-article-save-directory)))
2883 (string-equal (file-name-directory default)
2884 (file-name-directory last-file))
2885 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2887 (or last-file default))))
2889 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2890 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2891 If variable `gnus-use-long-file-name' is non-nil, it is
2892 ~/News/News.group. Otherwise, it is like ~/News/news/group/news."
2895 (if (gnus-use-long-file-name 'not-save)
2896 (gnus-capitalize-newsgroup newsgroup)
2897 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2898 gnus-article-save-directory)))
2900 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2901 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2902 If variable `gnus-use-long-file-name' is non-nil, it is
2903 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2906 (if (gnus-use-long-file-name 'not-save)
2908 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2909 gnus-article-save-directory)))
2911 ;; For subscribing new newsgroup
2913 (defun gnus-subscribe-hierarchical-interactive (groups)
2914 (let ((groups (sort groups 'string<))
2915 prefixes prefix start ans group starts)
2917 (setq prefixes (list "^"))
2918 (while (and groups prefixes)
2919 (while (not (string-match (car prefixes) (car groups)))
2920 (setq prefixes (cdr prefixes)))
2921 (setq prefix (car prefixes))
2922 (setq start (1- (length prefix)))
2923 (if (and (string-match "[^\\.]\\." (car groups) start)
2926 (concat "^" (substring (car groups) 0 (match-end 0))))
2927 (string-match prefix (cadr groups)))
2929 (setq prefixes (cons prefix prefixes))
2930 (message "Descend hierarchy %s? ([y]nsq): "
2931 (substring prefix 1 (1- (length prefix))))
2932 (while (not (memq (setq ans (read-char)) '(?y ?\n ?n ?s ?q)))
2934 (message "Descend hierarchy %s? ([y]nsq): "
2935 (substring prefix 1 (1- (length prefix)))))
2938 (string-match prefix
2939 (setq group (car groups))))
2940 (setq gnus-killed-list
2941 (cons group gnus-killed-list))
2942 (gnus-sethash group group gnus-killed-hashtb)
2943 (setq groups (cdr groups)))
2944 (setq starts (cdr starts)))
2947 (string-match prefix
2948 (setq group (car groups))))
2949 (gnus-sethash group group gnus-killed-hashtb)
2950 (gnus-subscribe-alphabetically (car groups))
2951 (setq groups (cdr groups)))
2952 (setq starts (cdr starts)))
2955 (setq group (car groups))
2956 (setq gnus-killed-list (cons group gnus-killed-list))
2957 (gnus-sethash group group gnus-killed-hashtb)
2958 (setq groups (cdr groups))))
2960 (message "Subscribe %s? ([n]yq)" (car groups))
2961 (while (not (memq (setq ans (read-char)) '(?y ?\n ?q ?n)))
2963 (message "Subscribe %s? ([n]yq)" (car groups)))
2964 (setq group (car groups))
2966 (gnus-subscribe-alphabetically (car groups))
2967 (gnus-sethash group group gnus-killed-hashtb))
2970 (setq group (car groups))
2971 (setq gnus-killed-list (cons group gnus-killed-list))
2972 (gnus-sethash group group gnus-killed-hashtb)
2973 (setq groups (cdr groups))))
2975 (setq gnus-killed-list (cons group gnus-killed-list))
2976 (gnus-sethash group group gnus-killed-hashtb)))
2977 (setq groups (cdr groups)))))))
2979 (defun gnus-subscribe-randomly (newsgroup)
2980 "Subscribe new NEWSGROUP by making it the first newsgroup."
2981 (gnus-subscribe-newsgroup newsgroup))
2983 (defun gnus-subscribe-alphabetically (newgroup)
2984 "Subscribe new NEWSGROUP and insert it in alphabetical order."
2985 (let ((groups (cdr gnus-newsrc-alist))
2987 (while (and (not before) groups)
2988 (if (string< newgroup (caar groups))
2989 (setq before (caar groups))
2990 (setq groups (cdr groups))))
2991 (gnus-subscribe-newsgroup newgroup before)))
2993 (defun gnus-subscribe-hierarchically (newgroup)
2994 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
2995 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2997 (set-buffer (find-file-noselect gnus-current-startup-file))
2998 (let ((groupkey newgroup)
3000 (while (and (not before) groupkey)
3001 (goto-char (point-min))
3003 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
3004 (while (and (re-search-forward groupkey-re nil t)
3006 (setq before (match-string 1))
3007 (string< before newgroup)))))
3008 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
3010 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
3011 (substring groupkey (match-beginning 1) (match-end 1)))))
3012 (gnus-subscribe-newsgroup newgroup before))))
3014 (defun gnus-subscribe-interactively (group)
3015 "Subscribe the new GROUP interactively.
3016 It is inserted in hierarchical newsgroup order if subscribed. If not,
3018 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " group))
3019 (gnus-subscribe-hierarchically group)
3020 (push group gnus-killed-list)))
3022 (defun gnus-subscribe-zombies (group)
3023 "Make the new GROUP into a zombie group."
3024 (push group gnus-zombie-list))
3026 (defun gnus-subscribe-killed (group)
3027 "Make the new GROUP a killed group."
3028 (push group gnus-killed-list))
3030 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
3031 "Subscribe new NEWSGROUP.
3032 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
3033 the first newsgroup."
3034 ;; We subscribe the group by changing its level to `subscribed'.
3035 (gnus-group-change-level
3036 newsgroup gnus-level-default-subscribed
3037 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
3038 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))
3042 (defun gnus-newsgroup-directory-form (newsgroup)
3043 "Make hierarchical directory name from NEWSGROUP name."
3044 (let ((newsgroup (gnus-newsgroup-savable-name newsgroup))
3045 (len (length newsgroup))
3047 ;; If this is a foreign group, we don't want to translate the
3049 (if (setq idx (string-match ":" newsgroup))
3050 (aset newsgroup idx ?/)
3052 ;; Replace all occurrences of `.' with `/'.
3054 (if (= (aref newsgroup idx) ?.)
3055 (aset newsgroup idx ?/))
3056 (setq idx (1+ idx)))
3059 (defun gnus-newsgroup-savable-name (group)
3060 ;; Replace any slashes in a group name (eg. an ange-ftp nndoc group)
3062 (nnheader-replace-chars-in-string group ?/ ?.))
3064 (defun gnus-make-directory (dir)
3065 "Make DIRECTORY recursively."
3066 ;; Why don't we use `(make-directory dir 'parents)'? That's just one
3067 ;; of the many mysteries of the universe.
3068 (let* ((dir (expand-file-name dir default-directory))
3070 (if (string-match "/$" dir)
3071 (setq dir (substring dir 0 (match-beginning 0))))
3072 ;; First go down the path until we find a directory that exists.
3073 (while (not (file-exists-p dir))
3074 (setq dirs (cons dir dirs))
3075 (string-match "/[^/]+$" dir)
3076 (setq dir (substring dir 0 (match-beginning 0))))
3077 ;; Then create all the subdirs.
3078 (while (and dirs (not err))
3080 (make-directory (car dirs))
3081 (error (setq err t)))
3082 (setq dirs (cdr dirs)))
3083 ;; We return whether we were successful or not.
3086 (defun gnus-capitalize-newsgroup (newsgroup)
3087 "Capitalize NEWSGROUP name."
3088 (and (not (zerop (length newsgroup)))
3089 (concat (char-to-string (upcase (aref newsgroup 0)))
3090 (substring newsgroup 1))))
3092 ;; Various... things.
3094 (defun gnus-simplify-subject (subject &optional re-only)
3095 "Remove `Re:' and words in parentheses.
3096 If RE-ONLY is non-nil, strip leading `Re:'s only."
3097 (let ((case-fold-search t)) ;Ignore case.
3098 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
3099 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
3100 (setq subject (substring subject (match-end 0))))
3101 ;; Remove uninteresting prefixes.
3102 (if (and (not re-only)
3103 gnus-simplify-ignored-prefixes
3104 (string-match gnus-simplify-ignored-prefixes subject))
3105 (setq subject (substring subject (match-end 0))))
3106 ;; Remove words in parentheses from end.
3108 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
3109 (setq subject (substring subject 0 (match-beginning 0)))))
3110 ;; Return subject string.
3113 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
3115 ;; Written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
3116 (defun gnus-simplify-buffer-fuzzy ()
3117 (let ((case-fold-search t))
3118 (goto-char (point-min))
3119 (while (search-forward "\t" nil t)
3120 (replace-match " " t t))
3121 (goto-char (point-min))
3122 (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *" nil t)
3123 (goto-char (match-beginning 0))
3125 (looking-at "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
3126 (looking-at "^[[].*: .*[]]$"))
3127 (goto-char (point-min))
3128 (while (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *"
3130 (replace-match "" t t))
3131 (goto-char (point-min))
3132 (while (re-search-forward "^[[].*: .*[]]$" nil t)
3133 (goto-char (match-end 0))
3136 (progn (goto-char (match-beginning 0)))
3137 (re-search-forward ":"))))
3138 (goto-char (point-min))
3139 (while (re-search-forward " *[[{(][^()\n]*[]})] *$" nil t)
3140 (replace-match "" t t))
3141 (goto-char (point-min))
3142 (while (re-search-forward " +" nil t)
3143 (replace-match " " t t))
3144 (goto-char (point-min))
3145 (while (re-search-forward " $" nil t)
3146 (replace-match "" t t))
3147 (goto-char (point-min))
3148 (while (re-search-forward "^ +" nil t)
3149 (replace-match "" t t))
3150 (goto-char (point-min))
3151 (when gnus-simplify-subject-fuzzy-regexp
3152 (if (listp gnus-simplify-subject-fuzzy-regexp)
3153 (let ((list gnus-simplify-subject-fuzzy-regexp))
3155 (goto-char (point-min))
3156 (while (re-search-forward (car list) nil t)
3157 (replace-match "" t t))
3158 (setq list (cdr list))))
3159 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
3160 (replace-match "" t t))))))
3162 (defun gnus-simplify-subject-fuzzy (subject)
3163 "Siplify a subject string fuzzily."
3165 (gnus-set-work-buffer)
3166 (let ((case-fold-search t))
3168 (inline (gnus-simplify-buffer-fuzzy))
3171 ;; Add the current buffer to the list of buffers to be killed on exit.
3172 (defun gnus-add-current-to-buffer-list ()
3173 (or (memq (current-buffer) gnus-buffer-list)
3174 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list))))
3176 (defun gnus-string> (s1 s2)
3177 (not (or (string< s1 s2)
3180 (defun gnus-read-active-file-p ()
3181 "Say whether the active file has been read from `gnus-select-method'."
3182 (memq gnus-select-method gnus-have-read-active-file))
3184 ;;; General various misc type functions.
3186 (defun gnus-clear-system ()
3187 "Clear all variables and buffers."
3188 ;; Clear Gnus variables.
3189 (let ((variables gnus-variable-list))
3191 (set (car variables) nil)
3192 (setq variables (cdr variables))))
3193 ;; Clear other internal variables.
3194 (setq gnus-list-of-killed-groups nil
3195 gnus-have-read-active-file nil
3196 gnus-newsrc-alist nil
3197 gnus-newsrc-hashtb nil
3198 gnus-killed-list nil
3199 gnus-zombie-list nil
3200 gnus-killed-hashtb nil
3201 gnus-active-hashtb nil
3202 gnus-moderated-list nil
3203 gnus-description-hashtb nil
3204 gnus-current-headers nil
3205 gnus-thread-indent-array nil
3206 gnus-newsgroup-headers nil
3207 gnus-newsgroup-name nil
3208 gnus-server-alist nil
3209 gnus-group-list-mode nil
3210 gnus-opened-servers nil
3211 gnus-current-select-method nil)
3212 (gnus-shutdown 'gnus)
3213 ;; Kill the startup file.
3214 (and gnus-current-startup-file
3215 (get-file-buffer gnus-current-startup-file)
3216 (kill-buffer (get-file-buffer gnus-current-startup-file)))
3217 ;; Clear the dribble buffer.
3218 (gnus-dribble-clear)
3219 ;; Kill global KILL file buffer.
3220 (when (get-file-buffer (gnus-newsgroup-kill-file nil))
3221 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
3222 (gnus-kill-buffer nntp-server-buffer)
3223 ;; Kill Gnus buffers.
3224 (while gnus-buffer-list
3225 (gnus-kill-buffer (pop gnus-buffer-list)))
3226 ;; Remove Gnus frames.
3227 (while gnus-created-frames
3228 (when (frame-live-p (car gnus-created-frames))
3229 ;; We slap a condition-case around this `delete-frame' to ensure
3230 ;; agains errors if we try do delete the single frame that's left.
3232 (delete-frame (car gnus-created-frames))
3234 (pop gnus-created-frames)))
3236 (defun gnus-windows-old-to-new (setting)
3237 ;; First we take care of the really, really old Gnus 3 actions.
3238 (when (symbolp setting)
3240 ;; Take care of ooold GNUS 3.x values.
3241 (cond ((eq setting 'SelectArticle) 'article)
3242 ((memq setting '(SelectSubject ExpandSubject)) 'summary)
3243 ((memq setting '(SelectNewsgroup ExitNewsgroup)) 'group)
3245 (if (or (listp setting)
3246 (not (and gnus-window-configuration
3247 (memq setting '(group summary article)))))
3249 (let* ((setting (if (eq setting 'group)
3250 (if (assq 'newsgroup gnus-window-configuration)
3252 'newsgroups) setting))
3253 (elem (cadr (assq setting gnus-window-configuration)))
3254 (total (apply '+ elem))
3255 (types '(group summary article))
3256 (pbuf (if (eq setting 'newsgroups) 'group 'summary))
3261 (or (not (numberp (nth i elem)))
3262 (zerop (nth i elem))
3264 (setq perc (/ (float (nth 0 elem)) total))
3265 (setq out (cons (if (eq pbuf (nth i types))
3266 (vector (nth i types) perc 'point)
3267 (vector (nth i types) perc))
3270 (list (nreverse out)))))
3273 (defun gnus-add-configuration (conf)
3274 "Add the window configuration CONF to `gnus-buffer-configuration'."
3275 (setq gnus-buffer-configuration
3276 (cons conf (delq (assq (car conf) gnus-buffer-configuration)
3277 gnus-buffer-configuration))))
3279 (defvar gnus-frame-list nil)
3281 (defun gnus-configure-frame (split &optional window)
3282 "Split WINDOW according to SPLIT."
3284 (setq window (get-buffer-window (current-buffer))))
3285 (select-window window)
3286 ;; This might be an old-stylee buffer config.
3287 (when (vectorp split)
3288 (setq split (append split nil)))
3289 (when (or (consp (car split))
3290 (vectorp (car split)))
3292 (push 'vertical split))
3293 ;; The SPLIT might be something that is to be evaled to
3294 ;; return a new SPLIT.
3295 (while (and (not (assq (car split) gnus-window-to-buffer))
3296 (gnus-functionp (car split)))
3297 (setq split (eval split)))
3298 (let* ((type (car split))
3300 (len (if (eq type 'horizontal) (window-width) (window-height)))
3302 (window-min-width (or gnus-window-min-width window-min-width))
3303 (window-min-height (or gnus-window-min-height window-min-height))
3304 s result new-win rest comp-subs size sub)
3306 ;; Nothing to do here.
3308 ;; Don't switch buffers.
3310 (and (memq 'point split) window))
3311 ;; This is a buffer to be selected.
3312 ((not (memq type '(frame horizontal vertical)))
3313 (let ((buffer (cond ((stringp type) type)
3314 (t (cdr (assq type gnus-window-to-buffer)))))
3317 (error "Illegal buffer type: %s" type))
3318 (unless (setq buf (get-buffer (if (symbolp buffer)
3319 (symbol-value buffer) buffer)))
3320 (setq buf (get-buffer-create (if (symbolp buffer)
3321 (symbol-value buffer) buffer))))
3322 (switch-to-buffer buf)
3323 ;; We return the window if it has the `point' spec.
3324 (and (memq 'point split) window)))
3325 ;; This is a frame split.
3327 (unless gnus-frame-list
3328 (setq gnus-frame-list (list (window-frame
3329 (get-buffer-window (current-buffer))))))
3331 params frame fresult)
3332 (while (< i (length subs))
3333 ;; Frame parameter is gotten from the sub-split.
3334 (setq params (cadr (elt subs i)))
3335 ;; It should be a list.
3336 (unless (listp params)
3338 ;; Create a new frame?
3339 (unless (setq frame (elt gnus-frame-list i))
3340 (nconc gnus-frame-list (list (setq frame (make-frame params))))
3341 (push frame gnus-created-frames))
3342 ;; Is the old frame still alive?
3343 (unless (frame-live-p frame)
3344 (setcar (nthcdr i gnus-frame-list)
3345 (setq frame (make-frame params))))
3346 ;; Select the frame in question and do more splits there.
3347 (select-frame frame)
3348 (setq fresult (or (gnus-configure-frame (elt subs i)) fresult))
3350 ;; Select the frame that has the selected buffer.
3352 (select-frame (window-frame fresult)))))
3353 ;; This is a normal split.
3355 (when (> (length subs) 0)
3356 ;; First we have to compute the sizes of all new windows.
3358 (setq sub (append (pop subs) nil))
3359 (while (and (not (assq (car sub) gnus-window-to-buffer))
3360 (gnus-functionp (car sub)))
3361 (setq sub (eval sub)))
3363 (push sub comp-subs)
3364 (setq size (cadar comp-subs))
3365 (cond ((equal size 1.0)
3366 (setq rest (car comp-subs))
3369 (setq s (floor (* size len))))
3373 (error "Illegal size: %s" size)))
3374 ;; Try to make sure that we are inside the safe limits.
3376 ((eq type 'horizontal)
3377 (setq s (max s window-min-width)))
3378 ((eq type 'vertical)
3379 (setq s (max s window-min-height))))
3380 (setcar (cdar comp-subs) s)
3382 ;; Take care of the "1.0" spec.
3384 (setcar (cdr rest) (- len total))
3385 (error "No 1.0 specs in %s" split))
3386 ;; The we do the actual splitting in a nice recursive
3388 (setq comp-subs (nreverse comp-subs))
3390 (if (null (cdr comp-subs))
3391 (setq new-win window)
3393 (split-window window (cadar comp-subs)
3394 (eq type 'horizontal))))
3395 (setq result (or (gnus-configure-frame
3396 (car comp-subs) window) result))
3397 (select-window new-win)
3398 (setq window new-win)
3399 (setq comp-subs (cdr comp-subs))))
3400 ;; Return the proper window, if any.
3402 (select-window result))))))
3404 (defvar gnus-frame-split-p nil)
3406 (defun gnus-configure-windows (setting &optional force)
3407 (setq setting (gnus-windows-old-to-new setting))
3408 (let ((split (if (symbolp setting)
3409 (cadr (assq setting gnus-buffer-configuration))
3413 (setq gnus-frame-split-p nil)
3416 (error "No such setting: %s" setting))
3418 (if (and (setq all-visible (gnus-all-windows-visible-p split))
3420 ;; All the windows mentioned are already visible, so we just
3421 ;; put point in the assigned buffer, and do not touch the
3423 (select-window all-visible)
3425 ;; Either remove all windows or just remove all Gnus windows.
3426 (let ((frame (selected-frame)))
3428 (if gnus-use-full-window
3429 ;; We want to remove all other windows.
3430 (if (not gnus-frame-split-p)
3431 ;; This is not a `frame' split, so we ignore the
3433 (delete-other-windows)
3434 ;; This is a `frame' split, so we delete all windows
3438 (unless (eq (cdr (assq 'minibuffer
3439 (frame-parameters frame)))
3441 (select-frame frame)
3442 (delete-other-windows)))
3444 ;; Just remove some windows.
3445 (gnus-remove-some-windows)
3446 (switch-to-buffer nntp-server-buffer))
3447 (select-frame frame)))
3449 (switch-to-buffer nntp-server-buffer)
3450 (gnus-configure-frame split (get-buffer-window (current-buffer))))))
3452 (defun gnus-all-windows-visible-p (split)
3453 "Say whether all buffers in SPLIT are currently visible.
3454 In particular, the value returned will be the window that
3456 (let ((stack (list split))
3458 type buffer win buf)
3459 (while (and (setq split (pop stack))
3461 ;; Be backwards compatible.
3462 (when (vectorp split)
3463 (setq split (append split nil)))
3464 (when (or (consp (car split))
3465 (vectorp (car split)))
3467 (push 'vertical split))
3468 ;; The SPLIT might be something that is to be evaled to
3469 ;; return a new SPLIT.
3470 (while (and (not (assq (car split) gnus-window-to-buffer))
3471 (gnus-functionp (car split)))
3472 (setq split (eval split)))
3474 (setq type (elt split 0))
3479 ((not (memq type '(horizontal vertical frame)))
3480 (setq buffer (cond ((stringp type) type)
3481 (t (cdr (assq type gnus-window-to-buffer)))))
3483 (error "Illegal buffer type: %s" type))
3484 (when (setq buf (get-buffer (if (symbolp buffer)
3485 (symbol-value buffer)
3487 (setq win (get-buffer-window buf t)))
3489 (when (memq 'point split)
3490 (setq all-visible win))
3491 (setq all-visible nil)))
3493 (when (eq type 'frame)
3494 (setq gnus-frame-split-p t))
3495 (setq stack (append (cddr split) stack)))))
3496 (unless (eq all-visible t)
3499 (defun gnus-window-top-edge (&optional window)
3500 (nth 1 (window-edges window)))
3502 (defun gnus-remove-some-windows ()
3503 (let ((buffers gnus-window-to-buffer)
3504 buf bufs lowest-buf lowest)
3506 ;; Remove windows on all known Gnus buffers.
3508 (setq buf (cdar buffers))
3510 (setq buf (and (boundp buf) (symbol-value buf))))
3512 (get-buffer-window buf)
3514 (setq bufs (cons buf bufs))
3516 (if (or (not lowest)
3517 (< (gnus-window-top-edge) lowest))
3519 (setq lowest (gnus-window-top-edge))
3520 (setq lowest-buf buf)))))
3521 (setq buffers (cdr buffers)))
3522 ;; Remove windows on *all* summary buffers.
3525 (let ((buf (window-buffer win)))
3526 (if (string-match "^\\*Summary" (buffer-name buf))
3528 (setq bufs (cons buf bufs))
3530 (if (or (not lowest)
3531 (< (gnus-window-top-edge) lowest))
3533 (setq lowest-buf buf)
3534 (setq lowest (gnus-window-top-edge)))))))))
3537 (pop-to-buffer lowest-buf)
3538 (switch-to-buffer nntp-server-buffer)))
3540 (and (not (eq (car bufs) lowest-buf))
3541 (delete-windows-on (car bufs)))
3542 (setq bufs (cdr bufs))))))
3544 (defun gnus-version (&optional arg)
3545 "Version number of this version of Gnus.
3546 If ARG, insert string at point."
3548 (let ((methods gnus-valid-select-methods)
3551 ;; Go through all the legal select methods and add their version
3552 ;; numbers to the total version string. Only the backends that are
3553 ;; currently in use will have their message numbers taken into
3556 (setq meth (intern (concat (caar methods) "-version")))
3558 (stringp (symbol-value meth))
3559 (setq mess (concat mess "; " (symbol-value meth))))
3560 (setq methods (cdr methods)))
3562 (insert (message mess))
3565 (defun gnus-info-find-node ()
3566 "Find Info documentation of Gnus."
3568 ;; Enlarge info window if needed.
3569 (let ((mode major-mode)
3571 (Info-goto-node (cadr (assq mode gnus-info-nodes)))
3572 (setq gnus-info-buffer (current-buffer))
3573 (gnus-configure-windows 'info)))
3575 (defun gnus-days-between (date1 date2)
3576 ;; Return the number of days between date1 and date2.
3577 (- (gnus-day-number date1) (gnus-day-number date2)))
3579 (defun gnus-day-number (date)
3580 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
3581 (timezone-parse-date date))))
3582 (timezone-absolute-from-gregorian
3583 (nth 1 dat) (nth 2 dat) (car dat))))
3585 (defun gnus-encode-date (date)
3586 "Convert DATE to internal time."
3587 (let* ((parse (timezone-parse-date date))
3588 (date (mapcar (lambda (d) (and d (string-to-int d))) parse))
3589 (time (mapcar 'string-to-int (timezone-parse-time (aref parse 3)))))
3590 (encode-time (caddr time) (cadr time) (car time)
3591 (caddr date) (cadr date) (car date) (nth 4 date))))
3593 (defun gnus-time-minus (t1 t2)
3594 "Subtract two internal times."
3595 (let ((borrow (< (cadr t1) (cadr t2))))
3596 (list (- (car t1) (car t2) (if borrow 1 0))
3597 (- (+ (if borrow 65536 0) (cadr t1)) (cadr t2)))))
3599 (defun gnus-file-newer-than (file date)
3600 (let ((fdate (nth 5 (file-attributes file))))
3601 (or (> (car fdate) (car date))
3602 (and (= (car fdate) (car date))
3603 (> (nth 1 fdate) (nth 1 date))))))
3605 (defmacro gnus-local-set-keys (&rest plist)
3606 "Set the keys in PLIST in the current keymap."
3607 `(gnus-define-keys-1 (current-local-map) ',plist))
3609 (defmacro gnus-define-keys (keymap &rest plist)
3610 "Define all keys in PLIST in KEYMAP."
3611 `(gnus-define-keys-1 (quote ,keymap) (quote ,plist)))
3613 (put 'gnus-define-keys 'lisp-indent-function 1)
3614 (put 'gnus-define-keys 'lisp-indent-hook 1)
3615 (put 'gnus-define-keymap 'lisp-indent-function 1)
3616 (put 'gnus-define-keymap 'lisp-indent-hook 1)
3618 (defmacro gnus-define-keymap (keymap &rest plist)
3619 "Define all keys in PLIST in KEYMAP."
3620 `(gnus-define-keys-1 ,keymap (quote ,plist)))
3622 (defun gnus-define-keys-1 (keymap plist)
3624 (error "Can't set keys in a null keymap"))
3625 (cond ((symbolp keymap)
3626 (setq keymap (symbol-value keymap)))
3629 (set (car keymap) nil)
3630 (define-prefix-command (car keymap))
3631 (define-key (symbol-value (caddr keymap)) (cadr keymap) (car keymap))
3632 (setq keymap (symbol-value (car keymap)))))
3635 (when (symbolp (setq key (pop plist)))
3636 (setq key (symbol-value key)))
3637 (define-key keymap key (pop plist)))))
3639 (defun gnus-group-read-only-p (&optional group)
3640 "Check whether GROUP supports editing or not.
3641 If GROUP is nil, `gnus-newsgroup-name' will be checked instead. Note
3642 that that variable is buffer-local to the summary buffers."
3643 (let ((group (or group gnus-newsgroup-name)))
3644 (not (gnus-check-backend-function 'request-replace-article group))))
3646 (defun gnus-group-total-expirable-p (group)
3647 "Check whether GROUP is total-expirable or not."
3648 (let ((params (gnus-info-params (gnus-get-info group))))
3649 (or (memq 'total-expire params)
3650 (cdr (assq 'total-expire params)) ; (total-expire . t)
3651 (and gnus-total-expirable-newsgroups ; Check var.
3652 (string-match gnus-total-expirable-newsgroups group)))))
3654 (defun gnus-group-auto-expirable-p (group)
3655 "Check whether GROUP is total-expirable or not."
3656 (let ((params (gnus-info-params (gnus-get-info group))))
3657 (or (memq 'auto-expire params)
3658 (cdr (assq 'auto-expire params)) ; (auto-expire . t)
3659 (and gnus-auto-expirable-newsgroups ; Check var.
3660 (string-match gnus-auto-expirable-newsgroups group)))))
3662 (defun gnus-virtual-group-p (group)
3663 "Say whether GROUP is virtual or not."
3664 (memq 'virtual (assoc (symbol-name (car (gnus-find-method-for-group group)))
3665 gnus-valid-select-methods)))
3667 (defun gnus-news-group-p (group &optional article)
3668 "Return non-nil if GROUP (and ARTICLE) come from a news server."
3669 (or (gnus-member-of-valid 'post group) ; Ordinary news group.
3670 (and (gnus-member-of-valid 'post-mail group) ; Combined group.
3671 (eq (gnus-request-type group article) 'news))))
3673 (defsubst gnus-simplify-subject-fully (subject)
3674 "Simplify a subject string according to the user's wishes."
3676 ((null gnus-summary-gather-subject-limit)
3677 (gnus-simplify-subject-re subject))
3678 ((eq gnus-summary-gather-subject-limit 'fuzzy)
3679 (gnus-simplify-subject-fuzzy subject))
3680 ((numberp gnus-summary-gather-subject-limit)
3681 (gnus-limit-string (gnus-simplify-subject-re subject)
3682 gnus-summary-gather-subject-limit))
3686 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
3687 "Check whether two subjects are equal. If optional argument
3688 simple-first is t, first argument is already simplified."
3690 ((null simple-first)
3691 (equal (gnus-simplify-subject-fully s1)
3692 (gnus-simplify-subject-fully s2)))
3695 (gnus-simplify-subject-fully s2)))))
3697 ;; Returns a list of writable groups.
3698 (defun gnus-writable-groups ()
3699 (let ((alist gnus-newsrc-alist)
3701 (while (setq group (car (pop alist)))
3702 (unless (gnus-group-read-only-p group)
3703 (push group groups)))
3706 (defun gnus-completing-read (default prompt &rest args)
3707 ;; Like `completing-read', except that DEFAULT is the default argument.
3708 (let* ((prompt (if default
3709 (concat prompt " (default " default ") ")
3710 (concat prompt " ")))
3711 (answer (apply 'completing-read prompt args)))
3712 (if (or (null answer) (zerop (length answer)))
3716 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
3718 (defun gnus-y-or-n-p (prompt)
3723 (defun gnus-yes-or-no-p (prompt)
3725 (yes-or-no-p prompt)
3728 ;; Check whether to use long file names.
3729 (defun gnus-use-long-file-name (symbol)
3730 ;; The variable has to be set...
3731 (and gnus-use-long-file-name
3732 ;; If it isn't a list, then we return t.
3733 (or (not (listp gnus-use-long-file-name))
3734 ;; If it is a list, and the list contains `symbol', we
3736 (not (memq symbol gnus-use-long-file-name)))))
3738 ;; I suspect there's a better way, but I haven't taken the time to do
3739 ;; it yet. -erik selberg@cs.washington.edu
3740 (defun gnus-dd-mmm (messy-date)
3741 "Return a string like DD-MMM from a big messy string"
3742 (let ((datevec (condition-case () (timezone-parse-date messy-date)
3748 ;; Make sure leading zeroes are stripped.
3749 (number-to-string (string-to-number (aref datevec 2)))
3753 (nth (1- (string-to-number (aref datevec 1)))
3754 timezone-months-assoc))
3757 (defun gnus-mode-string-quote (string)
3758 "Quote all \"%\" in STRING."
3760 (gnus-set-work-buffer)
3762 (goto-char (point-min))
3763 (while (search-forward "%" nil t)
3767 ;; Make a hash table (default and minimum size is 255).
3768 ;; Optional argument HASHSIZE specifies the table size.
3769 (defun gnus-make-hashtable (&optional hashsize)
3770 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0))
3772 ;; Make a number that is suitable for hashing; bigger than MIN and one
3774 (defun gnus-create-hash-size (min)
3780 ;; Show message if message has a lower level than `gnus-verbose'.
3781 ;; Guideline for numbers:
3782 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages
3783 ;; for things that take a long time, 7 - not very important messages
3784 ;; on stuff, 9 - messages inside loops.
3785 (defun gnus-message (level &rest args)
3786 (if (<= level gnus-verbose)
3787 (apply 'message args)
3788 ;; We have to do this format thingy here even if the result isn't
3789 ;; shown - the return value has to be the same as the return value
3791 (apply 'format args)))
3793 (defun gnus-error (level &rest args)
3794 "Beep an error if `gnus-verbose' is on LEVEL or less."
3795 (when (<= (floor level) gnus-verbose)
3796 (apply 'message args)
3799 (when (and (floatp level)
3800 (not (zerop (setq duration (* 10 (- level (floor level)))))))
3801 (sit-for duration))))
3804 ;; Generate a unique new group name.
3805 (defun gnus-generate-new-group-name (leaf)
3808 (while (gnus-gethash name gnus-newsrc-hashtb)
3809 (setq name (concat leaf "<" (int-to-string (setq num (1+ num))) ">")))
3812 (defsubst gnus-hide-text (b e props)
3813 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
3814 (gnus-add-text-properties b e props)
3815 (when (memq 'intangible props)
3816 (gnus-put-text-property (max (1- b) (point-min))
3817 b 'intangible (cddr (memq 'intangible props)))))
3819 (defsubst gnus-unhide-text (b e)
3820 "Remove hidden text properties from region between B and E."
3821 (remove-text-properties b e gnus-hidden-properties)
3822 (when (memq 'intangible gnus-hidden-properties)
3823 (gnus-put-text-property (max (1- b) (point-min))
3824 b 'intangible nil)))
3826 (defun gnus-hide-text-type (b e type)
3827 "Hide text of TYPE between B and E."
3828 (gnus-hide-text b e (cons 'gnus-type (cons type gnus-hidden-properties))))
3830 (defun gnus-parent-headers (headers &optional generation)
3831 "Return the headers of the GENERATIONeth parent of HEADERS."
3833 (setq generation 1))
3834 (let (references parent)
3835 (while (and headers (not (zerop generation)))
3836 (setq references (mail-header-references headers))
3837 (when (and references
3838 (setq parent (gnus-parent-id references))
3839 (setq headers (car (gnus-id-to-thread parent))))
3843 (defun gnus-parent-id (references)
3844 "Return the last Message-ID in REFERENCES."
3845 (when (and references
3846 (string-match "\\(<[^\n<>]+>\\)[ \t\n]*\\'" references))
3847 (substring references (match-beginning 1) (match-end 1))))
3849 (defun gnus-split-references (references)
3850 "Return a list of Message-IDs in REFERENCES."
3853 (while (string-match "<[^>]+>" references beg)
3854 (push (substring references (match-beginning 0) (setq beg (match-end 0)))
3858 (defun gnus-buffer-live-p (buffer)
3859 "Say whether BUFFER is alive or not."
3862 (buffer-name (get-buffer buffer))))
3864 (defun gnus-ephemeral-group-p (group)
3865 "Say whether GROUP is ephemeral or not."
3866 (gnus-group-get-parameter group 'quit-config))
3868 (defun gnus-group-quit-config (group)
3869 "Return the quit-config of GROUP."
3870 (gnus-group-get-parameter group 'quit-config))
3872 (defun gnus-simplify-mode-line ()
3873 "Make mode lines a bit simpler."
3874 (setq mode-line-modified "-- ")
3875 (when (listp mode-line-format)
3876 (make-local-variable 'mode-line-format)
3877 (setq mode-line-format (copy-sequence mode-line-format))
3878 (when (equal (nth 3 mode-line-format) " ")
3879 (setcar (nthcdr 3 mode-line-format) " "))))
3881 ;;; List and range functions
3883 (defun gnus-last-element (list)
3884 "Return last element of LIST."
3886 (setq list (cdr list)))
3889 (defun gnus-copy-sequence (list)
3890 "Do a complete, total copy of a list."
3891 (if (and (consp list) (not (consp (cdr list))))
3892 (cons (car list) (cdr list))
3893 (mapcar (lambda (elem) (if (consp elem)
3894 (if (consp (cdr elem))
3895 (gnus-copy-sequence elem)
3896 (cons (car elem) (cdr elem)))
3900 (defun gnus-set-difference (list1 list2)
3901 "Return a list of elements of LIST1 that do not appear in LIST2."
3902 (let ((list1 (copy-sequence list1)))
3904 (setq list1 (delq (car list2) list1))
3905 (setq list2 (cdr list2)))
3908 (defun gnus-sorted-complement (list1 list2)
3909 "Return a list of elements of LIST1 that do not appear in LIST2.
3910 Both lists have to be sorted over <."
3912 (if (or (null list1) (null list2))
3914 (while (and list1 list2)
3915 (cond ((= (car list1) (car list2))
3916 (setq list1 (cdr list1)
3918 ((< (car list1) (car list2))
3919 (setq out (cons (car list1) out))
3920 (setq list1 (cdr list1)))
3922 (setq out (cons (car list2) out))
3923 (setq list2 (cdr list2)))))
3924 (nconc (nreverse out) (or list1 list2)))))
3926 (defun gnus-intersection (list1 list2)
3929 (if (memq (car list2) list1)
3930 (setq result (cons (car list2) result)))
3931 (setq list2 (cdr list2)))
3934 (defun gnus-sorted-intersection (list1 list2)
3935 ;; LIST1 and LIST2 have to be sorted over <.
3937 (while (and list1 list2)
3938 (cond ((= (car list1) (car list2))
3939 (setq out (cons (car list1) out)
3942 ((< (car list1) (car list2))
3943 (setq list1 (cdr list1)))
3945 (setq list2 (cdr list2)))))
3948 (defun gnus-set-sorted-intersection (list1 list2)
3949 ;; LIST1 and LIST2 have to be sorted over <.
3950 ;; This function modifies LIST1.
3951 (let* ((top (cons nil list1))
3953 (while (and list1 list2)
3954 (cond ((= (car list1) (car list2))
3958 ((< (car list1) (car list2))
3959 (setcdr prev (cdr list1))
3960 (setq list1 (cdr list1)))
3962 (setq list2 (cdr list2)))))
3966 (defun gnus-compress-sequence (numbers &optional always-list)
3967 "Convert list of numbers to a list of ranges or a single range.
3968 If ALWAYS-LIST is non-nil, this function will always release a list of
3970 (let* ((first (car numbers))
3971 (last (car numbers))
3975 (if (not (listp (cdr numbers)))
3978 (cond ((= last (car numbers)) nil) ;Omit duplicated number
3979 ((= (1+ last) (car numbers)) ;Still in sequence
3980 (setq last (car numbers)))
3981 (t ;End of one sequence
3983 (cons (if (= first last) first
3984 (cons first last)) result))
3985 (setq first (car numbers))
3986 (setq last (car numbers))))
3987 (setq numbers (cdr numbers)))
3988 (if (and (not always-list) (null result))
3989 (if (= first last) (list first) (cons first last))
3990 (nreverse (cons (if (= first last) first (cons first last))
3993 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
3994 (defun gnus-uncompress-range (ranges)
3995 "Expand a list of ranges into a list of numbers.
3996 RANGES is either a single range on the form `(num . num)' or a list of
3998 (let (first last result)
4002 ((not (listp (cdr ranges)))
4003 (setq first (car ranges))
4004 (setq last (cdr ranges))
4005 (while (<= first last)
4006 (setq result (cons first result))
4007 (setq first (1+ first)))
4011 (if (atom (car ranges))
4012 (if (numberp (car ranges))
4013 (setq result (cons (car ranges) result)))
4014 (setq first (caar ranges))
4015 (setq last (cdar ranges))
4016 (while (<= first last)
4017 (setq result (cons first result))
4018 (setq first (1+ first))))
4019 (setq ranges (cdr ranges)))
4020 (nreverse result)))))
4022 (defun gnus-add-to-range (ranges list)
4023 "Return a list of ranges that has all articles from both RANGES and LIST.
4024 Note: LIST has to be sorted over `<'."
4026 (gnus-compress-sequence list t)
4027 (setq list (copy-sequence list))
4028 (or (listp (cdr ranges))
4029 (setq ranges (list ranges)))
4031 ilist lowest highest temp)
4032 (while (and ranges list)
4034 (setq lowest (or (and (atom (car ranges)) (car ranges))
4036 (while (and list (cdr list) (< (cadr list) lowest))
4037 (setq list (cdr list)))
4038 (if (< (car ilist) lowest)
4041 (setq list (cdr list))
4043 (setq out (nconc (gnus-compress-sequence ilist t) out))))
4044 (setq highest (or (and (atom (car ranges)) (car ranges))
4046 (while (and list (<= (car list) highest))
4047 (setq list (cdr list)))
4048 (setq ranges (cdr ranges)))
4050 (setq out (nconc (gnus-compress-sequence list t) out)))
4051 (setq out (sort out (lambda (r1 r2)
4052 (< (or (and (atom r1) r1) (car r1))
4053 (or (and (atom r2) r2) (car r2))))))
4056 (if (atom (car ranges))
4058 (if (atom (cadr ranges))
4059 (if (= (1+ (car ranges)) (cadr ranges))
4061 (setcar ranges (cons (car ranges)
4063 (setcdr ranges (cddr ranges))))
4064 (if (= (1+ (car ranges)) (caadr ranges))
4066 (setcar (cadr ranges) (car ranges))
4067 (setcar ranges (cadr ranges))
4068 (setcdr ranges (cddr ranges))))))
4070 (if (atom (cadr ranges))
4071 (if (= (1+ (cdar ranges)) (cadr ranges))
4073 (setcdr (car ranges) (cadr ranges))
4074 (setcdr ranges (cddr ranges))))
4075 (if (= (1+ (cdar ranges)) (caadr ranges))
4077 (setcdr (car ranges) (cdadr ranges))
4078 (setcdr ranges (cddr ranges)))))))
4079 (setq ranges (cdr ranges)))
4082 (defun gnus-remove-from-range (ranges list)
4083 "Return a list of ranges that has all articles from LIST removed from RANGES.
4084 Note: LIST has to be sorted over `<'."
4085 ;; !!! This function shouldn't look like this, but I've got a headache.
4086 (gnus-compress-sequence
4087 (gnus-sorted-complement
4088 (gnus-uncompress-range ranges) list)))
4090 (defun gnus-member-of-range (number ranges)
4091 (if (not (listp (cdr ranges)))
4092 (and (>= number (car ranges))
4093 (<= number (cdr ranges)))
4096 (if (numberp (car ranges))
4097 (>= number (car ranges))
4098 (>= number (caar ranges)))
4100 (if (if (numberp (car ranges))
4101 (= number (car ranges))
4102 (and (>= number (caar ranges))
4103 (<= number (cdar ranges))))
4104 (setq not-stop nil))
4105 (setq ranges (cdr ranges)))
4108 (defun gnus-range-length (range)
4109 "Return the length RANGE would have if uncompressed."
4110 (length (gnus-uncompress-range range)))
4112 (defun gnus-sublist-p (list sublist)
4113 "Test whether all elements in SUBLIST are members of LIST."
4116 (unless (memq (pop sublist) list)
4126 (defvar gnus-group-mode-map nil)
4127 (put 'gnus-group-mode 'mode-class 'special)
4129 (unless gnus-group-mode-map
4130 (setq gnus-group-mode-map (make-keymap))
4131 (suppress-keymap gnus-group-mode-map)
4133 (gnus-define-keys gnus-group-mode-map
4134 " " gnus-group-read-group
4135 "=" gnus-group-select-group
4136 "\r" gnus-group-select-group
4137 "\M-\r" gnus-group-quick-select-group
4138 "j" gnus-group-jump-to-group
4139 "n" gnus-group-next-unread-group
4140 "p" gnus-group-prev-unread-group
4141 "\177" gnus-group-prev-unread-group
4142 [delete] gnus-group-prev-unread-group
4143 "N" gnus-group-next-group
4144 "P" gnus-group-prev-group
4145 "\M-n" gnus-group-next-unread-group-same-level
4146 "\M-p" gnus-group-prev-unread-group-same-level
4147 "," gnus-group-best-unread-group
4148 "." gnus-group-first-unread-group
4149 "u" gnus-group-unsubscribe-current-group
4150 "U" gnus-group-unsubscribe-group
4151 "c" gnus-group-catchup-current
4152 "C" gnus-group-catchup-current-all
4153 "l" gnus-group-list-groups
4154 "L" gnus-group-list-all-groups
4156 "g" gnus-group-get-new-news
4157 "\M-g" gnus-group-get-new-news-this-group
4158 "R" gnus-group-restart
4159 "r" gnus-group-read-init-file
4160 "B" gnus-group-browse-foreign-server
4161 "b" gnus-group-check-bogus-groups
4162 "F" gnus-find-new-newsgroups
4163 "\C-c\C-d" gnus-group-describe-group
4164 "\M-d" gnus-group-describe-all-groups
4165 "\C-c\C-a" gnus-group-apropos
4166 "\C-c\M-\C-a" gnus-group-description-apropos
4167 "a" gnus-group-post-news
4168 "\ek" gnus-group-edit-local-kill
4169 "\eK" gnus-group-edit-global-kill
4170 "\C-k" gnus-group-kill-group
4171 "\C-y" gnus-group-yank-group
4172 "\C-w" gnus-group-kill-region
4173 "\C-x\C-t" gnus-group-transpose-groups
4174 "\C-c\C-l" gnus-group-list-killed
4175 "\C-c\C-x" gnus-group-expire-articles
4176 "\C-c\M-\C-x" gnus-group-expire-all-groups
4178 "s" gnus-group-save-newsrc
4179 "z" gnus-group-suspend
4180 "Z" gnus-group-clear-dribble
4183 "?" gnus-group-describe-briefly
4184 "\C-c\C-i" gnus-info-find-node
4185 "\M-e" gnus-group-edit-group-method
4186 "^" gnus-group-enter-server-mode
4187 gnus-mouse-2 gnus-mouse-pick-group
4188 "<" beginning-of-buffer
4191 "\C-c\C-s" gnus-group-sort-groups
4193 "\C-c\M-g" gnus-activate-all-groups
4194 "\M-&" gnus-group-universal-argument
4195 "#" gnus-group-mark-group
4196 "\M-#" gnus-group-unmark-group)
4198 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
4199 "m" gnus-group-mark-group
4200 "u" gnus-group-unmark-group
4201 "w" gnus-group-mark-region
4202 "m" gnus-group-mark-buffer
4203 "r" gnus-group-mark-regexp
4204 "U" gnus-group-unmark-all-groups)
4206 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
4207 "d" gnus-group-make-directory-group
4208 "h" gnus-group-make-help-group
4209 "a" gnus-group-make-archive-group
4210 "k" gnus-group-make-kiboze-group
4211 "m" gnus-group-make-group
4212 "E" gnus-group-edit-group
4213 "e" gnus-group-edit-group-method
4214 "p" gnus-group-edit-group-parameters
4215 "v" gnus-group-add-to-virtual
4216 "V" gnus-group-make-empty-virtual
4217 "D" gnus-group-enter-directory
4218 "f" gnus-group-make-doc-group
4219 "r" gnus-group-rename-group
4220 "\177" gnus-group-delete-group
4221 [delete] gnus-group-delete-group)
4223 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
4224 "b" gnus-group-brew-soup
4225 "w" gnus-soup-save-areas
4226 "s" gnus-soup-send-replies
4227 "p" gnus-soup-pack-packet
4228 "r" nnsoup-pack-replies)
4230 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
4231 "s" gnus-group-sort-groups
4232 "a" gnus-group-sort-groups-by-alphabet
4233 "u" gnus-group-sort-groups-by-unread
4234 "l" gnus-group-sort-groups-by-level
4235 "v" gnus-group-sort-groups-by-score
4236 "r" gnus-group-sort-groups-by-rank
4237 "m" gnus-group-sort-groups-by-method)
4239 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
4240 "k" gnus-group-list-killed
4241 "z" gnus-group-list-zombies
4242 "s" gnus-group-list-groups
4243 "u" gnus-group-list-all-groups
4244 "A" gnus-group-list-active
4245 "a" gnus-group-apropos
4246 "d" gnus-group-description-apropos
4247 "m" gnus-group-list-matching
4248 "M" gnus-group-list-all-matching
4249 "l" gnus-group-list-level)
4251 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
4252 "f" gnus-score-flush-cache)
4254 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
4255 "f" gnus-group-fetch-faq)
4257 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
4258 "l" gnus-group-set-current-level
4259 "t" gnus-group-unsubscribe-current-group
4260 "s" gnus-group-unsubscribe-group
4261 "k" gnus-group-kill-group
4262 "y" gnus-group-yank-group
4263 "w" gnus-group-kill-region
4264 "\C-k" gnus-group-kill-level
4265 "z" gnus-group-kill-all-zombies))
4267 (defun gnus-group-mode ()
4268 "Major mode for reading news.
4270 All normal editing commands are switched off.
4271 \\<gnus-group-mode-map>
4272 The group buffer lists (some of) the groups available. For instance,
4273 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
4274 lists all zombie groups.
4276 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
4277 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
4279 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
4281 The following commands are available:
4283 \\{gnus-group-mode-map}"
4285 (when (and menu-bar-mode
4286 (gnus-visual-p 'group-menu 'menu))
4287 (gnus-group-make-menu-bar))
4288 (kill-all-local-variables)
4289 (gnus-simplify-mode-line)
4290 (setq major-mode 'gnus-group-mode)
4291 (setq mode-name "Group")
4292 (gnus-group-set-mode-line)
4293 (setq mode-line-process nil)
4294 (use-local-map gnus-group-mode-map)
4295 (buffer-disable-undo (current-buffer))
4296 (setq truncate-lines t)
4297 (setq buffer-read-only t)
4298 (gnus-make-local-hook 'post-command-hook)
4299 (gnus-add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
4300 (run-hooks 'gnus-group-mode-hook))
4302 (defun gnus-clear-inboxes-moved ()
4303 (setq nnmail-moved-inboxes nil))
4305 (defun gnus-mouse-pick-group (e)
4306 "Enter the group under the mouse pointer."
4309 (gnus-group-read-group nil))
4311 ;; Look at LEVEL and find out what the level is really supposed to be.
4312 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
4313 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
4314 (defun gnus-group-default-level (&optional level number-or-nil)
4316 (gnus-group-use-permanent-levels
4317 (or (setq gnus-group-use-permanent-levels
4318 (or level (if (numberp gnus-group-use-permanent-levels)
4319 gnus-group-use-permanent-levels
4320 (or gnus-group-default-list-level
4321 gnus-level-subscribed))))
4322 gnus-group-default-list-level gnus-level-subscribed))
4326 (or level gnus-group-default-list-level gnus-level-subscribed))))
4329 (defun gnus-slave-no-server (&optional arg)
4330 "Read network news as a slave, without connecting to local server"
4332 (gnus-no-server arg t))
4335 (defun gnus-no-server (&optional arg slave)
4337 If ARG is a positive number, Gnus will use that as the
4338 startup level. If ARG is nil, Gnus will be started at level 2.
4339 If ARG is non-nil and not a positive number, Gnus will
4340 prompt the user for the name of an NNTP server to use.
4341 As opposed to `gnus', this command will not connect to the local server."
4343 (let ((val (or arg (1- gnus-level-default-subscribed))))
4345 (make-local-variable 'gnus-group-use-permanent-levels)
4346 (setq gnus-group-use-permanent-levels val)))
4349 (defun gnus-slave (&optional arg)
4350 "Read news as a slave."
4352 (gnus arg nil 'slave))
4355 (defun gnus-other-frame (&optional arg)
4356 "Pop up a frame to read news."
4358 (if (get-buffer gnus-group-buffer)
4359 (let ((pop-up-frames t))
4361 (select-frame (make-frame))
4365 (defun gnus (&optional arg dont-connect slave)
4367 If ARG is non-nil and a positive number, Gnus will use that as the
4368 startup level. If ARG is non-nil and not a positive number, Gnus will
4369 prompt the user for the name of an NNTP server to use."
4372 (if (get-buffer gnus-group-buffer)
4374 (switch-to-buffer gnus-group-buffer)
4375 (gnus-group-get-new-news))
4378 (nnheader-init-server-buffer)
4379 (gnus-read-init-file)
4380 (setq gnus-slave slave)
4382 (gnus-group-setup-buffer)
4383 (let ((buffer-read-only nil))
4385 (if (not gnus-inhibit-startup-message)
4387 (gnus-group-startup-message)
4390 (let ((level (and (numberp arg) (> arg 0) arg))
4396 (gnus-start-news-server (and arg (not level))))))
4397 (if (and (not dont-connect)
4400 (run-hooks 'gnus-startup-hook)
4401 ;; NNTP server is successfully open.
4403 ;; Find the current startup file name.
4404 (setq gnus-current-startup-file
4405 (gnus-make-newsrc-file gnus-startup-file))
4407 ;; Read the dribble file.
4408 (when (or gnus-slave gnus-use-dribble-file)
4409 (gnus-dribble-read-file))
4411 ;; Allow using GroupLens predictions.
4412 (when gnus-use-grouplens
4414 (add-hook 'gnus-summary-mode-hook 'gnus-grouplens-mode))
4416 (gnus-summary-make-display-table)
4417 ;; Do the actual startup.
4418 (gnus-setup-news nil level dont-connect)
4419 ;; Generate the group buffer.
4420 (gnus-group-list-groups level)
4421 (gnus-group-first-unread-group)
4422 (gnus-configure-windows 'group)
4423 (gnus-group-set-mode-line))))))
4425 (defun gnus-unload ()
4426 "Unload all Gnus features."
4428 (or (boundp 'load-history)
4429 (error "Sorry, `gnus-unload' is not implemented in this Emacs version."))
4430 (let ((history load-history)
4433 (and (string-match "^\\(gnus\\|nn\\)" (caar history))
4434 (setq feature (cdr (assq 'provide (car history))))
4435 (unload-feature feature 'force))
4436 (setq history (cdr history)))))
4438 (defun gnus-compile ()
4439 "Byte-compile the user-defined format specs."
4441 (let ((entries gnus-format-specs)
4442 entry gnus-tmp-func)
4444 (gnus-message 7 "Compiling format specs...")
4447 (setq entry (pop entries))
4448 (if (eq (car entry) 'version)
4449 (setq gnus-format-specs (delq entry gnus-format-specs))
4450 (when (and (listp (caddr entry))
4451 (not (eq 'byte-code (caaddr entry))))
4452 (fset 'gnus-tmp-func
4453 `(lambda () ,(caddr entry)))
4454 (byte-compile 'gnus-tmp-func)
4455 (setcar (cddr entry) (gnus-byte-code 'gnus-tmp-func)))))
4457 (push (cons 'version emacs-version) gnus-format-specs)
4459 (gnus-message 7 "Compiling user specs...done"))))
4461 (defun gnus-indent-rigidly (start end arg)
4462 "Indent rigidly using only spaces and no tabs."
4465 (narrow-to-region start end)
4466 (indent-rigidly start end arg)
4467 (goto-char (point-min))
4468 (while (search-forward "\t" nil t)
4469 (replace-match " " t t)))))
4471 (defun gnus-group-startup-message (&optional x y)
4472 "Insert startup message in current buffer."
4473 ;; Insert the message.
4478 _ ___ __ ___ __ _ ___
4497 ;; And then hack it.
4498 (gnus-indent-rigidly (point-min) (point-max)
4499 (/ (max (- (window-width) (or x 46)) 0) 2))
4500 (goto-char (point-min))
4502 (let* ((pheight (count-lines (point-min) (point-max)))
4503 (wheight (window-height))
4504 (rest (- wheight pheight)))
4505 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
4507 (goto-char (point-min))
4508 (and (search-forward "Praxis" nil t)
4509 (gnus-put-text-property (match-beginning 0) (match-end 0) 'face 'bold))
4510 (goto-char (point-min))
4511 (let* ((mode-string (gnus-group-set-mode-line)))
4512 (setq mode-line-buffer-identification
4513 (list (concat gnus-version (substring (car mode-string) 4))))
4514 (set-buffer-modified-p t)))
4516 (defun gnus-group-setup-buffer ()
4517 (or (get-buffer gnus-group-buffer)
4519 (switch-to-buffer gnus-group-buffer)
4520 (gnus-add-current-to-buffer-list)
4522 (and gnus-carpal (gnus-carpal-setup-buffer 'group)))))
4524 (defun gnus-group-list-groups (&optional level unread lowest)
4525 "List newsgroups with level LEVEL or lower that have unread articles.
4526 Default is all subscribed groups.
4527 If argument UNREAD is non-nil, groups with no unread articles are also
4529 (interactive (list (if current-prefix-arg
4530 (prefix-numeric-value current-prefix-arg)
4532 (gnus-group-default-level nil t)
4533 gnus-group-default-list-level
4534 gnus-level-subscribed))))
4536 (setq level (car gnus-group-list-mode)
4537 unread (cdr gnus-group-list-mode)))
4538 (setq level (gnus-group-default-level level))
4539 (gnus-group-setup-buffer) ;May call from out of group buffer
4540 (gnus-update-format-specifications)
4541 (let ((case-fold-search nil)
4542 (props (text-properties-at (gnus-point-at-bol)))
4543 (group (gnus-group-group-name)))
4544 (set-buffer gnus-group-buffer)
4545 (funcall gnus-group-prepare-function level unread lowest)
4546 (if (zerop (buffer-size))
4547 (gnus-message 5 gnus-no-groups-message)
4548 (goto-char (point-max))
4549 (when (or (not gnus-group-goto-next-group-function)
4550 (not (funcall gnus-group-goto-next-group-function
4553 ;; Go to the first group with unread articles.
4554 (gnus-group-search-forward t)
4555 ;; Find the right group to put point on. If the current group
4556 ;; has disappeared in the new listing, try to find the next
4557 ;; one. If no next one can be found, just leave point at the
4558 ;; first newsgroup in the buffer.
4559 (if (not (gnus-goto-char
4561 (point-min) (point-max)
4562 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
4563 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
4565 (not (gnus-goto-char
4567 (point-min) (point-max) 'gnus-group
4569 (caar newsrc) gnus-active-hashtb)))))
4570 (setq newsrc (cdr newsrc)))
4571 (or newsrc (progn (goto-char (point-max))
4572 (forward-line -1)))))))
4573 ;; Adjust cursor point.
4574 (gnus-group-position-point))))
4576 (defun gnus-group-list-level (level &optional all)
4577 "List groups on LEVEL.
4578 If ALL (the prefix), also list groups that have no unread articles."
4579 (interactive "nList groups on level: \nP")
4580 (gnus-group-list-groups level all level))
4582 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
4583 "List all newsgroups with unread articles of level LEVEL or lower.
4584 If ALL is non-nil, list groups that have no unread articles.
4585 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
4586 If REGEXP, only list groups matching REGEXP."
4587 (set-buffer gnus-group-buffer)
4588 (let ((buffer-read-only nil)
4589 (newsrc (cdr gnus-newsrc-alist))
4590 (lowest (or lowest 1))
4591 info clevel unread group params)
4593 (if (< lowest gnus-level-zombie)
4594 ;; List living groups.
4596 (setq info (car newsrc)
4597 group (gnus-info-group info)
4598 params (gnus-info-params info)
4600 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
4601 (and unread ; This group might be bogus
4603 (string-match regexp group))
4604 (<= (setq clevel (gnus-info-level info)) level)
4606 (or all ; We list all groups?
4607 (if (eq unread t) ; Unactivated?
4608 gnus-group-list-inactive-groups ; We list unactivated
4609 (> unread 0)) ; We list groups with unread articles
4610 (and gnus-list-groups-with-ticked-articles
4611 (cdr (assq 'tick (gnus-info-marks info))))
4612 ; And groups with tickeds
4613 ;; Check for permanent visibility.
4614 (and gnus-permanently-visible-groups
4615 (string-match gnus-permanently-visible-groups
4617 (memq 'visible params)
4618 (cdr (assq 'visible params)))
4619 (gnus-group-insert-group-line
4620 group (gnus-info-level info)
4621 (gnus-info-marks info) unread (gnus-info-method info)))))
4623 ;; List dead groups.
4624 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
4625 (gnus-group-prepare-flat-list-dead
4626 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
4627 gnus-level-zombie ?Z
4629 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
4630 (gnus-group-prepare-flat-list-dead
4631 (setq gnus-killed-list (sort gnus-killed-list 'string<))
4632 gnus-level-killed ?K regexp))
4634 (gnus-group-set-mode-line)
4635 (setq gnus-group-list-mode (cons level all))
4636 (run-hooks 'gnus-group-prepare-hook)))
4638 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
4639 ;; List zombies and killed lists somewhat faster, which was
4640 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
4641 ;; this by ignoring the group format specification altogether.
4644 ;; This loop is used when listing groups that match some
4647 (setq group (pop groups))
4648 (when (string-match regexp group)
4649 (gnus-add-text-properties
4650 (point) (prog1 (1+ (point))
4651 (insert " " mark " *: " group "\n"))
4652 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4654 'gnus-level level))))
4655 ;; This loop is used when listing all groups.
4657 (gnus-add-text-properties
4658 (point) (prog1 (1+ (point))
4659 (insert " " mark " *: "
4660 (setq group (pop groups)) "\n"))
4661 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4663 'gnus-level level))))))
4665 (defmacro gnus-group-real-name (group)
4666 "Find the real name of a foreign newsgroup."
4667 `(let ((gname ,group))
4668 (if (string-match ":[^:]+$" gname)
4669 (substring gname (1+ (match-beginning 0)))
4672 (defsubst gnus-server-add-address (method)
4673 (let ((method-name (symbol-name (car method))))
4674 (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
4675 (not (assq (intern (concat method-name "-address")) method)))
4676 (append method (list (list (intern (concat method-name "-address"))
4680 (defsubst gnus-server-get-method (group method)
4681 ;; Input either a server name, and extended server name, or a
4682 ;; select method, and return a select method.
4683 (cond ((stringp method)
4684 (gnus-server-to-method method))
4685 ((equal method gnus-select-method)
4687 ((and (stringp (car method)) group)
4688 (gnus-server-extend-method group method))
4689 ((and method (not group)
4690 (equal (cadr method) ""))
4693 (gnus-server-add-address method))))
4695 (defun gnus-server-to-method (server)
4696 "Map virtual server names to select methods."
4698 ;; Is this a method, perhaps?
4699 (and server (listp server) server)
4700 ;; Perhaps this is the native server?
4701 (and (equal server "native") gnus-select-method)
4702 ;; It should be in the server alist.
4703 (cdr (assoc server gnus-server-alist))
4704 ;; If not, we look through all the opened server
4705 ;; to see whether we can find it there.
4706 (let ((opened gnus-opened-servers))
4708 (not (equal server (format "%s:%s" (caaar opened)
4713 (defmacro gnus-method-equal (ss1 ss2)
4714 "Say whether two servers are equal."
4718 (and (= (length s1) (length s2))
4720 (while (and s1 (member (car s1) s2))
4724 (defun gnus-server-equal (m1 m2)
4725 "Say whether two methods are equal."
4726 (let ((m1 (cond ((null m1) gnus-select-method)
4727 ((stringp m1) (gnus-server-to-method m1))
4729 (m2 (cond ((null m2) gnus-select-method)
4730 ((stringp m2) (gnus-server-to-method m2))
4732 (gnus-method-equal m1 m2)))
4734 (defun gnus-servers-using-backend (backend)
4735 "Return a list of known servers using BACKEND."
4736 (let ((opened gnus-opened-servers)
4739 (when (eq backend (caaar opened))
4740 (push (caar opened) out))
4744 (defun gnus-group-prefixed-name (group method)
4745 "Return the whole name from GROUP and METHOD."
4746 (and (stringp method) (setq method (gnus-server-to-method method)))
4747 (concat (format "%s" (car method))
4749 (or (assoc (format "%s" (car method))
4750 (gnus-methods-using 'address))
4751 (gnus-server-equal method gnus-message-archive-method))
4753 (not (string= (nth 1 method) "")))
4754 (concat "+" (nth 1 method)))
4757 (defun gnus-group-real-prefix (group)
4758 "Return the prefix of the current group name."
4759 (if (string-match "^[^:]+:" group)
4760 (substring group 0 (match-end 0))
4763 (defun gnus-group-method (group)
4764 "Return the server or method used for selecting GROUP."
4765 (let ((prefix (gnus-group-real-prefix group)))
4766 (if (equal prefix "")
4768 (let ((servers gnus-opened-servers)
4770 backend possible found)
4771 (if (string-match "^[^\\+]+\\+" prefix)
4772 (setq backend (intern (substring prefix 0 (1- (match-end 0))))
4773 server (substring prefix (match-end 0) (1- (length prefix))))
4774 (setq backend (intern (substring prefix 0 (1- (length prefix))))))
4776 (when (eq (caaar servers) backend)
4777 (setq possible (caar servers))
4778 (when (equal (cadaar servers) server)
4779 (setq found (caar servers))))
4781 (or (car (rassoc found gnus-server-alist))
4783 (car (rassoc possible gnus-server-alist))
4785 (list backend server))))))
4787 (defsubst gnus-secondary-method-p (method)
4788 "Return whether METHOD is a secondary select method."
4789 (let ((methods gnus-secondary-select-methods)
4790 (gmethod (gnus-server-get-method nil method)))
4792 (not (equal (gnus-server-get-method nil (car methods))
4794 (setq methods (cdr methods)))
4797 (defun gnus-group-foreign-p (group)
4798 "Say whether a group is foreign or not."
4799 (and (not (gnus-group-native-p group))
4800 (not (gnus-group-secondary-p group))))
4802 (defun gnus-group-native-p (group)
4803 "Say whether the group is native or not."
4804 (not (string-match ":" group)))
4806 (defun gnus-group-secondary-p (group)
4807 "Say whether the group is secondary or not."
4808 (gnus-secondary-method-p (gnus-find-method-for-group group)))
4810 (defun gnus-group-get-parameter (group &optional symbol)
4811 "Returns the group parameters for GROUP.
4812 If SYMBOL, return the value of that symbol in the group parameters."
4813 (let ((params (gnus-info-params (gnus-get-info group))))
4815 (gnus-group-parameter-value params symbol)
4818 (defun gnus-group-parameter-value (params symbol)
4819 "Return the value of SYMBOL in group PARAMS."
4820 (or (car (memq symbol params)) ; It's either a simple symbol
4821 (cdr (assq symbol params)))) ; or a cons.
4823 (defun gnus-group-add-parameter (group param)
4824 "Add parameter PARAM to GROUP."
4825 (let ((info (gnus-get-info group)))
4827 () ; This is a dead group. We just ignore it.
4828 ;; Cons the new param to the old one and update.
4829 (gnus-group-set-info (cons param (gnus-info-params info))
4832 (defun gnus-group-set-parameter (group name value)
4833 "Set parameter NAME to VALUE in GROUP."
4834 (let ((info (gnus-get-info group)))
4836 () ; This is a dead group. We just ignore it.
4837 (let ((old-params (gnus-info-params info))
4838 (new-params (list (cons name value))))
4840 (if (or (not (listp (car old-params)))
4841 (not (eq (caar old-params) name)))
4842 (setq new-params (append new-params (list (car old-params)))))
4843 (setq old-params (cdr old-params)))
4844 (gnus-group-set-info new-params group 'params)))))
4846 (defun gnus-group-add-score (group &optional score)
4847 "Add SCORE to the GROUP score.
4848 If SCORE is nil, add 1 to the score of GROUP."
4849 (let ((info (gnus-get-info group)))
4851 (gnus-info-set-score info (+ (gnus-info-score info) (or score 1))))))
4853 (defun gnus-summary-bubble-group ()
4854 "Increase the score of the current group.
4855 This is a handy function to add to `gnus-summary-exit-hook' to
4856 increase the score of each group you read."
4857 (gnus-group-add-score gnus-newsgroup-name))
4859 (defun gnus-group-set-info (info &optional method-only-group part)
4860 (let* ((entry (gnus-gethash
4861 (or method-only-group (gnus-info-group info))
4862 gnus-newsrc-hashtb))
4864 (info (if method-only-group (nth 2 entry) info))
4866 (when method-only-group
4868 (error "Trying to change non-existent group %s" method-only-group))
4869 ;; We have received parts of the actual group info - either the
4870 ;; select method or the group parameters. We first check
4871 ;; whether we have to extend the info, and if so, do that.
4872 (let ((len (length info))
4873 (total (if (eq part 'method) 5 6)))
4875 (setcdr (nthcdr (1- len) info)
4876 (make-list (- total len) nil)))
4877 ;; Then we enter the new info.
4878 (setcar (nthcdr (1- total) info) part-info)))
4880 ;; This is a new group, so we just create it.
4882 (set-buffer gnus-group-buffer)
4883 (setq method (gnus-info-method info))
4884 (when (gnus-server-equal method "native")
4887 (set-buffer gnus-group-buffer)
4889 ;; It's a foreign group...
4890 (gnus-group-make-group
4891 (gnus-group-real-name (gnus-info-group info))
4892 (if (stringp method) method
4893 (prin1-to-string (car method)))
4895 (nth 1 (gnus-info-method info))))
4896 ;; It's a native group.
4897 (gnus-group-make-group (gnus-info-group info))))
4898 (gnus-message 6 "Note: New group created")
4900 (gnus-gethash (gnus-group-prefixed-name
4901 (gnus-group-real-name (gnus-info-group info))
4902 (or (gnus-info-method info) gnus-select-method))
4903 gnus-newsrc-hashtb))))
4904 ;; Whether it was a new group or not, we now have the entry, so we
4905 ;; can do the update.
4908 (setcar (nthcdr 2 entry) info)
4909 (when (and (not (eq (car entry) t))
4910 (gnus-active (gnus-info-group info)))
4911 (setcar entry (length (gnus-list-of-unread-articles (car info))))))
4912 (error "No such group: %s" (gnus-info-group info)))))
4914 (defun gnus-group-set-method-info (group select-method)
4915 (gnus-group-set-info select-method group 'method))
4917 (defun gnus-group-set-params-info (group params)
4918 (gnus-group-set-info params group 'params))
4920 (defun gnus-group-update-group-line ()
4921 "Update the current line in the group buffer."
4922 (let* ((buffer-read-only nil)
4923 (group (gnus-group-group-name))
4924 (entry (and group (gnus-gethash group gnus-newsrc-hashtb)))
4925 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
5116 (gnus-mode-line-buffer-identification
5117 (list mode-string)))
5118 (set-buffer-modified-p t))))))
5120 (defun gnus-group-group-name ()
5121 "Get the name of the newsgroup on the current line."
5122 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
5123 (and group (symbol-name group))))
5125 (defun gnus-group-group-level ()
5126 "Get the level of the newsgroup on the current line."
5127 (get-text-property (gnus-point-at-bol) 'gnus-level))
5129 (defun gnus-group-group-indentation ()
5130 "Get the indentation of the newsgroup on the current line."
5131 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
5132 (and gnus-group-indentation-function
5133 (funcall gnus-group-indentation-function))
5136 (defun gnus-group-group-unread ()
5137 "Get the number of unread articles of the newsgroup on the current line."
5138 (get-text-property (gnus-point-at-bol) 'gnus-unread))
5140 (defun gnus-group-search-forward (&optional backward all level first-too)
5141 "Find the next newsgroup with unread articles.
5142 If BACKWARD is non-nil, find the previous newsgroup instead.
5143 If ALL is non-nil, just find any newsgroup.
5144 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
5146 If FIRST-TOO, the current line is also eligible as a target."
5147 (let ((way (if backward -1 1))
5148 (low gnus-level-killed)
5151 (if (and backward (progn (beginning-of-line)) (bobp))
5153 (or first-too (forward-line way))
5161 (get-text-property (point) 'gnus-unread)))
5162 (and (numberp unread) (> unread 0)))
5163 (setq lev (get-text-property (point)
5165 (<= lev gnus-level-subscribed)))
5167 (and (setq lev (get-text-property (point)
5176 (zerop (forward-line way)))))
5178 (progn (gnus-group-position-point) t)
5179 (goto-char (or pos beg))
5182 ;;; Gnus group mode commands
5186 (defun gnus-group-mark-group (n &optional unmark no-advance)
5187 "Mark the current group."
5189 (let ((buffer-read-only nil)
5193 (when (setq group (gnus-group-group-name))
5197 (or (cdr (assq 'process gnus-group-mark-positions)) 2))
5202 (setq gnus-group-marked (delete group gnus-group-marked)))
5204 (setq gnus-group-marked
5205 (cons group (delete group gnus-group-marked)))))
5206 (or no-advance (gnus-group-next-group 1))
5208 (gnus-summary-position-point)
5211 (defun gnus-group-unmark-group (n)
5212 "Remove the mark from the current group."
5214 (gnus-group-mark-group n 'unmark)
5215 (gnus-group-position-point))
5217 (defun gnus-group-unmark-all-groups ()
5218 "Unmark all groups."
5220 (let ((groups gnus-group-marked))
5223 (gnus-group-remove-mark (pop groups)))))
5224 (gnus-group-position-point))
5226 (defun gnus-group-mark-region (unmark beg end)
5227 "Mark all groups between point and mark.
5228 If UNMARK, remove the mark instead."
5229 (interactive "P\nr")
5230 (let ((num (count-lines beg end)))
5233 (- num (gnus-group-mark-group num unmark)))))
5235 (defun gnus-group-mark-buffer (&optional unmark)
5236 "Mark all groups in the buffer.
5237 If UNMARK, remove the mark instead."
5239 (gnus-group-mark-region unmark (point-min) (point-max)))
5241 (defun gnus-group-mark-regexp (regexp)
5242 "Mark all groups that match some regexp."
5243 (interactive "sMark (regexp): ")
5244 (let ((alist (cdr gnus-newsrc-alist))
5247 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
5248 (gnus-group-set-mark group))))
5249 (gnus-group-position-point))
5251 (defun gnus-group-remove-mark (group)
5252 "Remove the process mark from GROUP and move point there.
5253 Return nil if the group isn't displayed."
5254 (if (gnus-group-goto-group group)
5256 (gnus-group-mark-group 1 'unmark t)
5258 (setq gnus-group-marked
5259 (delete group gnus-group-marked))
5262 (defun gnus-group-set-mark (group)
5263 "Set the process mark on GROUP."
5264 (if (gnus-group-goto-group group)
5266 (gnus-group-mark-group 1 nil t))
5267 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
5269 (defun gnus-group-universal-argument (arg &optional groups func)
5270 "Perform any command on all groups accoring to the process/prefix convention."
5272 (let ((groups (or groups (gnus-group-process-prefix arg)))
5274 (if (eq (setq func (or func
5277 (substitute-command-keys
5278 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
5280 (gnus-error 1 "Undefined key")
5282 (gnus-group-remove-mark (setq group (pop groups)))
5283 (command-execute func))))
5284 (gnus-group-position-point))
5286 (defun gnus-group-process-prefix (n)
5287 "Return a list of groups to work on.
5288 Take into consideration N (the prefix) and the list of marked groups."
5291 (setq n (prefix-numeric-value n))
5292 ;; There is a prefix, so we return a list of the N next
5294 (let ((way (if (< n 0) -1 1))
5299 (setq group (gnus-group-group-name)))
5300 (setq groups (cons group groups))
5302 (gnus-group-next-group way)))
5304 ((and (boundp 'transient-mark-mode)
5306 (boundp 'mark-active)
5308 ;; Work on the region between point and mark.
5309 (let ((max (max (point) (mark)))
5312 (goto-char (min (point) (mark)))
5315 (push (gnus-group-group-name) groups)
5316 (zerop (gnus-group-next-group 1))
5318 (nreverse groups))))
5320 ;; No prefix, but a list of marked articles.
5321 (reverse gnus-group-marked))
5323 ;; Neither marked articles or a prefix, so we return the
5325 (let ((group (gnus-group-group-name)))
5326 (and group (list group))))))
5328 ;; Selecting groups.
5330 (defun gnus-group-read-group (&optional all no-article group)
5331 "Read news in this newsgroup.
5332 If the prefix argument ALL is non-nil, already read articles become
5333 readable. IF ALL is a number, fetch this number of articles. If the
5334 optional argument NO-ARTICLE is non-nil, no article will be
5335 auto-selected upon group entry. If GROUP is non-nil, fetch that
5338 (let ((group (or group (gnus-group-group-name)))
5339 number active marked entry)
5340 (or group (error "No group on current line"))
5341 (setq marked (nth 3 (nth 2 (setq entry (gnus-gethash
5342 group gnus-newsrc-hashtb)))))
5343 ;; This group might be a dead group. In that case we have to get
5344 ;; the number of unread articles from `gnus-active-hashtb'.
5346 (cond ((numberp all) all)
5348 ((setq active (gnus-active group))
5349 (- (1+ (cdr active)) (car active)))))
5350 (gnus-summary-read-group
5351 group (or all (and (numberp number)
5352 (zerop (+ number (length (cdr (assq 'tick marked)))
5353 (length (cdr (assq 'dormant marked)))))))
5356 (defun gnus-group-select-group (&optional all)
5357 "Select this newsgroup.
5358 No article is selected automatically.
5359 If ALL is non-nil, already read articles become readable.
5360 If ALL is a number, fetch this number of articles."
5362 (gnus-group-read-group all t))
5364 (defun gnus-group-quick-select-group (&optional all)
5365 "Select the current group \"quickly\".
5366 This means that no highlighting or scoring will be performed."
5369 gnus-score-find-score-files-function
5370 gnus-apply-kill-hook
5371 gnus-summary-expunge-below)
5372 (gnus-group-read-group all t)))
5374 (defun gnus-group-visible-select-group (&optional all)
5375 "Select the current group without hiding any articles."
5377 (let ((gnus-inhibit-limiting t))
5378 (gnus-group-read-group all t)))
5381 (defun gnus-fetch-group (group)
5382 "Start Gnus if necessary and enter GROUP.
5383 Returns whether the fetching was successful or not."
5384 (interactive "sGroup name: ")
5385 (or (get-buffer gnus-group-buffer)
5387 (gnus-group-read-group nil nil group))
5389 ;; Enter a group that is not in the group buffer. Non-nil is returned
5390 ;; if selection was successful.
5391 (defun gnus-group-read-ephemeral-group
5392 (group method &optional activate quit-config)
5393 (let ((group (if (gnus-group-foreign-p group) group
5394 (gnus-group-prefixed-name group method))))
5397 `(t nil (,group ,gnus-level-default-subscribed nil nil ,method
5398 ((quit-config . ,(if quit-config quit-config
5399 (cons (current-buffer) 'summary))))))
5401 (set-buffer gnus-group-buffer)
5402 (or (gnus-check-server method)
5403 (error "Unable to contact server: %s" (gnus-status-message method)))
5404 (if activate (or (gnus-request-group group)
5405 (error "Couldn't request group")))
5407 (gnus-group-read-group t t group)
5411 (defun gnus-group-jump-to-group (group)
5412 "Jump to newsgroup GROUP."
5414 (list (completing-read
5415 "Group: " gnus-active-hashtb nil
5416 (gnus-read-active-file-p)
5418 'gnus-group-history)))
5420 (when (equal group "")
5421 (error "Empty group name"))
5423 (when (string-match "[\000-\032]" group)
5424 (error "Control characters in group: %s" group))
5426 (let ((b (text-property-any
5427 (point-min) (point-max)
5428 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
5429 (unless (gnus-ephemeral-group-p group)
5431 ;; Either go to the line in the group buffer...
5433 ;; ... or insert the line.
5436 (gnus-activate-group group)
5437 (error "%s error: %s" group (gnus-status-message group)))
5439 (gnus-group-update-group group)
5440 (goto-char (text-property-any
5441 (point-min) (point-max)
5442 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))
5443 ;; Adjust cursor point.
5444 (gnus-group-position-point)))
5446 (defun gnus-group-goto-group (group)
5447 "Goto to newsgroup GROUP."
5449 (let ((b (text-property-any (point-min) (point-max)
5450 'gnus-group (gnus-intern-safe
5451 group gnus-active-hashtb))))
5452 (and b (goto-char b)))))
5454 (defun gnus-group-next-group (n)
5455 "Go to next N'th newsgroup.
5456 If N is negative, search backward instead.
5457 Returns the difference between N and the number of skips actually
5460 (gnus-group-next-unread-group n t))
5462 (defun gnus-group-next-unread-group (n &optional all level)
5463 "Go to next N'th unread newsgroup.
5464 If N is negative, search backward instead.
5465 If ALL is non-nil, choose any newsgroup, unread or not.
5466 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
5467 such group can be found, the next group with a level higher than
5469 Returns the difference between N and the number of skips actually
5472 (let ((backward (< n 0))
5475 (gnus-group-search-forward
5476 backward (or (not gnus-group-goto-unread) all) level))
5478 (if (/= 0 n) (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
5479 (if level " on this level or higher" "")))
5482 (defun gnus-group-prev-group (n)
5483 "Go to previous N'th newsgroup.
5484 Returns the difference between N and the number of skips actually
5487 (gnus-group-next-unread-group (- n) t))
5489 (defun gnus-group-prev-unread-group (n)
5490 "Go to previous N'th unread newsgroup.
5491 Returns the difference between N and the number of skips actually
5494 (gnus-group-next-unread-group (- n)))
5496 (defun gnus-group-next-unread-group-same-level (n)
5497 "Go to next N'th unread newsgroup on the same level.
5498 If N is negative, search backward instead.
5499 Returns the difference between N and the number of skips actually
5502 (gnus-group-next-unread-group n t (gnus-group-group-level))
5503 (gnus-group-position-point))
5505 (defun gnus-group-prev-unread-group-same-level (n)
5506 "Go to next N'th unread newsgroup on the same level.
5507 Returns the difference between N and the number of skips actually
5510 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
5511 (gnus-group-position-point))
5513 (defun gnus-group-best-unread-group (&optional exclude-group)
5514 "Go to the group with the highest level.
5515 If EXCLUDE-GROUP, do not go to that group."
5517 (goto-char (point-min))
5521 (setq unread (get-text-property (point) 'gnus-unread))
5522 (if (and (numberp unread) (> unread 0))
5524 (if (and (get-text-property (point) 'gnus-level)
5525 (< (get-text-property (point) 'gnus-level) best)
5526 (or (not exclude-group)
5527 (not (equal exclude-group (gnus-group-group-name)))))
5529 (setq best (get-text-property (point) 'gnus-level))
5530 (setq best-point (point))))))
5532 (if best-point (goto-char best-point))
5533 (gnus-summary-position-point)
5534 (and best-point (gnus-group-group-name))))
5536 (defun gnus-group-first-unread-group ()
5537 "Go to the first group with unread articles."
5540 (let ((opoint (point))
5542 (goto-char (point-min))
5543 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
5544 (and (numberp unread) ; Not a topic.
5545 (not (zerop unread))) ; Has unread articles.
5546 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
5549 nil)) ; Not success.
5550 (gnus-group-position-point)))
5552 (defun gnus-group-enter-server-mode ()
5553 "Jump to the server buffer."
5555 (gnus-enter-server-buffer))
5557 (defun gnus-group-make-group (name &optional method address)
5558 "Add a new newsgroup.
5559 The user will be prompted for a NAME, for a select METHOD, and an
5563 (read-string "Group name: ")
5566 "Method: " (append gnus-valid-select-methods gnus-server-alist)
5567 nil t nil 'gnus-method-history)))
5568 (cond ((assoc method gnus-valid-select-methods)
5570 (if (memq 'prompt-address
5571 (assoc method gnus-valid-select-methods))
5572 (read-string "Address: ")
5574 ((assoc method gnus-server-alist)
5577 (list method ""))))))
5579 (let* ((meth (and method (if address (list (intern method) address)
5581 (nname (if method (gnus-group-prefixed-name name meth) name))
5583 (when (gnus-gethash nname gnus-newsrc-hashtb)
5584 (error "Group %s already exists" nname))
5585 ;; Subscribe to the new group.
5586 (gnus-group-change-level
5587 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
5588 gnus-level-default-subscribed gnus-level-killed
5589 (and (gnus-group-group-name)
5590 (gnus-gethash (gnus-group-group-name)
5591 gnus-newsrc-hashtb))
5594 (gnus-set-active nname (cons 1 0))
5595 (or (gnus-ephemeral-group-p name)
5597 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")")))
5599 (gnus-group-insert-group-line-info nname)
5601 (gnus-group-position-point)
5603 ;; Load the backend and try to make the backend create
5604 ;; the group as well.
5605 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
5607 gnus-valid-select-methods)
5609 (gnus-check-server meth)
5610 (and (gnus-check-backend-function 'request-create-group nname)
5611 (gnus-request-create-group nname))
5614 (defun gnus-group-delete-group (group &optional force)
5615 "Delete the current group. Only meaningful with mail groups.
5616 If FORCE (the prefix) is non-nil, all the articles in the group will
5617 be deleted. This is \"deleted\" as in \"removed forever from the face
5618 of the Earth\". There is no undo. The user will be prompted before
5619 doing the deletion."
5621 (list (gnus-group-group-name)
5622 current-prefix-arg))
5623 (or group (error "No group to rename"))
5624 (or (gnus-check-backend-function 'request-delete-group group)
5625 (error "This backend does not support group deletion"))
5627 (if (not (gnus-yes-or-no-p
5629 "Do you really want to delete %s%s? "
5630 group (if force " and all its contents" ""))))
5632 (gnus-message 6 "Deleting group %s..." group)
5633 (if (not (gnus-request-delete-group group force))
5634 (gnus-error 3 "Couldn't delete group %s" group)
5635 (gnus-message 6 "Deleting group %s...done" group)
5636 (gnus-group-goto-group group)
5637 (gnus-group-kill-group 1 t)
5638 (gnus-sethash group nil gnus-active-hashtb)
5640 (gnus-group-position-point)))
5642 (defun gnus-group-rename-group (group new-name)
5645 (gnus-group-group-name)
5647 (or (gnus-check-backend-function
5648 'request-rename-group (gnus-group-group-name))
5649 (error "This backend does not support renaming groups"))
5650 (read-string "New group name: "))))
5652 (or (gnus-check-backend-function 'request-rename-group group)
5653 (error "This backend does not support renaming groups"))
5655 (or group (error "No group to rename"))
5656 (and (string-match "^[ \t]*$" new-name)
5657 (error "Not a valid group name"))
5659 ;; We find the proper prefixed name.
5661 (gnus-group-prefixed-name
5662 (gnus-group-real-name new-name)
5663 (gnus-info-method (gnus-get-info group))))
5665 (gnus-message 6 "Renaming group %s to %s..." group new-name)
5667 (if (not (gnus-request-rename-group group new-name))
5668 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
5669 ;; We rename the group internally by killing it...
5670 (gnus-group-goto-group group)
5671 (gnus-group-kill-group)
5672 ;; ... changing its name ...
5673 (setcar (cdar gnus-list-of-killed-groups) new-name)
5674 ;; ... and then yanking it. Magic!
5675 (gnus-group-yank-group)
5676 (gnus-set-active new-name (gnus-active group))
5677 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
5679 (gnus-group-position-point)))
5681 (defun gnus-group-edit-group (group &optional part)
5682 "Edit the group on the current line."
5683 (interactive (list (gnus-group-group-name)))
5684 (let* ((part (or part 'info))
5685 (done-func `(lambda ()
5686 "Exit editing mode and update the information."
5688 (gnus-group-edit-group-done ',part ,group)))
5689 (winconf (current-window-configuration))
5691 (or group (error "No group on current line"))
5692 (or (setq info (gnus-get-info group))
5693 (error "Killed group; can't be edited"))
5694 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5695 (gnus-configure-windows 'edit-group)
5696 (gnus-add-current-to-buffer-list)
5698 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
5699 (use-local-map (copy-keymap emacs-lisp-mode-map))
5700 (local-set-key "\C-c\C-c" done-func)
5701 (make-local-variable 'gnus-prev-winconf)
5702 (setq gnus-prev-winconf winconf)
5707 ";; Type `C-c C-c' after editing the select method.\n\n")
5709 ";; Type `C-c C-c' after editing the group parameters.\n\n")
5711 ";; Type `C-c C-c' after editing the group info.\n\n")))
5714 (cond ((eq part 'method)
5715 (or (gnus-info-method info) "native"))
5717 (gnus-info-params info))
5721 (defun gnus-group-edit-group-method (group)
5722 "Edit the select method of GROUP."
5723 (interactive (list (gnus-group-group-name)))
5724 (gnus-group-edit-group group 'method))
5726 (defun gnus-group-edit-group-parameters (group)
5727 "Edit the group parameters of GROUP."
5728 (interactive (list (gnus-group-group-name)))
5729 (gnus-group-edit-group group 'params))
5731 (defun gnus-group-edit-group-done (part group)
5732 "Get info from buffer, update variables and jump to the group buffer."
5733 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5734 (goto-char (point-min))
5735 (let* ((form (read (current-buffer)))
5736 (winconf gnus-prev-winconf)
5737 (method (cond ((eq part 'info) (nth 4 form))
5738 ((eq part 'method) form)
5740 (info (cond ((eq part 'info) form)
5741 ((eq part 'method) (gnus-get-info group))
5744 (if (or (not method)
5746 gnus-select-method method))
5747 (gnus-group-real-name (car info))
5748 (gnus-group-prefixed-name
5749 (gnus-group-real-name (car info)) method))
5751 (when (and new-group
5752 (not (equal new-group group)))
5753 (when (gnus-group-goto-group group)
5754 (gnus-group-kill-group 1))
5755 (gnus-activate-group new-group))
5757 (if (and info new-group)
5759 (setq info (gnus-copy-sequence info))
5760 (setcar info new-group)
5761 (unless (gnus-server-equal method "native")
5762 (unless (nthcdr 3 info)
5763 (nconc info (list nil nil)))
5764 (unless (nthcdr 4 info)
5765 (nconc info (list nil)))
5766 (gnus-info-set-method info method))
5767 (gnus-group-set-info info))
5768 (gnus-group-set-info form (or new-group group) part))
5769 (kill-buffer (current-buffer))
5770 (and winconf (set-window-configuration winconf))
5771 (set-buffer gnus-group-buffer)
5772 (gnus-group-update-group (or new-group group))
5773 (gnus-group-position-point)))
5775 (defun gnus-group-make-help-group ()
5776 "Create the Gnus documentation group."
5778 (let ((path load-path)
5779 (name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
5781 (and (gnus-gethash name gnus-newsrc-hashtb)
5782 (error "Documentation group already exists"))
5784 (setq dir (file-name-as-directory (expand-file-name (pop path)))
5786 (when (or (file-exists-p (setq file (concat dir "gnus-tut.txt")))
5788 (setq file (concat (file-name-directory
5789 (directory-file-name dir))
5790 "etc/gnus-tut.txt"))))
5793 (gnus-message 1 "Couldn't find doc group")
5794 (gnus-group-make-group
5795 (gnus-group-real-name name)
5796 (list 'nndoc "gnus-help"
5797 (list 'nndoc-address file)
5798 (list 'nndoc-article-type 'mbox)))))
5799 (gnus-group-position-point))
5801 (defun gnus-group-make-doc-group (file type)
5802 "Create a group that uses a single file as the source."
5804 (list (read-file-name "File name: ")
5805 (and current-prefix-arg 'ask)))
5806 (when (eq type 'ask)
5811 "%sFile type (mbox, babyl, digest, forward, mmfd, guess) [mbdfag]: "
5813 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
5814 ((= char ?b) 'babyl)
5815 ((= char ?d) 'digest)
5816 ((= char ?f) 'forward)
5818 (t (setq err (format "%c unknown. " char))
5821 (let* ((file (expand-file-name file))
5822 (name (gnus-generate-new-group-name
5823 (gnus-group-prefixed-name
5824 (file-name-nondirectory file) '(nndoc "")))))
5825 (gnus-group-make-group
5826 (gnus-group-real-name name)
5827 (list 'nndoc (file-name-nondirectory file)
5828 (list 'nndoc-address file)
5829 (list 'nndoc-article-type (or type 'guess))))))
5831 (defun gnus-group-make-archive-group (&optional all)
5832 "Create the (ding) Gnus archive group of the most recent articles.
5833 Given a prefix, create a full group."
5835 (let ((group (gnus-group-prefixed-name
5836 (if all "ding.archives" "ding.recent") '(nndir ""))))
5837 (and (gnus-gethash group gnus-newsrc-hashtb)
5838 (error "Archive group already exists"))
5839 (gnus-group-make-group
5840 (gnus-group-real-name group)
5841 (list 'nndir (if all "hpc" "edu")
5842 (list 'nndir-directory
5843 (if all gnus-group-archive-directory
5844 gnus-group-recent-archive-directory))))))
5846 (defun gnus-group-make-directory-group (dir)
5847 "Create an nndir group.
5848 The user will be prompted for a directory. The contents of this
5849 directory will be used as a newsgroup. The directory should contain
5850 mail messages or news articles in files that have numeric names."
5852 (list (read-file-name "Create group from directory: ")))
5853 (or (file-exists-p dir) (error "No such directory"))
5854 (or (file-directory-p dir) (error "Not a directory"))
5858 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
5860 (gnus-group-prefixed-name
5861 (concat (file-name-as-directory (directory-file-name dir))
5864 (setq ext (format "<%d>" (setq i (1+ i)))))
5865 (gnus-group-make-group
5866 (gnus-group-real-name group)
5867 (list 'nndir group (list 'nndir-directory dir)))))
5869 (defun gnus-group-make-kiboze-group (group address scores)
5870 "Create an nnkiboze group.
5871 The user will be prompted for a name, a regexp to match groups, and
5872 score file entries for articles to include in the group."
5875 (read-string "nnkiboze group name: ")
5876 (read-string "Source groups (regexp): ")
5877 (let ((headers (mapcar (lambda (group) (list group))
5878 '("subject" "from" "number" "date" "message-id"
5879 "references" "chars" "lines" "xref"
5880 "followup" "all" "body" "head")))
5881 scores header regexp regexps)
5882 (while (not (equal "" (setq header (completing-read
5883 "Match on header: " headers nil t))))
5885 (while (not (equal "" (setq regexp (read-string
5886 (format "Match on %s (string): "
5888 (setq regexps (cons (list regexp nil nil 'r) regexps)))
5889 (setq scores (cons (cons header regexps) scores)))
5891 (gnus-group-make-group group "nnkiboze" address)
5892 (nnheader-temp-write (gnus-score-file-name (concat "nnkiboze:" group))
5893 (let (emacs-lisp-mode-hook)
5894 (pp scores (current-buffer)))))
5896 (defun gnus-group-add-to-virtual (n vgroup)
5897 "Add the current group to a virtual group."
5899 (list current-prefix-arg
5900 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
5902 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
5903 (error "%s is not an nnvirtual group" vgroup))
5904 (let* ((groups (gnus-group-process-prefix n))
5905 (method (gnus-info-method (gnus-get-info vgroup))))
5906 (setcar (cdr method)
5908 (nth 1 method) "\\|"
5911 (gnus-group-remove-mark s)
5912 (concat "\\(^" (regexp-quote s) "$\\)"))
5914 (gnus-group-position-point))
5916 (defun gnus-group-make-empty-virtual (group)
5917 "Create a new, fresh, empty virtual group."
5918 (interactive "sCreate new, empty virtual group: ")
5919 (let* ((method (list 'nnvirtual "^$"))
5920 (pgroup (gnus-group-prefixed-name group method)))
5921 ;; Check whether it exists already.
5922 (and (gnus-gethash pgroup gnus-newsrc-hashtb)
5923 (error "Group %s already exists." pgroup))
5924 ;; Subscribe the new group after the group on the current line.
5925 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
5926 (gnus-group-update-group pgroup)
5928 (gnus-group-position-point)))
5930 (defun gnus-group-enter-directory (dir)
5931 "Enter an ephemeral nneething group."
5932 (interactive "DDirectory to read: ")
5933 (let* ((method (list 'nneething dir))
5934 (leaf (gnus-group-prefixed-name
5935 (file-name-nondirectory (directory-file-name dir))
5937 (name (gnus-generate-new-group-name leaf)))
5938 (let ((nneething-read-only t))
5939 (or (gnus-group-read-ephemeral-group
5941 (cons (current-buffer) (if (eq major-mode 'gnus-summary-mode)
5943 (error "Couldn't enter %s" dir)))))
5945 ;; Group sorting commands
5946 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
5948 (defun gnus-group-sort-groups (func &optional reverse)
5949 "Sort the group buffer according to FUNC.
5950 If REVERSE, reverse the sorting order."
5951 (interactive (list gnus-group-sort-function
5952 current-prefix-arg))
5954 ((not (listp func)) func)
5956 ((= 1 (length func)) (car func))
5958 ,(gnus-make-sort-function
5959 (reverse func)))))))
5960 ;; We peel off the dummy group from the alist.
5962 (when (equal (car (gnus-info-group gnus-newsrc-alist)) "dummy.group")
5963 (pop gnus-newsrc-alist))
5965 (setq gnus-newsrc-alist
5966 (sort gnus-newsrc-alist func))
5968 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
5969 ;; Regenerate the hash table.
5970 (gnus-make-hashtable-from-newsrc-alist)
5971 (gnus-group-list-groups))))
5973 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
5974 "Sort the group buffer alphabetically by group name.
5975 If REVERSE, sort in reverse order."
5977 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
5979 (defun gnus-group-sort-groups-by-unread (&optional reverse)
5980 "Sort the group buffer by number of unread articles.
5981 If REVERSE, sort in reverse order."
5983 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
5985 (defun gnus-group-sort-groups-by-level (&optional reverse)
5986 "Sort the group buffer by group level.
5987 If REVERSE, sort in reverse order."
5989 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
5991 (defun gnus-group-sort-groups-by-score (&optional reverse)
5992 "Sort the group buffer by group score.
5993 If REVERSE, sort in reverse order."
5995 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
5997 (defun gnus-group-sort-groups-by-rank (&optional reverse)
5998 "Sort the group buffer by group rank.
5999 If REVERSE, sort in reverse order."
6001 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
6003 (defun gnus-group-sort-groups-by-method (&optional reverse)
6004 "Sort the group buffer alphabetically by backend name.
6005 If REVERSE, sort in reverse order."
6007 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
6009 (defun gnus-group-sort-by-alphabet (info1 info2)
6010 "Sort alphabetically."
6011 (string< (gnus-info-group info1) (gnus-info-group info2)))
6013 (defun gnus-group-sort-by-unread (info1 info2)
6014 "Sort by number of unread articles."
6015 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
6016 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
6017 (< (or (and (numberp n1) n1) 0)
6018 (or (and (numberp n2) n2) 0))))
6020 (defun gnus-group-sort-by-level (info1 info2)
6022 (< (gnus-info-level info1) (gnus-info-level info2)))
6024 (defun gnus-group-sort-by-method (info1 info2)
6025 "Sort alphabetically by backend name."
6026 (string< (symbol-name (car (gnus-find-method-for-group
6027 (gnus-info-group info1) info1)))
6028 (symbol-name (car (gnus-find-method-for-group
6029 (gnus-info-group info2) info2)))))
6031 (defun gnus-group-sort-by-score (info1 info2)
6032 "Sort by group score."
6033 (< (gnus-info-score info1) (gnus-info-score info2)))
6035 (defun gnus-group-sort-by-rank (info1 info2)
6036 "Sort by level and score."
6037 (let ((level1 (gnus-info-level info1))
6038 (level2 (gnus-info-level info2)))
6039 (or (< level1 level2)
6040 (and (= level1 level2)
6041 (> (gnus-info-score info1) (gnus-info-score info2))))))
6043 ;; Group catching up.
6045 (defun gnus-group-clear-data (n)
6046 "Clear all marks and read ranges from the current group."
6048 (let ((groups (gnus-group-process-prefix n))
6050 (while (setq group (pop groups))
6051 (setq info (gnus-get-info group))
6052 (gnus-info-set-read info nil)
6053 (when (gnus-info-marks info)
6054 (gnus-info-set-marks info nil))
6055 (gnus-get-unread-articles-in-group info (gnus-active group) t)
6056 (when (gnus-group-goto-group group)
6057 (gnus-group-remove-mark group)
6058 (gnus-group-update-group-line)))))
6060 (defun gnus-group-catchup-current (&optional n all)
6061 "Mark all articles not marked as unread in current newsgroup as read.
6062 If prefix argument N is numeric, the ARG next newsgroups will be
6063 caught up. If ALL is non-nil, marked articles will also be marked as
6064 read. Cross references (Xref: header) of articles are ignored.
6065 The difference between N and actual number of newsgroups that were
6066 caught up is returned."
6068 (unless (gnus-group-group-name)
6069 (error "No group on the current line"))
6070 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
6074 "Do you really want to mark all articles as read? "
6075 "Mark all unread articles as read? "))))
6077 (let ((groups (gnus-group-process-prefix n))
6080 ;; Virtual groups have to be given special treatment.
6081 (let ((method (gnus-find-method-for-group (car groups))))
6082 (if (eq 'nnvirtual (car method))
6083 (nnvirtual-catchup-group
6084 (gnus-group-real-name (car groups)) (nth 1 method) all)))
6085 (gnus-group-remove-mark (car groups))
6086 (if (>= (gnus-group-group-level) gnus-level-zombie)
6087 (gnus-message 2 "Dead groups can't be caught up")
6089 (gnus-group-goto-group (car groups))
6090 (gnus-group-catchup (car groups) all))
6091 (gnus-group-update-group-line)
6092 (setq ret (1+ ret))))
6093 (setq groups (cdr groups)))
6094 (gnus-group-next-unread-group 1)
6097 (defun gnus-group-catchup-current-all (&optional n)
6098 "Mark all articles in current newsgroup as read.
6099 Cross references (Xref: header) of articles are ignored."
6101 (gnus-group-catchup-current n 'all))
6103 (defun gnus-group-catchup (group &optional all)
6104 "Mark all articles in GROUP as read.
6105 If ALL is non-nil, all articles are marked as read.
6106 The return value is the number of articles that were marked as read,
6107 or nil if no action could be taken."
6108 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
6110 ;; Do the updating only if the newsgroup isn't killed.
6111 (if (not (numberp (car entry)))
6112 (gnus-message 1 "Can't catch up; non-active group")
6113 ;; Do auto-expirable marks if that's required.
6114 (when (gnus-group-auto-expirable-p group)
6115 (gnus-add-marked-articles
6116 group 'expire (gnus-list-of-unread-articles group))
6118 (let ((marks (nth 3 (nth 2 entry))))
6119 (gnus-add-marked-articles
6120 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))
6121 (gnus-add-marked-articles
6122 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))))))
6124 (gnus-update-read-articles group nil)
6125 ;; Also nix out the lists of marks and dormants.
6127 (gnus-add-marked-articles group 'tick nil nil 'force)
6128 (gnus-add-marked-articles group 'dormant nil nil 'force))
6129 (run-hooks 'gnus-group-catchup-group-hook)
6132 (defun gnus-group-expire-articles (&optional n)
6133 "Expire all expirable articles in the current newsgroup."
6135 (let ((groups (gnus-group-process-prefix n))
6138 (error "No groups to expire"))
6139 (while (setq group (pop groups))
6140 (gnus-group-remove-mark group)
6141 (when (gnus-check-backend-function 'request-expire-articles group)
6142 (gnus-message 6 "Expiring articles in %s..." group)
6143 (let* ((info (gnus-get-info group))
6144 (expirable (if (gnus-group-total-expirable-p group)
6145 (cons nil (gnus-list-of-read-articles group))
6146 (assq 'expire (gnus-info-marks info))))
6147 (expiry-wait (gnus-group-get-parameter group 'expiry-wait)))
6151 (gnus-compress-sequence
6153 ;; We set the expiry variables to the groupp
6155 (let ((nnmail-expiry-wait-function nil)
6156 (nnmail-expiry-wait expiry-wait))
6157 (gnus-request-expire-articles
6158 (gnus-uncompress-sequence (cdr expirable)) group))
6159 ;; Just expire using the normal expiry values.
6160 (gnus-request-expire-articles
6161 (gnus-uncompress-sequence (cdr expirable)) group)))))
6162 (gnus-message 6 "Expiring articles in %s...done" group)))
6163 (gnus-group-position-point))))
6165 (defun gnus-group-expire-all-groups ()
6166 "Expire all expirable articles in all newsgroups."
6169 (gnus-message 5 "Expiring...")
6170 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
6171 (cdr gnus-newsrc-alist))))
6172 (gnus-group-expire-articles nil)))
6173 (gnus-group-position-point)
6174 (gnus-message 5 "Expiring...done"))
6176 (defun gnus-group-set-current-level (n level)
6177 "Set the level of the next N groups to LEVEL."
6182 (let ((s (read-string
6183 (format "Level (default %s): "
6184 (or (gnus-group-group-level)
6185 gnus-level-default-subscribed)))))
6186 (if (string-match "^\\s-*$" s)
6187 (int-to-string (or (gnus-group-group-level)
6188 gnus-level-default-subscribed))
6190 (or (and (>= level 1) (<= level gnus-level-killed))
6191 (error "Illegal level: %d" level))
6192 (let ((groups (gnus-group-process-prefix n))
6194 (while (setq group (pop groups))
6195 (gnus-group-remove-mark group)
6196 (gnus-message 6 "Changed level of %s from %d to %d"
6197 group (or (gnus-group-group-level) gnus-level-killed)
6199 (gnus-group-change-level
6200 group level (or (gnus-group-group-level) gnus-level-killed))
6201 (gnus-group-update-group-line)))
6202 (gnus-group-position-point))
6204 (defun gnus-group-unsubscribe-current-group (&optional n)
6205 "Toggle subscription of the current group.
6206 If given numerical prefix, toggle the N next groups."
6208 (let ((groups (gnus-group-process-prefix n))
6211 (setq group (car groups)
6212 groups (cdr groups))
6213 (gnus-group-remove-mark group)
6214 (gnus-group-unsubscribe-group
6215 group (if (<= (gnus-group-group-level) gnus-level-subscribed)
6216 gnus-level-default-unsubscribed
6217 gnus-level-default-subscribed) t)
6218 (gnus-group-update-group-line))
6219 (gnus-group-next-group 1)))
6221 (defun gnus-group-unsubscribe-group (group &optional level silent)
6222 "Toggle subscription to GROUP.
6223 Killed newsgroups are subscribed. If SILENT, don't try to update the
6226 (list (completing-read
6227 "Group: " gnus-active-hashtb nil
6228 (gnus-read-active-file-p)
6230 'gnus-group-history)))
6231 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
6233 ((string-match "^[ \t]$" group)
6234 (error "Empty group name"))
6236 ;; Toggle subscription flag.
6237 (gnus-group-change-level
6238 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
6239 gnus-level-subscribed)
6240 (1+ gnus-level-subscribed)
6241 gnus-level-default-subscribed)))
6243 (gnus-group-update-group group)))
6244 ((and (stringp group)
6245 (or (not (gnus-read-active-file-p))
6246 (gnus-active group)))
6247 ;; Add new newsgroup.
6248 (gnus-group-change-level
6250 (if level level gnus-level-default-subscribed)
6251 (or (and (member group gnus-zombie-list)
6254 (and (gnus-group-group-name)
6255 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
6257 (gnus-group-update-group group)))
6258 (t (error "No such newsgroup: %s" group)))
6259 (gnus-group-position-point)))
6261 (defun gnus-group-transpose-groups (n)
6262 "Move the current newsgroup up N places.
6263 If given a negative prefix, move down instead. The difference between
6264 N and the number of steps taken is returned."
6266 (or (gnus-group-group-name)
6267 (error "No group on current line"))
6268 (gnus-group-kill-group 1)
6270 (forward-line (- n))
6271 (gnus-group-yank-group)
6272 (gnus-group-position-point)))
6274 (defun gnus-group-kill-all-zombies ()
6275 "Kill all zombie newsgroups."
6277 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
6278 (setq gnus-zombie-list nil)
6279 (gnus-group-list-groups))
6281 (defun gnus-group-kill-region (begin end)
6282 "Kill newsgroups in current region (excluding current point).
6283 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
6298 (beginning-of-line) ;Important when LINES < 1
6299 (gnus-group-kill-group lines)))
6301 (defun gnus-group-kill-group (&optional n discard)
6302 "Kill the next N groups.
6303 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
6304 However, only groups that were alive can be yanked; already killed
6305 groups or zombie groups can't be yanked.
6306 The return value is the name of the group that was killed, or a list
6309 (let ((buffer-read-only nil)
6310 (groups (gnus-group-process-prefix n))
6311 group entry level out)
6312 (if (< (length groups) 10)
6313 ;; This is faster when there are few groups.
6315 (push (setq group (pop groups)) out)
6316 (gnus-group-remove-mark group)
6317 (setq level (gnus-group-group-level))
6319 (when (and (not discard)
6320 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
6321 (push (cons (car entry) (nth 2 entry))
6322 gnus-list-of-killed-groups))
6323 (gnus-group-change-level
6324 (if entry entry group) gnus-level-killed (if entry nil level)))
6325 ;; If there are lots and lots of groups to be killed, we use
6326 ;; this thing instead.
6328 (setq groups (nreverse groups))
6330 (gnus-group-remove-mark (setq group (pop groups)))
6332 (push group gnus-killed-list)
6333 (setq gnus-newsrc-alist
6334 (delq (assoc group gnus-newsrc-alist)
6336 (when gnus-group-change-level-function
6337 (funcall gnus-group-change-level-function group 9 3))
6339 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
6340 (push (cons (car entry) (nth 2 entry))
6341 gnus-list-of-killed-groups)
6342 (setcdr (cdr entry) (cdddr entry)))
6343 ((member group gnus-zombie-list)
6344 (setq gnus-zombie-list (delete group gnus-zombie-list)))))
6345 (gnus-make-hashtable-from-newsrc-alist)))
6347 (gnus-group-position-point)
6348 (if (< (length out) 2) (car out) (nreverse out))))
6350 (defun gnus-group-yank-group (&optional arg)
6351 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
6352 inserting it before the current newsgroup. The numeric ARG specifies
6353 how many newsgroups are to be yanked. The name of the newsgroup yanked
6354 is returned, or (if several groups are yanked) a list of yanked groups
6357 (setq arg (or arg 1))
6358 (let (info group prev out)
6359 (while (>= (decf arg) 0)
6360 (if (not (setq info (pop gnus-list-of-killed-groups)))
6361 (error "No more newsgroups to yank"))
6362 (push (setq group (nth 1 info)) out)
6363 ;; Find which newsgroup to insert this one before - search
6364 ;; backward until something suitable is found. If there are no
6365 ;; other newsgroups in this buffer, just make this newsgroup the
6367 (setq prev (gnus-group-group-name))
6368 (gnus-group-change-level
6369 info (gnus-info-level (cdr info)) gnus-level-killed
6370 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
6372 (gnus-group-insert-group-line-info group))
6374 (gnus-group-position-point)
6375 (if (< (length out) 2) (car out) (nreverse out))))
6377 (defun gnus-group-kill-level (level)
6378 "Kill all groups that is on a certain LEVEL."
6379 (interactive "nKill all groups on level: ")
6381 ((= level gnus-level-zombie)
6382 (setq gnus-killed-list
6383 (nconc gnus-zombie-list gnus-killed-list))
6384 (setq gnus-zombie-list nil))
6385 ((and (< level gnus-level-zombie)
6387 (or gnus-expert-user
6390 "Do you really want to kill all groups on level %d? "
6392 (let* ((prev gnus-newsrc-alist)
6395 (if (= (gnus-info-level level) level)
6396 (setcdr prev (cdr alist))
6398 (setq alist (cdr alist)))
6399 (gnus-make-hashtable-from-newsrc-alist)
6400 (gnus-group-list-groups)))
6402 (error "Can't kill; illegal level: %d" level))))
6404 (defun gnus-group-list-all-groups (&optional arg)
6405 "List all newsgroups with level ARG or lower.
6406 Default is gnus-level-unsubscribed, which lists all subscribed and most
6407 unsubscribed groups."
6409 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
6411 ;; Redefine this to list ALL killed groups if prefix arg used.
6412 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
6413 (defun gnus-group-list-killed (&optional arg)
6414 "List all killed newsgroups in the group buffer.
6415 If ARG is non-nil, list ALL killed groups known to Gnus. This may
6416 entail asking the server for the groups."
6418 ;; Find all possible killed newsgroups if arg.
6420 (gnus-get-killed-groups))
6421 (if (not gnus-killed-list)
6422 (gnus-message 6 "No killed groups")
6423 (let (gnus-group-list-mode)
6424 (funcall gnus-group-prepare-function
6425 gnus-level-killed t gnus-level-killed))
6426 (goto-char (point-min)))
6427 (gnus-group-position-point))
6429 (defun gnus-group-list-zombies ()
6430 "List all zombie newsgroups in the group buffer."
6432 (if (not gnus-zombie-list)
6433 (gnus-message 6 "No zombie groups")
6434 (let (gnus-group-list-mode)
6435 (funcall gnus-group-prepare-function
6436 gnus-level-zombie t gnus-level-zombie))
6437 (goto-char (point-min)))
6438 (gnus-group-position-point))
6440 (defun gnus-group-list-active ()
6441 "List all groups that are available from the server(s)."
6443 ;; First we make sure that we have really read the active file.
6444 (unless (gnus-read-active-file-p)
6445 (let ((gnus-read-active-file t))
6446 (gnus-read-active-file)))
6447 ;; Find all groups and sort them.
6455 (setq list (cons (symbol-name sym) list))))
6459 (buffer-read-only nil))
6462 (gnus-group-insert-group-line-info (pop groups)))
6463 (goto-char (point-min))))
6465 (defun gnus-activate-all-groups (level)
6466 "Activate absolutely all groups."
6467 (interactive (list 7))
6468 (let ((gnus-activate-level level)
6469 (gnus-activate-foreign-newsgroups level))
6470 (gnus-group-get-new-news)))
6472 (defun gnus-group-get-new-news (&optional arg)
6473 "Get newly arrived articles.
6474 If ARG is a number, it specifies which levels you are interested in
6475 re-scanning. If ARG is non-nil and not a number, this will force
6476 \"hard\" re-reading of the active files from all servers."
6478 (run-hooks 'gnus-get-new-news-hook)
6479 ;; We might read in new NoCeM messages here.
6480 (when (and gnus-use-nocem
6482 (gnus-nocem-scan-groups))
6483 ;; If ARG is not a number, then we read the active file.
6484 (when (and arg (not (numberp arg)))
6485 (let ((gnus-read-active-file t))
6486 (gnus-read-active-file))
6489 (setq arg (gnus-group-default-level arg t))
6490 (if (and gnus-read-active-file (not arg))
6492 (gnus-read-active-file)
6493 (gnus-get-unread-articles arg))
6494 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
6495 (gnus-get-unread-articles arg)))
6496 (run-hooks 'gnus-after-getting-new-news-hook)
6497 (gnus-group-list-groups))
6499 (defun gnus-group-get-new-news-this-group (&optional n)
6500 "Check for newly arrived news in the current group (and the N-1 next groups).
6501 The difference between N and the number of newsgroup checked is returned.
6502 If N is negative, this group and the N-1 previous groups will be checked."
6504 (let* ((groups (gnus-group-process-prefix n))
6505 (ret (if (numberp n) (- n (length groups)) 0))
6506 (beg (unless n (point)))
6508 (while (setq group (pop groups))
6509 (gnus-group-remove-mark group)
6510 (if (gnus-activate-group group 'scan)
6512 (gnus-get-unread-articles-in-group
6513 (gnus-get-info group) (gnus-active group) t)
6514 (unless (gnus-virtual-group-p group)
6515 (gnus-close-group group))
6516 (gnus-group-update-group group))
6517 (gnus-error 3 "%s error: %s" group (gnus-status-message group))))
6518 (when beg (goto-char beg))
6519 (when gnus-goto-next-group-when-activating
6520 (gnus-group-next-unread-group 1 t))
6521 (gnus-summary-position-point)
6524 (defun gnus-group-fetch-faq (group &optional faq-dir)
6525 "Fetch the FAQ for the current group."
6528 (and (gnus-group-group-name)
6529 (gnus-group-real-name (gnus-group-group-name)))
6530 (cond (current-prefix-arg
6532 "Faq dir: " (and (listp gnus-group-faq-directory)
6533 (mapcar (lambda (file) (list file))
6534 gnus-group-faq-directory)))))))
6536 (setq faq-dir (if (listp gnus-group-faq-directory)
6537 (car gnus-group-faq-directory)
6538 gnus-group-faq-directory)))
6539 (or group (error "No group name given"))
6540 (let ((file (concat (file-name-as-directory faq-dir)
6541 (gnus-group-real-name group))))
6542 (if (not (file-exists-p file))
6543 (error "No such file: %s" file)
6546 (defun gnus-group-describe-group (force &optional group)
6547 "Display a description of the current newsgroup."
6548 (interactive (list current-prefix-arg (gnus-group-group-name)))
6550 gnus-description-hashtb)
6551 (gnus-sethash group nil gnus-description-hashtb))
6552 (let ((method (gnus-find-method-for-group group))
6554 (or group (error "No group name given"))
6555 (and (or (and gnus-description-hashtb
6556 ;; We check whether this group's method has been
6557 ;; queried for a description file.
6559 (gnus-group-prefixed-name "" method)
6560 gnus-description-hashtb))
6561 (setq desc (gnus-group-get-description group))
6562 (gnus-read-descriptions-file method))
6564 (or desc (gnus-gethash group gnus-description-hashtb)
6565 "No description available")))))
6567 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6568 (defun gnus-group-describe-all-groups (&optional force)
6569 "Pop up a buffer with descriptions of all newsgroups."
6571 (and force (setq gnus-description-hashtb nil))
6572 (if (not (or gnus-description-hashtb
6573 (gnus-read-all-descriptions-files)))
6574 (error "Couldn't request descriptions file"))
6575 (let ((buffer-read-only nil)
6581 (insert (format " *: %-20s %s\n" (symbol-name group)
6582 (symbol-value group)))
6583 (gnus-add-text-properties
6584 b (1+ b) (list 'gnus-group group
6585 'gnus-unread t 'gnus-marked nil
6586 'gnus-level (1+ gnus-level-subscribed))))
6587 gnus-description-hashtb)
6588 (goto-char (point-min))
6589 (gnus-group-position-point)))
6591 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
6592 (defun gnus-group-apropos (regexp &optional search-description)
6593 "List all newsgroups that have names that match a regexp."
6594 (interactive "sGnus apropos (regexp): ")
6596 (obuf (current-buffer))
6598 ;; Go through all newsgroups that are known to Gnus.
6601 (and (symbol-name group)
6602 (string-match regexp (symbol-name group))
6603 (setq groups (cons (symbol-name group) groups))))
6605 ;; Also go through all descriptions that are known to Gnus.
6606 (when search-description
6609 (and (string-match regexp (symbol-value group))
6610 (gnus-active (symbol-name group))
6611 (setq groups (cons (symbol-name group) groups))))
6612 gnus-description-hashtb))
6614 (gnus-message 3 "No groups matched \"%s\"." regexp)
6615 ;; Print out all the groups.
6617 (pop-to-buffer "*Gnus Help*")
6618 (buffer-disable-undo (current-buffer))
6620 (setq groups (sort groups 'string<))
6622 ;; Groups may be entered twice into the list of groups.
6623 (if (not (string= (car groups) prev))
6625 (insert (setq prev (car groups)) "\n")
6626 (if (and gnus-description-hashtb
6627 (setq des (gnus-gethash (car groups)
6628 gnus-description-hashtb)))
6629 (insert " " des "\n"))))
6630 (setq groups (cdr groups)))
6631 (goto-char (point-min))))
6632 (pop-to-buffer obuf)))
6634 (defun gnus-group-description-apropos (regexp)
6635 "List all newsgroups that have names or descriptions that match a regexp."
6636 (interactive "sGnus description apropos (regexp): ")
6637 (if (not (or gnus-description-hashtb
6638 (gnus-read-all-descriptions-files)))
6639 (error "Couldn't request descriptions file"))
6640 (gnus-group-apropos regexp t))
6642 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6643 (defun gnus-group-list-matching (level regexp &optional all lowest)
6644 "List all groups with unread articles that match REGEXP.
6645 If the prefix LEVEL is non-nil, it should be a number that says which
6646 level to cut off listing groups.
6647 If ALL, also list groups with no unread articles.
6648 If LOWEST, don't list groups with level lower than LOWEST.
6650 This command may read the active file."
6651 (interactive "P\nsList newsgroups matching: ")
6652 ;; First make sure active file has been read.
6654 (> (prefix-numeric-value level) gnus-level-killed))
6655 (gnus-get-killed-groups))
6656 (gnus-group-prepare-flat (or level gnus-level-subscribed)
6657 all (or lowest 1) regexp)
6658 (goto-char (point-min))
6659 (gnus-group-position-point))
6661 (defun gnus-group-list-all-matching (level regexp &optional lowest)
6662 "List all groups that match REGEXP.
6663 If the prefix LEVEL is non-nil, it should be a number that says which
6664 level to cut off listing groups.
6665 If LOWEST, don't list groups with level lower than LOWEST."
6666 (interactive "P\nsList newsgroups matching: ")
6667 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
6669 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
6670 (defun gnus-group-save-newsrc (&optional force)
6671 "Save the Gnus startup files.
6672 If FORCE, force saving whether it is necessary or not."
6674 (gnus-save-newsrc-file force))
6676 (defun gnus-group-restart (&optional arg)
6677 "Force Gnus to read the .newsrc file."
6679 (when (gnus-yes-or-no-p
6680 (format "Are you sure you want to read %s? "
6681 gnus-current-startup-file))
6682 (gnus-save-newsrc-file)
6683 (gnus-setup-news 'force)
6684 (gnus-group-list-groups arg)))
6686 (defun gnus-group-read-init-file ()
6687 "Read the Gnus elisp init file."
6689 (gnus-read-init-file))
6691 (defun gnus-group-check-bogus-groups (&optional silent)
6692 "Check bogus newsgroups.
6693 If given a prefix, don't ask for confirmation before removing a bogus
6696 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
6697 (gnus-group-list-groups))
6699 (defun gnus-group-edit-global-kill (&optional article group)
6700 "Edit the global kill file.
6701 If GROUP, edit that local kill file instead."
6703 (setq gnus-current-kill-article article)
6704 (gnus-kill-file-edit-file group)
6707 (substitute-command-keys
6708 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
6709 (if group "local" "global")))))
6711 (defun gnus-group-edit-local-kill (article group)
6712 "Edit a local kill file."
6713 (interactive (list nil (gnus-group-group-name)))
6714 (gnus-group-edit-global-kill article group))
6716 (defun gnus-group-force-update ()
6717 "Update `.newsrc' file."
6719 (gnus-save-newsrc-file))
6721 (defun gnus-group-suspend ()
6722 "Suspend the current Gnus session.
6723 In fact, cleanup buffers except for group mode buffer.
6724 The hook gnus-suspend-gnus-hook is called before actually suspending."
6726 (run-hooks 'gnus-suspend-gnus-hook)
6727 ;; Kill Gnus buffers except for group mode buffer.
6728 (let ((group-buf (get-buffer gnus-group-buffer)))
6729 ;; Do this on a separate list in case the user does a ^G before we finish
6730 (let ((gnus-buffer-list
6731 (delq group-buf (delq gnus-dribble-buffer
6732 (append gnus-buffer-list nil)))))
6733 (while gnus-buffer-list
6734 (gnus-kill-buffer (car gnus-buffer-list))
6735 (setq gnus-buffer-list (cdr gnus-buffer-list))))
6738 (setq gnus-buffer-list (list group-buf))
6739 (bury-buffer group-buf)
6740 (delete-windows-on group-buf t)))))
6742 (defun gnus-group-clear-dribble ()
6743 "Clear all information from the dribble buffer."
6745 (gnus-dribble-clear)
6746 (gnus-message 7 "Cleared dribble buffer"))
6748 (defun gnus-group-exit ()
6749 "Quit reading news after updating .newsrc.eld and .newsrc.
6750 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6753 (or noninteractive ;For gnus-batch-kill
6754 (not gnus-interactive-exit) ;Without confirmation
6756 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
6757 (run-hooks 'gnus-exit-gnus-hook)
6758 ;; Offer to save data from non-quitted summary buffers.
6759 (gnus-offer-save-summaries)
6760 ;; Save the newsrc file(s).
6761 (gnus-save-newsrc-file)
6763 (gnus-close-backends)
6764 ;; Reset everything.
6766 ;; Allow the user to do things after cleaning up.
6767 (run-hooks 'gnus-after-exiting-gnus-hook)))
6769 (defun gnus-close-backends ()
6770 ;; Send a close request to all backends that support such a request.
6771 (let ((methods gnus-valid-select-methods)
6774 (if (fboundp (setq func (intern (concat (caar methods)
6775 "-request-close"))))
6777 (setq methods (cdr methods)))))
6779 (defun gnus-group-quit ()
6780 "Quit reading news without updating .newsrc.eld or .newsrc.
6781 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6783 (when (or noninteractive ;For gnus-batch-kill
6784 (zerop (buffer-size))
6785 (not (gnus-server-opened gnus-select-method))
6787 (not gnus-current-startup-file)
6789 (format "Quit reading news without saving %s? "
6790 (file-name-nondirectory gnus-current-startup-file))))
6791 (run-hooks 'gnus-exit-gnus-hook)
6792 (if gnus-use-full-window
6793 (delete-other-windows)
6794 (gnus-remove-some-windows))
6796 (gnus-close-backends)
6798 ;; Allow the user to do things after cleaning up.
6799 (run-hooks 'gnus-after-exiting-gnus-hook)))
6801 (defun gnus-offer-save-summaries ()
6802 "Offer to save all active summary buffers."
6804 (let ((buflist (buffer-list))
6806 ;; Go through all buffers and find all summaries.
6808 (and (setq bufname (buffer-name (car buflist)))
6809 (string-match "Summary" bufname)
6811 (set-buffer bufname)
6812 ;; We check that this is, indeed, a summary buffer.
6813 (and (eq major-mode 'gnus-summary-mode)
6814 ;; Also make sure this isn't bogus.
6815 gnus-newsgroup-prepared))
6816 (push bufname buffers))
6817 (setq buflist (cdr buflist)))
6818 ;; Go through all these summary buffers and offer to save them.
6821 "Update summary buffer %s? "
6822 (lambda (buf) (set-buffer buf) (gnus-summary-exit))
6825 (defun gnus-group-describe-briefly ()
6826 "Give a one line description of the group mode commands."
6828 (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")))
6830 (defun gnus-group-browse-foreign-server (method)
6831 "Browse a foreign news server.
6832 If called interactively, this function will ask for a select method
6833 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
6834 If not, METHOD should be a list where the first element is the method
6835 and the second element is the address."
6837 (list (let ((how (completing-read
6839 (append gnus-valid-select-methods gnus-server-alist)
6840 nil t (cons "nntp" 0) 'gnus-method-history)))
6841 ;; We either got a backend name or a virtual server name.
6842 ;; If the first, we also need an address.
6843 (if (assoc how gnus-valid-select-methods)
6845 ;; Suggested by mapjph@bath.ac.uk.
6848 (mapcar (lambda (server) (list server))
6849 gnus-secondary-servers)))
6850 ;; We got a server name, so we find the method.
6851 (gnus-server-to-method how)))))
6852 (gnus-browse-foreign-server method))
6856 ;;; Gnus summary mode
6859 (defvar gnus-summary-mode-map nil)
6861 (put 'gnus-summary-mode 'mode-class 'special)
6863 (unless gnus-summary-mode-map
6864 (setq gnus-summary-mode-map (make-keymap))
6865 (suppress-keymap gnus-summary-mode-map)
6867 ;; Non-orthogonal keys
6869 (gnus-define-keys gnus-summary-mode-map
6870 " " gnus-summary-next-page
6871 "\177" gnus-summary-prev-page
6872 [delete] gnus-summary-prev-page
6873 "\r" gnus-summary-scroll-up
6874 "n" gnus-summary-next-unread-article
6875 "p" gnus-summary-prev-unread-article
6876 "N" gnus-summary-next-article
6877 "P" gnus-summary-prev-article
6878 "\M-\C-n" gnus-summary-next-same-subject
6879 "\M-\C-p" gnus-summary-prev-same-subject
6880 "\M-n" gnus-summary-next-unread-subject
6881 "\M-p" gnus-summary-prev-unread-subject
6882 "." gnus-summary-first-unread-article
6883 "," gnus-summary-best-unread-article
6884 "\M-s" gnus-summary-search-article-forward
6885 "\M-r" gnus-summary-search-article-backward
6886 "<" gnus-summary-beginning-of-article
6887 ">" gnus-summary-end-of-article
6888 "j" gnus-summary-goto-article
6889 "^" gnus-summary-refer-parent-article
6890 "\M-^" gnus-summary-refer-article
6891 "u" gnus-summary-tick-article-forward
6892 "!" gnus-summary-tick-article-forward
6893 "U" gnus-summary-tick-article-backward
6894 "d" gnus-summary-mark-as-read-forward
6895 "D" gnus-summary-mark-as-read-backward
6896 "E" gnus-summary-mark-as-expirable
6897 "\M-u" gnus-summary-clear-mark-forward
6898 "\M-U" gnus-summary-clear-mark-backward
6899 "k" gnus-summary-kill-same-subject-and-select
6900 "\C-k" gnus-summary-kill-same-subject
6901 "\M-\C-k" gnus-summary-kill-thread
6902 "\M-\C-l" gnus-summary-lower-thread
6903 "e" gnus-summary-edit-article
6904 "#" gnus-summary-mark-as-processable
6905 "\M-#" gnus-summary-unmark-as-processable
6906 "\M-\C-t" gnus-summary-toggle-threads
6907 "\M-\C-s" gnus-summary-show-thread
6908 "\M-\C-h" gnus-summary-hide-thread
6909 "\M-\C-f" gnus-summary-next-thread
6910 "\M-\C-b" gnus-summary-prev-thread
6911 "\M-\C-u" gnus-summary-up-thread
6912 "\M-\C-d" gnus-summary-down-thread
6913 "&" gnus-summary-execute-command
6914 "c" gnus-summary-catchup-and-exit
6915 "\C-w" gnus-summary-mark-region-as-read
6916 "\C-t" gnus-summary-toggle-truncation
6917 "?" gnus-summary-mark-as-dormant
6918 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
6919 "\C-c\C-s\C-n" gnus-summary-sort-by-number
6920 "\C-c\C-s\C-a" gnus-summary-sort-by-author
6921 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
6922 "\C-c\C-s\C-d" gnus-summary-sort-by-date
6923 "\C-c\C-s\C-i" gnus-summary-sort-by-score
6924 "=" gnus-summary-expand-window
6925 "\C-x\C-s" gnus-summary-reselect-current-group
6926 "\M-g" gnus-summary-rescan-group
6927 "w" gnus-summary-stop-page-breaking
6928 "\C-c\C-r" gnus-summary-caesar-message
6929 "\M-t" gnus-summary-toggle-mime
6930 "f" gnus-summary-followup
6931 "F" gnus-summary-followup-with-original
6932 "C" gnus-summary-cancel-article
6933 "r" gnus-summary-reply
6934 "R" gnus-summary-reply-with-original
6935 "\C-c\C-f" gnus-summary-mail-forward
6936 "o" gnus-summary-save-article
6937 "\C-o" gnus-summary-save-article-mail
6938 "|" gnus-summary-pipe-output
6939 "\M-k" gnus-summary-edit-local-kill
6940 "\M-K" gnus-summary-edit-global-kill
6942 "\C-c\C-d" gnus-summary-describe-group
6943 "q" gnus-summary-exit
6944 "Q" gnus-summary-exit-no-update
6945 "\C-c\C-i" gnus-info-find-node
6946 gnus-mouse-2 gnus-mouse-pick-article
6947 "m" gnus-summary-mail-other-window
6948 "a" gnus-summary-post-news
6949 "x" gnus-summary-limit-to-unread
6950 "s" gnus-summary-isearch-article
6951 "t" gnus-article-hide-headers
6952 "g" gnus-summary-show-article
6953 "l" gnus-summary-goto-last-article
6954 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
6955 "\C-d" gnus-summary-enter-digest-group
6957 "*" gnus-cache-enter-article
6958 "\M-*" gnus-cache-remove-article
6959 "\M-&" gnus-summary-universal-argument
6960 "\C-l" gnus-recenter
6961 "I" gnus-summary-increase-score
6962 "L" gnus-summary-lower-score
6964 "V" gnus-summary-score-map
6965 "X" gnus-uu-extract-map
6966 "S" gnus-summary-send-map)
6968 ;; Sort of orthogonal keymap
6969 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
6970 "t" gnus-summary-tick-article-forward
6971 "!" gnus-summary-tick-article-forward
6972 "d" gnus-summary-mark-as-read-forward
6973 "r" gnus-summary-mark-as-read-forward
6974 "c" gnus-summary-clear-mark-forward
6975 " " gnus-summary-clear-mark-forward
6976 "e" gnus-summary-mark-as-expirable
6977 "x" gnus-summary-mark-as-expirable
6978 "?" gnus-summary-mark-as-dormant
6979 "b" gnus-summary-set-bookmark
6980 "B" gnus-summary-remove-bookmark
6981 "#" gnus-summary-mark-as-processable
6982 "\M-#" gnus-summary-unmark-as-processable
6983 "S" gnus-summary-limit-include-expunged
6984 "C" gnus-summary-catchup
6985 "H" gnus-summary-catchup-to-here
6986 "\C-c" gnus-summary-catchup-all
6987 "k" gnus-summary-kill-same-subject-and-select
6988 "K" gnus-summary-kill-same-subject
6989 "P" gnus-uu-mark-map)
6991 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mode-map)
6992 "c" gnus-summary-clear-above
6993 "u" gnus-summary-tick-above
6994 "m" gnus-summary-mark-above
6995 "k" gnus-summary-kill-below)
6997 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
6998 "/" gnus-summary-limit-to-subject
6999 "n" gnus-summary-limit-to-articles
7000 "w" gnus-summary-pop-limit
7001 "s" gnus-summary-limit-to-subject
7002 "a" gnus-summary-limit-to-author
7003 "u" gnus-summary-limit-to-unread
7004 "m" gnus-summary-limit-to-marks
7005 "v" gnus-summary-limit-to-score
7006 "D" gnus-summary-limit-include-dormant
7007 "d" gnus-summary-limit-exclude-dormant
7008 ;; "t" gnus-summary-limit-exclude-thread
7009 "E" gnus-summary-limit-include-expunged
7010 "c" gnus-summary-limit-exclude-childless-dormant
7011 "C" gnus-summary-limit-mark-excluded-as-read)
7013 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
7014 "n" gnus-summary-next-unread-article
7015 "p" gnus-summary-prev-unread-article
7016 "N" gnus-summary-next-article
7017 "P" gnus-summary-prev-article
7018 "\C-n" gnus-summary-next-same-subject
7019 "\C-p" gnus-summary-prev-same-subject
7020 "\M-n" gnus-summary-next-unread-subject
7021 "\M-p" gnus-summary-prev-unread-subject
7022 "f" gnus-summary-first-unread-article
7023 "b" gnus-summary-best-unread-article
7024 "j" gnus-summary-goto-article
7025 "g" gnus-summary-goto-subject
7026 "l" gnus-summary-goto-last-article
7027 "p" gnus-summary-pop-article)
7029 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
7030 "k" gnus-summary-kill-thread
7031 "l" gnus-summary-lower-thread
7032 "i" gnus-summary-raise-thread
7033 "T" gnus-summary-toggle-threads
7034 "t" gnus-summary-rethread-current
7035 "^" gnus-summary-reparent-thread
7036 "s" gnus-summary-show-thread
7037 "S" gnus-summary-show-all-threads
7038 "h" gnus-summary-hide-thread
7039 "H" gnus-summary-hide-all-threads
7040 "n" gnus-summary-next-thread
7041 "p" gnus-summary-prev-thread
7042 "u" gnus-summary-up-thread
7043 "o" gnus-summary-top-thread
7044 "d" gnus-summary-down-thread
7045 "#" gnus-uu-mark-thread
7046 "\M-#" gnus-uu-unmark-thread)
7048 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
7049 "c" gnus-summary-catchup-and-exit
7050 "C" gnus-summary-catchup-all-and-exit
7051 "E" gnus-summary-exit-no-update
7052 "Q" gnus-summary-exit
7053 "Z" gnus-summary-exit
7054 "n" gnus-summary-catchup-and-goto-next-group
7055 "R" gnus-summary-reselect-current-group
7056 "G" gnus-summary-rescan-group
7057 "N" gnus-summary-next-group
7058 "P" gnus-summary-prev-group)
7060 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
7061 " " gnus-summary-next-page
7062 "n" gnus-summary-next-page
7063 "\177" gnus-summary-prev-page
7064 [delete] gnus-summary-prev-page
7065 "p" gnus-summary-prev-page
7066 "\r" gnus-summary-scroll-up
7067 "<" gnus-summary-beginning-of-article
7068 ">" gnus-summary-end-of-article
7069 "b" gnus-summary-beginning-of-article
7070 "e" gnus-summary-end-of-article
7071 "^" gnus-summary-refer-parent-article
7072 "r" gnus-summary-refer-parent-article
7073 "R" gnus-summary-refer-references
7074 "g" gnus-summary-show-article
7075 "s" gnus-summary-isearch-article)
7077 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
7078 "b" gnus-article-add-buttons
7079 "B" gnus-article-add-buttons-to-head
7080 "o" gnus-article-treat-overstrike
7081 ;; "w" gnus-article-word-wrap
7082 "w" gnus-article-fill-cited-article
7083 "c" gnus-article-remove-cr
7084 "L" gnus-article-remove-trailing-blank-lines
7085 "q" gnus-article-de-quoted-unreadable
7086 "f" gnus-article-display-x-face
7087 "l" gnus-summary-stop-page-breaking
7088 "r" gnus-summary-caesar-message
7089 "t" gnus-article-hide-headers
7090 "v" gnus-summary-verbose-headers
7091 "m" gnus-summary-toggle-mime)
7093 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
7094 "a" gnus-article-hide
7095 "h" gnus-article-hide-headers
7096 "b" gnus-article-hide-boring-headers
7097 "s" gnus-article-hide-signature
7098 "c" gnus-article-hide-citation
7099 "p" gnus-article-hide-pgp
7100 "\C-c" gnus-article-hide-citation-maybe)
7102 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
7103 "a" gnus-article-highlight
7104 "h" gnus-article-highlight-headers
7105 "c" gnus-article-highlight-citation
7106 "s" gnus-article-highlight-signature)
7108 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
7109 "z" gnus-article-date-ut
7110 "u" gnus-article-date-ut
7111 "l" gnus-article-date-local
7112 "e" gnus-article-date-lapsed
7113 "o" gnus-article-date-original)
7115 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
7117 "f" gnus-summary-fetch-faq
7118 "d" gnus-summary-describe-group
7119 "h" gnus-summary-describe-briefly
7120 "i" gnus-info-find-node)
7122 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
7123 "e" gnus-summary-expire-articles
7124 "\M-\C-e" gnus-summary-expire-articles-now
7125 "\177" gnus-summary-delete-article
7126 [delete] gnus-summary-delete-article
7127 "m" gnus-summary-move-article
7128 "r" gnus-summary-respool-article
7129 "w" gnus-summary-edit-article
7130 "c" gnus-summary-copy-article
7131 "B" gnus-summary-crosspost-article
7132 "q" gnus-summary-respool-query
7133 "i" gnus-summary-import-article)
7135 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
7136 "o" gnus-summary-save-article
7137 "m" gnus-summary-save-article-mail
7138 "r" gnus-summary-save-article-rmail
7139 "f" gnus-summary-save-article-file
7140 "b" gnus-summary-save-article-body-file
7141 "h" gnus-summary-save-article-folder
7142 "v" gnus-summary-save-article-vm
7143 "p" gnus-summary-pipe-output
7144 "s" gnus-soup-add-article)
7149 (defun gnus-summary-mode (&optional group)
7150 "Major mode for reading articles.
7152 All normal editing commands are switched off.
7153 \\<gnus-summary-mode-map>
7154 Each line in this buffer represents one article. To read an
7155 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
7156 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
7159 You can also post articles and send mail from this buffer. To
7160 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
7161 of an article, type `\\[gnus-summary-reply]'.
7163 There are approx. one gazillion commands you can execute in this
7164 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
7166 The following commands are available:
7168 \\{gnus-summary-mode-map}"
7170 (when (and menu-bar-mode
7171 (gnus-visual-p 'summary-menu 'menu))
7172 (gnus-summary-make-menu-bar))
7173 (kill-all-local-variables)
7174 (gnus-summary-make-local-variables)
7175 (gnus-make-thread-indent-array)
7176 (gnus-simplify-mode-line)
7177 (setq major-mode 'gnus-summary-mode)
7178 (setq mode-name "Summary")
7179 (make-local-variable 'minor-mode-alist)
7180 (use-local-map gnus-summary-mode-map)
7181 (buffer-disable-undo (current-buffer))
7182 (setq buffer-read-only t) ;Disable modification
7183 (setq truncate-lines t)
7184 (setq selective-display t)
7185 (setq selective-display-ellipses t) ;Display `...'
7186 (setq buffer-display-table gnus-summary-display-table)
7187 (setq gnus-newsgroup-name group)
7188 (make-local-variable 'gnus-summary-line-format)
7189 (make-local-variable 'gnus-summary-line-format-spec)
7190 (make-local-variable 'gnus-summary-mark-positions)
7191 (run-hooks 'gnus-summary-mode-hook))
7193 (defun gnus-summary-make-local-variables ()
7194 "Make all the local summary buffer variables."
7195 (let ((locals gnus-summary-local-variables)
7197 (while (setq local (pop locals))
7200 (if (eq (cdr local) 'global)
7201 ;; Copy the global value of the variable.
7202 (setq global (symbol-value (car local)))
7203 ;; Use the value from the list.
7204 (setq global (eval (cdr local))))
7205 (make-local-variable (car local))
7206 (set (car local) global))
7207 ;; Simple nil-valued local variable.
7208 (make-local-variable local)
7211 (defun gnus-summary-make-display-table ()
7212 ;; Change the display table. Odd characters have a tendency to mess
7213 ;; up nicely formatted displays - we make all possible glyphs
7214 ;; display only a single character.
7216 ;; We start from the standard display table, if any.
7217 (setq gnus-summary-display-table
7218 (or (copy-sequence standard-display-table)
7219 (make-display-table)))
7220 ;; Nix out all the control chars...
7222 (while (>= (setq i (1- i)) 0)
7223 (aset gnus-summary-display-table i [??])))
7224 ;; ... but not newline and cr, of course. (cr is necessary for the
7225 ;; selective display).
7226 (aset gnus-summary-display-table ?\n nil)
7227 (aset gnus-summary-display-table ?\r nil)
7228 ;; We nix out any glyphs over 126 that are not set already.
7230 (while (>= (setq i (1- i)) 127)
7231 ;; Only modify if the entry is nil.
7232 (or (aref gnus-summary-display-table i)
7233 (aset gnus-summary-display-table i [??])))))
7235 (defun gnus-summary-clear-local-variables ()
7236 (let ((locals gnus-summary-local-variables))
7238 (if (consp (car locals))
7239 (and (vectorp (caar locals))
7240 (set (caar locals) nil))
7241 (and (vectorp (car locals))
7242 (set (car locals) nil)))
7243 (setq locals (cdr locals)))))
7245 ;; Summary data functions.
7247 (defmacro gnus-data-number (data)
7250 (defmacro gnus-data-set-number (data number)
7251 `(setcar ,data ,number))
7253 (defmacro gnus-data-mark (data)
7256 (defmacro gnus-data-set-mark (data mark)
7257 `(setcar (nthcdr 1 ,data) ,mark))
7259 (defmacro gnus-data-pos (data)
7262 (defmacro gnus-data-set-pos (data pos)
7263 `(setcar (nthcdr 2 ,data) ,pos))
7265 (defmacro gnus-data-header (data)
7268 (defmacro gnus-data-level (data)
7271 (defmacro gnus-data-unread-p (data)
7272 `(= (nth 1 ,data) gnus-unread-mark))
7274 (defmacro gnus-data-pseudo-p (data)
7275 `(consp (nth 3 ,data)))
7277 (defmacro gnus-data-find (number)
7278 `(assq ,number gnus-newsgroup-data))
7280 (defmacro gnus-data-find-list (number &optional data)
7281 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
7282 (memq (assq ,number bdata)
7285 (defmacro gnus-data-make (number mark pos header level)
7286 `(list ,number ,mark ,pos ,header ,level))
7288 (defun gnus-data-enter (after-article number mark pos header level offset)
7289 (let ((data (gnus-data-find-list after-article)))
7290 (or data (error "No such article: %d" after-article))
7291 (setcdr data (cons (gnus-data-make number mark pos header level)
7293 (setq gnus-newsgroup-data-reverse nil)
7294 (gnus-data-update-list (cddr data) offset)))
7296 (defun gnus-data-enter-list (after-article list &optional offset)
7298 (let ((data (and after-article (gnus-data-find-list after-article)))
7300 (or data (not after-article) (error "No such article: %d" after-article))
7301 ;; Find the last element in the list to be spliced into the main
7304 (setq list (cdr list)))
7307 (setcdr list gnus-newsgroup-data)
7308 (setq gnus-newsgroup-data ilist)
7309 (and offset (gnus-data-update-list (cdr list) offset)))
7310 (setcdr list (cdr data))
7312 (and offset (gnus-data-update-list (cdr data) offset)))
7313 (setq gnus-newsgroup-data-reverse nil))))
7315 (defun gnus-data-remove (article &optional offset)
7316 (let ((data gnus-newsgroup-data))
7317 (if (= (gnus-data-number (car data)) article)
7318 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
7319 gnus-newsgroup-data-reverse nil)
7321 (and (= (gnus-data-number (cadr data)) article)
7323 (setcdr data (cddr data))
7324 (and offset (gnus-data-update-list (cdr data) offset))
7326 gnus-newsgroup-data-reverse nil)))
7327 (setq data (cdr data))))))
7329 (defmacro gnus-data-list (backward)
7331 (or gnus-newsgroup-data-reverse
7332 (setq gnus-newsgroup-data-reverse
7333 (reverse gnus-newsgroup-data)))
7334 gnus-newsgroup-data))
7336 (defun gnus-data-update-list (data offset)
7337 "Add OFFSET to the POS of all data entries in DATA."
7339 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
7340 (setq data (cdr data))))
7342 (defun gnus-data-compute-positions ()
7343 "Compute the positions of all articles."
7344 (let ((data gnus-newsgroup-data)
7347 (when (setq pos (text-property-any
7348 (point-min) (point-max)
7349 'gnus-number (gnus-data-number (car data))))
7350 (gnus-data-set-pos (car data) (+ pos 3)))
7351 (setq data (cdr data)))))
7353 (defun gnus-summary-article-pseudo-p (article)
7354 "Say whether this article is a pseudo article or not."
7355 (not (vectorp (gnus-data-header (gnus-data-find article)))))
7357 (defun gnus-article-parent-p (number)
7358 "Say whether this article is a parent or not."
7359 (let ((data (gnus-data-find-list number)))
7360 (and (cdr data) ; There has to be an article after...
7361 (< (gnus-data-level (car data)) ; And it has to have a higher level.
7362 (gnus-data-level (nth 1 data))))))
7364 (defun gnus-article-children (number)
7365 "Return a list of all children to NUMBER."
7366 (let* ((data (gnus-data-find-list number))
7367 (level (gnus-data-level (car data)))
7369 (setq data (cdr data))
7371 (= (gnus-data-level (car data)) (1+ level)))
7372 (push (gnus-data-number (car data)) children)
7373 (setq data (cdr data)))
7376 (defmacro gnus-summary-skip-intangible ()
7377 "If the current article is intangible, then jump to a different article."
7378 '(let ((to (get-text-property (point) 'gnus-intangible)))
7379 (and to (gnus-summary-goto-subject to))))
7381 (defmacro gnus-summary-article-intangible-p ()
7382 "Say whether this article is intangible or not."
7383 '(get-text-property (point) 'gnus-intangible))
7385 ;; Some summary mode macros.
7387 (defmacro gnus-summary-article-number ()
7388 "The article number of the article on the current line.
7389 If there isn's an article number here, then we return the current
7392 (gnus-summary-skip-intangible)
7393 (or (get-text-property (point) 'gnus-number)
7394 (gnus-summary-last-subject))))
7396 (defmacro gnus-summary-article-header (&optional number)
7397 `(gnus-data-header (gnus-data-find
7398 ,(or number '(gnus-summary-article-number)))))
7400 (defmacro gnus-summary-thread-level (&optional number)
7401 `(if (and (eq gnus-summary-make-false-root 'dummy)
7402 (get-text-property (point) 'gnus-intangible))
7404 (gnus-data-level (gnus-data-find
7405 ,(or number '(gnus-summary-article-number))))))
7407 (defmacro gnus-summary-article-mark (&optional number)
7408 `(gnus-data-mark (gnus-data-find
7409 ,(or number '(gnus-summary-article-number)))))
7411 (defmacro gnus-summary-article-pos (&optional number)
7412 `(gnus-data-pos (gnus-data-find
7413 ,(or number '(gnus-summary-article-number)))))
7415 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
7416 (defmacro gnus-summary-article-subject (&optional number)
7417 "Return current subject string or nil if nothing."
7420 `(gnus-data-header (assq ,number gnus-newsgroup-data))
7421 '(gnus-data-header (assq (gnus-summary-article-number)
7422 gnus-newsgroup-data)))))
7425 (mail-header-subject headers))))
7427 (defmacro gnus-summary-article-score (&optional number)
7428 "Return current article score."
7429 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
7430 gnus-newsgroup-scored))
7431 gnus-summary-default-score 0))
7433 (defun gnus-summary-article-children (&optional number)
7434 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
7435 (level (gnus-data-level (car data)))
7437 (while (and (setq data (cdr data))
7438 (> (setq l (gnus-data-level (car data))) level))
7439 (and (= (1+ level) l)
7440 (setq children (cons (gnus-data-number (car data))
7442 (nreverse children)))
7444 (defun gnus-summary-article-parent (&optional number)
7445 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
7446 (gnus-data-list t)))
7447 (level (gnus-data-level (car data))))
7449 () ; This is a root.
7450 ;; We search until we find an article with a level less than
7451 ;; this one. That function has to be the parent.
7452 (while (and (setq data (cdr data))
7453 (not (< (gnus-data-level (car data)) level))))
7454 (and data (gnus-data-number (car data))))))
7456 (defun gnus-unread-mark-p (mark)
7457 "Say whether MARK is the unread mark."
7458 (= mark gnus-unread-mark))
7460 (defun gnus-read-mark-p (mark)
7461 "Say whether MARK is one of the marks that mark as read.
7462 This is all marks except unread, ticked, dormant, and expirable."
7463 (not (or (= mark gnus-unread-mark)
7464 (= mark gnus-ticked-mark)
7465 (= mark gnus-dormant-mark)
7466 (= mark gnus-expirable-mark))))
7468 ;; Saving hidden threads.
7470 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
7471 (put 'gnus-save-hidden-threads 'lisp-indent-hook 0)
7472 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
7474 (defmacro gnus-save-hidden-threads (&rest forms)
7475 "Save hidden threads, eval FORMS, and restore the hidden threads."
7476 (let ((config (make-symbol "config")))
7477 `(let ((,config (gnus-hidden-threads-configuration)))
7481 (gnus-restore-hidden-threads-configuration ,config)))))
7483 (defun gnus-hidden-threads-configuration ()
7484 "Return the current hidden threads configuration."
7487 (goto-char (point-min))
7488 (while (search-forward "\r" nil t)
7489 (push (1- (point)) config))
7492 (defun gnus-restore-hidden-threads-configuration (config)
7493 "Restore hidden threads configuration from CONFIG."
7494 (let (point buffer-read-only)
7495 (while (setq point (pop config))
7496 (when (and (< point (point-max))
7498 (= (following-char) ?\n))
7499 (subst-char-in-region point (1+ point) ?\n ?\r)))))
7501 ;; Various summary mode internalish functions.
7503 (defun gnus-mouse-pick-article (e)
7506 (gnus-summary-next-page nil t))
7508 (defun gnus-summary-setup-buffer (group)
7509 "Initialize summary buffer."
7510 (let ((buffer (concat "*Summary " group "*")))
7511 (if (get-buffer buffer)
7514 (setq gnus-summary-buffer (current-buffer))
7515 (not gnus-newsgroup-prepared))
7516 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
7517 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
7518 (gnus-add-current-to-buffer-list)
7519 (gnus-summary-mode group)
7521 (gnus-carpal-setup-buffer 'summary))
7522 (unless gnus-single-article-buffer
7523 (make-local-variable 'gnus-article-buffer)
7524 (make-local-variable 'gnus-article-current)
7525 (make-local-variable 'gnus-original-article-buffer))
7526 (setq gnus-newsgroup-name group)
7529 (defun gnus-set-global-variables ()
7530 ;; Set the global equivalents of the summary buffer-local variables
7531 ;; to the latest values they had. These reflect the summary buffer
7532 ;; that was in action when the last article was fetched.
7533 (when (eq major-mode 'gnus-summary-mode)
7534 (setq gnus-summary-buffer (current-buffer))
7535 (let ((name gnus-newsgroup-name)
7536 (marked gnus-newsgroup-marked)
7537 (unread gnus-newsgroup-unreads)
7538 (headers gnus-current-headers)
7539 (data gnus-newsgroup-data)
7540 (summary gnus-summary-buffer)
7541 (article-buffer gnus-article-buffer)
7542 (original gnus-original-article-buffer)
7543 (gac gnus-article-current)
7544 (score-file gnus-current-score-file))
7546 (set-buffer gnus-group-buffer)
7547 (setq gnus-newsgroup-name name)
7548 (setq gnus-newsgroup-marked marked)
7549 (setq gnus-newsgroup-unreads unread)
7550 (setq gnus-current-headers headers)
7551 (setq gnus-newsgroup-data data)
7552 (setq gnus-article-current gac)
7553 (setq gnus-summary-buffer summary)
7554 (setq gnus-article-buffer article-buffer)
7555 (setq gnus-original-article-buffer original)
7556 (setq gnus-current-score-file score-file)))))
7558 (defun gnus-summary-last-article-p (&optional article)
7559 "Return whether ARTICLE is the last article in the buffer."
7560 (if (not (setq article (or article (gnus-summary-article-number))))
7561 t ; All non-existant numbers are the last article. :-)
7562 (not (cdr (gnus-data-find-list article)))))
7564 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
7565 "Insert a dummy root in the summary buffer."
7567 (gnus-add-text-properties
7568 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
7569 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
7571 (defun gnus-make-thread-indent-array ()
7573 (unless (and gnus-thread-indent-array
7574 (= gnus-thread-indent-level gnus-thread-indent-array-level))
7575 (setq gnus-thread-indent-array (make-vector 201 "")
7576 gnus-thread-indent-array-level gnus-thread-indent-level)
7578 (aset gnus-thread-indent-array n
7579 (make-string (* n gnus-thread-indent-level) ? ))
7582 (defun gnus-summary-insert-line
7583 (gnus-tmp-header gnus-tmp-level gnus-tmp-current gnus-tmp-unread
7584 gnus-tmp-replied gnus-tmp-expirable gnus-tmp-subject-or-nil
7585 &optional gnus-tmp-dummy gnus-tmp-score gnus-tmp-process)
7586 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
7587 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
7588 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
7589 (gnus-tmp-score-char
7590 (if (or (null gnus-summary-default-score)
7591 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
7592 gnus-summary-zcore-fuzz)) ?
7593 (if (< gnus-tmp-score gnus-summary-default-score)
7594 gnus-score-below-mark gnus-score-over-mark)))
7595 (gnus-tmp-replied (cond (gnus-tmp-process gnus-process-mark)
7596 ((memq gnus-tmp-current gnus-newsgroup-cached)
7598 (gnus-tmp-replied gnus-replied-mark)
7599 ((memq gnus-tmp-current gnus-newsgroup-saved)
7601 (t gnus-unread-mark)))
7602 (gnus-tmp-from (mail-header-from gnus-tmp-header))
7605 ((string-match "(.+)" gnus-tmp-from)
7606 (substring gnus-tmp-from
7607 (1+ (match-beginning 0)) (1- (match-end 0))))
7608 ((string-match "<[^>]+> *$" gnus-tmp-from)
7609 (let ((beg (match-beginning 0)))
7610 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
7611 (substring gnus-tmp-from (1+ (match-beginning 0))
7612 (1- (match-end 0))))
7613 (substring gnus-tmp-from 0 beg))))
7615 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
7616 (gnus-tmp-number (mail-header-number gnus-tmp-header))
7617 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
7618 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
7619 (buffer-read-only nil))
7620 (when (string= gnus-tmp-name "")
7621 (setq gnus-tmp-name gnus-tmp-from))
7622 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
7623 (gnus-put-text-property
7625 (progn (eval gnus-summary-line-format-spec) (point))
7626 'gnus-number gnus-tmp-number)
7627 (when (gnus-visual-p 'summary-highlight 'highlight)
7629 (run-hooks 'gnus-summary-update-hook)
7632 (defun gnus-summary-update-line (&optional dont-update)
7633 ;; Update summary line after change.
7634 (when (and gnus-summary-default-score
7635 (not gnus-summary-inhibit-highlight))
7636 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
7637 (article (gnus-summary-article-number))
7638 (score (gnus-summary-article-score article)))
7640 (if (and gnus-summary-mark-below
7641 (< (gnus-summary-article-score)
7642 gnus-summary-mark-below))
7643 ;; This article has a low score, so we mark it as read.
7644 (when (memq article gnus-newsgroup-unreads)
7645 (gnus-summary-mark-article-as-read gnus-low-score-mark))
7646 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
7647 ;; This article was previously marked as read on account
7648 ;; of a low score, but now it has risen, so we mark it as
7650 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
7651 (gnus-summary-update-mark
7652 (if (or (null gnus-summary-default-score)
7653 (<= (abs (- score gnus-summary-default-score))
7654 gnus-summary-zcore-fuzz)) ?
7655 (if (< score gnus-summary-default-score)
7656 gnus-score-below-mark gnus-score-over-mark)) 'score))
7657 ;; Do visual highlighting.
7658 (when (gnus-visual-p 'summary-highlight 'highlight)
7659 (run-hooks 'gnus-summary-update-hook)))))
7661 (defvar gnus-tmp-new-adopts nil)
7663 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
7664 ;; Sum up all elements (and sub-elements) in a list.
7666 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
7668 ((and (consp thread) (cdr thread))
7671 'gnus-summary-number-of-articles-in-thread (cdr thread))))
7674 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
7677 (when (and level (zerop level) gnus-tmp-new-adopts)
7680 'gnus-summary-number-of-articles-in-thread
7681 gnus-tmp-new-adopts))))
7683 (if (> number 1) gnus-not-empty-thread-mark
7684 gnus-empty-thread-mark)
7687 (defun gnus-summary-set-local-parameters (group)
7688 "Go through the local params of GROUP and set all variable specs in that list."
7689 (let ((params (gnus-info-params (gnus-get-info group)))
7692 (setq elem (car params)
7693 params (cdr params))
7694 (and (consp elem) ; Has to be a cons.
7695 (consp (cdr elem)) ; The cdr has to be a list.
7696 (symbolp (car elem)) ; Has to be a symbol in there.
7697 (not (memq (car elem)
7698 '(quit-config to-address to-list to-group)))
7699 (progn ; So we set it.
7700 (make-local-variable (car elem))
7701 (set (car elem) (eval (nth 1 elem))))))))
7703 (defun gnus-summary-read-group (group &optional show-all no-article
7704 kill-buffer no-display)
7705 "Start reading news in newsgroup GROUP.
7706 If SHOW-ALL is non-nil, already read articles are also listed.
7707 If NO-ARTICLE is non-nil, no article is selected initially.
7708 If NO-DISPLAY, don't generate a summary buffer."
7709 (gnus-message 5 "Retrieving newsgroup: %s..." group)
7710 (let* ((new-group (gnus-summary-setup-buffer group))
7711 (quit-config (gnus-group-quit-config group))
7712 (did-select (and new-group (gnus-select-newsgroup group show-all))))
7714 ;; This summary buffer exists already, so we just select it.
7716 (gnus-set-global-variables)
7718 (gnus-kill-or-deaden-summary kill-buffer))
7719 (gnus-configure-windows 'summary 'force)
7720 (gnus-set-mode-line 'summary)
7721 (gnus-summary-position-point)
7724 ;; We couldn't select this group.
7726 (when (and (eq major-mode 'gnus-summary-mode)
7727 (not (equal (current-buffer) kill-buffer)))
7728 (kill-buffer (current-buffer))
7729 (if (not quit-config)
7731 (set-buffer gnus-group-buffer)
7732 (gnus-group-jump-to-group group)
7733 (gnus-group-next-unread-group 1))
7734 (if (not (buffer-name (car quit-config)))
7735 (gnus-configure-windows 'group 'force)
7736 (set-buffer (car quit-config))
7737 (and (eq major-mode 'gnus-summary-mode)
7738 (gnus-set-global-variables))
7739 (gnus-configure-windows (cdr quit-config)))))
7740 (gnus-message 3 "Can't select group")
7742 ;; The user did a `C-g' while prompting for number of articles,
7743 ;; so we exit this group.
7744 ((eq did-select 'quit)
7745 (and (eq major-mode 'gnus-summary-mode)
7746 (not (equal (current-buffer) kill-buffer))
7747 (kill-buffer (current-buffer)))
7749 (gnus-kill-or-deaden-summary kill-buffer))
7750 (if (not quit-config)
7752 (set-buffer gnus-group-buffer)
7753 (gnus-group-jump-to-group group)
7754 (gnus-group-next-unread-group 1)
7755 (gnus-configure-windows 'group 'force))
7756 (if (not (buffer-name (car quit-config)))
7757 (gnus-configure-windows 'group 'force)
7758 (set-buffer (car quit-config))
7759 (and (eq major-mode 'gnus-summary-mode)
7760 (gnus-set-global-variables))
7761 (gnus-configure-windows (cdr quit-config))))
7762 ;; Finally signal the quit.
7764 ;; The group was successfully selected.
7766 (gnus-set-global-variables)
7767 ;; Save the active value in effect when the group was entered.
7768 (setq gnus-newsgroup-active
7770 (gnus-active gnus-newsgroup-name)))
7771 ;; You can change the summary buffer in some way with this hook.
7772 (run-hooks 'gnus-select-group-hook)
7773 ;; Set any local variables in the group parameters.
7774 (gnus-summary-set-local-parameters gnus-newsgroup-name)
7775 (gnus-update-format-specifications)
7776 ;; Do score processing.
7777 (when gnus-use-scoring
7778 (gnus-possibly-score-headers))
7779 ;; Check whether to fill in the gaps in the threads.
7780 (when gnus-build-sparse-threads
7781 (gnus-build-sparse-threads))
7782 ;; Find the initial limit.
7783 (if gnus-show-threads
7785 (let ((gnus-newsgroup-dormant nil))
7786 (gnus-summary-initial-limit show-all))
7787 (gnus-summary-initial-limit show-all))
7788 (setq gnus-newsgroup-limit
7790 (lambda (header) (mail-header-number header))
7791 gnus-newsgroup-headers)))
7792 ;; Generate the summary buffer.
7794 (gnus-summary-prepare))
7795 (when gnus-use-trees
7796 (gnus-tree-open group)
7797 (setq gnus-summary-highlight-line-function
7798 'gnus-tree-highlight-article))
7799 ;; If the summary buffer is empty, but there are some low-scored
7800 ;; articles or some excluded dormants, we include these in the
7802 (when (and (zerop (buffer-size))
7804 (cond (gnus-newsgroup-dormant
7805 (gnus-summary-limit-include-dormant))
7806 ((and gnus-newsgroup-scored show-all)
7807 (gnus-summary-limit-include-expunged))))
7808 ;; Function `gnus-apply-kill-file' must be called in this hook.
7809 (run-hooks 'gnus-apply-kill-hook)
7810 (if (and (zerop (buffer-size))
7813 ;; This newsgroup is empty.
7814 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
7815 (gnus-message 6 "No unread news")
7817 (gnus-kill-or-deaden-summary kill-buffer))
7818 ;; Return nil from this function.
7820 ;; Hide conversation thread subtrees. We cannot do this in
7821 ;; gnus-summary-prepare-hook since kill processing may not
7822 ;; work with hidden articles.
7823 (and gnus-show-threads
7824 gnus-thread-hide-subtree
7825 (gnus-summary-hide-all-threads))
7826 ;; Show first unread article if requested.
7827 (if (and (not no-article)
7829 gnus-newsgroup-unreads
7830 gnus-auto-select-first)
7831 (unless (if (eq gnus-auto-select-first 'best)
7832 (gnus-summary-best-unread-article)
7833 (gnus-summary-first-unread-article))
7834 (gnus-configure-windows 'summary))
7835 ;; Don't select any articles, just move point to the first
7836 ;; article in the group.
7837 (goto-char (point-min))
7838 (gnus-summary-position-point)
7839 (gnus-set-mode-line 'summary)
7840 (gnus-configure-windows 'summary 'force))
7841 ;; If we are in async mode, we send some info to the backend.
7842 (when gnus-newsgroup-async
7843 (gnus-request-asynchronous gnus-newsgroup-name gnus-newsgroup-data))
7845 (gnus-kill-or-deaden-summary kill-buffer))
7846 (when (get-buffer-window gnus-group-buffer t)
7847 ;; Gotta use windows, because recenter does wierd stuff if
7848 ;; the current buffer ain't the displayed window.
7849 (let ((owin (selected-window)))
7850 (select-window (get-buffer-window gnus-group-buffer t))
7851 (when (gnus-group-goto-group group)
7853 (select-window owin))))
7854 ;; Mark this buffer as "prepared".
7855 (setq gnus-newsgroup-prepared t)
7858 (defun gnus-summary-prepare ()
7859 "Generate the summary buffer."
7860 (let ((buffer-read-only nil))
7862 (setq gnus-newsgroup-data nil
7863 gnus-newsgroup-data-reverse nil)
7864 (run-hooks 'gnus-summary-generate-hook)
7865 ;; Generate the buffer, either with threads or without.
7866 (when gnus-newsgroup-headers
7867 (gnus-summary-prepare-threads
7868 (if gnus-show-threads
7869 (gnus-sort-gathered-threads
7870 (funcall gnus-summary-thread-gathering-function
7872 (gnus-cut-threads (gnus-make-threads)))))
7873 ;; Unthreaded display.
7874 (gnus-sort-articles gnus-newsgroup-headers))))
7875 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
7876 ;; Call hooks for modifying summary buffer.
7877 (goto-char (point-min))
7878 (run-hooks 'gnus-summary-prepare-hook)))
7880 (defun gnus-gather-threads-by-subject (threads)
7881 "Gather threads by looking at Subject headers."
7882 (if (not gnus-summary-make-false-root)
7884 (let ((hashtb (gnus-make-hashtable 1023))
7887 subject hthread whole-subject)
7889 (setq whole-subject (mail-header-subject (caar threads)))
7892 ;; Truncate the subject.
7893 ((numberp gnus-summary-gather-subject-limit)
7894 (setq subject (gnus-simplify-subject-re whole-subject))
7895 (if (> (length subject) gnus-summary-gather-subject-limit)
7896 (substring subject 0 gnus-summary-gather-subject-limit)
7898 ;; Fuzzily simplify it.
7899 ((eq 'fuzzy gnus-summary-gather-subject-limit)
7900 (gnus-simplify-subject-fuzzy whole-subject))
7901 ;; Just remove the leading "Re:".
7903 (gnus-simplify-subject-re whole-subject))))
7905 (if (and gnus-summary-gather-exclude-subject
7906 (string-match gnus-summary-gather-exclude-subject
7908 () ; We don't want to do anything with this article.
7909 ;; We simplify the subject before looking it up in the
7912 (if (setq hthread (gnus-gethash subject hashtb))
7914 ;; We enter a dummy root into the thread, if we
7915 ;; haven't done that already.
7916 (unless (stringp (caar hthread))
7917 (setcar hthread (list whole-subject (car hthread))))
7918 ;; We add this new gathered thread to this gathered
7920 (setcdr (car hthread)
7921 (nconc (cdar hthread) (list (car threads))))
7922 ;; Remove it from the list of threads.
7923 (setcdr prev (cdr threads))
7924 (setq threads prev))
7925 ;; Enter this thread into the hash table.
7926 (gnus-sethash subject threads hashtb)))
7928 (setq threads (cdr threads)))
7931 (defun gnus-gather-threads-by-references (threads)
7932 "Gather threads by looking at References headers."
7933 (let ((idhashtb (gnus-make-hashtable 1023))
7934 (thhashtb (gnus-make-hashtable 1023))
7937 ids references id gthread gid entered)
7939 (when (setq references (mail-header-references (caar threads)))
7940 (setq id (mail-header-id (caar threads)))
7941 (setq ids (gnus-split-references references))
7944 (if (not (setq gid (gnus-gethash (car ids) idhashtb)))
7946 (gnus-sethash (car ids) id idhashtb)
7947 (gnus-sethash id threads thhashtb))
7948 (setq gthread (gnus-gethash gid thhashtb))
7950 ;; We enter a dummy root into the thread, if we
7951 ;; haven't done that already.
7952 (unless (stringp (caar gthread))
7953 (setcar gthread (list (mail-header-subject (caar gthread))
7955 ;; We add this new gathered thread to this gathered
7957 (setcdr (car gthread)
7958 (nconc (cdar gthread) (list (car threads)))))
7959 ;; Add it into the thread hash table.
7960 (gnus-sethash id gthread thhashtb)
7962 ;; Remove it from the list of threads.
7963 (setcdr prev (cdr threads))
7964 (setq threads prev))
7965 (setq ids (cdr ids))))
7967 (setq threads (cdr threads)))
7970 (defun gnus-sort-gathered-threads (threads)
7971 "Sort subtreads inside each gathered thread by article number."
7972 (let ((result threads))
7974 (when (stringp (caar threads))
7975 (setcdr (car threads)
7976 (sort (cdar threads) 'gnus-thread-sort-by-number)))
7977 (setq threads (cdr threads)))
7980 (defun gnus-make-threads ()
7981 "Go through the dependency hashtb and find the roots. Return all threads."
7985 (unless (car (symbol-value refs))
7986 ;; These threads do not refer back to any other articles,
7987 ;; so they're roots.
7988 (setq threads (append (cdr (symbol-value refs)) threads))))
7989 gnus-newsgroup-dependencies)
7992 (defun gnus-build-sparse-threads ()
7993 (let ((headers gnus-newsgroup-headers)
7994 (deps gnus-newsgroup-dependencies)
7995 header references generation relations
7996 cthread subject child end pthread relation)
7997 ;; First we create an alist of generations/relations, where
7998 ;; generations is how much we trust the ralation, and the relation
8000 (gnus-message 7 "Making sparse threads...")
8002 (nnheader-set-temp-buffer " *gnus sparse threads*")
8003 (while (setq header (pop headers))
8004 (when (and (setq references (mail-header-references header))
8005 (not (string= references "")))
8007 (setq child (mail-header-id header)
8008 subject (mail-header-subject header))
8010 (while (search-backward ">" nil t)
8011 (setq end (1+ (point)))
8012 (when (search-backward "<" nil t)
8013 (push (list (incf generation)
8014 child (setq child (buffer-substring (point) end))
8017 (push (list (1+ generation) child nil subject) relations)
8019 (kill-buffer (current-buffer)))
8020 ;; Sort over trustworthiness.
8021 (setq relations (sort relations (lambda (r1 r2) (< (car r1) (car r2)))))
8022 (while (setq relation (pop relations))
8023 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
8024 (unless (car (symbol-value cthread))
8025 ;; Make this article the parent of these threads.
8026 (setcar (symbol-value cthread)
8027 (vector gnus-reffed-article-number
8031 (or (caddr relation) "") 0 0 "")))
8032 (set cthread (list (vector gnus-reffed-article-number
8034 "" "" (cadr relation)
8035 (or (caddr relation) "") 0 0 ""))))
8036 (push gnus-reffed-article-number gnus-newsgroup-limit)
8037 (push gnus-reffed-article-number gnus-newsgroup-sparse)
8038 (push (cons gnus-reffed-article-number gnus-sparse-mark)
8039 gnus-newsgroup-reads)
8040 (decf gnus-reffed-article-number)
8041 ;; Make this new thread the child of its parent.
8042 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
8043 (setcdr (symbol-value pthread)
8044 (nconc (cdr (symbol-value pthread))
8045 (list (symbol-value cthread))))
8046 (set pthread (list nil (symbol-value cthread))))))
8047 (gnus-message 7 "Making sparse threads...done")))
8049 (defun gnus-build-old-threads ()
8050 ;; Look at all the articles that refer back to old articles, and
8051 ;; fetch the headers for the articles that aren't there. This will
8052 ;; build complete threads - if the roots haven't been expired by the
8057 (when (not (car (symbol-value refs)))
8058 (setq heads (cdr (symbol-value refs)))
8060 (if (memq (mail-header-number (caar heads))
8061 gnus-newsgroup-dormant)
8062 (setq heads (cdr heads))
8063 (setq id (symbol-name refs))
8064 (while (and (setq id (gnus-build-get-header id))
8065 (not (car (gnus-gethash
8066 id gnus-newsgroup-dependencies)))))
8067 (setq heads nil)))))
8068 gnus-newsgroup-dependencies)))
8070 (defun gnus-build-get-header (id)
8071 ;; Look through the buffer of NOV lines and find the header to
8072 ;; ID. Enter this line into the dependencies hash table, and return
8073 ;; the id of the parent article (if any).
8074 (let ((deps gnus-newsgroup-dependencies)
8078 (set-buffer nntp-server-buffer)
8079 (goto-char (point-min))
8080 (while (and (not found) (search-forward id nil t))
8082 (setq found (looking-at
8083 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
8084 (regexp-quote id))))
8085 (or found (beginning-of-line 2)))
8089 (setq header (gnus-nov-parse-line
8090 (read (current-buffer)) deps))
8091 (gnus-parent-id (mail-header-references header)))))
8093 (let ((number (mail-header-number header)))
8094 (push number gnus-newsgroup-limit)
8095 (push header gnus-newsgroup-headers)
8096 (if (memq number gnus-newsgroup-unselected)
8098 (push number gnus-newsgroup-unreads)
8099 (setq gnus-newsgroup-unselected
8100 (delq number gnus-newsgroup-unselected)))
8101 (push number gnus-newsgroup-ancient)))))))
8103 (defun gnus-summary-update-article (article &optional iheader)
8104 "Update ARTICLE in the summary buffer."
8105 (set-buffer gnus-summary-buffer)
8106 (let* ((header (or iheader (gnus-summary-article-header article)))
8107 (id (mail-header-id header))
8108 (data (gnus-data-find article))
8109 (thread (gnus-id-to-thread id))
8110 (references (mail-header-references header))
8115 (not (equal "" references)))
8118 (buffer-read-only nil)
8120 (number (mail-header-number header))
8123 ;; !!! Should this be in or not?
8125 (setcar thread nil))
8127 (delq thread parent))
8128 (if (gnus-summary-insert-subject id header iheader)
8129 ;; Set the (possibly) new article number in the data structure.
8130 (gnus-data-set-number data (gnus-id-to-article id))
8134 (defun gnus-rebuild-thread (id)
8135 "Rebuild the thread containing ID."
8136 (let ((buffer-read-only nil)
8137 current thread data)
8138 (if (not gnus-show-threads)
8139 (setq thread (list (car (gnus-id-to-thread id))))
8140 ;; Get the thread this article is part of.
8141 (setq thread (gnus-remove-thread id)))
8142 (setq current (save-excursion
8143 (and (zerop (forward-line -1))
8144 (gnus-summary-article-number))))
8145 ;; If this is a gathered thread, we have to go some re-gathering.
8146 (when (stringp (car thread))
8147 (let ((subject (car thread))
8149 (setq thread (cdr thread))
8151 (unless (memq (setq thr (gnus-id-to-thread
8153 (mail-header-id (caar thread)))))
8156 (setq thread (cdr thread)))
8157 ;; We now have all (unique) roots.
8158 (if (= (length roots) 1)
8159 ;; All the loose roots are now one solid root.
8160 (setq thread (car roots))
8161 (setq thread (cons subject (gnus-sort-threads roots))))))
8163 ;; We then insert this thread into the summary buffer.
8164 (let (gnus-newsgroup-data gnus-newsgroup-threads)
8165 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
8166 (setq data (nreverse gnus-newsgroup-data))
8167 (setq threads gnus-newsgroup-threads))
8168 ;; We splice the new data into the data structure.
8169 (gnus-data-enter-list current data)
8170 (gnus-data-compute-positions)
8171 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
8173 (defun gnus-number-to-header (number)
8174 "Return the header for article NUMBER."
8175 (let ((headers gnus-newsgroup-headers))
8177 (not (= number (mail-header-number (car headers)))))
8182 (defun gnus-id-to-thread (id)
8183 "Return the (sub-)thread where ID appears."
8184 (gnus-gethash id gnus-newsgroup-dependencies))
8186 (defun gnus-id-to-article (id)
8187 "Return the article number of ID."
8188 (let ((thread (gnus-id-to-thread id)))
8191 (mail-header-number (car thread)))))
8193 (defun gnus-id-to-header (id)
8194 "Return the article headers of ID."
8195 (car (gnus-id-to-thread id)))
8197 (defun gnus-article-displayed-root-p (article)
8198 "Say whether ARTICLE is a root(ish) article."
8199 (let ((level (gnus-summary-thread-level article))
8200 (refs (mail-header-references (gnus-summary-article-header article)))
8206 ((null (gnus-parent-id refs)) t)
8208 (null (setq particle (gnus-id-to-article
8209 (gnus-parent-id refs))))
8210 (null (gnus-summary-thread-level particle)))))))
8212 (defun gnus-root-id (id)
8213 "Return the id of the root of the thread where ID appears."
8215 (while (and id (setq prev (car (gnus-gethash
8216 id gnus-newsgroup-dependencies))))
8218 id (gnus-parent-id (mail-header-references prev))))
8221 (defun gnus-remove-thread (id &optional dont-remove)
8222 "Remove the thread that has ID in it."
8223 (let ((dep gnus-newsgroup-dependencies)
8224 headers thread last-id)
8225 ;; First go up in this thread until we find the root.
8226 (setq last-id (gnus-root-id id))
8227 (setq headers (list (car (gnus-id-to-thread last-id))
8228 (caadr (gnus-id-to-thread last-id))))
8229 ;; We have now found the real root of this thread. It might have
8230 ;; been gathered into some loose thread, so we have to search
8231 ;; through the threads to find the thread we wanted.
8232 (let ((threads gnus-newsgroup-threads)
8235 (setq sub (car threads))
8236 (if (stringp (car sub))
8237 ;; This is a gathered threads, so we look at the roots
8238 ;; below it to find whether this article in in this
8241 (setq sub (cdr sub))
8243 (when (member (caar sub) headers)
8244 (setq thread (car threads)
8247 (setq sub (cdr sub))))
8248 ;; It's an ordinary thread, so we check it.
8249 (when (eq (car sub) (car headers))
8252 (setq threads (cdr threads)))
8253 ;; If this article is in no thread, then it's a root.
8256 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
8257 (setq thread (gnus-gethash last-id dep)))
8260 thread ; We return this thread.
8262 (if (stringp (car thread))
8264 ;; If we use dummy roots, then we have to remove the
8265 ;; dummy root as well.
8266 (when (eq gnus-summary-make-false-root 'dummy)
8269 (setq thread (cdr thread))
8271 (gnus-remove-thread-1 (car thread))
8272 (setq thread (cdr thread))))
8273 (gnus-remove-thread-1 thread))))))))
8275 (defun gnus-remove-thread-1 (thread)
8276 "Remove the thread THREAD recursively."
8277 (let ((number (mail-header-number (car thread)))
8279 (when (setq pos (text-property-any
8280 (point-min) (point-max) 'gnus-number number))
8283 (gnus-data-remove number))
8284 (setq thread (cdr thread))
8286 (gnus-remove-thread-1 (pop thread)))))
8288 (defun gnus-sort-threads (threads)
8290 (if (not gnus-thread-sort-functions)
8292 (let ((func (if (= 1 (length gnus-thread-sort-functions))
8293 (car gnus-thread-sort-functions)
8295 ,(gnus-make-sort-function
8296 (reverse gnus-thread-sort-functions))))))
8297 (gnus-message 7 "Sorting threads...")
8300 (gnus-message 7 "Sorting threads...done")))))
8302 (defun gnus-sort-articles (articles)
8304 (when gnus-article-sort-functions
8305 (let ((func (if (= 1 (length gnus-article-sort-functions))
8306 (car gnus-article-sort-functions)
8308 ,(gnus-make-sort-function
8309 (reverse gnus-article-sort-functions))))))
8310 (gnus-message 7 "Sorting articles...")
8312 (setq gnus-newsgroup-headers (sort articles func))
8313 (gnus-message 7 "Sorting articles...done")))))
8315 (defun gnus-make-sort-function (funs)
8316 "Return a composite sort condition based on the functions in FUNC."
8318 `(or (,(car funs) t1 t2)
8319 (and (not (,(car funs) t2 t1))
8320 ,(gnus-make-sort-function (cdr funs))))
8321 `(,(car funs) t1 t2)))
8323 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
8324 (defmacro gnus-thread-header (thread)
8325 ;; Return header of first article in THREAD.
8326 ;; Note that THREAD must never, ever be anything else than a variable -
8327 ;; using some other form will lead to serious barfage.
8328 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
8329 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
8330 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
8333 (defsubst gnus-article-sort-by-number (h1 h2)
8334 "Sort articles by article number."
8335 (< (mail-header-number h1)
8336 (mail-header-number h2)))
8338 (defun gnus-thread-sort-by-number (h1 h2)
8339 "Sort threads by root article number."
8340 (gnus-article-sort-by-number
8341 (gnus-thread-header h1) (gnus-thread-header h2)))
8343 (defsubst gnus-article-sort-by-author (h1 h2)
8344 "Sort articles by root author."
8346 (let ((extract (funcall
8347 gnus-extract-address-components
8348 (mail-header-from h1))))
8349 (or (car extract) (cdr extract)))
8350 (let ((extract (funcall
8351 gnus-extract-address-components
8352 (mail-header-from h2))))
8353 (or (car extract) (cdr extract)))))
8355 (defun gnus-thread-sort-by-author (h1 h2)
8356 "Sort threads by root author."
8357 (gnus-article-sort-by-author
8358 (gnus-thread-header h1) (gnus-thread-header h2)))
8360 (defsubst gnus-article-sort-by-subject (h1 h2)
8361 "Sort articles by root subject."
8363 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
8364 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
8366 (defun gnus-thread-sort-by-subject (h1 h2)
8367 "Sort threads by root subject."
8368 (gnus-article-sort-by-subject
8369 (gnus-thread-header h1) (gnus-thread-header h2)))
8371 (defsubst gnus-article-sort-by-date (h1 h2)
8372 "Sort articles by root article date."
8374 (inline (gnus-sortable-date (mail-header-date h1)))
8375 (inline (gnus-sortable-date (mail-header-date h2)))))
8377 (defun gnus-thread-sort-by-date (h1 h2)
8378 "Sort threads by root article date."
8379 (gnus-article-sort-by-date
8380 (gnus-thread-header h1) (gnus-thread-header h2)))
8382 (defsubst gnus-article-sort-by-score (h1 h2)
8383 "Sort articles by root article score.
8384 Unscored articles will be counted as having a score of zero."
8385 (> (or (cdr (assq (mail-header-number h1)
8386 gnus-newsgroup-scored))
8387 gnus-summary-default-score 0)
8388 (or (cdr (assq (mail-header-number h2)
8389 gnus-newsgroup-scored))
8390 gnus-summary-default-score 0)))
8392 (defun gnus-thread-sort-by-score (h1 h2)
8393 "Sort threads by root article score."
8394 (gnus-article-sort-by-score
8395 (gnus-thread-header h1) (gnus-thread-header h2)))
8397 (defun gnus-thread-sort-by-total-score (h1 h2)
8398 "Sort threads by the sum of all scores in the thread.
8399 Unscored articles will be counted as having a score of zero."
8400 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
8402 (defun gnus-thread-total-score (thread)
8403 ;; This function find the total score of THREAD.
8404 (cond ((null thread)
8407 (if (stringp (car thread))
8408 (apply gnus-thread-score-function 0
8409 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
8410 (gnus-thread-total-score-1 thread)))
8412 (gnus-thread-total-score-1 (list thread)))))
8414 (defun gnus-thread-total-score-1 (root)
8415 ;; This function find the total score of the thread below ROOT.
8416 (setq root (car root))
8417 (apply gnus-thread-score-function
8418 (or (cdr (assq (mail-header-number root) gnus-newsgroup-scored))
8419 gnus-summary-default-score 0)
8420 (mapcar 'gnus-thread-total-score
8421 (cdr (gnus-gethash (mail-header-id root)
8422 gnus-newsgroup-dependencies)))))
8424 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8425 (defvar gnus-tmp-prev-subject nil)
8426 (defvar gnus-tmp-false-parent nil)
8427 (defvar gnus-tmp-root-expunged nil)
8428 (defvar gnus-tmp-dummy-line nil)
8430 (defun gnus-summary-prepare-threads (threads)
8431 "Prepare summary buffer from THREADS and indentation LEVEL.
8432 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
8433 or a straight list of headers."
8434 (gnus-message 7 "Generating summary...")
8436 (setq gnus-newsgroup-threads threads)
8439 (let ((gnus-tmp-level 0)
8440 (default-score (or gnus-summary-default-score 0))
8441 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
8442 thread number subject stack state gnus-tmp-gathered beg-match
8443 new-roots gnus-tmp-new-adopts thread-end
8444 gnus-tmp-header gnus-tmp-unread
8445 gnus-tmp-replied gnus-tmp-subject-or-nil
8446 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
8447 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
8448 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
8450 (setq gnus-tmp-prev-subject nil)
8452 (if (vectorp (car threads))
8453 ;; If this is a straight (sic) list of headers, then a
8454 ;; threaded summary display isn't required, so we just create
8455 ;; an unthreaded one.
8456 (gnus-summary-prepare-unthreaded threads)
8458 ;; Do the threaded display.
8460 (while (or threads stack gnus-tmp-new-adopts new-roots)
8462 (if (and (= gnus-tmp-level 0)
8463 (not (setq gnus-tmp-dummy-line nil))
8466 (not gnus-tmp-false-parent)
8467 (or gnus-tmp-new-adopts new-roots))
8468 (if gnus-tmp-new-adopts
8469 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
8470 thread (list (car gnus-tmp-new-adopts))
8471 gnus-tmp-header (caar thread)
8472 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
8474 (setq thread (list (car new-roots))
8475 gnus-tmp-header (caar thread)
8476 new-roots (cdr new-roots))))
8479 ;; If there are some threads, we do them before the
8480 ;; threads on the stack.
8481 (setq thread threads
8482 gnus-tmp-header (caar thread))
8483 ;; There were no current threads, so we pop something off
8485 (setq state (car stack)
8486 gnus-tmp-level (car state)
8489 gnus-tmp-header (caar thread))))
8491 (setq gnus-tmp-false-parent nil)
8492 (setq gnus-tmp-root-expunged nil)
8493 (setq thread-end nil)
8495 (if (stringp gnus-tmp-header)
8496 ;; The header is a dummy root.
8498 ((eq gnus-summary-make-false-root 'adopt)
8499 ;; We let the first article adopt the rest.
8500 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
8502 (setq gnus-tmp-gathered
8504 (lambda (h) (mail-header-number (car h)))
8507 (setq thread (cons (list (caar thread)
8510 (setq gnus-tmp-level -1
8511 gnus-tmp-false-parent t))
8512 ((eq gnus-summary-make-false-root 'empty)
8513 ;; We print adopted articles with empty subject fields.
8514 (setq gnus-tmp-gathered
8516 (lambda (h) (mail-header-number (car h)))
8519 (setq gnus-tmp-level -1))
8520 ((eq gnus-summary-make-false-root 'dummy)
8521 ;; We remember that we probably want to output a dummy
8523 (setq gnus-tmp-dummy-line gnus-tmp-header)
8524 (setq gnus-tmp-prev-subject gnus-tmp-header))
8526 ;; We do not make a root for the gathered
8527 ;; sub-threads at all.
8528 (setq gnus-tmp-level -1)))
8530 (setq number (mail-header-number gnus-tmp-header)
8531 subject (mail-header-subject gnus-tmp-header))
8534 ;; If the thread has changed subject, we might want to make
8535 ;; this subthread into a root.
8536 ((and (null gnus-thread-ignore-subject)
8537 (not (zerop gnus-tmp-level))
8538 gnus-tmp-prev-subject
8540 (gnus-subject-equal gnus-tmp-prev-subject subject))))
8541 (setq new-roots (nconc new-roots (list (car thread)))
8543 gnus-tmp-header nil))
8544 ;; If the article lies outside the current limit,
8545 ;; then we do not display it.
8546 ((and (not (memq number gnus-newsgroup-limit))
8547 (not gnus-tmp-dummy-line))
8548 (setq gnus-tmp-gathered
8550 (lambda (h) (mail-header-number (car h)))
8553 (setq gnus-tmp-new-adopts (if (cdar thread)
8554 (append gnus-tmp-new-adopts
8556 gnus-tmp-new-adopts)
8558 gnus-tmp-header nil)
8559 (when (zerop gnus-tmp-level)
8560 (setq gnus-tmp-root-expunged t)))
8561 ;; Perhaps this article is to be marked as read?
8562 ((and gnus-summary-mark-below
8563 (< (or (cdr (assq number gnus-newsgroup-scored))
8565 gnus-summary-mark-below)
8566 ;; Don't touch sparse articles.
8567 (not (memq number gnus-newsgroup-sparse))
8568 (not (memq number gnus-newsgroup-ancient)))
8569 (setq gnus-newsgroup-unreads
8570 (delq number gnus-newsgroup-unreads))
8571 (if gnus-newsgroup-auto-expire
8572 (push number gnus-newsgroup-expirable)
8573 (push (cons number gnus-low-score-mark)
8574 gnus-newsgroup-reads))))
8576 (when gnus-tmp-header
8577 ;; We may have an old dummy line to output before this
8579 (when gnus-tmp-dummy-line
8580 (gnus-summary-insert-dummy-line
8581 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
8582 (setq gnus-tmp-dummy-line nil))
8584 ;; Compute the mark.
8588 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8589 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8590 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8591 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8592 (t (or (cdr (assq number gnus-newsgroup-reads))
8593 gnus-ancient-mark))))
8595 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
8596 gnus-tmp-header gnus-tmp-level)
8597 gnus-newsgroup-data)
8599 ;; Actually insert the line.
8601 gnus-tmp-subject-or-nil
8603 ((and gnus-thread-ignore-subject
8604 gnus-tmp-prev-subject
8605 (not (inline (gnus-subject-equal
8606 gnus-tmp-prev-subject subject))))
8608 ((zerop gnus-tmp-level)
8609 (if (and (eq gnus-summary-make-false-root 'empty)
8610 (memq number gnus-tmp-gathered)
8611 gnus-tmp-prev-subject
8612 (inline (gnus-subject-equal
8613 gnus-tmp-prev-subject subject)))
8614 gnus-summary-same-subject
8616 (t gnus-summary-same-subject)))
8617 (if (and (eq gnus-summary-make-false-root 'adopt)
8618 (= gnus-tmp-level 1)
8619 (memq number gnus-tmp-gathered))
8620 (setq gnus-tmp-opening-bracket ?\<
8621 gnus-tmp-closing-bracket ?\>)
8622 (setq gnus-tmp-opening-bracket ?\[
8623 gnus-tmp-closing-bracket ?\]))
8625 gnus-tmp-indentation
8626 (aref gnus-thread-indent-array gnus-tmp-level)
8627 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
8628 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
8629 gnus-summary-default-score 0)
8631 (if (or (null gnus-summary-default-score)
8632 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
8633 gnus-summary-zcore-fuzz)) ?
8634 (if (< gnus-tmp-score gnus-summary-default-score)
8635 gnus-score-below-mark gnus-score-over-mark))
8637 (cond ((memq number gnus-newsgroup-processable)
8639 ((memq number gnus-newsgroup-cached)
8641 ((memq number gnus-newsgroup-replied)
8643 ((memq number gnus-newsgroup-saved)
8645 (t gnus-unread-mark))
8646 gnus-tmp-from (mail-header-from gnus-tmp-header)
8649 ((string-match "(.+)" gnus-tmp-from)
8650 (substring gnus-tmp-from
8651 (1+ (match-beginning 0)) (1- (match-end 0))))
8652 ((string-match "<[^>]+> *$" gnus-tmp-from)
8653 (setq beg-match (match-beginning 0))
8654 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
8655 (substring gnus-tmp-from (1+ (match-beginning 0))
8656 (1- (match-end 0))))
8657 (substring gnus-tmp-from 0 beg-match)))
8659 (when (string= gnus-tmp-name "")
8660 (setq gnus-tmp-name gnus-tmp-from))
8661 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
8662 (gnus-put-text-property
8664 (progn (eval gnus-summary-line-format-spec) (point))
8665 'gnus-number number)
8668 (run-hooks 'gnus-summary-update-hook)
8671 (setq gnus-tmp-prev-subject subject)))
8673 (when (nth 1 thread)
8674 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
8675 (incf gnus-tmp-level)
8676 (setq threads (if thread-end nil (cdar thread)))
8678 (setq gnus-tmp-level 0)))))
8679 (gnus-message 7 "Generating summary...done"))
8681 (defun gnus-summary-prepare-unthreaded (headers)
8682 "Generate an unthreaded summary buffer based on HEADERS."
8683 (let (header number mark)
8686 ;; We may have to root out some bad articles...
8687 (when (memq (setq number (mail-header-number
8688 (setq header (pop headers))))
8689 gnus-newsgroup-limit)
8690 ;; Mark article as read when it has a low score.
8691 (when (and gnus-summary-mark-below
8692 (< (or (cdr (assq number gnus-newsgroup-scored))
8693 gnus-summary-default-score 0)
8694 gnus-summary-mark-below)
8695 (not (memq number gnus-newsgroup-ancient)))
8696 (setq gnus-newsgroup-unreads
8697 (delq number gnus-newsgroup-unreads))
8698 (if gnus-newsgroup-auto-expire
8699 (push number gnus-newsgroup-expirable)
8700 (push (cons number gnus-low-score-mark)
8701 gnus-newsgroup-reads)))
8705 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8706 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8707 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8708 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8709 (t (or (cdr (assq number gnus-newsgroup-reads))
8710 gnus-ancient-mark))))
8711 (setq gnus-newsgroup-data
8712 (cons (gnus-data-make number mark (1+ (point)) header 0)
8713 gnus-newsgroup-data))
8714 (gnus-summary-insert-line
8715 header 0 nil mark (memq number gnus-newsgroup-replied)
8716 (memq number gnus-newsgroup-expirable)
8717 (mail-header-subject header) nil
8718 (cdr (assq number gnus-newsgroup-scored))
8719 (memq number gnus-newsgroup-processable))))))
8721 (defun gnus-select-newsgroup (group &optional read-all)
8722 "Select newsgroup GROUP.
8723 If READ-ALL is non-nil, all articles in the group are selected."
8724 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
8725 (info (nth 2 entry))
8726 articles fetched-articles cached)
8728 (or (gnus-check-server
8729 (setq gnus-current-select-method (gnus-find-method-for-group group)))
8730 (error "Couldn't open server"))
8732 (or (and entry (not (eq (car entry) t))) ; Either it's active...
8733 (gnus-activate-group group) ; Or we can activate it...
8734 (progn ; Or we bug out.
8735 (when (equal major-mode 'gnus-summary-mode)
8736 (kill-buffer (current-buffer)))
8737 (error "Couldn't request group %s: %s"
8738 group (gnus-status-message group))))
8740 (unless (gnus-request-group group t)
8741 (when (equal major-mode 'gnus-summary-mode)
8742 (kill-buffer (current-buffer)))
8743 (error "Couldn't request group %s: %s"
8744 group (gnus-status-message group)))
8746 (setq gnus-newsgroup-name group)
8747 (setq gnus-newsgroup-unselected nil)
8748 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
8750 (and gnus-asynchronous
8751 (gnus-check-backend-function
8752 'request-asynchronous gnus-newsgroup-name)
8753 (setq gnus-newsgroup-async
8754 (gnus-request-asynchronous gnus-newsgroup-name)))
8756 ;; Adjust and set lists of article marks.
8758 (gnus-adjust-marked-articles info))
8760 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8761 (when (gnus-virtual-group-p group)
8762 (setq cached gnus-newsgroup-cached))
8764 (setq gnus-newsgroup-unreads
8765 (gnus-set-difference
8766 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
8767 gnus-newsgroup-dormant))
8769 (setq gnus-newsgroup-processable nil)
8771 (setq articles (gnus-articles-to-read group read-all))
8775 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
8777 ((eq articles 0) nil)
8779 ;; Init the dependencies hash table.
8780 (setq gnus-newsgroup-dependencies
8781 (gnus-make-hashtable (length articles)))
8782 ;; Retrieve the headers and read them in.
8783 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8784 (setq gnus-newsgroup-headers
8786 (setq gnus-headers-retrieved-by
8787 (gnus-retrieve-headers
8788 articles gnus-newsgroup-name
8789 ;; We might want to fetch old headers, but
8790 ;; not if there is only 1 article.
8791 (and gnus-fetch-old-headers
8793 (not (eq gnus-fetch-old-headers 'some))
8794 (not (numberp gnus-fetch-old-headers)))
8795 (> (length articles) 1))))))
8796 (gnus-get-newsgroup-headers-xover articles)
8797 (gnus-get-newsgroup-headers)))
8798 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
8800 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8802 (setq gnus-newsgroup-cached cached))
8804 ;; Set the initial limit.
8805 (setq gnus-newsgroup-limit (copy-sequence articles))
8806 ;; Remove canceled articles from the list of unread articles.
8807 (setq gnus-newsgroup-unreads
8808 (gnus-set-sorted-intersection
8809 gnus-newsgroup-unreads
8810 (setq fetched-articles
8811 (mapcar (lambda (headers) (mail-header-number headers))
8812 gnus-newsgroup-headers))))
8813 ;; Removed marked articles that do not exist.
8814 (gnus-update-missing-marks
8815 (gnus-sorted-complement fetched-articles articles))
8816 ;; We might want to build some more threads first.
8817 (and gnus-fetch-old-headers
8818 (eq gnus-headers-retrieved-by 'nov)
8819 (gnus-build-old-threads))
8820 ;; Check whether auto-expire is to be done in this group.
8821 (setq gnus-newsgroup-auto-expire
8822 (gnus-group-auto-expirable-p group))
8823 ;; Set up the article buffer now, if necessary.
8824 (unless gnus-single-article-buffer
8825 (gnus-article-setup-buffer))
8826 ;; First and last article in this newsgroup.
8827 (when gnus-newsgroup-headers
8828 (setq gnus-newsgroup-begin
8829 (mail-header-number (car gnus-newsgroup-headers))
8832 (gnus-last-element gnus-newsgroup-headers))))
8833 (setq gnus-reffed-article-number -1)
8834 ;; GROUP is successfully selected.
8835 (or gnus-newsgroup-headers t)))))
8837 (defun gnus-articles-to-read (group read-all)
8838 ;; Find out what articles the user wants to read.
8840 ;; Select all articles if `read-all' is non-nil, or if there
8841 ;; are no unread articles.
8843 (and (zerop (length gnus-newsgroup-marked))
8844 (zerop (length gnus-newsgroup-unreads))))
8845 (gnus-uncompress-range (gnus-active group))
8846 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
8847 (copy-sequence gnus-newsgroup-unreads))
8849 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
8850 (scored (length scored-list))
8851 (number (length articles))
8852 (marked (+ (length gnus-newsgroup-marked)
8853 (length gnus-newsgroup-dormant)))
8861 ((and (or (<= scored marked) (= scored number))
8862 (numberp gnus-large-newsgroup)
8863 (> number gnus-large-newsgroup))
8867 "How many articles from %s (default %d): "
8868 gnus-newsgroup-name number))))
8869 (if (string-match "^[ \t]*$" input) number input)))
8870 ((and (> scored marked) (< scored number)
8871 (> (- scored number) 20))
8874 (format "%s %s (%d scored, %d total): "
8875 "How many articles from"
8876 group scored number))))
8877 (if (string-match "^[ \t]*$" input)
8881 (setq select (if (stringp select) (string-to-number select) select))
8882 (if (or (null select) (zerop select))
8884 (if (and (not (zerop scored)) (<= (abs select) scored))
8886 (setq articles (sort scored-list '<))
8887 (setq number (length articles)))
8888 (setq articles (copy-sequence articles)))
8890 (if (< (abs select) number)
8892 ;; Select the N oldest articles.
8893 (setcdr (nthcdr (1- (abs select)) articles) nil)
8894 ;; Select the N most recent articles.
8895 (setq articles (nthcdr (- number select) articles))))
8896 (setq gnus-newsgroup-unselected
8897 (gnus-sorted-intersection
8898 gnus-newsgroup-unreads
8899 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
8902 (defun gnus-killed-articles (killed articles)
8905 (if (inline (gnus-member-of-range (car articles) killed))
8906 (setq out (cons (car articles) out)))
8907 (setq articles (cdr articles)))
8910 (defun gnus-uncompress-marks (marks)
8911 "Uncompress the mark ranges in MARKS."
8912 (let ((uncompressed '(score bookmark))
8915 (if (memq (caar marks) uncompressed)
8916 (push (car marks) out)
8917 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
8918 (setq marks (cdr marks)))
8921 (defun gnus-adjust-marked-articles (info)
8922 "Set all article lists and remove all marks that are no longer legal."
8923 (let* ((marked-lists (gnus-info-marks info))
8924 (active (gnus-active (gnus-info-group info)))
8927 (types gnus-article-mark-lists)
8928 (uncompressed '(score bookmark))
8929 marks var articles article mark)
8932 (setq marks (pop marked-lists))
8933 (set (setq var (intern (format "gnus-newsgroup-%s"
8934 (car (rassq (setq mark (car marks))
8936 (if (memq (car marks) uncompressed) (cdr marks)
8937 (gnus-uncompress-range (cdr marks))))
8939 (setq articles (symbol-value var))
8941 ;; All articles have to be subsets of the active articles.
8943 ;; Adjust "simple" lists.
8944 ((memq mark '(tick dormant expirable reply killed save))
8946 (when (or (< (setq article (pop articles)) min) (> article max))
8947 (set var (delq article (symbol-value var))))))
8949 ((memq mark '(score bookmark))
8951 (when (or (< (car (setq article (pop articles))) min)
8952 (> (car article) max))
8953 (set var (delq article (symbol-value var))))))))))
8955 (defun gnus-update-missing-marks (missing)
8956 "Go through the list of MISSING articles and remove them mark lists."
8958 (let ((types gnus-article-mark-lists)
8960 ;; Go through all types.
8962 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
8963 (when (symbol-value var)
8964 ;; This list has articles. So we delete all missing articles
8968 (set var (delq (pop m) (symbol-value var)))))))))
8970 (defun gnus-update-marks ()
8971 "Enter the various lists of marked articles into the newsgroup info list."
8972 (let ((types gnus-article-mark-lists)
8973 (info (gnus-get-info gnus-newsgroup-name))
8974 (uncompressed '(score bookmark killed))
8975 type list newmarked symbol)
8977 ;; Add all marks lists that are non-nil to the list of marks lists.
8979 (setq type (pop types))
8980 (when (setq list (symbol-value
8982 (intern (format "gnus-newsgroup-%s"
8984 (push (cons (cdr type)
8985 (if (memq (cdr type) uncompressed) list
8986 (gnus-compress-sequence
8987 (set symbol (sort list '<)) t)))
8990 ;; Enter these new marks into the info of the group.
8992 (setcar (nthcdr 3 info) newmarked)
8993 ;; Add the marks lists to the end of the info.
8995 (setcdr (nthcdr 2 info) (list newmarked))))
8997 ;; Cut off the end of the info if there's nothing else there.
9001 (when (nthcdr (decf i) info)
9002 (setcdr (nthcdr i info) nil)))))))
9004 (defun gnus-add-marked-articles (group type articles &optional info force)
9005 ;; Add ARTICLES of TYPE to the info of GROUP.
9006 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
9007 ;; add, but replace marked articles of TYPE with ARTICLES.
9008 (let ((info (or info (gnus-get-info group)))
9009 (uncompressed '(score bookmark killed))
9012 (and (not (setq marked (nthcdr 3 info)))
9014 (setcdr (nthcdr 2 info)
9015 (list (list (cons type (gnus-compress-sequence
9017 (and (not (setq m (assq type (car marked))))
9020 (cons (cons type (gnus-compress-sequence articles t) )
9024 (setcar (nthcdr 3 info)
9025 (delq (assq type (car marked)) (car marked)))
9026 (setcdr m (gnus-compress-sequence articles t)))
9027 (setcdr m (gnus-compress-sequence
9028 (sort (nconc (gnus-uncompress-range (cdr m))
9029 (copy-sequence articles)) '<) t))))))
9031 (defun gnus-set-mode-line (where)
9032 "This function sets the mode line of the article or summary buffers.
9033 If WHERE is `summary', the summary mode line format will be used."
9034 ;; Is this mode line one we keep updated?
9035 (when (memq where gnus-updated-mode-lines)
9038 ;; We evaluate this in the summary buffer since these
9039 ;; variables are buffer-local to that buffer.
9040 (set-buffer gnus-summary-buffer)
9041 ;; We bind all these variables that are used in the `eval' form
9043 (let* ((mformat (symbol-value
9045 (format "gnus-%s-mode-line-format-spec" where))))
9046 (gnus-tmp-group-name gnus-newsgroup-name)
9047 (gnus-tmp-article-number (or gnus-current-article 0))
9048 (gnus-tmp-unread gnus-newsgroup-unreads)
9049 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
9050 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
9051 (gnus-tmp-unread-and-unselected
9052 (cond ((and (zerop gnus-tmp-unread-and-unticked)
9053 (zerop gnus-tmp-unselected)) "")
9054 ((zerop gnus-tmp-unselected)
9055 (format "{%d more}" gnus-tmp-unread-and-unticked))
9056 (t (format "{%d(+%d) more}"
9057 gnus-tmp-unread-and-unticked
9058 gnus-tmp-unselected))))
9060 (if (and gnus-current-headers
9061 (vectorp gnus-current-headers))
9062 (gnus-mode-string-quote
9063 (mail-header-subject gnus-current-headers)) ""))
9065 gnus-tmp-header);; passed as argument to any user-format-funcs
9066 (setq mode-string (eval mformat))
9067 (setq max-len (max 4 (if gnus-mode-non-string-length
9069 gnus-mode-non-string-length)
9070 (length mode-string))))
9071 ;; We might have to chop a bit of the string off...
9072 (when (> (length mode-string) max-len)
9074 (concat (gnus-truncate-string mode-string (- max-len 3))
9076 ;; Pad the mode string a bit.
9077 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
9078 ;; Update the mode line.
9079 (setq mode-line-buffer-identification
9080 (gnus-mode-line-buffer-identification
9081 (list mode-string)))
9082 (set-buffer-modified-p t))))
9084 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
9085 "Go through the HEADERS list and add all Xrefs to a hash table.
9086 The resulting hash table is returned, or nil if no Xrefs were found."
9087 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
9088 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
9089 (xref-hashtb (make-vector 63 0))
9090 start group entry number xrefs header)
9092 (setq header (pop headers))
9093 (when (and (setq xrefs (mail-header-xref header))
9094 (not (memq (setq number (mail-header-number header))
9097 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
9098 (setq start (match-end 0))
9099 (setq group (if prefix
9100 (concat prefix (substring xrefs (match-beginning 1)
9102 (substring xrefs (match-beginning 1) (match-end 1))))
9104 (string-to-int (substring xrefs (match-beginning 2)
9106 (if (setq entry (gnus-gethash group xref-hashtb))
9107 (setcdr entry (cons number (cdr entry)))
9108 (gnus-sethash group (cons number nil) xref-hashtb)))))
9109 (and start xref-hashtb)))
9111 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
9112 "Look through all the headers and mark the Xrefs as read."
9113 (let ((virtual (gnus-virtual-group-p from-newsgroup))
9114 name entry info xref-hashtb idlist method nth4)
9116 (set-buffer gnus-group-buffer)
9117 (when (setq xref-hashtb
9118 (gnus-create-xref-hashtb from-newsgroup headers unreads))
9121 (unless (string= from-newsgroup (setq name (symbol-name group)))
9122 (setq idlist (symbol-value group))
9123 ;; Dead groups are not updated.
9125 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
9127 (if (stringp (setq nth4 (gnus-info-method info)))
9128 (setq nth4 (gnus-server-to-method nth4))))
9129 ;; Only do the xrefs if the group has the same
9130 ;; select method as the group we have just read.
9131 (or (gnus-methods-equal-p
9132 nth4 (gnus-find-method-for-group from-newsgroup))
9134 (equal nth4 (setq method (gnus-find-method-for-group
9136 (and (equal (car nth4) (car method))
9137 (equal (nth 1 nth4) (nth 1 method))))
9138 gnus-use-cross-reference
9139 (or (not (eq gnus-use-cross-reference t))
9141 ;; Only do cross-references on subscribed
9142 ;; groups, if that is what is wanted.
9143 (<= (gnus-info-level info) gnus-level-subscribed))
9144 (gnus-group-make-articles-read name idlist))))
9147 (defun gnus-group-make-articles-read (group articles)
9149 (entry (gnus-gethash group gnus-newsrc-hashtb))
9150 (info (nth 2 entry))
9151 (active (gnus-active group))
9153 ;; First peel off all illegal article numbers.
9155 (let ((ids articles)
9159 (if (and first (> id (cdr active)))
9161 ;; We'll end up in this situation in one particular
9162 ;; obscure situation. If you re-scan a group and get
9163 ;; a new article that is cross-posted to a different
9164 ;; group that has not been re-scanned, you might get
9165 ;; crossposted article that has a higher number than
9166 ;; Gnus believes possible. So we re-activate this
9167 ;; group as well. This might mean doing the
9168 ;; crossposting thingy will *increase* the number
9169 ;; of articles in some groups. Tsk, tsk.
9170 (setq active (or (gnus-activate-group group) active))))
9171 (if (or (> id (cdr active))
9172 (< id (car active)))
9173 (setq articles (delq id articles)))
9174 (setq ids (cdr ids)))))
9175 ;; If the read list is nil, we init it.
9177 (null (gnus-info-read info))
9179 (gnus-info-set-read info (cons 1 (1- (car active)))))
9180 ;; Then we add the read articles to the range.
9185 (gnus-info-read info) (setq articles (sort articles '<)))))
9186 ;; Then we have to re-compute how many unread
9187 ;; articles there are in this group.
9192 (setq num (- (1+ (cdr active)) (car active))))
9193 ((not (listp (cdr range)))
9194 (setq num (- (cdr active) (- (1+ (cdr range))
9198 (if (numberp (car range))
9200 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
9201 (setq range (cdr range)))
9202 (setq num (- (cdr active) num))))
9203 ;; Update the number of unread articles.
9205 ;; Update the group buffer.
9206 (gnus-group-update-group group t)))))
9208 (defun gnus-methods-equal-p (m1 m2)
9209 (let ((m1 (or m1 gnus-select-method))
9210 (m2 (or m2 gnus-select-method)))
9212 (and (eq (car m1) (car m2))
9213 (or (not (memq 'address (assoc (symbol-name (car m1))
9214 gnus-valid-select-methods)))
9215 (equal (nth 1 m1) (nth 1 m2)))))))
9217 (defsubst gnus-header-value ()
9218 (buffer-substring (match-end 0) (gnus-point-at-eol)))
9220 (defvar gnus-newsgroup-none-id 0)
9222 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
9223 (let ((cur nntp-server-buffer)
9226 (save-excursion (set-buffer gnus-summary-buffer)
9227 gnus-newsgroup-dependencies)))
9228 headers id id-dep ref-dep end ref)
9230 (set-buffer nntp-server-buffer)
9231 (run-hooks 'gnus-parse-headers-hook)
9232 (let ((case-fold-search t)
9233 in-reply-to header p lines)
9234 (goto-char (point-min))
9235 ;; Search to the beginning of the next header. Error messages
9236 ;; do not begin with 2 or 3.
9237 (while (re-search-forward "^[23][0-9]+ " nil t)
9240 ;; This implementation of this function, with nine
9241 ;; search-forwards instead of the one re-search-forward and
9242 ;; a case (which basically was the old function) is actually
9243 ;; about twice as fast, even though it looks messier. You
9244 ;; can't have everything, I guess. Speed and elegance
9245 ;; doesn't always go hand in hand.
9254 (narrow-to-region (point)
9255 (or (and (search-forward "\n.\n" nil t)
9261 (if (search-forward "\nsubject: " nil t)
9262 (gnus-header-value) "(none)"))
9266 (if (search-forward "\nfrom: " nil t)
9267 (gnus-header-value) "(nobody)"))
9271 (if (search-forward "\ndate: " nil t)
9272 (gnus-header-value) ""))
9276 (if (search-forward "\nmessage-id: " nil t)
9277 (setq id (gnus-header-value))
9278 ;; If there was no message-id, we just fake one to make
9279 ;; subsequent routines simpler.
9280 (setq id (concat "none+"
9282 (setq gnus-newsgroup-none-id
9283 (1+ gnus-newsgroup-none-id)))))))
9287 (if (search-forward "\nreferences: " nil t)
9296 (search-backward ">" end t)
9299 (search-backward "<" end t)
9301 ;; Get the references from the in-reply-to header if there
9302 ;; were no references and the in-reply-to header looks
9304 (if (and (search-forward "\nin-reply-to: " nil t)
9305 (setq in-reply-to (gnus-header-value))
9306 (string-match "<[^>]+>" in-reply-to))
9307 (setq ref (substring in-reply-to (match-beginning 0)
9315 (if (search-forward "\nlines: " nil t)
9316 (if (numberp (setq lines (read cur)))
9322 (and (search-forward "\nxref: " nil t)
9323 (gnus-header-value)))))
9324 ;; We do the threading while we read the headers. The
9325 ;; message-id and the last reference are both entered into
9326 ;; the same hash table. Some tippy-toeing around has to be
9327 ;; done in case an article has arrived before the article
9328 ;; which it refers to.
9329 (if (boundp (setq id-dep (intern id dependencies)))
9330 (if (and (car (symbol-value id-dep))
9332 ;; An article with this Message-ID has already
9333 ;; been seen, so we ignore this one, except we add
9334 ;; any additional Xrefs (in case the two articles
9335 ;; came from different servers).
9337 (mail-header-set-xref
9338 (car (symbol-value id-dep))
9339 (concat (or (mail-header-xref
9340 (car (symbol-value id-dep))) "")
9341 (or (mail-header-xref header) "")))
9343 (setcar (symbol-value id-dep) header))
9344 (set id-dep (list header)))
9346 (if (boundp (setq ref-dep (intern ref dependencies)))
9347 (setcdr (symbol-value ref-dep)
9348 (nconc (cdr (symbol-value ref-dep))
9349 (list (symbol-value id-dep))))
9350 (set ref-dep (list nil (symbol-value id-dep))))
9351 (setq headers (cons header headers)))
9352 (goto-char (point-max))
9354 (nreverse headers)))))
9356 ;; The following macros and functions were written by Felix Lee
9357 ;; <flee@cse.psu.edu>.
9359 (defmacro gnus-nov-read-integer ()
9361 (if (= (following-char) ?\t)
9363 (let ((num (condition-case nil (read buffer) (error nil))))
9364 (if (numberp num) num 0)))
9365 (or (eobp) (forward-char 1))))
9367 (defmacro gnus-nov-skip-field ()
9368 '(search-forward "\t" eol 'move))
9370 (defmacro gnus-nov-field ()
9371 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
9373 ;; Goes through the xover lines and returns a list of vectors
9374 (defun gnus-get-newsgroup-headers-xover (sequence &optional
9375 force-new dependencies)
9376 "Parse the news overview data in the server buffer, and return a
9377 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
9378 ;; Get the Xref when the users reads the articles since most/some
9379 ;; NNTP servers do not include Xrefs when using XOVER.
9380 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
9381 (let ((cur nntp-server-buffer)
9382 (dependencies (or dependencies gnus-newsgroup-dependencies))
9383 number headers header)
9385 (set-buffer nntp-server-buffer)
9386 ;; Allow the user to mangle the headers before parsing them.
9387 (run-hooks 'gnus-parse-headers-hook)
9388 (goto-char (point-min))
9389 (while (and sequence (not (eobp)))
9390 (setq number (read cur))
9391 (while (and sequence (< (car sequence) number))
9392 (setq sequence (cdr sequence)))
9394 (eq number (car sequence))
9396 (setq sequence (cdr sequence))
9398 (inline (gnus-nov-parse-line
9399 number dependencies force-new)))
9400 (setq headers (cons header headers)))))
9402 (setq headers (nreverse headers)))
9405 ;; This function has to be called with point after the article number
9406 ;; on the beginning of the line.
9407 (defun gnus-nov-parse-line (number dependencies &optional force-new)
9409 (eol (gnus-point-at-eol))
9410 (buffer (current-buffer))
9411 header ref id id-dep ref-dep)
9413 ;; overview: [num subject from date id refs chars lines misc]
9414 (narrow-to-region (point) eol)
9415 (or (eobp) (forward-char))
9421 (gnus-nov-field) ; subject
9422 (gnus-nov-field) ; from
9423 (gnus-nov-field) ; date
9424 (setq id (or (gnus-nov-field)
9427 (setq none (1+ none)))))) ; id
9430 (let ((beg (point)))
9431 (search-forward "\t" eol)
9432 (if (search-backward ">" beg t)
9436 (search-backward "<" beg t)))
9438 (gnus-nov-field)) ; refs
9439 (gnus-nov-read-integer) ; chars
9440 (gnus-nov-read-integer) ; lines
9441 (if (= (following-char) ?\n)
9443 (gnus-nov-field)) ; misc
9446 (gnus-error 4 "Strange nov line")
9452 ;; We build the thread tree.
9454 (if (boundp (setq id-dep (intern id dependencies)))
9455 (if (and (car (symbol-value id-dep))
9457 ;; An article with this Message-ID has already been seen,
9458 ;; so we ignore this one, except we add any additional
9459 ;; Xrefs (in case the two articles came from different
9462 (mail-header-set-xref
9463 (car (symbol-value id-dep))
9464 (concat (or (mail-header-xref
9465 (car (symbol-value id-dep))) "")
9466 (or (mail-header-xref header) "")))
9468 (setcar (symbol-value id-dep) header))
9469 (set id-dep (list header))))
9471 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
9472 (setcdr (symbol-value ref-dep)
9473 (nconc (cdr (symbol-value ref-dep))
9474 (list (symbol-value id-dep))))
9475 (set ref-dep (list nil (symbol-value id-dep)))))
9478 (defun gnus-article-get-xrefs ()
9479 "Fill in the Xref value in `gnus-current-headers', if necessary.
9480 This is meant to be called in `gnus-article-internal-prepare-hook'."
9481 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
9482 gnus-current-headers)))
9483 (or (not gnus-use-cross-reference)
9485 (and (mail-header-xref headers)
9486 (not (string= (mail-header-xref headers) "")))
9487 (let ((case-fold-search t)
9490 (nnheader-narrow-to-headers)
9491 (goto-char (point-min))
9492 (if (or (and (eq (downcase (following-char)) ?x)
9493 (looking-at "Xref:"))
9494 (search-forward "\nXref:" nil t))
9496 (goto-char (1+ (match-end 0)))
9497 (setq xref (buffer-substring (point)
9498 (progn (end-of-line) (point))))
9499 (mail-header-set-xref headers xref))))))))
9501 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
9502 "Find article ID and insert the summary line for that article."
9503 (let ((header (if (and old-header use-old-header)
9504 old-header (gnus-read-header id)))
9505 (number (and (numberp id) id))
9508 ;; Rebuild the thread that this article is part of and go to the
9509 ;; article we have fetched.
9510 (when (and (not gnus-show-threads)
9512 (when (setq pos (text-property-any
9513 (point-min) (point-max) 'gnus-number
9514 (mail-header-number old-header)))
9517 (gnus-data-remove (mail-header-number old-header))))
9519 (mail-header-set-number header (mail-header-number old-header)))
9520 (setq gnus-newsgroup-sparse
9521 (delq (setq number (mail-header-number header))
9522 gnus-newsgroup-sparse))
9523 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
9524 (gnus-rebuild-thread (mail-header-id header))
9525 (gnus-summary-goto-subject number nil t))
9526 (when (and (numberp number)
9528 ;; We have to update the boundaries even if we can't fetch the
9529 ;; article if ID is a number -- so that the next `P' or `N'
9530 ;; command will fetch the previous (or next) article even
9531 ;; if the one we tried to fetch this time has been canceled.
9532 (and (> number gnus-newsgroup-end)
9533 (setq gnus-newsgroup-end number))
9534 (and (< number gnus-newsgroup-begin)
9535 (setq gnus-newsgroup-begin number))
9536 (setq gnus-newsgroup-unselected
9537 (delq number gnus-newsgroup-unselected)))
9538 ;; Report back a success?
9539 (and header (mail-header-number header))))
9541 (defun gnus-summary-work-articles (n)
9542 "Return a list of articles to be worked upon. The prefix argument,
9543 the list of process marked articles, and the current article will be
9544 taken into consideration."
9546 ((and n (numberp n))
9547 ;; A numerical prefix has been given.
9548 (let ((backward (< n 0))
9554 (push (setq article (gnus-summary-article-number))
9557 (gnus-summary-find-prev nil article)
9558 (gnus-summary-find-next nil article)))
9560 (nreverse articles)))
9561 ((and (boundp 'transient-mark-mode)
9564 ;; Work on the region between point and mark.
9565 (let ((max (max (point) (mark)))
9568 (goto-char (min (point) (mark)))
9571 (push (setq article (gnus-summary-article-number)) articles)
9572 (gnus-summary-find-next nil article)
9574 (nreverse articles))))
9575 (gnus-newsgroup-processable
9576 ;; There are process-marked articles present.
9577 (reverse gnus-newsgroup-processable))
9579 ;; Just return the current article.
9580 (list (gnus-summary-article-number)))))
9582 (defun gnus-summary-search-group (&optional backward use-level)
9583 "Search for next unread newsgroup.
9584 If optional argument BACKWARD is non-nil, search backward instead."
9586 (set-buffer gnus-group-buffer)
9587 (if (gnus-group-search-forward
9588 backward nil (if use-level (gnus-group-group-level) nil))
9589 (gnus-group-group-name))))
9591 (defun gnus-summary-best-group (&optional exclude-group)
9592 "Find the name of the best unread group.
9593 If EXCLUDE-GROUP, do not go to this group."
9595 (set-buffer gnus-group-buffer)
9597 (gnus-group-best-unread-group exclude-group))))
9599 (defun gnus-summary-find-next (&optional unread article backward)
9600 (if backward (gnus-summary-find-prev)
9601 (let* ((dummy (gnus-summary-article-intangible-p))
9602 (article (or article (gnus-summary-article-number)))
9603 (arts (gnus-data-find-list article))
9605 (when (and (not dummy)
9606 (or (not gnus-summary-check-current)
9608 (not (gnus-data-unread-p (car arts)))))
9609 (setq arts (cdr arts)))
9614 (when (gnus-data-unread-p (car arts))
9615 (setq result (car arts)
9617 (setq arts (cdr arts)))
9620 (goto-char (gnus-data-pos result))
9621 (gnus-data-number result)))))
9623 (defun gnus-summary-find-prev (&optional unread article)
9624 (let* ((eobp (eobp))
9625 (article (or article (gnus-summary-article-number)))
9626 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
9628 (when (and (not eobp)
9629 (or (not gnus-summary-check-current)
9631 (not (gnus-data-unread-p (car arts)))))
9632 (setq arts (cdr arts)))
9637 (and (gnus-data-unread-p (car arts))
9638 (setq result (car arts)
9640 (setq arts (cdr arts)))
9644 (goto-char (gnus-data-pos result))
9645 (gnus-data-number result)))))
9647 (defun gnus-summary-find-subject (subject &optional unread backward article)
9648 (let* ((simp-subject (gnus-simplify-subject-fully subject))
9649 (article (or article (gnus-summary-article-number)))
9650 (articles (gnus-data-list backward))
9651 (arts (gnus-data-find-list article articles))
9653 (when (or (not gnus-summary-check-current)
9655 (not (gnus-data-unread-p (car arts))))
9656 (setq arts (cdr arts)))
9658 (and (or (not unread)
9659 (gnus-data-unread-p (car arts)))
9660 (vectorp (gnus-data-header (car arts)))
9662 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
9663 (setq result (car arts)
9665 (setq arts (cdr arts)))
9667 (goto-char (gnus-data-pos result))
9668 (gnus-data-number result))))
9670 (defun gnus-summary-search-forward (&optional unread subject backward)
9671 "Search forward for an article.
9672 If UNREAD, look for unread articles. If SUBJECT, look for
9673 articles with that subject. If BACKWARD, search backward instead."
9674 (cond (subject (gnus-summary-find-subject subject unread backward))
9675 (backward (gnus-summary-find-prev unread))
9676 (t (gnus-summary-find-next unread))))
9678 (defun gnus-recenter (&optional n)
9679 "Center point in window and redisplay frame.
9680 Also do horizontal recentering."
9682 (when (and gnus-auto-center-summary
9683 (not (eq gnus-auto-center-summary 'vertical)))
9684 (gnus-horizontal-recenter))
9687 (defun gnus-summary-recenter ()
9688 "Center point in the summary window.
9689 If `gnus-auto-center-summary' is nil, or the article buffer isn't
9690 displayed, no centering will be performed."
9691 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
9692 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
9693 (let* ((top (cond ((< (window-height) 4) 0)
9694 ((< (window-height) 7) 1)
9696 (height (1- (window-height)))
9697 (bottom (save-excursion (goto-char (point-max))
9698 (forward-line (- height))
9700 (window (get-buffer-window (current-buffer))))
9701 ;; The user has to want it.
9702 (when gnus-auto-center-summary
9703 (when (get-buffer-window gnus-article-buffer)
9704 ;; Only do recentering when the article buffer is displayed,
9705 ;; Set the window start to either `bottom', which is the biggest
9706 ;; possible valid number, or the second line from the top,
9707 ;; whichever is the least.
9709 window (min bottom (save-excursion
9710 (forward-line (- top)) (point)))))
9711 ;; Do horizontal recentering while we're at it.
9712 (when (and (get-buffer-window (current-buffer) t)
9713 (not (eq gnus-auto-center-summary 'vertical)))
9714 (let ((selected (selected-window)))
9715 (select-window (get-buffer-window (current-buffer) t))
9716 (gnus-summary-position-point)
9717 (gnus-horizontal-recenter)
9718 (select-window selected))))))
9720 (defun gnus-horizontal-recenter ()
9721 "Recenter the current buffer horizontally."
9722 (if (< (current-column) (/ (window-width) 2))
9723 (set-window-hscroll (get-buffer-window (current-buffer) t) 0)
9724 (let* ((orig (point))
9725 (end (window-end (get-buffer-window (current-buffer) t)))
9727 ;; Find the longest line currently displayed in the window.
9728 (goto-char (window-start))
9729 (while (and (not (eobp))
9732 (setq max (max max (current-column)))
9735 ;; Scroll horizontally to center (sort of) the point.
9736 (if (> max (window-width))
9738 (get-buffer-window (current-buffer) t)
9739 (min (- (current-column) (/ (window-width) 3))
9740 (+ 2 (- max (window-width)))))
9741 (set-window-hscroll (get-buffer-window (current-buffer) t) 0))
9744 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
9745 (defun gnus-short-group-name (group &optional levels)
9746 "Collapse GROUP name LEVELS."
9753 (while (string-match "\\." group skip)
9754 (setq skip (match-end 0)
9757 (if (string-match ":" group)
9758 (setq foreign (substring group 0 (match-end 0))
9759 group (substring group (match-end 0))))
9761 (if (and (string-match "\\." group)
9762 (> levels (- gnus-group-uncollapsed-levels 1)))
9763 (setq name (concat name (substring group 0 1))
9764 group (substring group (match-end 0))
9766 name (concat name "."))
9767 (setq name (concat foreign name group)
9771 (defun gnus-summary-jump-to-group (newsgroup)
9772 "Move point to NEWSGROUP in group mode buffer."
9773 ;; Keep update point of group mode buffer if visible.
9774 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
9775 (save-window-excursion
9776 ;; Take care of tree window mode.
9777 (if (get-buffer-window gnus-group-buffer)
9778 (pop-to-buffer gnus-group-buffer))
9779 (gnus-group-jump-to-group newsgroup))
9781 ;; Take care of tree window mode.
9782 (if (get-buffer-window gnus-group-buffer)
9783 (pop-to-buffer gnus-group-buffer)
9784 (set-buffer gnus-group-buffer))
9785 (gnus-group-jump-to-group newsgroup))))
9787 ;; This function returns a list of article numbers based on the
9788 ;; difference between the ranges of read articles in this group and
9789 ;; the range of active articles.
9790 (defun gnus-list-of-unread-articles (group)
9791 (let* ((read (gnus-info-read (gnus-get-info group)))
9792 (active (gnus-active group))
9795 ;; If none are read, then all are unread.
9797 (setq first (car active))
9798 ;; If the range of read articles is a single range, then the
9799 ;; first unread article is the article after the last read
9800 ;; article. Sounds logical, doesn't it?
9801 (if (not (listp (cdr read)))
9802 (setq first (1+ (cdr read)))
9803 ;; `read' is a list of ranges.
9804 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
9809 (while (< first nlast)
9810 (setq unread (cons first unread))
9811 (setq first (1+ first))))
9812 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
9813 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
9814 (setq read (cdr read)))))
9815 ;; And add the last unread articles.
9816 (while (<= first last)
9817 (setq unread (cons first unread))
9818 (setq first (1+ first)))
9819 ;; Return the list of unread articles.
9822 (defun gnus-list-of-read-articles (group)
9823 "Return a list of unread, unticked and non-dormant articles."
9824 (let* ((info (gnus-get-info group))
9825 (marked (gnus-info-marks info))
9826 (active (gnus-active group)))
9828 (gnus-set-difference
9829 (gnus-sorted-complement
9830 (gnus-uncompress-range active)
9831 (gnus-list-of-unread-articles group))
9833 (gnus-uncompress-range (cdr (assq 'dormant marked)))
9834 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
9836 ;; Various summary commands
9838 (defun gnus-summary-universal-argument (arg)
9839 "Perform any operation on all articles that are process/prefixed."
9841 (gnus-set-global-variables)
9842 (let ((articles (gnus-summary-work-articles arg))
9849 (substitute-command-keys
9850 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
9853 (gnus-error 1 "Undefined key")
9856 (gnus-summary-goto-subject (setq article (pop articles)))
9857 (command-execute func)
9858 (gnus-summary-remove-process-mark article)))))
9859 (gnus-summary-position-point))
9861 (defun gnus-summary-toggle-truncation (&optional arg)
9862 "Toggle truncation of summary lines.
9863 With arg, turn line truncation on iff arg is positive."
9865 (setq truncate-lines
9866 (if (null arg) (not truncate-lines)
9867 (> (prefix-numeric-value arg) 0)))
9870 (defun gnus-summary-reselect-current-group (&optional all rescan)
9871 "Exit and then reselect the current newsgroup.
9872 The prefix argument ALL means to select all articles."
9874 (gnus-set-global-variables)
9875 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
9876 (error "Ephemeral groups can't be reselected"))
9877 (let ((current-subject (gnus-summary-article-number))
9878 (group gnus-newsgroup-name))
9879 (setq gnus-newsgroup-begin nil)
9881 ;; We have to adjust the point of group mode buffer because the
9882 ;; current point was moved to the next unread newsgroup by
9884 (gnus-summary-jump-to-group group)
9887 (gnus-group-get-new-news-this-group 1)))
9888 (gnus-group-read-group all t)
9889 (gnus-summary-goto-subject current-subject)))
9891 (defun gnus-summary-rescan-group (&optional all)
9892 "Exit the newsgroup, ask for new articles, and select the newsgroup."
9894 (gnus-summary-reselect-current-group all t))
9896 (defun gnus-summary-update-info ()
9897 (let* ((group gnus-newsgroup-name))
9898 (when gnus-newsgroup-kill-headers
9899 (setq gnus-newsgroup-killed
9900 (gnus-compress-sequence
9902 (gnus-set-sorted-intersection
9903 (gnus-uncompress-range gnus-newsgroup-killed)
9904 (setq gnus-newsgroup-unselected
9905 (sort gnus-newsgroup-unselected '<)))
9906 (setq gnus-newsgroup-unreads
9907 (sort gnus-newsgroup-unreads '<))) t)))
9908 (unless (listp (cdr gnus-newsgroup-killed))
9909 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
9910 (let ((headers gnus-newsgroup-headers))
9911 (run-hooks 'gnus-exit-group-hook)
9912 (unless gnus-save-score
9913 (setq gnus-newsgroup-scored nil))
9914 ;; Set the new ranges of read articles.
9915 (gnus-update-read-articles
9916 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
9917 ;; Set the current article marks.
9919 ;; Do the cross-ref thing.
9920 (when gnus-use-cross-reference
9921 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
9922 ;; Do adaptive scoring, and possibly save score files.
9923 (when gnus-newsgroup-adaptive
9924 (gnus-score-adaptive))
9925 (when gnus-use-scoring
9927 ;; Do not switch windows but change the buffer to work.
9928 (set-buffer gnus-group-buffer)
9929 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
9930 (gnus-group-update-group group)))))
9932 (defun gnus-summary-exit (&optional temporary)
9933 "Exit reading current newsgroup, and then return to group selection mode.
9934 gnus-exit-group-hook is called with no arguments if that value is non-nil."
9936 (gnus-set-global-variables)
9937 (gnus-kill-save-kill-buffer)
9938 (let* ((group gnus-newsgroup-name)
9939 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
9941 (buf (current-buffer)))
9942 (run-hooks 'gnus-summary-prepare-exit-hook)
9943 ;; If we have several article buffers, we kill them at exit.
9944 (unless gnus-single-article-buffer
9945 (gnus-kill-buffer gnus-original-article-buffer)
9946 (setq gnus-article-current nil))
9947 (when gnus-use-cache
9948 (gnus-cache-possibly-remove-articles)
9949 (gnus-cache-save-buffers))
9950 (when gnus-use-trees
9951 (gnus-tree-close group))
9952 ;; Make all changes in this group permanent.
9954 (gnus-summary-update-info))
9955 (gnus-close-group group)
9956 ;; Make sure where I was, and go to next newsgroup.
9957 (set-buffer gnus-group-buffer)
9959 (gnus-group-jump-to-group group))
9960 (run-hooks 'gnus-summary-exit-hook)
9962 (gnus-group-next-unread-group 1))
9965 ;; If we have several article buffers, we kill them at exit.
9966 (unless gnus-single-article-buffer
9967 (gnus-kill-buffer gnus-article-buffer)
9968 (gnus-kill-buffer gnus-original-article-buffer)
9969 (setq gnus-article-current nil))
9971 (if (not gnus-kill-summary-on-exit)
9972 (gnus-deaden-summary)
9973 ;; We set all buffer-local variables to nil. It is unclear why
9974 ;; this is needed, but if we don't, buffer-local variables are
9975 ;; not garbage-collected, it seems. This would the lead to en
9976 ;; ever-growing Emacs.
9977 (gnus-summary-clear-local-variables)
9978 (when (get-buffer gnus-article-buffer)
9979 (bury-buffer gnus-article-buffer))
9980 ;; We clear the global counterparts of the buffer-local
9981 ;; variables as well, just to be on the safe side.
9982 (gnus-configure-windows 'group 'force)
9983 (gnus-summary-clear-local-variables)
9984 ;; Return to group mode buffer.
9985 (if (eq mode 'gnus-summary-mode)
9986 (gnus-kill-buffer buf)))
9987 (setq gnus-current-select-method gnus-select-method)
9988 (pop-to-buffer gnus-group-buffer)
9989 ;; Clear the current group name.
9990 (if (not quit-config)
9992 (gnus-group-jump-to-group group)
9993 (gnus-group-next-unread-group 1)
9994 (gnus-configure-windows 'group 'force))
9995 (if (not (buffer-name (car quit-config)))
9996 (gnus-configure-windows 'group 'force)
9997 (set-buffer (car quit-config))
9998 (and (eq major-mode 'gnus-summary-mode)
9999 (gnus-set-global-variables))
10000 (gnus-configure-windows (cdr quit-config))))
10001 (unless quit-config
10002 (setq gnus-newsgroup-name nil)))))
10004 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
10005 (defun gnus-summary-exit-no-update (&optional no-questions)
10006 "Quit reading current newsgroup without updating read article info."
10008 (gnus-set-global-variables)
10009 (let* ((group gnus-newsgroup-name)
10010 (quit-config (gnus-group-quit-config group)))
10011 (when (or no-questions
10013 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
10014 ;; If we have several article buffers, we kill them at exit.
10015 (unless gnus-single-article-buffer
10016 (gnus-kill-buffer gnus-article-buffer)
10017 (gnus-kill-buffer gnus-original-article-buffer)
10018 (setq gnus-article-current nil))
10019 (if (not gnus-kill-summary-on-exit)
10020 (gnus-deaden-summary)
10021 (gnus-close-group group)
10022 (gnus-summary-clear-local-variables)
10023 (set-buffer gnus-group-buffer)
10024 (gnus-summary-clear-local-variables)
10025 (when (get-buffer gnus-summary-buffer)
10026 (kill-buffer gnus-summary-buffer)))
10027 (unless gnus-single-article-buffer
10028 (setq gnus-article-current nil))
10029 (when gnus-use-trees
10030 (gnus-tree-close group))
10031 (when (get-buffer gnus-article-buffer)
10032 (bury-buffer gnus-article-buffer))
10033 ;; Return to the group buffer.
10034 (gnus-configure-windows 'group 'force)
10035 ;; Clear the current group name.
10036 (setq gnus-newsgroup-name nil)
10037 (when (equal (gnus-group-group-name) group)
10038 (gnus-group-next-unread-group 1))
10040 (if (not (buffer-name (car quit-config)))
10041 (gnus-configure-windows 'group 'force)
10042 (set-buffer (car quit-config))
10043 (when (eq major-mode 'gnus-summary-mode)
10044 (gnus-set-global-variables))
10045 (gnus-configure-windows (cdr quit-config)))))))
10047 ;;; Dead summaries.
10049 (defvar gnus-dead-summary-mode-map nil)
10051 (if gnus-dead-summary-mode-map
10053 (setq gnus-dead-summary-mode-map (make-keymap))
10054 (suppress-keymap gnus-dead-summary-mode-map)
10055 (substitute-key-definition
10056 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
10057 (let ((keys '("\C-d" "\r" "\177")))
10059 (define-key gnus-dead-summary-mode-map
10060 (pop keys) 'gnus-summary-wake-up-the-dead))))
10062 (defvar gnus-dead-summary-mode nil
10063 "Minor mode for Gnus summary buffers.")
10065 (defun gnus-dead-summary-mode (&optional arg)
10066 "Minor mode for Gnus summary buffers."
10068 (when (eq major-mode 'gnus-summary-mode)
10069 (make-local-variable 'gnus-dead-summary-mode)
10070 (setq gnus-dead-summary-mode
10071 (if (null arg) (not gnus-dead-summary-mode)
10072 (> (prefix-numeric-value arg) 0)))
10073 (when gnus-dead-summary-mode
10074 (unless (assq 'gnus-dead-summary-mode minor-mode-alist)
10075 (push '(gnus-dead-summary-mode " Dead") minor-mode-alist))
10076 (unless (assq 'gnus-dead-summary-mode minor-mode-map-alist)
10077 (push (cons 'gnus-dead-summary-mode gnus-dead-summary-mode-map)
10078 minor-mode-map-alist)))))
10080 (defun gnus-deaden-summary ()
10081 "Make the current summary buffer into a dead summary buffer."
10082 ;; Kill any previous dead summary buffer.
10083 (when (and gnus-dead-summary
10084 (buffer-name gnus-dead-summary))
10086 (set-buffer gnus-dead-summary)
10087 (when gnus-dead-summary-mode
10088 (kill-buffer (current-buffer)))))
10089 ;; Make this the current dead summary.
10090 (setq gnus-dead-summary (current-buffer))
10091 (gnus-dead-summary-mode 1)
10092 (let ((name (buffer-name)))
10093 (when (string-match "Summary" name)
10095 (concat (substring name 0 (match-beginning 0)) "Dead "
10096 (substring name (match-beginning 0))) t))))
10098 (defun gnus-kill-or-deaden-summary (buffer)
10099 "Kill or deaden the summary BUFFER."
10100 (when (and (buffer-name buffer)
10101 (not gnus-single-article-buffer))
10103 (set-buffer buffer)
10104 (gnus-kill-buffer gnus-article-buffer)
10105 (gnus-kill-buffer gnus-original-article-buffer)))
10106 (cond (gnus-kill-summary-on-exit
10107 (when (and gnus-use-trees
10108 (and (get-buffer buffer)
10109 (buffer-name (get-buffer buffer))))
10111 (set-buffer (get-buffer buffer))
10112 (gnus-tree-close gnus-newsgroup-name)))
10113 (gnus-kill-buffer buffer))
10114 ((and (get-buffer buffer)
10115 (buffer-name (get-buffer buffer)))
10117 (set-buffer buffer)
10118 (gnus-deaden-summary)))))
10120 (defun gnus-summary-wake-up-the-dead (&rest args)
10121 "Wake up the dead summary buffer."
10123 (gnus-dead-summary-mode -1)
10124 (let ((name (buffer-name)))
10125 (when (string-match "Dead " name)
10127 (concat (substring name 0 (match-beginning 0))
10128 (substring name (match-end 0))) t)))
10129 (gnus-message 3 "This dead summary is now alive again"))
10131 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
10132 (defun gnus-summary-fetch-faq (&optional faq-dir)
10133 "Fetch the FAQ for the current group.
10134 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
10138 (if current-prefix-arg
10140 "Faq dir: " (and (listp gnus-group-faq-directory)
10141 gnus-group-faq-directory)))))
10142 (let (gnus-faq-buffer)
10143 (and (setq gnus-faq-buffer
10144 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
10145 (gnus-configure-windows 'summary-faq))))
10147 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
10148 (defun gnus-summary-describe-group (&optional force)
10149 "Describe the current newsgroup."
10151 (gnus-group-describe-group force gnus-newsgroup-name))
10153 (defun gnus-summary-describe-briefly ()
10154 "Describe summary mode commands briefly."
10157 (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")))
10159 ;; Walking around group mode buffer from summary mode.
10161 (defun gnus-summary-next-group (&optional no-article target-group backward)
10162 "Exit current newsgroup and then select next unread newsgroup.
10163 If prefix argument NO-ARTICLE is non-nil, no article is selected
10164 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
10165 previous group instead."
10167 (gnus-set-global-variables)
10168 (let ((current-group gnus-newsgroup-name)
10169 (current-buffer (current-buffer))
10171 ;; First we semi-exit this group to update Xrefs and all variables.
10172 ;; We can't do a real exit, because the window conf must remain
10173 ;; the same in case the user is prompted for info, and we don't
10174 ;; want the window conf to change before that...
10175 (gnus-summary-exit t)
10176 (while (not entered)
10177 ;; Then we find what group we are supposed to enter.
10178 (set-buffer gnus-group-buffer)
10179 (gnus-group-jump-to-group current-group)
10182 (if (eq gnus-keep-same-level 'best)
10183 (gnus-summary-best-group gnus-newsgroup-name)
10184 (gnus-summary-search-group backward gnus-keep-same-level))))
10185 (if (not target-group)
10186 ;; There are no further groups, so we return to the group
10189 (gnus-message 5 "Returning to the group buffer")
10191 (set-buffer current-buffer)
10192 (gnus-summary-exit))
10193 ;; We try to enter the target group.
10194 (gnus-group-jump-to-group target-group)
10195 (let ((unreads (gnus-group-group-unread)))
10196 (if (and (or (eq t unreads)
10197 (and unreads (not (zerop unreads))))
10198 (gnus-summary-read-group
10199 target-group nil no-article current-buffer))
10201 (setq current-group target-group
10202 target-group nil)))))))
10204 (defun gnus-summary-prev-group (&optional no-article)
10205 "Exit current newsgroup and then select previous unread newsgroup.
10206 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
10208 (gnus-summary-next-group no-article nil t))
10210 ;; Walking around summary lines.
10212 (defun gnus-summary-first-subject (&optional unread)
10213 "Go to the first unread subject.
10214 If UNREAD is non-nil, go to the first unread article.
10215 Returns the article selected or nil if there are no unread articles."
10220 ((null gnus-newsgroup-data)
10221 (gnus-message 3 "No articles in the group")
10223 ;; Pick the first article.
10225 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
10226 (gnus-data-number (car gnus-newsgroup-data)))
10227 ;; No unread articles.
10228 ((null gnus-newsgroup-unreads)
10229 (gnus-message 3 "No more unread articles")
10231 ;; Find the first unread article.
10233 (let ((data gnus-newsgroup-data))
10235 (not (gnus-data-unread-p (car data))))
10236 (setq data (cdr data)))
10239 (goto-char (gnus-data-pos (car data)))
10240 (gnus-data-number (car data)))))))
10241 (gnus-summary-position-point)))
10243 (defun gnus-summary-next-subject (n &optional unread dont-display)
10244 "Go to next N'th summary line.
10245 If N is negative, go to the previous N'th subject line.
10246 If UNREAD is non-nil, only unread articles are selected.
10247 The difference between N and the actual number of steps taken is
10250 (let ((backward (< n 0))
10252 (while (and (> n 0)
10254 (gnus-summary-find-prev unread)
10255 (gnus-summary-find-next unread)))
10257 (if (/= 0 n) (gnus-message 7 "No more%s articles"
10258 (if unread " unread" "")))
10259 (unless dont-display
10260 (gnus-summary-recenter)
10261 (gnus-summary-position-point))
10264 (defun gnus-summary-next-unread-subject (n)
10265 "Go to next N'th unread summary line."
10267 (gnus-summary-next-subject n t))
10269 (defun gnus-summary-prev-subject (n &optional unread)
10270 "Go to previous N'th summary line.
10271 If optional argument UNREAD is non-nil, only unread article is selected."
10273 (gnus-summary-next-subject (- n) unread))
10275 (defun gnus-summary-prev-unread-subject (n)
10276 "Go to previous N'th unread summary line."
10278 (gnus-summary-next-subject (- n) t))
10280 (defun gnus-summary-goto-subject (article &optional force silent)
10281 "Go the subject line of ARTICLE.
10282 If FORCE, also allow jumping to articles not currently shown."
10284 (data (gnus-data-find article)))
10285 ;; We read in the article if we have to.
10288 (gnus-summary-insert-subject article (and (vectorp force) force) t)
10289 (setq data (gnus-data-find article)))
10294 (gnus-message 3 "Can't find article %d" article))
10296 (goto-char (gnus-data-pos data))
10299 ;; Walking around summary lines with displaying articles.
10301 (defun gnus-summary-expand-window (&optional arg)
10302 "Make the summary buffer take up the entire Emacs frame.
10303 Given a prefix, will force an `article' buffer configuration."
10305 (gnus-set-global-variables)
10307 (gnus-configure-windows 'article 'force)
10308 (gnus-configure-windows 'summary 'force)))
10310 (defun gnus-summary-display-article (article &optional all-header)
10311 "Display ARTICLE in article buffer."
10312 (gnus-set-global-variables)
10316 (if gnus-summary-display-article-function
10317 (funcall gnus-summary-display-article-function article all-header)
10318 (gnus-article-prepare article all-header))
10319 (run-hooks 'gnus-select-article-hook)
10320 (unless (zerop gnus-current-article)
10321 (gnus-summary-goto-subject gnus-current-article))
10322 (gnus-summary-recenter)
10323 (when gnus-use-trees
10324 (gnus-possibly-generate-tree article)
10325 (gnus-highlight-selected-tree article))
10326 ;; Successfully display article.
10327 (gnus-article-set-window-start
10328 (cdr (assq article gnus-newsgroup-bookmarks))))))
10330 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
10331 "Select the current article.
10332 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
10333 non-nil, the article will be re-fetched even if it already present in
10334 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
10336 ;; Make sure we are in the summary buffer to work around bbdb bug.
10337 (unless (eq major-mode 'gnus-summary-mode)
10338 (set-buffer gnus-summary-buffer))
10339 (let ((article (or article (gnus-summary-article-number)))
10340 (all-headers (not (not all-headers))) ;Must be T or NIL.
10341 gnus-summary-display-article-function
10344 (gnus-summary-article-pseudo-p article)
10345 (error "This is a pseudo-article."))
10348 (set-buffer gnus-summary-buffer)
10349 (if (or (and gnus-single-article-buffer
10350 (or (null gnus-current-article)
10351 (null gnus-article-current)
10352 (null (get-buffer gnus-article-buffer))
10353 (not (eq article (cdr gnus-article-current)))
10354 (not (equal (car gnus-article-current)
10355 gnus-newsgroup-name))))
10356 (and (not gnus-single-article-buffer)
10357 (or (null gnus-current-article)
10358 (not (eq gnus-current-article article))))
10360 ;; The requested article is different from the current article.
10362 (gnus-summary-display-article article all-headers)
10363 (setq did article))
10364 (if (or all-headers gnus-show-all-headers)
10365 (gnus-article-show-all-headers))
10368 (gnus-article-set-window-start
10369 (cdr (assq article gnus-newsgroup-bookmarks)))))))
10371 (defun gnus-summary-set-current-mark (&optional current-mark)
10372 "Obsolete function."
10375 (defun gnus-summary-next-article (&optional unread subject backward push)
10376 "Select the next article.
10377 If UNREAD, only unread articles are selected.
10378 If SUBJECT, only articles with SUBJECT are selected.
10379 If BACKWARD, the previous article is selected instead of the next."
10381 (gnus-set-global-variables)
10383 ;; Is there such an article?
10384 ((and (gnus-summary-search-forward unread subject backward)
10385 (or (gnus-summary-display-article (gnus-summary-article-number))
10386 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
10387 (gnus-summary-position-point))
10388 ;; If not, we try the first unread, if that is wanted.
10390 gnus-auto-select-same
10391 (or (gnus-summary-first-unread-article)
10392 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
10393 (gnus-summary-position-point)
10394 (gnus-message 6 "Wrapped"))
10395 ;; Try to get next/previous article not displayed in this group.
10396 ((and gnus-auto-extend-newsgroup
10397 (not unread) (not subject))
10398 (gnus-summary-goto-article
10399 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
10401 ;; Go to next/previous group.
10403 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
10404 (gnus-summary-jump-to-group gnus-newsgroup-name))
10405 (let ((cmd last-command-char)
10407 (if (eq gnus-keep-same-level 'best)
10408 (gnus-summary-best-group gnus-newsgroup-name)
10409 (gnus-summary-search-group backward gnus-keep-same-level))))
10410 ;; For some reason, the group window gets selected. We change
10412 (select-window (get-buffer-window (current-buffer)))
10413 ;; Select next unread newsgroup automagically.
10415 ((or (not gnus-auto-select-next)
10417 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
10418 ((or (eq gnus-auto-select-next 'quietly)
10419 (and (eq gnus-auto-select-next 'slightly-quietly)
10421 (and (eq gnus-auto-select-next 'almost-quietly)
10422 (gnus-summary-last-article-p)))
10424 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
10425 (gnus-summary-exit)
10426 (gnus-message 7 "No more%s articles (%s)..."
10427 (if unread " unread" "")
10428 (if group (concat "selecting " group)
10430 (gnus-summary-next-group nil group backward)))
10432 (gnus-summary-walk-group-buffer
10433 gnus-newsgroup-name cmd unread backward)))))))
10435 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward)
10436 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
10437 (?\C-p (gnus-group-prev-unread-group 1))))
10438 keve key group ended)
10440 (set-buffer gnus-group-buffer)
10441 (gnus-summary-jump-to-group from-group)
10443 (if (eq gnus-keep-same-level 'best)
10444 (gnus-summary-best-group gnus-newsgroup-name)
10445 (gnus-summary-search-group backward gnus-keep-same-level))))
10448 5 "No more%s articles%s" (if unread " unread" "")
10450 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
10451 (format " (Type %s for %s [%s])"
10452 (single-key-description cmd) group
10453 (car (gnus-gethash group gnus-newsrc-hashtb)))
10454 (format " (Type %s to exit %s)"
10455 (single-key-description cmd)
10456 gnus-newsgroup-name)))
10457 ;; Confirm auto selection.
10458 (setq key (car (setq keve (gnus-read-event-char))))
10461 ((assq key keystrokes)
10462 (let ((obuf (current-buffer)))
10463 (switch-to-buffer gnus-group-buffer)
10465 (gnus-group-jump-to-group group))
10466 (eval (cadr (assq key keystrokes)))
10467 (setq group (gnus-group-group-name))
10468 (switch-to-buffer obuf))
10471 (if (or (not group)
10472 (gnus-ephemeral-group-p gnus-newsgroup-name))
10473 (gnus-summary-exit)
10474 (gnus-summary-next-group nil group backward)))
10476 (push (cdr keve) unread-command-events))))))
10478 (defun gnus-read-event-char ()
10479 "Get the next event."
10480 (let ((event (read-event)))
10481 (cons (and (numberp event) event) event)))
10483 (defun gnus-summary-next-unread-article ()
10484 "Select unread article after current one."
10486 (gnus-summary-next-article t (and gnus-auto-select-same
10487 (gnus-summary-article-subject))))
10489 (defun gnus-summary-prev-article (&optional unread subject)
10490 "Select the article after the current one.
10491 If UNREAD is non-nil, only unread articles are selected."
10493 (gnus-summary-next-article unread subject t))
10495 (defun gnus-summary-prev-unread-article ()
10496 "Select unred article before current one."
10498 (gnus-summary-prev-article t (and gnus-auto-select-same
10499 (gnus-summary-article-subject))))
10501 (defun gnus-summary-next-page (&optional lines circular)
10502 "Show next page of the selected article.
10503 If at the end of the current article, select the next article.
10504 LINES says how many lines should be scrolled up.
10506 If CIRCULAR is non-nil, go to the start of the article instead of
10507 selecting the next article when reaching the end of the current
10510 (setq gnus-summary-buffer (current-buffer))
10511 (gnus-set-global-variables)
10512 (let ((article (gnus-summary-article-number))
10514 (gnus-configure-windows 'article)
10515 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
10516 (if (and (eq gnus-summary-goto-unread 'never)
10517 (not (gnus-summary-last-article-p article)))
10518 (gnus-summary-next-article)
10519 (gnus-summary-next-unread-article))
10520 (if (or (null gnus-current-article)
10521 (null gnus-article-current)
10522 (/= article (cdr gnus-article-current))
10523 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10524 ;; Selected subject is different from current article's.
10525 (gnus-summary-display-article article)
10526 (gnus-eval-in-buffer-window gnus-article-buffer
10527 (setq endp (gnus-article-next-page lines)))
10530 (gnus-summary-beginning-of-article))
10532 (gnus-message 3 "End of message"))
10534 (if (and (eq gnus-summary-goto-unread 'never)
10535 (not (gnus-summary-last-article-p article)))
10536 (gnus-summary-next-article)
10537 (gnus-summary-next-unread-article)))))))
10538 (gnus-summary-recenter)
10539 (gnus-summary-position-point)))
10541 (defun gnus-summary-prev-page (&optional lines)
10542 "Show previous page of selected article.
10543 Argument LINES specifies lines to be scrolled down."
10545 (gnus-set-global-variables)
10546 (let ((article (gnus-summary-article-number)))
10547 (gnus-configure-windows 'article)
10548 (if (or (null gnus-current-article)
10549 (null gnus-article-current)
10550 (/= article (cdr gnus-article-current))
10551 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10552 ;; Selected subject is different from current article's.
10553 (gnus-summary-display-article article)
10554 (gnus-summary-recenter)
10555 (gnus-eval-in-buffer-window gnus-article-buffer
10556 (gnus-article-prev-page lines))))
10557 (gnus-summary-position-point))
10559 (defun gnus-summary-scroll-up (lines)
10560 "Scroll up (or down) one line current article.
10561 Argument LINES specifies lines to be scrolled up (or down if negative)."
10563 (gnus-set-global-variables)
10564 (gnus-configure-windows 'article)
10565 (gnus-summary-show-thread)
10566 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
10567 (gnus-eval-in-buffer-window gnus-article-buffer
10569 (if (gnus-article-next-page lines)
10570 (gnus-message 3 "End of message")))
10572 (gnus-article-prev-page (- lines))))))
10573 (gnus-summary-recenter)
10574 (gnus-summary-position-point))
10576 (defun gnus-summary-next-same-subject ()
10577 "Select next article which has the same subject as current one."
10579 (gnus-set-global-variables)
10580 (gnus-summary-next-article nil (gnus-summary-article-subject)))
10582 (defun gnus-summary-prev-same-subject ()
10583 "Select previous article which has the same subject as current one."
10585 (gnus-set-global-variables)
10586 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
10588 (defun gnus-summary-next-unread-same-subject ()
10589 "Select next unread article which has the same subject as current one."
10591 (gnus-set-global-variables)
10592 (gnus-summary-next-article t (gnus-summary-article-subject)))
10594 (defun gnus-summary-prev-unread-same-subject ()
10595 "Select previous unread article which has the same subject as current one."
10597 (gnus-set-global-variables)
10598 (gnus-summary-prev-article t (gnus-summary-article-subject)))
10600 (defun gnus-summary-first-unread-article ()
10601 "Select the first unread article.
10602 Return nil if there are no unread articles."
10604 (gnus-set-global-variables)
10606 (if (gnus-summary-first-subject t)
10608 (gnus-summary-show-thread)
10609 (gnus-summary-first-subject t)
10610 (gnus-summary-display-article (gnus-summary-article-number))))
10611 (gnus-summary-position-point)))
10613 (defun gnus-summary-best-unread-article ()
10614 "Select the unread article with the highest score."
10616 (gnus-set-global-variables)
10617 (let ((best -1000000)
10618 (data gnus-newsgroup-data)
10621 (and (gnus-data-unread-p (car data))
10623 (gnus-summary-article-score (gnus-data-number (car data))))
10626 article (gnus-data-number (car data))))
10627 (setq data (cdr data)))
10630 (gnus-summary-goto-article article)
10631 (error "No unread articles"))
10632 (gnus-summary-position-point))))
10634 (defun gnus-summary-last-subject ()
10635 "Go to the last displayed subject line in the group."
10636 (let ((article (gnus-data-number (car (gnus-data-list t)))))
10638 (gnus-summary-goto-subject article))))
10640 (defun gnus-summary-goto-article (article &optional all-headers force)
10641 "Fetch ARTICLE and display it if it exists.
10642 If ALL-HEADERS is non-nil, no header lines are hidden."
10648 (mapcar (lambda (number) (list (int-to-string number)))
10649 gnus-newsgroup-limit)))
10653 (if (gnus-summary-goto-subject article force)
10654 (gnus-summary-display-article article all-headers)
10655 (gnus-message 4 "Couldn't go to article %s" article) nil)
10656 (gnus-summary-position-point)))
10658 (defun gnus-summary-goto-last-article ()
10659 "Go to the previously read article."
10662 (and gnus-last-article
10663 (gnus-summary-goto-article gnus-last-article))
10664 (gnus-summary-position-point)))
10666 (defun gnus-summary-pop-article (number)
10667 "Pop one article off the history and go to the previous.
10668 NUMBER articles will be popped off."
10671 (setq gnus-newsgroup-history
10672 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
10674 (gnus-summary-goto-article (car to))
10675 (error "Article history empty")))
10676 (gnus-summary-position-point))
10678 ;; Summary commands and functions for limiting the summary buffer.
10680 (defun gnus-summary-limit-to-articles (n)
10681 "Limit the summary buffer to the next N articles.
10682 If not given a prefix, use the process marked articles instead."
10684 (gnus-set-global-variables)
10686 (let ((articles (gnus-summary-work-articles n)))
10687 (setq gnus-newsgroup-processable nil)
10688 (gnus-summary-limit articles))
10689 (gnus-summary-position-point)))
10691 (defun gnus-summary-pop-limit (&optional total)
10692 "Restore the previous limit.
10693 If given a prefix, remove all limits."
10695 (gnus-set-global-variables)
10697 (setq gnus-newsgroup-limits
10698 (list (mapcar (lambda (h) (mail-header-number h))
10699 gnus-newsgroup-headers))))
10700 (unless gnus-newsgroup-limits
10701 (error "No limit to pop"))
10703 (gnus-summary-limit nil 'pop)
10704 (gnus-summary-position-point)))
10706 (defun gnus-summary-limit-to-subject (subject &optional header)
10707 "Limit the summary buffer to articles that have subjects that match a regexp."
10708 (interactive "sRegexp: ")
10710 (setq header "subject"))
10711 (when (not (equal "" subject))
10713 (let ((articles (gnus-summary-find-matching
10714 (or header "subject") subject 'all)))
10715 (or articles (error "Found no matches for \"%s\"" subject))
10716 (gnus-summary-limit articles))
10717 (gnus-summary-position-point))))
10719 (defun gnus-summary-limit-to-author (from)
10720 "Limit the summary buffer to articles that have authors that match a regexp."
10721 (interactive "sRegexp: ")
10722 (gnus-summary-limit-to-subject from "from"))
10724 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10726 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10728 (defun gnus-summary-limit-to-unread (&optional all)
10729 "Limit the summary buffer to articles that are not marked as read.
10730 If ALL is non-nil, limit strictly to unread articles."
10733 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
10734 (gnus-summary-limit-to-marks
10735 ;; Concat all the marks that say that an article is read and have
10737 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
10738 gnus-killed-mark gnus-kill-file-mark
10739 gnus-low-score-mark gnus-expirable-mark
10740 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark)
10743 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10744 (make-obsolete 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10746 (defun gnus-summary-limit-to-marks (marks &optional reverse)
10747 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
10748 If REVERSE, limit the summary buffer to articles that are not marked
10749 with MARKS. MARKS can either be a string of marks or a list of marks.
10750 Returns how many articles were removed."
10751 (interactive "sMarks: ")
10752 (gnus-set-global-variables)
10754 (let ((data gnus-newsgroup-data)
10755 (marks (if (listp marks) marks
10756 (append marks nil))) ; Transform to list.
10759 (and (if reverse (not (memq (gnus-data-mark (car data)) marks))
10760 (memq (gnus-data-mark (car data)) marks))
10761 (setq articles (cons (gnus-data-number (car data)) articles)))
10762 (setq data (cdr data)))
10763 (gnus-summary-limit articles))
10764 (gnus-summary-position-point)))
10766 (defun gnus-summary-limit-to-score (&optional score)
10767 "Limit to articles with score at or above SCORE."
10769 (gnus-set-global-variables)
10770 (setq score (if score
10771 (prefix-numeric-value score)
10772 (or gnus-summary-default-score 0)))
10773 (let ((data gnus-newsgroup-data)
10776 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
10778 (push (gnus-data-number (car data)) articles))
10779 (setq data (cdr data)))
10781 (gnus-summary-limit articles)
10782 (gnus-summary-position-point))))
10784 (defun gnus-summary-limit-include-dormant ()
10785 "Display all the hidden articles that are marked as dormant."
10787 (gnus-set-global-variables)
10788 (or gnus-newsgroup-dormant
10789 (error "There are no dormant articles in this group"))
10791 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
10792 (gnus-summary-position-point)))
10794 (defun gnus-summary-limit-exclude-dormant ()
10795 "Hide all dormant articles."
10797 (gnus-set-global-variables)
10799 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
10800 (gnus-summary-position-point)))
10802 (defun gnus-summary-limit-exclude-childless-dormant ()
10803 "Hide all dormant articles that have no children."
10805 (gnus-set-global-variables)
10806 (let ((data (gnus-data-list t))
10807 articles d children)
10808 ;; Find all articles that are either not dormant or have
10810 (while (setq d (pop data))
10811 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
10812 (and (setq children
10813 (gnus-article-children (gnus-data-number d)))
10816 (when (memq (car children) articles)
10821 (push (gnus-data-number d) articles)))
10822 ;; Do the limiting.
10824 (gnus-summary-limit articles)
10825 (gnus-summary-position-point))))
10827 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
10828 "Mark all unread excluded articles as read.
10829 If ALL, mark even excluded ticked and dormants as read."
10831 (let ((articles (gnus-sorted-complement
10833 (mapcar (lambda (h) (mail-header-number h))
10834 gnus-newsgroup-headers)
10836 (sort gnus-newsgroup-limit '<)))
10838 (setq gnus-newsgroup-unreads nil)
10840 (setq gnus-newsgroup-dormant nil
10841 gnus-newsgroup-marked nil
10842 gnus-newsgroup-reads
10844 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
10845 gnus-newsgroup-reads))
10846 (while (setq article (pop articles))
10847 (unless (or (memq article gnus-newsgroup-dormant)
10848 (memq article gnus-newsgroup-marked))
10849 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
10851 (defun gnus-summary-limit (articles &optional pop)
10853 ;; We pop the previous limit off the stack and use that.
10854 (setq articles (car gnus-newsgroup-limits)
10855 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
10856 ;; We use the new limit, so we push the old limit on the stack.
10857 (setq gnus-newsgroup-limits
10858 (cons gnus-newsgroup-limit gnus-newsgroup-limits)))
10860 (setq gnus-newsgroup-limit articles)
10861 (let ((total (length gnus-newsgroup-data))
10862 (data (gnus-data-find-list (gnus-summary-article-number)))
10864 ;; This will do all the work of generating the new summary buffer
10865 ;; according to the new limit.
10866 (gnus-summary-prepare)
10867 ;; Hide any threads, possibly.
10868 (and gnus-show-threads
10869 gnus-thread-hide-subtree
10870 (gnus-summary-hide-all-threads))
10871 ;; Try to return to the article you were at, or one in the
10874 ;; We try to find some article after the current one.
10876 (and (gnus-summary-goto-subject
10877 (gnus-data-number (car data)) nil t)
10880 (setq data (cdr data))))
10882 ;; If there is no data, that means that we were after the last
10883 ;; article. The same goes when we can't find any articles
10884 ;; after the current one.
10886 (goto-char (point-max))
10887 (gnus-summary-find-prev)))
10888 ;; We return how many articles were removed from the summary
10889 ;; buffer as a result of the new limit.
10890 (- total (length gnus-newsgroup-data))))
10892 (defsubst gnus-invisible-cut-children (threads)
10895 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
10900 (defsubst gnus-cut-thread (thread)
10901 "Go forwards in the thread until we find an article that we want to display."
10902 (when (or (eq gnus-fetch-old-headers 'some)
10903 (eq gnus-build-sparse-threads 'some)
10904 (eq gnus-build-sparse-threads 'more))
10905 ;; Deal with old-fetched headers and sparse threads.
10909 (memq (mail-header-number (car thread)) gnus-newsgroup-sparse)
10910 (memq (mail-header-number (car thread)) gnus-newsgroup-ancient))
10911 (or (<= (length (cdr thread)) 1)
10912 (gnus-invisible-cut-children (cdr thread))))
10913 (setq thread (cadr thread))))
10916 (defun gnus-cut-threads (threads)
10917 "Cut off all uninteresting articles from the beginning of threads."
10918 (when (or (eq gnus-fetch-old-headers 'some)
10919 (eq gnus-build-sparse-threads 'some)
10920 (eq gnus-build-sparse-threads 'more))
10921 (let ((th threads))
10923 (setcar th (gnus-cut-thread (car th)))
10924 (setq th (cdr th)))))
10925 ;; Remove nixed out threads.
10926 (delq nil threads))
10928 (defun gnus-summary-initial-limit (&optional show-if-empty)
10929 "Figure out what the initial limit is supposed to be on group entry.
10930 This entails weeding out unwanted dormants, low-scored articles,
10931 fetch-old-headers verbiage, and so on."
10932 ;; Most groups have nothing to remove.
10933 (if (or gnus-inhibit-limiting
10934 (and (null gnus-newsgroup-dormant)
10935 (not (eq gnus-fetch-old-headers 'some))
10936 (null gnus-summary-expunge-below)
10937 (not (eq gnus-build-sparse-threads 'some))
10938 (not (eq gnus-build-sparse-threads 'more))
10939 (null gnus-thread-expunge-below)
10940 (not gnus-use-nocem)))
10942 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10943 (setq gnus-newsgroup-limit nil)
10946 (unless (car (symbol-value node))
10947 ;; These threads have no parents -- they are roots.
10948 (let ((nodes (cdr (symbol-value node)))
10951 (if (and gnus-thread-expunge-below
10952 (< (gnus-thread-total-score (car nodes))
10953 gnus-thread-expunge-below))
10954 (gnus-expunge-thread (pop nodes))
10955 (setq thread (pop nodes))
10956 (gnus-summary-limit-children thread))))))
10957 gnus-newsgroup-dependencies)
10958 ;; If this limitation resulted in an empty group, we might
10959 ;; pop the previous limit and use it instead.
10960 (when (and (not gnus-newsgroup-limit)
10962 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
10963 gnus-newsgroup-limit))
10965 (defun gnus-summary-limit-children (thread)
10966 "Return 1 if this subthread is visible and 0 if it is not."
10967 ;; First we get the number of visible children to this thread. This
10968 ;; is done by recursing down the thread using this function, so this
10969 ;; will really go down to a leaf article first, before slowly
10970 ;; working its way up towards the root.
10974 (apply '+ (mapcar 'gnus-summary-limit-children
10977 (number (mail-header-number (car thread)))
10980 ;; If this article is dormant and has absolutely no visible
10981 ;; children, then this article isn't visible.
10982 (and (memq number gnus-newsgroup-dormant)
10984 ;; If this is "fetch-old-headered" and there is only one
10985 ;; visible child (or less), then we don't want this article.
10986 (and (eq gnus-fetch-old-headers 'some)
10987 (memq number gnus-newsgroup-ancient)
10989 ;; If this is a sparsely inserted article with no children,
10990 ;; we don't want it.
10991 (and (eq gnus-build-sparse-threads 'some)
10992 (memq number gnus-newsgroup-sparse)
10994 ;; If we use expunging, and this article is really
10995 ;; low-scored, then we don't want this article.
10996 (when (and gnus-summary-expunge-below
10998 (or (cdr (assq number gnus-newsgroup-scored))
10999 gnus-summary-default-score))
11000 gnus-summary-expunge-below))
11001 ;; We increase the expunge-tally here, but that has
11002 ;; nothing to do with the limits, really.
11003 (incf gnus-newsgroup-expunged-tally)
11004 ;; We also mark as read here, if that's wanted.
11005 (when (and gnus-summary-mark-below
11006 (< score gnus-summary-mark-below))
11007 (setq gnus-newsgroup-unreads
11008 (delq number gnus-newsgroup-unreads))
11009 (if gnus-newsgroup-auto-expire
11010 (push number gnus-newsgroup-expirable)
11011 (push (cons number gnus-low-score-mark)
11012 gnus-newsgroup-reads)))
11014 (and gnus-use-nocem
11015 (gnus-nocem-unwanted-article-p (mail-header-id (car thread)))))
11016 ;; Nope, invisible article.
11018 ;; Ok, this article is to be visible, so we add it to the limit
11020 (setq gnus-newsgroup-limit (cons number gnus-newsgroup-limit))
11023 (defun gnus-expunge-thread (thread)
11024 "Mark all articles in THREAD as read."
11025 (let* ((number (mail-header-number (car thread))))
11026 (incf gnus-newsgroup-expunged-tally)
11027 ;; We also mark as read here, if that's wanted.
11028 (setq gnus-newsgroup-unreads
11029 (delq number gnus-newsgroup-unreads))
11030 (if gnus-newsgroup-auto-expire
11031 (push number gnus-newsgroup-expirable)
11032 (push (cons number gnus-low-score-mark)
11033 gnus-newsgroup-reads)))
11034 ;; Go recursively through all subthreads.
11035 (mapcar 'gnus-expunge-thread (cdr thread)))
11037 ;; Summary article oriented commands
11039 (defun gnus-summary-refer-parent-article (n)
11040 "Refer parent article N times.
11041 The difference between N and the number of articles fetched is returned."
11043 (gnus-set-global-variables)
11047 (let* ((header (gnus-summary-article-header))
11049 ;; If we try to find the parent of the currently
11050 ;; displayed article, then we take a look at the actual
11051 ;; References header, since this is slightly more
11052 ;; reliable than the References field we got from the
11054 (if (and (eq (mail-header-number header)
11055 (cdr gnus-article-current))
11056 (equal gnus-newsgroup-name
11057 (car gnus-article-current)))
11059 (set-buffer gnus-original-article-buffer)
11060 (nnheader-narrow-to-headers)
11062 (message-fetch-field "references")
11064 ;; It's not the current article, so we take a bet on
11065 ;; the value we got from the server.
11066 (mail-header-references header))))
11067 (if (setq ref (or ref (mail-header-references header)))
11068 (or (gnus-summary-refer-article (gnus-parent-id ref))
11069 (gnus-message 1 "Couldn't find parent"))
11070 (gnus-message 1 "No references in article %d"
11071 (gnus-summary-article-number))
11074 (gnus-summary-position-point)
11077 (defun gnus-summary-refer-references ()
11078 "Fetch all articles mentioned in the References header.
11079 Return how many articles were fetched."
11081 (gnus-set-global-variables)
11082 (let ((ref (mail-header-references (gnus-summary-article-header)))
11083 (current (gnus-summary-article-number))
11085 ;; For each Message-ID in the References header...
11086 (while (string-match "<[^>]*>" ref)
11088 ;; ... fetch that article.
11089 (gnus-summary-refer-article
11090 (prog1 (match-string 0 ref)
11091 (setq ref (substring ref (match-end 0))))))
11092 (gnus-summary-goto-subject current)
11093 (gnus-summary-position-point)
11096 (defun gnus-summary-refer-article (message-id)
11097 "Fetch an article specified by MESSAGE-ID."
11098 (interactive "sMessage-ID: ")
11099 (when (and (stringp message-id)
11100 (not (zerop (length message-id))))
11101 ;; Construct the correct Message-ID if necessary.
11102 ;; Suggested by tale@pawl.rpi.edu.
11103 (unless (string-match "^<" message-id)
11104 (setq message-id (concat "<" message-id)))
11105 (unless (string-match ">$" message-id)
11106 (setq message-id (concat message-id ">")))
11107 (let* ((header (gnus-id-to-header message-id))
11108 (sparse (and header
11109 (memq (mail-header-number header)
11110 gnus-newsgroup-sparse))))
11113 ;; The article is present in the buffer, to we just go to it.
11114 (gnus-summary-goto-article
11115 (mail-header-number header) nil header)
11117 (gnus-summary-update-article (mail-header-number header))))
11118 ;; We fetch the article
11119 (let ((gnus-override-method
11120 (and (gnus-news-group-p gnus-newsgroup-name)
11121 gnus-refer-article-method))
11123 ;; Start the special refer-article method, if necessary.
11124 (when (and gnus-refer-article-method
11125 (gnus-news-group-p gnus-newsgroup-name))
11126 (gnus-check-server gnus-refer-article-method))
11127 ;; Fetch the header, and display the article.
11128 (if (setq number (gnus-summary-insert-subject message-id))
11129 (gnus-summary-select-article nil nil nil number)
11130 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
11132 (defun gnus-summary-enter-digest-group (&optional force)
11133 "Enter a digest group based on the current article."
11135 (gnus-set-global-variables)
11136 (gnus-summary-select-article)
11137 (let ((name (format "%s-%d"
11138 (gnus-group-prefixed-name
11139 gnus-newsgroup-name (list 'nndoc ""))
11140 gnus-current-article))
11141 (ogroup gnus-newsgroup-name)
11142 (case-fold-search t)
11143 (buf (current-buffer))
11146 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
11147 (insert-buffer-substring gnus-original-article-buffer)
11149 (goto-char (point-min))
11150 (or (search-forward "\n\n" nil t) (point)))
11151 (goto-char (point-min))
11152 (delete-matching-lines "^\\(Path\\):\\|^From ")
11155 (if (gnus-group-read-ephemeral-group
11156 name `(nndoc ,name (nndoc-address
11158 (nndoc-article-type ,(if force 'digest 'guess))) t)
11159 ;; Make all postings to this group go to the parent group.
11160 (nconc (gnus-info-params (gnus-get-info name))
11161 (list (cons 'to-group ogroup)))
11162 ;; Couldn't select this doc group.
11163 (switch-to-buffer buf)
11164 (gnus-set-global-variables)
11165 (gnus-configure-windows 'summary)
11166 (gnus-message 3 "Article couldn't be entered?"))
11167 (kill-buffer dig))))
11169 (defun gnus-summary-isearch-article (&optional regexp-p)
11170 "Do incremental search forward on the current article.
11171 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
11173 (gnus-set-global-variables)
11174 (gnus-summary-select-article)
11175 (gnus-configure-windows 'article)
11176 (gnus-eval-in-buffer-window gnus-article-buffer
11177 (goto-char (point-min))
11178 (isearch-forward regexp-p)))
11180 (defun gnus-summary-search-article-forward (regexp &optional backward)
11181 "Search for an article containing REGEXP forward.
11182 If BACKWARD, search backward instead."
11185 (format "Search article %s (regexp%s): "
11186 (if current-prefix-arg "backward" "forward")
11187 (if gnus-last-search-regexp
11188 (concat ", default " gnus-last-search-regexp)
11190 current-prefix-arg))
11191 (gnus-set-global-variables)
11192 (if (string-equal regexp "")
11193 (setq regexp (or gnus-last-search-regexp ""))
11194 (setq gnus-last-search-regexp regexp))
11195 (unless (gnus-summary-search-article regexp backward)
11196 (error "Search failed: \"%s\"" regexp)))
11198 (defun gnus-summary-search-article-backward (regexp)
11199 "Search for an article containing REGEXP backward."
11202 (format "Search article backward (regexp%s): "
11203 (if gnus-last-search-regexp
11204 (concat ", default " gnus-last-search-regexp)
11206 (gnus-summary-search-article-forward regexp 'backward))
11208 (defun gnus-summary-search-article (regexp &optional backward)
11209 "Search for an article containing REGEXP.
11210 Optional argument BACKWARD means do search for backward.
11211 `gnus-select-article-hook' is not called during the search."
11212 (let ((gnus-select-article-hook nil) ;Disable hook.
11213 (gnus-article-display-hook nil)
11214 (gnus-mark-article-hook nil) ;Inhibit marking as read.
11217 're-search-backward 're-search-forward))
11218 (sum (current-buffer))
11220 (gnus-save-hidden-threads
11221 (gnus-summary-select-article)
11222 (set-buffer gnus-article-buffer)
11226 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
11228 (re-search-backward regexp nil t)
11229 (re-search-forward regexp nil t))
11230 ;; We found the regexp.
11232 (setq found 'found)
11233 (beginning-of-line)
11235 (get-buffer-window (current-buffer))
11239 ;; We didn't find it, so we go to the next article.
11241 (if (not (if backward (gnus-summary-find-prev)
11242 (gnus-summary-find-next)))
11243 ;; No more articles.
11245 ;; Select the next article and adjust point.
11246 (gnus-summary-select-article)
11247 (set-buffer gnus-article-buffer)
11249 (goto-char (if backward (point-max) (point-min))))))
11250 (gnus-message 7 ""))
11251 ;; Return whether we found the regexp.
11252 (when (eq found 'found)
11253 (gnus-summary-show-thread)
11254 (gnus-summary-goto-subject gnus-current-article)
11255 (gnus-summary-position-point)
11258 (defun gnus-summary-find-matching (header regexp &optional backward unread
11260 "Return a list of all articles that match REGEXP on HEADER.
11261 The search stars on the current article and goes forwards unless
11262 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
11263 If UNREAD is non-nil, only unread articles will
11264 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
11265 in the comparisons."
11266 (let ((data (if (eq backward 'all) gnus-newsgroup-data
11267 (gnus-data-find-list
11268 (gnus-summary-article-number) (gnus-data-list backward))))
11269 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
11270 (case-fold-search (not not-case-fold))
11272 (or (fboundp (intern (concat "mail-header-" header)))
11273 (error "%s is not a valid header" header))
11275 (setq d (car data))
11276 (and (or (not unread) ; We want all articles...
11277 (gnus-data-unread-p d)) ; Or just unreads.
11278 (vectorp (gnus-data-header d)) ; It's not a pseudo.
11279 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
11280 (setq articles (cons (gnus-data-number d) articles))) ; Success!
11281 (setq data (cdr data)))
11282 (nreverse articles)))
11284 (defun gnus-summary-execute-command (header regexp command &optional backward)
11285 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
11286 If HEADER is an empty string (or nil), the match is done on the entire
11287 article. If BACKWARD (the prefix) is non-nil, search backward instead."
11289 (list (let ((completion-ignore-case t))
11292 (mapcar (lambda (string) (list string))
11293 '("Number" "Subject" "From" "Lines" "Date"
11294 "Message-ID" "Xref" "References" "Body"))
11295 nil 'require-match))
11296 (read-string "Regexp: ")
11297 (read-key-sequence "Command: ")
11298 current-prefix-arg))
11299 (when (equal header "Body")
11301 (gnus-set-global-variables)
11302 ;; Hidden thread subtrees must be searched as well.
11303 (gnus-summary-show-all-threads)
11304 ;; We don't want to change current point nor window configuration.
11306 (save-window-excursion
11307 (gnus-message 6 "Executing %s..." (key-description command))
11308 ;; We'd like to execute COMMAND interactively so as to give arguments.
11309 (gnus-execute header regexp
11310 `(lambda () (call-interactively ',(key-binding command)))
11312 (gnus-message 6 "Executing %s...done" (key-description command)))))
11314 (defun gnus-summary-beginning-of-article ()
11315 "Scroll the article back to the beginning."
11317 (gnus-set-global-variables)
11318 (gnus-summary-select-article)
11319 (gnus-configure-windows 'article)
11320 (gnus-eval-in-buffer-window gnus-article-buffer
11322 (goto-char (point-min))
11323 (and gnus-break-pages (gnus-narrow-to-page))))
11325 (defun gnus-summary-end-of-article ()
11326 "Scroll to the end of the article."
11328 (gnus-set-global-variables)
11329 (gnus-summary-select-article)
11330 (gnus-configure-windows 'article)
11331 (gnus-eval-in-buffer-window gnus-article-buffer
11333 (goto-char (point-max))
11335 (and gnus-break-pages (gnus-narrow-to-page))))
11337 (defun gnus-summary-show-article (&optional arg)
11338 "Force re-fetching of the current article.
11339 If ARG (the prefix) is non-nil, show the raw article without any
11340 article massaging functions being run."
11342 (gnus-set-global-variables)
11344 ;; Select the article the normal way.
11345 (gnus-summary-select-article nil 'force)
11346 ;; Bind the article treatment functions to nil.
11347 (let ((gnus-have-all-headers t)
11348 gnus-article-display-hook
11349 gnus-article-prepare-hook
11352 (gnus-summary-select-article nil 'force)))
11353 (gnus-summary-goto-subject gnus-current-article)
11354 ; (gnus-configure-windows 'article)
11355 (gnus-summary-position-point))
11357 (defun gnus-summary-verbose-headers (&optional arg)
11358 "Toggle permanent full header display.
11359 If ARG is a positive number, turn header display on.
11360 If ARG is a negative number, turn header display off."
11362 (gnus-set-global-variables)
11363 (gnus-summary-toggle-header arg)
11364 (setq gnus-show-all-headers
11365 (cond ((or (not (numberp arg))
11367 (not gnus-show-all-headers))
11371 (defun gnus-summary-toggle-header (&optional arg)
11372 "Show the headers if they are hidden, or hide them if they are shown.
11373 If ARG is a positive number, show the entire header.
11374 If ARG is a negative number, hide the unwanted header lines."
11376 (gnus-set-global-variables)
11378 (set-buffer gnus-article-buffer)
11379 (let* ((buffer-read-only nil)
11380 (inhibit-point-motion-hooks t)
11381 (hidden (text-property-any
11382 (goto-char (point-min)) (search-forward "\n\n")
11385 (goto-char (point-min))
11386 (when (search-forward "\n\n" nil t)
11387 (delete-region (point-min) (1- (point))))
11388 (goto-char (point-min))
11390 (set-buffer gnus-original-article-buffer)
11391 (goto-char (point-min))
11392 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
11393 (insert-buffer-substring gnus-original-article-buffer 1 e)
11394 (let ((gnus-inhibit-hiding t))
11395 (run-hooks 'gnus-article-display-hook))
11396 (if (or (not hidden) (and (numberp arg) (< arg 0)))
11397 (gnus-article-hide-headers)))))
11399 (defun gnus-summary-show-all-headers ()
11400 "Make all header lines visible."
11402 (gnus-set-global-variables)
11403 (gnus-article-show-all-headers))
11405 (defun gnus-summary-toggle-mime (&optional arg)
11406 "Toggle MIME processing.
11407 If ARG is a positive number, turn MIME processing on."
11409 (gnus-set-global-variables)
11410 (setq gnus-show-mime
11411 (if (null arg) (not gnus-show-mime)
11412 (> (prefix-numeric-value arg) 0)))
11413 (gnus-summary-select-article t 'force))
11415 (defun gnus-summary-caesar-message (&optional arg)
11416 "Caesar rotate the current article by 13.
11417 The numerical prefix specifies how manu places to rotate each letter
11420 (gnus-set-global-variables)
11421 (gnus-summary-select-article)
11422 (let ((mail-header-separator ""))
11423 (gnus-eval-in-buffer-window gnus-article-buffer
11426 (let ((start (window-start))
11428 (message-caesar-buffer-body arg)
11429 (set-window-start (get-buffer-window (current-buffer)) start))))))
11431 (defun gnus-summary-stop-page-breaking ()
11432 "Stop page breaking in the current article."
11434 (gnus-set-global-variables)
11435 (gnus-summary-select-article)
11436 (gnus-eval-in-buffer-window gnus-article-buffer
11439 (defun gnus-summary-move-article (&optional n to-newsgroup select-method action)
11440 "Move the current article to a different newsgroup.
11441 If N is a positive number, move the N next articles.
11442 If N is a negative number, move the N previous articles.
11443 If N is nil and any articles have been marked with the process mark,
11444 move those articles instead.
11445 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11446 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
11447 re-spool using this method.
11449 For this function to work, both the current newsgroup and the
11450 newsgroup that you want to move to have to support the `request-move'
11451 and `request-accept' functions."
11453 (unless action (setq action 'move))
11454 (gnus-set-global-variables)
11455 ;; Check whether the source group supports the required functions.
11456 (cond ((and (eq action 'move)
11457 (not (gnus-check-backend-function
11458 'request-move-article gnus-newsgroup-name)))
11459 (error "The current group does not support article moving"))
11460 ((and (eq action 'crosspost)
11461 (not (gnus-check-backend-function
11462 'request-replace-article gnus-newsgroup-name)))
11463 (error "The current group does not support article editing")))
11464 (let ((articles (gnus-summary-work-articles n))
11465 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
11466 (names '((move "Move" "Moving")
11467 (copy "Copy" "Copying")
11468 (crosspost "Crosspost" "Crossposting")))
11469 (copy-buf (save-excursion
11470 (nnheader-set-temp-buffer " *copy article*")))
11471 art-group to-method new-xref article to-groups)
11472 (unless (assq action names)
11473 (error "Unknown action %s" action))
11474 ;; Read the newsgroup name.
11475 (when (and (not to-newsgroup)
11476 (not select-method))
11478 (gnus-read-move-group-name
11479 (cadr (assq action names))
11480 (symbol-value (intern (format "gnus-current-%s-group" action)))
11482 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
11483 (setq to-method (or select-method
11484 (gnus-find-method-for-group to-newsgroup)))
11485 ;; Check the method we are to move this article to...
11486 (or (gnus-check-backend-function 'request-accept-article (car to-method))
11487 (error "%s does not support article copying" (car to-method)))
11488 (or (gnus-check-server to-method)
11489 (error "Can't open server %s" (car to-method)))
11490 (gnus-message 6 "%s to %s: %s..."
11491 (caddr (assq action names))
11492 (or (car select-method) to-newsgroup) articles)
11494 (setq article (pop articles))
11498 ;; Move the article.
11500 (gnus-request-move-article
11501 article ; Article to move
11502 gnus-newsgroup-name ; From newsgrouo
11503 (nth 1 (gnus-find-method-for-group
11504 gnus-newsgroup-name)) ; Server
11505 (list 'gnus-request-accept-article
11506 to-newsgroup (list 'quote select-method)
11507 (not articles)) ; Accept form
11508 (not articles))) ; Only save nov last time
11509 ;; Copy the article.
11512 (set-buffer copy-buf)
11513 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11514 (gnus-request-accept-article
11515 to-newsgroup select-method (not articles))))
11516 ;; Crosspost the article.
11517 ((eq action 'crosspost)
11518 (let ((xref (mail-header-xref (gnus-summary-article-header article))))
11519 (setq new-xref (concat gnus-newsgroup-name ":" article))
11520 (if (and xref (not (string= xref "")))
11522 (when (string-match "^Xref: " xref)
11523 (setq xref (substring xref (match-end 0))))
11524 (setq new-xref (concat xref " " new-xref)))
11525 (setq new-xref (concat (system-name) " " new-xref)))
11527 (set-buffer copy-buf)
11528 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11529 (nnheader-replace-header "xref" new-xref)
11530 (gnus-request-accept-article
11531 to-newsgroup select-method (not articles)))))))
11532 (if (not art-group)
11533 (gnus-message 1 "Couldn't %s article %s"
11534 (cadr (assq action names)) article)
11537 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
11539 (gnus-group-prefixed-name
11542 (gnus-find-method-for-group to-newsgroup)))
11543 gnus-newsrc-hashtb)))
11544 (info (nth 2 entry))
11545 (to-group (gnus-info-group info)))
11546 ;; Update the group that has been moved to.
11548 (memq action '(move copy)))
11549 (unless (member to-group to-groups)
11550 (push to-group to-groups))
11552 (unless (memq article gnus-newsgroup-unreads)
11553 (gnus-info-set-read
11554 info (gnus-add-to-range (gnus-info-read info)
11555 (list (cdr art-group)))))
11557 ;; Copy any marks over to the new group.
11558 (let ((marks gnus-article-mark-lists)
11559 (to-article (cdr art-group)))
11561 ;; See whether the article is to be put in the cache.
11562 (when gnus-use-cache
11563 (gnus-cache-possibly-enter-article
11564 to-group to-article
11565 (let ((header (copy-sequence
11566 (gnus-summary-article-header article))))
11567 (mail-header-set-number header to-article)
11569 (memq article gnus-newsgroup-marked)
11570 (memq article gnus-newsgroup-dormant)
11571 (memq article gnus-newsgroup-unreads)))
11574 (when (memq article (symbol-value
11575 (intern (format "gnus-newsgroup-%s"
11577 ;; If the other group is the same as this group,
11578 ;; then we have to add the mark to the list.
11579 (when (equal to-group gnus-newsgroup-name)
11580 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
11583 (intern (format "gnus-newsgroup-%s"
11585 ;; Copy mark to other group.
11586 (gnus-add-marked-articles
11587 to-group (cdar marks) (list to-article) info))
11588 (setq marks (cdr marks)))))
11590 ;; Update the Xref header in this article to point to
11591 ;; the new crossposted article we have just created.
11592 (when (eq action 'crosspost)
11594 (set-buffer copy-buf)
11595 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11596 (nnheader-replace-header
11597 "xref" (concat new-xref " " (gnus-group-prefixed-name
11598 (car art-group) to-method)
11599 ":" (cdr art-group)))
11600 (gnus-request-replace-article
11601 article gnus-newsgroup-name (current-buffer)))))
11603 (gnus-summary-goto-subject article)
11604 (when (eq action 'move)
11605 (gnus-summary-mark-article article gnus-canceled-mark)))
11606 (gnus-summary-remove-process-mark article))
11607 ;; Re-activate all groups that have been moved to.
11609 (gnus-activate-group (pop to-groups)))
11611 (gnus-kill-buffer copy-buf)
11612 (gnus-summary-position-point)
11613 (gnus-set-mode-line 'summary)))
11615 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
11616 "Move the current article to a different newsgroup.
11617 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11618 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
11619 re-spool using this method."
11621 (gnus-summary-move-article n nil select-method 'copy))
11623 (defun gnus-summary-crosspost-article (&optional n)
11624 "Crosspost the current article to some other group."
11626 (gnus-summary-move-article n nil nil 'crosspost))
11628 (defvar gnus-summary-respool-default-method nil
11629 "Default method for respooling an article.
11630 If nil, use to the current newsgroup method.")
11632 (defun gnus-summary-respool-article (&optional n method)
11633 "Respool the current article.
11634 The article will be squeezed through the mail spooling process again,
11635 which means that it will be put in some mail newsgroup or other
11636 depending on `nnmail-split-methods'.
11637 If N is a positive number, respool the N next articles.
11638 If N is a negative number, respool the N previous articles.
11639 If N is nil and any articles have been marked with the process mark,
11640 respool those articles instead.
11642 Respooling can be done both from mail groups and \"real\" newsgroups.
11643 In the former case, the articles in question will be moved from the
11644 current group into whatever groups they are destined to. In the
11645 latter case, they will be copied into the relevant groups."
11647 (list current-prefix-arg
11648 (let* ((methods (gnus-methods-using 'respool))
11650 (symbol-name (or gnus-summary-respool-default-method
11651 (car (gnus-find-method-for-group
11652 gnus-newsgroup-name)))))
11654 (gnus-completing-read
11655 methname "What backend do you want to use when? "
11656 methods nil t nil 'gnus-method-history))
11659 ((zerop (length (setq ms (gnus-servers-using-backend method))))
11660 (list (intern method) ""))
11664 (cdr (completing-read
11666 (mapcar (lambda (m) (cons (cadr m) m)) ms) nil t)))))))
11667 (gnus-set-global-variables)
11669 (error "No method given for respooling"))
11670 (if (assoc (symbol-name
11671 (car (gnus-find-method-for-group gnus-newsgroup-name)))
11672 (gnus-methods-using 'respool))
11673 (gnus-summary-move-article n nil method)
11674 (gnus-summary-copy-article n nil method)))
11676 (defun gnus-summary-import-article (file)
11677 "Import a random file into a mail newsgroup."
11678 (interactive "fImport file: ")
11679 (gnus-set-global-variables)
11680 (let ((group gnus-newsgroup-name)
11681 (now (current-time))
11683 (or (gnus-check-backend-function 'request-accept-article group)
11684 (error "%s does not support article importing" group))
11685 (or (file-readable-p file)
11686 (not (file-regular-p file))
11687 (error "Can't read %s" file))
11689 (set-buffer (get-buffer-create " *import file*"))
11690 (buffer-disable-undo (current-buffer))
11692 (insert-file-contents file)
11693 (goto-char (point-min))
11694 (unless (nnheader-article-p)
11695 ;; This doesn't look like an article, so we fudge some headers.
11696 (setq atts (file-attributes file)
11697 lines (count-lines (point-min) (point-max)))
11698 (insert "From: " (read-string "From: ") "\n"
11699 "Subject: " (read-string "Subject: ") "\n"
11700 "Date: " (timezone-make-date-arpa-standard
11701 (current-time-string (nth 5 atts))
11702 (current-time-zone now)
11703 (current-time-zone now)) "\n"
11704 "Message-ID: " (message-make-message-id) "\n"
11705 "Lines: " (int-to-string lines) "\n"
11706 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
11707 (gnus-request-accept-article group nil t)
11708 (kill-buffer (current-buffer)))))
11710 (defun gnus-summary-expire-articles (&optional now)
11711 "Expire all articles that are marked as expirable in the current group."
11713 (gnus-set-global-variables)
11714 (when (gnus-check-backend-function
11715 'request-expire-articles gnus-newsgroup-name)
11716 ;; This backend supports expiry.
11717 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
11718 (expirable (if total
11719 (gnus-list-of-read-articles gnus-newsgroup-name)
11720 (setq gnus-newsgroup-expirable
11721 (sort gnus-newsgroup-expirable '<))))
11722 (expiry-wait (if now 'immediate
11723 (gnus-group-get-parameter
11724 gnus-newsgroup-name 'expiry-wait)))
11727 ;; There are expirable articles in this group, so we run them
11728 ;; through the expiry process.
11729 (gnus-message 6 "Expiring articles...")
11730 ;; The list of articles that weren't expired is returned.
11732 (let ((nnmail-expiry-wait-function nil)
11733 (nnmail-expiry-wait expiry-wait))
11734 (setq es (gnus-request-expire-articles
11735 expirable gnus-newsgroup-name)))
11736 (setq es (gnus-request-expire-articles
11737 expirable gnus-newsgroup-name)))
11738 (or total (setq gnus-newsgroup-expirable es))
11739 ;; We go through the old list of expirable, and mark all
11740 ;; really expired articles as nonexistent.
11741 (unless (eq es expirable) ;If nothing was expired, we don't mark.
11742 (let ((gnus-use-cache nil))
11744 (unless (memq (car expirable) es)
11745 (when (gnus-data-find (car expirable))
11746 (gnus-summary-mark-article
11747 (car expirable) gnus-canceled-mark)))
11748 (setq expirable (cdr expirable)))))
11749 (gnus-message 6 "Expiring articles...done")))))
11751 (defun gnus-summary-expire-articles-now ()
11752 "Expunge all expirable articles in the current group.
11753 This means that *all* articles that are marked as expirable will be
11754 deleted forever, right now."
11756 (gnus-set-global-variables)
11757 (or gnus-expert-user
11759 "Are you really, really, really sure you want to delete all these messages? ")
11761 (gnus-summary-expire-articles t))
11763 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
11764 (defun gnus-summary-delete-article (&optional n)
11765 "Delete the N next (mail) articles.
11766 This command actually deletes articles. This is not a marking
11767 command. The article will disappear forever from your life, never to
11769 If N is negative, delete backwards.
11770 If N is nil and articles have been marked with the process mark,
11771 delete these instead."
11773 (gnus-set-global-variables)
11774 (or (gnus-check-backend-function 'request-expire-articles
11775 gnus-newsgroup-name)
11776 (error "The current newsgroup does not support article deletion."))
11777 ;; Compute the list of articles to delete.
11778 (let ((articles (gnus-summary-work-articles n))
11780 (if (and gnus-novice-user
11781 (not (gnus-y-or-n-p
11782 (format "Do you really want to delete %s forever? "
11783 (if (> (length articles) 1)
11784 (format "these %s articles" (length articles))
11785 "this article")))))
11787 ;; Delete the articles.
11788 (setq not-deleted (gnus-request-expire-articles
11789 articles gnus-newsgroup-name 'force))
11791 (gnus-summary-remove-process-mark (car articles))
11792 ;; The backend might not have been able to delete the article
11794 (or (memq (car articles) not-deleted)
11795 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
11796 (setq articles (cdr articles))))
11797 (gnus-summary-position-point)
11798 (gnus-set-mode-line 'summary)
11801 (defun gnus-summary-edit-article (&optional force)
11802 "Enter into a buffer and edit the current article.
11803 This will have permanent effect only in mail groups.
11804 If FORCE is non-nil, allow editing of articles even in read-only
11808 (set-buffer gnus-summary-buffer)
11809 (gnus-set-global-variables)
11810 (when (and (not force)
11811 (gnus-group-read-only-p))
11812 (error "The current newsgroup does not support article editing."))
11813 (gnus-summary-select-article t nil t)
11814 (gnus-configure-windows 'article)
11815 (select-window (get-buffer-window gnus-article-buffer))
11816 (gnus-message 6 "C-c C-c to end edits")
11817 (setq buffer-read-only nil)
11819 (use-local-map (copy-keymap (current-local-map)))
11820 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
11821 (buffer-enable-undo)
11823 (goto-char (point-min))
11824 (search-forward "\n\n" nil t)))
11826 (defun gnus-summary-edit-article-done ()
11827 "Make edits to the current article permanent."
11829 (if (gnus-group-read-only-p)
11831 (gnus-summary-edit-article-postpone)
11833 1 "The current newsgroup does not support article editing."))
11834 (let ((buf (format "%s" (buffer-string))))
11837 (if (not (gnus-request-replace-article
11838 (cdr gnus-article-current) (car gnus-article-current)
11840 (error "Couldn't replace article.")
11841 (gnus-article-mode)
11842 (use-local-map gnus-article-mode-map)
11843 (setq buffer-read-only t)
11844 (buffer-disable-undo (current-buffer))
11845 (gnus-configure-windows 'summary)
11846 (gnus-summary-update-article (cdr gnus-article-current))
11847 (when gnus-use-cache
11848 (gnus-cache-update-article
11849 (car gnus-article-current) (cdr gnus-article-current)))
11850 (when gnus-keep-backlog
11851 (gnus-backlog-remove-article
11852 (car gnus-article-current) (cdr gnus-article-current))))
11854 (when (get-buffer gnus-original-article-buffer)
11855 (set-buffer gnus-original-article-buffer)
11856 (setq gnus-original-article nil)))
11857 (setq gnus-article-current nil
11858 gnus-current-article nil)
11859 (run-hooks 'gnus-article-display-hook)
11860 (and (gnus-visual-p 'summary-highlight 'highlight)
11861 (run-hooks 'gnus-visual-mark-article-hook)))))
11863 (defun gnus-summary-edit-article-postpone ()
11864 "Postpone changes to the current article."
11866 (gnus-article-mode)
11867 (use-local-map gnus-article-mode-map)
11868 (setq buffer-read-only t)
11869 (buffer-disable-undo (current-buffer))
11870 (gnus-configure-windows 'summary)
11871 (and (gnus-visual-p 'summary-highlight 'highlight)
11872 (run-hooks 'gnus-visual-mark-article-hook)))
11874 (defun gnus-summary-respool-query ()
11875 "Query where the respool algorithm would put this article."
11877 (gnus-set-global-variables)
11878 (gnus-summary-select-article)
11880 (set-buffer gnus-article-buffer)
11882 (goto-char (point-min))
11883 (search-forward "\n\n")
11884 (narrow-to-region (point-min) (point))
11885 (pp-eval-expression
11886 (list 'quote (mapcar 'car (nnmail-article-group 'identity)))))))
11888 ;; Summary marking commands.
11890 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
11891 "Mark articles which has the same subject as read, and then select the next.
11892 If UNMARK is positive, remove any kind of mark.
11893 If UNMARK is negative, tick articles."
11895 (gnus-set-global-variables)
11897 (setq unmark (prefix-numeric-value unmark)))
11899 (gnus-summary-mark-same-subject
11900 (gnus-summary-article-subject) unmark)))
11901 ;; Select next unread article. If auto-select-same mode, should
11902 ;; select the first unread article.
11903 (gnus-summary-next-article t (and gnus-auto-select-same
11904 (gnus-summary-article-subject)))
11905 (gnus-message 7 "%d article%s marked as %s"
11906 count (if (= count 1) " is" "s are")
11907 (if unmark "unread" "read"))))
11909 (defun gnus-summary-kill-same-subject (&optional unmark)
11910 "Mark articles which has the same subject as read.
11911 If UNMARK is positive, remove any kind of mark.
11912 If UNMARK is negative, tick articles."
11914 (gnus-set-global-variables)
11916 (setq unmark (prefix-numeric-value unmark)))
11918 (gnus-summary-mark-same-subject
11919 (gnus-summary-article-subject) unmark)))
11920 ;; If marked as read, go to next unread subject.
11922 ;; Go to next unread subject.
11923 (gnus-summary-next-subject 1 t))
11924 (gnus-message 7 "%d articles are marked as %s"
11925 count (if unmark "unread" "read"))))
11927 (defun gnus-summary-mark-same-subject (subject &optional unmark)
11928 "Mark articles with same SUBJECT as read, and return marked number.
11929 If optional argument UNMARK is positive, remove any kinds of marks.
11930 If optional argument UNMARK is negative, mark articles as unread instead."
11934 ((null unmark) ; Mark as read.
11937 (gnus-summary-mark-article-as-read gnus-killed-mark)
11938 (gnus-summary-show-thread) t)
11939 (gnus-summary-find-subject subject))
11940 (setq count (1+ count))))
11941 ((> unmark 0) ; Tick.
11944 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
11945 (gnus-summary-show-thread) t)
11946 (gnus-summary-find-subject subject))
11947 (setq count (1+ count))))
11948 (t ; Mark as unread.
11951 (gnus-summary-mark-article-as-unread gnus-unread-mark)
11952 (gnus-summary-show-thread) t)
11953 (gnus-summary-find-subject subject))
11954 (setq count (1+ count)))))
11955 (gnus-set-mode-line 'summary)
11956 ;; Return the number of marked articles.
11959 (defun gnus-summary-mark-as-processable (n &optional unmark)
11960 "Set the process mark on the next N articles.
11961 If N is negative, mark backward instead. If UNMARK is non-nil, remove
11962 the process mark instead. The difference between N and the actual
11963 number of articles marked is returned."
11965 (gnus-set-global-variables)
11966 (let ((backward (< n 0))
11971 (gnus-summary-remove-process-mark
11972 (gnus-summary-article-number))
11973 (gnus-summary-set-process-mark (gnus-summary-article-number)))
11974 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
11976 (if (/= 0 n) (gnus-message 7 "No more articles"))
11977 (gnus-summary-recenter)
11978 (gnus-summary-position-point)
11981 (defun gnus-summary-unmark-as-processable (n)
11982 "Remove the process mark from the next N articles.
11983 If N is negative, mark backward instead. The difference between N and
11984 the actual number of articles marked is returned."
11986 (gnus-set-global-variables)
11987 (gnus-summary-mark-as-processable n t))
11989 (defun gnus-summary-unmark-all-processable ()
11990 "Remove the process mark from all articles."
11992 (gnus-set-global-variables)
11994 (while gnus-newsgroup-processable
11995 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
11996 (gnus-summary-position-point))
11998 (defun gnus-summary-mark-as-expirable (n)
11999 "Mark N articles forward as expirable.
12000 If N is negative, mark backward instead. The difference between N and
12001 the actual number of articles marked is returned."
12003 (gnus-set-global-variables)
12004 (gnus-summary-mark-forward n gnus-expirable-mark))
12006 (defun gnus-summary-mark-article-as-replied (article)
12007 "Mark ARTICLE replied and update the summary line."
12008 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
12009 (let ((buffer-read-only nil))
12010 (when (gnus-summary-goto-subject article)
12011 (gnus-summary-update-secondary-mark article))))
12013 (defun gnus-summary-set-bookmark (article)
12014 "Set a bookmark in current article."
12015 (interactive (list (gnus-summary-article-number)))
12016 (gnus-set-global-variables)
12017 (if (or (not (get-buffer gnus-article-buffer))
12018 (not gnus-current-article)
12019 (not gnus-article-current)
12020 (not (equal gnus-newsgroup-name (car gnus-article-current))))
12021 (error "No current article selected"))
12022 ;; Remove old bookmark, if one exists.
12023 (let ((old (assq article gnus-newsgroup-bookmarks)))
12024 (if old (setq gnus-newsgroup-bookmarks
12025 (delq old gnus-newsgroup-bookmarks))))
12026 ;; Set the new bookmark, which is on the form
12027 ;; (article-number . line-number-in-body).
12028 (setq gnus-newsgroup-bookmarks
12032 (set-buffer gnus-article-buffer)
12036 (goto-char (point-min))
12037 (search-forward "\n\n" nil t)
12040 gnus-newsgroup-bookmarks))
12041 (gnus-message 6 "A bookmark has been added to the current article."))
12043 (defun gnus-summary-remove-bookmark (article)
12044 "Remove the bookmark from the current article."
12045 (interactive (list (gnus-summary-article-number)))
12046 (gnus-set-global-variables)
12047 ;; Remove old bookmark, if one exists.
12048 (let ((old (assq article gnus-newsgroup-bookmarks)))
12051 (setq gnus-newsgroup-bookmarks
12052 (delq old gnus-newsgroup-bookmarks))
12053 (gnus-message 6 "Removed bookmark."))
12054 (gnus-message 6 "No bookmark in current article."))))
12056 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
12057 (defun gnus-summary-mark-as-dormant (n)
12058 "Mark N articles forward as dormant.
12059 If N is negative, mark backward instead. The difference between N and
12060 the actual number of articles marked is returned."
12062 (gnus-set-global-variables)
12063 (gnus-summary-mark-forward n gnus-dormant-mark))
12065 (defun gnus-summary-set-process-mark (article)
12066 "Set the process mark on ARTICLE and update the summary line."
12067 (setq gnus-newsgroup-processable
12069 (delq article gnus-newsgroup-processable)))
12070 (when (gnus-summary-goto-subject article)
12071 (gnus-summary-show-thread)
12072 (gnus-summary-update-secondary-mark article)))
12074 (defun gnus-summary-remove-process-mark (article)
12075 "Remove the process mark from ARTICLE and update the summary line."
12076 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
12077 (when (gnus-summary-goto-subject article)
12078 (gnus-summary-show-thread)
12079 (gnus-summary-update-secondary-mark article)))
12081 (defun gnus-summary-set-saved-mark (article)
12082 "Set the process mark on ARTICLE and update the summary line."
12083 (push article gnus-newsgroup-saved)
12084 (when (gnus-summary-goto-subject article)
12085 (gnus-summary-update-secondary-mark article)))
12087 (defun gnus-summary-mark-forward (n &optional mark no-expire)
12088 "Mark N articles as read forwards.
12089 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
12090 The difference between N and the actual number of articles marked is
12093 (gnus-set-global-variables)
12094 (let ((backward (< n 0))
12095 (gnus-summary-goto-unread
12096 (and gnus-summary-goto-unread
12097 (not (eq gnus-summary-goto-unread 'never))
12098 (not (memq mark (list gnus-unread-mark
12099 gnus-ticked-mark gnus-dormant-mark)))))
12101 (mark (or mark gnus-del-mark)))
12102 (while (and (> n 0)
12103 (gnus-summary-mark-article nil mark no-expire)
12104 (zerop (gnus-summary-next-subject
12106 (and gnus-summary-goto-unread
12107 (not (eq gnus-summary-goto-unread 'never)))
12110 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
12111 (gnus-summary-recenter)
12112 (gnus-summary-position-point)
12113 (gnus-set-mode-line 'summary)
12116 (defun gnus-summary-mark-article-as-read (mark)
12117 "Mark the current article quickly as read with MARK."
12118 (let ((article (gnus-summary-article-number)))
12119 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12120 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12121 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12122 (setq gnus-newsgroup-reads
12123 (cons (cons article mark) gnus-newsgroup-reads))
12124 ;; Possibly remove from cache, if that is used.
12125 (and gnus-use-cache (gnus-cache-enter-remove-article article))
12126 ;; Allow the backend to change the mark.
12127 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
12128 ;; Check for auto-expiry.
12129 (when (and gnus-newsgroup-auto-expire
12130 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
12131 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
12132 (= mark gnus-ancient-mark)
12133 (= mark gnus-read-mark) (= mark gnus-souped-mark)))
12134 (setq mark gnus-expirable-mark)
12135 (push article gnus-newsgroup-expirable))
12136 ;; Set the mark in the buffer.
12137 (gnus-summary-update-mark mark 'unread)
12140 (defun gnus-summary-mark-article-as-unread (mark)
12141 "Mark the current article quickly as unread with MARK."
12142 (let ((article (gnus-summary-article-number)))
12144 (gnus-error 1 "Unmarkable article")
12145 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12146 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12147 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
12148 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
12149 (cond ((= mark gnus-ticked-mark)
12150 (push article gnus-newsgroup-marked))
12151 ((= mark gnus-dormant-mark)
12152 (push article gnus-newsgroup-dormant))
12154 (push article gnus-newsgroup-unreads)))
12155 (setq gnus-newsgroup-reads
12156 (delq (assq article gnus-newsgroup-reads)
12157 gnus-newsgroup-reads))
12159 ;; See whether the article is to be put in the cache.
12160 (and gnus-use-cache
12161 (vectorp (gnus-summary-article-header article))
12163 (gnus-cache-possibly-enter-article
12164 gnus-newsgroup-name article
12165 (gnus-summary-article-header article)
12166 (= mark gnus-ticked-mark)
12167 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
12170 (gnus-summary-update-mark mark 'unread))
12173 (defun gnus-summary-mark-article (&optional article mark no-expire)
12174 "Mark ARTICLE with MARK. MARK can be any character.
12175 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
12176 `??' (dormant) and `?E' (expirable).
12177 If MARK is nil, then the default character `?D' is used.
12178 If ARTICLE is nil, then the article on the current line will be
12180 ;; The mark might be a string.
12181 (and (stringp mark)
12182 (setq mark (aref mark 0)))
12183 ;; If no mark is given, then we check auto-expiring.
12184 (and (not no-expire)
12185 gnus-newsgroup-auto-expire
12187 (and (numberp mark)
12188 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
12189 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
12190 (= mark gnus-read-mark) (= mark gnus-souped-mark))))
12191 (setq mark gnus-expirable-mark))
12192 (let* ((mark (or mark gnus-del-mark))
12193 (article (or article (gnus-summary-article-number))))
12194 (or article (error "No article on current line"))
12195 (if (or (= mark gnus-unread-mark)
12196 (= mark gnus-ticked-mark)
12197 (= mark gnus-dormant-mark))
12198 (gnus-mark-article-as-unread article mark)
12199 (gnus-mark-article-as-read article mark))
12201 ;; See whether the article is to be put in the cache.
12202 (and gnus-use-cache
12203 (not (= mark gnus-canceled-mark))
12204 (vectorp (gnus-summary-article-header article))
12206 (gnus-cache-possibly-enter-article
12207 gnus-newsgroup-name article
12208 (gnus-summary-article-header article)
12209 (= mark gnus-ticked-mark)
12210 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
12212 (if (gnus-summary-goto-subject article nil t)
12213 (let ((buffer-read-only nil))
12214 (gnus-summary-show-thread)
12216 (gnus-summary-update-mark mark 'unread)
12219 (defun gnus-summary-update-secondary-mark (article)
12220 "Update the secondary (read, process, cache) mark."
12221 (gnus-summary-update-mark
12222 (cond ((memq article gnus-newsgroup-processable)
12224 ((memq article gnus-newsgroup-cached)
12226 ((memq article gnus-newsgroup-replied)
12228 ((memq article gnus-newsgroup-saved)
12230 (t gnus-unread-mark))
12232 (when (gnus-visual-p 'summary-highlight 'highlight)
12233 (run-hooks 'gnus-summary-update-hook))
12236 (defun gnus-summary-update-mark (mark type)
12237 (beginning-of-line)
12238 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
12239 (buffer-read-only nil))
12241 (<= (+ forward (point)) (point-max)))
12242 ;; Go to the right position on the line.
12243 (goto-char (+ forward (point)))
12244 ;; Replace the old mark with the new mark.
12245 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
12246 ;; Optionally update the marks by some user rule.
12247 (when (eq type 'unread)
12248 (gnus-data-set-mark
12249 (gnus-data-find (gnus-summary-article-number)) mark)
12250 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
12252 (defun gnus-mark-article-as-read (article &optional mark)
12253 "Enter ARTICLE in the pertinent lists and remove it from others."
12254 ;; Make the article expirable.
12255 (let ((mark (or mark gnus-del-mark)))
12256 (if (= mark gnus-expirable-mark)
12257 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
12258 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
12259 ;; Remove from unread and marked lists.
12260 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12261 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12262 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12263 (push (cons article mark) gnus-newsgroup-reads)
12264 ;; Possibly remove from cache, if that is used.
12265 (when gnus-use-cache
12266 (gnus-cache-enter-remove-article article))))
12268 (defun gnus-mark-article-as-unread (article &optional mark)
12269 "Enter ARTICLE in the pertinent lists and remove it from others."
12270 (let ((mark (or mark gnus-ticked-mark)))
12271 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12272 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12273 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
12274 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12275 (cond ((= mark gnus-ticked-mark)
12276 (push article gnus-newsgroup-marked))
12277 ((= mark gnus-dormant-mark)
12278 (push article gnus-newsgroup-dormant))
12280 (push article gnus-newsgroup-unreads)))
12281 (setq gnus-newsgroup-reads
12282 (delq (assq article gnus-newsgroup-reads)
12283 gnus-newsgroup-reads))))
12285 (defalias 'gnus-summary-mark-as-unread-forward
12286 'gnus-summary-tick-article-forward)
12287 (make-obsolete 'gnus-summary-mark-as-unread-forward
12288 'gnus-summary-tick-article-forward)
12289 (defun gnus-summary-tick-article-forward (n)
12290 "Tick N articles forwards.
12291 If N is negative, tick backwards instead.
12292 The difference between N and the number of articles ticked is returned."
12294 (gnus-summary-mark-forward n gnus-ticked-mark))
12296 (defalias 'gnus-summary-mark-as-unread-backward
12297 'gnus-summary-tick-article-backward)
12298 (make-obsolete 'gnus-summary-mark-as-unread-backward
12299 'gnus-summary-tick-article-backward)
12300 (defun gnus-summary-tick-article-backward (n)
12301 "Tick N articles backwards.
12302 The difference between N and the number of articles ticked is returned."
12304 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
12306 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
12307 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
12308 (defun gnus-summary-tick-article (&optional article clear-mark)
12309 "Mark current article as unread.
12310 Optional 1st argument ARTICLE specifies article number to be marked as unread.
12311 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
12313 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
12314 gnus-ticked-mark)))
12316 (defun gnus-summary-mark-as-read-forward (n)
12317 "Mark N articles as read forwards.
12318 If N is negative, mark backwards instead.
12319 The difference between N and the actual number of articles marked is
12322 (gnus-summary-mark-forward n gnus-del-mark t))
12324 (defun gnus-summary-mark-as-read-backward (n)
12325 "Mark the N articles as read backwards.
12326 The difference between N and the actual number of articles marked is
12329 (gnus-summary-mark-forward (- n) gnus-del-mark t))
12331 (defun gnus-summary-mark-as-read (&optional article mark)
12332 "Mark current article as read.
12333 ARTICLE specifies the article to be marked as read.
12334 MARK specifies a string to be inserted at the beginning of the line."
12335 (gnus-summary-mark-article article mark))
12337 (defun gnus-summary-clear-mark-forward (n)
12338 "Clear marks from N articles forward.
12339 If N is negative, clear backward instead.
12340 The difference between N and the number of marks cleared is returned."
12342 (gnus-summary-mark-forward n gnus-unread-mark))
12344 (defun gnus-summary-clear-mark-backward (n)
12345 "Clear marks from N articles backward.
12346 The difference between N and the number of marks cleared is returned."
12348 (gnus-summary-mark-forward (- n) gnus-unread-mark))
12350 (defun gnus-summary-mark-unread-as-read ()
12351 "Intended to be used by `gnus-summary-mark-article-hook'."
12352 (when (memq gnus-current-article gnus-newsgroup-unreads)
12353 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
12355 (defun gnus-summary-mark-read-and-unread-as-read ()
12356 "Intended to be used by `gnus-summary-mark-article-hook'."
12357 (let ((mark (gnus-summary-article-mark)))
12358 (when (or (gnus-unread-mark-p mark)
12359 (gnus-read-mark-p mark))
12360 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
12362 (defun gnus-summary-mark-region-as-read (point mark all)
12363 "Mark all unread articles between point and mark as read.
12364 If given a prefix, mark all articles between point and mark as read,
12365 even ticked and dormant ones."
12366 (interactive "r\nP")
12370 (beginning-of-line)
12375 (memq (setq article (gnus-summary-article-number))
12376 gnus-newsgroup-unreads))
12377 (gnus-summary-mark-article article gnus-del-mark))
12379 (gnus-summary-find-next))))))
12381 (defun gnus-summary-mark-below (score mark)
12382 "Mark articles with score less than SCORE with MARK."
12383 (interactive "P\ncMark: ")
12384 (gnus-set-global-variables)
12385 (setq score (if score
12386 (prefix-numeric-value score)
12387 (or gnus-summary-default-score 0)))
12389 (set-buffer gnus-summary-buffer)
12390 (goto-char (point-min))
12393 (and (< (gnus-summary-article-score) score)
12394 (gnus-summary-mark-article nil mark))
12395 (gnus-summary-find-next)))))
12397 (defun gnus-summary-kill-below (&optional score)
12398 "Mark articles with score below SCORE as read."
12400 (gnus-set-global-variables)
12401 (gnus-summary-mark-below score gnus-killed-mark))
12403 (defun gnus-summary-clear-above (&optional score)
12404 "Clear all marks from articles with score above SCORE."
12406 (gnus-set-global-variables)
12407 (gnus-summary-mark-above score gnus-unread-mark))
12409 (defun gnus-summary-tick-above (&optional score)
12410 "Tick all articles with score above SCORE."
12412 (gnus-set-global-variables)
12413 (gnus-summary-mark-above score gnus-ticked-mark))
12415 (defun gnus-summary-mark-above (score mark)
12416 "Mark articles with score over SCORE with MARK."
12417 (interactive "P\ncMark: ")
12418 (gnus-set-global-variables)
12419 (setq score (if score
12420 (prefix-numeric-value score)
12421 (or gnus-summary-default-score 0)))
12423 (set-buffer gnus-summary-buffer)
12424 (goto-char (point-min))
12426 (if (> (gnus-summary-article-score) score)
12427 (gnus-summary-mark-article nil mark))
12429 (gnus-summary-find-next)))))
12431 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
12432 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
12433 (defun gnus-summary-limit-include-expunged ()
12434 "Display all the hidden articles that were expunged for low scores."
12436 (gnus-set-global-variables)
12437 (let ((buffer-read-only nil))
12438 (let ((scored gnus-newsgroup-scored)
12441 (or (gnus-summary-goto-subject (caar scored))
12442 (and (setq h (gnus-summary-article-header (caar scored)))
12443 (< (cdar scored) gnus-summary-expunge-below)
12444 (setq headers (cons h headers))))
12445 (setq scored (cdr scored)))
12446 (or headers (error "No expunged articles hidden."))
12447 (goto-char (point-min))
12448 (gnus-summary-prepare-unthreaded (nreverse headers)))
12449 (goto-char (point-min))
12450 (gnus-summary-position-point)))
12452 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
12453 "Mark all articles not marked as unread in this newsgroup as read.
12454 If prefix argument ALL is non-nil, all articles are marked as read.
12455 If QUIETLY is non-nil, no questions will be asked.
12456 If TO-HERE is non-nil, it should be a point in the buffer. All
12457 articles before this point will be marked as read.
12458 The number of articles marked as read is returned."
12460 (gnus-set-global-variables)
12463 (not gnus-interactive-catchup) ;Without confirmation?
12467 "Mark absolutely all articles as read? "
12468 "Mark all unread articles as read? ")))
12470 (not gnus-newsgroup-adaptive)
12471 (not gnus-newsgroup-auto-expire))
12474 (setq gnus-newsgroup-marked nil
12475 gnus-newsgroup-dormant nil))
12476 (setq gnus-newsgroup-unreads nil))
12477 ;; We actually mark all articles as canceled, which we
12478 ;; have to do when using auto-expiry or adaptive scoring.
12479 (gnus-summary-show-all-threads)
12480 (if (gnus-summary-first-subject (not all))
12482 (if to-here (< (point) to-here) t)
12483 (gnus-summary-mark-article-as-read gnus-catchup-mark)
12484 (gnus-summary-find-next (not all)))))
12486 (setq gnus-newsgroup-unreads nil))
12487 (gnus-set-mode-line 'summary)))
12488 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
12489 (if (and (not to-here) (eq 'nnvirtual (car method)))
12490 (nnvirtual-catchup-group
12491 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
12492 (gnus-summary-position-point)))
12494 (defun gnus-summary-catchup-to-here (&optional all)
12495 "Mark all unticked articles before the current one as read.
12496 If ALL is non-nil, also mark ticked and dormant articles as read."
12498 (gnus-set-global-variables)
12500 (gnus-save-hidden-threads
12501 (let ((beg (point)))
12502 ;; We check that there are unread articles.
12503 (when (or all (gnus-summary-find-prev))
12504 (gnus-summary-catchup all t beg)))))
12505 (gnus-summary-position-point))
12507 (defun gnus-summary-catchup-all (&optional quietly)
12508 "Mark all articles in this newsgroup as read."
12510 (gnus-set-global-variables)
12511 (gnus-summary-catchup t quietly))
12513 (defun gnus-summary-catchup-and-exit (&optional all quietly)
12514 "Mark all articles not marked as unread in this newsgroup as read, then exit.
12515 If prefix argument ALL is non-nil, all articles are marked as read."
12517 (gnus-set-global-variables)
12518 (gnus-summary-catchup all quietly nil 'fast)
12519 ;; Select next newsgroup or exit.
12520 (if (eq gnus-auto-select-next 'quietly)
12521 (gnus-summary-next-group nil)
12522 (gnus-summary-exit)))
12524 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
12525 "Mark all articles in this newsgroup as read, and then exit."
12527 (gnus-set-global-variables)
12528 (gnus-summary-catchup-and-exit t quietly))
12530 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
12531 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
12532 "Mark all articles in this group as read and select the next group.
12533 If given a prefix, mark all articles, unread as well as ticked, as
12536 (gnus-set-global-variables)
12538 (gnus-summary-catchup all))
12539 (gnus-summary-next-article t nil nil t))
12541 ;; Thread-based commands.
12543 (defun gnus-summary-articles-in-thread (&optional article)
12544 "Return a list of all articles in the current thread.
12545 If ARTICLE is non-nil, return all articles in the thread that starts
12546 with that article."
12547 (let* ((article (or article (gnus-summary-article-number)))
12548 (data (gnus-data-find-list article))
12549 (top-level (gnus-data-level (car data)))
12551 (cond ((null gnus-thread-operation-ignore-subject)
12552 (gnus-simplify-subject-re
12553 (mail-header-subject (gnus-data-header (car data)))))
12554 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
12555 (gnus-simplify-subject-fuzzy
12556 (mail-header-subject (gnus-data-header (car data)))))
12558 (end-point (save-excursion
12559 (if (gnus-summary-go-to-next-thread)
12560 (point) (point-max))))
12563 (< (gnus-data-pos (car data)) end-point))
12564 (when (or (not top-subject)
12565 (string= top-subject
12566 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
12567 (gnus-simplify-subject-fuzzy
12568 (mail-header-subject
12569 (gnus-data-header (car data))))
12570 (gnus-simplify-subject-re
12571 (mail-header-subject
12572 (gnus-data-header (car data)))))))
12573 (push (gnus-data-number (car data)) articles))
12574 (unless (and (setq data (cdr data))
12575 (> (gnus-data-level (car data)) top-level))
12577 ;; Return the list of articles.
12578 (nreverse articles)))
12580 (defun gnus-summary-rethread-current ()
12581 "Rethread the thread the current article is part of."
12583 (gnus-set-global-variables)
12584 (let* ((gnus-show-threads t)
12585 (article (gnus-summary-article-number))
12586 (id (mail-header-id (gnus-summary-article-header)))
12587 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
12589 (error "No article on the current line"))
12590 (gnus-rebuild-thread id)
12591 (gnus-summary-goto-subject article)))
12593 (defun gnus-summary-reparent-thread ()
12594 "Make current article child of the marked (or previous) article.
12596 Note that the re-threading will only work if `gnus-thread-ignore-subject'
12597 is non-nil or the Subject: of both articles are the same."
12599 (or (not (gnus-group-read-only-p))
12600 (error "The current newsgroup does not support article editing."))
12601 (or (<= (length gnus-newsgroup-processable) 1)
12602 (error "No more than one article may be marked."))
12603 (save-window-excursion
12604 (let ((gnus-article-buffer " *reparent*")
12605 (current-article (gnus-summary-article-number))
12606 ; first grab the marked article, otherwise one line up.
12607 (parent-article (if (not (null gnus-newsgroup-processable))
12608 (car gnus-newsgroup-processable)
12610 (if (eq (forward-line -1) 0)
12611 (gnus-summary-article-number)
12612 (error "Beginning of summary buffer."))))))
12613 (or (not (eq current-article parent-article))
12614 (error "An article may not be self-referential."))
12615 (let ((message-id (mail-header-id
12616 (gnus-summary-article-header parent-article))))
12617 (or (and message-id (not (equal message-id "")))
12618 (error "No message-id in desired parent."))
12619 (gnus-summary-select-article t t nil current-article)
12620 (set-buffer gnus-article-buffer)
12621 (setq buffer-read-only nil)
12622 (let ((buf (format "%s" (buffer-string))))
12625 (goto-char (point-min))
12626 (if (search-forward-regexp "^References: " nil t)
12627 (insert message-id " " )
12628 (insert "References: " message-id "\n"))
12629 (or (gnus-request-replace-article current-article
12630 (car gnus-article-current)
12631 gnus-article-buffer)
12632 (error "Couldn't replace article."))
12633 (set-buffer gnus-summary-buffer)
12634 (gnus-summary-unmark-all-processable)
12635 (gnus-summary-rethread-current)
12636 (gnus-message 3 "Article %d is now the child of article %d."
12637 current-article parent-article)))))
12639 (defun gnus-summary-toggle-threads (&optional arg)
12640 "Toggle showing conversation threads.
12641 If ARG is positive number, turn showing conversation threads on."
12643 (gnus-set-global-variables)
12644 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
12645 (setq gnus-show-threads
12646 (if (null arg) (not gnus-show-threads)
12647 (> (prefix-numeric-value arg) 0)))
12648 (gnus-summary-prepare)
12649 (gnus-summary-goto-subject current)
12650 (gnus-summary-position-point)))
12652 (defun gnus-summary-show-all-threads ()
12653 "Show all threads."
12655 (gnus-set-global-variables)
12657 (let ((buffer-read-only nil))
12658 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
12659 (gnus-summary-position-point))
12661 (defun gnus-summary-show-thread ()
12662 "Show thread subtrees.
12663 Returns nil if no thread was there to be shown."
12665 (gnus-set-global-variables)
12666 (let ((buffer-read-only nil)
12668 ;; first goto end then to beg, to have point at beg after let
12669 (end (progn (end-of-line) (point)))
12670 (beg (progn (beginning-of-line) (point))))
12672 ;; Any hidden lines here?
12673 (search-forward "\r" end t)
12674 (subst-char-in-region beg end ?\^M ?\n t)
12676 (gnus-summary-position-point))))
12678 (defun gnus-summary-hide-all-threads ()
12679 "Hide all thread subtrees."
12681 (gnus-set-global-variables)
12683 (goto-char (point-min))
12684 (gnus-summary-hide-thread)
12685 (while (zerop (gnus-summary-next-thread 1 t))
12686 (gnus-summary-hide-thread)))
12687 (gnus-summary-position-point))
12689 (defun gnus-summary-hide-thread ()
12690 "Hide thread subtrees.
12691 Returns nil if no threads were there to be hidden."
12693 (gnus-set-global-variables)
12694 (let ((buffer-read-only nil)
12696 (article (gnus-summary-article-number)))
12698 ;; Go forward until either the buffer ends or the subthread
12700 (when (and (not (eobp))
12701 (or (zerop (gnus-summary-next-thread 1 t))
12702 (goto-char (point-max))))
12704 (if (and (> (point) start)
12705 (search-backward "\n" start t))
12707 (subst-char-in-region start (point) ?\n ?\^M)
12708 (gnus-summary-goto-subject article))
12711 ;;(gnus-summary-position-point)
12714 (defun gnus-summary-go-to-next-thread (&optional previous)
12715 "Go to the same level (or less) next thread.
12716 If PREVIOUS is non-nil, go to previous thread instead.
12717 Return the article number moved to, or nil if moving was impossible."
12718 (let ((level (gnus-summary-thread-level))
12719 (way (if previous -1 1))
12722 (while (and (not (eobp))
12723 (< level (gnus-summary-thread-level)))
12724 (forward-line way))
12731 (gnus-summary-article-number)
12732 (goto-char beg)))))
12734 (defun gnus-summary-go-to-next-thread-old (&optional previous)
12735 "Go to the same level (or less) next thread.
12736 If PREVIOUS is non-nil, go to previous thread instead.
12737 Return the article number moved to, or nil if moving was impossible."
12738 (if (and (eq gnus-summary-make-false-root 'dummy)
12739 (gnus-summary-article-intangible-p))
12740 (let ((beg (point)))
12741 (while (and (zerop (forward-line 1))
12742 (not (gnus-summary-article-intangible-p))
12743 (not (zerop (save-excursion
12744 (gnus-summary-thread-level))))))
12750 (let* ((level (gnus-summary-thread-level))
12751 (article (gnus-summary-article-number))
12752 (data (cdr (gnus-data-find-list article (gnus-data-list previous))))
12755 (if (<= (gnus-data-level (car data)) level)
12756 (setq oart (gnus-data-number (car data))
12758 (setq data (cdr data))))
12760 (gnus-summary-goto-subject oart)))))
12762 (defun gnus-summary-next-thread (n &optional silent)
12763 "Go to the same level next N'th thread.
12764 If N is negative, search backward instead.
12765 Returns the difference between N and the number of skips actually
12768 If SILENT, don't output messages."
12770 (gnus-set-global-variables)
12771 (let ((backward (< n 0))
12774 (while (and (> n 0)
12775 (gnus-summary-go-to-next-thread backward))
12778 (gnus-summary-position-point))
12779 (when (and (not silent) (/= 0 n))
12780 (gnus-message 7 "No more threads"))
12783 (defun gnus-summary-prev-thread (n)
12784 "Go to the same level previous N'th thread.
12785 Returns the difference between N and the number of skips actually
12788 (gnus-set-global-variables)
12789 (gnus-summary-next-thread (- n)))
12791 (defun gnus-summary-go-down-thread ()
12792 "Go down one level in the current thread."
12793 (let ((children (gnus-summary-article-children)))
12795 (gnus-summary-goto-subject (car children)))))
12797 (defun gnus-summary-go-up-thread ()
12798 "Go up one level in the current thread."
12799 (let ((parent (gnus-summary-article-parent)))
12801 (gnus-summary-goto-subject parent))))
12803 (defun gnus-summary-down-thread (n)
12804 "Go down thread N steps.
12805 If N is negative, go up instead.
12806 Returns the difference between N and how many steps down that were
12809 (gnus-set-global-variables)
12812 (while (and (> n 0)
12813 (if up (gnus-summary-go-up-thread)
12814 (gnus-summary-go-down-thread)))
12816 (gnus-summary-position-point)
12817 (if (/= 0 n) (gnus-message 7 "Can't go further"))
12820 (defun gnus-summary-up-thread (n)
12821 "Go up thread N steps.
12822 If N is negative, go up instead.
12823 Returns the difference between N and how many steps down that were
12826 (gnus-set-global-variables)
12827 (gnus-summary-down-thread (- n)))
12829 (defun gnus-summary-top-thread ()
12830 "Go to the top of the thread."
12832 (gnus-set-global-variables)
12833 (while (gnus-summary-go-up-thread))
12834 (gnus-summary-article-number))
12836 (defun gnus-summary-kill-thread (&optional unmark)
12837 "Mark articles under current thread as read.
12838 If the prefix argument is positive, remove any kinds of marks.
12839 If the prefix argument is negative, tick articles instead."
12841 (gnus-set-global-variables)
12843 (setq unmark (prefix-numeric-value unmark)))
12844 (let ((articles (gnus-summary-articles-in-thread)))
12846 ;; Expand the thread.
12847 (gnus-summary-show-thread)
12848 ;; Mark all the articles.
12850 (gnus-summary-goto-subject (car articles))
12851 (cond ((null unmark)
12852 (gnus-summary-mark-article-as-read gnus-killed-mark))
12854 (gnus-summary-mark-article-as-unread gnus-unread-mark))
12856 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
12857 (setq articles (cdr articles))))
12858 ;; Hide killed subtrees.
12860 gnus-thread-hide-killed
12861 (gnus-summary-hide-thread))
12862 ;; If marked as read, go to next unread subject.
12864 ;; Go to next unread subject.
12865 (gnus-summary-next-subject 1 t)))
12866 (gnus-set-mode-line 'summary))
12868 ;; Summary sorting commands
12870 (defun gnus-summary-sort-by-number (&optional reverse)
12871 "Sort summary buffer by article number.
12872 Argument REVERSE means reverse order."
12874 (gnus-summary-sort 'number reverse))
12876 (defun gnus-summary-sort-by-author (&optional reverse)
12877 "Sort summary buffer by author name alphabetically.
12878 If case-fold-search is non-nil, case of letters is ignored.
12879 Argument REVERSE means reverse order."
12881 (gnus-summary-sort 'author reverse))
12883 (defun gnus-summary-sort-by-subject (&optional reverse)
12884 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
12885 If case-fold-search is non-nil, case of letters is ignored.
12886 Argument REVERSE means reverse order."
12888 (gnus-summary-sort 'subject reverse))
12890 (defun gnus-summary-sort-by-date (&optional reverse)
12891 "Sort summary buffer by date.
12892 Argument REVERSE means reverse order."
12894 (gnus-summary-sort 'date reverse))
12896 (defun gnus-summary-sort-by-score (&optional reverse)
12897 "Sort summary buffer by score.
12898 Argument REVERSE means reverse order."
12900 (gnus-summary-sort 'score reverse))
12902 (defun gnus-summary-sort (predicate reverse)
12903 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
12904 (gnus-set-global-variables)
12905 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
12906 (article (intern (format "gnus-article-sort-by-%s" predicate)))
12907 (gnus-thread-sort-functions
12912 (,thread t2 t1)))))
12913 (gnus-article-sort-functions
12918 (,article t2 t1)))))
12920 (gnus-summary-prepare-hook nil))
12921 ;; We do the sorting by regenerating the threads.
12922 (gnus-summary-prepare)
12923 ;; Hide subthreads if needed.
12924 (when (and gnus-show-threads gnus-thread-hide-subtree)
12925 (gnus-summary-hide-all-threads)))
12926 ;; If in async mode, we send some info to the backend.
12927 (when gnus-newsgroup-async
12928 (gnus-request-asynchronous
12929 gnus-newsgroup-name gnus-newsgroup-data)))
12931 (defun gnus-sortable-date (date)
12932 "Make sortable string by string-lessp from DATE.
12933 Timezone package is used."
12936 (setq date (inline (timezone-fix-time
12938 (aref (inline (timezone-parse-date date)) 4))))
12940 (timezone-make-sortable-date
12941 (aref date 0) (aref date 1) (aref date 2)
12943 (timezone-make-time-string
12944 (aref date 3) (aref date 4) (aref date 5))))))
12947 ;; Summary saving commands.
12949 (defun gnus-summary-save-article (&optional n not-saved)
12950 "Save the current article using the default saver function.
12951 If N is a positive number, save the N next articles.
12952 If N is a negative number, save the N previous articles.
12953 If N is nil and any articles have been marked with the process mark,
12954 save those articles instead.
12955 The variable `gnus-default-article-saver' specifies the saver function."
12957 (gnus-set-global-variables)
12958 (let ((articles (gnus-summary-work-articles n))
12959 (save-buffer (save-excursion
12960 (nnheader-set-temp-buffer " *Gnus Save*")))
12961 file header article)
12963 (setq header (gnus-summary-article-header
12964 (setq article (pop articles))))
12965 (if (not (vectorp header))
12966 ;; This is a pseudo-article.
12967 (if (assq 'name header)
12968 (gnus-copy-file (cdr (assq 'name header)))
12969 (gnus-message 1 "Article %d is unsaveable" article))
12970 ;; This is a real article.
12971 (save-window-excursion
12972 (gnus-summary-select-article t nil nil article))
12974 (set-buffer save-buffer)
12976 (insert-buffer-substring gnus-original-article-buffer))
12977 (unless gnus-save-all-headers
12978 ;; Remove headers accoring to `gnus-saved-headers'.
12979 (let ((gnus-visible-headers
12980 (or gnus-saved-headers gnus-visible-headers))
12981 (gnus-article-buffer save-buffer))
12982 (gnus-article-hide-headers 1 t)))
12983 (save-window-excursion
12984 (if (not gnus-default-article-saver)
12985 (error "No default saver is defined.")
12986 ;; !!! Magic! The saving functions all save
12987 ;; `gnus-original-article-buffer' (or so they think),
12988 ;; but we bind that variable to our save-buffer.
12989 (set-buffer gnus-article-buffer)
12990 (let ((gnus-original-article-buffer save-buffer))
12991 (set-buffer gnus-summary-buffer)
12992 (setq file (funcall
12993 gnus-default-article-saver
12995 ((not gnus-prompt-before-saving)
12997 ((eq gnus-prompt-before-saving 'always)
13000 (gnus-summary-remove-process-mark article)
13002 (gnus-summary-set-saved-mark article))))
13003 (gnus-kill-buffer save-buffer)
13004 (gnus-summary-position-point)
13007 (defun gnus-summary-pipe-output (&optional arg)
13008 "Pipe the current article to a subprocess.
13009 If N is a positive number, pipe the N next articles.
13010 If N is a negative number, pipe the N previous articles.
13011 If N is nil and any articles have been marked with the process mark,
13012 pipe those articles instead."
13014 (gnus-set-global-variables)
13015 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
13016 (gnus-summary-save-article arg t))
13017 (gnus-configure-windows 'pipe))
13019 (defun gnus-summary-save-article-mail (&optional arg)
13020 "Append the current article to an mail file.
13021 If N is a positive number, save the N next articles.
13022 If N is a negative number, save the N previous articles.
13023 If N is nil and any articles have been marked with the process mark,
13024 save those articles instead."
13026 (gnus-set-global-variables)
13027 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
13028 (gnus-summary-save-article arg)))
13030 (defun gnus-summary-save-article-rmail (&optional arg)
13031 "Append the current article to an rmail file.
13032 If N is a positive number, save the N next articles.
13033 If N is a negative number, save the N previous articles.
13034 If N is nil and any articles have been marked with the process mark,
13035 save those articles instead."
13037 (gnus-set-global-variables)
13038 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
13039 (gnus-summary-save-article arg)))
13041 (defun gnus-summary-save-article-file (&optional arg)
13042 "Append the current article to a file.
13043 If N is a positive number, save the N next articles.
13044 If N is a negative number, save the N previous articles.
13045 If N is nil and any articles have been marked with the process mark,
13046 save those articles instead."
13048 (gnus-set-global-variables)
13049 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
13050 (gnus-summary-save-article arg)))
13052 (defun gnus-summary-save-article-body-file (&optional arg)
13053 "Append the current article body to a file.
13054 If N is a positive number, save the N next articles.
13055 If N is a negative number, save the N previous articles.
13056 If N is nil and any articles have been marked with the process mark,
13057 save those articles instead."
13059 (gnus-set-global-variables)
13060 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
13061 (gnus-summary-save-article arg)))
13063 (defun gnus-get-split-value (methods)
13064 "Return a value based on the split METHODS."
13065 (let (split-name method result match)
13068 (set-buffer gnus-original-article-buffer)
13070 (nnheader-narrow-to-headers)
13072 (goto-char (point-min))
13073 (setq method (pop methods))
13074 (setq match (car method))
13077 ;; Regular expression.
13079 (re-search-forward match nil t)
13081 ((gnus-functionp match)
13085 (setq result (funcall match gnus-newsgroup-name))))
13090 (setq result (eval match)))))
13091 (setq split-name (append (cdr method) split-name))
13092 (cond ((stringp result)
13093 (push result split-name))
13095 (setq split-name (append result split-name)))))))))
13098 (defun gnus-read-move-group-name (prompt default articles prefix)
13099 "Read a group name."
13100 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
13101 (minibuffer-confirm-incomplete nil) ; XEmacs
13108 (assoc (symbol-name
13109 (car (gnus-find-method-for-group
13111 gnus-valid-select-methods))
13112 (push (list (symbol-name g)) group-map)))
13113 gnus-active-hashtb))
13115 (format "%s %s to:"
13117 (if (> (length articles) 1)
13118 (format "these %d articles" (length articles))
13123 (gnus-completing-read default prom
13124 group-map nil nil prefix
13125 'gnus-group-history))
13126 ((= 1 (length split-name))
13127 (gnus-completing-read (car split-name) prom group-map
13129 'gnus-group-history))
13131 (gnus-completing-read nil prom
13132 (mapcar (lambda (el) (list el))
13133 (nreverse split-name))
13135 'gnus-group-history)))))
13137 (if (or (string= to-newsgroup "")
13138 (string= to-newsgroup prefix))
13139 (setq to-newsgroup (or default "")))
13140 (or (gnus-active to-newsgroup)
13141 (gnus-activate-group to-newsgroup)
13142 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
13144 (or (gnus-request-create-group to-newsgroup)
13145 (error "Couldn't create group %s" to-newsgroup)))
13146 (error "No such group: %s" to-newsgroup)))
13149 (defun gnus-read-save-file-name (prompt default-name)
13150 (let* ((split-name (gnus-get-split-value gnus-split-methods))
13152 ;; Let the split methods have their say.
13154 ;; No split name was found.
13157 (concat prompt " (default "
13158 (file-name-nondirectory default-name) ") ")
13159 (file-name-directory default-name)
13161 ;; A single split name was found
13162 ((= 1 (length split-name))
13163 (let* ((name (car split-name))
13164 (dir (cond ((file-directory-p name)
13165 (file-name-as-directory name))
13166 ((file-exists-p name) name)
13167 (t gnus-article-save-directory))))
13169 (concat prompt " (default " name ") ")
13171 ;; A list of splits was found.
13173 (setq split-name (nreverse split-name))
13175 (let ((file-name-history (nconc split-name file-name-history)))
13178 (concat prompt " (`M-p' for defaults) ")
13179 gnus-article-save-directory
13180 (car split-name))))
13181 (car (push result file-name-history)))))))
13182 ;; If we have read a directory, we append the default file name.
13183 (when (file-directory-p file)
13184 (setq file (concat (file-name-as-directory file)
13185 (file-name-nondirectory default-name))))
13186 ;; Possibly translate some charaters.
13187 (nnheader-translate-file-chars file)))
13189 (defun gnus-article-archive-name (group)
13190 "Return the first instance of an \"Archive-name\" in the current buffer."
13191 (let ((case-fold-search t))
13192 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
13193 (match-string 1))))
13195 (defun gnus-summary-save-in-rmail (&optional filename)
13196 "Append this article to Rmail file.
13197 Optional argument FILENAME specifies file name.
13198 Directory to save to is default to `gnus-article-save-directory'."
13200 (gnus-set-global-variables)
13201 (let ((default-name
13202 (funcall gnus-rmail-save-name gnus-newsgroup-name
13203 gnus-current-headers gnus-newsgroup-last-rmail)))
13205 (cond ((eq filename 'default)
13207 (filename filename)
13208 (t (gnus-read-save-file-name
13209 "Save in rmail file:" default-name))))
13210 (gnus-make-directory (file-name-directory filename))
13211 (gnus-eval-in-buffer-window gnus-original-article-buffer
13215 (gnus-output-to-rmail filename))))
13216 ;; Remember the directory name to save articles
13217 (setq gnus-newsgroup-last-rmail filename)))
13219 (defun gnus-summary-save-in-mail (&optional filename)
13220 "Append this article to Unix mail file.
13221 Optional argument FILENAME specifies file name.
13222 Directory to save to is default to `gnus-article-save-directory'."
13224 (gnus-set-global-variables)
13225 (let ((default-name
13226 (funcall gnus-mail-save-name gnus-newsgroup-name
13227 gnus-current-headers gnus-newsgroup-last-mail)))
13229 (cond ((eq filename 'default)
13231 (filename filename)
13232 (t (gnus-read-save-file-name
13233 "Save in Unix mail file:" default-name))))
13235 (expand-file-name filename
13237 (file-name-directory default-name))))
13238 (gnus-make-directory (file-name-directory filename))
13239 (gnus-eval-in-buffer-window gnus-original-article-buffer
13243 (if (and (file-readable-p filename) (mail-file-babyl-p filename))
13244 (gnus-output-to-rmail filename)
13245 (let ((mail-use-rfc822 t))
13246 (rmail-output filename 1 t t))))))
13247 ;; Remember the directory name to save articles.
13248 (setq gnus-newsgroup-last-mail filename)))
13250 (defun gnus-summary-save-in-file (&optional filename)
13251 "Append this article to file.
13252 Optional argument FILENAME specifies file name.
13253 Directory to save to is default to `gnus-article-save-directory'."
13255 (gnus-set-global-variables)
13256 (let ((default-name
13257 (funcall gnus-file-save-name gnus-newsgroup-name
13258 gnus-current-headers gnus-newsgroup-last-file)))
13260 (cond ((eq filename 'default)
13262 (filename filename)
13263 (t (gnus-read-save-file-name
13264 "Save in file:" default-name))))
13265 (gnus-make-directory (file-name-directory filename))
13266 (gnus-eval-in-buffer-window gnus-original-article-buffer
13270 (gnus-output-to-file filename))))
13271 ;; Remember the directory name to save articles.
13272 (setq gnus-newsgroup-last-file filename)))
13274 (defun gnus-summary-save-body-in-file (&optional filename)
13275 "Append this article body to a file.
13276 Optional argument FILENAME specifies file name.
13277 The directory to save in defaults to `gnus-article-save-directory'."
13279 (gnus-set-global-variables)
13280 (let ((default-name
13281 (funcall gnus-file-save-name gnus-newsgroup-name
13282 gnus-current-headers gnus-newsgroup-last-file)))
13284 (cond ((eq filename 'default)
13286 (filename filename)
13287 (t (gnus-read-save-file-name
13288 "Save body in file:" default-name))))
13289 (gnus-make-directory (file-name-directory filename))
13290 (gnus-eval-in-buffer-window gnus-article-buffer
13294 (goto-char (point-min))
13295 (and (search-forward "\n\n" nil t)
13296 (narrow-to-region (point) (point-max)))
13297 (gnus-output-to-file filename))))
13298 ;; Remember the directory name to save articles.
13299 (setq gnus-newsgroup-last-file filename)))
13301 (defun gnus-summary-save-in-pipe (&optional command)
13302 "Pipe this article to subprocess."
13304 (gnus-set-global-variables)
13306 (cond ((eq command 'default)
13307 gnus-last-shell-command)
13309 (t (read-string "Shell command on article: "
13310 gnus-last-shell-command))))
13311 (if (string-equal command "")
13312 (setq command gnus-last-shell-command))
13313 (gnus-eval-in-buffer-window gnus-article-buffer
13316 (shell-command-on-region (point-min) (point-max) command nil)))
13317 (setq gnus-last-shell-command command))
13319 ;; Summary extract commands
13321 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
13322 (let ((buffer-read-only nil)
13323 (article (gnus-summary-article-number))
13325 (or (gnus-summary-goto-subject article)
13326 (error (format "No such article: %d" article)))
13327 (gnus-summary-position-point)
13328 ;; If all commands are to be bunched up on one line, we collect
13330 (if gnus-view-pseudos-separately
13332 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
13335 (setq action (cdr (assq 'action (car ps))))
13336 (setq files (list (cdr (assq 'name (car ps)))))
13337 (while (and ps (cdr ps)
13338 (string= (or action "1")
13339 (or (cdr (assq 'action (cadr ps))) "2")))
13340 (setq files (cons (cdr (assq 'name (cadr ps))) files))
13341 (setcdr ps (cddr ps)))
13344 (if (not (string-match "%s" action))
13345 (setq files (cons " " files)))
13346 (setq files (cons " " files))
13347 (and (assq 'execute (car ps))
13348 (setcdr (assq 'execute (car ps))
13349 (funcall (if (string-match "%s" action)
13352 (mapconcat (lambda (f) f) files " ")))))
13353 (setq ps (cdr ps)))))
13354 (if (and gnus-view-pseudos (not not-view))
13356 (and (assq 'execute (car pslist))
13357 (gnus-execute-command (cdr (assq 'execute (car pslist)))
13358 (eq gnus-view-pseudos 'not-confirm)))
13359 (setq pslist (cdr pslist)))
13362 (setq after-article (or (cdr (assq 'article (car pslist)))
13363 (gnus-summary-article-number)))
13364 (gnus-summary-goto-subject after-article)
13367 (insert " " (file-name-nondirectory
13368 (cdr (assq 'name (car pslist))))
13369 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
13371 (forward-line -1) ; back to `b'
13372 (gnus-add-text-properties
13373 b (1- e) (list 'gnus-number gnus-reffed-article-number
13374 gnus-mouse-face-prop gnus-mouse-face))
13376 after-article gnus-reffed-article-number
13377 gnus-unread-mark b (car pslist) 0 (- e b))
13378 (push gnus-reffed-article-number gnus-newsgroup-unreads)
13379 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
13380 (setq pslist (cdr pslist)))))))
13382 (defun gnus-pseudos< (p1 p2)
13383 (let ((c1 (cdr (assq 'action p1)))
13384 (c2 (cdr (assq 'action p2))))
13385 (and c1 c2 (string< c1 c2))))
13387 (defun gnus-request-pseudo-article (props)
13388 (cond ((assq 'execute props)
13389 (gnus-execute-command (cdr (assq 'execute props)))))
13390 (let ((gnus-current-article (gnus-summary-article-number)))
13391 (run-hooks 'gnus-mark-article-hook)))
13393 (defun gnus-execute-command (command &optional automatic)
13395 (gnus-article-setup-buffer)
13396 (set-buffer gnus-article-buffer)
13397 (setq buffer-read-only nil)
13398 (let ((command (if automatic command (read-string "Command: " command)))
13399 ;; Just binding this here doesn't help, because there might
13400 ;; be output from the process after exiting the scope of
13402 ;; (buffer-read-only nil)
13405 (insert "$ " command "\n\n")
13406 (if gnus-view-pseudo-asynchronously
13407 (start-process "gnus-execute" nil shell-file-name
13408 shell-command-switch command)
13409 (call-process shell-file-name nil t nil
13410 shell-command-switch command)))))
13412 (defun gnus-copy-file (file &optional to)
13415 (list (read-file-name "Copy file: " default-directory)
13416 (read-file-name "Copy file to: " default-directory)))
13417 (gnus-set-global-variables)
13418 (or to (setq to (read-file-name "Copy file to: " default-directory)))
13419 (and (file-directory-p to)
13420 (setq to (concat (file-name-as-directory to)
13421 (file-name-nondirectory file))))
13422 (copy-file file to))
13424 ;; Summary kill commands.
13426 (defun gnus-summary-edit-global-kill (article)
13427 "Edit the \"global\" kill file."
13428 (interactive (list (gnus-summary-article-number)))
13429 (gnus-set-global-variables)
13430 (gnus-group-edit-global-kill article))
13432 (defun gnus-summary-edit-local-kill ()
13433 "Edit a local kill file applied to the current newsgroup."
13435 (gnus-set-global-variables)
13436 (setq gnus-current-headers (gnus-summary-article-header))
13437 (gnus-set-global-variables)
13438 (gnus-group-edit-local-kill
13439 (gnus-summary-article-number) gnus-newsgroup-name))
13443 ;;; Gnus article mode
13446 (put 'gnus-article-mode 'mode-class 'special)
13448 (if gnus-article-mode-map
13450 (setq gnus-article-mode-map (make-keymap))
13451 (suppress-keymap gnus-article-mode-map)
13453 (gnus-define-keys gnus-article-mode-map
13454 " " gnus-article-goto-next-page
13455 "\177" gnus-article-goto-prev-page
13456 [delete] gnus-article-goto-prev-page
13457 "\C-c^" gnus-article-refer-article
13458 "h" gnus-article-show-summary
13459 "s" gnus-article-show-summary
13460 "\C-c\C-m" gnus-article-mail
13461 "?" gnus-article-describe-briefly
13462 gnus-mouse-2 gnus-article-push-button
13463 "\r" gnus-article-press-button
13464 "\t" gnus-article-next-button
13465 "\M-\t" gnus-article-prev-button
13466 "\C-c\C-b" gnus-bug)
13468 (substitute-key-definition
13469 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map))
13471 (defun gnus-article-mode ()
13472 "Major mode for displaying an article.
13474 All normal editing commands are switched off.
13476 The following commands are available:
13478 \\<gnus-article-mode-map>
13479 \\[gnus-article-next-page]\t Scroll the article one page forwards
13480 \\[gnus-article-prev-page]\t Scroll the article one page backwards
13481 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
13482 \\[gnus-article-show-summary]\t Display the summary buffer
13483 \\[gnus-article-mail]\t Send a reply to the address near point
13484 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
13485 \\[gnus-info-find-node]\t Go to the Gnus info node"
13487 (when (and menu-bar-mode
13488 (gnus-visual-p 'article-menu 'menu))
13489 (gnus-article-make-menu-bar))
13490 (kill-all-local-variables)
13491 (gnus-simplify-mode-line)
13492 (setq mode-name "Article")
13493 (setq major-mode 'gnus-article-mode)
13494 (make-local-variable 'minor-mode-alist)
13495 (or (assq 'gnus-show-mime minor-mode-alist)
13496 (setq minor-mode-alist
13497 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
13498 (use-local-map gnus-article-mode-map)
13499 (make-local-variable 'page-delimiter)
13500 (setq page-delimiter gnus-page-delimiter)
13501 (buffer-disable-undo (current-buffer))
13502 (setq buffer-read-only t) ;Disable modification
13503 (run-hooks 'gnus-article-mode-hook))
13505 (defun gnus-article-setup-buffer ()
13506 "Initialize the article buffer."
13507 (let* ((name (if gnus-single-article-buffer "*Article*"
13508 (concat "*Article " gnus-newsgroup-name "*")))
13510 (progn (string-match "\\*Article" name)
13511 (concat " *Original Article"
13512 (substring name (match-end 0))))))
13513 (setq gnus-article-buffer name)
13514 (setq gnus-original-article-buffer original)
13515 ;; This might be a variable local to the summary buffer.
13516 (unless gnus-single-article-buffer
13518 (set-buffer gnus-summary-buffer)
13519 (setq gnus-article-buffer name)
13520 (setq gnus-original-article-buffer original)
13521 (gnus-set-global-variables))
13522 (make-local-variable 'gnus-summary-buffer))
13523 ;; Init original article buffer.
13525 (set-buffer (get-buffer-create gnus-original-article-buffer))
13526 (buffer-disable-undo (current-buffer))
13527 (setq major-mode 'gnus-original-article-mode)
13528 (make-local-variable 'gnus-original-article))
13529 (if (get-buffer name)
13532 (buffer-disable-undo (current-buffer))
13533 (setq buffer-read-only t)
13534 (gnus-add-current-to-buffer-list)
13535 (or (eq major-mode 'gnus-article-mode)
13536 (gnus-article-mode))
13539 (set-buffer (get-buffer-create name))
13540 (gnus-add-current-to-buffer-list)
13541 (gnus-article-mode)
13542 (current-buffer)))))
13544 ;; Set article window start at LINE, where LINE is the number of lines
13545 ;; from the head of the article.
13546 (defun gnus-article-set-window-start (&optional line)
13548 (get-buffer-window gnus-article-buffer t)
13550 (set-buffer gnus-article-buffer)
13551 (goto-char (point-min))
13554 (gnus-message 6 "Moved to bookmark")
13555 (search-forward "\n\n" nil t)
13556 (forward-line line)
13559 (defun gnus-kill-all-overlays ()
13560 "Delete all overlays in the current buffer."
13561 (when (fboundp 'overlay-lists)
13562 (let* ((overlayss (overlay-lists))
13563 (buffer-read-only nil)
13564 (overlays (nconc (car overlayss) (cdr overlayss))))
13566 (delete-overlay (pop overlays))))))
13568 (defun gnus-request-article-this-buffer (article group)
13569 "Get an article and insert it into this buffer."
13570 (let (do-update-line)
13574 (gnus-kill-all-overlays)
13575 (setq group (or group gnus-newsgroup-name))
13577 ;; Open server if it has closed.
13578 (gnus-check-server (gnus-find-method-for-group group))
13580 ;; Using `gnus-request-article' directly will insert the article into
13581 ;; `nntp-server-buffer' - so we'll save some time by not having to
13582 ;; copy it from the server buffer into the article buffer.
13584 ;; We only request an article by message-id when we do not have the
13585 ;; headers for it, so we'll have to get those.
13586 (when (stringp article)
13587 (let ((gnus-override-method gnus-refer-article-method))
13588 (gnus-read-header article)))
13590 ;; If the article number is negative, that means that this article
13591 ;; doesn't belong in this newsgroup (possibly), so we find its
13592 ;; message-id and request it by id instead of number.
13593 (when (and (numberp article)
13594 gnus-summary-buffer
13595 (get-buffer gnus-summary-buffer)
13596 (buffer-name (get-buffer gnus-summary-buffer)))
13598 (set-buffer gnus-summary-buffer)
13599 (let ((header (gnus-summary-article-header article)))
13602 ((memq article gnus-newsgroup-sparse)
13603 ;; This is a sparse gap article.
13604 (setq do-update-line article)
13605 (setq article (mail-header-id header))
13606 (let ((gnus-override-method gnus-refer-article-method))
13607 (gnus-read-header article))
13608 (setq gnus-newsgroup-sparse
13609 (delq article gnus-newsgroup-sparse)))
13611 ;; It's a real article.
13612 (setq article (mail-header-id header)))
13614 ;; It is an extracted pseudo-article.
13615 (setq article 'pseudo)
13616 (gnus-request-pseudo-article header))))
13618 (let ((method (gnus-find-method-for-group
13619 gnus-newsgroup-name)))
13620 (if (not (eq (car method) 'nneething))
13622 (let ((dir (concat (file-name-as-directory (nth 1 method))
13623 (mail-header-subject header))))
13624 (if (file-directory-p dir)
13626 (setq article 'nneething)
13627 (gnus-group-enter-directory dir)))))))))
13630 ;; Refuse to select canceled articles.
13631 ((and (numberp article)
13632 gnus-summary-buffer
13633 (get-buffer gnus-summary-buffer)
13634 (buffer-name (get-buffer gnus-summary-buffer))
13635 (eq (cdr (save-excursion
13636 (set-buffer gnus-summary-buffer)
13637 (assq article gnus-newsgroup-reads)))
13638 gnus-canceled-mark))
13640 ;; We first check `gnus-original-article-buffer'.
13641 ((and (get-buffer gnus-original-article-buffer)
13644 (set-buffer gnus-original-article-buffer)
13645 (and (equal (car gnus-original-article) group)
13646 (eq (cdr gnus-original-article) article))))
13647 (insert-buffer-substring gnus-original-article-buffer)
13649 ;; Check the backlog.
13650 ((and gnus-keep-backlog
13651 (gnus-backlog-request-article group article (current-buffer)))
13653 ;; Check the cache.
13654 ((and gnus-use-cache
13656 (gnus-cache-request-article article group))
13658 ;; Get the article and put into the article buffer.
13659 ((or (stringp article) (numberp article))
13660 (let ((gnus-override-method
13661 (and (stringp article) gnus-refer-article-method))
13662 (buffer-read-only nil))
13664 (gnus-kill-all-overlays)
13665 (if (gnus-request-article article group (current-buffer))
13667 (and gnus-keep-backlog
13669 (gnus-backlog-enter-article
13670 group article (current-buffer)))
13672 ;; It was a pseudo.
13675 ;; Take the article from the original article buffer
13676 ;; and place it in the buffer it's supposed to be in.
13677 (when (and (get-buffer gnus-article-buffer)
13678 ;;(numberp article)
13679 (equal (buffer-name (current-buffer))
13680 (buffer-name (get-buffer gnus-article-buffer))))
13682 (if (get-buffer gnus-original-article-buffer)
13683 (set-buffer (get-buffer gnus-original-article-buffer))
13684 (set-buffer (get-buffer-create gnus-original-article-buffer))
13685 (buffer-disable-undo (current-buffer))
13686 (setq major-mode 'gnus-original-article-mode)
13687 (setq buffer-read-only t)
13688 (gnus-add-current-to-buffer-list))
13689 (let (buffer-read-only)
13691 (insert-buffer-substring gnus-article-buffer))
13692 (setq gnus-original-article (cons group article))))
13694 ;; Update sparse articles.
13695 (when (and do-update-line
13696 (or (numberp article)
13697 (stringp article)))
13698 (let ((buf (current-buffer)))
13699 (set-buffer gnus-summary-buffer)
13700 (gnus-summary-update-article do-update-line)
13701 (gnus-summary-goto-subject do-update-line nil t)
13702 (set-window-point (get-buffer-window (current-buffer) t)
13704 (set-buffer buf))))))
13706 (defun gnus-read-header (id &optional header)
13707 "Read the headers of article ID and enter them into the Gnus system."
13708 (let ((group gnus-newsgroup-name)
13709 (gnus-override-method
13710 (and (gnus-news-group-p gnus-newsgroup-name)
13711 gnus-refer-article-method))
13713 ;; First we check to see whether the header in question is already
13716 ;; This is a Message-ID.
13717 (setq header (or header (gnus-id-to-header id)))
13718 ;; This is an article number.
13719 (setq header (or header (gnus-summary-article-header id))))
13721 (not (memq (mail-header-number header) gnus-newsgroup-sparse)))
13722 ;; We have found the header.
13724 ;; We have to really fetch the header to this article.
13725 (when (setq where (gnus-request-head id group))
13727 (set-buffer nntp-server-buffer)
13728 (goto-char (point-max))
13730 (goto-char (point-min))
13734 ((cdr where) (cdr where))
13735 (header (mail-header-number header))
13736 (t gnus-reffed-article-number))
13738 (insert " Article retrieved.\n"))
13740 ; (memq (mail-header-number header) gnus-newsgroup-sparse))
13741 ; (setcar (gnus-id-to-thread id) nil))
13742 (if (not (setq header (car (gnus-get-newsgroup-headers))))
13743 () ; Malformed head.
13744 (unless (memq (mail-header-number header) gnus-newsgroup-sparse)
13745 (if (and (stringp id)
13746 (not (string= (gnus-group-real-name group)
13748 ;; If we fetched by Message-ID and the article came
13749 ;; from a different group, we fudge some bogus article
13750 ;; numbers for this article.
13751 (mail-header-set-number header gnus-reffed-article-number))
13752 (decf gnus-reffed-article-number)
13753 (gnus-remove-header (mail-header-number header))
13754 (push header gnus-newsgroup-headers)
13755 (setq gnus-current-headers header)
13756 (push (mail-header-number header) gnus-newsgroup-limit))
13759 (defun gnus-remove-header (number)
13760 "Remove header NUMBER from `gnus-newsgroup-headers'."
13761 (if (and gnus-newsgroup-headers
13762 (= number (mail-header-number (car gnus-newsgroup-headers))))
13763 (pop gnus-newsgroup-headers)
13764 (let ((headers gnus-newsgroup-headers))
13765 (while (and (cdr headers)
13766 (not (= number (mail-header-number (cadr headers)))))
13768 (when (cdr headers)
13769 (setcdr headers (cddr headers))))))
13771 (defun gnus-article-prepare (article &optional all-headers header)
13772 "Prepare ARTICLE in article mode buffer.
13773 ARTICLE should either be an article number or a Message-ID.
13774 If ARTICLE is an id, HEADER should be the article headers.
13775 If ALL-HEADERS is non-nil, no headers are hidden."
13777 ;; Make sure we start in a summary buffer.
13778 (unless (eq major-mode 'gnus-summary-mode)
13779 (set-buffer gnus-summary-buffer))
13780 (setq gnus-summary-buffer (current-buffer))
13781 ;; Make sure the connection to the server is alive.
13782 (unless (gnus-server-opened
13783 (gnus-find-method-for-group gnus-newsgroup-name))
13784 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
13785 (gnus-request-group gnus-newsgroup-name t))
13786 (let* ((article (if header (mail-header-number header) article))
13787 (summary-buffer (current-buffer))
13788 (internal-hook gnus-article-internal-prepare-hook)
13789 (group gnus-newsgroup-name)
13792 (gnus-article-setup-buffer)
13793 (set-buffer gnus-article-buffer)
13794 ;; Deactivate active regions.
13795 (when (and (boundp 'transient-mark-mode)
13796 transient-mark-mode)
13797 (setq mark-active nil))
13798 (if (not (setq result (let ((buffer-read-only nil))
13799 (gnus-request-article-this-buffer
13801 ;; There is no such article.
13803 (when (and (numberp article)
13804 (not (memq article gnus-newsgroup-sparse)))
13805 (setq gnus-article-current
13806 (cons gnus-newsgroup-name article))
13807 (set-buffer gnus-summary-buffer)
13808 (setq gnus-current-article article)
13809 (gnus-summary-mark-article article gnus-canceled-mark))
13810 (unless (memq article gnus-newsgroup-sparse)
13812 1 "No such article (may have expired or been canceled)")))
13813 (if (or (eq result 'pseudo) (eq result 'nneething))
13816 (set-buffer summary-buffer)
13817 (setq gnus-last-article gnus-current-article
13818 gnus-newsgroup-history (cons gnus-current-article
13819 gnus-newsgroup-history)
13820 gnus-current-article 0
13821 gnus-current-headers nil
13822 gnus-article-current nil)
13823 (if (eq result 'nneething)
13824 (gnus-configure-windows 'summary)
13825 (gnus-configure-windows 'article))
13826 (gnus-set-global-variables))
13827 (gnus-set-mode-line 'article))
13828 ;; The result from the `request' was an actual article -
13829 ;; or at least some text that is now displayed in the
13831 (if (and (numberp article)
13832 (not (eq article gnus-current-article)))
13833 ;; Seems like a new article has been selected.
13834 ;; `gnus-current-article' must be an article number.
13836 (set-buffer summary-buffer)
13837 (setq gnus-last-article gnus-current-article
13838 gnus-newsgroup-history (cons gnus-current-article
13839 gnus-newsgroup-history)
13840 gnus-current-article article
13841 gnus-current-headers
13842 (gnus-summary-article-header gnus-current-article)
13843 gnus-article-current
13844 (cons gnus-newsgroup-name gnus-current-article))
13845 (unless (vectorp gnus-current-headers)
13846 (setq gnus-current-headers nil))
13847 (gnus-summary-show-thread)
13848 (run-hooks 'gnus-mark-article-hook)
13849 (gnus-set-mode-line 'summary)
13850 (and (gnus-visual-p 'article-highlight 'highlight)
13851 (run-hooks 'gnus-visual-mark-article-hook))
13852 ;; Set the global newsgroup variables here.
13853 ;; Suggested by Jim Sisolak
13854 ;; <sisolak@trans4.neep.wisc.edu>.
13855 (gnus-set-global-variables)
13856 (setq gnus-have-all-headers
13857 (or all-headers gnus-show-all-headers))
13858 (and gnus-use-cache
13859 (vectorp (gnus-summary-article-header article))
13860 (gnus-cache-possibly-enter-article
13862 (gnus-summary-article-header article)
13863 (memq article gnus-newsgroup-marked)
13864 (memq article gnus-newsgroup-dormant)
13865 (memq article gnus-newsgroup-unreads)))))
13866 (when (or (numberp article)
13868 ;; Hooks for getting information from the article.
13869 ;; This hook must be called before being narrowed.
13870 (let (buffer-read-only)
13871 (run-hooks 'internal-hook)
13872 (run-hooks 'gnus-article-prepare-hook)
13873 ;; Decode MIME message.
13875 (if (or (not gnus-strict-mime)
13876 (gnus-fetch-field "Mime-Version"))
13877 (funcall gnus-show-mime-method)
13878 (funcall gnus-decode-encoded-word-method)))
13879 ;; Perform the article display hooks.
13880 (run-hooks 'gnus-article-display-hook))
13882 (goto-char (point-min))
13883 (and gnus-break-pages (gnus-narrow-to-page)))
13884 (gnus-set-mode-line 'article)
13885 (gnus-configure-windows 'article)
13886 (goto-char (point-min))
13889 (defun gnus-article-show-all-headers ()
13890 "Show all article headers in article mode buffer."
13892 (gnus-article-setup-buffer)
13893 (set-buffer gnus-article-buffer)
13894 (let ((buffer-read-only nil))
13895 (gnus-unhide-text (point-min) (point-max)))))
13897 (defun gnus-article-hide-headers-if-wanted ()
13898 "Hide unwanted headers if `gnus-have-all-headers' is nil.
13899 Provided for backwards compatibility."
13900 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers)
13901 gnus-inhibit-hiding
13902 (gnus-article-hide-headers)))
13904 (defsubst gnus-article-header-rank ()
13905 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
13906 (let ((list gnus-sorted-header-list)
13909 (when (looking-at (car list))
13911 (setq list (cdr list))
13915 (defun gnus-article-hide-headers (&optional arg delete)
13916 "Toggle whether to hide unwanted headers and possibly sort them as well.
13917 If given a negative prefix, always show; if given a positive prefix,
13919 (interactive (gnus-hidden-arg))
13920 (if (gnus-article-check-hidden-text 'headers arg)
13921 ;; Show boring headers as well.
13922 (gnus-article-show-hidden-text 'boring-headers)
13923 ;; This function might be inhibited.
13924 (unless gnus-inhibit-hiding
13926 (set-buffer gnus-article-buffer)
13928 (let ((buffer-read-only nil)
13929 (props (nconc (list 'gnus-type 'headers)
13930 gnus-hidden-properties))
13931 (max (1+ (length gnus-sorted-header-list)))
13932 (ignored (when (not (stringp gnus-visible-headers))
13933 (cond ((stringp gnus-ignored-headers)
13934 gnus-ignored-headers)
13935 ((listp gnus-ignored-headers)
13936 (mapconcat 'identity gnus-ignored-headers
13939 (cond ((stringp gnus-visible-headers)
13940 gnus-visible-headers)
13941 ((and gnus-visible-headers
13942 (listp gnus-visible-headers))
13943 (mapconcat 'identity gnus-visible-headers "\\|"))))
13944 (inhibit-point-motion-hooks t)
13946 ;; First we narrow to just the headers.
13948 (goto-char (point-min))
13949 ;; Hide any "From " lines at the beginning of (mail) articles.
13950 (while (looking-at "From ")
13954 (delete-region (point-min) (point))
13955 (gnus-hide-text (point-min) (point) props)))
13956 ;; Then treat the rest of the header lines.
13959 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
13960 ;; Then we use the two regular expressions
13961 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
13962 ;; select which header lines is to remain visible in the
13964 (goto-char (point-min))
13965 (while (re-search-forward "^[^ \t]*:" nil t)
13966 (beginning-of-line)
13967 ;; We add the headers we want to keep to a list and delete
13968 ;; them from the buffer.
13969 (gnus-put-text-property
13970 (point) (1+ (point)) 'message-rank
13971 (if (or (and visible (looking-at visible))
13973 (not (looking-at ignored))))
13974 (gnus-article-header-rank)
13977 (message-sort-headers-1)
13978 (when (setq beg (text-property-any
13979 (point-min) (point-max) 'message-rank (+ 2 max)))
13980 ;; We make the unwanted headers invisible.
13982 (delete-region beg (point-max))
13983 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
13984 (gnus-hide-text-type beg (point-max) 'headers))
13985 ;; Work around XEmacs lossage.
13986 (gnus-put-text-property (point-min) beg 'invisible nil))))))))
13988 (defun gnus-article-hide-boring-headers (&optional arg)
13989 "Toggle hiding of headers that aren't very interesting.
13990 If given a negative prefix, always show; if given a positive prefix,
13992 (interactive (gnus-hidden-arg))
13993 (unless (gnus-article-check-hidden-text 'boring-headers arg)
13995 (set-buffer gnus-article-buffer)
13997 (let ((buffer-read-only nil)
13998 (list gnus-boring-article-headers)
13999 (inhibit-point-motion-hooks t)
14001 (nnheader-narrow-to-headers)
14003 (setq elem (pop list))
14004 (goto-char (point-min))
14006 ;; Hide empty headers.
14008 (while (re-search-forward "^[^:]+:[ \t]\n[^ \t]" nil t)
14010 (gnus-hide-text-type
14011 (progn (beginning-of-line) (point))
14014 (if (re-search-forward "^[^ \t]" nil t)
14015 (match-beginning 0)
14018 ;; Hide boring Newsgroups header.
14019 ((eq elem 'newsgroups)
14020 (when (equal (message-fetch-field "newsgroups")
14021 (gnus-group-real-name gnus-newsgroup-name))
14022 (gnus-article-hide-header "newsgroups")))
14023 ((eq elem 'followup-to)
14024 (when (equal (message-fetch-field "followup-to")
14025 (message-fetch-field "newsgroups"))
14026 (gnus-article-hide-header "followup-to")))
14027 ((eq elem 'reply-to)
14028 (let ((from (message-fetch-field "from"))
14029 (reply-to (message-fetch-field "reply-to")))
14033 (nth 1 (funcall gnus-extract-address-components from))
14034 (nth 1 (funcall gnus-extract-address-components
14036 (gnus-article-hide-header "reply-to"))))
14038 (let ((date (message-fetch-field "date")))
14040 (< (gnus-days-between date (current-time-string))
14042 (gnus-article-hide-header "date")))))))))))
14044 (defun gnus-article-hide-header (header)
14046 (goto-char (point-min))
14047 (when (re-search-forward (concat "^" header ":") nil t)
14048 (gnus-hide-text-type
14049 (progn (beginning-of-line) (point))
14052 (if (re-search-forward "^[^ \t]" nil t)
14053 (match-beginning 0)
14055 'boring-headers))))
14057 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
14058 (defun gnus-article-treat-overstrike ()
14059 "Translate overstrikes into bold text."
14062 (set-buffer gnus-article-buffer)
14063 (let ((buffer-read-only nil))
14064 (while (search-forward "\b" nil t)
14065 (let ((next (following-char))
14066 (previous (char-after (- (point) 2))))
14068 ((eq next previous)
14069 (gnus-put-text-property (- (point) 2) (point) 'invisible t)
14070 (gnus-put-text-property (point) (1+ (point)) 'face 'bold))
14072 (gnus-put-text-property (1- (point)) (1+ (point)) 'invisible t)
14073 (gnus-put-text-property
14074 (- (point) 2) (1- (point)) 'face 'underline))
14076 (gnus-put-text-property (- (point) 2) (point) 'invisible t)
14077 (gnus-put-text-property
14078 (point) (1+ (point)) 'face 'underline))))))))
14080 (defun gnus-article-word-wrap ()
14081 "Format too long lines."
14084 (set-buffer gnus-article-buffer)
14085 (let ((buffer-read-only nil))
14087 (goto-char (point-min))
14088 (search-forward "\n\n" nil t)
14090 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
14091 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
14092 (adaptive-fill-mode t))
14093 (while (not (eobp))
14094 (and (>= (current-column) (min fill-column (window-width)))
14095 (/= (preceding-char) ?:)
14096 (fill-paragraph nil))
14097 (end-of-line 2))))))
14099 (defun gnus-article-remove-cr ()
14100 "Remove carriage returns from an article."
14103 (set-buffer gnus-article-buffer)
14104 (let ((buffer-read-only nil))
14105 (goto-char (point-min))
14106 (while (search-forward "\r" nil t)
14107 (replace-match "" t t)))))
14109 (defun gnus-article-remove-trailing-blank-lines ()
14110 "Remove all trailing blank lines from the article."
14113 (set-buffer gnus-article-buffer)
14114 (let ((buffer-read-only nil))
14115 (goto-char (point-max))
14119 (while (looking-at "^[ \t]*$")
14124 (defun gnus-article-display-x-face (&optional force)
14125 "Look for an X-Face header and display it if present."
14126 (interactive (list 'force))
14128 (set-buffer gnus-article-buffer)
14129 ;; Delete the old process, if any.
14130 (when (process-status "gnus-x-face")
14131 (delete-process "gnus-x-face"))
14132 (let ((inhibit-point-motion-hooks t)
14133 (case-fold-search nil)
14136 (nnheader-narrow-to-headers)
14137 (setq from (message-fetch-field "from"))
14138 (goto-char (point-min))
14139 (when (and gnus-article-x-face-command
14141 ;; Check whether this face is censored.
14142 (not gnus-article-x-face-too-ugly)
14143 (and gnus-article-x-face-too-ugly from
14144 (not (string-match gnus-article-x-face-too-ugly
14146 ;; Has to be present.
14147 (re-search-forward "^X-Face: " nil t))
14148 ;; We now have the area of the buffer where the X-Face is stored.
14149 (let ((beg (point))
14150 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
14151 ;; We display the face.
14152 (if (symbolp gnus-article-x-face-command)
14153 ;; The command is a lisp function, so we call it.
14154 (if (gnus-functionp gnus-article-x-face-command)
14155 (funcall gnus-article-x-face-command beg end)
14156 (error "%s is not a function" gnus-article-x-face-command))
14157 ;; The command is a string, so we interpret the command
14158 ;; as a, well, command, and fork it off.
14159 (let ((process-connection-type nil))
14160 (process-kill-without-query
14162 "gnus-x-face" nil shell-file-name shell-command-switch
14163 gnus-article-x-face-command))
14164 (process-send-region "gnus-x-face" beg end)
14165 (process-send-eof "gnus-x-face")))))))))
14167 (defalias 'gnus-headers-decode-quoted-printable 'gnus-decode-rfc1522)
14168 (defun gnus-decode-rfc1522 ()
14169 "Hack to remove QP encoding from headers."
14170 (let ((case-fold-search t)
14171 (inhibit-point-motion-hooks t)
14172 (buffer-read-only nil)
14176 (goto-char (point-min))
14177 (or (search-forward "\n\n" nil t) (point-max)))
14179 (while (re-search-forward
14180 "=\\?iso-8859-1\\?q\\?\\([^?\t\n]*\\)\\?=" nil t)
14181 (setq string (match-string 1))
14182 (narrow-to-region (match-beginning 0) (match-end 0))
14183 (delete-region (point-min) (point-max))
14185 (gnus-mime-decode-quoted-printable (goto-char (point-min)) (point-max))
14186 (subst-char-in-region (point-min) (point-max) ?_ ? )
14188 (goto-char (point-min))))))
14190 (defun gnus-article-de-quoted-unreadable (&optional force)
14191 "Do a naive translation of a quoted-printable-encoded article.
14192 This is in no way, shape or form meant as a replacement for real MIME
14193 processing, but is simply a stop-gap measure until MIME support is
14195 If FORCE, decode the article whether it is marked as quoted-printable
14197 (interactive (list 'force))
14199 (set-buffer gnus-article-buffer)
14200 (let ((case-fold-search t)
14201 (buffer-read-only nil)
14202 (type (gnus-fetch-field "content-transfer-encoding")))
14203 (gnus-decode-rfc1522)
14205 (and type (string-match "quoted-printable" (downcase type))))
14206 (goto-char (point-min))
14207 (search-forward "\n\n" nil 'move)
14208 (gnus-mime-decode-quoted-printable (point) (point-max))))))
14210 (defun gnus-mime-decode-quoted-printable (from to)
14211 "Decode Quoted-Printable in the region between FROM and TO."
14214 (while (search-forward "=" to t)
14215 (cond ((eq (following-char) ?\n)
14218 ((looking-at "[0-9A-F][0-9A-F]")
14219 (subst-char-in-region
14220 (1- (point)) (point) ?=
14221 (hexl-hex-string-to-integer
14222 (buffer-substring (point) (+ 2 (point)))))
14226 ((gnus-message 3 "Malformed MIME quoted-printable message")))))
14228 (defun gnus-article-hide-pgp (&optional arg)
14229 "Toggle hiding of any PGP headers and signatures in the current article.
14230 If given a negative prefix, always show; if given a positive prefix,
14232 (interactive (gnus-hidden-arg))
14233 (unless (gnus-article-check-hidden-text 'pgp arg)
14235 (set-buffer gnus-article-buffer)
14236 (let ((props (nconc (list 'gnus-type 'pgp) gnus-hidden-properties))
14237 buffer-read-only beg end)
14239 (goto-char (point-min))
14240 ;; Hide the "header".
14241 (and (search-forward "\n-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
14242 (gnus-hide-text (match-beginning 0) (match-end 0) props))
14244 ;; Hide the actual signature.
14245 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
14246 (setq end (1+ (match-beginning 0)))
14249 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
14251 ;; Perhaps we shouldn't hide to the end of the buffer
14252 ;; if there is no end to the signature?
14255 ;; Hide "- " PGP quotation markers.
14256 (when (and beg end)
14257 (narrow-to-region beg end)
14258 (goto-char (point-min))
14259 (while (re-search-forward "^- " nil t)
14260 (gnus-hide-text (match-beginning 0) (match-end 0) props))
14263 (defun gnus-article-hide-signature (&optional arg)
14264 "Hide the signature in the current article.
14265 If given a negative prefix, always show; if given a positive prefix,
14267 (interactive (gnus-hidden-arg))
14268 (unless (gnus-article-check-hidden-text 'signature arg)
14270 (set-buffer gnus-article-buffer)
14272 (let ((buffer-read-only nil))
14273 (when (gnus-narrow-to-signature)
14274 (gnus-hide-text-type (point-min) (point-max) 'signature)))))))
14276 (defun gnus-article-strip-leading-blank-lines ()
14277 "Remove all blank lines from the beginning of the article."
14280 (set-buffer gnus-article-buffer)
14281 (let (buffer-read-only)
14282 (goto-char (point-min))
14283 (when (search-forward "\n\n" nil t)
14284 (while (looking-at "[ \t]$")
14285 (gnus-delete-line))))))
14287 (defvar mime::preview/content-list)
14288 (defvar mime::preview-content-info/point-min)
14289 (defun gnus-narrow-to-signature ()
14290 "Narrow to the signature."
14292 (if (and (boundp 'mime::preview/content-list)
14293 mime::preview/content-list)
14294 (let ((pcinfo (car (last mime::preview/content-list))))
14297 (funcall (intern "mime::preview-content-info/point-min") pcinfo)
14300 (goto-char (point-max))
14301 (when (re-search-backward gnus-signature-separator nil t)
14303 (when (or (null gnus-signature-limit)
14304 (and (numberp gnus-signature-limit)
14305 (< (- (point-max) (point)) gnus-signature-limit))
14306 (and (gnus-functionp gnus-signature-limit)
14307 (funcall gnus-signature-limit))
14308 (and (stringp gnus-signature-limit)
14309 (not (re-search-forward gnus-signature-limit nil t))))
14310 (narrow-to-region (point) (point-max))
14313 (defun gnus-hidden-arg ()
14314 "Return the current prefix arg as a number, or 0 if no prefix."
14315 (list (if current-prefix-arg
14316 (prefix-numeric-value current-prefix-arg)
14319 (defun gnus-article-check-hidden-text (type arg)
14320 "Return nil if hiding is necessary.
14321 Arg can be nil or a number. Nil and positive means hide, negative
14322 means show, 0 means toggle."
14324 (set-buffer gnus-article-buffer)
14325 (let ((hide (gnus-article-hidden-text-p type)))
14331 (gnus-article-show-hidden-text type))
14333 (if (eq hide 'hidden)
14334 (gnus-article-show-hidden-text type)
14337 (defun gnus-article-hidden-text-p (type)
14338 "Say whether the current buffer contains hidden text of type TYPE."
14339 (let ((pos (text-property-any (point-min) (point-max) 'gnus-type type)))
14341 (if (get-text-property pos 'invisible)
14345 (defun gnus-article-hide (&optional arg force)
14346 "Hide all the gruft in the current article.
14347 This means that PGP stuff, signatures, cited text and (some)
14348 headers will be hidden.
14349 If given a prefix, show the hidden text instead."
14350 (interactive (list current-prefix-arg 'force))
14351 (gnus-article-hide-headers arg)
14352 (gnus-article-hide-pgp arg)
14353 (gnus-article-hide-citation-maybe arg force)
14354 (gnus-article-hide-signature arg))
14356 (defun gnus-article-show-hidden-text (type &optional hide)
14357 "Show all hidden text of type TYPE.
14358 If HIDE, hide the text instead."
14360 (set-buffer gnus-article-buffer)
14361 (let ((buffer-read-only nil)
14362 (inhibit-point-motion-hooks t)
14364 (while (gnus-goto-char (text-property-any
14365 beg (point-max) 'gnus-type type))
14369 (gnus-hide-text beg (point) gnus-hidden-properties)
14370 (gnus-unhide-text beg (point)))
14371 (setq beg (point)))
14374 (defvar gnus-article-time-units
14375 `((year . ,(* 365.25 24 60 60))
14376 (week . ,(* 7 24 60 60))
14377 (day . ,(* 24 60 60))
14378 (hour . ,(* 60 60))
14381 "Mapping from time units to seconds.")
14383 (defun gnus-article-date-ut (&optional type highlight)
14384 "Convert DATE date to universal time in the current article.
14385 If TYPE is `local', convert to local time; if it is `lapsed', output
14386 how much time has lapsed since DATE."
14387 (interactive (list 'ut t))
14388 (let* ((header (or gnus-current-headers
14389 (gnus-summary-article-header) ""))
14390 (date (and (vectorp header) (mail-header-date header)))
14391 (date-regexp "^Date: \\|^X-Sent: ")
14392 (now (current-time))
14393 (inhibit-point-motion-hooks t)
14395 (when (and date (not (string= date "")))
14397 (set-buffer gnus-article-buffer)
14399 (nnheader-narrow-to-headers)
14400 (let ((buffer-read-only nil))
14401 ;; Delete any old Date headers.
14402 (if (re-search-forward date-regexp nil t)
14404 (setq bface (get-text-property (gnus-point-at-bol) 'face)
14405 eface (get-text-property (1- (gnus-point-at-eol))
14407 (message-remove-header date-regexp t)
14408 (beginning-of-line))
14409 (goto-char (point-max)))
14410 (insert (gnus-make-date-line date type))
14411 ;; Do highlighting.
14413 (when (and (gnus-visual-p 'article-highlight 'highlight)
14414 (looking-at "\\([^:]+\\): *\\(.*\\)$"))
14415 (gnus-put-text-property (match-beginning 1) (match-end 1)
14417 (gnus-put-text-property (match-beginning 2) (match-end 2)
14418 'face eface))))))))
14420 (defun gnus-make-date-line (date type)
14421 "Return a DATE line of TYPE."
14423 ;; Convert to the local timezone. We have to slap a
14424 ;; `condition-case' round the calls to the timezone
14425 ;; functions since they aren't particularly resistant to
14428 (concat "Date: " (condition-case ()
14429 (timezone-make-date-arpa-standard date)
14432 ;; Convert to Universal Time.
14436 (timezone-make-date-arpa-standard date nil "UT")
14439 ;; Get the original date from the article.
14440 ((eq type 'original)
14441 (concat "Date: " date "\n"))
14442 ;; Do an X-Sent lapsed format.
14444 ;; If the date is seriously mangled, the timezone
14445 ;; functions are liable to bug out, so we condition-case
14446 ;; the entire thing.
14447 (let* ((now (current-time))
14452 (timezone-make-date-arpa-standard
14453 (current-time-string now)
14454 (current-time-zone now) "UT"))
14456 (timezone-make-date-arpa-standard
14459 (real-sec (+ (* (float (car real-time)) 65536)
14461 (sec (abs real-sec))
14464 ((equal real-time '(0 0))
14465 "X-Sent: Unknown\n")
14471 ;; This is a bit convoluted, but basically we go
14472 ;; through the time units for years, weeks, etc,
14473 ;; and divide things to see whether that results
14474 ;; in positive answers.
14477 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
14478 ;; The (remaining) seconds are too few to
14479 ;; be divided into this time unit.
14481 ;; It's big enough, so we output it.
14482 (setq sec (- sec (* num (cdr unit))))
14484 (concat (if prev ", " "") (int-to-string
14486 " " (symbol-name (car unit))
14487 (if (> num 1) "s" ""))
14489 gnus-article-time-units "")
14490 ;; If dates are odd, then it might appear like the
14491 ;; article was sent in the future.
14494 " in the future\n"))))))
14496 (error "Unknown conversion type: %s" type))))
14498 (defun gnus-article-date-local (&optional highlight)
14499 "Convert the current article date to the local timezone."
14500 (interactive (list t))
14501 (gnus-article-date-ut 'local highlight))
14503 (defun gnus-article-date-original (&optional highlight)
14504 "Convert the current article date to what it was originally.
14505 This is only useful if you have used some other date conversion
14506 function and want to see what the date was before converting."
14507 (interactive (list t))
14508 (gnus-article-date-ut 'original highlight))
14510 (defun gnus-article-date-lapsed (&optional highlight)
14511 "Convert the current article date to time lapsed since it was sent."
14512 (interactive (list t))
14513 (gnus-article-date-ut 'lapsed highlight))
14515 (defun gnus-article-maybe-highlight ()
14516 "Do some article highlighting if `gnus-visual' is non-nil."
14517 (if (gnus-visual-p 'article-highlight 'highlight)
14518 (gnus-article-highlight-some)))
14520 ;;; Article savers.
14522 (defun gnus-output-to-rmail (file-name)
14523 "Append the current article to an Rmail file named FILE-NAME."
14525 ;; Most of these codes are borrowed from rmailout.el.
14526 (setq file-name (expand-file-name file-name))
14527 (setq rmail-default-rmail-file file-name)
14528 (let ((artbuf (current-buffer))
14529 (tmpbuf (get-buffer-create " *Gnus-output*")))
14531 (or (get-file-buffer file-name)
14532 (file-exists-p file-name)
14533 (if (gnus-yes-or-no-p
14534 (concat "\"" file-name "\" does not exist, create it? "))
14535 (let ((file-buffer (create-file-buffer file-name)))
14537 (set-buffer file-buffer)
14538 (rmail-insert-rmail-file-header)
14539 (let ((require-final-newline nil))
14540 (write-region (point-min) (point-max) file-name t 1)))
14541 (kill-buffer file-buffer))
14542 (error "Output file does not exist")))
14543 (set-buffer tmpbuf)
14544 (buffer-disable-undo (current-buffer))
14546 (insert-buffer-substring artbuf)
14547 (gnus-convert-article-to-rmail)
14548 ;; Decide whether to append to a file or to an Emacs buffer.
14549 (let ((outbuf (get-file-buffer file-name)))
14551 (append-to-file (point-min) (point-max) file-name)
14552 ;; File has been visited, in buffer OUTBUF.
14553 (set-buffer outbuf)
14554 (let ((buffer-read-only nil)
14555 (msg (and (boundp 'rmail-current-message)
14556 (symbol-value 'rmail-current-message))))
14557 ;; If MSG is non-nil, buffer is in RMAIL mode.
14560 (narrow-to-region (point-max) (point-max))))
14561 (insert-buffer-substring tmpbuf)
14564 (goto-char (point-min))
14566 (search-backward "\^_")
14567 (narrow-to-region (point) (point-max))
14568 (goto-char (1+ (point-min)))
14569 (rmail-count-new-messages t)
14570 (rmail-show-message msg)))))))
14571 (kill-buffer tmpbuf)))
14573 (defun gnus-output-to-file (file-name)
14574 "Append the current article to a file named FILE-NAME."
14575 (let ((artbuf (current-buffer)))
14576 (nnheader-temp-write nil
14577 (insert-buffer-substring artbuf)
14578 ;; Append newline at end of the buffer as separator, and then
14579 ;; save it to file.
14580 (goto-char (point-max))
14582 (append-to-file (point-min) (point-max) file-name))))
14584 (defun gnus-convert-article-to-rmail ()
14585 "Convert article in current buffer to Rmail message format."
14586 (let ((buffer-read-only nil))
14587 ;; Convert article directly into Babyl format.
14588 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
14589 (goto-char (point-min))
14590 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
14591 (while (search-forward "\n\^_" nil t) ;single char
14592 (replace-match "\n^_" t t)) ;2 chars: "^" and "_"
14593 (goto-char (point-max))
14596 (defun gnus-narrow-to-page (&optional arg)
14597 "Narrow the article buffer to a page.
14598 If given a numerical ARG, move forward ARG pages."
14600 (setq arg (if arg (prefix-numeric-value arg) 0))
14602 (set-buffer gnus-article-buffer)
14603 (goto-char (point-min))
14605 (when (gnus-visual-p 'page-marker)
14606 (let ((buffer-read-only nil))
14607 (gnus-remove-text-with-property 'gnus-prev)
14608 (gnus-remove-text-with-property 'gnus-next)))
14611 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
14613 (re-search-forward page-delimiter nil 'move arg)))
14614 (goto-char (match-end 0)))
14617 (if (re-search-forward page-delimiter nil 'move)
14618 (match-beginning 0)
14620 (when (and (gnus-visual-p 'page-marker)
14621 (not (= (point-min) 1)))
14623 (goto-char (point-min))
14624 (gnus-insert-prev-page-button)))
14625 (when (and (gnus-visual-p 'page-marker)
14626 (not (= (1- (point-max)) (buffer-size))))
14628 (goto-char (point-max))
14629 (gnus-insert-next-page-button)))))
14631 ;; Article mode commands
14633 (defun gnus-article-goto-next-page ()
14634 "Show the next page of the article."
14636 (when (gnus-article-next-page)
14637 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
14639 (defun gnus-article-goto-prev-page ()
14640 "Show the next page of the article."
14642 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))
14643 (gnus-article-prev-page nil)))
14645 (defun gnus-article-next-page (&optional lines)
14646 "Show the next page of the current article.
14647 If end of article, return non-nil. Otherwise return nil.
14648 Argument LINES specifies lines to be scrolled up."
14650 (move-to-window-line -1)
14651 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
14652 (if (save-excursion
14654 (and (pos-visible-in-window-p) ;Not continuation line.
14656 ;; Nothing in this page.
14657 (if (or (not gnus-break-pages)
14660 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
14662 (gnus-narrow-to-page 1) ;Go to next page.
14664 ;; More in this page.
14668 ;; Long lines may cause an end-of-buffer error.
14669 (goto-char (point-max))))
14670 (move-to-window-line 0)
14673 (defun gnus-article-prev-page (&optional lines)
14674 "Show previous page of current article.
14675 Argument LINES specifies lines to be scrolled down."
14677 (move-to-window-line 0)
14678 (if (and gnus-break-pages
14680 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
14682 (gnus-narrow-to-page -1) ;Go to previous page.
14683 (goto-char (point-max))
14687 (scroll-down lines)
14689 (move-to-window-line 0))))
14691 (defun gnus-article-refer-article ()
14692 "Read article specified by message-id around point."
14694 (let ((point (point)))
14695 (search-forward ">" nil t) ;Move point to end of "<....>".
14696 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
14697 (let ((message-id (match-string 1)))
14699 (set-buffer gnus-summary-buffer)
14700 (gnus-summary-refer-article message-id))
14701 (goto-char (point))
14702 (error "No references around point"))))
14704 (defun gnus-article-show-summary ()
14705 "Reconfigure windows to show summary buffer."
14707 (gnus-configure-windows 'article)
14708 (gnus-summary-goto-subject gnus-current-article))
14710 (defun gnus-article-describe-briefly ()
14711 "Describe article mode commands briefly."
14714 (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")))
14716 (defun gnus-article-summary-command ()
14717 "Execute the last keystroke in the summary buffer."
14719 (let ((obuf (current-buffer))
14720 (owin (current-window-configuration))
14722 (switch-to-buffer gnus-summary-buffer 'norecord)
14723 (setq func (lookup-key (current-local-map) (this-command-keys)))
14724 (call-interactively func)
14726 (set-window-configuration owin)
14727 (set-window-point (get-buffer-window (current-buffer)) (point))))
14729 (defun gnus-article-summary-command-nosave ()
14730 "Execute the last keystroke in the summary buffer."
14733 (pop-to-buffer gnus-summary-buffer 'norecord)
14734 (setq func (lookup-key (current-local-map) (this-command-keys)))
14735 (call-interactively func)))
14737 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
14738 "Read a summary buffer key sequence and execute it from the article buffer."
14741 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
14742 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
14743 "=" "^" "\M-^" "|"))
14746 (set-buffer gnus-summary-buffer)
14747 (push (or key last-command-event) unread-command-events)
14748 (setq keys (read-key-sequence nil)))
14751 (if (member keys nosaves)
14753 (pop-to-buffer gnus-summary-buffer 'norecord)
14754 (if (setq func (lookup-key (current-local-map) keys))
14755 (call-interactively func)
14757 (let ((obuf (current-buffer))
14758 (owin (current-window-configuration))
14761 (if not-restore-window
14762 (pop-to-buffer gnus-summary-buffer 'norecord)
14763 (switch-to-buffer gnus-summary-buffer 'norecord))
14764 (setq in-buffer (current-buffer))
14765 (if (setq func (lookup-key (current-local-map) keys))
14766 (call-interactively func)
14768 (when (eq in-buffer (current-buffer))
14770 (unless not-restore-window
14771 (set-window-configuration owin))
14772 (set-window-point (get-buffer-window (current-buffer)) opoint))))))
14776 ;;; Kill file handling.
14780 (defalias 'gnus-batch-kill 'gnus-batch-score)
14782 (defun gnus-batch-score ()
14783 "Run batched scoring.
14784 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
14785 Newsgroups is a list of strings in Bnews format. If you want to score
14786 the comp hierarchy, you'd say \"comp.all\". If you would not like to
14787 score the alt hierarchy, you'd say \"!alt.all\"."
14790 (gnus-newsrc-parse-options
14791 (apply (function concat)
14792 (mapcar (lambda (g) (concat g " "))
14793 command-line-args-left))))
14794 (gnus-expert-user t)
14795 (nnmail-spool-file nil)
14796 (gnus-use-dribble-file nil)
14797 (yes (car yes-and-no))
14798 (no (cdr yes-and-no))
14800 ;; Disable verbose message.
14801 gnus-novice-user gnus-large-newsgroup)
14802 ;; Eat all arguments.
14803 (setq command-line-args-left nil)
14806 ;; Apply kills to specified newsgroups in command line arguments.
14807 (setq newsrc (cdr gnus-newsrc-alist))
14809 (setq group (caar newsrc))
14810 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
14811 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed)
14813 (or (eq (car entry) t)
14814 (not (zerop (car entry)))))
14815 (if yes (string-match yes group) t)
14816 (or (null no) (not (string-match no group))))
14818 (gnus-summary-read-group group nil t nil t)
14819 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
14820 (gnus-summary-exit))))
14821 (setq newsrc (cdr newsrc)))
14823 (switch-to-buffer gnus-group-buffer)
14824 (gnus-group-save-newsrc)))
14826 (defun gnus-apply-kill-file ()
14827 "Apply a kill file to the current newsgroup.
14828 Returns the number of articles marked as read."
14829 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
14830 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14831 (gnus-apply-kill-file-internal)
14834 (defun gnus-kill-save-kill-buffer ()
14835 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14836 (when (get-file-buffer file)
14838 (set-buffer (get-file-buffer file))
14839 (and (buffer-modified-p) (save-buffer))
14840 (kill-buffer (current-buffer))))))
14842 (defvar gnus-kill-file-name "KILL"
14843 "Suffix of the kill files.")
14845 (defun gnus-newsgroup-kill-file (newsgroup)
14846 "Return the name of a kill file name for NEWSGROUP.
14847 If NEWSGROUP is nil, return the global kill file name instead."
14849 ;; The global KILL file is placed at top of the directory.
14850 ((or (null newsgroup)
14851 (string-equal newsgroup ""))
14852 (expand-file-name gnus-kill-file-name
14853 gnus-kill-files-directory))
14854 ;; Append ".KILL" to newsgroup name.
14855 ((gnus-use-long-file-name 'not-kill)
14856 (expand-file-name (concat (gnus-newsgroup-savable-name newsgroup)
14857 "." gnus-kill-file-name)
14858 gnus-kill-files-directory))
14859 ;; Place "KILL" under the hierarchical directory.
14861 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
14862 "/" gnus-kill-file-name)
14863 gnus-kill-files-directory))))
14870 (defvar gnus-dribble-ignore nil)
14871 (defvar gnus-dribble-eval-file nil)
14873 (defun gnus-dribble-file-name ()
14874 "Return the dribble file for the current .newsrc."
14876 (if gnus-dribble-directory
14877 (concat (file-name-as-directory gnus-dribble-directory)
14878 (file-name-nondirectory gnus-current-startup-file))
14879 gnus-current-startup-file)
14882 (defun gnus-dribble-enter (string)
14883 "Enter STRING into the dribble buffer."
14884 (if (and (not gnus-dribble-ignore)
14885 gnus-dribble-buffer
14886 (buffer-name gnus-dribble-buffer))
14887 (let ((obuf (current-buffer)))
14888 (set-buffer gnus-dribble-buffer)
14889 (insert string "\n")
14890 (set-window-point (get-buffer-window (current-buffer)) (point-max))
14891 (set-buffer obuf))))
14893 (defun gnus-dribble-read-file ()
14894 "Read the dribble file from disk."
14895 (let ((dribble-file (gnus-dribble-file-name)))
14897 (set-buffer (setq gnus-dribble-buffer
14899 (file-name-nondirectory dribble-file))))
14900 (gnus-add-current-to-buffer-list)
14902 (setq buffer-file-name dribble-file)
14904 (buffer-disable-undo (current-buffer))
14905 (bury-buffer (current-buffer))
14906 (set-buffer-modified-p nil)
14907 (let ((auto (make-auto-save-file-name))
14908 (gnus-dribble-ignore t)
14910 (when (or (file-exists-p auto) (file-exists-p dribble-file))
14911 ;; Load whichever file is newest -- the auto save file
14912 ;; or the "real" file.
14913 (if (file-newer-than-file-p auto dribble-file)
14914 (insert-file-contents auto)
14915 (insert-file-contents dribble-file))
14916 (unless (zerop (buffer-size))
14917 (set-buffer-modified-p t))
14918 ;; Set the file modes to reflect the .newsrc file modes.
14920 (when (and (file-exists-p gnus-current-startup-file)
14921 (setq modes (file-modes gnus-current-startup-file)))
14922 (set-file-modes dribble-file modes))
14923 ;; Possibly eval the file later.
14924 (when (gnus-y-or-n-p
14925 "Auto-save file exists. Do you want to read it? ")
14926 (setq gnus-dribble-eval-file t)))))))
14928 (defun gnus-dribble-eval-file ()
14929 (when gnus-dribble-eval-file
14930 (setq gnus-dribble-eval-file nil)
14932 (let ((gnus-dribble-ignore t))
14933 (set-buffer gnus-dribble-buffer)
14934 (eval-buffer (current-buffer))))))
14936 (defun gnus-dribble-delete-file ()
14937 (when (file-exists-p (gnus-dribble-file-name))
14938 (delete-file (gnus-dribble-file-name)))
14939 (when gnus-dribble-buffer
14941 (set-buffer gnus-dribble-buffer)
14942 (let ((auto (make-auto-save-file-name)))
14943 (if (file-exists-p auto)
14944 (delete-file auto))
14946 (set-buffer-modified-p nil)))))
14948 (defun gnus-dribble-save ()
14949 (when (and gnus-dribble-buffer
14950 (buffer-name gnus-dribble-buffer))
14952 (set-buffer gnus-dribble-buffer)
14955 (defun gnus-dribble-clear ()
14956 (when (gnus-buffer-exists-p gnus-dribble-buffer)
14958 (set-buffer gnus-dribble-buffer)
14960 (set-buffer-modified-p nil)
14961 (setq buffer-saved-size (buffer-size)))))
14965 ;;; Server Communication
14968 (defun gnus-start-news-server (&optional confirm)
14969 "Open a method for getting news.
14970 If CONFIRM is non-nil, the user will be asked for an NNTP server."
14972 (if gnus-current-select-method
14973 ;; Stream is already opened.
14975 ;; Open NNTP server.
14976 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
14979 ;; Read server name with completion.
14980 (setq gnus-nntp-server
14981 (completing-read "NNTP server: "
14982 (mapcar (lambda (server) (list server))
14983 (cons (list gnus-nntp-server)
14984 gnus-secondary-servers))
14985 nil nil gnus-nntp-server))))
14987 (if (and gnus-nntp-server
14988 (stringp gnus-nntp-server)
14989 (not (string= gnus-nntp-server "")))
14990 (setq gnus-select-method
14991 (cond ((or (string= gnus-nntp-server "")
14992 (string= gnus-nntp-server "::"))
14993 (list 'nnspool (system-name)))
14994 ((string-match "^:" gnus-nntp-server)
14995 (list 'nnmh gnus-nntp-server
14996 (list 'nnmh-directory
14997 (file-name-as-directory
14999 (concat "~/" (substring
15000 gnus-nntp-server 1)))))
15001 (list 'nnmh-get-new-mail nil)))
15003 (list 'nntp gnus-nntp-server)))))
15005 (setq how (car gnus-select-method))
15006 (cond ((eq how 'nnspool)
15008 (gnus-message 5 "Looking up local news spool..."))
15011 (gnus-message 5 "Looking up mh spool..."))
15014 (setq gnus-current-select-method gnus-select-method)
15015 (run-hooks 'gnus-open-server-hook)
15017 ;; gnus-open-server-hook might have opened it
15018 (gnus-server-opened gnus-select-method)
15019 (gnus-open-server gnus-select-method)
15022 "%s (%s) open error: '%s'. Continue? "
15023 (car gnus-select-method) (cadr gnus-select-method)
15024 (gnus-status-message gnus-select-method)))
15025 (gnus-error 1 "Couldn't open server on %s"
15026 (nth 1 gnus-select-method))))))
15028 (defun gnus-check-group (group)
15029 "Try to make sure that the server where GROUP exists is alive."
15030 (let ((method (gnus-find-method-for-group group)))
15031 (or (gnus-server-opened method)
15032 (gnus-open-server method))))
15034 (defun gnus-check-server (&optional method silent)
15035 "Check whether the connection to METHOD is down.
15036 If METHOD is nil, use `gnus-select-method'.
15037 If it is down, start it up (again)."
15038 (let ((method (or method gnus-select-method)))
15039 ;; Transform virtual server names into select methods.
15040 (when (stringp method)
15041 (setq method (gnus-server-to-method method)))
15042 (if (gnus-server-opened method)
15043 ;; The stream is already opened.
15045 ;; Open the server.
15047 (gnus-message 5 "Opening %s server%s..." (car method)
15048 (if (equal (nth 1 method) "") ""
15049 (format " on %s" (nth 1 method)))))
15050 (run-hooks 'gnus-open-server-hook)
15052 (gnus-open-server method)
15056 (defun gnus-get-function (method function &optional noerror)
15057 "Return a function symbol based on METHOD and FUNCTION."
15058 ;; Translate server names into methods.
15060 (error "Attempted use of a nil select method"))
15061 (when (stringp method)
15062 (setq method (gnus-server-to-method method)))
15063 (let ((func (intern (format "%s-%s" (car method) function))))
15064 ;; If the functions isn't bound, we require the backend in
15066 (unless (fboundp func)
15067 (require (car method))
15068 (when (and (not (fboundp func))
15070 ;; This backend doesn't implement this function.
15071 (error "No such function: %s" func)))
15076 ;;; Interface functions to the backends.
15079 (defun gnus-open-server (method)
15080 "Open a connection to METHOD."
15081 (when (stringp method)
15082 (setq method (gnus-server-to-method method)))
15083 (let ((elem (assoc method gnus-opened-servers)))
15084 ;; If this method was previously denied, we just return nil.
15085 (if (eq (nth 1 elem) 'denied)
15087 (gnus-message 1 "Denied server")
15089 ;; Open the server.
15091 (funcall (gnus-get-function method 'open-server)
15092 (nth 1 method) (nthcdr 2 method))))
15093 ;; If this hasn't been opened before, we add it to the list.
15095 (setq elem (list method nil)
15096 gnus-opened-servers (cons elem gnus-opened-servers)))
15097 ;; Set the status of this server.
15098 (setcar (cdr elem) (if result 'ok 'denied))
15099 ;; Return the result from the "open" call.
15102 (defun gnus-close-server (method)
15103 "Close the connection to METHOD."
15104 (when (stringp method)
15105 (setq method (gnus-server-to-method method)))
15106 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
15108 (defun gnus-request-list (method)
15109 "Request the active file from METHOD."
15110 (when (stringp method)
15111 (setq method (gnus-server-to-method method)))
15112 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
15114 (defun gnus-request-list-newsgroups (method)
15115 "Request the newsgroups file from METHOD."
15116 (when (stringp method)
15117 (setq method (gnus-server-to-method method)))
15118 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
15120 (defun gnus-request-newgroups (date method)
15121 "Request all new groups since DATE from METHOD."
15122 (when (stringp method)
15123 (setq method (gnus-server-to-method method)))
15124 (funcall (gnus-get-function method 'request-newgroups)
15125 date (nth 1 method)))
15127 (defun gnus-server-opened (method)
15128 "Check whether a connection to METHOD has been opened."
15129 (when (stringp method)
15130 (setq method (gnus-server-to-method method)))
15131 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
15133 (defun gnus-status-message (method)
15134 "Return the status message from METHOD.
15135 If METHOD is a string, it is interpreted as a group name. The method
15136 this group uses will be queried."
15137 (let ((method (if (stringp method) (gnus-find-method-for-group method)
15139 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
15141 (defun gnus-request-group (group &optional dont-check method)
15142 "Request GROUP. If DONT-CHECK, no information is required."
15143 (let ((method (or method (gnus-find-method-for-group group))))
15144 (when (stringp method)
15145 (setq method (gnus-server-to-method method)))
15146 (funcall (gnus-get-function method 'request-group)
15147 (gnus-group-real-name group) (nth 1 method) dont-check)))
15149 (defun gnus-request-asynchronous (group &optional articles)
15150 "Request that GROUP behave asynchronously.
15151 ARTICLES is the `data' of the group."
15152 (let ((method (gnus-find-method-for-group group)))
15153 (funcall (gnus-get-function method 'request-asynchronous)
15154 (gnus-group-real-name group) (nth 1 method) articles)))
15156 (defun gnus-list-active-group (group)
15157 "Request active information on GROUP."
15158 (let ((method (gnus-find-method-for-group group))
15159 (func 'list-active-group))
15160 (when (gnus-check-backend-function func group)
15161 (funcall (gnus-get-function method func)
15162 (gnus-group-real-name group) (nth 1 method)))))
15164 (defun gnus-request-group-description (group)
15165 "Request a description of GROUP."
15166 (let ((method (gnus-find-method-for-group group))
15167 (func 'request-group-description))
15168 (when (gnus-check-backend-function func group)
15169 (funcall (gnus-get-function method func)
15170 (gnus-group-real-name group) (nth 1 method)))))
15172 (defun gnus-close-group (group)
15173 "Request the GROUP be closed."
15174 (let ((method (gnus-find-method-for-group group)))
15175 (funcall (gnus-get-function method 'close-group)
15176 (gnus-group-real-name group) (nth 1 method))))
15178 (defun gnus-retrieve-headers (articles group &optional fetch-old)
15179 "Request headers for ARTICLES in GROUP.
15180 If FETCH-OLD, retrieve all headers (or some subset thereof) in the group."
15181 (let ((method (gnus-find-method-for-group group)))
15182 (if (and gnus-use-cache (numberp (car articles)))
15183 (gnus-cache-retrieve-headers articles group fetch-old)
15184 (funcall (gnus-get-function method 'retrieve-headers)
15185 articles (gnus-group-real-name group) (nth 1 method)
15188 (defun gnus-retrieve-groups (groups method)
15189 "Request active information on GROUPS from METHOD."
15190 (when (stringp method)
15191 (setq method (gnus-server-to-method method)))
15192 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method)))
15194 (defun gnus-request-type (group &optional article)
15195 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
15196 (let ((method (gnus-find-method-for-group group)))
15197 (if (not (gnus-check-backend-function 'request-type (car method)))
15199 (funcall (gnus-get-function method 'request-type)
15200 (gnus-group-real-name group) article))))
15202 (defun gnus-request-update-mark (group article mark)
15203 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
15204 (let ((method (gnus-find-method-for-group group)))
15205 (if (not (gnus-check-backend-function 'request-update-mark (car method)))
15207 (funcall (gnus-get-function method 'request-update-mark)
15208 (gnus-group-real-name group) article mark))))
15210 (defun gnus-request-article (article group &optional buffer)
15211 "Request the ARTICLE in GROUP.
15212 ARTICLE can either be an article number or an article Message-ID.
15213 If BUFFER, insert the article in that group."
15214 (let ((method (gnus-find-method-for-group group)))
15215 (funcall (gnus-get-function method 'request-article)
15216 article (gnus-group-real-name group) (nth 1 method) buffer)))
15218 (defun gnus-request-head (article group)
15219 "Request the head of ARTICLE in GROUP."
15220 (let* ((method (gnus-find-method-for-group group))
15221 (head (gnus-get-function method 'request-head t)))
15223 (funcall head article (gnus-group-real-name group) (nth 1 method))
15224 (let ((res (gnus-request-article article group)))
15227 (set-buffer nntp-server-buffer)
15228 (goto-char (point-min))
15229 (when (search-forward "\n\n" nil t)
15230 (delete-region (1- (point)) (point-max)))
15231 (nnheader-fold-continuation-lines)))
15234 (defun gnus-request-body (article group)
15235 "Request the body of ARTICLE in GROUP."
15236 (let ((method (gnus-find-method-for-group group)))
15237 (funcall (gnus-get-function method 'request-body)
15238 article (gnus-group-real-name group) (nth 1 method))))
15240 (defun gnus-request-post (method)
15241 "Post the current buffer using METHOD."
15242 (when (stringp method)
15243 (setq method (gnus-server-to-method method)))
15244 (funcall (gnus-get-function method 'request-post) (nth 1 method)))
15246 (defun gnus-request-scan (group method)
15247 "Request a SCAN being performed in GROUP from METHOD.
15248 If GROUP is nil, all groups on METHOD are scanned."
15249 (let ((method (if group (gnus-find-method-for-group group) method)))
15250 (funcall (gnus-get-function method 'request-scan)
15251 (and group (gnus-group-real-name group)) (nth 1 method))))
15253 (defsubst gnus-request-update-info (info method)
15254 "Request that METHOD update INFO."
15255 (when (stringp method)
15256 (setq method (gnus-server-to-method method)))
15257 (when (gnus-check-backend-function 'request-update-info (car method))
15258 (funcall (gnus-get-function method 'request-update-info)
15259 (gnus-group-real-name (gnus-info-group info))
15260 info (nth 1 method))))
15262 (defun gnus-request-expire-articles (articles group &optional force)
15263 (let ((method (gnus-find-method-for-group group)))
15264 (funcall (gnus-get-function method 'request-expire-articles)
15265 articles (gnus-group-real-name group) (nth 1 method)
15268 (defun gnus-request-move-article
15269 (article group server accept-function &optional last)
15270 (let ((method (gnus-find-method-for-group group)))
15271 (funcall (gnus-get-function method 'request-move-article)
15272 article (gnus-group-real-name group)
15273 (nth 1 method) accept-function last)))
15275 (defun gnus-request-accept-article (group method &optional last)
15276 ;; Make sure there's a newline at the end of the article.
15277 (when (stringp method)
15278 (setq method (gnus-server-to-method method)))
15279 (when (and (not method)
15281 (setq method (gnus-find-method-for-group group)))
15282 (goto-char (point-max))
15285 (let ((func (car (or method (gnus-find-method-for-group group)))))
15286 (funcall (intern (format "%s-request-accept-article" func))
15287 (if (stringp group) (gnus-group-real-name group) group)
15291 (defun gnus-request-replace-article (article group buffer)
15292 (let ((func (car (gnus-find-method-for-group group))))
15293 (funcall (intern (format "%s-request-replace-article" func))
15294 article (gnus-group-real-name group) buffer)))
15296 (defun gnus-request-associate-buffer (group)
15297 (let ((method (gnus-find-method-for-group group)))
15298 (funcall (gnus-get-function method 'request-associate-buffer)
15299 (gnus-group-real-name group))))
15301 (defun gnus-request-restore-buffer (article group)
15302 "Request a new buffer restored to the state of ARTICLE."
15303 (let ((method (gnus-find-method-for-group group)))
15304 (funcall (gnus-get-function method 'request-restore-buffer)
15305 article (gnus-group-real-name group) (nth 1 method))))
15307 (defun gnus-request-create-group (group &optional method)
15308 (when (stringp method)
15309 (setq method (gnus-server-to-method method)))
15310 (let ((method (or method (gnus-find-method-for-group group))))
15311 (funcall (gnus-get-function method 'request-create-group)
15312 (gnus-group-real-name group) (nth 1 method))))
15314 (defun gnus-request-delete-group (group &optional force)
15315 (let ((method (gnus-find-method-for-group group)))
15316 (funcall (gnus-get-function method 'request-delete-group)
15317 (gnus-group-real-name group) force (nth 1 method))))
15319 (defun gnus-request-rename-group (group new-name)
15320 (let ((method (gnus-find-method-for-group group)))
15321 (funcall (gnus-get-function method 'request-rename-group)
15322 (gnus-group-real-name group)
15323 (gnus-group-real-name new-name) (nth 1 method))))
15325 (defun gnus-member-of-valid (symbol group)
15326 "Find out if GROUP has SYMBOL as part of its \"valid\" spec."
15327 (memq symbol (assoc
15328 (symbol-name (car (gnus-find-method-for-group group)))
15329 gnus-valid-select-methods)))
15331 (defun gnus-method-option-p (method option)
15332 "Return non-nil if select METHOD has OPTION as a parameter."
15333 (when (stringp method)
15334 (setq method (gnus-server-to-method method)))
15335 (memq option (assoc (format "%s" (car method))
15336 gnus-valid-select-methods)))
15338 (defun gnus-server-extend-method (group method)
15339 ;; This function "extends" a virtual server. If the server is
15340 ;; "hello", and the select method is ("hello" (my-var "something"))
15341 ;; in the group "alt.alt", this will result in a new virtual server
15342 ;; called "hello+alt.alt".
15344 (gnus-copy-sequence
15345 (if (equal (car method) "native") gnus-select-method
15346 (cdr (assoc (car method) gnus-server-alist))))))
15347 (setcar (cdr entry) (concat (nth 1 entry) "+" group))
15348 (nconc entry (cdr method))))
15350 (defun gnus-find-method-for-group (group &optional info)
15351 "Find the select method that GROUP uses."
15352 (or gnus-override-method
15354 gnus-select-method)
15355 (let ((info (or info (gnus-get-info group)))
15358 (not (setq method (gnus-info-method info)))
15359 (equal method "native"))
15362 (cond ((stringp method)
15363 (gnus-server-to-method method))
15364 ((stringp (car method))
15365 (gnus-server-extend-method group method))
15368 (cond ((equal (cadr method) "")
15370 ((null (cadr method))
15371 (list (car method) ""))
15373 (gnus-server-add-address method)))))))
15375 (defun gnus-check-backend-function (func group)
15376 "Check whether GROUP supports function FUNC."
15377 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
15379 (fboundp (intern (format "%s-%s" method func)))))
15381 (defun gnus-methods-using (feature)
15382 "Find all methods that have FEATURE."
15383 (let ((valids gnus-valid-select-methods)
15386 (if (memq feature (car valids))
15387 (setq outs (cons (car valids) outs)))
15388 (setq valids (cdr valids)))
15393 ;;; Active & Newsrc File Handling
15396 (defun gnus-setup-news (&optional rawfile level dont-connect)
15397 "Setup news information.
15398 If RAWFILE is non-nil, the .newsrc file will also be read.
15399 If LEVEL is non-nil, the news will be set up at level LEVEL."
15400 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile)))))
15403 ;; Clear some variables to re-initialize news information.
15404 (setq gnus-newsrc-alist nil
15405 gnus-active-hashtb nil)
15406 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
15407 (gnus-read-newsrc-file rawfile))
15409 (when (and (not (assoc "archive" gnus-server-alist))
15410 gnus-message-archive-method)
15411 (push (cons "archive" gnus-message-archive-method)
15412 gnus-server-alist))
15414 ;; If we don't read the complete active file, we fill in the
15416 (if (or (null gnus-read-active-file)
15417 (eq gnus-read-active-file 'some))
15418 (gnus-update-active-hashtb-from-killed))
15420 ;; Read the active file and create `gnus-active-hashtb'.
15421 ;; If `gnus-read-active-file' is nil, then we just create an empty
15422 ;; hash table. The partial filling out of the hash table will be
15423 ;; done in `gnus-get-unread-articles'.
15424 (and gnus-read-active-file
15426 (gnus-read-active-file))
15428 (or gnus-active-hashtb
15429 (setq gnus-active-hashtb (make-vector 4095 0)))
15431 ;; Initialize the cache.
15432 (when gnus-use-cache
15435 ;; Possibly eval the dribble file.
15436 (and init (or gnus-use-dribble-file gnus-slave) (gnus-dribble-eval-file))
15438 ;; Slave Gnusii should then clear the dribble buffer.
15439 (when (and init gnus-slave)
15440 (gnus-dribble-clear))
15442 (gnus-update-format-specifications)
15444 ;; See whether we need to read the description file.
15445 (if (and (string-match "%[-,0-9]*D" gnus-group-line-format)
15446 (not gnus-description-hashtb)
15448 gnus-read-active-file)
15449 (gnus-read-all-descriptions-files))
15451 ;; Find new newsgroups and treat them.
15452 (if (and init gnus-check-new-newsgroups (not level)
15453 (gnus-check-server gnus-select-method))
15454 (gnus-find-new-newsgroups))
15456 ;; We might read in new NoCeM messages here.
15457 (when (and gnus-use-nocem
15459 (not dont-connect))
15460 (gnus-nocem-scan-groups))
15462 ;; Find the number of unread articles in each non-dead group.
15463 (let ((gnus-read-active-file (and (not level) gnus-read-active-file)))
15464 (gnus-get-unread-articles level))
15466 (if (and init gnus-check-bogus-newsgroups
15467 gnus-read-active-file (not level)
15468 (gnus-server-opened gnus-select-method))
15469 (gnus-check-bogus-newsgroups))))
15471 (defun gnus-find-new-newsgroups (&optional arg)
15472 "Search for new newsgroups and add them.
15473 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
15474 The `-n' option line from .newsrc is respected.
15475 If ARG (the prefix), use the `ask-server' method to query
15476 the server for new groups."
15478 (let ((check (if (or (and arg (not (listp gnus-check-new-newsgroups)))
15479 (null gnus-read-active-file)
15480 (eq gnus-read-active-file 'some))
15481 'ask-server gnus-check-new-newsgroups)))
15482 (unless (gnus-check-first-time-used)
15483 (if (or (consp check)
15484 (eq check 'ask-server))
15485 ;; Ask the server for new groups.
15486 (gnus-ask-server-for-new-groups)
15487 ;; Go through the active hashtb and look for new groups.
15489 group new-newsgroups)
15490 (gnus-message 5 "Looking for new newsgroups...")
15491 (unless gnus-have-read-active-file
15492 (gnus-read-active-file))
15493 (setq gnus-newsrc-last-checked-date (current-time-string))
15494 (unless gnus-killed-hashtb
15495 (gnus-make-hashtable-from-killed))
15496 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
15497 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
15500 (if (or (null (setq group (symbol-name sym)))
15502 (null (symbol-value sym))
15503 (gnus-gethash group gnus-killed-hashtb)
15504 (gnus-gethash group gnus-newsrc-hashtb))
15506 (let ((do-sub (gnus-matches-options-n group)))
15508 ((eq do-sub 'subscribe)
15509 (setq groups (1+ groups))
15510 (gnus-sethash group group gnus-killed-hashtb)
15511 (funcall gnus-subscribe-options-newsgroup-method group))
15512 ((eq do-sub 'ignore)
15515 (setq groups (1+ groups))
15516 (gnus-sethash group group gnus-killed-hashtb)
15517 (if gnus-subscribe-hierarchical-interactive
15518 (setq new-newsgroups (cons group new-newsgroups))
15519 (funcall gnus-subscribe-newsgroup-method group)))))))
15520 gnus-active-hashtb)
15521 (when new-newsgroups
15522 (gnus-subscribe-hierarchical-interactive new-newsgroups))
15523 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
15525 (gnus-message 6 "%d new newsgroup%s arrived."
15526 groups (if (> groups 1) "s have" " has"))
15527 (gnus-message 6 "No new newsgroups.")))))))
15529 (defun gnus-matches-options-n (group)
15530 ;; Returns `subscribe' if the group is to be unconditionally
15531 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
15532 ;; no match for the group.
15534 ;; First we check the two user variables.
15536 ((and gnus-options-subscribe
15537 (string-match gnus-options-subscribe group))
15539 ((and gnus-auto-subscribed-groups
15540 (string-match gnus-auto-subscribed-groups group))
15542 ((and gnus-options-not-subscribe
15543 (string-match gnus-options-not-subscribe group))
15545 ;; Then we go through the list that was retrieved from the .newsrc
15546 ;; file. This list has elements on the form
15547 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
15548 ;; is in the reverse order of the options line) is returned.
15550 (let ((regs gnus-newsrc-options-n))
15552 (not (string-match (caar regs) group)))
15553 (setq regs (cdr regs)))
15554 (and regs (cdar regs))))))
15556 (defun gnus-ask-server-for-new-groups ()
15557 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
15558 (methods (cons gnus-select-method
15560 (when gnus-message-archive-method
15563 (and (consp gnus-check-new-newsgroups)
15564 gnus-check-new-newsgroups)
15565 gnus-secondary-select-methods))))
15567 (new-date (current-time-string))
15568 group new-newsgroups got-new method hashtb
15569 gnus-override-subscribe-method)
15570 ;; Go through both primary and secondary select methods and
15571 ;; request new newsgroups.
15572 (while (setq method (gnus-server-get-method nil (pop methods)))
15573 (setq new-newsgroups nil)
15574 (setq gnus-override-subscribe-method method)
15575 (when (and (gnus-check-server method)
15576 (gnus-request-newgroups date method))
15579 (setq hashtb (gnus-make-hashtable 100))
15580 (set-buffer nntp-server-buffer)
15581 ;; Enter all the new groups into a hashtable.
15582 (gnus-active-to-gnus-format method hashtb 'ignore))
15583 ;; Now all new groups from `method' are in `hashtb'.
15585 (lambda (group-sym)
15586 (if (or (null (setq group (symbol-name group-sym)))
15587 (not (boundp group-sym))
15588 (null (symbol-value group-sym))
15589 (gnus-gethash group gnus-newsrc-hashtb)
15590 (member group gnus-zombie-list)
15591 (member group gnus-killed-list))
15592 ;; The group is already known.
15594 ;; Make this group active.
15595 (when (symbol-value group-sym)
15596 (gnus-set-active group (symbol-value group-sym)))
15597 ;; Check whether we want it or not.
15598 (let ((do-sub (gnus-matches-options-n group)))
15600 ((eq do-sub 'subscribe)
15602 (gnus-sethash group group gnus-killed-hashtb)
15603 (funcall gnus-subscribe-options-newsgroup-method group))
15604 ((eq do-sub 'ignore)
15608 (gnus-sethash group group gnus-killed-hashtb)
15609 (if gnus-subscribe-hierarchical-interactive
15610 (push group new-newsgroups)
15611 (funcall gnus-subscribe-newsgroup-method group)))))))
15613 (when new-newsgroups
15614 (gnus-subscribe-hierarchical-interactive new-newsgroups)))
15615 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
15617 (gnus-message 6 "%d new newsgroup%s arrived."
15618 groups (if (> groups 1) "s have" " has")))
15619 (and got-new (setq gnus-newsrc-last-checked-date new-date))
15622 (defun gnus-check-first-time-used ()
15623 (if (or (> (length gnus-newsrc-alist) 1)
15624 (file-exists-p gnus-startup-file)
15625 (file-exists-p (concat gnus-startup-file ".el"))
15626 (file-exists-p (concat gnus-startup-file ".eld")))
15628 (gnus-message 6 "First time user; subscribing you to default groups")
15629 (unless (gnus-read-active-file-p)
15630 (gnus-read-active-file))
15631 (setq gnus-newsrc-last-checked-date (current-time-string))
15632 (let ((groups gnus-default-subscribed-newsgroups)
15636 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
15639 (if (null (setq group (symbol-name sym)))
15641 (let ((do-sub (gnus-matches-options-n group)))
15643 ((eq do-sub 'subscribe)
15644 (gnus-sethash group group gnus-killed-hashtb)
15645 (funcall gnus-subscribe-options-newsgroup-method group))
15646 ((eq do-sub 'ignore)
15649 (setq gnus-killed-list (cons group gnus-killed-list)))))))
15650 gnus-active-hashtb)
15652 (if (gnus-active (car groups))
15653 (gnus-group-change-level
15654 (car groups) gnus-level-default-subscribed gnus-level-killed))
15655 (setq groups (cdr groups)))
15656 (gnus-group-make-help-group)
15657 (and gnus-novice-user
15658 (gnus-message 7 "`A k' to list killed groups"))))))
15660 (defun gnus-subscribe-group (group previous &optional method)
15661 (gnus-group-change-level
15663 (list t group gnus-level-default-subscribed nil nil method)
15665 gnus-level-default-subscribed gnus-level-killed previous t))
15667 ;; `gnus-group-change-level' is the fundamental function for changing
15668 ;; subscription levels of newsgroups. This might mean just changing
15669 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
15670 ;; again, which subscribes/unsubscribes a group, which is equally
15671 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
15672 ;; from 8-9 to 1-7 means that you remove the group from the list of
15673 ;; killed (or zombie) groups and add them to the (kinda) subscribed
15674 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
15675 ;; which is trivial.
15676 ;; ENTRY can either be a string (newsgroup name) or a list (if
15677 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
15678 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
15680 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
15681 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
15683 (defun gnus-group-change-level (entry level &optional oldlevel
15684 previous fromkilled)
15685 (let (group info active num)
15686 ;; Glean what info we can from the arguments
15688 (if fromkilled (setq group (nth 1 entry))
15689 (setq group (car (nth 2 entry))))
15690 (setq group entry))
15691 (if (and (stringp entry)
15693 (< oldlevel gnus-level-zombie))
15694 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
15695 (if (and (not oldlevel)
15697 (setq oldlevel (gnus-info-level (nth 2 entry)))
15698 (setq oldlevel (or oldlevel 9)))
15699 (if (stringp previous)
15700 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
15702 (if (and (>= oldlevel gnus-level-zombie)
15703 (gnus-gethash group gnus-newsrc-hashtb))
15704 ;; We are trying to subscribe a group that is already
15708 (or (gnus-ephemeral-group-p group)
15709 (gnus-dribble-enter
15710 (format "(gnus-group-change-level %S %S %S %S %S)"
15711 group level oldlevel (car (nth 2 previous)) fromkilled)))
15713 ;; Then we remove the newgroup from any old structures, if needed.
15714 ;; If the group was killed, we remove it from the killed or zombie
15715 ;; list. If not, and it is in fact going to be killed, we remove
15716 ;; it from the newsrc hash table and assoc.
15718 ((>= oldlevel gnus-level-zombie)
15719 (if (= oldlevel gnus-level-zombie)
15720 (setq gnus-zombie-list (delete group gnus-zombie-list))
15721 (setq gnus-killed-list (delete group gnus-killed-list))))
15723 (if (and (>= level gnus-level-zombie)
15726 (gnus-sethash (car (nth 2 entry)) nil gnus-newsrc-hashtb)
15728 (setcdr (gnus-gethash (car (nth 3 entry))
15729 gnus-newsrc-hashtb)
15731 (setcdr (cdr entry) (cdddr entry))))))
15733 ;; Finally we enter (if needed) the list where it is supposed to
15734 ;; go, and change the subscription level. If it is to be killed,
15735 ;; we enter it into the killed or zombie list.
15737 ((>= level gnus-level-zombie)
15738 ;; Remove from the hash table.
15739 (gnus-sethash group nil gnus-newsrc-hashtb)
15740 ;; We do not enter foreign groups into the list of dead
15742 (unless (gnus-group-foreign-p group)
15743 (if (= level gnus-level-zombie)
15744 (setq gnus-zombie-list (cons group gnus-zombie-list))
15745 (setq gnus-killed-list (cons group gnus-killed-list)))))
15747 ;; If the list is to be entered into the newsrc assoc, and
15748 ;; it was killed, we have to create an entry in the newsrc
15749 ;; hashtb format and fix the pointers in the newsrc assoc.
15750 (if (< oldlevel gnus-level-zombie)
15751 ;; It was alive, and it is going to stay alive, so we
15752 ;; just change the level and don't change any pointers or
15753 ;; hash table entries.
15754 (setcar (cdaddr entry) level)
15756 (setq info (cdr entry)
15758 (setq active (gnus-active group))
15760 (if active (- (1+ (cdr active)) (car active)) t))
15761 ;; Check whether the group is foreign. If so, the
15762 ;; foreign select method has to be entered into the
15764 (let ((method (or gnus-override-subscribe-method
15765 (gnus-group-method group))))
15766 (if (eq method gnus-select-method)
15767 (setq info (list group level nil))
15768 (setq info (list group level nil nil method)))))
15771 (let ((p gnus-newsrc-alist))
15775 (setq entry (cons info (cddr previous)))
15778 (setcdr (cdr previous) entry)
15779 (gnus-sethash group (cons num (cdr previous))
15780 gnus-newsrc-hashtb))
15781 (setcdr previous entry)
15782 (gnus-sethash group (cons num previous)
15783 gnus-newsrc-hashtb))
15785 (setcdr (gnus-gethash (caadr entry) gnus-newsrc-hashtb) entry)))))
15786 (when gnus-group-change-level-function
15787 (funcall gnus-group-change-level-function group level oldlevel)))))
15789 (defun gnus-kill-newsgroup (newsgroup)
15790 "Obsolete function. Kills a newsgroup."
15791 (gnus-group-change-level
15792 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed))
15794 (defun gnus-check-bogus-newsgroups (&optional confirm)
15795 "Remove bogus newsgroups.
15796 If CONFIRM is non-nil, the user has to confirm the deletion of every
15798 (let ((newsrc (cdr gnus-newsrc-alist))
15799 bogus group entry info)
15800 (gnus-message 5 "Checking bogus newsgroups...")
15801 (unless (gnus-read-active-file-p)
15802 (gnus-read-active-file))
15803 (when (gnus-read-active-file-p)
15804 ;; Find all bogus newsgroup that are subscribed.
15806 (setq info (pop newsrc)
15807 group (gnus-info-group info))
15808 (unless (or (gnus-active group) ; Active
15809 (gnus-info-method info) ; Foreign
15811 (not (gnus-y-or-n-p
15812 (format "Remove bogus newsgroup: %s " group)))))
15813 ;; Found a bogus newsgroup.
15814 (push group bogus)))
15815 ;; Remove all bogus subscribed groups by first killing them, and
15816 ;; then removing them from the list of killed groups.
15818 (when (setq entry (gnus-gethash (setq group (pop bogus))
15819 gnus-newsrc-hashtb))
15820 (gnus-group-change-level entry gnus-level-killed)
15821 (setq gnus-killed-list (delete group gnus-killed-list))))
15822 ;; Then we remove all bogus groups from the list of killed and
15823 ;; zombie groups. They are are removed without confirmation.
15824 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
15827 (setq killed (symbol-value (car dead-lists)))
15829 (unless (gnus-active (setq group (pop killed)))
15830 ;; The group is bogus.
15831 ;; !!!Slow as hell.
15832 (set (car dead-lists)
15833 (delete group (symbol-value (car dead-lists))))))
15834 (setq dead-lists (cdr dead-lists))))
15835 (gnus-message 5 "Checking bogus newsgroups...done"))))
15837 (defun gnus-check-duplicate-killed-groups ()
15838 "Remove duplicates from the list of killed groups."
15840 (let ((killed gnus-killed-list))
15842 (gnus-message 9 "%d" (length killed))
15843 (setcdr killed (delete (car killed) (cdr killed)))
15844 (setq killed (cdr killed)))))
15846 ;; We want to inline a function from gnus-cache, so we cheat here:
15849 (require 'gnus-cache))
15851 (defun gnus-get-unread-articles-in-group (info active &optional update)
15853 ;; Allow the backend to update the info in the group.
15855 (gnus-request-update-info
15856 info (gnus-find-method-for-group (gnus-info-group info))))
15857 (gnus-activate-group (gnus-info-group info) nil t))
15858 (let* ((range (gnus-info-read info))
15860 ;; If a cache is present, we may have to alter the active info.
15861 (when (and gnus-use-cache info)
15862 (inline (gnus-cache-possibly-alter-active
15863 (gnus-info-group info) active)))
15864 ;; Modify the list of read articles according to what articles
15865 ;; are available; then tally the unread articles and add the
15866 ;; number to the group hash table entry.
15868 ((zerop (cdr active))
15871 (setq num (- (1+ (cdr active)) (car active))))
15872 ((not (listp (cdr range)))
15873 ;; Fix a single (num . num) range according to the
15874 ;; active hash table.
15875 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
15876 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
15877 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
15878 ;; Compute number of unread articles.
15879 (setq num (max 0 (- (cdr active) (- (1+ (cdr range)) (car range))))))
15881 ;; The read list is a list of ranges. Fix them according to
15882 ;; the active hash table.
15883 ;; First peel off any elements that are below the lower
15885 (while (and (cdr range)
15887 (or (and (atom (cadr range)) (cadr range))
15889 (if (numberp (car range))
15892 (or (and (numberp (cadr range))
15895 (setcdr (car range)
15896 (or (and (numberp (nth 1 range)) (nth 1 range))
15898 (setcdr range (cddr range)))
15899 ;; Adjust the first element to be the same as the lower limit.
15900 (if (and (not (atom (car range)))
15901 (< (cdar range) (car active)))
15902 (setcdr (car range) (1- (car active))))
15903 ;; Then we want to peel off any elements that are higher
15904 ;; than the upper active limit.
15905 (let ((srange range))
15906 ;; Go past all legal elements.
15907 (while (and (cdr srange)
15908 (<= (or (and (atom (cadr srange))
15910 (caadr srange)) (cdr active)))
15911 (setq srange (cdr srange)))
15913 ;; Nuke all remaining illegal elements.
15914 (setcdr srange nil))
15916 ;; Adjust the final element.
15917 (if (and (not (atom (car srange)))
15918 (> (cdar srange) (cdr active)))
15919 (setcdr (car srange) (cdr active))))
15920 ;; Compute the number of unread articles.
15922 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
15924 (or (and (atom (car range)) (car range))
15926 (setq range (cdr range)))
15927 (setq num (max 0 (- (cdr active) num)))))
15928 ;; Set the number of unread articles.
15930 (setcar (gnus-gethash (gnus-info-group info) gnus-newsrc-hashtb) num))
15933 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
15934 ;; and compute how many unread articles there are in each group.
15935 (defun gnus-get-unread-articles (&optional level)
15936 (let* ((newsrc (cdr gnus-newsrc-alist))
15937 (level (or level gnus-activate-level (1+ gnus-level-subscribed)))
15940 (cond ((and gnus-activate-foreign-newsgroups
15941 (not (numberp gnus-activate-foreign-newsgroups)))
15942 (1+ gnus-level-subscribed))
15943 ((numberp gnus-activate-foreign-newsgroups)
15944 gnus-activate-foreign-newsgroups)
15947 info group active method)
15948 (gnus-message 5 "Checking new news...")
15951 (setq active (gnus-active (setq group (gnus-info-group
15952 (setq info (pop newsrc))))))
15954 ;; Check newsgroups. If the user doesn't want to check them, or
15955 ;; they can't be checked (for instance, if the news server can't
15956 ;; be reached) we just set the number of unread articles in this
15957 ;; newsgroup to t. This means that Gnus thinks that there are
15958 ;; unread articles, but it has no idea how many.
15959 (if (and (setq method (gnus-info-method info))
15960 (not (gnus-server-equal
15962 (setq method (gnus-server-get-method nil method))))
15963 (not (gnus-secondary-method-p method)))
15964 ;; These groups are foreign. Check the level.
15965 (when (<= (gnus-info-level info) foreign-level)
15966 (setq active (gnus-activate-group group 'scan))
15967 (unless (inline (gnus-virtual-group-p group))
15968 (inline (gnus-close-group group)))
15969 (when (fboundp (intern (concat (symbol-name (car method))
15970 "-request-update-info")))
15971 (inline (gnus-request-update-info info method))))
15972 ;; These groups are native or secondary.
15973 (when (and (<= (gnus-info-level info) level)
15974 (not gnus-read-active-file))
15975 (setq active (gnus-activate-group group 'scan))
15976 (inline (gnus-close-group group))))
15978 ;; Get the number of unread articles in the group.
15980 (inline (gnus-get-unread-articles-in-group info active))
15981 ;; The group couldn't be reached, so we nix out the number of
15982 ;; unread articles and stuff.
15983 (gnus-set-active group nil)
15984 (setcar (gnus-gethash group gnus-newsrc-hashtb) t)))
15986 (gnus-message 5 "Checking new news...done")))
15988 ;; Create a hash table out of the newsrc alist. The `car's of the
15989 ;; alist elements are used as keys.
15990 (defun gnus-make-hashtable-from-newsrc-alist ()
15991 (let ((alist gnus-newsrc-alist)
15992 (ohashtb gnus-newsrc-hashtb)
15994 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
15996 (setq prev (setq gnus-newsrc-alist
15997 (if (equal (caar gnus-newsrc-alist)
16000 (cons (list "dummy.group" 0 nil) alist)))))
16004 (cons (and ohashtb (car (gnus-gethash (caar alist) ohashtb)))
16006 gnus-newsrc-hashtb)
16008 alist (cdr alist)))))
16010 (defun gnus-make-hashtable-from-killed ()
16011 "Create a hash table from the killed and zombie lists."
16012 (let ((lists '(gnus-killed-list gnus-zombie-list))
16014 (setq gnus-killed-hashtb
16015 (gnus-make-hashtable
16016 (+ (length gnus-killed-list) (length gnus-zombie-list))))
16017 (while (setq list (pop lists))
16018 (setq list (symbol-value list))
16020 (gnus-sethash (car list) (pop list) gnus-killed-hashtb)))))
16022 (defun gnus-activate-group (group &optional scan dont-check)
16023 ;; Check whether a group has been activated or not.
16024 ;; If SCAN, request a scan of that group as well.
16025 (let ((method (gnus-find-method-for-group group))
16027 (and (gnus-check-server method)
16028 ;; We escape all bugs and quit here to make it possible to
16029 ;; continue if a group is so out-there that it reports bugs
16033 (gnus-check-backend-function 'request-scan (car method))
16034 (gnus-request-scan group method))
16037 (gnus-request-group group dont-check)
16041 (set-buffer nntp-server-buffer)
16042 (goto-char (point-min))
16043 ;; Parse the result we got from `gnus-request-group'.
16044 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
16046 (goto-char (match-beginning 1))
16048 group (setq active (cons (read (current-buffer))
16049 (read (current-buffer)))))
16050 ;; Return the new active info.
16053 (defun gnus-update-read-articles (group unread)
16054 "Update the list of read and ticked articles in GROUP using the
16055 UNREAD and TICKED lists.
16056 Note: UNSELECTED has to be sorted over `<'.
16057 Returns whether the updating was successful."
16058 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
16059 (entry (gnus-gethash group gnus-newsrc-hashtb))
16060 (info (nth 2 entry))
16062 (unread (sort (copy-sequence unread) '<))
16064 (if (or (not info) (not active))
16065 ;; There is no info on this group if it was, in fact,
16066 ;; killed. Gnus stores no information on killed groups, so
16067 ;; there's nothing to be done.
16068 ;; One could store the information somewhere temporarily,
16069 ;; perhaps... Hmmm...
16071 ;; Remove any negative articles numbers.
16072 (while (and unread (< (car unread) 0))
16073 (setq unread (cdr unread)))
16074 ;; Remove any expired article numbers
16075 (while (and unread (< (car unread) (car active)))
16076 (setq unread (cdr unread)))
16077 ;; Compute the ranges of read articles by looking at the list of
16078 ;; unread articles.
16080 (if (/= (car unread) prev)
16081 (setq read (cons (if (= prev (1- (car unread))) prev
16082 (cons prev (1- (car unread)))) read)))
16083 (setq prev (1+ (car unread)))
16084 (setq unread (cdr unread)))
16085 (when (<= prev (cdr active))
16086 (setq read (cons (cons prev (cdr active)) read)))
16087 ;; Enter this list into the group info.
16088 (gnus-info-set-read
16089 info (if (> (length read) 1) (nreverse read) read))
16090 ;; Set the number of unread articles in gnus-newsrc-hashtb.
16091 (gnus-get-unread-articles-in-group info (gnus-active group))
16094 (defun gnus-make-articles-unread (group articles)
16095 "Mark ARTICLES in GROUP as unread."
16096 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
16097 (gnus-gethash (gnus-group-real-name group)
16098 gnus-newsrc-hashtb))))
16099 (ranges (gnus-info-read info))
16102 (when (gnus-member-of-range
16103 (setq article (pop articles)) ranges)
16104 (setq news (cons article news))))
16106 (gnus-info-set-read
16107 info (gnus-remove-from-range (gnus-info-read info) (nreverse news)))
16108 (gnus-group-update-group group t))))
16110 ;; Enter all dead groups into the hashtb.
16111 (defun gnus-update-active-hashtb-from-killed ()
16112 (let ((hashtb (setq gnus-active-hashtb (make-vector 4095 0)))
16113 (lists (list gnus-killed-list gnus-zombie-list))
16116 (setq killed (car lists))
16118 (gnus-sethash (car killed) nil hashtb)
16119 (setq killed (cdr killed)))
16120 (setq lists (cdr lists)))))
16122 (defun gnus-get-killed-groups ()
16123 "Go through the active hashtb and all all unknown groups as killed."
16124 ;; First make sure active file has been read.
16125 (unless (gnus-read-active-file-p)
16126 (let ((gnus-read-active-file t))
16127 (gnus-read-active-file)))
16128 (or gnus-killed-hashtb (gnus-make-hashtable-from-killed))
16129 ;; Go through all newsgroups that are known to Gnus - enlarge kill list.
16133 (group (symbol-name sym)))
16134 (if (or (null group)
16135 (gnus-gethash group gnus-killed-hashtb)
16136 (gnus-gethash group gnus-newsrc-hashtb))
16138 (let ((do-sub (gnus-matches-options-n group)))
16139 (if (or (eq do-sub 'subscribe) (eq do-sub 'ignore))
16141 (setq groups (1+ groups))
16142 (setq gnus-killed-list
16143 (cons group gnus-killed-list))
16144 (gnus-sethash group group gnus-killed-hashtb))))))
16145 gnus-active-hashtb))
16147 ;; Get the active file(s) from the backend(s).
16148 (defun gnus-read-active-file ()
16149 (gnus-group-set-mode-line)
16152 (if (gnus-check-server gnus-select-method)
16153 ;; The native server is available.
16154 (cons gnus-select-method gnus-secondary-select-methods)
16155 ;; The native server is down, so we just do the
16157 gnus-secondary-select-methods)
16158 ;; Also read from the archive server.
16159 (when gnus-message-archive-method
16160 (list "archive"))))
16162 (setq gnus-have-read-active-file nil)
16164 (set-buffer nntp-server-buffer)
16166 (let* ((method (if (stringp (car methods))
16167 (gnus-server-get-method nil (car methods))
16169 (where (nth 1 method))
16170 (mesg (format "Reading active file%s via %s..."
16171 (if (and where (not (zerop (length where))))
16172 (concat " from " where) "")
16174 (gnus-message 5 mesg)
16175 (when (gnus-check-server method)
16176 ;; Request that the backend scan its incoming messages.
16177 (and (gnus-check-backend-function 'request-scan (car method))
16178 (gnus-request-scan nil method))
16180 ((and (eq gnus-read-active-file 'some)
16181 (gnus-check-backend-function 'retrieve-groups (car method)))
16182 (let ((newsrc (cdr gnus-newsrc-alist))
16183 (gmethod (gnus-server-get-method nil method))
16185 (while (setq info (pop newsrc))
16186 (when (gnus-server-equal
16187 (gnus-find-method-for-group
16188 (gnus-info-group info) info)
16190 (push (gnus-group-real-name (gnus-info-group info))
16193 (gnus-check-server method)
16194 (setq list-type (gnus-retrieve-groups groups method))
16198 1.2 "Cannot read partial active file from %s server."
16200 ((eq list-type 'active)
16201 (gnus-active-to-gnus-format method gnus-active-hashtb))
16203 (gnus-groups-to-gnus-format method gnus-active-hashtb))))))
16205 (if (not (gnus-request-list method))
16206 (unless (equal method gnus-message-archive-method)
16207 (gnus-error 1 "Cannot read active file from %s server."
16209 (gnus-message 5 mesg)
16210 (gnus-active-to-gnus-format method gnus-active-hashtb)
16211 ;; We mark this active file as read.
16212 (push method gnus-have-read-active-file)
16213 (gnus-message 5 "%sdone" mesg))))))
16214 (setq methods (cdr methods))))))
16216 ;; Read an active file and place the results in `gnus-active-hashtb'.
16217 (defun gnus-active-to-gnus-format (&optional method hashtb ignore-errors)
16219 (setq method gnus-select-method))
16220 (let ((cur (current-buffer))
16222 (if (and gnus-active-hashtb
16223 (not (equal method gnus-select-method)))
16225 (setq gnus-active-hashtb
16226 (if (equal method gnus-select-method)
16227 (gnus-make-hashtable
16228 (count-lines (point-min) (point-max)))
16229 (gnus-make-hashtable 4096)))))))
16230 ;; Delete unnecessary lines.
16231 (goto-char (point-min))
16232 (while (search-forward "\nto." nil t)
16233 (delete-region (1+ (match-beginning 0))
16234 (progn (forward-line 1) (point))))
16235 (or (string= gnus-ignored-newsgroups "")
16237 (goto-char (point-min))
16238 (delete-matching-lines gnus-ignored-newsgroups)))
16239 ;; Make the group names readable as a lisp expression even if they
16240 ;; contain special characters.
16241 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
16242 (goto-char (point-max))
16243 (while (re-search-backward "[][';?()#]" nil t)
16245 ;; If these are groups from a foreign select method, we insert the
16246 ;; group prefix in front of the group names.
16247 (and method (not (gnus-server-equal
16248 (gnus-server-get-method nil method)
16249 (gnus-server-get-method nil gnus-select-method)))
16250 (let ((prefix (gnus-group-prefixed-name "" method)))
16251 (goto-char (point-min))
16252 (while (and (not (eobp))
16253 (progn (insert prefix)
16254 (zerop (forward-line 1)))))))
16255 ;; Store the active file in a hash table.
16256 (goto-char (point-min))
16257 (if (string-match "%[oO]" gnus-group-line-format)
16258 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
16259 ;; If we want information on moderated groups, we use this
16261 (let* ((mod-hashtb (make-vector 7 0))
16262 (m (intern "m" mod-hashtb))
16264 (while (not (eobp))
16265 (condition-case nil
16267 (narrow-to-region (point) (gnus-point-at-eol))
16268 (setq group (let ((obarray hashtb)) (read cur)))
16269 (if (and (numberp (setq max (read cur)))
16270 (numberp (setq min (read cur)))
16272 (skip-chars-forward " \t")
16274 (or (= (following-char) ?=)
16275 (= (following-char) ?x)
16276 (= (following-char) ?j)))))
16277 (set group (cons min max))
16279 ;; Enter moderated groups into a list.
16280 (if (eq (let ((obarray mod-hashtb)) (read cur)) m)
16281 (setq gnus-moderated-list
16282 (cons (symbol-name group) gnus-moderated-list))))
16289 ;; And if we do not care about moderation, we use this loop,
16290 ;; which is faster.
16291 (let (group max min)
16292 (while (not (eobp))
16295 (narrow-to-region (point) (gnus-point-at-eol))
16296 ;; group gets set to a symbol interned in the hash table
16297 ;; (what a hack!!) - jwz
16298 (setq group (let ((obarray hashtb)) (read cur)))
16299 (if (and (numberp (setq max (read cur)))
16300 (numberp (setq min (read cur)))
16302 (skip-chars-forward " \t")
16304 (or (= (following-char) ?=)
16305 (= (following-char) ?x)
16306 (= (following-char) ?j)))))
16307 (set group (cons min max))
16315 (gnus-message 3 "Warning - illegal active: %s"
16317 (gnus-point-at-bol) (gnus-point-at-eol)))))))
16319 (forward-line 1))))))
16321 (defun gnus-groups-to-gnus-format (method &optional hashtb)
16322 ;; Parse a "groups" active file.
16323 (let ((cur (current-buffer))
16325 (if (and method gnus-active-hashtb)
16327 (setq gnus-active-hashtb
16328 (gnus-make-hashtable
16329 (count-lines (point-min) (point-max)))))))
16330 (prefix (and method
16331 (not (gnus-server-equal
16332 (gnus-server-get-method nil method)
16333 (gnus-server-get-method nil gnus-select-method)))
16334 (gnus-group-prefixed-name "" method))))
16336 (goto-char (point-min))
16337 ;; We split this into to separate loops, one with the prefix
16338 ;; and one without to speed the reading up somewhat.
16340 (let (min max opoint group)
16341 (while (not (eobp))
16344 (read cur) (read cur)
16345 (setq min (read cur)
16348 (skip-chars-forward " \t")
16351 (set (let ((obarray hashtb)) (read cur))
16353 (error (and group (symbolp group) (set group nil))))
16355 (let (min max group)
16356 (while (not (eobp))
16358 (if (= (following-char) ?2)
16360 (read cur) (read cur)
16361 (setq min (read cur)
16363 (set (setq group (let ((obarray hashtb)) (read cur)))
16365 (error (and group (symbolp group) (set group nil))))
16366 (forward-line 1))))))
16368 (defun gnus-read-newsrc-file (&optional force)
16369 "Read startup file.
16370 If FORCE is non-nil, the .newsrc file is read."
16371 ;; Reset variables that might be defined in the .newsrc.eld file.
16372 (let ((variables gnus-variable-list))
16374 (set (car variables) nil)
16375 (setq variables (cdr variables))))
16376 (let* ((newsrc-file gnus-current-startup-file)
16377 (quick-file (concat newsrc-file ".el")))
16379 ;; We always load the .newsrc.eld file. If always contains
16380 ;; much information that can not be gotten from the .newsrc
16381 ;; file (ticked articles, killed groups, foreign methods, etc.)
16382 (gnus-read-newsrc-el-file quick-file)
16384 (if (and (file-exists-p gnus-current-startup-file)
16386 (and (file-newer-than-file-p newsrc-file quick-file)
16387 (file-newer-than-file-p newsrc-file
16388 (concat quick-file "d")))
16389 (not gnus-newsrc-alist)))
16390 ;; We read the .newsrc file. Note that if there if a
16391 ;; .newsrc.eld file exists, it has already been read, and
16392 ;; the `gnus-newsrc-hashtb' has been created. While reading
16393 ;; the .newsrc file, Gnus will only use the information it
16394 ;; can find there for changing the data already read -
16395 ;; ie. reading the .newsrc file will not trash the data
16396 ;; already read (except for read articles).
16398 (gnus-message 5 "Reading %s..." newsrc-file)
16399 (set-buffer (find-file-noselect newsrc-file))
16400 (buffer-disable-undo (current-buffer))
16401 (gnus-newsrc-to-gnus-format)
16402 (kill-buffer (current-buffer))
16403 (gnus-message 5 "Reading %s...done" newsrc-file)))
16405 ;; Read any slave files.
16407 (gnus-master-read-slave-newsrc))
16409 ;; Convert old to new.
16410 (gnus-convert-old-newsrc))))
16412 (defun gnus-continuum-version (version)
16413 "Return VERSION as a floating point number."
16414 (when (or (string-match "^\\([^ ]+\\)? ?Gnus v?\\([0-9.]+\\)$" version)
16415 (string-match "^\\(.?\\)gnus-\\([0-9.]+\\)$" version))
16416 (let* ((alpha (and (match-beginning 1) (match-string 1 version)))
16417 (number (match-string 2 version))
16419 (string-match "\\([0-9]\\)\\.\\([0-9]+\\)\\.?\\([0-9]+\\)?" number)
16420 (setq major (string-to-number (match-string 1 number)))
16421 (setq minor (string-to-number (match-string 2 number)))
16422 (setq least (if (match-beginning 3)
16423 (string-to-number (match-string 3 number))
16427 (format "%s00%02d%02d"
16429 ((member alpha '("(ding)" "d")) "4.99")
16430 ((member alpha '("September" "s")) "5.01")
16431 ((member alpha '("Red" "r")) "5.03"))
16433 (format "%d.%02d%02d" major minor least))))))
16435 (defun gnus-convert-old-newsrc ()
16436 "Convert old newsrc into the new format, if needed."
16437 (let ((fcv (and gnus-newsrc-file-version
16438 (gnus-continuum-version gnus-newsrc-file-version))))
16440 ;; No .newsrc.eld file was loaded.
16442 ;; Gnus 5 .newsrc.eld was loaded.
16443 ((< fcv (gnus-continuum-version "September Gnus v0.1"))
16444 (gnus-convert-old-ticks)))))
16446 (defun gnus-convert-old-ticks ()
16447 (let ((newsrc (cdr gnus-newsrc-alist))
16448 marks info dormant ticked)
16449 (while (setq info (pop newsrc))
16450 (when (setq marks (gnus-info-marks info))
16451 (setq dormant (cdr (assq 'dormant marks))
16452 ticked (cdr (assq 'tick marks)))
16453 (when (or dormant ticked)
16454 (gnus-info-set-read
16457 (gnus-info-read info)
16458 (nconc (gnus-uncompress-range dormant)
16459 (gnus-uncompress-range ticked)))))))))
16461 (defun gnus-read-newsrc-el-file (file)
16462 (let ((ding-file (concat file "d")))
16463 ;; We always, always read the .eld file.
16464 (gnus-message 5 "Reading %s..." ding-file)
16465 (let (gnus-newsrc-assoc)
16466 (condition-case nil
16467 (load ding-file t t t)
16469 (gnus-error 1 "Error in %s" ding-file)))
16470 (when gnus-newsrc-assoc
16471 (setq gnus-newsrc-alist gnus-newsrc-assoc)))
16472 (gnus-make-hashtable-from-newsrc-alist)
16473 (when (file-newer-than-file-p file ding-file)
16474 ;; Old format quick file
16475 (gnus-message 5 "Reading %s..." file)
16476 ;; The .el file is newer than the .eld file, so we read that one
16478 (gnus-read-old-newsrc-el-file file))))
16480 ;; Parse the old-style quick startup file
16481 (defun gnus-read-old-newsrc-el-file (file)
16482 (let (newsrc killed marked group m info)
16484 (let ((gnus-killed-assoc nil)
16485 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc)
16487 (condition-case nil
16490 (setq newsrc gnus-newsrc-assoc
16491 killed gnus-killed-assoc
16492 marked gnus-marked-assoc)))
16493 (setq gnus-newsrc-alist nil)
16494 (while (setq group (pop newsrc))
16495 (if (setq info (gnus-get-info (car group)))
16497 (gnus-info-set-read info (cddr group))
16498 (gnus-info-set-level
16499 info (if (nth 1 group) gnus-level-default-subscribed
16500 gnus-level-default-unsubscribed))
16501 (setq gnus-newsrc-alist (cons info gnus-newsrc-alist)))
16504 (if (nth 1 group) gnus-level-default-subscribed
16505 gnus-level-default-unsubscribed)
16507 gnus-newsrc-alist))
16508 ;; Copy marks into info.
16509 (when (setq m (assoc (car group) marked))
16510 (unless (nthcdr 3 info)
16511 (nconc info (list nil)))
16512 (gnus-info-set-marks
16513 info (list (cons 'tick (gnus-compress-sequence
16514 (sort (cdr m) '<) t))))))
16515 (setq newsrc killed)
16517 (setcar newsrc (caar newsrc))
16518 (setq newsrc (cdr newsrc)))
16519 (setq gnus-killed-list killed))
16520 ;; The .el file version of this variable does not begin with
16521 ;; "options", while the .eld version does, so we just add it if it
16524 gnus-newsrc-options
16526 (and (not (string-match "^ *options" gnus-newsrc-options))
16527 (setq gnus-newsrc-options (concat "options " gnus-newsrc-options)))
16528 (and (not (string-match "\n$" gnus-newsrc-options))
16529 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n")))
16530 ;; Finally, if we read some options lines, we parse them.
16531 (or (string= gnus-newsrc-options "")
16532 (gnus-newsrc-parse-options gnus-newsrc-options))))
16534 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))
16535 (gnus-make-hashtable-from-newsrc-alist)))
16537 (defun gnus-make-newsrc-file (file)
16538 "Make server dependent file name by catenating FILE and server host name."
16539 (let* ((file (expand-file-name file nil))
16540 (real-file (concat file "-" (nth 1 gnus-select-method))))
16541 (if (or (file-exists-p real-file)
16542 (file-exists-p (concat real-file ".el"))
16543 (file-exists-p (concat real-file ".eld")))
16546 (defun gnus-newsrc-to-gnus-format ()
16547 (setq gnus-newsrc-options "")
16548 (setq gnus-newsrc-options-n nil)
16550 (or gnus-active-hashtb
16551 (setq gnus-active-hashtb (make-vector 4095 0)))
16552 (let ((buf (current-buffer))
16553 (already-read (> (length gnus-newsrc-alist) 1))
16554 group subscribed options-symbol newsrc Options-symbol
16556 (goto-char (point-min))
16557 ;; We intern the symbol `options' in the active hashtb so that we
16558 ;; can `eq' against it later.
16559 (set (setq options-symbol (intern "options" gnus-active-hashtb)) nil)
16560 (set (setq Options-symbol (intern "Options" gnus-active-hashtb)) nil)
16562 (while (not (eobp))
16563 ;; We first read the first word on the line by narrowing and
16564 ;; then reading into `gnus-active-hashtb'. Most groups will
16565 ;; already exist in that hashtb, so this will save some string
16569 (progn (skip-chars-forward "^ \t!:\n") (point)))
16570 (goto-char (point-min))
16572 (and (/= (point-min) (point-max))
16573 (let ((obarray gnus-active-hashtb)) (read buf))))
16575 ;; Now, the symbol we have read is either `options' or a group
16576 ;; name. If it is an options line, we just add it to a string.
16578 ((or (eq symbol options-symbol)
16579 (eq symbol Options-symbol))
16580 (setq gnus-newsrc-options
16581 ;; This concating is quite inefficient, but since our
16582 ;; thorough studies show that approx 99.37% of all
16583 ;; .newsrc files only contain a single options line, we
16584 ;; don't give a damn, frankly, my dear.
16585 (concat gnus-newsrc-options
16587 (gnus-point-at-bol)
16588 ;; Options may continue on the next line.
16589 (or (and (re-search-forward "^[^ \t]" nil 'move)
16590 (progn (beginning-of-line) (point)))
16594 ;; Group names can be just numbers.
16595 (when (numberp symbol)
16596 (setq symbol (intern (int-to-string symbol) gnus-active-hashtb)))
16597 (or (boundp symbol) (set symbol nil))
16598 ;; It was a group name.
16599 (setq subscribed (= (following-char) ?:)
16600 group (symbol-name symbol)
16603 ;; If the line ends here, this is clearly a buggy line, so
16604 ;; we put point a the beginning of line and let the cond
16605 ;; below do the error handling.
16606 (beginning-of-line)
16607 ;; We skip to the beginning of the ranges.
16608 (skip-chars-forward "!: \t"))
16609 ;; We are now at the beginning of the list of read articles.
16610 ;; We read them range by range.
16613 ((looking-at "[0-9]+")
16614 ;; We narrow and read a number instead of buffer-substring/
16615 ;; string-to-int because it's faster. narrow/widen is
16616 ;; faster than save-restriction/narrow, and save-restriction
16617 ;; produces a garbage object.
16619 (narrow-to-region (match-beginning 0) (match-end 0))
16622 ;; If the next character is a dash, then this is a range.
16623 (if (= (following-char) ?-)
16625 ;; We read the upper bound of the range.
16627 (if (not (looking-at "[0-9]+"))
16628 ;; This is a buggy line, by we pretend that
16629 ;; it's kinda OK. Perhaps the user should be
16631 (setq reads (cons num1 reads))
16636 (narrow-to-region (match-beginning 0)
16641 ;; It was just a simple number, so we add it to the
16643 (setq reads (cons num1 reads)))
16644 ;; If the next char in ?\n, then we have reached the end
16645 ;; of the line and return nil.
16646 (/= (following-char) ?\n))
16647 ((= (following-char) ?\n)
16648 ;; End of line, so we end.
16651 ;; Not numbers and not eol, so this might be a buggy
16654 ;; If it was eob instead of ?\n, we allow it.
16656 ;; The line was buggy.
16658 (gnus-error 3.1 "Mangled line: %s"
16659 (buffer-substring (gnus-point-at-bol)
16660 (gnus-point-at-eol)))))
16662 ;; Skip past ", ". Spaces are illegal in these ranges, but
16663 ;; we allow them, because it's a common mistake to put a
16664 ;; space after the comma.
16665 (skip-chars-forward ", "))
16667 ;; We have already read .newsrc.eld, so we gently update the
16668 ;; data in the hash table with the information we have just
16671 (let ((info (gnus-get-info group))
16674 ;; There is an entry for this file in the alist.
16676 (gnus-info-set-read info (nreverse reads))
16677 ;; We update the level very gently. In fact, we
16678 ;; only change it if there's been a status change
16679 ;; from subscribed to unsubscribed, or vice versa.
16680 (setq level (gnus-info-level info))
16681 (cond ((and (<= level gnus-level-subscribed)
16683 (setq level (if reads
16684 gnus-level-default-unsubscribed
16685 (1+ gnus-level-default-unsubscribed))))
16686 ((and (> level gnus-level-subscribed) subscribed)
16687 (setq level gnus-level-default-subscribed)))
16688 (gnus-info-set-level info level))
16689 ;; This is a new group.
16690 (setq info (list group
16692 gnus-level-default-subscribed
16694 (1+ gnus-level-subscribed)
16695 gnus-level-default-unsubscribed))
16696 (nreverse reads))))
16697 (setq newsrc (cons info newsrc))))))
16700 (setq newsrc (nreverse newsrc))
16702 (if (not already-read)
16704 ;; We now have two newsrc lists - `newsrc', which is what we
16705 ;; have read from .newsrc, and `gnus-newsrc-alist', which is
16706 ;; what we've read from .newsrc.eld. We have to merge these
16707 ;; lists. We do this by "attaching" any (foreign) groups in the
16708 ;; gnus-newsrc-alist to the (native) group that precedes them.
16709 (let ((rc (cdr gnus-newsrc-alist))
16710 (prev gnus-newsrc-alist)
16713 (or (null (nth 4 (car rc))) ; It's a native group.
16714 (assoc (caar rc) newsrc) ; It's already in the alist.
16715 (if (setq entry (assoc (caar prev) newsrc))
16716 (setcdr (setq mentry (memq entry newsrc))
16717 (cons (car rc) (cdr mentry)))
16718 (setq newsrc (cons (car rc) newsrc))))
16722 (setq gnus-newsrc-alist newsrc)
16723 ;; We make the newsrc hashtb.
16724 (gnus-make-hashtable-from-newsrc-alist)
16726 ;; Finally, if we read some options lines, we parse them.
16727 (or (string= gnus-newsrc-options "")
16728 (gnus-newsrc-parse-options gnus-newsrc-options))))
16730 ;; Parse options lines to find "options -n !all rec.all" and stuff.
16731 ;; The return value will be a list on the form
16732 ;; ((regexp1 . ignore)
16733 ;; (regexp2 . subscribe)...)
16734 ;; When handling new newsgroups, groups that match a `ignore' regexp
16735 ;; will be ignored, and groups that match a `subscribe' regexp will be
16736 ;; subscribed. A line like
16737 ;; options -n !all rec.all
16738 ;; will lead to a list that looks like
16739 ;; (("^rec\\..+" . subscribe)
16740 ;; ("^.+" . ignore))
16741 ;; So all "rec.*" groups will be subscribed, while all the other
16742 ;; groups will be ignored. Note that "options -n !all rec.all" is very
16743 ;; different from "options -n rec.all !all".
16744 (defun gnus-newsrc-parse-options (options)
16747 (gnus-set-work-buffer)
16748 (insert (regexp-quote options))
16749 ;; First we treat all continuation lines.
16750 (goto-char (point-min))
16751 (while (re-search-forward "\n[ \t]+" nil t)
16752 (replace-match " " t t))
16753 ;; Then we transform all "all"s into ".+"s.
16754 (goto-char (point-min))
16755 (while (re-search-forward "\\ball\\b" nil t)
16756 (replace-match ".+" t t))
16757 (goto-char (point-min))
16758 ;; We remove all other options than the "-n" ones.
16759 (while (re-search-forward "[ \t]-[^n][^-]*" nil t)
16760 (replace-match " ")
16762 (goto-char (point-min))
16764 ;; We are only interested in "options -n" lines - we
16765 ;; ignore the other option lines.
16766 (while (re-search-forward "[ \t]-n" nil t)
16768 (or (save-excursion
16769 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t)
16771 (gnus-point-at-eol)))
16772 ;; Search for all "words"...
16773 (while (re-search-forward "[^ \t,\n]+" eol t)
16774 (if (= (char-after (match-beginning 0)) ?!)
16775 ;; If the word begins with a bang (!), this is a "not"
16776 ;; spec. We put this spec (minus the bang) and the
16777 ;; symbol `ignore' into the list.
16778 (setq out (cons (cons (concat
16779 "^" (buffer-substring
16780 (1+ (match-beginning 0))
16783 ;; There was no bang, so this is a "yes" spec.
16784 (setq out (cons (cons (concat "^" (match-string 0))
16785 'subscribe) out)))))
16787 (setq gnus-newsrc-options-n out))))
16789 (defun gnus-save-newsrc-file (&optional force)
16790 "Save .newsrc file."
16791 ;; Note: We cannot save .newsrc file if all newsgroups are removed
16792 ;; from the variable gnus-newsrc-alist.
16793 (when (and (or gnus-newsrc-alist gnus-killed-list)
16794 gnus-current-startup-file)
16796 (if (and (or gnus-use-dribble-file gnus-slave)
16798 (or (not gnus-dribble-buffer)
16799 (not (buffer-name gnus-dribble-buffer))
16800 (zerop (save-excursion
16801 (set-buffer gnus-dribble-buffer)
16803 (gnus-message 4 "(No changes need to be saved)")
16804 (run-hooks 'gnus-save-newsrc-hook)
16806 (gnus-slave-save-newsrc)
16808 (when gnus-save-newsrc-file
16809 (gnus-message 5 "Saving %s..." gnus-current-startup-file)
16810 (gnus-gnus-to-newsrc-format)
16811 (gnus-message 5 "Saving %s...done" gnus-current-startup-file))
16812 ;; Save .newsrc.eld.
16813 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
16814 (make-local-variable 'version-control)
16815 (setq version-control 'never)
16816 (setq buffer-file-name
16817 (concat gnus-current-startup-file ".eld"))
16818 (setq default-directory (file-name-directory buffer-file-name))
16819 (gnus-add-current-to-buffer-list)
16820 (buffer-disable-undo (current-buffer))
16822 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file)
16823 (gnus-gnus-to-quick-newsrc-format)
16824 (run-hooks 'gnus-save-quick-newsrc-hook)
16826 (kill-buffer (current-buffer))
16828 5 "Saving %s.eld...done" gnus-current-startup-file))
16829 (gnus-dribble-delete-file)
16830 (gnus-group-set-mode-line)))))
16832 (defun gnus-gnus-to-quick-newsrc-format ()
16833 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
16834 (insert ";; Gnus startup file.\n")
16835 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
16836 (insert ";; to read .newsrc.\n")
16837 (insert "(setq gnus-newsrc-file-version "
16838 (prin1-to-string gnus-version) ")\n")
16840 (if gnus-save-killed-list gnus-variable-list
16841 ;; Remove the `gnus-killed-list' from the list of variables
16842 ;; to be saved, if required.
16843 (delq 'gnus-killed-list (copy-sequence gnus-variable-list))))
16844 ;; Peel off the "dummy" group.
16845 (gnus-newsrc-alist (cdr gnus-newsrc-alist))
16847 ;; Insert the variables into the file.
16849 (when (and (boundp (setq variable (pop variables)))
16850 (symbol-value variable))
16851 (insert "(setq " (symbol-name variable) " '")
16852 (prin1 (symbol-value variable) (current-buffer))
16855 (defun gnus-gnus-to-newsrc-format ()
16856 ;; Generate and save the .newsrc file.
16858 (set-buffer (create-file-buffer gnus-current-startup-file))
16859 (let ((newsrc (cdr gnus-newsrc-alist))
16860 (standard-output (current-buffer))
16861 info ranges range method)
16862 (setq buffer-file-name gnus-current-startup-file)
16863 (setq default-directory (file-name-directory buffer-file-name))
16864 (buffer-disable-undo (current-buffer))
16867 (if gnus-newsrc-options (insert gnus-newsrc-options))
16868 ;; Write subscribed and unsubscribed.
16869 (while (setq info (pop newsrc))
16870 ;; Don't write foreign groups to .newsrc.
16871 (when (or (null (setq method (gnus-info-method info)))
16872 (equal method "native")
16873 (gnus-server-equal method gnus-select-method))
16874 (insert (gnus-info-group info)
16875 (if (> (gnus-info-level info) gnus-level-subscribed)
16877 (when (setq ranges (gnus-info-read info))
16879 (if (not (listp (cdr ranges)))
16880 (if (= (car ranges) (cdr ranges))
16881 (princ (car ranges))
16882 (princ (car ranges))
16884 (princ (cdr ranges)))
16885 (while (setq range (pop ranges))
16886 (if (or (atom range) (= (car range) (cdr range)))
16887 (princ (or (and (atom range) range) (car range)))
16888 (princ (car range))
16890 (princ (cdr range)))
16891 (if ranges (insert ",")))))
16893 (make-local-variable 'version-control)
16894 (setq version-control 'never)
16895 ;; It has been reported that sometime the modtime on the .newsrc
16896 ;; file seems to be off. We really do want to overwrite it, so
16897 ;; we clear the modtime here before saving. It's a bit odd,
16899 ;; sometimes the modtime clear isn't sufficient. most brute force:
16900 ;; delete the silly thing entirely first. but this fails to provide
16901 ;; such niceties as .newsrc~ creation.
16902 (if gnus-modtime-botch
16903 (delete-file gnus-startup-file)
16904 (clear-visited-file-modtime))
16905 (run-hooks 'gnus-save-standard-newsrc-hook)
16907 (kill-buffer (current-buffer)))))
16911 ;;; Slave functions.
16914 (defun gnus-slave-save-newsrc ()
16916 (set-buffer gnus-dribble-buffer)
16918 (make-temp-name (concat gnus-current-startup-file "-slave-"))))
16919 (write-region (point-min) (point-max) slave-name nil 'nomesg))))
16921 (defun gnus-master-read-slave-newsrc ()
16924 (file-name-directory gnus-current-startup-file)
16928 (file-name-nondirectory gnus-current-startup-file)
16932 (if (not slave-files)
16933 () ; There are no slave files to read.
16934 (gnus-message 7 "Reading slave newsrcs...")
16936 (set-buffer (get-buffer-create " *gnus slave*"))
16937 (buffer-disable-undo (current-buffer))
16939 (sort (mapcar (lambda (file)
16940 (list (nth 5 (file-attributes file)) file))
16943 (or (< (caar f1) (caar f2))
16944 (< (nth 1 (car f1)) (nth 1 (car f2)))))))
16947 (setq file (nth 1 (car slave-files)))
16948 (insert-file-contents file)
16949 (if (condition-case ()
16951 (eval-buffer (current-buffer))
16954 (gnus-error 3.2 "Possible error in %s" file)
16956 (or gnus-slave ; Slaves shouldn't delete these files.
16960 (setq slave-files (cdr slave-files))))
16961 (gnus-message 7 "Reading slave newsrcs...done"))))
16965 ;;; Group description.
16968 (defun gnus-read-all-descriptions-files ()
16969 (let ((methods (cons gnus-select-method
16971 (when gnus-message-archive-method
16973 gnus-secondary-select-methods))))
16975 (gnus-read-descriptions-file (car methods))
16976 (setq methods (cdr methods)))
16979 (defun gnus-read-descriptions-file (&optional method)
16980 (let ((method (or method gnus-select-method))
16982 (when (stringp method)
16983 (setq method (gnus-server-to-method method)))
16984 ;; We create the hashtable whether we manage to read the desc file
16985 ;; to avoid trying to re-read after a failed read.
16986 (or gnus-description-hashtb
16987 (setq gnus-description-hashtb
16988 (gnus-make-hashtable (length gnus-active-hashtb))))
16989 ;; Mark this method's desc file as read.
16990 (gnus-sethash (gnus-group-prefixed-name "" method) "Has read"
16991 gnus-description-hashtb)
16993 (gnus-message 5 "Reading descriptions file via %s..." (car method))
16995 ((not (gnus-check-server method))
16996 (gnus-message 1 "Couldn't open server")
16998 ((not (gnus-request-list-newsgroups method))
16999 (gnus-message 1 "Couldn't read newsgroups descriptions")
17004 (set-buffer nntp-server-buffer)
17005 (goto-char (point-min))
17006 (when (or (search-forward "\n.\n" nil t)
17007 (goto-char (point-max)))
17008 (beginning-of-line)
17009 (narrow-to-region (point-min) (point)))
17010 ;; If these are groups from a foreign select method, we insert the
17011 ;; group prefix in front of the group names.
17012 (and method (not (gnus-server-equal
17013 (gnus-server-get-method nil method)
17014 (gnus-server-get-method nil gnus-select-method)))
17015 (let ((prefix (gnus-group-prefixed-name "" method)))
17016 (goto-char (point-min))
17017 (while (and (not (eobp))
17018 (progn (insert prefix)
17019 (zerop (forward-line 1)))))))
17020 (goto-char (point-min))
17021 (while (not (eobp))
17022 ;; If we get an error, we set group to 0, which is not a
17026 (let ((obarray gnus-description-hashtb))
17027 ;; Group is set to a symbol interned in this
17029 (read nntp-server-buffer))
17031 (skip-chars-forward " \t")
17032 ;; ... which leads to this line being effectively ignored.
17033 (and (symbolp group)
17034 (set group (buffer-substring
17035 (point) (progn (end-of-line) (point)))))
17036 (forward-line 1))))
17037 (gnus-message 5 "Reading descriptions file...done")
17040 (defun gnus-group-get-description (group)
17041 "Get the description of a group by sending XGTITLE to the server."
17042 (when (gnus-request-group-description group)
17044 (set-buffer nntp-server-buffer)
17045 (goto-char (point-min))
17046 (when (looking-at "[^ \t]+[ \t]+\\(.*\\)")
17047 (match-string 1)))))
17051 ;;; Buffering of read articles.
17054 (defvar gnus-backlog-buffer " *Gnus Backlog*")
17055 (defvar gnus-backlog-articles nil)
17056 (defvar gnus-backlog-hashtb nil)
17058 (defun gnus-backlog-buffer ()
17059 "Return the backlog buffer."
17060 (or (get-buffer gnus-backlog-buffer)
17062 (set-buffer (get-buffer-create gnus-backlog-buffer))
17063 (buffer-disable-undo (current-buffer))
17064 (setq buffer-read-only t)
17065 (gnus-add-current-to-buffer-list)
17066 (get-buffer gnus-backlog-buffer))))
17068 (defun gnus-backlog-setup ()
17069 "Initialize backlog variables."
17070 (unless gnus-backlog-hashtb
17071 (setq gnus-backlog-hashtb (make-vector 1023 0))))
17073 (gnus-add-shutdown 'gnus-backlog-shutdown 'gnus)
17075 (defun gnus-backlog-shutdown ()
17076 "Clear all backlog variables and buffers."
17077 (when (get-buffer gnus-backlog-buffer)
17078 (kill-buffer gnus-backlog-buffer))
17079 (setq gnus-backlog-hashtb nil
17080 gnus-backlog-articles nil))
17082 (defun gnus-backlog-enter-article (group number buffer)
17083 (gnus-backlog-setup)
17084 (let ((ident (intern (concat group ":" (int-to-string number))
17085 gnus-backlog-hashtb))
17087 (if (memq ident gnus-backlog-articles)
17088 () ; It's already kept.
17089 ;; Remove the oldest article, if necessary.
17090 (and (numberp gnus-keep-backlog)
17091 (>= (length gnus-backlog-articles) gnus-keep-backlog)
17092 (gnus-backlog-remove-oldest-article))
17093 (setq gnus-backlog-articles (cons ident gnus-backlog-articles))
17094 ;; Insert the new article.
17096 (set-buffer (gnus-backlog-buffer))
17097 (let (buffer-read-only)
17098 (goto-char (point-max))
17099 (or (bolp) (insert "\n"))
17101 (insert-buffer-substring buffer)
17102 ;; Tag the beginning of the article with the ident.
17103 (gnus-put-text-property b (1+ b) 'gnus-backlog ident))))))
17105 (defun gnus-backlog-remove-oldest-article ()
17107 (set-buffer (gnus-backlog-buffer))
17108 (goto-char (point-min))
17109 (if (zerop (buffer-size))
17110 () ; The buffer is empty.
17111 (let ((ident (get-text-property (point) 'gnus-backlog))
17113 ;; Remove the ident from the list of articles.
17115 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
17116 ;; Delete the article itself.
17118 (point) (next-single-property-change
17119 (1+ (point)) 'gnus-backlog nil (point-max)))))))
17121 (defun gnus-backlog-remove-article (group number)
17122 "Remove article NUMBER in GROUP from the backlog."
17123 (when (numberp number)
17124 (gnus-backlog-setup)
17125 (let ((ident (intern (concat group ":" (int-to-string number))
17126 gnus-backlog-hashtb))
17128 (when (memq ident gnus-backlog-articles)
17129 ;; It was in the backlog.
17131 (set-buffer (gnus-backlog-buffer))
17132 (let (buffer-read-only)
17133 (when (setq beg (text-property-any
17134 (point-min) (point-max) 'gnus-backlog
17136 ;; Find the end (i. e., the beginning of the next article).
17138 (next-single-property-change
17139 (1+ beg) 'gnus-backlog (current-buffer) (point-max)))
17140 (delete-region beg end)
17144 (defun gnus-backlog-request-article (group number buffer)
17145 (when (numberp number)
17146 (gnus-backlog-setup)
17147 (let ((ident (intern (concat group ":" (int-to-string number))
17148 gnus-backlog-hashtb))
17150 (when (memq ident gnus-backlog-articles)
17151 ;; It was in the backlog.
17153 (set-buffer (gnus-backlog-buffer))
17154 (if (not (setq beg (text-property-any
17155 (point-min) (point-max) 'gnus-backlog
17157 ;; It wasn't in the backlog after all.
17159 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
17160 ;; Find the end (i. e., the beginning of the next article).
17162 (next-single-property-change
17163 (1+ beg) 'gnus-backlog (current-buffer) (point-max)))))
17164 (let ((buffer-read-only nil))
17166 (insert-buffer-substring gnus-backlog-buffer beg end)
17169 ;; Allow redefinition of Gnus functions.
17171 (gnus-ems-redefine)
17175 ;;; gnus.el ends here