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.22"
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 (gnus-server-mode "(gnus)The Server Buffer")
1744 (gnus-browse-mode "(gnus)Browse Foreign Server")
1745 (gnus-tree-mode "(gnus)Tree Display")
1747 "Alist of major modes and related Info nodes.")
1749 (defvar gnus-group-buffer "*Group*")
1750 (defvar gnus-summary-buffer "*Summary*")
1751 (defvar gnus-article-buffer "*Article*")
1752 (defvar gnus-server-buffer "*Server*")
1754 (defvar gnus-work-buffer " *gnus work*")
1756 (defvar gnus-original-article-buffer " *Original Article*")
1757 (defvar gnus-original-article nil)
1759 (defvar gnus-buffer-list nil
1760 "Gnus buffers that should be killed on exit.")
1762 (defvar gnus-slave nil
1763 "Whether this Gnus is a slave or not.")
1765 (defvar gnus-variable-list
1766 '(gnus-newsrc-options gnus-newsrc-options-n
1767 gnus-newsrc-last-checked-date
1768 gnus-newsrc-alist gnus-server-alist
1769 gnus-killed-list gnus-zombie-list
1770 gnus-topic-topology gnus-topic-alist
1772 "Gnus variables saved in the quick startup file.")
1774 (defvar gnus-newsrc-options nil
1775 "Options line in the .newsrc file.")
1777 (defvar gnus-newsrc-options-n nil
1778 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1780 (defvar gnus-newsrc-last-checked-date nil
1781 "Date Gnus last asked server for new newsgroups.")
1783 (defvar gnus-topic-topology nil
1784 "The complete topic hierarchy.")
1786 (defvar gnus-topic-alist nil
1787 "The complete topic-group alist.")
1789 (defvar gnus-newsrc-alist nil
1790 "Assoc list of read articles.
1791 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1793 (defvar gnus-newsrc-hashtb nil
1794 "Hashtable of gnus-newsrc-alist.")
1796 (defvar gnus-killed-list nil
1797 "List of killed newsgroups.")
1799 (defvar gnus-killed-hashtb nil
1800 "Hash table equivalent of gnus-killed-list.")
1802 (defvar gnus-zombie-list nil
1803 "List of almost dead newsgroups.")
1805 (defvar gnus-description-hashtb nil
1806 "Descriptions of newsgroups.")
1808 (defvar gnus-list-of-killed-groups nil
1809 "List of newsgroups that have recently been killed by the user.")
1811 (defvar gnus-active-hashtb nil
1812 "Hashtable of active articles.")
1814 (defvar gnus-moderated-list nil
1815 "List of moderated newsgroups.")
1817 (defvar gnus-group-marked nil)
1819 (defvar gnus-current-startup-file nil
1820 "Startup file for the current host.")
1822 (defvar gnus-last-search-regexp nil
1823 "Default regexp for article search command.")
1825 (defvar gnus-last-shell-command nil
1826 "Default shell command on article.")
1828 (defvar gnus-current-select-method nil
1829 "The current method for selecting a newsgroup.")
1831 (defvar gnus-group-list-mode nil)
1833 (defvar gnus-article-internal-prepare-hook nil)
1835 (defvar gnus-newsgroup-name nil)
1836 (defvar gnus-newsgroup-begin nil)
1837 (defvar gnus-newsgroup-end nil)
1838 (defvar gnus-newsgroup-last-rmail nil)
1839 (defvar gnus-newsgroup-last-mail nil)
1840 (defvar gnus-newsgroup-last-folder nil)
1841 (defvar gnus-newsgroup-last-file nil)
1842 (defvar gnus-newsgroup-auto-expire nil)
1843 (defvar gnus-newsgroup-active nil)
1845 (defvar gnus-newsgroup-data nil)
1846 (defvar gnus-newsgroup-data-reverse nil)
1847 (defvar gnus-newsgroup-limit nil)
1848 (defvar gnus-newsgroup-limits nil)
1850 (defvar gnus-newsgroup-unreads nil
1851 "List of unread articles in the current newsgroup.")
1853 (defvar gnus-newsgroup-unselected nil
1854 "List of unselected unread articles in the current newsgroup.")
1856 (defvar gnus-newsgroup-reads nil
1857 "Alist of read articles and article marks in the current newsgroup.")
1859 (defvar gnus-newsgroup-expunged-tally nil)
1861 (defvar gnus-newsgroup-marked nil
1862 "List of ticked articles in the current newsgroup (a subset of unread art).")
1864 (defvar gnus-newsgroup-killed nil
1865 "List of ranges of articles that have been through the scoring process.")
1867 (defvar gnus-newsgroup-cached nil
1868 "List of articles that come from the article cache.")
1870 (defvar gnus-newsgroup-saved nil
1871 "List of articles that have been saved.")
1873 (defvar gnus-newsgroup-kill-headers nil)
1875 (defvar gnus-newsgroup-replied nil
1876 "List of articles that have been replied to in the current newsgroup.")
1878 (defvar gnus-newsgroup-expirable nil
1879 "List of articles in the current newsgroup that can be expired.")
1881 (defvar gnus-newsgroup-processable nil
1882 "List of articles in the current newsgroup that can be processed.")
1884 (defvar gnus-newsgroup-bookmarks nil
1885 "List of articles in the current newsgroup that have bookmarks.")
1887 (defvar gnus-newsgroup-dormant nil
1888 "List of dormant articles in the current newsgroup.")
1890 (defvar gnus-newsgroup-scored nil
1891 "List of scored articles in the current newsgroup.")
1893 (defvar gnus-newsgroup-headers nil
1894 "List of article headers in the current newsgroup.")
1896 (defvar gnus-newsgroup-threads nil)
1898 (defvar gnus-newsgroup-prepared nil
1899 "Whether the current group has been prepared properly.")
1901 (defvar gnus-newsgroup-ancient nil
1902 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1904 (defvar gnus-newsgroup-sparse nil)
1906 (defvar gnus-current-article nil)
1907 (defvar gnus-article-current nil)
1908 (defvar gnus-current-headers nil)
1909 (defvar gnus-have-all-headers nil)
1910 (defvar gnus-last-article nil)
1911 (defvar gnus-newsgroup-history nil)
1912 (defvar gnus-current-kill-article nil)
1914 ;; Save window configuration.
1915 (defvar gnus-prev-winconf nil)
1917 (defvar gnus-summary-mark-positions nil)
1918 (defvar gnus-group-mark-positions nil)
1920 (defvar gnus-reffed-article-number nil)
1922 ;;; Let the byte-compiler know that we know about this variable.
1923 (defvar rmail-default-rmail-file)
1925 (defvar gnus-cache-removable-articles nil)
1927 (defvar gnus-dead-summary nil)
1929 (defconst gnus-summary-local-variables
1930 '(gnus-newsgroup-name
1931 gnus-newsgroup-begin gnus-newsgroup-end
1932 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1933 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1934 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1935 gnus-newsgroup-unselected gnus-newsgroup-marked
1936 gnus-newsgroup-reads gnus-newsgroup-saved
1937 gnus-newsgroup-replied gnus-newsgroup-expirable
1938 gnus-newsgroup-processable gnus-newsgroup-killed
1939 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1940 gnus-newsgroup-headers gnus-newsgroup-threads
1941 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1942 gnus-current-article gnus-current-headers gnus-have-all-headers
1943 gnus-last-article gnus-article-internal-prepare-hook
1944 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1945 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1946 gnus-newsgroup-async gnus-thread-expunge-below
1947 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1948 (gnus-summary-mark-below . global)
1949 gnus-newsgroup-active gnus-scores-exclude-files
1950 gnus-newsgroup-history gnus-newsgroup-ancient
1951 gnus-newsgroup-sparse
1952 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1953 gnus-newsgroup-adaptive-score-file
1954 (gnus-newsgroup-expunged-tally . 0)
1955 gnus-cache-removable-articles gnus-newsgroup-cached
1956 gnus-newsgroup-data gnus-newsgroup-data-reverse
1957 gnus-newsgroup-limit gnus-newsgroup-limits)
1958 "Variables that are buffer-local to the summary buffers.")
1960 (defconst gnus-bug-message
1961 "Sending a bug report to the Gnus Towers.
1962 ========================================
1964 The buffer below is a mail buffer. When you press `C-c C-c', it will
1965 be sent to the Gnus Bug Exterminators.
1967 At the bottom of the buffer you'll see lots of variable settings.
1968 Please do not delete those. They will tell the Bug People what your
1969 environment is, so that it will be easier to locate the bugs.
1971 If you have found a bug that makes Emacs go \"beep\", set
1972 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
1973 and include the backtrace in your bug report.
1975 Please describe the bug in annoying, painstaking detail.
1977 Thank you for your help in stamping out bugs.
1980 ;;; End of variables.
1982 ;; Define some autoload functions Gnus might use.
1985 ;; This little mapcar goes through the list below and marks the
1986 ;; symbols in question as autoloaded functions.
1989 (let ((interactive (nth 1 (memq ':interactive package))))
1993 (when (consp function)
1994 (setq keymap (car (memq 'keymap function)))
1995 (setq function (car function)))
1996 (autoload function (car package) nil interactive keymap)))
1997 (if (eq (nth 1 package) ':interactive)
2000 '(("metamail" metamail-buffer)
2001 ("info" Info-goto-node)
2002 ("hexl" hexl-hex-string-to-integer)
2003 ("pp" pp pp-to-string pp-eval-expression)
2004 ("mail-extr" mail-extract-address-components)
2005 ("nnmail" nnmail-split-fancy nnmail-article-group)
2006 ("nnvirtual" nnvirtual-catchup-group)
2007 ("timezone" timezone-make-date-arpa-standard timezone-fix-time
2008 timezone-make-sortable-date timezone-make-time-string)
2009 ("rmailout" rmail-output)
2010 ("rmail" rmail-insert-rmail-file-header rmail-count-new-messages
2012 ("gnus-soup" :interactive t
2013 gnus-group-brew-soup gnus-brew-soup gnus-soup-add-article
2014 gnus-soup-send-replies gnus-soup-save-areas gnus-soup-pack-packet)
2015 ("nnsoup" nnsoup-pack-replies)
2016 ("gnus-scomo" :interactive t gnus-score-mode)
2017 ("gnus-mh" gnus-mh-mail-setup gnus-summary-save-article-folder
2018 gnus-Folder-save-name gnus-folder-save-name)
2019 ("gnus-mh" :interactive t gnus-summary-save-in-folder)
2020 ("gnus-vis" gnus-group-make-menu-bar gnus-summary-make-menu-bar
2021 gnus-server-make-menu-bar gnus-article-make-menu-bar
2022 gnus-browse-make-menu-bar gnus-highlight-selected-summary
2023 gnus-summary-highlight-line gnus-carpal-setup-buffer
2024 gnus-group-highlight-line
2025 gnus-article-add-button gnus-insert-next-page-button
2026 gnus-insert-prev-page-button gnus-visual-turn-off-edit-menu)
2027 ("gnus-vis" :interactive t
2028 gnus-article-push-button gnus-article-press-button
2029 gnus-article-highlight gnus-article-highlight-some
2030 gnus-article-highlight-headers gnus-article-highlight-signature
2031 gnus-article-add-buttons gnus-article-add-buttons-to-head
2032 gnus-article-next-button gnus-article-prev-button)
2033 ("gnus-demon" gnus-demon-add-nocem gnus-demon-add-scanmail
2034 gnus-demon-add-disconnection gnus-demon-add-handler
2035 gnus-demon-remove-handler)
2036 ("gnus-demon" :interactive t
2037 gnus-demon-init gnus-demon-cancel)
2038 ("gnus-salt" gnus-highlight-selected-tree gnus-possibly-generate-tree
2039 gnus-tree-open gnus-tree-close)
2040 ("gnus-nocem" gnus-nocem-scan-groups gnus-nocem-close
2041 gnus-nocem-unwanted-article-p)
2042 ("gnus-srvr" gnus-enter-server-buffer gnus-server-set-info)
2043 ("gnus-srvr" gnus-browse-foreign-server)
2044 ("gnus-cite" :interactive t
2045 gnus-article-highlight-citation gnus-article-hide-citation-maybe
2046 gnus-article-hide-citation gnus-article-fill-cited-article
2047 gnus-article-hide-citation-in-followups)
2048 ("gnus-kill" gnus-kill gnus-apply-kill-file-internal
2049 gnus-kill-file-edit-file gnus-kill-file-raise-followups-to-author
2050 gnus-execute gnus-expunge)
2051 ("gnus-cache" gnus-cache-possibly-enter-article gnus-cache-save-buffers
2052 gnus-cache-possibly-remove-articles gnus-cache-request-article
2053 gnus-cache-retrieve-headers gnus-cache-possibly-alter-active
2054 gnus-cache-enter-remove-article gnus-cached-article-p
2055 gnus-cache-open gnus-cache-close gnus-cache-update-article)
2056 ("gnus-cache" :interactive t gnus-jog-cache gnus-cache-enter-article
2057 gnus-cache-remove-article)
2058 ("gnus-score" :interactive t
2059 gnus-summary-increase-score gnus-summary-lower-score
2060 gnus-score-flush-cache gnus-score-close
2061 gnus-score-raise-same-subject-and-select
2062 gnus-score-raise-same-subject gnus-score-default
2063 gnus-score-raise-thread gnus-score-lower-same-subject-and-select
2064 gnus-score-lower-same-subject gnus-score-lower-thread
2065 gnus-possibly-score-headers gnus-summary-raise-score
2066 gnus-summary-set-score gnus-summary-current-score)
2068 (gnus-summary-score-map keymap) gnus-score-save gnus-score-headers
2069 gnus-current-score-file-nondirectory gnus-score-adaptive
2070 gnus-score-find-trace gnus-score-file-name)
2071 ("gnus-edit" :interactive t gnus-score-customize)
2072 ("gnus-topic" :interactive t gnus-topic-mode)
2073 ("gnus-topic" gnus-topic-remove-group)
2074 ("gnus-salt" :interactive t gnus-pick-mode gnus-binary-mode)
2075 ("gnus-uu" (gnus-uu-extract-map keymap) (gnus-uu-mark-map keymap))
2076 ("gnus-uu" :interactive t
2077 gnus-uu-digest-mail-forward gnus-uu-digest-post-forward
2078 gnus-uu-mark-series gnus-uu-mark-region gnus-uu-mark-buffer
2079 gnus-uu-mark-by-regexp gnus-uu-mark-all
2080 gnus-uu-mark-sparse gnus-uu-mark-thread gnus-uu-decode-uu
2081 gnus-uu-decode-uu-and-save gnus-uu-decode-unshar
2082 gnus-uu-decode-unshar-and-save gnus-uu-decode-save
2083 gnus-uu-decode-binhex gnus-uu-decode-uu-view
2084 gnus-uu-decode-uu-and-save-view gnus-uu-decode-unshar-view
2085 gnus-uu-decode-unshar-and-save-view gnus-uu-decode-save-view
2086 gnus-uu-decode-binhex-view)
2087 ("gnus-msg" (gnus-summary-send-map keymap)
2088 gnus-mail-yank-original gnus-mail-send-and-exit
2089 gnus-article-mail gnus-new-mail gnus-mail-reply)
2090 ("gnus-msg" :interactive t
2091 gnus-group-post-news gnus-group-mail gnus-summary-post-news
2092 gnus-summary-followup gnus-summary-followup-with-original
2093 gnus-summary-cancel-article gnus-summary-supersede-article
2094 gnus-post-news gnus-inews-news
2095 gnus-summary-reply gnus-summary-reply-with-original
2096 gnus-summary-mail-forward gnus-summary-mail-other-window
2098 ("gnus-picon" :interactive t gnus-article-display-picons
2099 gnus-group-display-picons gnus-picons-article-display-x-face)
2100 ("gnus-gl" bbb-login bbb-logout bbb-grouplens-group-p
2101 gnus-grouplens-mode)
2102 ("smiley" :interactive t gnus-smiley-display)
2103 ("gnus-vm" gnus-vm-mail-setup)
2104 ("gnus-vm" :interactive t gnus-summary-save-in-vm
2105 gnus-summary-save-article-vm))))
2109 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2110 ;; If you want the cursor to go somewhere else, set these two
2111 ;; functions in some startup hook to whatever you want.
2112 (defalias 'gnus-summary-position-point 'gnus-goto-colon)
2113 (defalias 'gnus-group-position-point 'gnus-goto-colon)
2115 ;;; Various macros and substs.
2117 (defun gnus-header-from (header)
2118 (mail-header-from header))
2120 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
2121 "Pop to BUFFER, evaluate FORMS, and then return to the original window."
2122 (let ((tempvar (make-symbol "GnusStartBufferWindow"))
2123 (w (make-symbol "w"))
2124 (buf (make-symbol "buf")))
2125 `(let* ((,tempvar (selected-window))
2127 (,w (get-buffer-window ,buf 'visible)))
2132 (pop-to-buffer ,buf))
2134 (select-window ,tempvar)))))
2136 (put 'gnus-eval-in-buffer-window 'lisp-indent-function 1)
2137 (put 'gnus-eval-in-buffer-window 'lisp-indent-hook 1)
2138 (put 'gnus-eval-in-buffer-window 'edebug-form-spec '(form body))
2140 (defmacro gnus-gethash (string hashtable)
2141 "Get hash value of STRING in HASHTABLE."
2142 `(symbol-value (intern-soft ,string ,hashtable)))
2144 (defmacro gnus-sethash (string value hashtable)
2145 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2146 `(set (intern ,string ,hashtable) ,value))
2148 (defmacro gnus-intern-safe (string hashtable)
2149 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2150 `(let ((symbol (intern ,string ,hashtable)))
2155 (defmacro gnus-group-unread (group)
2156 "Get the currently computed number of unread articles in GROUP."
2157 `(car (gnus-gethash ,group gnus-newsrc-hashtb)))
2159 (defmacro gnus-group-entry (group)
2160 "Get the newsrc entry for GROUP."
2161 `(gnus-gethash ,group gnus-newsrc-hashtb))
2163 (defmacro gnus-active (group)
2164 "Get active info on GROUP."
2165 `(gnus-gethash ,group gnus-active-hashtb))
2167 (defmacro gnus-set-active (group active)
2168 "Set GROUP's active info."
2169 `(gnus-sethash ,group ,active gnus-active-hashtb))
2171 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2172 ;; function `substring' might cut on a middle of multi-octet
2174 (defun gnus-truncate-string (str width)
2175 (substring str 0 width))
2177 ;; Added by Geoffrey T. Dairiki <dairiki@u.washington.edu>. A safe way
2178 ;; to limit the length of a string. This function is necessary since
2179 ;; `(substr "abc" 0 30)' pukes with "Args out of range".
2180 (defsubst gnus-limit-string (str width)
2181 (if (> (length str) width)
2182 (substring str 0 width)
2185 (defsubst gnus-simplify-subject-re (subject)
2186 "Remove \"Re:\" from subject lines."
2187 (if (string-match "^[Rr][Ee]: *" subject)
2188 (substring subject (match-end 0))
2191 (defsubst gnus-functionp (form)
2192 "Return non-nil if FORM is funcallable."
2193 (or (and (symbolp form) (fboundp form))
2194 (and (listp form) (eq (car form) 'lambda))))
2196 (defsubst gnus-goto-char (point)
2197 (and point (goto-char point)))
2199 (defmacro gnus-buffer-exists-p (buffer)
2200 `(let ((buffer ,buffer))
2202 (funcall (if (stringp buffer) 'get-buffer 'buffer-name)
2205 (defmacro gnus-kill-buffer (buffer)
2206 `(let ((buf ,buffer))
2207 (if (gnus-buffer-exists-p buf)
2208 (kill-buffer buf))))
2210 (defsubst gnus-point-at-bol ()
2211 "Return point at the beginning of the line."
2218 (defsubst gnus-point-at-eol ()
2219 "Return point at the end of the line."
2226 (defun gnus-alive-p ()
2227 "Say whether Gnus is running or not."
2228 (and gnus-group-buffer
2229 (get-buffer gnus-group-buffer)))
2231 (defun gnus-delete-first (elt list)
2232 "Delete by side effect the first occurrence of ELT as a member of LIST."
2233 (if (equal (car list) elt)
2236 (while (and (cdr list)
2237 (not (equal (cadr list) elt)))
2238 (setq list (cdr list)))
2240 (setcdr list (cddr list)))
2243 ;; Delete the current line (and the next N lines.);
2244 (defmacro gnus-delete-line (&optional n)
2245 `(delete-region (progn (beginning-of-line) (point))
2246 (progn (forward-line ,(or n 1)) (point))))
2248 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
2249 (defvar gnus-init-inhibit nil)
2250 (defun gnus-read-init-file (&optional inhibit-next)
2251 (if gnus-init-inhibit
2252 (setq gnus-init-inhibit nil)
2253 (setq gnus-init-inhibit inhibit-next)
2255 (or (and (file-exists-p gnus-init-file)
2256 ;; Don't try to load a directory.
2257 (not (file-directory-p gnus-init-file)))
2258 (file-exists-p (concat gnus-init-file ".el"))
2259 (file-exists-p (concat gnus-init-file ".elc")))
2261 (load gnus-init-file nil t)
2263 (error "Error in %s: %s" gnus-init-file var))))))
2265 ;; Info access macros.
2267 (defmacro gnus-info-group (info)
2269 (defmacro gnus-info-rank (info)
2271 (defmacro gnus-info-read (info)
2273 (defmacro gnus-info-marks (info)
2275 (defmacro gnus-info-method (info)
2277 (defmacro gnus-info-params (info)
2280 (defmacro gnus-info-level (info)
2281 `(let ((rank (gnus-info-rank ,info)))
2285 (defmacro gnus-info-score (info)
2286 `(let ((rank (gnus-info-rank ,info)))
2287 (or (and (consp rank) (cdr rank)) 0)))
2289 (defmacro gnus-info-set-group (info group)
2290 `(setcar ,info ,group))
2291 (defmacro gnus-info-set-rank (info rank)
2292 `(setcar (nthcdr 1 ,info) ,rank))
2293 (defmacro gnus-info-set-read (info read)
2294 `(setcar (nthcdr 2 ,info) ,read))
2295 (defmacro gnus-info-set-marks (info marks)
2296 `(setcar (nthcdr 3 ,info) ,marks))
2297 (defmacro gnus-info-set-method (info method)
2298 `(setcar (nthcdr 4 ,info) ,method))
2299 (defmacro gnus-info-set-params (info params)
2300 `(setcar (nthcdr 5 ,info) ,params))
2302 (defmacro gnus-info-set-level (info level)
2303 `(let ((rank (cdr ,info)))
2304 (if (consp (car rank))
2305 (setcar (car rank) ,level)
2306 (setcar rank ,level))))
2307 (defmacro gnus-info-set-score (info score)
2308 `(let ((rank (cdr ,info)))
2309 (if (consp (car rank))
2310 (setcdr (car rank) ,score)
2311 (setcar rank (cons (car rank) ,score)))))
2313 (defmacro gnus-get-info (group)
2314 `(nth 2 (gnus-gethash ,group gnus-newsrc-hashtb)))
2316 (defun gnus-byte-code (func)
2317 "Return a form that can be `eval'ed based on FUNC."
2318 (let ((fval (symbol-function func)))
2319 (if (byte-code-function-p fval)
2320 (let ((flist (append fval nil)))
2321 (setcar flist 'byte-code)
2323 (cons 'progn (cddr fval)))))
2325 ;; Find out whether the gnus-visual TYPE is wanted.
2326 (defun gnus-visual-p (&optional type class)
2327 (and gnus-visual ; Has to be non-nil, at least.
2328 (if (not type) ; We don't care about type.
2330 (if (listp gnus-visual) ; It's a list, so we check it.
2331 (or (memq type gnus-visual)
2332 (memq class gnus-visual))
2335 ;;; Load the compatability functions.
2345 (defvar gnus-shutdown-alist nil)
2347 (defun gnus-add-shutdown (function &rest symbols)
2348 "Run FUNCTION whenever one of SYMBOLS is shut down."
2349 (push (cons function symbols) gnus-shutdown-alist))
2351 (defun gnus-shutdown (symbol)
2352 "Shut down everything that waits for SYMBOL."
2353 (let ((alist gnus-shutdown-alist)
2355 (while (setq entry (pop alist))
2356 (when (memq symbol (cdr entry))
2357 (funcall (car entry))))))
2361 ;; Format specs. The chunks below are the machine-generated forms
2362 ;; that are to be evaled as the result of the default format strings.
2363 ;; We write them in here to get them byte-compiled. That way the
2364 ;; default actions will be quite fast, while still retaining the full
2365 ;; flexibility of the user-defined format specs.
2367 ;; First we have lots of dummy defvars to let the compiler know these
2368 ;; are really dynamic variables.
2370 (defvar gnus-tmp-unread)
2371 (defvar gnus-tmp-replied)
2372 (defvar gnus-tmp-score-char)
2373 (defvar gnus-tmp-indentation)
2374 (defvar gnus-tmp-opening-bracket)
2375 (defvar gnus-tmp-lines)
2376 (defvar gnus-tmp-name)
2377 (defvar gnus-tmp-closing-bracket)
2378 (defvar gnus-tmp-subject-or-nil)
2379 (defvar gnus-tmp-subject)
2380 (defvar gnus-tmp-marked)
2381 (defvar gnus-tmp-marked-mark)
2382 (defvar gnus-tmp-subscribed)
2383 (defvar gnus-tmp-process-marked)
2384 (defvar gnus-tmp-number-of-unread)
2385 (defvar gnus-tmp-group-name)
2386 (defvar gnus-tmp-group)
2387 (defvar gnus-tmp-article-number)
2388 (defvar gnus-tmp-unread-and-unselected)
2389 (defvar gnus-tmp-news-method)
2390 (defvar gnus-tmp-news-server)
2391 (defvar gnus-tmp-article-number)
2392 (defvar gnus-mouse-face)
2393 (defvar gnus-mouse-face-prop)
2395 (defun gnus-summary-line-format-spec ()
2396 (insert gnus-tmp-unread gnus-tmp-replied
2397 gnus-tmp-score-char gnus-tmp-indentation)
2398 (gnus-put-text-property
2402 gnus-tmp-opening-bracket
2403 (format "%4d: %-20s"
2405 (if (> (length gnus-tmp-name) 20)
2406 (substring gnus-tmp-name 0 20)
2408 gnus-tmp-closing-bracket)
2410 gnus-mouse-face-prop gnus-mouse-face)
2411 (insert " " gnus-tmp-subject-or-nil "\n"))
2413 (defvar gnus-summary-line-format-spec
2414 (gnus-byte-code 'gnus-summary-line-format-spec))
2416 (defun gnus-summary-dummy-line-format-spec ()
2418 (gnus-put-text-property
2423 gnus-mouse-face-prop gnus-mouse-face)
2424 (insert " " gnus-tmp-subject "\n"))
2426 (defvar gnus-summary-dummy-line-format-spec
2427 (gnus-byte-code 'gnus-summary-dummy-line-format-spec))
2429 (defun gnus-group-line-format-spec ()
2430 (insert gnus-tmp-marked-mark gnus-tmp-subscribed
2431 gnus-tmp-process-marked
2432 gnus-group-indentation
2433 (format "%5s: " gnus-tmp-number-of-unread))
2434 (gnus-put-text-property
2437 (insert gnus-tmp-group "\n")
2439 gnus-mouse-face-prop gnus-mouse-face))
2440 (defvar gnus-group-line-format-spec
2441 (gnus-byte-code 'gnus-group-line-format-spec))
2443 (defvar gnus-format-specs
2444 `((version . ,emacs-version)
2445 (group ,gnus-group-line-format ,gnus-group-line-format-spec)
2446 (summary-dummy ,gnus-summary-dummy-line-format
2447 ,gnus-summary-dummy-line-format-spec)
2448 (summary ,gnus-summary-line-format ,gnus-summary-line-format-spec)))
2450 (defvar gnus-article-mode-line-format-spec nil)
2451 (defvar gnus-summary-mode-line-format-spec nil)
2452 (defvar gnus-group-mode-line-format-spec nil)
2454 ;;; Phew. All that gruft is over, fortunately.
2458 ;;; Gnus Utility Functions
2461 (defun gnus-extract-address-components (from)
2463 ;; First find the address - the thing with the @ in it. This may
2464 ;; not be accurate in mail addresses, but does the trick most of
2465 ;; the time in news messages.
2466 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
2467 (setq address (substring from (match-beginning 0) (match-end 0))))
2468 ;; Then we check whether the "name <address>" format is used.
2470 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2471 ;; Linear white space is not required.
2472 (string-match (concat "[ \t]*<" (regexp-quote address) ">") from)
2473 (and (setq name (substring from 0 (match-beginning 0)))
2474 ;; Strip any quotes from the name.
2475 (string-match "\".*\"" name)
2476 (setq name (substring name 1 (1- (match-end 0))))))
2477 ;; If not, then "address (name)" is used.
2479 (and (string-match "(.+)" from)
2480 (setq name (substring from (1+ (match-beginning 0))
2481 (1- (match-end 0)))))
2482 (and (string-match "()" from)
2483 (setq name address))
2484 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>.
2485 ;; XOVER might not support folded From headers.
2486 (and (string-match "(.*" from)
2487 (setq name (substring from (1+ (match-beginning 0))
2489 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2490 (list (or name from) (or address from))))
2492 (defun gnus-fetch-field (field)
2493 "Return the value of the header FIELD of current article."
2496 (let ((case-fold-search t)
2497 (inhibit-point-motion-hooks t))
2498 (nnheader-narrow-to-headers)
2499 (message-fetch-field field)))))
2501 (defun gnus-goto-colon ()
2503 (search-forward ":" (gnus-point-at-eol) t))
2506 (defun gnus-update-format (var)
2507 "Update the format specification near point."
2512 ;; Find the end of the current word.
2513 (re-search-forward "[ \t\n]" nil t)
2515 (when (re-search-backward "\\(gnus-[-a-z]+-line-format\\)" nil t)
2516 (match-string 1)))))
2517 (let* ((type (intern (progn (string-match "gnus-\\([-a-z]+\\)-line" var)
2518 (match-string 1 var))))
2519 (entry (assq type gnus-format-specs))
2522 (setq gnus-format-specs (delq entry gnus-format-specs)))
2524 (intern (format "%s-spec" var))
2525 (gnus-parse-format (setq value (symbol-value (intern var)))
2526 (symbol-value (intern (format "%s-alist" var)))
2527 (not (string-match "mode" var))))
2528 (setq spec (symbol-value (intern (format "%s-spec" var))))
2529 (push (list type value spec) gnus-format-specs)
2531 (pop-to-buffer "*Gnus Format*")
2533 (lisp-interaction-mode)
2534 (insert (pp-to-string spec))))
2536 (defun gnus-update-format-specifications (&optional force)
2537 "Update all (necessary) format specifications."
2538 ;; Make the indentation array.
2539 (gnus-make-thread-indent-array)
2541 ;; See whether all the stored info needs to be flushed.
2543 (not (equal emacs-version
2544 (cdr (assq 'version gnus-format-specs)))))
2545 (setq gnus-format-specs nil))
2547 ;; Go through all the formats and see whether they need updating.
2548 (let ((types '(summary summary-dummy group
2549 summary-mode group-mode article-mode))
2550 new-format entry type val)
2551 (while (setq type (pop types))
2552 ;; Jump to the proper buffer to find out the value of
2553 ;; the variable, if possible. (It may be buffer-local.)
2555 (let ((buffer (intern (format "gnus-%s-buffer" type)))
2557 (when (and (boundp buffer)
2558 (setq val (symbol-value buffer))
2560 (buffer-name (get-buffer val)))
2561 (set-buffer (get-buffer val)))
2562 (setq new-format (symbol-value
2563 (intern (format "gnus-%s-line-format" type))))))
2564 (setq entry (cdr (assq type gnus-format-specs)))
2566 (equal (car entry) new-format))
2567 ;; Use the old format.
2568 (set (intern (format "gnus-%s-line-format-spec" type))
2570 ;; This is a new format.
2572 (if (not (stringp new-format))
2573 ;; This is a function call or something.
2575 ;; This is a "real" format.
2579 (intern (format "gnus-%s-line-format-alist"
2580 (if (eq type 'article-mode)
2581 'summary-mode type))))
2582 (not (string-match "mode$" (symbol-name type))))))
2583 ;; Enter the new format spec into the list.
2586 (setcar (cdr entry) val)
2587 (setcar entry new-format))
2588 (push (list type new-format val) gnus-format-specs))
2589 (set (intern (format "gnus-%s-line-format-spec" type)) val))))
2591 (unless (assq 'version gnus-format-specs)
2592 (push (cons 'version emacs-version) gnus-format-specs))
2594 (gnus-update-group-mark-positions)
2595 (gnus-update-summary-mark-positions))
2597 (defun gnus-update-summary-mark-positions ()
2598 "Compute where the summary marks are to go."
2600 (when (and gnus-summary-buffer
2601 (get-buffer gnus-summary-buffer)
2602 (buffer-name (get-buffer gnus-summary-buffer)))
2603 (set-buffer gnus-summary-buffer))
2604 (let ((gnus-replied-mark 129)
2605 (gnus-score-below-mark 130)
2606 (gnus-score-over-mark 130)
2609 (spec gnus-summary-line-format-spec)
2612 (gnus-set-work-buffer)
2613 (let ((gnus-summary-line-format-spec spec))
2614 (gnus-summary-insert-line
2615 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2616 (goto-char (point-min))
2617 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2619 (goto-char (point-min))
2620 (push (cons 'replied (and (search-forward "\201" nil t)
2623 (goto-char (point-min))
2624 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2626 (setq gnus-summary-mark-positions pos))))
2628 (defun gnus-update-group-mark-positions ()
2630 (let ((gnus-process-mark 128)
2631 (gnus-group-marked '("dummy.group"))
2632 (gnus-active-hashtb (make-vector 10 0)))
2633 (gnus-set-active "dummy.group" '(0 . 0))
2634 (gnus-set-work-buffer)
2635 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
2636 (goto-char (point-min))
2637 (setq gnus-group-mark-positions
2638 (list (cons 'process (and (search-forward "\200" nil t)
2639 (- (point) 2))))))))
2641 (defvar gnus-mouse-face-0 'highlight)
2642 (defvar gnus-mouse-face-1 'highlight)
2643 (defvar gnus-mouse-face-2 'highlight)
2644 (defvar gnus-mouse-face-3 'highlight)
2645 (defvar gnus-mouse-face-4 'highlight)
2647 (defun gnus-mouse-face-function (form type)
2648 `(gnus-put-text-property
2649 (point) (progn ,@form (point))
2650 gnus-mouse-face-prop
2653 `(quote ,(symbol-value (intern (format "gnus-mouse-face-%d" type)))))))
2655 (defvar gnus-face-0 'bold)
2656 (defvar gnus-face-1 'italic)
2657 (defvar gnus-face-2 'bold-italic)
2658 (defvar gnus-face-3 'bold)
2659 (defvar gnus-face-4 'bold)
2661 (defun gnus-face-face-function (form type)
2662 `(gnus-put-text-property
2663 (point) (progn ,@form (point))
2664 'face ',(symbol-value (intern (format "gnus-face-%d" type)))))
2666 (defun gnus-max-width-function (el max-width)
2667 (or (numberp max-width) (signal 'wrong-type-argument '(numberp max-width)))
2669 `(if (> (length ,el) ,max-width)
2670 (substring ,el 0 ,max-width)
2672 `(let ((val (eval ,el)))
2674 (setq val (int-to-string val)))
2675 (if (> (length val) ,max-width)
2676 (substring val 0 ,max-width)
2679 (defun gnus-parse-format (format spec-alist &optional insert)
2680 ;; This function parses the FORMAT string with the help of the
2681 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
2682 ;; string. If the FORMAT string contains the specifiers %( and %)
2683 ;; the text between them will have the mouse-face text property.
2685 "\\`\\(.*\\)%[0-9]?[{(]\\(.*\\)%[0-9]?[})]\\(.*\n?\\)\\'"
2687 (gnus-parse-complex-format format spec-alist)
2688 ;; This is a simple format.
2689 (gnus-parse-simple-format format spec-alist insert)))
2691 (defun gnus-parse-complex-format (format spec-alist)
2693 (gnus-set-work-buffer)
2695 (goto-char (point-min))
2696 (while (re-search-forward "\"" nil t)
2697 (replace-match "\\\"" nil t))
2698 (goto-char (point-min))
2700 (while (re-search-forward "%\\([0-9]+\\)?\\([{}()]\\)" nil t)
2701 (let ((number (if (match-beginning 1)
2702 (match-string 1) "0"))
2703 (delim (aref (match-string 2) 0)))
2704 (if (or (= delim ?\() (= delim ?\{))
2705 (replace-match (concat "\"(" (if (= delim ?\() "mouse" "face")
2707 (replace-match "\")\""))))
2708 (goto-char (point-max))
2710 (goto-char (point-min))
2711 (let ((form (read (current-buffer))))
2712 (cons 'progn (gnus-complex-form-to-spec form spec-alist)))))
2714 (defun gnus-complex-form-to-spec (form spec-alist)
2719 (gnus-parse-simple-format sform spec-alist t)
2720 (funcall (intern (format "gnus-%s-face-function" (car sform)))
2721 (gnus-complex-form-to-spec (cddr sform) spec-alist)
2725 (defun gnus-parse-simple-format (format spec-alist &optional insert)
2726 ;; This function parses the FORMAT string with the help of the
2727 ;; SPEC-ALIST and returns a list that can be eval'ed to return a
2730 spec flist fstring newspec elem beg result dontinsert)
2732 (gnus-set-work-buffer)
2734 (goto-char (point-min))
2735 (while (re-search-forward "%[-0-9]*\\(,[0-9]+\\)?\\([^0-9]\\)\\(.\\)?"
2737 (if (= (setq spec (string-to-char (match-string 2))) ?%)
2739 beg (1+ (match-beginning 0)))
2740 ;; First check if there are any specs that look anything like
2741 ;; "%12,12A", ie. with a "max width specification". These have
2742 ;; to be treated specially.
2743 (if (setq beg (match-beginning 1))
2747 (1+ (match-beginning 1)) (match-end 1))))
2749 (setq beg (match-beginning 2)))
2750 ;; Find the specification from `spec-alist'.
2751 (unless (setq elem (cdr (assq spec spec-alist)))
2752 (setq elem '("*" ?s)))
2753 ;; Treat user defined format specifiers specially.
2754 (when (eq (car elem) 'gnus-tmp-user-defined)
2757 (list (intern (concat "gnus-user-format-function-"
2759 'gnus-tmp-header) ?s))
2760 (delete-region (match-beginning 3) (match-end 3)))
2761 (if (not (zerop max-width))
2762 (let ((el (car elem)))
2763 (cond ((= (cadr elem) ?c)
2764 (setq el (list 'char-to-string el)))
2766 (setq el (list 'int-to-string el))))
2767 (setq flist (cons (gnus-max-width-function el max-width)
2771 (setq flist (cons (car elem) flist))
2772 (setq newspec (cadr elem)))))
2773 ;; Remove the old specification (and possibly a ",12" string).
2774 (delete-region beg (match-end 2))
2775 ;; Insert the new specification.
2778 (setq fstring (buffer-substring 1 (point-max))))
2779 ;; Do some postprocessing to increase efficiency.
2784 ((string= fstring "")
2786 ;; Not a format string.
2787 ((not (string-match "%" fstring))
2789 ;; A format string with just a single string spec.
2790 ((string= fstring "%s")
2792 ;; A single character.
2793 ((string= fstring "%c")
2796 ((string= fstring "%d")
2799 (list `(princ ,(car flist)))
2800 (list `(int-to-string ,(car flist)))))
2801 ;; Just lots of chars and strings.
2802 ((string-match "\\`\\(%[cs]\\)+\\'" fstring)
2804 ;; A single string spec at the beginning of the spec.
2805 ((string-match "\\`%[sc][^%]+\\'" fstring)
2806 (list (car flist) (substring fstring 2)))
2807 ;; A single string spec in the middle of the spec.
2808 ((string-match "\\`\\([^%]+\\)%[sc]\\([^%]+\\)\\'" fstring)
2809 (list (match-string 1 fstring) (car flist) (match-string 2 fstring)))
2810 ;; A single string spec in the end of the spec.
2811 ((string-match "\\`\\([^%]+\\)%[sc]\\'" fstring)
2812 (list (match-string 1 fstring) (car flist)))
2813 ;; A more complex spec.
2815 (list (cons 'format (cons fstring (nreverse flist)))))))
2821 (cons 'insert result)))
2822 (cond ((stringp result)
2825 (cons 'concat result))
2828 (defun gnus-eval-format (format &optional alist props)
2829 "Eval the format variable FORMAT, using ALIST.
2830 If PROPS, insert the result."
2831 (let ((form (gnus-parse-format format alist props)))
2833 (gnus-add-text-properties (point) (progn (eval form) (point)) props)
2836 (defun gnus-remove-text-with-property (prop)
2837 "Delete all text in the current buffer with text property PROP."
2839 (goto-char (point-min))
2841 (while (get-text-property (point) prop)
2843 (goto-char (next-single-property-change (point) prop nil (point-max))))))
2845 (defun gnus-set-work-buffer ()
2846 (if (get-buffer gnus-work-buffer)
2848 (set-buffer gnus-work-buffer)
2850 (set-buffer (get-buffer-create gnus-work-buffer))
2851 (kill-all-local-variables)
2852 (buffer-disable-undo (current-buffer))
2853 (gnus-add-current-to-buffer-list)))
2855 ;; Article file names when saving.
2857 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2858 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2859 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
2860 Otherwise, it is like ~/News/news/group/num."
2863 (concat (if (gnus-use-long-file-name 'not-save)
2864 (gnus-capitalize-newsgroup newsgroup)
2865 (gnus-newsgroup-directory-form newsgroup))
2866 "/" (int-to-string (mail-header-number headers)))
2867 gnus-article-save-directory)))
2869 (string-equal (file-name-directory default)
2870 (file-name-directory last-file))
2871 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2873 (or last-file default))))
2875 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2876 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2877 If variable `gnus-use-long-file-name' is non-nil, it is
2878 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2881 (concat (if (gnus-use-long-file-name 'not-save)
2883 (gnus-newsgroup-directory-form newsgroup))
2884 "/" (int-to-string (mail-header-number headers)))
2885 gnus-article-save-directory)))
2887 (string-equal (file-name-directory default)
2888 (file-name-directory last-file))
2889 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2891 (or last-file default))))
2893 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2894 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2895 If variable `gnus-use-long-file-name' is non-nil, it is
2896 ~/News/News.group. Otherwise, it is like ~/News/news/group/news."
2899 (if (gnus-use-long-file-name 'not-save)
2900 (gnus-capitalize-newsgroup newsgroup)
2901 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2902 gnus-article-save-directory)))
2904 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2905 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2906 If variable `gnus-use-long-file-name' is non-nil, it is
2907 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2910 (if (gnus-use-long-file-name 'not-save)
2912 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2913 gnus-article-save-directory)))
2915 ;; For subscribing new newsgroup
2917 (defun gnus-subscribe-hierarchical-interactive (groups)
2918 (let ((groups (sort groups 'string<))
2919 prefixes prefix start ans group starts)
2921 (setq prefixes (list "^"))
2922 (while (and groups prefixes)
2923 (while (not (string-match (car prefixes) (car groups)))
2924 (setq prefixes (cdr prefixes)))
2925 (setq prefix (car prefixes))
2926 (setq start (1- (length prefix)))
2927 (if (and (string-match "[^\\.]\\." (car groups) start)
2930 (concat "^" (substring (car groups) 0 (match-end 0))))
2931 (string-match prefix (cadr groups)))
2933 (setq prefixes (cons prefix prefixes))
2934 (message "Descend hierarchy %s? ([y]nsq): "
2935 (substring prefix 1 (1- (length prefix))))
2936 (while (not (memq (setq ans (read-char)) '(?y ?\n ?n ?s ?q)))
2938 (message "Descend hierarchy %s? ([y]nsq): "
2939 (substring prefix 1 (1- (length prefix)))))
2942 (string-match prefix
2943 (setq group (car groups))))
2944 (setq gnus-killed-list
2945 (cons group gnus-killed-list))
2946 (gnus-sethash group group gnus-killed-hashtb)
2947 (setq groups (cdr groups)))
2948 (setq starts (cdr starts)))
2951 (string-match prefix
2952 (setq group (car groups))))
2953 (gnus-sethash group group gnus-killed-hashtb)
2954 (gnus-subscribe-alphabetically (car groups))
2955 (setq groups (cdr groups)))
2956 (setq starts (cdr starts)))
2959 (setq group (car groups))
2960 (setq gnus-killed-list (cons group gnus-killed-list))
2961 (gnus-sethash group group gnus-killed-hashtb)
2962 (setq groups (cdr groups))))
2964 (message "Subscribe %s? ([n]yq)" (car groups))
2965 (while (not (memq (setq ans (read-char)) '(?y ?\n ?q ?n)))
2967 (message "Subscribe %s? ([n]yq)" (car groups)))
2968 (setq group (car groups))
2970 (gnus-subscribe-alphabetically (car groups))
2971 (gnus-sethash group group gnus-killed-hashtb))
2974 (setq group (car 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 (setq gnus-killed-list (cons group gnus-killed-list))
2980 (gnus-sethash group group gnus-killed-hashtb)))
2981 (setq groups (cdr groups)))))))
2983 (defun gnus-subscribe-randomly (newsgroup)
2984 "Subscribe new NEWSGROUP by making it the first newsgroup."
2985 (gnus-subscribe-newsgroup newsgroup))
2987 (defun gnus-subscribe-alphabetically (newgroup)
2988 "Subscribe new NEWSGROUP and insert it in alphabetical order."
2989 (let ((groups (cdr gnus-newsrc-alist))
2991 (while (and (not before) groups)
2992 (if (string< newgroup (caar groups))
2993 (setq before (caar groups))
2994 (setq groups (cdr groups))))
2995 (gnus-subscribe-newsgroup newgroup before)))
2997 (defun gnus-subscribe-hierarchically (newgroup)
2998 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
2999 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
3001 (set-buffer (find-file-noselect gnus-current-startup-file))
3002 (let ((groupkey newgroup)
3004 (while (and (not before) groupkey)
3005 (goto-char (point-min))
3007 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
3008 (while (and (re-search-forward groupkey-re nil t)
3010 (setq before (match-string 1))
3011 (string< before newgroup)))))
3012 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
3014 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
3015 (substring groupkey (match-beginning 1) (match-end 1)))))
3016 (gnus-subscribe-newsgroup newgroup before))))
3018 (defun gnus-subscribe-interactively (group)
3019 "Subscribe the new GROUP interactively.
3020 It is inserted in hierarchical newsgroup order if subscribed. If not,
3022 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " group))
3023 (gnus-subscribe-hierarchically group)
3024 (push group gnus-killed-list)))
3026 (defun gnus-subscribe-zombies (group)
3027 "Make the new GROUP into a zombie group."
3028 (push group gnus-zombie-list))
3030 (defun gnus-subscribe-killed (group)
3031 "Make the new GROUP a killed group."
3032 (push group gnus-killed-list))
3034 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
3035 "Subscribe new NEWSGROUP.
3036 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
3037 the first newsgroup."
3038 ;; We subscribe the group by changing its level to `subscribed'.
3039 (gnus-group-change-level
3040 newsgroup gnus-level-default-subscribed
3041 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
3042 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))
3046 (defun gnus-newsgroup-directory-form (newsgroup)
3047 "Make hierarchical directory name from NEWSGROUP name."
3048 (let ((newsgroup (gnus-newsgroup-savable-name newsgroup))
3049 (len (length newsgroup))
3051 ;; If this is a foreign group, we don't want to translate the
3053 (if (setq idx (string-match ":" newsgroup))
3054 (aset newsgroup idx ?/)
3056 ;; Replace all occurrences of `.' with `/'.
3058 (if (= (aref newsgroup idx) ?.)
3059 (aset newsgroup idx ?/))
3060 (setq idx (1+ idx)))
3063 (defun gnus-newsgroup-savable-name (group)
3064 ;; Replace any slashes in a group name (eg. an ange-ftp nndoc group)
3066 (nnheader-replace-chars-in-string group ?/ ?.))
3068 (defun gnus-make-directory (dir)
3069 "Make DIRECTORY recursively."
3070 ;; Why don't we use `(make-directory dir 'parents)'? That's just one
3071 ;; of the many mysteries of the universe.
3072 (let* ((dir (expand-file-name dir default-directory))
3074 (if (string-match "/$" dir)
3075 (setq dir (substring dir 0 (match-beginning 0))))
3076 ;; First go down the path until we find a directory that exists.
3077 (while (not (file-exists-p dir))
3078 (setq dirs (cons dir dirs))
3079 (string-match "/[^/]+$" dir)
3080 (setq dir (substring dir 0 (match-beginning 0))))
3081 ;; Then create all the subdirs.
3082 (while (and dirs (not err))
3084 (make-directory (car dirs))
3085 (error (setq err t)))
3086 (setq dirs (cdr dirs)))
3087 ;; We return whether we were successful or not.
3090 (defun gnus-capitalize-newsgroup (newsgroup)
3091 "Capitalize NEWSGROUP name."
3092 (and (not (zerop (length newsgroup)))
3093 (concat (char-to-string (upcase (aref newsgroup 0)))
3094 (substring newsgroup 1))))
3096 ;; Various... things.
3098 (defun gnus-simplify-subject (subject &optional re-only)
3099 "Remove `Re:' and words in parentheses.
3100 If RE-ONLY is non-nil, strip leading `Re:'s only."
3101 (let ((case-fold-search t)) ;Ignore case.
3102 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
3103 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
3104 (setq subject (substring subject (match-end 0))))
3105 ;; Remove uninteresting prefixes.
3106 (if (and (not re-only)
3107 gnus-simplify-ignored-prefixes
3108 (string-match gnus-simplify-ignored-prefixes subject))
3109 (setq subject (substring subject (match-end 0))))
3110 ;; Remove words in parentheses from end.
3112 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
3113 (setq subject (substring subject 0 (match-beginning 0)))))
3114 ;; Return subject string.
3117 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
3119 ;; Written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
3120 (defun gnus-simplify-buffer-fuzzy ()
3121 (let ((case-fold-search t))
3122 (goto-char (point-min))
3123 (while (search-forward "\t" nil t)
3124 (replace-match " " t t))
3125 (goto-char (point-min))
3126 (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *" nil t)
3127 (goto-char (match-beginning 0))
3129 (looking-at "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
3130 (looking-at "^[[].*: .*[]]$"))
3131 (goto-char (point-min))
3132 (while (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *"
3134 (replace-match "" t t))
3135 (goto-char (point-min))
3136 (while (re-search-forward "^[[].*: .*[]]$" nil t)
3137 (goto-char (match-end 0))
3140 (progn (goto-char (match-beginning 0)))
3141 (re-search-forward ":"))))
3142 (goto-char (point-min))
3143 (while (re-search-forward " *[[{(][^()\n]*[]})] *$" nil t)
3144 (replace-match "" t t))
3145 (goto-char (point-min))
3146 (while (re-search-forward " +" nil t)
3147 (replace-match " " t t))
3148 (goto-char (point-min))
3149 (while (re-search-forward " $" nil t)
3150 (replace-match "" t t))
3151 (goto-char (point-min))
3152 (while (re-search-forward "^ +" nil t)
3153 (replace-match "" t t))
3154 (goto-char (point-min))
3155 (when gnus-simplify-subject-fuzzy-regexp
3156 (if (listp gnus-simplify-subject-fuzzy-regexp)
3157 (let ((list gnus-simplify-subject-fuzzy-regexp))
3159 (goto-char (point-min))
3160 (while (re-search-forward (car list) nil t)
3161 (replace-match "" t t))
3162 (setq list (cdr list))))
3163 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
3164 (replace-match "" t t))))))
3166 (defun gnus-simplify-subject-fuzzy (subject)
3167 "Siplify a subject string fuzzily."
3169 (gnus-set-work-buffer)
3170 (let ((case-fold-search t))
3172 (inline (gnus-simplify-buffer-fuzzy))
3175 ;; Add the current buffer to the list of buffers to be killed on exit.
3176 (defun gnus-add-current-to-buffer-list ()
3177 (or (memq (current-buffer) gnus-buffer-list)
3178 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list))))
3180 (defun gnus-string> (s1 s2)
3181 (not (or (string< s1 s2)
3184 (defun gnus-read-active-file-p ()
3185 "Say whether the active file has been read from `gnus-select-method'."
3186 (memq gnus-select-method gnus-have-read-active-file))
3188 ;;; General various misc type functions.
3190 (defun gnus-clear-system ()
3191 "Clear all variables and buffers."
3192 ;; Clear Gnus variables.
3193 (let ((variables gnus-variable-list))
3195 (set (car variables) nil)
3196 (setq variables (cdr variables))))
3197 ;; Clear other internal variables.
3198 (setq gnus-list-of-killed-groups nil
3199 gnus-have-read-active-file nil
3200 gnus-newsrc-alist nil
3201 gnus-newsrc-hashtb nil
3202 gnus-killed-list nil
3203 gnus-zombie-list nil
3204 gnus-killed-hashtb nil
3205 gnus-active-hashtb nil
3206 gnus-moderated-list nil
3207 gnus-description-hashtb nil
3208 gnus-current-headers nil
3209 gnus-thread-indent-array nil
3210 gnus-newsgroup-headers nil
3211 gnus-newsgroup-name nil
3212 gnus-server-alist nil
3213 gnus-group-list-mode nil
3214 gnus-opened-servers nil
3215 gnus-current-select-method nil)
3216 (gnus-shutdown 'gnus)
3217 ;; Kill the startup file.
3218 (and gnus-current-startup-file
3219 (get-file-buffer gnus-current-startup-file)
3220 (kill-buffer (get-file-buffer gnus-current-startup-file)))
3221 ;; Clear the dribble buffer.
3222 (gnus-dribble-clear)
3223 ;; Kill global KILL file buffer.
3224 (when (get-file-buffer (gnus-newsgroup-kill-file nil))
3225 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
3226 (gnus-kill-buffer nntp-server-buffer)
3227 ;; Kill Gnus buffers.
3228 (while gnus-buffer-list
3229 (gnus-kill-buffer (pop gnus-buffer-list)))
3230 ;; Remove Gnus frames.
3231 (while gnus-created-frames
3232 (when (frame-live-p (car gnus-created-frames))
3233 ;; We slap a condition-case around this `delete-frame' to ensure
3234 ;; agains errors if we try do delete the single frame that's left.
3236 (delete-frame (car gnus-created-frames))
3238 (pop gnus-created-frames)))
3240 (defun gnus-windows-old-to-new (setting)
3241 ;; First we take care of the really, really old Gnus 3 actions.
3242 (when (symbolp setting)
3244 ;; Take care of ooold GNUS 3.x values.
3245 (cond ((eq setting 'SelectArticle) 'article)
3246 ((memq setting '(SelectSubject ExpandSubject)) 'summary)
3247 ((memq setting '(SelectNewsgroup ExitNewsgroup)) 'group)
3249 (if (or (listp setting)
3250 (not (and gnus-window-configuration
3251 (memq setting '(group summary article)))))
3253 (let* ((setting (if (eq setting 'group)
3254 (if (assq 'newsgroup gnus-window-configuration)
3256 'newsgroups) setting))
3257 (elem (cadr (assq setting gnus-window-configuration)))
3258 (total (apply '+ elem))
3259 (types '(group summary article))
3260 (pbuf (if (eq setting 'newsgroups) 'group 'summary))
3265 (or (not (numberp (nth i elem)))
3266 (zerop (nth i elem))
3268 (setq perc (if (= i 2)
3270 (/ (float (nth 0 elem)) total)))
3271 (setq out (cons (if (eq pbuf (nth i types))
3272 (list (nth i types) perc 'point)
3273 (list (nth i types) perc))
3276 `(vertical 1.0 ,@(nreverse out)))))
3279 (defun gnus-add-configuration (conf)
3280 "Add the window configuration CONF to `gnus-buffer-configuration'."
3281 (setq gnus-buffer-configuration
3282 (cons conf (delq (assq (car conf) gnus-buffer-configuration)
3283 gnus-buffer-configuration))))
3285 (defvar gnus-frame-list nil)
3287 (defun gnus-configure-frame (split &optional window)
3288 "Split WINDOW according to SPLIT."
3290 (setq window (get-buffer-window (current-buffer))))
3291 (select-window window)
3292 ;; This might be an old-stylee buffer config.
3293 (when (vectorp split)
3294 (setq split (append split nil)))
3295 (when (or (consp (car split))
3296 (vectorp (car split)))
3298 (push 'vertical split))
3299 ;; The SPLIT might be something that is to be evaled to
3300 ;; return a new SPLIT.
3301 (while (and (not (assq (car split) gnus-window-to-buffer))
3302 (gnus-functionp (car split)))
3303 (setq split (eval split)))
3304 (let* ((type (car split))
3306 (len (if (eq type 'horizontal) (window-width) (window-height)))
3308 (window-min-width (or gnus-window-min-width window-min-width))
3309 (window-min-height (or gnus-window-min-height window-min-height))
3310 s result new-win rest comp-subs size sub)
3312 ;; Nothing to do here.
3314 ;; Don't switch buffers.
3316 (and (memq 'point split) window))
3317 ;; This is a buffer to be selected.
3318 ((not (memq type '(frame horizontal vertical)))
3319 (let ((buffer (cond ((stringp type) type)
3320 (t (cdr (assq type gnus-window-to-buffer)))))
3323 (error "Illegal buffer type: %s" type))
3324 (unless (setq buf (get-buffer (if (symbolp buffer)
3325 (symbol-value buffer) buffer)))
3326 (setq buf (get-buffer-create (if (symbolp buffer)
3327 (symbol-value buffer) buffer))))
3328 (switch-to-buffer buf)
3329 ;; We return the window if it has the `point' spec.
3330 (and (memq 'point split) window)))
3331 ;; This is a frame split.
3333 (unless gnus-frame-list
3334 (setq gnus-frame-list (list (window-frame
3335 (get-buffer-window (current-buffer))))))
3337 params frame fresult)
3338 (while (< i (length subs))
3339 ;; Frame parameter is gotten from the sub-split.
3340 (setq params (cadr (elt subs i)))
3341 ;; It should be a list.
3342 (unless (listp params)
3344 ;; Create a new frame?
3345 (unless (setq frame (elt gnus-frame-list i))
3346 (nconc gnus-frame-list (list (setq frame (make-frame params))))
3347 (push frame gnus-created-frames))
3348 ;; Is the old frame still alive?
3349 (unless (frame-live-p frame)
3350 (setcar (nthcdr i gnus-frame-list)
3351 (setq frame (make-frame params))))
3352 ;; Select the frame in question and do more splits there.
3353 (select-frame frame)
3354 (setq fresult (or (gnus-configure-frame (elt subs i)) fresult))
3356 ;; Select the frame that has the selected buffer.
3358 (select-frame (window-frame fresult)))))
3359 ;; This is a normal split.
3361 (when (> (length subs) 0)
3362 ;; First we have to compute the sizes of all new windows.
3364 (setq sub (append (pop subs) nil))
3365 (while (and (not (assq (car sub) gnus-window-to-buffer))
3366 (gnus-functionp (car sub)))
3367 (setq sub (eval sub)))
3369 (push sub comp-subs)
3370 (setq size (cadar comp-subs))
3371 (cond ((equal size 1.0)
3372 (setq rest (car comp-subs))
3375 (setq s (floor (* size len))))
3379 (error "Illegal size: %s" size)))
3380 ;; Try to make sure that we are inside the safe limits.
3382 ((eq type 'horizontal)
3383 (setq s (max s window-min-width)))
3384 ((eq type 'vertical)
3385 (setq s (max s window-min-height))))
3386 (setcar (cdar comp-subs) s)
3388 ;; Take care of the "1.0" spec.
3390 (setcar (cdr rest) (- len total))
3391 (error "No 1.0 specs in %s" split))
3392 ;; The we do the actual splitting in a nice recursive
3394 (setq comp-subs (nreverse comp-subs))
3396 (if (null (cdr comp-subs))
3397 (setq new-win window)
3399 (split-window window (cadar comp-subs)
3400 (eq type 'horizontal))))
3401 (setq result (or (gnus-configure-frame
3402 (car comp-subs) window) result))
3403 (select-window new-win)
3404 (setq window new-win)
3405 (setq comp-subs (cdr comp-subs))))
3406 ;; Return the proper window, if any.
3408 (select-window result))))))
3410 (defvar gnus-frame-split-p nil)
3412 (defun gnus-configure-windows (setting &optional force)
3413 (setq setting (gnus-windows-old-to-new setting))
3414 (let ((split (if (symbolp setting)
3415 (cadr (assq setting gnus-buffer-configuration))
3419 (setq gnus-frame-split-p nil)
3422 (error "No such setting: %s" setting))
3424 (if (and (setq all-visible (gnus-all-windows-visible-p split))
3426 ;; All the windows mentioned are already visible, so we just
3427 ;; put point in the assigned buffer, and do not touch the
3429 (select-window all-visible)
3431 ;; Either remove all windows or just remove all Gnus windows.
3432 (let ((frame (selected-frame)))
3434 (if gnus-use-full-window
3435 ;; We want to remove all other windows.
3436 (if (not gnus-frame-split-p)
3437 ;; This is not a `frame' split, so we ignore the
3439 (delete-other-windows)
3440 ;; This is a `frame' split, so we delete all windows
3444 (unless (eq (cdr (assq 'minibuffer
3445 (frame-parameters frame)))
3447 (select-frame frame)
3448 (delete-other-windows)))
3450 ;; Just remove some windows.
3451 (gnus-remove-some-windows)
3452 (switch-to-buffer nntp-server-buffer))
3453 (select-frame frame)))
3455 (switch-to-buffer nntp-server-buffer)
3456 (gnus-configure-frame split (get-buffer-window (current-buffer))))))
3458 (defun gnus-all-windows-visible-p (split)
3459 "Say whether all buffers in SPLIT are currently visible.
3460 In particular, the value returned will be the window that
3462 (let ((stack (list split))
3464 type buffer win buf)
3465 (while (and (setq split (pop stack))
3467 ;; Be backwards compatible.
3468 (when (vectorp split)
3469 (setq split (append split nil)))
3470 (when (or (consp (car split))
3471 (vectorp (car split)))
3473 (push 'vertical split))
3474 ;; The SPLIT might be something that is to be evaled to
3475 ;; return a new SPLIT.
3476 (while (and (not (assq (car split) gnus-window-to-buffer))
3477 (gnus-functionp (car split)))
3478 (setq split (eval split)))
3480 (setq type (elt split 0))
3485 ((not (memq type '(horizontal vertical frame)))
3486 (setq buffer (cond ((stringp type) type)
3487 (t (cdr (assq type gnus-window-to-buffer)))))
3489 (error "Illegal buffer type: %s" type))
3490 (when (setq buf (get-buffer (if (symbolp buffer)
3491 (symbol-value buffer)
3493 (setq win (get-buffer-window buf t)))
3495 (when (memq 'point split)
3496 (setq all-visible win))
3497 (setq all-visible nil)))
3499 (when (eq type 'frame)
3500 (setq gnus-frame-split-p t))
3501 (setq stack (append (cddr split) stack)))))
3502 (unless (eq all-visible t)
3505 (defun gnus-window-top-edge (&optional window)
3506 (nth 1 (window-edges window)))
3508 (defun gnus-remove-some-windows ()
3509 (let ((buffers gnus-window-to-buffer)
3510 buf bufs lowest-buf lowest)
3512 ;; Remove windows on all known Gnus buffers.
3514 (setq buf (cdar buffers))
3516 (setq buf (and (boundp buf) (symbol-value buf))))
3518 (get-buffer-window buf)
3520 (setq bufs (cons buf bufs))
3522 (if (or (not lowest)
3523 (< (gnus-window-top-edge) lowest))
3525 (setq lowest (gnus-window-top-edge))
3526 (setq lowest-buf buf)))))
3527 (setq buffers (cdr buffers)))
3528 ;; Remove windows on *all* summary buffers.
3531 (let ((buf (window-buffer win)))
3532 (if (string-match "^\\*Summary" (buffer-name buf))
3534 (setq bufs (cons buf bufs))
3536 (if (or (not lowest)
3537 (< (gnus-window-top-edge) lowest))
3539 (setq lowest-buf buf)
3540 (setq lowest (gnus-window-top-edge)))))))))
3543 (pop-to-buffer lowest-buf)
3544 (switch-to-buffer nntp-server-buffer)))
3546 (and (not (eq (car bufs) lowest-buf))
3547 (delete-windows-on (car bufs)))
3548 (setq bufs (cdr bufs))))))
3550 (defun gnus-version (&optional arg)
3551 "Version number of this version of Gnus.
3552 If ARG, insert string at point."
3554 (let ((methods gnus-valid-select-methods)
3557 ;; Go through all the legal select methods and add their version
3558 ;; numbers to the total version string. Only the backends that are
3559 ;; currently in use will have their message numbers taken into
3562 (setq meth (intern (concat (caar methods) "-version")))
3564 (stringp (symbol-value meth))
3565 (setq mess (concat mess "; " (symbol-value meth))))
3566 (setq methods (cdr methods)))
3568 (insert (message mess))
3571 (defun gnus-info-find-node ()
3572 "Find Info documentation of Gnus."
3574 ;; Enlarge info window if needed.
3575 (let ((mode major-mode)
3577 (Info-goto-node (cadr (assq mode gnus-info-nodes)))
3578 (setq gnus-info-buffer (current-buffer))
3579 (gnus-configure-windows 'info)))
3581 (defun gnus-days-between (date1 date2)
3582 ;; Return the number of days between date1 and date2.
3583 (- (gnus-day-number date1) (gnus-day-number date2)))
3585 (defun gnus-day-number (date)
3586 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
3587 (timezone-parse-date date))))
3588 (timezone-absolute-from-gregorian
3589 (nth 1 dat) (nth 2 dat) (car dat))))
3591 (defun gnus-encode-date (date)
3592 "Convert DATE to internal time."
3593 (let* ((parse (timezone-parse-date date))
3594 (date (mapcar (lambda (d) (and d (string-to-int d))) parse))
3595 (time (mapcar 'string-to-int (timezone-parse-time (aref parse 3)))))
3596 (encode-time (caddr time) (cadr time) (car time)
3597 (caddr date) (cadr date) (car date) (nth 4 date))))
3599 (defun gnus-time-minus (t1 t2)
3600 "Subtract two internal times."
3601 (let ((borrow (< (cadr t1) (cadr t2))))
3602 (list (- (car t1) (car t2) (if borrow 1 0))
3603 (- (+ (if borrow 65536 0) (cadr t1)) (cadr t2)))))
3605 (defun gnus-file-newer-than (file date)
3606 (let ((fdate (nth 5 (file-attributes file))))
3607 (or (> (car fdate) (car date))
3608 (and (= (car fdate) (car date))
3609 (> (nth 1 fdate) (nth 1 date))))))
3611 (defmacro gnus-local-set-keys (&rest plist)
3612 "Set the keys in PLIST in the current keymap."
3613 `(gnus-define-keys-1 (current-local-map) ',plist))
3615 (defmacro gnus-define-keys (keymap &rest plist)
3616 "Define all keys in PLIST in KEYMAP."
3617 `(gnus-define-keys-1 (quote ,keymap) (quote ,plist)))
3619 (put 'gnus-define-keys 'lisp-indent-function 1)
3620 (put 'gnus-define-keys 'lisp-indent-hook 1)
3621 (put 'gnus-define-keymap 'lisp-indent-function 1)
3622 (put 'gnus-define-keymap 'lisp-indent-hook 1)
3624 (defmacro gnus-define-keymap (keymap &rest plist)
3625 "Define all keys in PLIST in KEYMAP."
3626 `(gnus-define-keys-1 ,keymap (quote ,plist)))
3628 (defun gnus-define-keys-1 (keymap plist)
3630 (error "Can't set keys in a null keymap"))
3631 (cond ((symbolp keymap)
3632 (setq keymap (symbol-value keymap)))
3635 (set (car keymap) nil)
3636 (define-prefix-command (car keymap))
3637 (define-key (symbol-value (caddr keymap)) (cadr keymap) (car keymap))
3638 (setq keymap (symbol-value (car keymap)))))
3641 (when (symbolp (setq key (pop plist)))
3642 (setq key (symbol-value key)))
3643 (define-key keymap key (pop plist)))))
3645 (defun gnus-group-read-only-p (&optional group)
3646 "Check whether GROUP supports editing or not.
3647 If GROUP is nil, `gnus-newsgroup-name' will be checked instead. Note
3648 that that variable is buffer-local to the summary buffers."
3649 (let ((group (or group gnus-newsgroup-name)))
3650 (not (gnus-check-backend-function 'request-replace-article group))))
3652 (defun gnus-group-total-expirable-p (group)
3653 "Check whether GROUP is total-expirable or not."
3654 (let ((params (gnus-info-params (gnus-get-info group))))
3655 (or (memq 'total-expire params)
3656 (cdr (assq 'total-expire params)) ; (total-expire . t)
3657 (and gnus-total-expirable-newsgroups ; Check var.
3658 (string-match gnus-total-expirable-newsgroups group)))))
3660 (defun gnus-group-auto-expirable-p (group)
3661 "Check whether GROUP is total-expirable or not."
3662 (let ((params (gnus-info-params (gnus-get-info group))))
3663 (or (memq 'auto-expire params)
3664 (cdr (assq 'auto-expire params)) ; (auto-expire . t)
3665 (and gnus-auto-expirable-newsgroups ; Check var.
3666 (string-match gnus-auto-expirable-newsgroups group)))))
3668 (defun gnus-virtual-group-p (group)
3669 "Say whether GROUP is virtual or not."
3670 (memq 'virtual (assoc (symbol-name (car (gnus-find-method-for-group group)))
3671 gnus-valid-select-methods)))
3673 (defun gnus-news-group-p (group &optional article)
3674 "Return non-nil if GROUP (and ARTICLE) come from a news server."
3675 (or (gnus-member-of-valid 'post group) ; Ordinary news group.
3676 (and (gnus-member-of-valid 'post-mail group) ; Combined group.
3677 (eq (gnus-request-type group article) 'news))))
3679 (defsubst gnus-simplify-subject-fully (subject)
3680 "Simplify a subject string according to the user's wishes."
3682 ((null gnus-summary-gather-subject-limit)
3683 (gnus-simplify-subject-re subject))
3684 ((eq gnus-summary-gather-subject-limit 'fuzzy)
3685 (gnus-simplify-subject-fuzzy subject))
3686 ((numberp gnus-summary-gather-subject-limit)
3687 (gnus-limit-string (gnus-simplify-subject-re subject)
3688 gnus-summary-gather-subject-limit))
3692 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
3693 "Check whether two subjects are equal. If optional argument
3694 simple-first is t, first argument is already simplified."
3696 ((null simple-first)
3697 (equal (gnus-simplify-subject-fully s1)
3698 (gnus-simplify-subject-fully s2)))
3701 (gnus-simplify-subject-fully s2)))))
3703 ;; Returns a list of writable groups.
3704 (defun gnus-writable-groups ()
3705 (let ((alist gnus-newsrc-alist)
3707 (while (setq group (car (pop alist)))
3708 (unless (gnus-group-read-only-p group)
3709 (push group groups)))
3712 (defun gnus-completing-read (default prompt &rest args)
3713 ;; Like `completing-read', except that DEFAULT is the default argument.
3714 (let* ((prompt (if default
3715 (concat prompt " (default " default ") ")
3716 (concat prompt " ")))
3717 (answer (apply 'completing-read prompt args)))
3718 (if (or (null answer) (zerop (length answer)))
3722 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
3724 (defun gnus-y-or-n-p (prompt)
3729 (defun gnus-yes-or-no-p (prompt)
3731 (yes-or-no-p prompt)
3734 ;; Check whether to use long file names.
3735 (defun gnus-use-long-file-name (symbol)
3736 ;; The variable has to be set...
3737 (and gnus-use-long-file-name
3738 ;; If it isn't a list, then we return t.
3739 (or (not (listp gnus-use-long-file-name))
3740 ;; If it is a list, and the list contains `symbol', we
3742 (not (memq symbol gnus-use-long-file-name)))))
3744 ;; I suspect there's a better way, but I haven't taken the time to do
3745 ;; it yet. -erik selberg@cs.washington.edu
3746 (defun gnus-dd-mmm (messy-date)
3747 "Return a string like DD-MMM from a big messy string"
3748 (let ((datevec (condition-case () (timezone-parse-date messy-date)
3754 ;; Make sure leading zeroes are stripped.
3755 (number-to-string (string-to-number (aref datevec 2)))
3759 (nth (1- (string-to-number (aref datevec 1)))
3760 timezone-months-assoc))
3763 (defun gnus-mode-string-quote (string)
3764 "Quote all \"%\" in STRING."
3766 (gnus-set-work-buffer)
3768 (goto-char (point-min))
3769 (while (search-forward "%" nil t)
3773 ;; Make a hash table (default and minimum size is 255).
3774 ;; Optional argument HASHSIZE specifies the table size.
3775 (defun gnus-make-hashtable (&optional hashsize)
3776 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0))
3778 ;; Make a number that is suitable for hashing; bigger than MIN and one
3780 (defun gnus-create-hash-size (min)
3786 ;; Show message if message has a lower level than `gnus-verbose'.
3787 ;; Guideline for numbers:
3788 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages
3789 ;; for things that take a long time, 7 - not very important messages
3790 ;; on stuff, 9 - messages inside loops.
3791 (defun gnus-message (level &rest args)
3792 (if (<= level gnus-verbose)
3793 (apply 'message args)
3794 ;; We have to do this format thingy here even if the result isn't
3795 ;; shown - the return value has to be the same as the return value
3797 (apply 'format args)))
3799 (defun gnus-error (level &rest args)
3800 "Beep an error if `gnus-verbose' is on LEVEL or less."
3801 (when (<= (floor level) gnus-verbose)
3802 (apply 'message args)
3805 (when (and (floatp level)
3806 (not (zerop (setq duration (* 10 (- level (floor level)))))))
3807 (sit-for duration))))
3810 ;; Generate a unique new group name.
3811 (defun gnus-generate-new-group-name (leaf)
3814 (while (gnus-gethash name gnus-newsrc-hashtb)
3815 (setq name (concat leaf "<" (int-to-string (setq num (1+ num))) ">")))
3818 (defsubst gnus-hide-text (b e props)
3819 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
3820 (gnus-add-text-properties b e props)
3821 (when (memq 'intangible props)
3822 (gnus-put-text-property (max (1- b) (point-min))
3823 b 'intangible (cddr (memq 'intangible props)))))
3825 (defsubst gnus-unhide-text (b e)
3826 "Remove hidden text properties from region between B and E."
3827 (remove-text-properties b e gnus-hidden-properties)
3828 (when (memq 'intangible gnus-hidden-properties)
3829 (gnus-put-text-property (max (1- b) (point-min))
3830 b 'intangible nil)))
3832 (defun gnus-hide-text-type (b e type)
3833 "Hide text of TYPE between B and E."
3834 (gnus-hide-text b e (cons 'gnus-type (cons type gnus-hidden-properties))))
3836 (defun gnus-parent-headers (headers &optional generation)
3837 "Return the headers of the GENERATIONeth parent of HEADERS."
3839 (setq generation 1))
3840 (let (references parent)
3841 (while (and headers (not (zerop generation)))
3842 (setq references (mail-header-references headers))
3843 (when (and references
3844 (setq parent (gnus-parent-id references))
3845 (setq headers (car (gnus-id-to-thread parent))))
3849 (defun gnus-parent-id (references)
3850 "Return the last Message-ID in REFERENCES."
3851 (when (and references
3852 (string-match "\\(<[^\n<>]+>\\)[ \t\n]*\\'" references))
3853 (substring references (match-beginning 1) (match-end 1))))
3855 (defun gnus-split-references (references)
3856 "Return a list of Message-IDs in REFERENCES."
3859 (while (string-match "<[^>]+>" references beg)
3860 (push (substring references (match-beginning 0) (setq beg (match-end 0)))
3864 (defun gnus-buffer-live-p (buffer)
3865 "Say whether BUFFER is alive or not."
3868 (buffer-name (get-buffer buffer))))
3870 (defun gnus-ephemeral-group-p (group)
3871 "Say whether GROUP is ephemeral or not."
3872 (gnus-group-get-parameter group 'quit-config))
3874 (defun gnus-group-quit-config (group)
3875 "Return the quit-config of GROUP."
3876 (gnus-group-get-parameter group 'quit-config))
3878 (defun gnus-simplify-mode-line ()
3879 "Make mode lines a bit simpler."
3880 (setq mode-line-modified "-- ")
3881 (when (listp mode-line-format)
3882 (make-local-variable 'mode-line-format)
3883 (setq mode-line-format (copy-sequence mode-line-format))
3884 (when (equal (nth 3 mode-line-format) " ")
3885 (setcar (nthcdr 3 mode-line-format) " "))))
3887 ;;; List and range functions
3889 (defun gnus-last-element (list)
3890 "Return last element of LIST."
3892 (setq list (cdr list)))
3895 (defun gnus-copy-sequence (list)
3896 "Do a complete, total copy of a list."
3897 (if (and (consp list) (not (consp (cdr list))))
3898 (cons (car list) (cdr list))
3899 (mapcar (lambda (elem) (if (consp elem)
3900 (if (consp (cdr elem))
3901 (gnus-copy-sequence elem)
3902 (cons (car elem) (cdr elem)))
3906 (defun gnus-set-difference (list1 list2)
3907 "Return a list of elements of LIST1 that do not appear in LIST2."
3908 (let ((list1 (copy-sequence list1)))
3910 (setq list1 (delq (car list2) list1))
3911 (setq list2 (cdr list2)))
3914 (defun gnus-sorted-complement (list1 list2)
3915 "Return a list of elements of LIST1 that do not appear in LIST2.
3916 Both lists have to be sorted over <."
3918 (if (or (null list1) (null list2))
3920 (while (and list1 list2)
3921 (cond ((= (car list1) (car list2))
3922 (setq list1 (cdr list1)
3924 ((< (car list1) (car list2))
3925 (setq out (cons (car list1) out))
3926 (setq list1 (cdr list1)))
3928 (setq out (cons (car list2) out))
3929 (setq list2 (cdr list2)))))
3930 (nconc (nreverse out) (or list1 list2)))))
3932 (defun gnus-intersection (list1 list2)
3935 (if (memq (car list2) list1)
3936 (setq result (cons (car list2) result)))
3937 (setq list2 (cdr list2)))
3940 (defun gnus-sorted-intersection (list1 list2)
3941 ;; LIST1 and LIST2 have to be sorted over <.
3943 (while (and list1 list2)
3944 (cond ((= (car list1) (car list2))
3945 (setq out (cons (car list1) out)
3948 ((< (car list1) (car list2))
3949 (setq list1 (cdr list1)))
3951 (setq list2 (cdr list2)))))
3954 (defun gnus-set-sorted-intersection (list1 list2)
3955 ;; LIST1 and LIST2 have to be sorted over <.
3956 ;; This function modifies LIST1.
3957 (let* ((top (cons nil list1))
3959 (while (and list1 list2)
3960 (cond ((= (car list1) (car list2))
3964 ((< (car list1) (car list2))
3965 (setcdr prev (cdr list1))
3966 (setq list1 (cdr list1)))
3968 (setq list2 (cdr list2)))))
3972 (defun gnus-compress-sequence (numbers &optional always-list)
3973 "Convert list of numbers to a list of ranges or a single range.
3974 If ALWAYS-LIST is non-nil, this function will always release a list of
3976 (let* ((first (car numbers))
3977 (last (car numbers))
3981 (if (not (listp (cdr numbers)))
3984 (cond ((= last (car numbers)) nil) ;Omit duplicated number
3985 ((= (1+ last) (car numbers)) ;Still in sequence
3986 (setq last (car numbers)))
3987 (t ;End of one sequence
3989 (cons (if (= first last) first
3990 (cons first last)) result))
3991 (setq first (car numbers))
3992 (setq last (car numbers))))
3993 (setq numbers (cdr numbers)))
3994 (if (and (not always-list) (null result))
3995 (if (= first last) (list first) (cons first last))
3996 (nreverse (cons (if (= first last) first (cons first last))
3999 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
4000 (defun gnus-uncompress-range (ranges)
4001 "Expand a list of ranges into a list of numbers.
4002 RANGES is either a single range on the form `(num . num)' or a list of
4004 (let (first last result)
4008 ((not (listp (cdr ranges)))
4009 (setq first (car ranges))
4010 (setq last (cdr ranges))
4011 (while (<= first last)
4012 (setq result (cons first result))
4013 (setq first (1+ first)))
4017 (if (atom (car ranges))
4018 (if (numberp (car ranges))
4019 (setq result (cons (car ranges) result)))
4020 (setq first (caar ranges))
4021 (setq last (cdar ranges))
4022 (while (<= first last)
4023 (setq result (cons first result))
4024 (setq first (1+ first))))
4025 (setq ranges (cdr ranges)))
4026 (nreverse result)))))
4028 (defun gnus-add-to-range (ranges list)
4029 "Return a list of ranges that has all articles from both RANGES and LIST.
4030 Note: LIST has to be sorted over `<'."
4032 (gnus-compress-sequence list t)
4033 (setq list (copy-sequence list))
4034 (or (listp (cdr ranges))
4035 (setq ranges (list ranges)))
4037 ilist lowest highest temp)
4038 (while (and ranges list)
4040 (setq lowest (or (and (atom (car ranges)) (car ranges))
4042 (while (and list (cdr list) (< (cadr list) lowest))
4043 (setq list (cdr list)))
4044 (if (< (car ilist) lowest)
4047 (setq list (cdr list))
4049 (setq out (nconc (gnus-compress-sequence ilist t) out))))
4050 (setq highest (or (and (atom (car ranges)) (car ranges))
4052 (while (and list (<= (car list) highest))
4053 (setq list (cdr list)))
4054 (setq ranges (cdr ranges)))
4056 (setq out (nconc (gnus-compress-sequence list t) out)))
4057 (setq out (sort out (lambda (r1 r2)
4058 (< (or (and (atom r1) r1) (car r1))
4059 (or (and (atom r2) r2) (car r2))))))
4062 (if (atom (car ranges))
4064 (if (atom (cadr ranges))
4065 (if (= (1+ (car ranges)) (cadr ranges))
4067 (setcar ranges (cons (car ranges)
4069 (setcdr ranges (cddr ranges))))
4070 (if (= (1+ (car ranges)) (caadr ranges))
4072 (setcar (cadr ranges) (car ranges))
4073 (setcar ranges (cadr ranges))
4074 (setcdr ranges (cddr ranges))))))
4076 (if (atom (cadr ranges))
4077 (if (= (1+ (cdar ranges)) (cadr ranges))
4079 (setcdr (car ranges) (cadr ranges))
4080 (setcdr ranges (cddr ranges))))
4081 (if (= (1+ (cdar ranges)) (caadr ranges))
4083 (setcdr (car ranges) (cdadr ranges))
4084 (setcdr ranges (cddr ranges)))))))
4085 (setq ranges (cdr ranges)))
4088 (defun gnus-remove-from-range (ranges list)
4089 "Return a list of ranges that has all articles from LIST removed from RANGES.
4090 Note: LIST has to be sorted over `<'."
4091 ;; !!! This function shouldn't look like this, but I've got a headache.
4092 (gnus-compress-sequence
4093 (gnus-sorted-complement
4094 (gnus-uncompress-range ranges) list)))
4096 (defun gnus-member-of-range (number ranges)
4097 (if (not (listp (cdr ranges)))
4098 (and (>= number (car ranges))
4099 (<= number (cdr ranges)))
4102 (if (numberp (car ranges))
4103 (>= number (car ranges))
4104 (>= number (caar ranges)))
4106 (if (if (numberp (car ranges))
4107 (= number (car ranges))
4108 (and (>= number (caar ranges))
4109 (<= number (cdar ranges))))
4110 (setq not-stop nil))
4111 (setq ranges (cdr ranges)))
4114 (defun gnus-range-length (range)
4115 "Return the length RANGE would have if uncompressed."
4116 (length (gnus-uncompress-range range)))
4118 (defun gnus-sublist-p (list sublist)
4119 "Test whether all elements in SUBLIST are members of LIST."
4122 (unless (memq (pop sublist) list)
4132 (defvar gnus-group-mode-map nil)
4133 (put 'gnus-group-mode 'mode-class 'special)
4135 (unless gnus-group-mode-map
4136 (setq gnus-group-mode-map (make-keymap))
4137 (suppress-keymap gnus-group-mode-map)
4139 (gnus-define-keys gnus-group-mode-map
4140 " " gnus-group-read-group
4141 "=" gnus-group-select-group
4142 "\r" gnus-group-select-group
4143 "\M-\r" gnus-group-quick-select-group
4144 "j" gnus-group-jump-to-group
4145 "n" gnus-group-next-unread-group
4146 "p" gnus-group-prev-unread-group
4147 "\177" gnus-group-prev-unread-group
4148 [delete] gnus-group-prev-unread-group
4149 "N" gnus-group-next-group
4150 "P" gnus-group-prev-group
4151 "\M-n" gnus-group-next-unread-group-same-level
4152 "\M-p" gnus-group-prev-unread-group-same-level
4153 "," gnus-group-best-unread-group
4154 "." gnus-group-first-unread-group
4155 "u" gnus-group-unsubscribe-current-group
4156 "U" gnus-group-unsubscribe-group
4157 "c" gnus-group-catchup-current
4158 "C" gnus-group-catchup-current-all
4159 "l" gnus-group-list-groups
4160 "L" gnus-group-list-all-groups
4162 "g" gnus-group-get-new-news
4163 "\M-g" gnus-group-get-new-news-this-group
4164 "R" gnus-group-restart
4165 "r" gnus-group-read-init-file
4166 "B" gnus-group-browse-foreign-server
4167 "b" gnus-group-check-bogus-groups
4168 "F" gnus-find-new-newsgroups
4169 "\C-c\C-d" gnus-group-describe-group
4170 "\M-d" gnus-group-describe-all-groups
4171 "\C-c\C-a" gnus-group-apropos
4172 "\C-c\M-\C-a" gnus-group-description-apropos
4173 "a" gnus-group-post-news
4174 "\ek" gnus-group-edit-local-kill
4175 "\eK" gnus-group-edit-global-kill
4176 "\C-k" gnus-group-kill-group
4177 "\C-y" gnus-group-yank-group
4178 "\C-w" gnus-group-kill-region
4179 "\C-x\C-t" gnus-group-transpose-groups
4180 "\C-c\C-l" gnus-group-list-killed
4181 "\C-c\C-x" gnus-group-expire-articles
4182 "\C-c\M-\C-x" gnus-group-expire-all-groups
4184 "s" gnus-group-save-newsrc
4185 "z" gnus-group-suspend
4186 "Z" gnus-group-clear-dribble
4189 "?" gnus-group-describe-briefly
4190 "\C-c\C-i" gnus-info-find-node
4191 "\M-e" gnus-group-edit-group-method
4192 "^" gnus-group-enter-server-mode
4193 gnus-mouse-2 gnus-mouse-pick-group
4194 "<" beginning-of-buffer
4197 "\C-c\C-s" gnus-group-sort-groups
4199 "\C-c\M-g" gnus-activate-all-groups
4200 "\M-&" gnus-group-universal-argument
4201 "#" gnus-group-mark-group
4202 "\M-#" gnus-group-unmark-group)
4204 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
4205 "m" gnus-group-mark-group
4206 "u" gnus-group-unmark-group
4207 "w" gnus-group-mark-region
4208 "m" gnus-group-mark-buffer
4209 "r" gnus-group-mark-regexp
4210 "U" gnus-group-unmark-all-groups)
4212 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
4213 "d" gnus-group-make-directory-group
4214 "h" gnus-group-make-help-group
4215 "a" gnus-group-make-archive-group
4216 "k" gnus-group-make-kiboze-group
4217 "m" gnus-group-make-group
4218 "E" gnus-group-edit-group
4219 "e" gnus-group-edit-group-method
4220 "p" gnus-group-edit-group-parameters
4221 "v" gnus-group-add-to-virtual
4222 "V" gnus-group-make-empty-virtual
4223 "D" gnus-group-enter-directory
4224 "f" gnus-group-make-doc-group
4225 "r" gnus-group-rename-group
4226 "\177" gnus-group-delete-group
4227 [delete] gnus-group-delete-group)
4229 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
4230 "b" gnus-group-brew-soup
4231 "w" gnus-soup-save-areas
4232 "s" gnus-soup-send-replies
4233 "p" gnus-soup-pack-packet
4234 "r" nnsoup-pack-replies)
4236 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
4237 "s" gnus-group-sort-groups
4238 "a" gnus-group-sort-groups-by-alphabet
4239 "u" gnus-group-sort-groups-by-unread
4240 "l" gnus-group-sort-groups-by-level
4241 "v" gnus-group-sort-groups-by-score
4242 "r" gnus-group-sort-groups-by-rank
4243 "m" gnus-group-sort-groups-by-method)
4245 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
4246 "k" gnus-group-list-killed
4247 "z" gnus-group-list-zombies
4248 "s" gnus-group-list-groups
4249 "u" gnus-group-list-all-groups
4250 "A" gnus-group-list-active
4251 "a" gnus-group-apropos
4252 "d" gnus-group-description-apropos
4253 "m" gnus-group-list-matching
4254 "M" gnus-group-list-all-matching
4255 "l" gnus-group-list-level)
4257 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
4258 "f" gnus-score-flush-cache)
4260 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
4261 "f" gnus-group-fetch-faq)
4263 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
4264 "l" gnus-group-set-current-level
4265 "t" gnus-group-unsubscribe-current-group
4266 "s" gnus-group-unsubscribe-group
4267 "k" gnus-group-kill-group
4268 "y" gnus-group-yank-group
4269 "w" gnus-group-kill-region
4270 "\C-k" gnus-group-kill-level
4271 "z" gnus-group-kill-all-zombies))
4273 (defun gnus-group-mode ()
4274 "Major mode for reading news.
4276 All normal editing commands are switched off.
4277 \\<gnus-group-mode-map>
4278 The group buffer lists (some of) the groups available. For instance,
4279 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
4280 lists all zombie groups.
4282 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
4283 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
4285 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
4287 The following commands are available:
4289 \\{gnus-group-mode-map}"
4291 (when (and menu-bar-mode
4292 (gnus-visual-p 'group-menu 'menu))
4293 (gnus-group-make-menu-bar))
4294 (kill-all-local-variables)
4295 (gnus-simplify-mode-line)
4296 (setq major-mode 'gnus-group-mode)
4297 (setq mode-name "Group")
4298 (gnus-group-set-mode-line)
4299 (setq mode-line-process nil)
4300 (use-local-map gnus-group-mode-map)
4301 (buffer-disable-undo (current-buffer))
4302 (setq truncate-lines t)
4303 (setq buffer-read-only t)
4304 (gnus-make-local-hook 'post-command-hook)
4305 (gnus-add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
4306 (run-hooks 'gnus-group-mode-hook))
4308 (defun gnus-clear-inboxes-moved ()
4309 (setq nnmail-moved-inboxes nil))
4311 (defun gnus-mouse-pick-group (e)
4312 "Enter the group under the mouse pointer."
4315 (gnus-group-read-group nil))
4317 ;; Look at LEVEL and find out what the level is really supposed to be.
4318 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
4319 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
4320 (defun gnus-group-default-level (&optional level number-or-nil)
4322 (gnus-group-use-permanent-levels
4323 (or (setq gnus-group-use-permanent-levels
4324 (or level (if (numberp gnus-group-use-permanent-levels)
4325 gnus-group-use-permanent-levels
4326 (or gnus-group-default-list-level
4327 gnus-level-subscribed))))
4328 gnus-group-default-list-level gnus-level-subscribed))
4332 (or level gnus-group-default-list-level gnus-level-subscribed))))
4335 (defun gnus-slave-no-server (&optional arg)
4336 "Read network news as a slave, without connecting to local server"
4338 (gnus-no-server arg t))
4341 (defun gnus-no-server (&optional arg slave)
4343 If ARG is a positive number, Gnus will use that as the
4344 startup level. If ARG is nil, Gnus will be started at level 2.
4345 If ARG is non-nil and not a positive number, Gnus will
4346 prompt the user for the name of an NNTP server to use.
4347 As opposed to `gnus', this command will not connect to the local server."
4349 (let ((val (or arg (1- gnus-level-default-subscribed))))
4351 (make-local-variable 'gnus-group-use-permanent-levels)
4352 (setq gnus-group-use-permanent-levels val)))
4355 (defun gnus-slave (&optional arg)
4356 "Read news as a slave."
4358 (gnus arg nil 'slave))
4361 (defun gnus-other-frame (&optional arg)
4362 "Pop up a frame to read news."
4364 (if (get-buffer gnus-group-buffer)
4365 (let ((pop-up-frames t))
4367 (select-frame (make-frame))
4371 (defun gnus (&optional arg dont-connect slave)
4373 If ARG is non-nil and a positive number, Gnus will use that as the
4374 startup level. If ARG is non-nil and not a positive number, Gnus will
4375 prompt the user for the name of an NNTP server to use."
4378 (if (get-buffer gnus-group-buffer)
4380 (switch-to-buffer gnus-group-buffer)
4381 (gnus-group-get-new-news))
4384 (nnheader-init-server-buffer)
4385 (gnus-read-init-file)
4386 (setq gnus-slave slave)
4388 (gnus-group-setup-buffer)
4389 (let ((buffer-read-only nil))
4391 (if (not gnus-inhibit-startup-message)
4393 (gnus-group-startup-message)
4396 (let ((level (and (numberp arg) (> arg 0) arg))
4402 (gnus-start-news-server (and arg (not level))))))
4403 (if (and (not dont-connect)
4406 (run-hooks 'gnus-startup-hook)
4407 ;; NNTP server is successfully open.
4409 ;; Find the current startup file name.
4410 (setq gnus-current-startup-file
4411 (gnus-make-newsrc-file gnus-startup-file))
4413 ;; Read the dribble file.
4414 (when (or gnus-slave gnus-use-dribble-file)
4415 (gnus-dribble-read-file))
4417 ;; Allow using GroupLens predictions.
4418 (when gnus-use-grouplens
4420 (add-hook 'gnus-summary-mode-hook 'gnus-grouplens-mode))
4422 (gnus-summary-make-display-table)
4423 ;; Do the actual startup.
4424 (gnus-setup-news nil level dont-connect)
4425 ;; Generate the group buffer.
4426 (gnus-group-list-groups level)
4427 (gnus-group-first-unread-group)
4428 (gnus-configure-windows 'group)
4429 (gnus-group-set-mode-line))))))
4431 (defun gnus-unload ()
4432 "Unload all Gnus features."
4434 (or (boundp 'load-history)
4435 (error "Sorry, `gnus-unload' is not implemented in this Emacs version."))
4436 (let ((history load-history)
4439 (and (string-match "^\\(gnus\\|nn\\)" (caar history))
4440 (setq feature (cdr (assq 'provide (car history))))
4441 (unload-feature feature 'force))
4442 (setq history (cdr history)))))
4444 (defun gnus-compile ()
4445 "Byte-compile the user-defined format specs."
4447 (let ((entries gnus-format-specs)
4448 entry gnus-tmp-func)
4450 (gnus-message 7 "Compiling format specs...")
4453 (setq entry (pop entries))
4454 (if (eq (car entry) 'version)
4455 (setq gnus-format-specs (delq entry gnus-format-specs))
4456 (when (and (listp (caddr entry))
4457 (not (eq 'byte-code (caaddr entry))))
4458 (fset 'gnus-tmp-func
4459 `(lambda () ,(caddr entry)))
4460 (byte-compile 'gnus-tmp-func)
4461 (setcar (cddr entry) (gnus-byte-code 'gnus-tmp-func)))))
4463 (push (cons 'version emacs-version) gnus-format-specs)
4465 (gnus-message 7 "Compiling user specs...done"))))
4467 (defun gnus-indent-rigidly (start end arg)
4468 "Indent rigidly using only spaces and no tabs."
4471 (narrow-to-region start end)
4472 (indent-rigidly start end arg)
4473 (goto-char (point-min))
4474 (while (search-forward "\t" nil t)
4475 (replace-match " " t t)))))
4477 (defun gnus-group-startup-message (&optional x y)
4478 "Insert startup message in current buffer."
4479 ;; Insert the message.
4484 _ ___ __ ___ __ _ ___
4503 ;; And then hack it.
4504 (gnus-indent-rigidly (point-min) (point-max)
4505 (/ (max (- (window-width) (or x 46)) 0) 2))
4506 (goto-char (point-min))
4508 (let* ((pheight (count-lines (point-min) (point-max)))
4509 (wheight (window-height))
4510 (rest (- wheight pheight)))
4511 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
4513 (goto-char (point-min))
4514 (and (search-forward "Praxis" nil t)
4515 (gnus-put-text-property (match-beginning 0) (match-end 0) 'face 'bold))
4516 (goto-char (point-min))
4517 (let* ((mode-string (gnus-group-set-mode-line)))
4518 (setq mode-line-buffer-identification
4519 (list (concat gnus-version (substring (car mode-string) 4))))
4520 (set-buffer-modified-p t)))
4522 (defun gnus-group-setup-buffer ()
4523 (or (get-buffer gnus-group-buffer)
4525 (switch-to-buffer gnus-group-buffer)
4526 (gnus-add-current-to-buffer-list)
4528 (and gnus-carpal (gnus-carpal-setup-buffer 'group)))))
4530 (defun gnus-group-list-groups (&optional level unread lowest)
4531 "List newsgroups with level LEVEL or lower that have unread articles.
4532 Default is all subscribed groups.
4533 If argument UNREAD is non-nil, groups with no unread articles are also
4535 (interactive (list (if current-prefix-arg
4536 (prefix-numeric-value current-prefix-arg)
4538 (gnus-group-default-level nil t)
4539 gnus-group-default-list-level
4540 gnus-level-subscribed))))
4542 (setq level (car gnus-group-list-mode)
4543 unread (cdr gnus-group-list-mode)))
4544 (setq level (gnus-group-default-level level))
4545 (gnus-group-setup-buffer) ;May call from out of group buffer
4546 (gnus-update-format-specifications)
4547 (let ((case-fold-search nil)
4548 (props (text-properties-at (gnus-point-at-bol)))
4549 (group (gnus-group-group-name)))
4550 (set-buffer gnus-group-buffer)
4551 (funcall gnus-group-prepare-function level unread lowest)
4552 (if (zerop (buffer-size))
4553 (gnus-message 5 gnus-no-groups-message)
4554 (goto-char (point-max))
4555 (when (or (not gnus-group-goto-next-group-function)
4556 (not (funcall gnus-group-goto-next-group-function
4559 ;; Go to the first group with unread articles.
4560 (gnus-group-search-forward t)
4561 ;; Find the right group to put point on. If the current group
4562 ;; has disappeared in the new listing, try to find the next
4563 ;; one. If no next one can be found, just leave point at the
4564 ;; first newsgroup in the buffer.
4565 (if (not (gnus-goto-char
4567 (point-min) (point-max)
4568 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
4569 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
4571 (not (gnus-goto-char
4573 (point-min) (point-max) 'gnus-group
4575 (caar newsrc) gnus-active-hashtb)))))
4576 (setq newsrc (cdr newsrc)))
4577 (or newsrc (progn (goto-char (point-max))
4578 (forward-line -1)))))))
4579 ;; Adjust cursor point.
4580 (gnus-group-position-point))))
4582 (defun gnus-group-list-level (level &optional all)
4583 "List groups on LEVEL.
4584 If ALL (the prefix), also list groups that have no unread articles."
4585 (interactive "nList groups on level: \nP")
4586 (gnus-group-list-groups level all level))
4588 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
4589 "List all newsgroups with unread articles of level LEVEL or lower.
4590 If ALL is non-nil, list groups that have no unread articles.
4591 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
4592 If REGEXP, only list groups matching REGEXP."
4593 (set-buffer gnus-group-buffer)
4594 (let ((buffer-read-only nil)
4595 (newsrc (cdr gnus-newsrc-alist))
4596 (lowest (or lowest 1))
4597 info clevel unread group params)
4599 (if (< lowest gnus-level-zombie)
4600 ;; List living groups.
4602 (setq info (car newsrc)
4603 group (gnus-info-group info)
4604 params (gnus-info-params info)
4606 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
4607 (and unread ; This group might be bogus
4609 (string-match regexp group))
4610 (<= (setq clevel (gnus-info-level info)) level)
4612 (or all ; We list all groups?
4613 (if (eq unread t) ; Unactivated?
4614 gnus-group-list-inactive-groups ; We list unactivated
4615 (> unread 0)) ; We list groups with unread articles
4616 (and gnus-list-groups-with-ticked-articles
4617 (cdr (assq 'tick (gnus-info-marks info))))
4618 ; And groups with tickeds
4619 ;; Check for permanent visibility.
4620 (and gnus-permanently-visible-groups
4621 (string-match gnus-permanently-visible-groups
4623 (memq 'visible params)
4624 (cdr (assq 'visible params)))
4625 (gnus-group-insert-group-line
4626 group (gnus-info-level info)
4627 (gnus-info-marks info) unread (gnus-info-method info)))))
4629 ;; List dead groups.
4630 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
4631 (gnus-group-prepare-flat-list-dead
4632 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
4633 gnus-level-zombie ?Z
4635 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
4636 (gnus-group-prepare-flat-list-dead
4637 (setq gnus-killed-list (sort gnus-killed-list 'string<))
4638 gnus-level-killed ?K regexp))
4640 (gnus-group-set-mode-line)
4641 (setq gnus-group-list-mode (cons level all))
4642 (run-hooks 'gnus-group-prepare-hook)))
4644 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
4645 ;; List zombies and killed lists somewhat faster, which was
4646 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
4647 ;; this by ignoring the group format specification altogether.
4650 ;; This loop is used when listing groups that match some
4653 (setq group (pop groups))
4654 (when (string-match regexp group)
4655 (gnus-add-text-properties
4656 (point) (prog1 (1+ (point))
4657 (insert " " mark " *: " group "\n"))
4658 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4660 'gnus-level level))))
4661 ;; This loop is used when listing all groups.
4663 (gnus-add-text-properties
4664 (point) (prog1 (1+ (point))
4665 (insert " " mark " *: "
4666 (setq group (pop groups)) "\n"))
4667 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4669 'gnus-level level))))))
4671 (defmacro gnus-group-real-name (group)
4672 "Find the real name of a foreign newsgroup."
4673 `(let ((gname ,group))
4674 (if (string-match ":[^:]+$" gname)
4675 (substring gname (1+ (match-beginning 0)))
4678 (defsubst gnus-server-add-address (method)
4679 (let ((method-name (symbol-name (car method))))
4680 (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
4681 (not (assq (intern (concat method-name "-address")) method)))
4682 (append method (list (list (intern (concat method-name "-address"))
4686 (defsubst gnus-server-get-method (group method)
4687 ;; Input either a server name, and extended server name, or a
4688 ;; select method, and return a select method.
4689 (cond ((stringp method)
4690 (gnus-server-to-method method))
4691 ((equal method gnus-select-method)
4693 ((and (stringp (car method)) group)
4694 (gnus-server-extend-method group method))
4695 ((and method (not group)
4696 (equal (cadr method) ""))
4699 (gnus-server-add-address method))))
4701 (defun gnus-server-to-method (server)
4702 "Map virtual server names to select methods."
4704 ;; Is this a method, perhaps?
4705 (and server (listp server) server)
4706 ;; Perhaps this is the native server?
4707 (and (equal server "native") gnus-select-method)
4708 ;; It should be in the server alist.
4709 (cdr (assoc server gnus-server-alist))
4710 ;; If not, we look through all the opened server
4711 ;; to see whether we can find it there.
4712 (let ((opened gnus-opened-servers))
4714 (not (equal server (format "%s:%s" (caaar opened)
4719 (defmacro gnus-method-equal (ss1 ss2)
4720 "Say whether two servers are equal."
4724 (and (= (length s1) (length s2))
4726 (while (and s1 (member (car s1) s2))
4730 (defun gnus-server-equal (m1 m2)
4731 "Say whether two methods are equal."
4732 (let ((m1 (cond ((null m1) gnus-select-method)
4733 ((stringp m1) (gnus-server-to-method m1))
4735 (m2 (cond ((null m2) gnus-select-method)
4736 ((stringp m2) (gnus-server-to-method m2))
4738 (gnus-method-equal m1 m2)))
4740 (defun gnus-servers-using-backend (backend)
4741 "Return a list of known servers using BACKEND."
4742 (let ((opened gnus-opened-servers)
4745 (when (eq backend (caaar opened))
4746 (push (caar opened) out))
4750 (defun gnus-group-prefixed-name (group method)
4751 "Return the whole name from GROUP and METHOD."
4752 (and (stringp method) (setq method (gnus-server-to-method method)))
4753 (concat (format "%s" (car method))
4755 (or (assoc (format "%s" (car method))
4756 (gnus-methods-using 'address))
4757 (gnus-server-equal method gnus-message-archive-method))
4759 (not (string= (nth 1 method) "")))
4760 (concat "+" (nth 1 method)))
4763 (defun gnus-group-real-prefix (group)
4764 "Return the prefix of the current group name."
4765 (if (string-match "^[^:]+:" group)
4766 (substring group 0 (match-end 0))
4769 (defun gnus-group-method (group)
4770 "Return the server or method used for selecting GROUP."
4771 (let ((prefix (gnus-group-real-prefix group)))
4772 (if (equal prefix "")
4774 (let ((servers gnus-opened-servers)
4776 backend possible found)
4777 (if (string-match "^[^\\+]+\\+" prefix)
4778 (setq backend (intern (substring prefix 0 (1- (match-end 0))))
4779 server (substring prefix (match-end 0) (1- (length prefix))))
4780 (setq backend (intern (substring prefix 0 (1- (length prefix))))))
4782 (when (eq (caaar servers) backend)
4783 (setq possible (caar servers))
4784 (when (equal (cadaar servers) server)
4785 (setq found (caar servers))))
4787 (or (car (rassoc found gnus-server-alist))
4789 (car (rassoc possible gnus-server-alist))
4791 (list backend server))))))
4793 (defsubst gnus-secondary-method-p (method)
4794 "Return whether METHOD is a secondary select method."
4795 (let ((methods gnus-secondary-select-methods)
4796 (gmethod (gnus-server-get-method nil method)))
4798 (not (equal (gnus-server-get-method nil (car methods))
4800 (setq methods (cdr methods)))
4803 (defun gnus-group-foreign-p (group)
4804 "Say whether a group is foreign or not."
4805 (and (not (gnus-group-native-p group))
4806 (not (gnus-group-secondary-p group))))
4808 (defun gnus-group-native-p (group)
4809 "Say whether the group is native or not."
4810 (not (string-match ":" group)))
4812 (defun gnus-group-secondary-p (group)
4813 "Say whether the group is secondary or not."
4814 (gnus-secondary-method-p (gnus-find-method-for-group group)))
4816 (defun gnus-group-get-parameter (group &optional symbol)
4817 "Returns the group parameters for GROUP.
4818 If SYMBOL, return the value of that symbol in the group parameters."
4819 (let ((params (gnus-info-params (gnus-get-info group))))
4821 (gnus-group-parameter-value params symbol)
4824 (defun gnus-group-parameter-value (params symbol)
4825 "Return the value of SYMBOL in group PARAMS."
4826 (or (car (memq symbol params)) ; It's either a simple symbol
4827 (cdr (assq symbol params)))) ; or a cons.
4829 (defun gnus-group-add-parameter (group param)
4830 "Add parameter PARAM to GROUP."
4831 (let ((info (gnus-get-info group)))
4833 () ; This is a dead group. We just ignore it.
4834 ;; Cons the new param to the old one and update.
4835 (gnus-group-set-info (cons param (gnus-info-params info))
4838 (defun gnus-group-set-parameter (group name value)
4839 "Set parameter NAME to VALUE in GROUP."
4840 (let ((info (gnus-get-info group)))
4842 () ; This is a dead group. We just ignore it.
4843 (let ((old-params (gnus-info-params info))
4844 (new-params (list (cons name value))))
4846 (if (or (not (listp (car old-params)))
4847 (not (eq (caar old-params) name)))
4848 (setq new-params (append new-params (list (car old-params)))))
4849 (setq old-params (cdr old-params)))
4850 (gnus-group-set-info new-params group 'params)))))
4852 (defun gnus-group-add-score (group &optional score)
4853 "Add SCORE to the GROUP score.
4854 If SCORE is nil, add 1 to the score of GROUP."
4855 (let ((info (gnus-get-info group)))
4857 (gnus-info-set-score info (+ (gnus-info-score info) (or score 1))))))
4859 (defun gnus-summary-bubble-group ()
4860 "Increase the score of the current group.
4861 This is a handy function to add to `gnus-summary-exit-hook' to
4862 increase the score of each group you read."
4863 (gnus-group-add-score gnus-newsgroup-name))
4865 (defun gnus-group-set-info (info &optional method-only-group part)
4866 (let* ((entry (gnus-gethash
4867 (or method-only-group (gnus-info-group info))
4868 gnus-newsrc-hashtb))
4870 (info (if method-only-group (nth 2 entry) info))
4872 (when method-only-group
4874 (error "Trying to change non-existent group %s" method-only-group))
4875 ;; We have received parts of the actual group info - either the
4876 ;; select method or the group parameters. We first check
4877 ;; whether we have to extend the info, and if so, do that.
4878 (let ((len (length info))
4879 (total (if (eq part 'method) 5 6)))
4881 (setcdr (nthcdr (1- len) info)
4882 (make-list (- total len) nil)))
4883 ;; Then we enter the new info.
4884 (setcar (nthcdr (1- total) info) part-info)))
4886 ;; This is a new group, so we just create it.
4888 (set-buffer gnus-group-buffer)
4889 (setq method (gnus-info-method info))
4890 (when (gnus-server-equal method "native")
4893 (set-buffer gnus-group-buffer)
4895 ;; It's a foreign group...
4896 (gnus-group-make-group
4897 (gnus-group-real-name (gnus-info-group info))
4898 (if (stringp method) method
4899 (prin1-to-string (car method)))
4901 (nth 1 (gnus-info-method info))))
4902 ;; It's a native group.
4903 (gnus-group-make-group (gnus-info-group info))))
4904 (gnus-message 6 "Note: New group created")
4906 (gnus-gethash (gnus-group-prefixed-name
4907 (gnus-group-real-name (gnus-info-group info))
4908 (or (gnus-info-method info) gnus-select-method))
4909 gnus-newsrc-hashtb))))
4910 ;; Whether it was a new group or not, we now have the entry, so we
4911 ;; can do the update.
4914 (setcar (nthcdr 2 entry) info)
4915 (when (and (not (eq (car entry) t))
4916 (gnus-active (gnus-info-group info)))
4917 (setcar entry (length (gnus-list-of-unread-articles (car info))))))
4918 (error "No such group: %s" (gnus-info-group info)))))
4920 (defun gnus-group-set-method-info (group select-method)
4921 (gnus-group-set-info select-method group 'method))
4923 (defun gnus-group-set-params-info (group params)
4924 (gnus-group-set-info params group 'params))
4926 (defun gnus-group-update-group-line ()
4927 "Update the current line in the group buffer."
4928 (let* ((buffer-read-only nil)
4929 (group (gnus-group-group-name))
4930 (entry (and group (gnus-gethash group gnus-newsrc-hashtb)))
4931 gnus-group-indentation)
4934 (not (gnus-ephemeral-group-p group))
4936 (concat "(gnus-group-set-info '"
4937 (prin1-to-string (nth 2 entry)) ")")))
4938 (setq gnus-group-indentation (gnus-group-group-indentation))
4940 (gnus-group-insert-group-line-info group)
4942 (gnus-group-position-point))))
4944 (defun gnus-group-insert-group-line-info (group)
4945 "Insert GROUP on the current line."
4946 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
4950 ;; (Un)subscribed group.
4951 (setq info (nth 2 entry))
4952 (gnus-group-insert-group-line
4953 group (gnus-info-level info) (gnus-info-marks info)
4954 (or (car entry) t) (gnus-info-method info)))
4955 ;; This group is dead.
4956 (gnus-group-insert-group-line
4958 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
4960 (if (setq active (gnus-active group))
4961 (- (1+ (cdr active)) (car active)) 0)
4964 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
4965 gnus-tmp-marked number
4967 "Insert a group line in the group buffer."
4968 (let* ((gnus-tmp-active (gnus-active gnus-tmp-group))
4969 (gnus-tmp-number-total
4971 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
4973 (gnus-tmp-number-of-unread
4974 (if (numberp number) (int-to-string (max 0 number))
4976 (gnus-tmp-number-of-read
4977 (if (numberp number)
4978 (int-to-string (max 0 (- gnus-tmp-number-total number)))
4980 (gnus-tmp-subscribed
4981 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
4982 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
4983 ((= gnus-tmp-level gnus-level-zombie) ?Z)
4985 (gnus-tmp-qualified-group (gnus-group-real-name gnus-tmp-group))
4986 (gnus-tmp-newsgroup-description
4987 (if gnus-description-hashtb
4988 (or (gnus-gethash gnus-tmp-group gnus-description-hashtb) "")
4991 (if (member gnus-tmp-group gnus-moderated-list) ?m ? ))
4992 (gnus-tmp-moderated-string
4993 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
4995 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
4996 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
4997 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
4998 (gnus-tmp-news-method-string
5000 (format "(%s:%s)" (car gnus-tmp-method)
5001 (cadr gnus-tmp-method)) ""))
5002 (gnus-tmp-marked-mark
5003 (if (and (numberp number)
5005 (cdr (assq 'tick gnus-tmp-marked)))
5007 (gnus-tmp-process-marked
5008 (if (member gnus-tmp-group gnus-group-marked)
5009 gnus-process-mark ? ))
5011 (or (and gnus-use-grouplens
5012 (bbb-grouplens-group-p gnus-tmp-group))
5014 (buffer-read-only nil)
5015 header gnus-tmp-header) ; passed as parameter to user-funcs.
5017 (gnus-add-text-properties
5021 (eval gnus-group-line-format-spec))
5022 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
5023 gnus-unread ,(if (numberp number)
5024 (string-to-int gnus-tmp-number-of-unread)
5026 gnus-marked ,gnus-tmp-marked-mark
5027 gnus-indentation ,gnus-group-indentation
5028 gnus-level ,gnus-tmp-level))
5029 (when (inline (gnus-visual-p 'group-highlight 'highlight))
5031 (run-hooks 'gnus-group-update-hook)
5033 ;; Allow XEmacs to remove front-sticky text properties.
5034 (gnus-group-remove-excess-properties)))
5036 (defun gnus-group-update-group (group &optional visible-only)
5037 "Update all lines where GROUP appear.
5038 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
5041 (set-buffer gnus-group-buffer)
5042 ;; The buffer may be narrowed.
5045 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
5047 found buffer-read-only)
5048 ;; Enter the current status into the dribble buffer.
5049 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
5050 (if (and entry (not (gnus-ephemeral-group-p group)))
5052 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
5054 ;; Find all group instances. If topics are in use, each group
5055 ;; may be listed in more than once.
5056 (while (setq loc (text-property-any
5057 loc (point-max) 'gnus-group ident))
5060 (let ((gnus-group-indentation (gnus-group-group-indentation)))
5062 (gnus-group-insert-group-line-info group)
5065 (run-hooks 'gnus-group-update-group-hook)))
5066 (setq loc (1+ loc)))
5067 (unless (or found visible-only)
5068 ;; No such line in the buffer, find out where it's supposed to
5069 ;; go, and insert it there (or at the end of the buffer).
5070 (if gnus-goto-missing-group-function
5071 (funcall gnus-goto-missing-group-function group)
5072 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
5073 (while (and entry (car entry)
5077 (point-min) (point-max)
5078 'gnus-group (gnus-intern-safe
5079 (caar entry) gnus-active-hashtb)))))
5080 (setq entry (cdr entry)))
5081 (or entry (goto-char (point-max)))))
5082 ;; Finally insert the line.
5083 (let ((gnus-group-indentation (gnus-group-group-indentation)))
5084 (gnus-group-insert-group-line-info group)
5087 (run-hooks 'gnus-group-update-group-hook))))
5088 (gnus-group-set-mode-line)))))
5090 (defun gnus-group-set-mode-line ()
5091 "Update the mode line in the group buffer."
5092 (when (memq 'group gnus-updated-mode-lines)
5093 ;; Yes, we want to keep this mode line updated.
5095 (set-buffer gnus-group-buffer)
5096 (let* ((gformat (or gnus-group-mode-line-format-spec
5097 (setq gnus-group-mode-line-format-spec
5099 gnus-group-mode-line-format
5100 gnus-group-mode-line-format-alist))))
5101 (gnus-tmp-news-server (cadr gnus-select-method))
5102 (gnus-tmp-news-method (car gnus-select-method))
5103 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
5105 gnus-tmp-header ;Dummy binding for user-defined formats
5106 ;; Get the resulting string.
5108 (and gnus-dribble-buffer
5109 (buffer-name gnus-dribble-buffer)
5110 (buffer-modified-p gnus-dribble-buffer)
5112 (set-buffer gnus-dribble-buffer)
5113 (not (zerop (buffer-size))))))
5114 (mode-string (eval gformat)))
5115 ;; Say whether the dribble buffer has been modified.
5116 (setq mode-line-modified
5117 (if modified "---*- " "----- "))
5118 ;; If the line is too long, we chop it off.
5119 (when (> (length mode-string) max-len)
5120 (setq mode-string (substring mode-string 0 (- max-len 4))))
5122 (setq mode-line-buffer-identification
5123 (gnus-mode-line-buffer-identification
5124 (list mode-string)))
5125 (set-buffer-modified-p modified))))))
5127 (defun gnus-group-group-name ()
5128 "Get the name of the newsgroup on the current line."
5129 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
5130 (and group (symbol-name group))))
5132 (defun gnus-group-group-level ()
5133 "Get the level of the newsgroup on the current line."
5134 (get-text-property (gnus-point-at-bol) 'gnus-level))
5136 (defun gnus-group-group-indentation ()
5137 "Get the indentation of the newsgroup on the current line."
5138 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
5139 (and gnus-group-indentation-function
5140 (funcall gnus-group-indentation-function))
5143 (defun gnus-group-group-unread ()
5144 "Get the number of unread articles of the newsgroup on the current line."
5145 (get-text-property (gnus-point-at-bol) 'gnus-unread))
5147 (defun gnus-group-search-forward (&optional backward all level first-too)
5148 "Find the next newsgroup with unread articles.
5149 If BACKWARD is non-nil, find the previous newsgroup instead.
5150 If ALL is non-nil, just find any newsgroup.
5151 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
5153 If FIRST-TOO, the current line is also eligible as a target."
5154 (let ((way (if backward -1 1))
5155 (low gnus-level-killed)
5158 (if (and backward (progn (beginning-of-line)) (bobp))
5160 (or first-too (forward-line way))
5168 (get-text-property (point) 'gnus-unread)))
5169 (and (numberp unread) (> unread 0)))
5170 (setq lev (get-text-property (point)
5172 (<= lev gnus-level-subscribed)))
5174 (and (setq lev (get-text-property (point)
5183 (zerop (forward-line way)))))
5185 (progn (gnus-group-position-point) t)
5186 (goto-char (or pos beg))
5189 ;;; Gnus group mode commands
5193 (defun gnus-group-mark-group (n &optional unmark no-advance)
5194 "Mark the current group."
5196 (let ((buffer-read-only nil)
5200 (when (setq group (gnus-group-group-name))
5204 (or (cdr (assq 'process gnus-group-mark-positions)) 2))
5209 (setq gnus-group-marked (delete group gnus-group-marked)))
5211 (setq gnus-group-marked
5212 (cons group (delete group gnus-group-marked)))))
5213 (or no-advance (gnus-group-next-group 1))
5215 (gnus-summary-position-point)
5218 (defun gnus-group-unmark-group (n)
5219 "Remove the mark from the current group."
5221 (gnus-group-mark-group n 'unmark)
5222 (gnus-group-position-point))
5224 (defun gnus-group-unmark-all-groups ()
5225 "Unmark all groups."
5227 (let ((groups gnus-group-marked))
5230 (gnus-group-remove-mark (pop groups)))))
5231 (gnus-group-position-point))
5233 (defun gnus-group-mark-region (unmark beg end)
5234 "Mark all groups between point and mark.
5235 If UNMARK, remove the mark instead."
5236 (interactive "P\nr")
5237 (let ((num (count-lines beg end)))
5240 (- num (gnus-group-mark-group num unmark)))))
5242 (defun gnus-group-mark-buffer (&optional unmark)
5243 "Mark all groups in the buffer.
5244 If UNMARK, remove the mark instead."
5246 (gnus-group-mark-region unmark (point-min) (point-max)))
5248 (defun gnus-group-mark-regexp (regexp)
5249 "Mark all groups that match some regexp."
5250 (interactive "sMark (regexp): ")
5251 (let ((alist (cdr gnus-newsrc-alist))
5254 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
5255 (gnus-group-set-mark group))))
5256 (gnus-group-position-point))
5258 (defun gnus-group-remove-mark (group)
5259 "Remove the process mark from GROUP and move point there.
5260 Return nil if the group isn't displayed."
5261 (if (gnus-group-goto-group group)
5263 (gnus-group-mark-group 1 'unmark t)
5265 (setq gnus-group-marked
5266 (delete group gnus-group-marked))
5269 (defun gnus-group-set-mark (group)
5270 "Set the process mark on GROUP."
5271 (if (gnus-group-goto-group group)
5273 (gnus-group-mark-group 1 nil t))
5274 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
5276 (defun gnus-group-universal-argument (arg &optional groups func)
5277 "Perform any command on all groups accoring to the process/prefix convention."
5279 (let ((groups (or groups (gnus-group-process-prefix arg)))
5281 (if (eq (setq func (or func
5284 (substitute-command-keys
5285 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
5287 (gnus-error 1 "Undefined key")
5289 (gnus-group-remove-mark (setq group (pop groups)))
5290 (command-execute func))))
5291 (gnus-group-position-point))
5293 (defun gnus-group-process-prefix (n)
5294 "Return a list of groups to work on.
5295 Take into consideration N (the prefix) and the list of marked groups."
5298 (setq n (prefix-numeric-value n))
5299 ;; There is a prefix, so we return a list of the N next
5301 (let ((way (if (< n 0) -1 1))
5306 (setq group (gnus-group-group-name)))
5307 (setq groups (cons group groups))
5309 (gnus-group-next-group way)))
5311 ((and (boundp 'transient-mark-mode)
5313 (boundp 'mark-active)
5315 ;; Work on the region between point and mark.
5316 (let ((max (max (point) (mark)))
5319 (goto-char (min (point) (mark)))
5322 (push (gnus-group-group-name) groups)
5323 (zerop (gnus-group-next-group 1))
5325 (nreverse groups))))
5327 ;; No prefix, but a list of marked articles.
5328 (reverse gnus-group-marked))
5330 ;; Neither marked articles or a prefix, so we return the
5332 (let ((group (gnus-group-group-name)))
5333 (and group (list group))))))
5335 ;; Selecting groups.
5337 (defun gnus-group-read-group (&optional all no-article group)
5338 "Read news in this newsgroup.
5339 If the prefix argument ALL is non-nil, already read articles become
5340 readable. IF ALL is a number, fetch this number of articles. If the
5341 optional argument NO-ARTICLE is non-nil, no article will be
5342 auto-selected upon group entry. If GROUP is non-nil, fetch that
5345 (let ((group (or group (gnus-group-group-name)))
5346 number active marked entry)
5347 (or group (error "No group on current line"))
5348 (setq marked (nth 3 (nth 2 (setq entry (gnus-gethash
5349 group gnus-newsrc-hashtb)))))
5350 ;; This group might be a dead group. In that case we have to get
5351 ;; the number of unread articles from `gnus-active-hashtb'.
5353 (cond ((numberp all) all)
5355 ((setq active (gnus-active group))
5356 (- (1+ (cdr active)) (car active)))))
5357 (gnus-summary-read-group
5358 group (or all (and (numberp number)
5359 (zerop (+ number (length (cdr (assq 'tick marked)))
5360 (length (cdr (assq 'dormant marked)))))))
5363 (defun gnus-group-select-group (&optional all)
5364 "Select this newsgroup.
5365 No article is selected automatically.
5366 If ALL is non-nil, already read articles become readable.
5367 If ALL is a number, fetch this number of articles."
5369 (gnus-group-read-group all t))
5371 (defun gnus-group-quick-select-group (&optional all)
5372 "Select the current group \"quickly\".
5373 This means that no highlighting or scoring will be performed."
5376 gnus-score-find-score-files-function
5377 gnus-apply-kill-hook
5378 gnus-summary-expunge-below)
5379 (gnus-group-read-group all t)))
5381 (defun gnus-group-visible-select-group (&optional all)
5382 "Select the current group without hiding any articles."
5384 (let ((gnus-inhibit-limiting t))
5385 (gnus-group-read-group all t)))
5388 (defun gnus-fetch-group (group)
5389 "Start Gnus if necessary and enter GROUP.
5390 Returns whether the fetching was successful or not."
5391 (interactive "sGroup name: ")
5392 (or (get-buffer gnus-group-buffer)
5394 (gnus-group-read-group nil nil group))
5396 ;; Enter a group that is not in the group buffer. Non-nil is returned
5397 ;; if selection was successful.
5398 (defun gnus-group-read-ephemeral-group
5399 (group method &optional activate quit-config)
5400 (let ((group (if (gnus-group-foreign-p group) group
5401 (gnus-group-prefixed-name group method))))
5404 `(t nil (,group ,gnus-level-default-subscribed nil nil ,method
5405 ((quit-config . ,(if quit-config quit-config
5406 (cons (current-buffer) 'summary))))))
5408 (set-buffer gnus-group-buffer)
5409 (or (gnus-check-server method)
5410 (error "Unable to contact server: %s" (gnus-status-message method)))
5411 (if activate (or (gnus-request-group group)
5412 (error "Couldn't request group")))
5414 (gnus-group-read-group t t group)
5418 (defun gnus-group-jump-to-group (group)
5419 "Jump to newsgroup GROUP."
5421 (list (completing-read
5422 "Group: " gnus-active-hashtb nil
5423 (gnus-read-active-file-p)
5425 'gnus-group-history)))
5427 (when (equal group "")
5428 (error "Empty group name"))
5430 (when (string-match "[\000-\032]" group)
5431 (error "Control characters in group: %s" group))
5433 (let ((b (text-property-any
5434 (point-min) (point-max)
5435 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
5436 (unless (gnus-ephemeral-group-p group)
5438 ;; Either go to the line in the group buffer...
5440 ;; ... or insert the line.
5443 (gnus-activate-group group)
5444 (error "%s error: %s" group (gnus-status-message group)))
5446 (gnus-group-update-group group)
5447 (goto-char (text-property-any
5448 (point-min) (point-max)
5449 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))
5450 ;; Adjust cursor point.
5451 (gnus-group-position-point)))
5453 (defun gnus-group-goto-group (group)
5454 "Goto to newsgroup GROUP."
5456 (let ((b (text-property-any (point-min) (point-max)
5457 'gnus-group (gnus-intern-safe
5458 group gnus-active-hashtb))))
5459 (and b (goto-char b)))))
5461 (defun gnus-group-next-group (n)
5462 "Go to next N'th newsgroup.
5463 If N is negative, search backward instead.
5464 Returns the difference between N and the number of skips actually
5467 (gnus-group-next-unread-group n t))
5469 (defun gnus-group-next-unread-group (n &optional all level)
5470 "Go to next N'th unread newsgroup.
5471 If N is negative, search backward instead.
5472 If ALL is non-nil, choose any newsgroup, unread or not.
5473 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
5474 such group can be found, the next group with a level higher than
5476 Returns the difference between N and the number of skips actually
5479 (let ((backward (< n 0))
5482 (gnus-group-search-forward
5483 backward (or (not gnus-group-goto-unread) all) level))
5485 (if (/= 0 n) (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
5486 (if level " on this level or higher" "")))
5489 (defun gnus-group-prev-group (n)
5490 "Go to previous N'th newsgroup.
5491 Returns the difference between N and the number of skips actually
5494 (gnus-group-next-unread-group (- n) t))
5496 (defun gnus-group-prev-unread-group (n)
5497 "Go to previous N'th unread newsgroup.
5498 Returns the difference between N and the number of skips actually
5501 (gnus-group-next-unread-group (- n)))
5503 (defun gnus-group-next-unread-group-same-level (n)
5504 "Go to next N'th unread newsgroup on the same level.
5505 If N is negative, search backward instead.
5506 Returns the difference between N and the number of skips actually
5509 (gnus-group-next-unread-group n t (gnus-group-group-level))
5510 (gnus-group-position-point))
5512 (defun gnus-group-prev-unread-group-same-level (n)
5513 "Go to next N'th unread newsgroup on the same level.
5514 Returns the difference between N and the number of skips actually
5517 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
5518 (gnus-group-position-point))
5520 (defun gnus-group-best-unread-group (&optional exclude-group)
5521 "Go to the group with the highest level.
5522 If EXCLUDE-GROUP, do not go to that group."
5524 (goto-char (point-min))
5528 (setq unread (get-text-property (point) 'gnus-unread))
5529 (if (and (numberp unread) (> unread 0))
5531 (if (and (get-text-property (point) 'gnus-level)
5532 (< (get-text-property (point) 'gnus-level) best)
5533 (or (not exclude-group)
5534 (not (equal exclude-group (gnus-group-group-name)))))
5536 (setq best (get-text-property (point) 'gnus-level))
5537 (setq best-point (point))))))
5539 (if best-point (goto-char best-point))
5540 (gnus-summary-position-point)
5541 (and best-point (gnus-group-group-name))))
5543 (defun gnus-group-first-unread-group ()
5544 "Go to the first group with unread articles."
5547 (let ((opoint (point))
5549 (goto-char (point-min))
5550 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
5551 (and (numberp unread) ; Not a topic.
5552 (not (zerop unread))) ; Has unread articles.
5553 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
5556 nil)) ; Not success.
5557 (gnus-group-position-point)))
5559 (defun gnus-group-enter-server-mode ()
5560 "Jump to the server buffer."
5562 (gnus-enter-server-buffer))
5564 (defun gnus-group-make-group (name &optional method address)
5565 "Add a new newsgroup.
5566 The user will be prompted for a NAME, for a select METHOD, and an
5570 (read-string "Group name: ")
5573 "Method: " (append gnus-valid-select-methods gnus-server-alist)
5574 nil t nil 'gnus-method-history)))
5575 (cond ((assoc method gnus-valid-select-methods)
5577 (if (memq 'prompt-address
5578 (assoc method gnus-valid-select-methods))
5579 (read-string "Address: ")
5581 ((assoc method gnus-server-alist)
5584 (list method ""))))))
5586 (let* ((meth (and method (if address (list (intern method) address)
5588 (nname (if method (gnus-group-prefixed-name name meth) name))
5590 (when (gnus-gethash nname gnus-newsrc-hashtb)
5591 (error "Group %s already exists" nname))
5592 ;; Subscribe to the new group.
5593 (gnus-group-change-level
5594 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
5595 gnus-level-default-subscribed gnus-level-killed
5596 (and (gnus-group-group-name)
5597 (gnus-gethash (gnus-group-group-name)
5598 gnus-newsrc-hashtb))
5601 (gnus-set-active nname (cons 1 0))
5602 (or (gnus-ephemeral-group-p name)
5604 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")")))
5606 (gnus-group-insert-group-line-info nname)
5608 (gnus-group-position-point)
5610 ;; Load the backend and try to make the backend create
5611 ;; the group as well.
5612 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
5614 gnus-valid-select-methods)
5616 (gnus-check-server meth)
5617 (and (gnus-check-backend-function 'request-create-group nname)
5618 (gnus-request-create-group nname))
5621 (defun gnus-group-delete-group (group &optional force)
5622 "Delete the current group. Only meaningful with mail groups.
5623 If FORCE (the prefix) is non-nil, all the articles in the group will
5624 be deleted. This is \"deleted\" as in \"removed forever from the face
5625 of the Earth\". There is no undo. The user will be prompted before
5626 doing the deletion."
5628 (list (gnus-group-group-name)
5629 current-prefix-arg))
5630 (or group (error "No group to rename"))
5631 (or (gnus-check-backend-function 'request-delete-group group)
5632 (error "This backend does not support group deletion"))
5634 (if (not (gnus-yes-or-no-p
5636 "Do you really want to delete %s%s? "
5637 group (if force " and all its contents" ""))))
5639 (gnus-message 6 "Deleting group %s..." group)
5640 (if (not (gnus-request-delete-group group force))
5641 (gnus-error 3 "Couldn't delete group %s" group)
5642 (gnus-message 6 "Deleting group %s...done" group)
5643 (gnus-group-goto-group group)
5644 (gnus-group-kill-group 1 t)
5645 (gnus-sethash group nil gnus-active-hashtb)
5647 (gnus-group-position-point)))
5649 (defun gnus-group-rename-group (group new-name)
5652 (gnus-group-group-name)
5654 (or (gnus-check-backend-function
5655 'request-rename-group (gnus-group-group-name))
5656 (error "This backend does not support renaming groups"))
5657 (read-string "New group name: "))))
5659 (or (gnus-check-backend-function 'request-rename-group group)
5660 (error "This backend does not support renaming groups"))
5662 (or group (error "No group to rename"))
5663 (and (string-match "^[ \t]*$" new-name)
5664 (error "Not a valid group name"))
5666 ;; We find the proper prefixed name.
5668 (gnus-group-prefixed-name
5669 (gnus-group-real-name new-name)
5670 (gnus-info-method (gnus-get-info group))))
5672 (gnus-message 6 "Renaming group %s to %s..." group new-name)
5674 (if (not (gnus-request-rename-group group new-name))
5675 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
5676 ;; We rename the group internally by killing it...
5677 (gnus-group-goto-group group)
5678 (gnus-group-kill-group)
5679 ;; ... changing its name ...
5680 (setcar (cdar gnus-list-of-killed-groups) new-name)
5681 ;; ... and then yanking it. Magic!
5682 (gnus-group-yank-group)
5683 (gnus-set-active new-name (gnus-active group))
5684 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
5686 (gnus-group-position-point)))
5688 (defun gnus-group-edit-group (group &optional part)
5689 "Edit the group on the current line."
5690 (interactive (list (gnus-group-group-name)))
5691 (let* ((part (or part 'info))
5692 (done-func `(lambda ()
5693 "Exit editing mode and update the information."
5695 (gnus-group-edit-group-done ',part ,group)))
5696 (winconf (current-window-configuration))
5698 (or group (error "No group on current line"))
5699 (or (setq info (gnus-get-info group))
5700 (error "Killed group; can't be edited"))
5701 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5702 (gnus-configure-windows 'edit-group)
5703 (gnus-add-current-to-buffer-list)
5705 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
5706 (use-local-map (copy-keymap emacs-lisp-mode-map))
5707 (local-set-key "\C-c\C-c" done-func)
5708 (make-local-variable 'gnus-prev-winconf)
5709 (setq gnus-prev-winconf winconf)
5714 ";; Type `C-c C-c' after editing the select method.\n\n")
5716 ";; Type `C-c C-c' after editing the group parameters.\n\n")
5718 ";; Type `C-c C-c' after editing the group info.\n\n")))
5721 (cond ((eq part 'method)
5722 (or (gnus-info-method info) "native"))
5724 (gnus-info-params info))
5728 (defun gnus-group-edit-group-method (group)
5729 "Edit the select method of GROUP."
5730 (interactive (list (gnus-group-group-name)))
5731 (gnus-group-edit-group group 'method))
5733 (defun gnus-group-edit-group-parameters (group)
5734 "Edit the group parameters of GROUP."
5735 (interactive (list (gnus-group-group-name)))
5736 (gnus-group-edit-group group 'params))
5738 (defun gnus-group-edit-group-done (part group)
5739 "Get info from buffer, update variables and jump to the group buffer."
5740 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5741 (goto-char (point-min))
5742 (let* ((form (read (current-buffer)))
5743 (winconf gnus-prev-winconf)
5744 (method (cond ((eq part 'info) (nth 4 form))
5745 ((eq part 'method) form)
5747 (info (cond ((eq part 'info) form)
5748 ((eq part 'method) (gnus-get-info group))
5751 (if (or (not method)
5753 gnus-select-method method))
5754 (gnus-group-real-name (car info))
5755 (gnus-group-prefixed-name
5756 (gnus-group-real-name (car info)) method))
5758 (when (and new-group
5759 (not (equal new-group group)))
5760 (when (gnus-group-goto-group group)
5761 (gnus-group-kill-group 1))
5762 (gnus-activate-group new-group))
5764 (if (and info new-group)
5766 (setq info (gnus-copy-sequence info))
5767 (setcar info new-group)
5768 (unless (gnus-server-equal method "native")
5769 (unless (nthcdr 3 info)
5770 (nconc info (list nil nil)))
5771 (unless (nthcdr 4 info)
5772 (nconc info (list nil)))
5773 (gnus-info-set-method info method))
5774 (gnus-group-set-info info))
5775 (gnus-group-set-info form (or new-group group) part))
5776 (kill-buffer (current-buffer))
5777 (and winconf (set-window-configuration winconf))
5778 (set-buffer gnus-group-buffer)
5779 (gnus-group-update-group (or new-group group))
5780 (gnus-group-position-point)))
5782 (defun gnus-group-make-help-group ()
5783 "Create the Gnus documentation group."
5785 (let ((path load-path)
5786 (name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
5788 (and (gnus-gethash name gnus-newsrc-hashtb)
5789 (error "Documentation group already exists"))
5791 (setq dir (file-name-as-directory (expand-file-name (pop path)))
5793 (when (or (file-exists-p (setq file (concat dir "gnus-tut.txt")))
5795 (setq file (concat (file-name-directory
5796 (directory-file-name dir))
5797 "etc/gnus-tut.txt"))))
5800 (gnus-message 1 "Couldn't find doc group")
5801 (gnus-group-make-group
5802 (gnus-group-real-name name)
5803 (list 'nndoc "gnus-help"
5804 (list 'nndoc-address file)
5805 (list 'nndoc-article-type 'mbox)))))
5806 (gnus-group-position-point))
5808 (defun gnus-group-make-doc-group (file type)
5809 "Create a group that uses a single file as the source."
5811 (list (read-file-name "File name: ")
5812 (and current-prefix-arg 'ask)))
5813 (when (eq type 'ask)
5818 "%sFile type (mbox, babyl, digest, forward, mmfd, guess) [mbdfag]: "
5820 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
5821 ((= char ?b) 'babyl)
5822 ((= char ?d) 'digest)
5823 ((= char ?f) 'forward)
5825 (t (setq err (format "%c unknown. " char))
5828 (let* ((file (expand-file-name file))
5829 (name (gnus-generate-new-group-name
5830 (gnus-group-prefixed-name
5831 (file-name-nondirectory file) '(nndoc "")))))
5832 (gnus-group-make-group
5833 (gnus-group-real-name name)
5834 (list 'nndoc (file-name-nondirectory file)
5835 (list 'nndoc-address file)
5836 (list 'nndoc-article-type (or type 'guess))))))
5838 (defun gnus-group-make-archive-group (&optional all)
5839 "Create the (ding) Gnus archive group of the most recent articles.
5840 Given a prefix, create a full group."
5842 (let ((group (gnus-group-prefixed-name
5843 (if all "ding.archives" "ding.recent") '(nndir ""))))
5844 (and (gnus-gethash group gnus-newsrc-hashtb)
5845 (error "Archive group already exists"))
5846 (gnus-group-make-group
5847 (gnus-group-real-name group)
5848 (list 'nndir (if all "hpc" "edu")
5849 (list 'nndir-directory
5850 (if all gnus-group-archive-directory
5851 gnus-group-recent-archive-directory))))))
5853 (defun gnus-group-make-directory-group (dir)
5854 "Create an nndir group.
5855 The user will be prompted for a directory. The contents of this
5856 directory will be used as a newsgroup. The directory should contain
5857 mail messages or news articles in files that have numeric names."
5859 (list (read-file-name "Create group from directory: ")))
5860 (or (file-exists-p dir) (error "No such directory"))
5861 (or (file-directory-p dir) (error "Not a directory"))
5865 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
5867 (gnus-group-prefixed-name
5868 (concat (file-name-as-directory (directory-file-name dir))
5871 (setq ext (format "<%d>" (setq i (1+ i)))))
5872 (gnus-group-make-group
5873 (gnus-group-real-name group)
5874 (list 'nndir group (list 'nndir-directory dir)))))
5876 (defun gnus-group-make-kiboze-group (group address scores)
5877 "Create an nnkiboze group.
5878 The user will be prompted for a name, a regexp to match groups, and
5879 score file entries for articles to include in the group."
5882 (read-string "nnkiboze group name: ")
5883 (read-string "Source groups (regexp): ")
5884 (let ((headers (mapcar (lambda (group) (list group))
5885 '("subject" "from" "number" "date" "message-id"
5886 "references" "chars" "lines" "xref"
5887 "followup" "all" "body" "head")))
5888 scores header regexp regexps)
5889 (while (not (equal "" (setq header (completing-read
5890 "Match on header: " headers nil t))))
5892 (while (not (equal "" (setq regexp (read-string
5893 (format "Match on %s (string): "
5895 (setq regexps (cons (list regexp nil nil 'r) regexps)))
5896 (setq scores (cons (cons header regexps) scores)))
5898 (gnus-group-make-group group "nnkiboze" address)
5899 (nnheader-temp-write (gnus-score-file-name (concat "nnkiboze:" group))
5900 (let (emacs-lisp-mode-hook)
5901 (pp scores (current-buffer)))))
5903 (defun gnus-group-add-to-virtual (n vgroup)
5904 "Add the current group to a virtual group."
5906 (list current-prefix-arg
5907 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
5909 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
5910 (error "%s is not an nnvirtual group" vgroup))
5911 (let* ((groups (gnus-group-process-prefix n))
5912 (method (gnus-info-method (gnus-get-info vgroup))))
5913 (setcar (cdr method)
5915 (nth 1 method) "\\|"
5918 (gnus-group-remove-mark s)
5919 (concat "\\(^" (regexp-quote s) "$\\)"))
5921 (gnus-group-position-point))
5923 (defun gnus-group-make-empty-virtual (group)
5924 "Create a new, fresh, empty virtual group."
5925 (interactive "sCreate new, empty virtual group: ")
5926 (let* ((method (list 'nnvirtual "^$"))
5927 (pgroup (gnus-group-prefixed-name group method)))
5928 ;; Check whether it exists already.
5929 (and (gnus-gethash pgroup gnus-newsrc-hashtb)
5930 (error "Group %s already exists." pgroup))
5931 ;; Subscribe the new group after the group on the current line.
5932 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
5933 (gnus-group-update-group pgroup)
5935 (gnus-group-position-point)))
5937 (defun gnus-group-enter-directory (dir)
5938 "Enter an ephemeral nneething group."
5939 (interactive "DDirectory to read: ")
5940 (let* ((method (list 'nneething dir))
5941 (leaf (gnus-group-prefixed-name
5942 (file-name-nondirectory (directory-file-name dir))
5944 (name (gnus-generate-new-group-name leaf)))
5945 (let ((nneething-read-only t))
5946 (or (gnus-group-read-ephemeral-group
5948 (cons (current-buffer) (if (eq major-mode 'gnus-summary-mode)
5950 (error "Couldn't enter %s" dir)))))
5952 ;; Group sorting commands
5953 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
5955 (defun gnus-group-sort-groups (func &optional reverse)
5956 "Sort the group buffer according to FUNC.
5957 If REVERSE, reverse the sorting order."
5958 (interactive (list gnus-group-sort-function
5959 current-prefix-arg))
5961 ((not (listp func)) func)
5963 ((= 1 (length func)) (car func))
5965 ,(gnus-make-sort-function
5966 (reverse func)))))))
5967 ;; We peel off the dummy group from the alist.
5969 (when (equal (car (gnus-info-group gnus-newsrc-alist)) "dummy.group")
5970 (pop gnus-newsrc-alist))
5972 (setq gnus-newsrc-alist
5973 (sort gnus-newsrc-alist func))
5975 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
5976 ;; Regenerate the hash table.
5977 (gnus-make-hashtable-from-newsrc-alist)
5978 (gnus-group-list-groups))))
5980 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
5981 "Sort the group buffer alphabetically by group name.
5982 If REVERSE, sort in reverse order."
5984 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
5986 (defun gnus-group-sort-groups-by-unread (&optional reverse)
5987 "Sort the group buffer by number of unread articles.
5988 If REVERSE, sort in reverse order."
5990 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
5992 (defun gnus-group-sort-groups-by-level (&optional reverse)
5993 "Sort the group buffer by group level.
5994 If REVERSE, sort in reverse order."
5996 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
5998 (defun gnus-group-sort-groups-by-score (&optional reverse)
5999 "Sort the group buffer by group score.
6000 If REVERSE, sort in reverse order."
6002 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
6004 (defun gnus-group-sort-groups-by-rank (&optional reverse)
6005 "Sort the group buffer by group rank.
6006 If REVERSE, sort in reverse order."
6008 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
6010 (defun gnus-group-sort-groups-by-method (&optional reverse)
6011 "Sort the group buffer alphabetically by backend name.
6012 If REVERSE, sort in reverse order."
6014 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
6016 (defun gnus-group-sort-by-alphabet (info1 info2)
6017 "Sort alphabetically."
6018 (string< (gnus-info-group info1) (gnus-info-group info2)))
6020 (defun gnus-group-sort-by-unread (info1 info2)
6021 "Sort by number of unread articles."
6022 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
6023 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
6024 (< (or (and (numberp n1) n1) 0)
6025 (or (and (numberp n2) n2) 0))))
6027 (defun gnus-group-sort-by-level (info1 info2)
6029 (< (gnus-info-level info1) (gnus-info-level info2)))
6031 (defun gnus-group-sort-by-method (info1 info2)
6032 "Sort alphabetically by backend name."
6033 (string< (symbol-name (car (gnus-find-method-for-group
6034 (gnus-info-group info1) info1)))
6035 (symbol-name (car (gnus-find-method-for-group
6036 (gnus-info-group info2) info2)))))
6038 (defun gnus-group-sort-by-score (info1 info2)
6039 "Sort by group score."
6040 (< (gnus-info-score info1) (gnus-info-score info2)))
6042 (defun gnus-group-sort-by-rank (info1 info2)
6043 "Sort by level and score."
6044 (let ((level1 (gnus-info-level info1))
6045 (level2 (gnus-info-level info2)))
6046 (or (< level1 level2)
6047 (and (= level1 level2)
6048 (> (gnus-info-score info1) (gnus-info-score info2))))))
6050 ;; Group catching up.
6052 (defun gnus-group-clear-data (n)
6053 "Clear all marks and read ranges from the current group."
6055 (let ((groups (gnus-group-process-prefix n))
6057 (while (setq group (pop groups))
6058 (setq info (gnus-get-info group))
6059 (gnus-info-set-read info nil)
6060 (when (gnus-info-marks info)
6061 (gnus-info-set-marks info nil))
6062 (gnus-get-unread-articles-in-group info (gnus-active group) t)
6063 (when (gnus-group-goto-group group)
6064 (gnus-group-remove-mark group)
6065 (gnus-group-update-group-line)))))
6067 (defun gnus-group-catchup-current (&optional n all)
6068 "Mark all articles not marked as unread in current newsgroup as read.
6069 If prefix argument N is numeric, the ARG next newsgroups will be
6070 caught up. If ALL is non-nil, marked articles will also be marked as
6071 read. Cross references (Xref: header) of articles are ignored.
6072 The difference between N and actual number of newsgroups that were
6073 caught up is returned."
6075 (unless (gnus-group-group-name)
6076 (error "No group on the current line"))
6077 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
6081 "Do you really want to mark all articles as read? "
6082 "Mark all unread articles as read? "))))
6084 (let ((groups (gnus-group-process-prefix n))
6087 ;; Virtual groups have to be given special treatment.
6088 (let ((method (gnus-find-method-for-group (car groups))))
6089 (if (eq 'nnvirtual (car method))
6090 (nnvirtual-catchup-group
6091 (gnus-group-real-name (car groups)) (nth 1 method) all)))
6092 (gnus-group-remove-mark (car groups))
6093 (if (>= (gnus-group-group-level) gnus-level-zombie)
6094 (gnus-message 2 "Dead groups can't be caught up")
6096 (gnus-group-goto-group (car groups))
6097 (gnus-group-catchup (car groups) all))
6098 (gnus-group-update-group-line)
6099 (setq ret (1+ ret))))
6100 (setq groups (cdr groups)))
6101 (gnus-group-next-unread-group 1)
6104 (defun gnus-group-catchup-current-all (&optional n)
6105 "Mark all articles in current newsgroup as read.
6106 Cross references (Xref: header) of articles are ignored."
6108 (gnus-group-catchup-current n 'all))
6110 (defun gnus-group-catchup (group &optional all)
6111 "Mark all articles in GROUP as read.
6112 If ALL is non-nil, all articles are marked as read.
6113 The return value is the number of articles that were marked as read,
6114 or nil if no action could be taken."
6115 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
6117 ;; Do the updating only if the newsgroup isn't killed.
6118 (if (not (numberp (car entry)))
6119 (gnus-message 1 "Can't catch up; non-active group")
6120 ;; Do auto-expirable marks if that's required.
6121 (when (gnus-group-auto-expirable-p group)
6122 (gnus-add-marked-articles
6123 group 'expire (gnus-list-of-unread-articles group))
6125 (let ((marks (nth 3 (nth 2 entry))))
6126 (gnus-add-marked-articles
6127 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))
6128 (gnus-add-marked-articles
6129 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))))))
6131 (gnus-update-read-articles group nil)
6132 ;; Also nix out the lists of marks and dormants.
6134 (gnus-add-marked-articles group 'tick nil nil 'force)
6135 (gnus-add-marked-articles group 'dormant nil nil 'force))
6136 (run-hooks 'gnus-group-catchup-group-hook)
6139 (defun gnus-group-expire-articles (&optional n)
6140 "Expire all expirable articles in the current newsgroup."
6142 (let ((groups (gnus-group-process-prefix n))
6145 (error "No groups to expire"))
6146 (while (setq group (pop groups))
6147 (gnus-group-remove-mark group)
6148 (when (gnus-check-backend-function 'request-expire-articles group)
6149 (gnus-message 6 "Expiring articles in %s..." group)
6150 (let* ((info (gnus-get-info group))
6151 (expirable (if (gnus-group-total-expirable-p group)
6152 (cons nil (gnus-list-of-read-articles group))
6153 (assq 'expire (gnus-info-marks info))))
6154 (expiry-wait (gnus-group-get-parameter group 'expiry-wait)))
6158 (gnus-compress-sequence
6160 ;; We set the expiry variables to the groupp
6162 (let ((nnmail-expiry-wait-function nil)
6163 (nnmail-expiry-wait expiry-wait))
6164 (gnus-request-expire-articles
6165 (gnus-uncompress-sequence (cdr expirable)) group))
6166 ;; Just expire using the normal expiry values.
6167 (gnus-request-expire-articles
6168 (gnus-uncompress-sequence (cdr expirable)) group))))
6169 (gnus-close-group group))
6170 (gnus-message 6 "Expiring articles in %s...done" group)))
6171 (gnus-group-position-point))))
6173 (defun gnus-group-expire-all-groups ()
6174 "Expire all expirable articles in all newsgroups."
6177 (gnus-message 5 "Expiring...")
6178 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
6179 (cdr gnus-newsrc-alist))))
6180 (gnus-group-expire-articles nil)))
6181 (gnus-group-position-point)
6182 (gnus-message 5 "Expiring...done"))
6184 (defun gnus-group-set-current-level (n level)
6185 "Set the level of the next N groups to LEVEL."
6190 (let ((s (read-string
6191 (format "Level (default %s): "
6192 (or (gnus-group-group-level)
6193 gnus-level-default-subscribed)))))
6194 (if (string-match "^\\s-*$" s)
6195 (int-to-string (or (gnus-group-group-level)
6196 gnus-level-default-subscribed))
6198 (or (and (>= level 1) (<= level gnus-level-killed))
6199 (error "Illegal level: %d" level))
6200 (let ((groups (gnus-group-process-prefix n))
6202 (while (setq group (pop groups))
6203 (gnus-group-remove-mark group)
6204 (gnus-message 6 "Changed level of %s from %d to %d"
6205 group (or (gnus-group-group-level) gnus-level-killed)
6207 (gnus-group-change-level
6208 group level (or (gnus-group-group-level) gnus-level-killed))
6209 (gnus-group-update-group-line)))
6210 (gnus-group-position-point))
6212 (defun gnus-group-unsubscribe-current-group (&optional n)
6213 "Toggle subscription of the current group.
6214 If given numerical prefix, toggle the N next groups."
6216 (let ((groups (gnus-group-process-prefix n))
6219 (setq group (car groups)
6220 groups (cdr groups))
6221 (gnus-group-remove-mark group)
6222 (gnus-group-unsubscribe-group
6223 group (if (<= (gnus-group-group-level) gnus-level-subscribed)
6224 gnus-level-default-unsubscribed
6225 gnus-level-default-subscribed) t)
6226 (gnus-group-update-group-line))
6227 (gnus-group-next-group 1)))
6229 (defun gnus-group-unsubscribe-group (group &optional level silent)
6230 "Toggle subscription to GROUP.
6231 Killed newsgroups are subscribed. If SILENT, don't try to update the
6234 (list (completing-read
6235 "Group: " gnus-active-hashtb nil
6236 (gnus-read-active-file-p)
6238 'gnus-group-history)))
6239 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
6241 ((string-match "^[ \t]$" group)
6242 (error "Empty group name"))
6244 ;; Toggle subscription flag.
6245 (gnus-group-change-level
6246 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
6247 gnus-level-subscribed)
6248 (1+ gnus-level-subscribed)
6249 gnus-level-default-subscribed)))
6251 (gnus-group-update-group group)))
6252 ((and (stringp group)
6253 (or (not (gnus-read-active-file-p))
6254 (gnus-active group)))
6255 ;; Add new newsgroup.
6256 (gnus-group-change-level
6258 (if level level gnus-level-default-subscribed)
6259 (or (and (member group gnus-zombie-list)
6262 (and (gnus-group-group-name)
6263 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
6265 (gnus-group-update-group group)))
6266 (t (error "No such newsgroup: %s" group)))
6267 (gnus-group-position-point)))
6269 (defun gnus-group-transpose-groups (n)
6270 "Move the current newsgroup up N places.
6271 If given a negative prefix, move down instead. The difference between
6272 N and the number of steps taken is returned."
6274 (or (gnus-group-group-name)
6275 (error "No group on current line"))
6276 (gnus-group-kill-group 1)
6278 (forward-line (- n))
6279 (gnus-group-yank-group)
6280 (gnus-group-position-point)))
6282 (defun gnus-group-kill-all-zombies ()
6283 "Kill all zombie newsgroups."
6285 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
6286 (setq gnus-zombie-list nil)
6287 (gnus-group-list-groups))
6289 (defun gnus-group-kill-region (begin end)
6290 "Kill newsgroups in current region (excluding current point).
6291 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
6306 (beginning-of-line) ;Important when LINES < 1
6307 (gnus-group-kill-group lines)))
6309 (defun gnus-group-kill-group (&optional n discard)
6310 "Kill the next N groups.
6311 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
6312 However, only groups that were alive can be yanked; already killed
6313 groups or zombie groups can't be yanked.
6314 The return value is the name of the group that was killed, or a list
6317 (let ((buffer-read-only nil)
6318 (groups (gnus-group-process-prefix n))
6319 group entry level out)
6320 (if (< (length groups) 10)
6321 ;; This is faster when there are few groups.
6323 (push (setq group (pop groups)) out)
6324 (gnus-group-remove-mark group)
6325 (setq level (gnus-group-group-level))
6327 (when (and (not discard)
6328 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
6329 (push (cons (car entry) (nth 2 entry))
6330 gnus-list-of-killed-groups))
6331 (gnus-group-change-level
6332 (if entry entry group) gnus-level-killed (if entry nil level)))
6333 ;; If there are lots and lots of groups to be killed, we use
6334 ;; this thing instead.
6336 (setq groups (nreverse groups))
6338 (gnus-group-remove-mark (setq group (pop groups)))
6340 (push group gnus-killed-list)
6341 (setq gnus-newsrc-alist
6342 (delq (assoc group gnus-newsrc-alist)
6344 (when gnus-group-change-level-function
6345 (funcall gnus-group-change-level-function group 9 3))
6347 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
6348 (push (cons (car entry) (nth 2 entry))
6349 gnus-list-of-killed-groups)
6350 (setcdr (cdr entry) (cdddr entry)))
6351 ((member group gnus-zombie-list)
6352 (setq gnus-zombie-list (delete group gnus-zombie-list)))))
6353 (gnus-make-hashtable-from-newsrc-alist)))
6355 (gnus-group-position-point)
6356 (if (< (length out) 2) (car out) (nreverse out))))
6358 (defun gnus-group-yank-group (&optional arg)
6359 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
6360 inserting it before the current newsgroup. The numeric ARG specifies
6361 how many newsgroups are to be yanked. The name of the newsgroup yanked
6362 is returned, or (if several groups are yanked) a list of yanked groups
6365 (setq arg (or arg 1))
6366 (let (info group prev out)
6367 (while (>= (decf arg) 0)
6368 (if (not (setq info (pop gnus-list-of-killed-groups)))
6369 (error "No more newsgroups to yank"))
6370 (push (setq group (nth 1 info)) out)
6371 ;; Find which newsgroup to insert this one before - search
6372 ;; backward until something suitable is found. If there are no
6373 ;; other newsgroups in this buffer, just make this newsgroup the
6375 (setq prev (gnus-group-group-name))
6376 (gnus-group-change-level
6377 info (gnus-info-level (cdr info)) gnus-level-killed
6378 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
6380 (gnus-group-insert-group-line-info group))
6382 (gnus-group-position-point)
6383 (if (< (length out) 2) (car out) (nreverse out))))
6385 (defun gnus-group-kill-level (level)
6386 "Kill all groups that is on a certain LEVEL."
6387 (interactive "nKill all groups on level: ")
6389 ((= level gnus-level-zombie)
6390 (setq gnus-killed-list
6391 (nconc gnus-zombie-list gnus-killed-list))
6392 (setq gnus-zombie-list nil))
6393 ((and (< level gnus-level-zombie)
6395 (or gnus-expert-user
6398 "Do you really want to kill all groups on level %d? "
6400 (let* ((prev gnus-newsrc-alist)
6403 (if (= (gnus-info-level level) level)
6404 (setcdr prev (cdr alist))
6406 (setq alist (cdr alist)))
6407 (gnus-make-hashtable-from-newsrc-alist)
6408 (gnus-group-list-groups)))
6410 (error "Can't kill; illegal level: %d" level))))
6412 (defun gnus-group-list-all-groups (&optional arg)
6413 "List all newsgroups with level ARG or lower.
6414 Default is gnus-level-unsubscribed, which lists all subscribed and most
6415 unsubscribed groups."
6417 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
6419 ;; Redefine this to list ALL killed groups if prefix arg used.
6420 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
6421 (defun gnus-group-list-killed (&optional arg)
6422 "List all killed newsgroups in the group buffer.
6423 If ARG is non-nil, list ALL killed groups known to Gnus. This may
6424 entail asking the server for the groups."
6426 ;; Find all possible killed newsgroups if arg.
6428 (gnus-get-killed-groups))
6429 (if (not gnus-killed-list)
6430 (gnus-message 6 "No killed groups")
6431 (let (gnus-group-list-mode)
6432 (funcall gnus-group-prepare-function
6433 gnus-level-killed t gnus-level-killed))
6434 (goto-char (point-min)))
6435 (gnus-group-position-point))
6437 (defun gnus-group-list-zombies ()
6438 "List all zombie newsgroups in the group buffer."
6440 (if (not gnus-zombie-list)
6441 (gnus-message 6 "No zombie groups")
6442 (let (gnus-group-list-mode)
6443 (funcall gnus-group-prepare-function
6444 gnus-level-zombie t gnus-level-zombie))
6445 (goto-char (point-min)))
6446 (gnus-group-position-point))
6448 (defun gnus-group-list-active ()
6449 "List all groups that are available from the server(s)."
6451 ;; First we make sure that we have really read the active file.
6452 (unless (gnus-read-active-file-p)
6453 (let ((gnus-read-active-file t))
6454 (gnus-read-active-file)))
6455 ;; Find all groups and sort them.
6463 (setq list (cons (symbol-name sym) list))))
6467 (buffer-read-only nil))
6470 (gnus-group-insert-group-line-info (pop groups)))
6471 (goto-char (point-min))))
6473 (defun gnus-activate-all-groups (level)
6474 "Activate absolutely all groups."
6475 (interactive (list 7))
6476 (let ((gnus-activate-level level)
6477 (gnus-activate-foreign-newsgroups level))
6478 (gnus-group-get-new-news)))
6480 (defun gnus-group-get-new-news (&optional arg)
6481 "Get newly arrived articles.
6482 If ARG is a number, it specifies which levels you are interested in
6483 re-scanning. If ARG is non-nil and not a number, this will force
6484 \"hard\" re-reading of the active files from all servers."
6486 (run-hooks 'gnus-get-new-news-hook)
6487 ;; We might read in new NoCeM messages here.
6488 (when (and gnus-use-nocem
6490 (gnus-nocem-scan-groups))
6491 ;; If ARG is not a number, then we read the active file.
6492 (when (and arg (not (numberp arg)))
6493 (let ((gnus-read-active-file t))
6494 (gnus-read-active-file))
6497 (setq arg (gnus-group-default-level arg t))
6498 (if (and gnus-read-active-file (not arg))
6500 (gnus-read-active-file)
6501 (gnus-get-unread-articles arg))
6502 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
6503 (gnus-get-unread-articles arg)))
6504 (run-hooks 'gnus-after-getting-new-news-hook)
6505 (gnus-group-list-groups))
6507 (defun gnus-group-get-new-news-this-group (&optional n)
6508 "Check for newly arrived news in the current group (and the N-1 next groups).
6509 The difference between N and the number of newsgroup checked is returned.
6510 If N is negative, this group and the N-1 previous groups will be checked."
6512 (let* ((groups (gnus-group-process-prefix n))
6513 (ret (if (numberp n) (- n (length groups)) 0))
6514 (beg (unless n (point)))
6516 (while (setq group (pop groups))
6517 (gnus-group-remove-mark group)
6518 (if (gnus-activate-group group 'scan)
6520 (gnus-get-unread-articles-in-group
6521 (gnus-get-info group) (gnus-active group) t)
6522 (unless (gnus-virtual-group-p group)
6523 (gnus-close-group group))
6524 (gnus-group-update-group group))
6525 (gnus-error 3 "%s error: %s" group (gnus-status-message group))))
6526 (when beg (goto-char beg))
6527 (when gnus-goto-next-group-when-activating
6528 (gnus-group-next-unread-group 1 t))
6529 (gnus-summary-position-point)
6532 (defun gnus-group-fetch-faq (group &optional faq-dir)
6533 "Fetch the FAQ for the current group."
6536 (and (gnus-group-group-name)
6537 (gnus-group-real-name (gnus-group-group-name)))
6538 (cond (current-prefix-arg
6540 "Faq dir: " (and (listp gnus-group-faq-directory)
6541 (mapcar (lambda (file) (list file))
6542 gnus-group-faq-directory)))))))
6544 (setq faq-dir (if (listp gnus-group-faq-directory)
6545 (car gnus-group-faq-directory)
6546 gnus-group-faq-directory)))
6547 (or group (error "No group name given"))
6548 (let ((file (concat (file-name-as-directory faq-dir)
6549 (gnus-group-real-name group))))
6550 (if (not (file-exists-p file))
6551 (error "No such file: %s" file)
6554 (defun gnus-group-describe-group (force &optional group)
6555 "Display a description of the current newsgroup."
6556 (interactive (list current-prefix-arg (gnus-group-group-name)))
6558 gnus-description-hashtb)
6559 (gnus-sethash group nil gnus-description-hashtb))
6560 (let ((method (gnus-find-method-for-group group))
6562 (or group (error "No group name given"))
6563 (and (or (and gnus-description-hashtb
6564 ;; We check whether this group's method has been
6565 ;; queried for a description file.
6567 (gnus-group-prefixed-name "" method)
6568 gnus-description-hashtb))
6569 (setq desc (gnus-group-get-description group))
6570 (gnus-read-descriptions-file method))
6572 (or desc (gnus-gethash group gnus-description-hashtb)
6573 "No description available")))))
6575 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6576 (defun gnus-group-describe-all-groups (&optional force)
6577 "Pop up a buffer with descriptions of all newsgroups."
6579 (and force (setq gnus-description-hashtb nil))
6580 (if (not (or gnus-description-hashtb
6581 (gnus-read-all-descriptions-files)))
6582 (error "Couldn't request descriptions file"))
6583 (let ((buffer-read-only nil)
6589 (insert (format " *: %-20s %s\n" (symbol-name group)
6590 (symbol-value group)))
6591 (gnus-add-text-properties
6592 b (1+ b) (list 'gnus-group group
6593 'gnus-unread t 'gnus-marked nil
6594 'gnus-level (1+ gnus-level-subscribed))))
6595 gnus-description-hashtb)
6596 (goto-char (point-min))
6597 (gnus-group-position-point)))
6599 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
6600 (defun gnus-group-apropos (regexp &optional search-description)
6601 "List all newsgroups that have names that match a regexp."
6602 (interactive "sGnus apropos (regexp): ")
6604 (obuf (current-buffer))
6606 ;; Go through all newsgroups that are known to Gnus.
6609 (and (symbol-name group)
6610 (string-match regexp (symbol-name group))
6611 (setq groups (cons (symbol-name group) groups))))
6613 ;; Also go through all descriptions that are known to Gnus.
6614 (when search-description
6617 (and (string-match regexp (symbol-value group))
6618 (gnus-active (symbol-name group))
6619 (setq groups (cons (symbol-name group) groups))))
6620 gnus-description-hashtb))
6622 (gnus-message 3 "No groups matched \"%s\"." regexp)
6623 ;; Print out all the groups.
6625 (pop-to-buffer "*Gnus Help*")
6626 (buffer-disable-undo (current-buffer))
6628 (setq groups (sort groups 'string<))
6630 ;; Groups may be entered twice into the list of groups.
6631 (if (not (string= (car groups) prev))
6633 (insert (setq prev (car groups)) "\n")
6634 (if (and gnus-description-hashtb
6635 (setq des (gnus-gethash (car groups)
6636 gnus-description-hashtb)))
6637 (insert " " des "\n"))))
6638 (setq groups (cdr groups)))
6639 (goto-char (point-min))))
6640 (pop-to-buffer obuf)))
6642 (defun gnus-group-description-apropos (regexp)
6643 "List all newsgroups that have names or descriptions that match a regexp."
6644 (interactive "sGnus description apropos (regexp): ")
6645 (if (not (or gnus-description-hashtb
6646 (gnus-read-all-descriptions-files)))
6647 (error "Couldn't request descriptions file"))
6648 (gnus-group-apropos regexp t))
6650 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6651 (defun gnus-group-list-matching (level regexp &optional all lowest)
6652 "List all groups with unread articles that match REGEXP.
6653 If the prefix LEVEL is non-nil, it should be a number that says which
6654 level to cut off listing groups.
6655 If ALL, also list groups with no unread articles.
6656 If LOWEST, don't list groups with level lower than LOWEST.
6658 This command may read the active file."
6659 (interactive "P\nsList newsgroups matching: ")
6660 ;; First make sure active file has been read.
6662 (> (prefix-numeric-value level) gnus-level-killed))
6663 (gnus-get-killed-groups))
6664 (gnus-group-prepare-flat (or level gnus-level-subscribed)
6665 all (or lowest 1) regexp)
6666 (goto-char (point-min))
6667 (gnus-group-position-point))
6669 (defun gnus-group-list-all-matching (level regexp &optional lowest)
6670 "List all groups that match REGEXP.
6671 If the prefix LEVEL is non-nil, it should be a number that says which
6672 level to cut off listing groups.
6673 If LOWEST, don't list groups with level lower than LOWEST."
6674 (interactive "P\nsList newsgroups matching: ")
6675 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
6677 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
6678 (defun gnus-group-save-newsrc (&optional force)
6679 "Save the Gnus startup files.
6680 If FORCE, force saving whether it is necessary or not."
6682 (gnus-save-newsrc-file force))
6684 (defun gnus-group-restart (&optional arg)
6685 "Force Gnus to read the .newsrc file."
6687 (when (gnus-yes-or-no-p
6688 (format "Are you sure you want to read %s? "
6689 gnus-current-startup-file))
6690 (gnus-save-newsrc-file)
6691 (gnus-setup-news 'force)
6692 (gnus-group-list-groups arg)))
6694 (defun gnus-group-read-init-file ()
6695 "Read the Gnus elisp init file."
6697 (gnus-read-init-file))
6699 (defun gnus-group-check-bogus-groups (&optional silent)
6700 "Check bogus newsgroups.
6701 If given a prefix, don't ask for confirmation before removing a bogus
6704 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
6705 (gnus-group-list-groups))
6707 (defun gnus-group-edit-global-kill (&optional article group)
6708 "Edit the global kill file.
6709 If GROUP, edit that local kill file instead."
6711 (setq gnus-current-kill-article article)
6712 (gnus-kill-file-edit-file group)
6715 (substitute-command-keys
6716 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
6717 (if group "local" "global")))))
6719 (defun gnus-group-edit-local-kill (article group)
6720 "Edit a local kill file."
6721 (interactive (list nil (gnus-group-group-name)))
6722 (gnus-group-edit-global-kill article group))
6724 (defun gnus-group-force-update ()
6725 "Update `.newsrc' file."
6727 (gnus-save-newsrc-file))
6729 (defun gnus-group-suspend ()
6730 "Suspend the current Gnus session.
6731 In fact, cleanup buffers except for group mode buffer.
6732 The hook gnus-suspend-gnus-hook is called before actually suspending."
6734 (run-hooks 'gnus-suspend-gnus-hook)
6735 ;; Kill Gnus buffers except for group mode buffer.
6736 (let ((group-buf (get-buffer gnus-group-buffer)))
6737 ;; Do this on a separate list in case the user does a ^G before we finish
6738 (let ((gnus-buffer-list
6739 (delq group-buf (delq gnus-dribble-buffer
6740 (append gnus-buffer-list nil)))))
6741 (while gnus-buffer-list
6742 (gnus-kill-buffer (car gnus-buffer-list))
6743 (setq gnus-buffer-list (cdr gnus-buffer-list))))
6746 (setq gnus-buffer-list (list group-buf))
6747 (bury-buffer group-buf)
6748 (delete-windows-on group-buf t)))))
6750 (defun gnus-group-clear-dribble ()
6751 "Clear all information from the dribble buffer."
6753 (gnus-dribble-clear)
6754 (gnus-message 7 "Cleared dribble buffer"))
6756 (defun gnus-group-exit ()
6757 "Quit reading news after updating .newsrc.eld and .newsrc.
6758 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6761 (or noninteractive ;For gnus-batch-kill
6762 (not gnus-interactive-exit) ;Without confirmation
6764 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
6765 (run-hooks 'gnus-exit-gnus-hook)
6766 ;; Offer to save data from non-quitted summary buffers.
6767 (gnus-offer-save-summaries)
6768 ;; Save the newsrc file(s).
6769 (gnus-save-newsrc-file)
6771 (gnus-close-backends)
6772 ;; Reset everything.
6774 ;; Allow the user to do things after cleaning up.
6775 (run-hooks 'gnus-after-exiting-gnus-hook)))
6777 (defun gnus-close-backends ()
6778 ;; Send a close request to all backends that support such a request.
6779 (let ((methods gnus-valid-select-methods)
6782 (if (fboundp (setq func (intern (concat (caar methods)
6783 "-request-close"))))
6785 (setq methods (cdr methods)))))
6787 (defun gnus-group-quit ()
6788 "Quit reading news without updating .newsrc.eld or .newsrc.
6789 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6791 (when (or noninteractive ;For gnus-batch-kill
6792 (zerop (buffer-size))
6793 (not (gnus-server-opened gnus-select-method))
6795 (not gnus-current-startup-file)
6797 (format "Quit reading news without saving %s? "
6798 (file-name-nondirectory gnus-current-startup-file))))
6799 (run-hooks 'gnus-exit-gnus-hook)
6800 (if gnus-use-full-window
6801 (delete-other-windows)
6802 (gnus-remove-some-windows))
6804 (gnus-close-backends)
6806 ;; Allow the user to do things after cleaning up.
6807 (run-hooks 'gnus-after-exiting-gnus-hook)))
6809 (defun gnus-offer-save-summaries ()
6810 "Offer to save all active summary buffers."
6812 (let ((buflist (buffer-list))
6814 ;; Go through all buffers and find all summaries.
6816 (and (setq bufname (buffer-name (car buflist)))
6817 (string-match "Summary" bufname)
6819 (set-buffer bufname)
6820 ;; We check that this is, indeed, a summary buffer.
6821 (and (eq major-mode 'gnus-summary-mode)
6822 ;; Also make sure this isn't bogus.
6823 gnus-newsgroup-prepared))
6824 (push bufname buffers))
6825 (setq buflist (cdr buflist)))
6826 ;; Go through all these summary buffers and offer to save them.
6829 "Update summary buffer %s? "
6830 (lambda (buf) (set-buffer buf) (gnus-summary-exit))
6833 (defun gnus-group-describe-briefly ()
6834 "Give a one line description of the group mode commands."
6836 (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")))
6838 (defun gnus-group-browse-foreign-server (method)
6839 "Browse a foreign news server.
6840 If called interactively, this function will ask for a select method
6841 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
6842 If not, METHOD should be a list where the first element is the method
6843 and the second element is the address."
6845 (list (let ((how (completing-read
6847 (append gnus-valid-select-methods gnus-server-alist)
6848 nil t (cons "nntp" 0) 'gnus-method-history)))
6849 ;; We either got a backend name or a virtual server name.
6850 ;; If the first, we also need an address.
6851 (if (assoc how gnus-valid-select-methods)
6853 ;; Suggested by mapjph@bath.ac.uk.
6856 (mapcar (lambda (server) (list server))
6857 gnus-secondary-servers)))
6858 ;; We got a server name, so we find the method.
6859 (gnus-server-to-method how)))))
6860 (gnus-browse-foreign-server method))
6864 ;;; Gnus summary mode
6867 (defvar gnus-summary-mode-map nil)
6869 (put 'gnus-summary-mode 'mode-class 'special)
6871 (unless gnus-summary-mode-map
6872 (setq gnus-summary-mode-map (make-keymap))
6873 (suppress-keymap gnus-summary-mode-map)
6875 ;; Non-orthogonal keys
6877 (gnus-define-keys gnus-summary-mode-map
6878 " " gnus-summary-next-page
6879 "\177" gnus-summary-prev-page
6880 [delete] gnus-summary-prev-page
6881 "\r" gnus-summary-scroll-up
6882 "n" gnus-summary-next-unread-article
6883 "p" gnus-summary-prev-unread-article
6884 "N" gnus-summary-next-article
6885 "P" gnus-summary-prev-article
6886 "\M-\C-n" gnus-summary-next-same-subject
6887 "\M-\C-p" gnus-summary-prev-same-subject
6888 "\M-n" gnus-summary-next-unread-subject
6889 "\M-p" gnus-summary-prev-unread-subject
6890 "." gnus-summary-first-unread-article
6891 "," gnus-summary-best-unread-article
6892 "\M-s" gnus-summary-search-article-forward
6893 "\M-r" gnus-summary-search-article-backward
6894 "<" gnus-summary-beginning-of-article
6895 ">" gnus-summary-end-of-article
6896 "j" gnus-summary-goto-article
6897 "^" gnus-summary-refer-parent-article
6898 "\M-^" gnus-summary-refer-article
6899 "u" gnus-summary-tick-article-forward
6900 "!" gnus-summary-tick-article-forward
6901 "U" gnus-summary-tick-article-backward
6902 "d" gnus-summary-mark-as-read-forward
6903 "D" gnus-summary-mark-as-read-backward
6904 "E" gnus-summary-mark-as-expirable
6905 "\M-u" gnus-summary-clear-mark-forward
6906 "\M-U" gnus-summary-clear-mark-backward
6907 "k" gnus-summary-kill-same-subject-and-select
6908 "\C-k" gnus-summary-kill-same-subject
6909 "\M-\C-k" gnus-summary-kill-thread
6910 "\M-\C-l" gnus-summary-lower-thread
6911 "e" gnus-summary-edit-article
6912 "#" gnus-summary-mark-as-processable
6913 "\M-#" gnus-summary-unmark-as-processable
6914 "\M-\C-t" gnus-summary-toggle-threads
6915 "\M-\C-s" gnus-summary-show-thread
6916 "\M-\C-h" gnus-summary-hide-thread
6917 "\M-\C-f" gnus-summary-next-thread
6918 "\M-\C-b" gnus-summary-prev-thread
6919 "\M-\C-u" gnus-summary-up-thread
6920 "\M-\C-d" gnus-summary-down-thread
6921 "&" gnus-summary-execute-command
6922 "c" gnus-summary-catchup-and-exit
6923 "\C-w" gnus-summary-mark-region-as-read
6924 "\C-t" gnus-summary-toggle-truncation
6925 "?" gnus-summary-mark-as-dormant
6926 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
6927 "\C-c\C-s\C-n" gnus-summary-sort-by-number
6928 "\C-c\C-s\C-a" gnus-summary-sort-by-author
6929 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
6930 "\C-c\C-s\C-d" gnus-summary-sort-by-date
6931 "\C-c\C-s\C-i" gnus-summary-sort-by-score
6932 "=" gnus-summary-expand-window
6933 "\C-x\C-s" gnus-summary-reselect-current-group
6934 "\M-g" gnus-summary-rescan-group
6935 "w" gnus-summary-stop-page-breaking
6936 "\C-c\C-r" gnus-summary-caesar-message
6937 "\M-t" gnus-summary-toggle-mime
6938 "f" gnus-summary-followup
6939 "F" gnus-summary-followup-with-original
6940 "C" gnus-summary-cancel-article
6941 "r" gnus-summary-reply
6942 "R" gnus-summary-reply-with-original
6943 "\C-c\C-f" gnus-summary-mail-forward
6944 "o" gnus-summary-save-article
6945 "\C-o" gnus-summary-save-article-mail
6946 "|" gnus-summary-pipe-output
6947 "\M-k" gnus-summary-edit-local-kill
6948 "\M-K" gnus-summary-edit-global-kill
6950 "\C-c\C-d" gnus-summary-describe-group
6951 "q" gnus-summary-exit
6952 "Q" gnus-summary-exit-no-update
6953 "\C-c\C-i" gnus-info-find-node
6954 gnus-mouse-2 gnus-mouse-pick-article
6955 "m" gnus-summary-mail-other-window
6956 "a" gnus-summary-post-news
6957 "x" gnus-summary-limit-to-unread
6958 "s" gnus-summary-isearch-article
6959 "t" gnus-article-hide-headers
6960 "g" gnus-summary-show-article
6961 "l" gnus-summary-goto-last-article
6962 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
6963 "\C-d" gnus-summary-enter-digest-group
6965 "*" gnus-cache-enter-article
6966 "\M-*" gnus-cache-remove-article
6967 "\M-&" gnus-summary-universal-argument
6968 "\C-l" gnus-recenter
6969 "I" gnus-summary-increase-score
6970 "L" gnus-summary-lower-score
6972 "V" gnus-summary-score-map
6973 "X" gnus-uu-extract-map
6974 "S" gnus-summary-send-map)
6976 ;; Sort of orthogonal keymap
6977 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
6978 "t" gnus-summary-tick-article-forward
6979 "!" gnus-summary-tick-article-forward
6980 "d" gnus-summary-mark-as-read-forward
6981 "r" gnus-summary-mark-as-read-forward
6982 "c" gnus-summary-clear-mark-forward
6983 " " gnus-summary-clear-mark-forward
6984 "e" gnus-summary-mark-as-expirable
6985 "x" gnus-summary-mark-as-expirable
6986 "?" gnus-summary-mark-as-dormant
6987 "b" gnus-summary-set-bookmark
6988 "B" gnus-summary-remove-bookmark
6989 "#" gnus-summary-mark-as-processable
6990 "\M-#" gnus-summary-unmark-as-processable
6991 "S" gnus-summary-limit-include-expunged
6992 "C" gnus-summary-catchup
6993 "H" gnus-summary-catchup-to-here
6994 "\C-c" gnus-summary-catchup-all
6995 "k" gnus-summary-kill-same-subject-and-select
6996 "K" gnus-summary-kill-same-subject
6997 "P" gnus-uu-mark-map)
6999 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mode-map)
7000 "c" gnus-summary-clear-above
7001 "u" gnus-summary-tick-above
7002 "m" gnus-summary-mark-above
7003 "k" gnus-summary-kill-below)
7005 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
7006 "/" gnus-summary-limit-to-subject
7007 "n" gnus-summary-limit-to-articles
7008 "w" gnus-summary-pop-limit
7009 "s" gnus-summary-limit-to-subject
7010 "a" gnus-summary-limit-to-author
7011 "u" gnus-summary-limit-to-unread
7012 "m" gnus-summary-limit-to-marks
7013 "v" gnus-summary-limit-to-score
7014 "D" gnus-summary-limit-include-dormant
7015 "d" gnus-summary-limit-exclude-dormant
7016 ;; "t" gnus-summary-limit-exclude-thread
7017 "E" gnus-summary-limit-include-expunged
7018 "c" gnus-summary-limit-exclude-childless-dormant
7019 "C" gnus-summary-limit-mark-excluded-as-read)
7021 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
7022 "n" gnus-summary-next-unread-article
7023 "p" gnus-summary-prev-unread-article
7024 "N" gnus-summary-next-article
7025 "P" gnus-summary-prev-article
7026 "\C-n" gnus-summary-next-same-subject
7027 "\C-p" gnus-summary-prev-same-subject
7028 "\M-n" gnus-summary-next-unread-subject
7029 "\M-p" gnus-summary-prev-unread-subject
7030 "f" gnus-summary-first-unread-article
7031 "b" gnus-summary-best-unread-article
7032 "j" gnus-summary-goto-article
7033 "g" gnus-summary-goto-subject
7034 "l" gnus-summary-goto-last-article
7035 "p" gnus-summary-pop-article)
7037 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
7038 "k" gnus-summary-kill-thread
7039 "l" gnus-summary-lower-thread
7040 "i" gnus-summary-raise-thread
7041 "T" gnus-summary-toggle-threads
7042 "t" gnus-summary-rethread-current
7043 "^" gnus-summary-reparent-thread
7044 "s" gnus-summary-show-thread
7045 "S" gnus-summary-show-all-threads
7046 "h" gnus-summary-hide-thread
7047 "H" gnus-summary-hide-all-threads
7048 "n" gnus-summary-next-thread
7049 "p" gnus-summary-prev-thread
7050 "u" gnus-summary-up-thread
7051 "o" gnus-summary-top-thread
7052 "d" gnus-summary-down-thread
7053 "#" gnus-uu-mark-thread
7054 "\M-#" gnus-uu-unmark-thread)
7056 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
7057 "c" gnus-summary-catchup-and-exit
7058 "C" gnus-summary-catchup-all-and-exit
7059 "E" gnus-summary-exit-no-update
7060 "Q" gnus-summary-exit
7061 "Z" gnus-summary-exit
7062 "n" gnus-summary-catchup-and-goto-next-group
7063 "R" gnus-summary-reselect-current-group
7064 "G" gnus-summary-rescan-group
7065 "N" gnus-summary-next-group
7066 "P" gnus-summary-prev-group)
7068 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
7069 " " gnus-summary-next-page
7070 "n" gnus-summary-next-page
7071 "\177" gnus-summary-prev-page
7072 [delete] gnus-summary-prev-page
7073 "p" gnus-summary-prev-page
7074 "\r" gnus-summary-scroll-up
7075 "<" gnus-summary-beginning-of-article
7076 ">" gnus-summary-end-of-article
7077 "b" gnus-summary-beginning-of-article
7078 "e" gnus-summary-end-of-article
7079 "^" gnus-summary-refer-parent-article
7080 "r" gnus-summary-refer-parent-article
7081 "R" gnus-summary-refer-references
7082 "g" gnus-summary-show-article
7083 "s" gnus-summary-isearch-article)
7085 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
7086 "b" gnus-article-add-buttons
7087 "B" gnus-article-add-buttons-to-head
7088 "o" gnus-article-treat-overstrike
7089 ;; "w" gnus-article-word-wrap
7090 "w" gnus-article-fill-cited-article
7091 "c" gnus-article-remove-cr
7092 "L" gnus-article-remove-trailing-blank-lines
7093 "q" gnus-article-de-quoted-unreadable
7094 "f" gnus-article-display-x-face
7095 "l" gnus-summary-stop-page-breaking
7096 "r" gnus-summary-caesar-message
7097 "t" gnus-article-hide-headers
7098 "v" gnus-summary-verbose-headers
7099 "m" gnus-summary-toggle-mime)
7101 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
7102 "a" gnus-article-hide
7103 "h" gnus-article-hide-headers
7104 "b" gnus-article-hide-boring-headers
7105 "s" gnus-article-hide-signature
7106 "c" gnus-article-hide-citation
7107 "p" gnus-article-hide-pgp
7108 "\C-c" gnus-article-hide-citation-maybe)
7110 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
7111 "a" gnus-article-highlight
7112 "h" gnus-article-highlight-headers
7113 "c" gnus-article-highlight-citation
7114 "s" gnus-article-highlight-signature)
7116 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
7117 "z" gnus-article-date-ut
7118 "u" gnus-article-date-ut
7119 "l" gnus-article-date-local
7120 "e" gnus-article-date-lapsed
7121 "o" gnus-article-date-original)
7123 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
7125 "f" gnus-summary-fetch-faq
7126 "d" gnus-summary-describe-group
7127 "h" gnus-summary-describe-briefly
7128 "i" gnus-info-find-node)
7130 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
7131 "e" gnus-summary-expire-articles
7132 "\M-\C-e" gnus-summary-expire-articles-now
7133 "\177" gnus-summary-delete-article
7134 [delete] gnus-summary-delete-article
7135 "m" gnus-summary-move-article
7136 "r" gnus-summary-respool-article
7137 "w" gnus-summary-edit-article
7138 "c" gnus-summary-copy-article
7139 "B" gnus-summary-crosspost-article
7140 "q" gnus-summary-respool-query
7141 "i" gnus-summary-import-article)
7143 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
7144 "o" gnus-summary-save-article
7145 "m" gnus-summary-save-article-mail
7146 "r" gnus-summary-save-article-rmail
7147 "f" gnus-summary-save-article-file
7148 "b" gnus-summary-save-article-body-file
7149 "h" gnus-summary-save-article-folder
7150 "v" gnus-summary-save-article-vm
7151 "p" gnus-summary-pipe-output
7152 "s" gnus-soup-add-article)
7157 (defun gnus-summary-mode (&optional group)
7158 "Major mode for reading articles.
7160 All normal editing commands are switched off.
7161 \\<gnus-summary-mode-map>
7162 Each line in this buffer represents one article. To read an
7163 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
7164 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
7167 You can also post articles and send mail from this buffer. To
7168 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
7169 of an article, type `\\[gnus-summary-reply]'.
7171 There are approx. one gazillion commands you can execute in this
7172 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
7174 The following commands are available:
7176 \\{gnus-summary-mode-map}"
7178 (when (and menu-bar-mode
7179 (gnus-visual-p 'summary-menu 'menu))
7180 (gnus-summary-make-menu-bar))
7181 (kill-all-local-variables)
7182 (gnus-summary-make-local-variables)
7183 (gnus-make-thread-indent-array)
7184 (gnus-simplify-mode-line)
7185 (setq major-mode 'gnus-summary-mode)
7186 (setq mode-name "Summary")
7187 (make-local-variable 'minor-mode-alist)
7188 (use-local-map gnus-summary-mode-map)
7189 (buffer-disable-undo (current-buffer))
7190 (setq buffer-read-only t) ;Disable modification
7191 (setq truncate-lines t)
7192 (setq selective-display t)
7193 (setq selective-display-ellipses t) ;Display `...'
7194 (setq buffer-display-table gnus-summary-display-table)
7195 (setq gnus-newsgroup-name group)
7196 (make-local-variable 'gnus-summary-line-format)
7197 (make-local-variable 'gnus-summary-line-format-spec)
7198 (make-local-variable 'gnus-summary-mark-positions)
7199 (run-hooks 'gnus-summary-mode-hook))
7201 (defun gnus-summary-make-local-variables ()
7202 "Make all the local summary buffer variables."
7203 (let ((locals gnus-summary-local-variables)
7205 (while (setq local (pop locals))
7208 (if (eq (cdr local) 'global)
7209 ;; Copy the global value of the variable.
7210 (setq global (symbol-value (car local)))
7211 ;; Use the value from the list.
7212 (setq global (eval (cdr local))))
7213 (make-local-variable (car local))
7214 (set (car local) global))
7215 ;; Simple nil-valued local variable.
7216 (make-local-variable local)
7219 (defun gnus-summary-make-display-table ()
7220 ;; Change the display table. Odd characters have a tendency to mess
7221 ;; up nicely formatted displays - we make all possible glyphs
7222 ;; display only a single character.
7224 ;; We start from the standard display table, if any.
7225 (setq gnus-summary-display-table
7226 (or (copy-sequence standard-display-table)
7227 (make-display-table)))
7228 ;; Nix out all the control chars...
7230 (while (>= (setq i (1- i)) 0)
7231 (aset gnus-summary-display-table i [??])))
7232 ;; ... but not newline and cr, of course. (cr is necessary for the
7233 ;; selective display).
7234 (aset gnus-summary-display-table ?\n nil)
7235 (aset gnus-summary-display-table ?\r nil)
7236 ;; We nix out any glyphs over 126 that are not set already.
7238 (while (>= (setq i (1- i)) 127)
7239 ;; Only modify if the entry is nil.
7240 (or (aref gnus-summary-display-table i)
7241 (aset gnus-summary-display-table i [??])))))
7243 (defun gnus-summary-clear-local-variables ()
7244 (let ((locals gnus-summary-local-variables))
7246 (if (consp (car locals))
7247 (and (vectorp (caar locals))
7248 (set (caar locals) nil))
7249 (and (vectorp (car locals))
7250 (set (car locals) nil)))
7251 (setq locals (cdr locals)))))
7253 ;; Summary data functions.
7255 (defmacro gnus-data-number (data)
7258 (defmacro gnus-data-set-number (data number)
7259 `(setcar ,data ,number))
7261 (defmacro gnus-data-mark (data)
7264 (defmacro gnus-data-set-mark (data mark)
7265 `(setcar (nthcdr 1 ,data) ,mark))
7267 (defmacro gnus-data-pos (data)
7270 (defmacro gnus-data-set-pos (data pos)
7271 `(setcar (nthcdr 2 ,data) ,pos))
7273 (defmacro gnus-data-header (data)
7276 (defmacro gnus-data-level (data)
7279 (defmacro gnus-data-unread-p (data)
7280 `(= (nth 1 ,data) gnus-unread-mark))
7282 (defmacro gnus-data-pseudo-p (data)
7283 `(consp (nth 3 ,data)))
7285 (defmacro gnus-data-find (number)
7286 `(assq ,number gnus-newsgroup-data))
7288 (defmacro gnus-data-find-list (number &optional data)
7289 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
7290 (memq (assq ,number bdata)
7293 (defmacro gnus-data-make (number mark pos header level)
7294 `(list ,number ,mark ,pos ,header ,level))
7296 (defun gnus-data-enter (after-article number mark pos header level offset)
7297 (let ((data (gnus-data-find-list after-article)))
7298 (or data (error "No such article: %d" after-article))
7299 (setcdr data (cons (gnus-data-make number mark pos header level)
7301 (setq gnus-newsgroup-data-reverse nil)
7302 (gnus-data-update-list (cddr data) offset)))
7304 (defun gnus-data-enter-list (after-article list &optional offset)
7306 (let ((data (and after-article (gnus-data-find-list after-article)))
7308 (or data (not after-article) (error "No such article: %d" after-article))
7309 ;; Find the last element in the list to be spliced into the main
7312 (setq list (cdr list)))
7315 (setcdr list gnus-newsgroup-data)
7316 (setq gnus-newsgroup-data ilist)
7317 (and offset (gnus-data-update-list (cdr list) offset)))
7318 (setcdr list (cdr data))
7320 (and offset (gnus-data-update-list (cdr data) offset)))
7321 (setq gnus-newsgroup-data-reverse nil))))
7323 (defun gnus-data-remove (article &optional offset)
7324 (let ((data gnus-newsgroup-data))
7325 (if (= (gnus-data-number (car data)) article)
7326 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
7327 gnus-newsgroup-data-reverse nil)
7329 (and (= (gnus-data-number (cadr data)) article)
7331 (setcdr data (cddr data))
7332 (and offset (gnus-data-update-list (cdr data) offset))
7334 gnus-newsgroup-data-reverse nil)))
7335 (setq data (cdr data))))))
7337 (defmacro gnus-data-list (backward)
7339 (or gnus-newsgroup-data-reverse
7340 (setq gnus-newsgroup-data-reverse
7341 (reverse gnus-newsgroup-data)))
7342 gnus-newsgroup-data))
7344 (defun gnus-data-update-list (data offset)
7345 "Add OFFSET to the POS of all data entries in DATA."
7347 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
7348 (setq data (cdr data))))
7350 (defun gnus-data-compute-positions ()
7351 "Compute the positions of all articles."
7352 (let ((data gnus-newsgroup-data)
7355 (when (setq pos (text-property-any
7356 (point-min) (point-max)
7357 'gnus-number (gnus-data-number (car data))))
7358 (gnus-data-set-pos (car data) (+ pos 3)))
7359 (setq data (cdr data)))))
7361 (defun gnus-summary-article-pseudo-p (article)
7362 "Say whether this article is a pseudo article or not."
7363 (not (vectorp (gnus-data-header (gnus-data-find article)))))
7365 (defun gnus-article-parent-p (number)
7366 "Say whether this article is a parent or not."
7367 (let ((data (gnus-data-find-list number)))
7368 (and (cdr data) ; There has to be an article after...
7369 (< (gnus-data-level (car data)) ; And it has to have a higher level.
7370 (gnus-data-level (nth 1 data))))))
7372 (defun gnus-article-children (number)
7373 "Return a list of all children to NUMBER."
7374 (let* ((data (gnus-data-find-list number))
7375 (level (gnus-data-level (car data)))
7377 (setq data (cdr data))
7379 (= (gnus-data-level (car data)) (1+ level)))
7380 (push (gnus-data-number (car data)) children)
7381 (setq data (cdr data)))
7384 (defmacro gnus-summary-skip-intangible ()
7385 "If the current article is intangible, then jump to a different article."
7386 '(let ((to (get-text-property (point) 'gnus-intangible)))
7387 (and to (gnus-summary-goto-subject to))))
7389 (defmacro gnus-summary-article-intangible-p ()
7390 "Say whether this article is intangible or not."
7391 '(get-text-property (point) 'gnus-intangible))
7393 ;; Some summary mode macros.
7395 (defmacro gnus-summary-article-number ()
7396 "The article number of the article on the current line.
7397 If there isn's an article number here, then we return the current
7400 (gnus-summary-skip-intangible)
7401 (or (get-text-property (point) 'gnus-number)
7402 (gnus-summary-last-subject))))
7404 (defmacro gnus-summary-article-header (&optional number)
7405 `(gnus-data-header (gnus-data-find
7406 ,(or number '(gnus-summary-article-number)))))
7408 (defmacro gnus-summary-thread-level (&optional number)
7409 `(if (and (eq gnus-summary-make-false-root 'dummy)
7410 (get-text-property (point) 'gnus-intangible))
7412 (gnus-data-level (gnus-data-find
7413 ,(or number '(gnus-summary-article-number))))))
7415 (defmacro gnus-summary-article-mark (&optional number)
7416 `(gnus-data-mark (gnus-data-find
7417 ,(or number '(gnus-summary-article-number)))))
7419 (defmacro gnus-summary-article-pos (&optional number)
7420 `(gnus-data-pos (gnus-data-find
7421 ,(or number '(gnus-summary-article-number)))))
7423 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
7424 (defmacro gnus-summary-article-subject (&optional number)
7425 "Return current subject string or nil if nothing."
7428 `(gnus-data-header (assq ,number gnus-newsgroup-data))
7429 '(gnus-data-header (assq (gnus-summary-article-number)
7430 gnus-newsgroup-data)))))
7433 (mail-header-subject headers))))
7435 (defmacro gnus-summary-article-score (&optional number)
7436 "Return current article score."
7437 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
7438 gnus-newsgroup-scored))
7439 gnus-summary-default-score 0))
7441 (defun gnus-summary-article-children (&optional number)
7442 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
7443 (level (gnus-data-level (car data)))
7445 (while (and (setq data (cdr data))
7446 (> (setq l (gnus-data-level (car data))) level))
7447 (and (= (1+ level) l)
7448 (setq children (cons (gnus-data-number (car data))
7450 (nreverse children)))
7452 (defun gnus-summary-article-parent (&optional number)
7453 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
7454 (gnus-data-list t)))
7455 (level (gnus-data-level (car data))))
7457 () ; This is a root.
7458 ;; We search until we find an article with a level less than
7459 ;; this one. That function has to be the parent.
7460 (while (and (setq data (cdr data))
7461 (not (< (gnus-data-level (car data)) level))))
7462 (and data (gnus-data-number (car data))))))
7464 (defun gnus-unread-mark-p (mark)
7465 "Say whether MARK is the unread mark."
7466 (= mark gnus-unread-mark))
7468 (defun gnus-read-mark-p (mark)
7469 "Say whether MARK is one of the marks that mark as read.
7470 This is all marks except unread, ticked, dormant, and expirable."
7471 (not (or (= mark gnus-unread-mark)
7472 (= mark gnus-ticked-mark)
7473 (= mark gnus-dormant-mark)
7474 (= mark gnus-expirable-mark))))
7476 ;; Saving hidden threads.
7478 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
7479 (put 'gnus-save-hidden-threads 'lisp-indent-hook 0)
7480 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
7482 (defmacro gnus-save-hidden-threads (&rest forms)
7483 "Save hidden threads, eval FORMS, and restore the hidden threads."
7484 (let ((config (make-symbol "config")))
7485 `(let ((,config (gnus-hidden-threads-configuration)))
7489 (gnus-restore-hidden-threads-configuration ,config)))))
7491 (defun gnus-hidden-threads-configuration ()
7492 "Return the current hidden threads configuration."
7495 (goto-char (point-min))
7496 (while (search-forward "\r" nil t)
7497 (push (1- (point)) config))
7500 (defun gnus-restore-hidden-threads-configuration (config)
7501 "Restore hidden threads configuration from CONFIG."
7502 (let (point buffer-read-only)
7503 (while (setq point (pop config))
7504 (when (and (< point (point-max))
7506 (= (following-char) ?\n))
7507 (subst-char-in-region point (1+ point) ?\n ?\r)))))
7509 ;; Various summary mode internalish functions.
7511 (defun gnus-mouse-pick-article (e)
7514 (gnus-summary-next-page nil t))
7516 (defun gnus-summary-setup-buffer (group)
7517 "Initialize summary buffer."
7518 (let ((buffer (concat "*Summary " group "*")))
7519 (if (get-buffer buffer)
7522 (setq gnus-summary-buffer (current-buffer))
7523 (not gnus-newsgroup-prepared))
7524 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
7525 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
7526 (gnus-add-current-to-buffer-list)
7527 (gnus-summary-mode group)
7529 (gnus-carpal-setup-buffer 'summary))
7530 (unless gnus-single-article-buffer
7531 (make-local-variable 'gnus-article-buffer)
7532 (make-local-variable 'gnus-article-current)
7533 (make-local-variable 'gnus-original-article-buffer))
7534 (setq gnus-newsgroup-name group)
7537 (defun gnus-set-global-variables ()
7538 ;; Set the global equivalents of the summary buffer-local variables
7539 ;; to the latest values they had. These reflect the summary buffer
7540 ;; that was in action when the last article was fetched.
7541 (when (eq major-mode 'gnus-summary-mode)
7542 (setq gnus-summary-buffer (current-buffer))
7543 (let ((name gnus-newsgroup-name)
7544 (marked gnus-newsgroup-marked)
7545 (unread gnus-newsgroup-unreads)
7546 (headers gnus-current-headers)
7547 (data gnus-newsgroup-data)
7548 (summary gnus-summary-buffer)
7549 (article-buffer gnus-article-buffer)
7550 (original gnus-original-article-buffer)
7551 (gac gnus-article-current)
7552 (score-file gnus-current-score-file))
7554 (set-buffer gnus-group-buffer)
7555 (setq gnus-newsgroup-name name)
7556 (setq gnus-newsgroup-marked marked)
7557 (setq gnus-newsgroup-unreads unread)
7558 (setq gnus-current-headers headers)
7559 (setq gnus-newsgroup-data data)
7560 (setq gnus-article-current gac)
7561 (setq gnus-summary-buffer summary)
7562 (setq gnus-article-buffer article-buffer)
7563 (setq gnus-original-article-buffer original)
7564 (setq gnus-current-score-file score-file)))))
7566 (defun gnus-summary-last-article-p (&optional article)
7567 "Return whether ARTICLE is the last article in the buffer."
7568 (if (not (setq article (or article (gnus-summary-article-number))))
7569 t ; All non-existant numbers are the last article. :-)
7570 (not (cdr (gnus-data-find-list article)))))
7572 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
7573 "Insert a dummy root in the summary buffer."
7575 (gnus-add-text-properties
7576 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
7577 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
7579 (defun gnus-make-thread-indent-array ()
7581 (unless (and gnus-thread-indent-array
7582 (= gnus-thread-indent-level gnus-thread-indent-array-level))
7583 (setq gnus-thread-indent-array (make-vector 201 "")
7584 gnus-thread-indent-array-level gnus-thread-indent-level)
7586 (aset gnus-thread-indent-array n
7587 (make-string (* n gnus-thread-indent-level) ? ))
7590 (defun gnus-summary-insert-line
7591 (gnus-tmp-header gnus-tmp-level gnus-tmp-current gnus-tmp-unread
7592 gnus-tmp-replied gnus-tmp-expirable gnus-tmp-subject-or-nil
7593 &optional gnus-tmp-dummy gnus-tmp-score gnus-tmp-process)
7594 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
7595 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
7596 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
7597 (gnus-tmp-score-char
7598 (if (or (null gnus-summary-default-score)
7599 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
7600 gnus-summary-zcore-fuzz)) ?
7601 (if (< gnus-tmp-score gnus-summary-default-score)
7602 gnus-score-below-mark gnus-score-over-mark)))
7603 (gnus-tmp-replied (cond (gnus-tmp-process gnus-process-mark)
7604 ((memq gnus-tmp-current gnus-newsgroup-cached)
7606 (gnus-tmp-replied gnus-replied-mark)
7607 ((memq gnus-tmp-current gnus-newsgroup-saved)
7609 (t gnus-unread-mark)))
7610 (gnus-tmp-from (mail-header-from gnus-tmp-header))
7613 ((string-match "(.+)" gnus-tmp-from)
7614 (substring gnus-tmp-from
7615 (1+ (match-beginning 0)) (1- (match-end 0))))
7616 ((string-match "<[^>]+> *$" gnus-tmp-from)
7617 (let ((beg (match-beginning 0)))
7618 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
7619 (substring gnus-tmp-from (1+ (match-beginning 0))
7620 (1- (match-end 0))))
7621 (substring gnus-tmp-from 0 beg))))
7623 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
7624 (gnus-tmp-number (mail-header-number gnus-tmp-header))
7625 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
7626 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
7627 (buffer-read-only nil))
7628 (when (string= gnus-tmp-name "")
7629 (setq gnus-tmp-name gnus-tmp-from))
7630 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
7631 (gnus-put-text-property
7633 (progn (eval gnus-summary-line-format-spec) (point))
7634 'gnus-number gnus-tmp-number)
7635 (when (gnus-visual-p 'summary-highlight 'highlight)
7637 (run-hooks 'gnus-summary-update-hook)
7640 (defun gnus-summary-update-line (&optional dont-update)
7641 ;; Update summary line after change.
7642 (when (and gnus-summary-default-score
7643 (not gnus-summary-inhibit-highlight))
7644 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
7645 (article (gnus-summary-article-number))
7646 (score (gnus-summary-article-score article)))
7648 (if (and gnus-summary-mark-below
7649 (< (gnus-summary-article-score)
7650 gnus-summary-mark-below))
7651 ;; This article has a low score, so we mark it as read.
7652 (when (memq article gnus-newsgroup-unreads)
7653 (gnus-summary-mark-article-as-read gnus-low-score-mark))
7654 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
7655 ;; This article was previously marked as read on account
7656 ;; of a low score, but now it has risen, so we mark it as
7658 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
7659 (gnus-summary-update-mark
7660 (if (or (null gnus-summary-default-score)
7661 (<= (abs (- score gnus-summary-default-score))
7662 gnus-summary-zcore-fuzz)) ?
7663 (if (< score gnus-summary-default-score)
7664 gnus-score-below-mark gnus-score-over-mark)) 'score))
7665 ;; Do visual highlighting.
7666 (when (gnus-visual-p 'summary-highlight 'highlight)
7667 (run-hooks 'gnus-summary-update-hook)))))
7669 (defvar gnus-tmp-new-adopts nil)
7671 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
7672 ;; Sum up all elements (and sub-elements) in a list.
7674 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
7676 ((and (consp thread) (cdr thread))
7679 'gnus-summary-number-of-articles-in-thread (cdr thread))))
7682 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
7685 (when (and level (zerop level) gnus-tmp-new-adopts)
7688 'gnus-summary-number-of-articles-in-thread
7689 gnus-tmp-new-adopts))))
7691 (if (> number 1) gnus-not-empty-thread-mark
7692 gnus-empty-thread-mark)
7695 (defun gnus-summary-set-local-parameters (group)
7696 "Go through the local params of GROUP and set all variable specs in that list."
7697 (let ((params (gnus-info-params (gnus-get-info group)))
7700 (setq elem (car params)
7701 params (cdr params))
7702 (and (consp elem) ; Has to be a cons.
7703 (consp (cdr elem)) ; The cdr has to be a list.
7704 (symbolp (car elem)) ; Has to be a symbol in there.
7705 (not (memq (car elem)
7706 '(quit-config to-address to-list to-group)))
7707 (progn ; So we set it.
7708 (make-local-variable (car elem))
7709 (set (car elem) (eval (nth 1 elem))))))))
7711 (defun gnus-summary-read-group (group &optional show-all no-article
7712 kill-buffer no-display)
7713 "Start reading news in newsgroup GROUP.
7714 If SHOW-ALL is non-nil, already read articles are also listed.
7715 If NO-ARTICLE is non-nil, no article is selected initially.
7716 If NO-DISPLAY, don't generate a summary buffer."
7717 (gnus-message 5 "Retrieving newsgroup: %s..." group)
7718 (let* ((new-group (gnus-summary-setup-buffer group))
7719 (quit-config (gnus-group-quit-config group))
7720 (did-select (and new-group (gnus-select-newsgroup group show-all))))
7722 ;; This summary buffer exists already, so we just select it.
7724 (gnus-set-global-variables)
7726 (gnus-kill-or-deaden-summary kill-buffer))
7727 (gnus-configure-windows 'summary 'force)
7728 (gnus-set-mode-line 'summary)
7729 (gnus-summary-position-point)
7732 ;; We couldn't select this group.
7734 (when (and (eq major-mode 'gnus-summary-mode)
7735 (not (equal (current-buffer) kill-buffer)))
7736 (kill-buffer (current-buffer))
7737 (if (not quit-config)
7739 (set-buffer gnus-group-buffer)
7740 (gnus-group-jump-to-group group)
7741 (gnus-group-next-unread-group 1))
7742 (if (not (buffer-name (car quit-config)))
7743 (gnus-configure-windows 'group 'force)
7744 (set-buffer (car quit-config))
7745 (and (eq major-mode 'gnus-summary-mode)
7746 (gnus-set-global-variables))
7747 (gnus-configure-windows (cdr quit-config)))))
7748 (gnus-message 3 "Can't select group")
7750 ;; The user did a `C-g' while prompting for number of articles,
7751 ;; so we exit this group.
7752 ((eq did-select 'quit)
7753 (and (eq major-mode 'gnus-summary-mode)
7754 (not (equal (current-buffer) kill-buffer))
7755 (kill-buffer (current-buffer)))
7757 (gnus-kill-or-deaden-summary kill-buffer))
7758 (if (not quit-config)
7760 (set-buffer gnus-group-buffer)
7761 (gnus-group-jump-to-group group)
7762 (gnus-group-next-unread-group 1)
7763 (gnus-configure-windows 'group 'force))
7764 (if (not (buffer-name (car quit-config)))
7765 (gnus-configure-windows 'group 'force)
7766 (set-buffer (car quit-config))
7767 (and (eq major-mode 'gnus-summary-mode)
7768 (gnus-set-global-variables))
7769 (gnus-configure-windows (cdr quit-config))))
7770 ;; Finally signal the quit.
7772 ;; The group was successfully selected.
7774 (gnus-set-global-variables)
7775 ;; Save the active value in effect when the group was entered.
7776 (setq gnus-newsgroup-active
7778 (gnus-active gnus-newsgroup-name)))
7779 ;; You can change the summary buffer in some way with this hook.
7780 (run-hooks 'gnus-select-group-hook)
7781 ;; Set any local variables in the group parameters.
7782 (gnus-summary-set-local-parameters gnus-newsgroup-name)
7783 (gnus-update-format-specifications)
7784 ;; Do score processing.
7785 (when gnus-use-scoring
7786 (gnus-possibly-score-headers))
7787 ;; Check whether to fill in the gaps in the threads.
7788 (when gnus-build-sparse-threads
7789 (gnus-build-sparse-threads))
7790 ;; Find the initial limit.
7791 (if gnus-show-threads
7793 (let ((gnus-newsgroup-dormant nil))
7794 (gnus-summary-initial-limit show-all))
7795 (gnus-summary-initial-limit show-all))
7796 (setq gnus-newsgroup-limit
7798 (lambda (header) (mail-header-number header))
7799 gnus-newsgroup-headers)))
7800 ;; Generate the summary buffer.
7802 (gnus-summary-prepare))
7803 (when gnus-use-trees
7804 (gnus-tree-open group)
7805 (setq gnus-summary-highlight-line-function
7806 'gnus-tree-highlight-article))
7807 ;; If the summary buffer is empty, but there are some low-scored
7808 ;; articles or some excluded dormants, we include these in the
7810 (when (and (zerop (buffer-size))
7812 (cond (gnus-newsgroup-dormant
7813 (gnus-summary-limit-include-dormant))
7814 ((and gnus-newsgroup-scored show-all)
7815 (gnus-summary-limit-include-expunged))))
7816 ;; Function `gnus-apply-kill-file' must be called in this hook.
7817 (run-hooks 'gnus-apply-kill-hook)
7818 (if (and (zerop (buffer-size))
7821 ;; This newsgroup is empty.
7822 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
7823 (gnus-message 6 "No unread news")
7825 (gnus-kill-or-deaden-summary kill-buffer))
7826 ;; Return nil from this function.
7828 ;; Hide conversation thread subtrees. We cannot do this in
7829 ;; gnus-summary-prepare-hook since kill processing may not
7830 ;; work with hidden articles.
7831 (and gnus-show-threads
7832 gnus-thread-hide-subtree
7833 (gnus-summary-hide-all-threads))
7834 ;; Show first unread article if requested.
7835 (if (and (not no-article)
7837 gnus-newsgroup-unreads
7838 gnus-auto-select-first)
7839 (unless (if (eq gnus-auto-select-first 'best)
7840 (gnus-summary-best-unread-article)
7841 (gnus-summary-first-unread-article))
7842 (gnus-configure-windows 'summary))
7843 ;; Don't select any articles, just move point to the first
7844 ;; article in the group.
7845 (goto-char (point-min))
7846 (gnus-summary-position-point)
7847 (gnus-set-mode-line 'summary)
7848 (gnus-configure-windows 'summary 'force))
7849 ;; If we are in async mode, we send some info to the backend.
7850 (when gnus-newsgroup-async
7851 (gnus-request-asynchronous gnus-newsgroup-name gnus-newsgroup-data))
7853 (gnus-kill-or-deaden-summary kill-buffer))
7854 (when (get-buffer-window gnus-group-buffer t)
7855 ;; Gotta use windows, because recenter does wierd stuff if
7856 ;; the current buffer ain't the displayed window.
7857 (let ((owin (selected-window)))
7858 (select-window (get-buffer-window gnus-group-buffer t))
7859 (when (gnus-group-goto-group group)
7861 (select-window owin))))
7862 ;; Mark this buffer as "prepared".
7863 (setq gnus-newsgroup-prepared t)
7866 (defun gnus-summary-prepare ()
7867 "Generate the summary buffer."
7868 (let ((buffer-read-only nil))
7870 (setq gnus-newsgroup-data nil
7871 gnus-newsgroup-data-reverse nil)
7872 (run-hooks 'gnus-summary-generate-hook)
7873 ;; Generate the buffer, either with threads or without.
7874 (when gnus-newsgroup-headers
7875 (gnus-summary-prepare-threads
7876 (if gnus-show-threads
7877 (gnus-sort-gathered-threads
7878 (funcall gnus-summary-thread-gathering-function
7880 (gnus-cut-threads (gnus-make-threads)))))
7881 ;; Unthreaded display.
7882 (gnus-sort-articles gnus-newsgroup-headers))))
7883 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
7884 ;; Call hooks for modifying summary buffer.
7885 (goto-char (point-min))
7886 (run-hooks 'gnus-summary-prepare-hook)))
7888 (defun gnus-gather-threads-by-subject (threads)
7889 "Gather threads by looking at Subject headers."
7890 (if (not gnus-summary-make-false-root)
7892 (let ((hashtb (gnus-make-hashtable 1023))
7895 subject hthread whole-subject)
7897 (setq whole-subject (mail-header-subject (caar threads)))
7900 ;; Truncate the subject.
7901 ((numberp gnus-summary-gather-subject-limit)
7902 (setq subject (gnus-simplify-subject-re whole-subject))
7903 (if (> (length subject) gnus-summary-gather-subject-limit)
7904 (substring subject 0 gnus-summary-gather-subject-limit)
7906 ;; Fuzzily simplify it.
7907 ((eq 'fuzzy gnus-summary-gather-subject-limit)
7908 (gnus-simplify-subject-fuzzy whole-subject))
7909 ;; Just remove the leading "Re:".
7911 (gnus-simplify-subject-re whole-subject))))
7913 (if (and gnus-summary-gather-exclude-subject
7914 (string-match gnus-summary-gather-exclude-subject
7916 () ; We don't want to do anything with this article.
7917 ;; We simplify the subject before looking it up in the
7920 (if (setq hthread (gnus-gethash subject hashtb))
7922 ;; We enter a dummy root into the thread, if we
7923 ;; haven't done that already.
7924 (unless (stringp (caar hthread))
7925 (setcar hthread (list whole-subject (car hthread))))
7926 ;; We add this new gathered thread to this gathered
7928 (setcdr (car hthread)
7929 (nconc (cdar hthread) (list (car threads))))
7930 ;; Remove it from the list of threads.
7931 (setcdr prev (cdr threads))
7932 (setq threads prev))
7933 ;; Enter this thread into the hash table.
7934 (gnus-sethash subject threads hashtb)))
7936 (setq threads (cdr threads)))
7939 (defun gnus-gather-threads-by-references (threads)
7940 "Gather threads by looking at References headers."
7941 (let ((idhashtb (gnus-make-hashtable 1023))
7942 (thhashtb (gnus-make-hashtable 1023))
7945 ids references id gthread gid entered)
7947 (when (setq references (mail-header-references (caar threads)))
7948 (setq id (mail-header-id (caar threads)))
7949 (setq ids (gnus-split-references references))
7952 (if (not (setq gid (gnus-gethash (car ids) idhashtb)))
7954 (gnus-sethash (car ids) id idhashtb)
7955 (gnus-sethash id threads thhashtb))
7956 (setq gthread (gnus-gethash gid thhashtb))
7958 ;; We enter a dummy root into the thread, if we
7959 ;; haven't done that already.
7960 (unless (stringp (caar gthread))
7961 (setcar gthread (list (mail-header-subject (caar gthread))
7963 ;; We add this new gathered thread to this gathered
7965 (setcdr (car gthread)
7966 (nconc (cdar gthread) (list (car threads)))))
7967 ;; Add it into the thread hash table.
7968 (gnus-sethash id gthread thhashtb)
7970 ;; Remove it from the list of threads.
7971 (setcdr prev (cdr threads))
7972 (setq threads prev))
7973 (setq ids (cdr ids))))
7975 (setq threads (cdr threads)))
7978 (defun gnus-sort-gathered-threads (threads)
7979 "Sort subtreads inside each gathered thread by article number."
7980 (let ((result threads))
7982 (when (stringp (caar threads))
7983 (setcdr (car threads)
7984 (sort (cdar threads) 'gnus-thread-sort-by-number)))
7985 (setq threads (cdr threads)))
7988 (defun gnus-make-threads ()
7989 "Go through the dependency hashtb and find the roots. Return all threads."
7993 (unless (car (symbol-value refs))
7994 ;; These threads do not refer back to any other articles,
7995 ;; so they're roots.
7996 (setq threads (append (cdr (symbol-value refs)) threads))))
7997 gnus-newsgroup-dependencies)
8000 (defun gnus-build-sparse-threads ()
8001 (let ((headers gnus-newsgroup-headers)
8002 (deps gnus-newsgroup-dependencies)
8003 header references generation relations
8004 cthread subject child end pthread relation)
8005 ;; First we create an alist of generations/relations, where
8006 ;; generations is how much we trust the ralation, and the relation
8008 (gnus-message 7 "Making sparse threads...")
8010 (nnheader-set-temp-buffer " *gnus sparse threads*")
8011 (while (setq header (pop headers))
8012 (when (and (setq references (mail-header-references header))
8013 (not (string= references "")))
8015 (setq child (mail-header-id header)
8016 subject (mail-header-subject header))
8018 (while (search-backward ">" nil t)
8019 (setq end (1+ (point)))
8020 (when (search-backward "<" nil t)
8021 (push (list (incf generation)
8022 child (setq child (buffer-substring (point) end))
8025 (push (list (1+ generation) child nil subject) relations)
8027 (kill-buffer (current-buffer)))
8028 ;; Sort over trustworthiness.
8029 (setq relations (sort relations (lambda (r1 r2) (< (car r1) (car r2)))))
8030 (while (setq relation (pop relations))
8031 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
8032 (unless (car (symbol-value cthread))
8033 ;; Make this article the parent of these threads.
8034 (setcar (symbol-value cthread)
8035 (vector gnus-reffed-article-number
8039 (or (caddr relation) "") 0 0 "")))
8040 (set cthread (list (vector gnus-reffed-article-number
8042 "" "" (cadr relation)
8043 (or (caddr relation) "") 0 0 ""))))
8044 (push gnus-reffed-article-number gnus-newsgroup-limit)
8045 (push gnus-reffed-article-number gnus-newsgroup-sparse)
8046 (push (cons gnus-reffed-article-number gnus-sparse-mark)
8047 gnus-newsgroup-reads)
8048 (decf gnus-reffed-article-number)
8049 ;; Make this new thread the child of its parent.
8050 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
8051 (setcdr (symbol-value pthread)
8052 (nconc (cdr (symbol-value pthread))
8053 (list (symbol-value cthread))))
8054 (set pthread (list nil (symbol-value cthread))))))
8055 (gnus-message 7 "Making sparse threads...done")))
8057 (defun gnus-build-old-threads ()
8058 ;; Look at all the articles that refer back to old articles, and
8059 ;; fetch the headers for the articles that aren't there. This will
8060 ;; build complete threads - if the roots haven't been expired by the
8065 (when (not (car (symbol-value refs)))
8066 (setq heads (cdr (symbol-value refs)))
8068 (if (memq (mail-header-number (caar heads))
8069 gnus-newsgroup-dormant)
8070 (setq heads (cdr heads))
8071 (setq id (symbol-name refs))
8072 (while (and (setq id (gnus-build-get-header id))
8073 (not (car (gnus-gethash
8074 id gnus-newsgroup-dependencies)))))
8075 (setq heads nil)))))
8076 gnus-newsgroup-dependencies)))
8078 (defun gnus-build-get-header (id)
8079 ;; Look through the buffer of NOV lines and find the header to
8080 ;; ID. Enter this line into the dependencies hash table, and return
8081 ;; the id of the parent article (if any).
8082 (let ((deps gnus-newsgroup-dependencies)
8086 (set-buffer nntp-server-buffer)
8087 (goto-char (point-min))
8088 (while (and (not found) (search-forward id nil t))
8090 (setq found (looking-at
8091 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
8092 (regexp-quote id))))
8093 (or found (beginning-of-line 2)))
8097 (setq header (gnus-nov-parse-line
8098 (read (current-buffer)) deps))
8099 (gnus-parent-id (mail-header-references header)))))
8101 (let ((number (mail-header-number header)))
8102 (push number gnus-newsgroup-limit)
8103 (push header gnus-newsgroup-headers)
8104 (if (memq number gnus-newsgroup-unselected)
8106 (push number gnus-newsgroup-unreads)
8107 (setq gnus-newsgroup-unselected
8108 (delq number gnus-newsgroup-unselected)))
8109 (push number gnus-newsgroup-ancient)))))))
8111 (defun gnus-summary-update-article (article &optional iheader)
8112 "Update ARTICLE in the summary buffer."
8113 (set-buffer gnus-summary-buffer)
8114 (let* ((header (or iheader (gnus-summary-article-header article)))
8115 (id (mail-header-id header))
8116 (data (gnus-data-find article))
8117 (thread (gnus-id-to-thread id))
8118 (references (mail-header-references header))
8123 (not (equal "" references)))
8126 (buffer-read-only nil)
8128 (number (mail-header-number header))
8131 ;; !!! Should this be in or not?
8133 (setcar thread nil))
8135 (delq thread parent))
8136 (if (gnus-summary-insert-subject id header iheader)
8137 ;; Set the (possibly) new article number in the data structure.
8138 (gnus-data-set-number data (gnus-id-to-article id))
8142 (defun gnus-rebuild-thread (id)
8143 "Rebuild the thread containing ID."
8144 (let ((buffer-read-only nil)
8145 current thread data)
8146 (if (not gnus-show-threads)
8147 (setq thread (list (car (gnus-id-to-thread id))))
8148 ;; Get the thread this article is part of.
8149 (setq thread (gnus-remove-thread id)))
8150 (setq current (save-excursion
8151 (and (zerop (forward-line -1))
8152 (gnus-summary-article-number))))
8153 ;; If this is a gathered thread, we have to go some re-gathering.
8154 (when (stringp (car thread))
8155 (let ((subject (car thread))
8157 (setq thread (cdr thread))
8159 (unless (memq (setq thr (gnus-id-to-thread
8161 (mail-header-id (caar thread)))))
8164 (setq thread (cdr thread)))
8165 ;; We now have all (unique) roots.
8166 (if (= (length roots) 1)
8167 ;; All the loose roots are now one solid root.
8168 (setq thread (car roots))
8169 (setq thread (cons subject (gnus-sort-threads roots))))))
8171 ;; We then insert this thread into the summary buffer.
8172 (let (gnus-newsgroup-data gnus-newsgroup-threads)
8173 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
8174 (setq data (nreverse gnus-newsgroup-data))
8175 (setq threads gnus-newsgroup-threads))
8176 ;; We splice the new data into the data structure.
8177 (gnus-data-enter-list current data)
8178 (gnus-data-compute-positions)
8179 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
8181 (defun gnus-number-to-header (number)
8182 "Return the header for article NUMBER."
8183 (let ((headers gnus-newsgroup-headers))
8185 (not (= number (mail-header-number (car headers)))))
8190 (defun gnus-id-to-thread (id)
8191 "Return the (sub-)thread where ID appears."
8192 (gnus-gethash id gnus-newsgroup-dependencies))
8194 (defun gnus-id-to-article (id)
8195 "Return the article number of ID."
8196 (let ((thread (gnus-id-to-thread id)))
8199 (mail-header-number (car thread)))))
8201 (defun gnus-id-to-header (id)
8202 "Return the article headers of ID."
8203 (car (gnus-id-to-thread id)))
8205 (defun gnus-article-displayed-root-p (article)
8206 "Say whether ARTICLE is a root(ish) article."
8207 (let ((level (gnus-summary-thread-level article))
8208 (refs (mail-header-references (gnus-summary-article-header article)))
8214 ((null (gnus-parent-id refs)) t)
8216 (null (setq particle (gnus-id-to-article
8217 (gnus-parent-id refs))))
8218 (null (gnus-summary-thread-level particle)))))))
8220 (defun gnus-root-id (id)
8221 "Return the id of the root of the thread where ID appears."
8223 (while (and id (setq prev (car (gnus-gethash
8224 id gnus-newsgroup-dependencies))))
8226 id (gnus-parent-id (mail-header-references prev))))
8229 (defun gnus-remove-thread (id &optional dont-remove)
8230 "Remove the thread that has ID in it."
8231 (let ((dep gnus-newsgroup-dependencies)
8232 headers thread last-id)
8233 ;; First go up in this thread until we find the root.
8234 (setq last-id (gnus-root-id id))
8235 (setq headers (list (car (gnus-id-to-thread last-id))
8236 (caadr (gnus-id-to-thread last-id))))
8237 ;; We have now found the real root of this thread. It might have
8238 ;; been gathered into some loose thread, so we have to search
8239 ;; through the threads to find the thread we wanted.
8240 (let ((threads gnus-newsgroup-threads)
8243 (setq sub (car threads))
8244 (if (stringp (car sub))
8245 ;; This is a gathered threads, so we look at the roots
8246 ;; below it to find whether this article in in this
8249 (setq sub (cdr sub))
8251 (when (member (caar sub) headers)
8252 (setq thread (car threads)
8255 (setq sub (cdr sub))))
8256 ;; It's an ordinary thread, so we check it.
8257 (when (eq (car sub) (car headers))
8260 (setq threads (cdr threads)))
8261 ;; If this article is in no thread, then it's a root.
8264 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
8265 (setq thread (gnus-gethash last-id dep)))
8268 thread ; We return this thread.
8270 (if (stringp (car thread))
8272 ;; If we use dummy roots, then we have to remove the
8273 ;; dummy root as well.
8274 (when (eq gnus-summary-make-false-root 'dummy)
8277 (setq thread (cdr thread))
8279 (gnus-remove-thread-1 (car thread))
8280 (setq thread (cdr thread))))
8281 (gnus-remove-thread-1 thread))))))))
8283 (defun gnus-remove-thread-1 (thread)
8284 "Remove the thread THREAD recursively."
8285 (let ((number (mail-header-number (car thread)))
8287 (when (setq pos (text-property-any
8288 (point-min) (point-max) 'gnus-number number))
8291 (gnus-data-remove number))
8292 (setq thread (cdr thread))
8294 (gnus-remove-thread-1 (pop thread)))))
8296 (defun gnus-sort-threads (threads)
8298 (if (not gnus-thread-sort-functions)
8300 (let ((func (if (= 1 (length gnus-thread-sort-functions))
8301 (car gnus-thread-sort-functions)
8303 ,(gnus-make-sort-function
8304 (reverse gnus-thread-sort-functions))))))
8305 (gnus-message 7 "Sorting threads...")
8308 (gnus-message 7 "Sorting threads...done")))))
8310 (defun gnus-sort-articles (articles)
8312 (when gnus-article-sort-functions
8313 (let ((func (if (= 1 (length gnus-article-sort-functions))
8314 (car gnus-article-sort-functions)
8316 ,(gnus-make-sort-function
8317 (reverse gnus-article-sort-functions))))))
8318 (gnus-message 7 "Sorting articles...")
8320 (setq gnus-newsgroup-headers (sort articles func))
8321 (gnus-message 7 "Sorting articles...done")))))
8323 (defun gnus-make-sort-function (funs)
8324 "Return a composite sort condition based on the functions in FUNC."
8326 `(or (,(car funs) t1 t2)
8327 (and (not (,(car funs) t2 t1))
8328 ,(gnus-make-sort-function (cdr funs))))
8329 `(,(car funs) t1 t2)))
8331 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
8332 (defmacro gnus-thread-header (thread)
8333 ;; Return header of first article in THREAD.
8334 ;; Note that THREAD must never, ever be anything else than a variable -
8335 ;; using some other form will lead to serious barfage.
8336 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
8337 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
8338 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
8341 (defsubst gnus-article-sort-by-number (h1 h2)
8342 "Sort articles by article number."
8343 (< (mail-header-number h1)
8344 (mail-header-number h2)))
8346 (defun gnus-thread-sort-by-number (h1 h2)
8347 "Sort threads by root article number."
8348 (gnus-article-sort-by-number
8349 (gnus-thread-header h1) (gnus-thread-header h2)))
8351 (defsubst gnus-article-sort-by-author (h1 h2)
8352 "Sort articles by root author."
8354 (let ((extract (funcall
8355 gnus-extract-address-components
8356 (mail-header-from h1))))
8357 (or (car extract) (cdr extract)))
8358 (let ((extract (funcall
8359 gnus-extract-address-components
8360 (mail-header-from h2))))
8361 (or (car extract) (cdr extract)))))
8363 (defun gnus-thread-sort-by-author (h1 h2)
8364 "Sort threads by root author."
8365 (gnus-article-sort-by-author
8366 (gnus-thread-header h1) (gnus-thread-header h2)))
8368 (defsubst gnus-article-sort-by-subject (h1 h2)
8369 "Sort articles by root subject."
8371 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
8372 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
8374 (defun gnus-thread-sort-by-subject (h1 h2)
8375 "Sort threads by root subject."
8376 (gnus-article-sort-by-subject
8377 (gnus-thread-header h1) (gnus-thread-header h2)))
8379 (defsubst gnus-article-sort-by-date (h1 h2)
8380 "Sort articles by root article date."
8382 (inline (gnus-sortable-date (mail-header-date h1)))
8383 (inline (gnus-sortable-date (mail-header-date h2)))))
8385 (defun gnus-thread-sort-by-date (h1 h2)
8386 "Sort threads by root article date."
8387 (gnus-article-sort-by-date
8388 (gnus-thread-header h1) (gnus-thread-header h2)))
8390 (defsubst gnus-article-sort-by-score (h1 h2)
8391 "Sort articles by root article score.
8392 Unscored articles will be counted as having a score of zero."
8393 (> (or (cdr (assq (mail-header-number h1)
8394 gnus-newsgroup-scored))
8395 gnus-summary-default-score 0)
8396 (or (cdr (assq (mail-header-number h2)
8397 gnus-newsgroup-scored))
8398 gnus-summary-default-score 0)))
8400 (defun gnus-thread-sort-by-score (h1 h2)
8401 "Sort threads by root article score."
8402 (gnus-article-sort-by-score
8403 (gnus-thread-header h1) (gnus-thread-header h2)))
8405 (defun gnus-thread-sort-by-total-score (h1 h2)
8406 "Sort threads by the sum of all scores in the thread.
8407 Unscored articles will be counted as having a score of zero."
8408 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
8410 (defun gnus-thread-total-score (thread)
8411 ;; This function find the total score of THREAD.
8412 (cond ((null thread)
8415 (if (stringp (car thread))
8416 (apply gnus-thread-score-function 0
8417 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
8418 (gnus-thread-total-score-1 thread)))
8420 (gnus-thread-total-score-1 (list thread)))))
8422 (defun gnus-thread-total-score-1 (root)
8423 ;; This function find the total score of the thread below ROOT.
8424 (setq root (car root))
8425 (apply gnus-thread-score-function
8426 (or (cdr (assq (mail-header-number root) gnus-newsgroup-scored))
8427 gnus-summary-default-score 0)
8428 (mapcar 'gnus-thread-total-score
8429 (cdr (gnus-gethash (mail-header-id root)
8430 gnus-newsgroup-dependencies)))))
8432 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8433 (defvar gnus-tmp-prev-subject nil)
8434 (defvar gnus-tmp-false-parent nil)
8435 (defvar gnus-tmp-root-expunged nil)
8436 (defvar gnus-tmp-dummy-line nil)
8438 (defun gnus-summary-prepare-threads (threads)
8439 "Prepare summary buffer from THREADS and indentation LEVEL.
8440 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
8441 or a straight list of headers."
8442 (gnus-message 7 "Generating summary...")
8444 (setq gnus-newsgroup-threads threads)
8447 (let ((gnus-tmp-level 0)
8448 (default-score (or gnus-summary-default-score 0))
8449 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
8450 thread number subject stack state gnus-tmp-gathered beg-match
8451 new-roots gnus-tmp-new-adopts thread-end
8452 gnus-tmp-header gnus-tmp-unread
8453 gnus-tmp-replied gnus-tmp-subject-or-nil
8454 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
8455 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
8456 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
8458 (setq gnus-tmp-prev-subject nil)
8460 (if (vectorp (car threads))
8461 ;; If this is a straight (sic) list of headers, then a
8462 ;; threaded summary display isn't required, so we just create
8463 ;; an unthreaded one.
8464 (gnus-summary-prepare-unthreaded threads)
8466 ;; Do the threaded display.
8468 (while (or threads stack gnus-tmp-new-adopts new-roots)
8470 (if (and (= gnus-tmp-level 0)
8471 (not (setq gnus-tmp-dummy-line nil))
8474 (not gnus-tmp-false-parent)
8475 (or gnus-tmp-new-adopts new-roots))
8476 (if gnus-tmp-new-adopts
8477 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
8478 thread (list (car gnus-tmp-new-adopts))
8479 gnus-tmp-header (caar thread)
8480 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
8482 (setq thread (list (car new-roots))
8483 gnus-tmp-header (caar thread)
8484 new-roots (cdr new-roots))))
8487 ;; If there are some threads, we do them before the
8488 ;; threads on the stack.
8489 (setq thread threads
8490 gnus-tmp-header (caar thread))
8491 ;; There were no current threads, so we pop something off
8493 (setq state (car stack)
8494 gnus-tmp-level (car state)
8497 gnus-tmp-header (caar thread))))
8499 (setq gnus-tmp-false-parent nil)
8500 (setq gnus-tmp-root-expunged nil)
8501 (setq thread-end nil)
8503 (if (stringp gnus-tmp-header)
8504 ;; The header is a dummy root.
8506 ((eq gnus-summary-make-false-root 'adopt)
8507 ;; We let the first article adopt the rest.
8508 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
8510 (setq gnus-tmp-gathered
8512 (lambda (h) (mail-header-number (car h)))
8515 (setq thread (cons (list (caar thread)
8518 (setq gnus-tmp-level -1
8519 gnus-tmp-false-parent t))
8520 ((eq gnus-summary-make-false-root 'empty)
8521 ;; We print adopted articles with empty subject fields.
8522 (setq gnus-tmp-gathered
8524 (lambda (h) (mail-header-number (car h)))
8527 (setq gnus-tmp-level -1))
8528 ((eq gnus-summary-make-false-root 'dummy)
8529 ;; We remember that we probably want to output a dummy
8531 (setq gnus-tmp-dummy-line gnus-tmp-header)
8532 (setq gnus-tmp-prev-subject gnus-tmp-header))
8534 ;; We do not make a root for the gathered
8535 ;; sub-threads at all.
8536 (setq gnus-tmp-level -1)))
8538 (setq number (mail-header-number gnus-tmp-header)
8539 subject (mail-header-subject gnus-tmp-header))
8542 ;; If the thread has changed subject, we might want to make
8543 ;; this subthread into a root.
8544 ((and (null gnus-thread-ignore-subject)
8545 (not (zerop gnus-tmp-level))
8546 gnus-tmp-prev-subject
8548 (gnus-subject-equal gnus-tmp-prev-subject subject))))
8549 (setq new-roots (nconc new-roots (list (car thread)))
8551 gnus-tmp-header nil))
8552 ;; If the article lies outside the current limit,
8553 ;; then we do not display it.
8554 ((and (not (memq number gnus-newsgroup-limit))
8555 (not gnus-tmp-dummy-line))
8556 (setq gnus-tmp-gathered
8558 (lambda (h) (mail-header-number (car h)))
8561 (setq gnus-tmp-new-adopts (if (cdar thread)
8562 (append gnus-tmp-new-adopts
8564 gnus-tmp-new-adopts)
8566 gnus-tmp-header nil)
8567 (when (zerop gnus-tmp-level)
8568 (setq gnus-tmp-root-expunged t)))
8569 ;; Perhaps this article is to be marked as read?
8570 ((and gnus-summary-mark-below
8571 (< (or (cdr (assq number gnus-newsgroup-scored))
8573 gnus-summary-mark-below)
8574 ;; Don't touch sparse articles.
8575 (not (memq number gnus-newsgroup-sparse))
8576 (not (memq number gnus-newsgroup-ancient)))
8577 (setq gnus-newsgroup-unreads
8578 (delq number gnus-newsgroup-unreads))
8579 (if gnus-newsgroup-auto-expire
8580 (push number gnus-newsgroup-expirable)
8581 (push (cons number gnus-low-score-mark)
8582 gnus-newsgroup-reads))))
8584 (when gnus-tmp-header
8585 ;; We may have an old dummy line to output before this
8587 (when gnus-tmp-dummy-line
8588 (gnus-summary-insert-dummy-line
8589 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
8590 (setq gnus-tmp-dummy-line nil))
8592 ;; Compute the mark.
8596 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8597 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8598 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8599 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8600 (t (or (cdr (assq number gnus-newsgroup-reads))
8601 gnus-ancient-mark))))
8603 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
8604 gnus-tmp-header gnus-tmp-level)
8605 gnus-newsgroup-data)
8607 ;; Actually insert the line.
8609 gnus-tmp-subject-or-nil
8611 ((and gnus-thread-ignore-subject
8612 gnus-tmp-prev-subject
8613 (not (inline (gnus-subject-equal
8614 gnus-tmp-prev-subject subject))))
8616 ((zerop gnus-tmp-level)
8617 (if (and (eq gnus-summary-make-false-root 'empty)
8618 (memq number gnus-tmp-gathered)
8619 gnus-tmp-prev-subject
8620 (inline (gnus-subject-equal
8621 gnus-tmp-prev-subject subject)))
8622 gnus-summary-same-subject
8624 (t gnus-summary-same-subject)))
8625 (if (and (eq gnus-summary-make-false-root 'adopt)
8626 (= gnus-tmp-level 1)
8627 (memq number gnus-tmp-gathered))
8628 (setq gnus-tmp-opening-bracket ?\<
8629 gnus-tmp-closing-bracket ?\>)
8630 (setq gnus-tmp-opening-bracket ?\[
8631 gnus-tmp-closing-bracket ?\]))
8633 gnus-tmp-indentation
8634 (aref gnus-thread-indent-array gnus-tmp-level)
8635 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
8636 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
8637 gnus-summary-default-score 0)
8639 (if (or (null gnus-summary-default-score)
8640 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
8641 gnus-summary-zcore-fuzz)) ?
8642 (if (< gnus-tmp-score gnus-summary-default-score)
8643 gnus-score-below-mark gnus-score-over-mark))
8645 (cond ((memq number gnus-newsgroup-processable)
8647 ((memq number gnus-newsgroup-cached)
8649 ((memq number gnus-newsgroup-replied)
8651 ((memq number gnus-newsgroup-saved)
8653 (t gnus-unread-mark))
8654 gnus-tmp-from (mail-header-from gnus-tmp-header)
8657 ((string-match "(.+)" gnus-tmp-from)
8658 (substring gnus-tmp-from
8659 (1+ (match-beginning 0)) (1- (match-end 0))))
8660 ((string-match "<[^>]+> *$" gnus-tmp-from)
8661 (setq beg-match (match-beginning 0))
8662 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
8663 (substring gnus-tmp-from (1+ (match-beginning 0))
8664 (1- (match-end 0))))
8665 (substring gnus-tmp-from 0 beg-match)))
8667 (when (string= gnus-tmp-name "")
8668 (setq gnus-tmp-name gnus-tmp-from))
8669 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
8670 (gnus-put-text-property
8672 (progn (eval gnus-summary-line-format-spec) (point))
8673 'gnus-number number)
8676 (run-hooks 'gnus-summary-update-hook)
8679 (setq gnus-tmp-prev-subject subject)))
8681 (when (nth 1 thread)
8682 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
8683 (incf gnus-tmp-level)
8684 (setq threads (if thread-end nil (cdar thread)))
8686 (setq gnus-tmp-level 0)))))
8687 (gnus-message 7 "Generating summary...done"))
8689 (defun gnus-summary-prepare-unthreaded (headers)
8690 "Generate an unthreaded summary buffer based on HEADERS."
8691 (let (header number mark)
8694 ;; We may have to root out some bad articles...
8695 (when (memq (setq number (mail-header-number
8696 (setq header (pop headers))))
8697 gnus-newsgroup-limit)
8698 ;; Mark article as read when it has a low score.
8699 (when (and gnus-summary-mark-below
8700 (< (or (cdr (assq number gnus-newsgroup-scored))
8701 gnus-summary-default-score 0)
8702 gnus-summary-mark-below)
8703 (not (memq number gnus-newsgroup-ancient)))
8704 (setq gnus-newsgroup-unreads
8705 (delq number gnus-newsgroup-unreads))
8706 (if gnus-newsgroup-auto-expire
8707 (push number gnus-newsgroup-expirable)
8708 (push (cons number gnus-low-score-mark)
8709 gnus-newsgroup-reads)))
8713 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8714 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8715 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8716 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8717 (t (or (cdr (assq number gnus-newsgroup-reads))
8718 gnus-ancient-mark))))
8719 (setq gnus-newsgroup-data
8720 (cons (gnus-data-make number mark (1+ (point)) header 0)
8721 gnus-newsgroup-data))
8722 (gnus-summary-insert-line
8723 header 0 nil mark (memq number gnus-newsgroup-replied)
8724 (memq number gnus-newsgroup-expirable)
8725 (mail-header-subject header) nil
8726 (cdr (assq number gnus-newsgroup-scored))
8727 (memq number gnus-newsgroup-processable))))))
8729 (defun gnus-select-newsgroup (group &optional read-all)
8730 "Select newsgroup GROUP.
8731 If READ-ALL is non-nil, all articles in the group are selected."
8732 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
8733 (info (nth 2 entry))
8734 articles fetched-articles cached)
8736 (or (gnus-check-server
8737 (setq gnus-current-select-method (gnus-find-method-for-group group)))
8738 (error "Couldn't open server"))
8740 (or (and entry (not (eq (car entry) t))) ; Either it's active...
8741 (gnus-activate-group group) ; Or we can activate it...
8742 (progn ; Or we bug out.
8743 (when (equal major-mode 'gnus-summary-mode)
8744 (kill-buffer (current-buffer)))
8745 (error "Couldn't request group %s: %s"
8746 group (gnus-status-message group))))
8748 (unless (gnus-request-group group t)
8749 (when (equal major-mode 'gnus-summary-mode)
8750 (kill-buffer (current-buffer)))
8751 (error "Couldn't request group %s: %s"
8752 group (gnus-status-message group)))
8754 (setq gnus-newsgroup-name group)
8755 (setq gnus-newsgroup-unselected nil)
8756 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
8758 (and gnus-asynchronous
8759 (gnus-check-backend-function
8760 'request-asynchronous gnus-newsgroup-name)
8761 (setq gnus-newsgroup-async
8762 (gnus-request-asynchronous gnus-newsgroup-name)))
8764 ;; Adjust and set lists of article marks.
8766 (gnus-adjust-marked-articles info))
8768 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8769 (when (gnus-virtual-group-p group)
8770 (setq cached gnus-newsgroup-cached))
8772 (setq gnus-newsgroup-unreads
8773 (gnus-set-difference
8774 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
8775 gnus-newsgroup-dormant))
8777 (setq gnus-newsgroup-processable nil)
8779 (setq articles (gnus-articles-to-read group read-all))
8783 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
8785 ((eq articles 0) nil)
8787 ;; Init the dependencies hash table.
8788 (setq gnus-newsgroup-dependencies
8789 (gnus-make-hashtable (length articles)))
8790 ;; Retrieve the headers and read them in.
8791 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8792 (setq gnus-newsgroup-headers
8794 (setq gnus-headers-retrieved-by
8795 (gnus-retrieve-headers
8796 articles gnus-newsgroup-name
8797 ;; We might want to fetch old headers, but
8798 ;; not if there is only 1 article.
8799 (and gnus-fetch-old-headers
8801 (not (eq gnus-fetch-old-headers 'some))
8802 (not (numberp gnus-fetch-old-headers)))
8803 (> (length articles) 1))))))
8804 (gnus-get-newsgroup-headers-xover articles)
8805 (gnus-get-newsgroup-headers)))
8806 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
8808 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8810 (setq gnus-newsgroup-cached cached))
8812 ;; Set the initial limit.
8813 (setq gnus-newsgroup-limit (copy-sequence articles))
8814 ;; Remove canceled articles from the list of unread articles.
8815 (setq gnus-newsgroup-unreads
8816 (gnus-set-sorted-intersection
8817 gnus-newsgroup-unreads
8818 (setq fetched-articles
8819 (mapcar (lambda (headers) (mail-header-number headers))
8820 gnus-newsgroup-headers))))
8821 ;; Removed marked articles that do not exist.
8822 (gnus-update-missing-marks
8823 (gnus-sorted-complement fetched-articles articles))
8824 ;; We might want to build some more threads first.
8825 (and gnus-fetch-old-headers
8826 (eq gnus-headers-retrieved-by 'nov)
8827 (gnus-build-old-threads))
8828 ;; Check whether auto-expire is to be done in this group.
8829 (setq gnus-newsgroup-auto-expire
8830 (gnus-group-auto-expirable-p group))
8831 ;; Set up the article buffer now, if necessary.
8832 (unless gnus-single-article-buffer
8833 (gnus-article-setup-buffer))
8834 ;; First and last article in this newsgroup.
8835 (when gnus-newsgroup-headers
8836 (setq gnus-newsgroup-begin
8837 (mail-header-number (car gnus-newsgroup-headers))
8840 (gnus-last-element gnus-newsgroup-headers))))
8841 (setq gnus-reffed-article-number -1)
8842 ;; GROUP is successfully selected.
8843 (or gnus-newsgroup-headers t)))))
8845 (defun gnus-articles-to-read (group read-all)
8846 ;; Find out what articles the user wants to read.
8848 ;; Select all articles if `read-all' is non-nil, or if there
8849 ;; are no unread articles.
8851 (and (zerop (length gnus-newsgroup-marked))
8852 (zerop (length gnus-newsgroup-unreads))))
8853 (gnus-uncompress-range (gnus-active group))
8854 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
8855 (copy-sequence gnus-newsgroup-unreads))
8857 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
8858 (scored (length scored-list))
8859 (number (length articles))
8860 (marked (+ (length gnus-newsgroup-marked)
8861 (length gnus-newsgroup-dormant)))
8869 ((and (or (<= scored marked) (= scored number))
8870 (numberp gnus-large-newsgroup)
8871 (> number gnus-large-newsgroup))
8875 "How many articles from %s (default %d): "
8876 gnus-newsgroup-name number))))
8877 (if (string-match "^[ \t]*$" input) number input)))
8878 ((and (> scored marked) (< scored number)
8879 (> (- scored number) 20))
8882 (format "%s %s (%d scored, %d total): "
8883 "How many articles from"
8884 group scored number))))
8885 (if (string-match "^[ \t]*$" input)
8889 (setq select (if (stringp select) (string-to-number select) select))
8890 (if (or (null select) (zerop select))
8892 (if (and (not (zerop scored)) (<= (abs select) scored))
8894 (setq articles (sort scored-list '<))
8895 (setq number (length articles)))
8896 (setq articles (copy-sequence articles)))
8898 (if (< (abs select) number)
8900 ;; Select the N oldest articles.
8901 (setcdr (nthcdr (1- (abs select)) articles) nil)
8902 ;; Select the N most recent articles.
8903 (setq articles (nthcdr (- number select) articles))))
8904 (setq gnus-newsgroup-unselected
8905 (gnus-sorted-intersection
8906 gnus-newsgroup-unreads
8907 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
8910 (defun gnus-killed-articles (killed articles)
8913 (if (inline (gnus-member-of-range (car articles) killed))
8914 (setq out (cons (car articles) out)))
8915 (setq articles (cdr articles)))
8918 (defun gnus-uncompress-marks (marks)
8919 "Uncompress the mark ranges in MARKS."
8920 (let ((uncompressed '(score bookmark))
8923 (if (memq (caar marks) uncompressed)
8924 (push (car marks) out)
8925 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
8926 (setq marks (cdr marks)))
8929 (defun gnus-adjust-marked-articles (info)
8930 "Set all article lists and remove all marks that are no longer legal."
8931 (let* ((marked-lists (gnus-info-marks info))
8932 (active (gnus-active (gnus-info-group info)))
8935 (types gnus-article-mark-lists)
8936 (uncompressed '(score bookmark))
8937 marks var articles article mark)
8940 (setq marks (pop marked-lists))
8941 (set (setq var (intern (format "gnus-newsgroup-%s"
8942 (car (rassq (setq mark (car marks))
8944 (if (memq (car marks) uncompressed) (cdr marks)
8945 (gnus-uncompress-range (cdr marks))))
8947 (setq articles (symbol-value var))
8949 ;; All articles have to be subsets of the active articles.
8951 ;; Adjust "simple" lists.
8952 ((memq mark '(tick dormant expirable reply killed save))
8954 (when (or (< (setq article (pop articles)) min) (> article max))
8955 (set var (delq article (symbol-value var))))))
8957 ((memq mark '(score bookmark))
8959 (when (or (< (car (setq article (pop articles))) min)
8960 (> (car article) max))
8961 (set var (delq article (symbol-value var))))))))))
8963 (defun gnus-update-missing-marks (missing)
8964 "Go through the list of MISSING articles and remove them mark lists."
8966 (let ((types gnus-article-mark-lists)
8968 ;; Go through all types.
8970 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
8971 (when (symbol-value var)
8972 ;; This list has articles. So we delete all missing articles
8976 (set var (delq (pop m) (symbol-value var)))))))))
8978 (defun gnus-update-marks ()
8979 "Enter the various lists of marked articles into the newsgroup info list."
8980 (let ((types gnus-article-mark-lists)
8981 (info (gnus-get-info gnus-newsgroup-name))
8982 (uncompressed '(score bookmark killed))
8983 type list newmarked symbol)
8985 ;; Add all marks lists that are non-nil to the list of marks lists.
8987 (setq type (pop types))
8988 (when (setq list (symbol-value
8990 (intern (format "gnus-newsgroup-%s"
8992 (push (cons (cdr type)
8993 (if (memq (cdr type) uncompressed) list
8994 (gnus-compress-sequence
8995 (set symbol (sort list '<)) t)))
8998 ;; Enter these new marks into the info of the group.
9000 (setcar (nthcdr 3 info) newmarked)
9001 ;; Add the marks lists to the end of the info.
9003 (setcdr (nthcdr 2 info) (list newmarked))))
9005 ;; Cut off the end of the info if there's nothing else there.
9009 (when (nthcdr (decf i) info)
9010 (setcdr (nthcdr i info) nil)))))))
9012 (defun gnus-add-marked-articles (group type articles &optional info force)
9013 ;; Add ARTICLES of TYPE to the info of GROUP.
9014 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
9015 ;; add, but replace marked articles of TYPE with ARTICLES.
9016 (let ((info (or info (gnus-get-info group)))
9017 (uncompressed '(score bookmark killed))
9020 (and (not (setq marked (nthcdr 3 info)))
9022 (setcdr (nthcdr 2 info)
9023 (list (list (cons type (gnus-compress-sequence
9025 (and (not (setq m (assq type (car marked))))
9028 (cons (cons type (gnus-compress-sequence articles t) )
9032 (setcar (nthcdr 3 info)
9033 (delq (assq type (car marked)) (car marked)))
9034 (setcdr m (gnus-compress-sequence articles t)))
9035 (setcdr m (gnus-compress-sequence
9036 (sort (nconc (gnus-uncompress-range (cdr m))
9037 (copy-sequence articles)) '<) t))))))
9039 (defun gnus-set-mode-line (where)
9040 "This function sets the mode line of the article or summary buffers.
9041 If WHERE is `summary', the summary mode line format will be used."
9042 ;; Is this mode line one we keep updated?
9043 (when (memq where gnus-updated-mode-lines)
9046 ;; We evaluate this in the summary buffer since these
9047 ;; variables are buffer-local to that buffer.
9048 (set-buffer gnus-summary-buffer)
9049 ;; We bind all these variables that are used in the `eval' form
9051 (let* ((mformat (symbol-value
9053 (format "gnus-%s-mode-line-format-spec" where))))
9054 (gnus-tmp-group-name gnus-newsgroup-name)
9055 (gnus-tmp-article-number (or gnus-current-article 0))
9056 (gnus-tmp-unread gnus-newsgroup-unreads)
9057 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
9058 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
9059 (gnus-tmp-unread-and-unselected
9060 (cond ((and (zerop gnus-tmp-unread-and-unticked)
9061 (zerop gnus-tmp-unselected)) "")
9062 ((zerop gnus-tmp-unselected)
9063 (format "{%d more}" gnus-tmp-unread-and-unticked))
9064 (t (format "{%d(+%d) more}"
9065 gnus-tmp-unread-and-unticked
9066 gnus-tmp-unselected))))
9068 (if (and gnus-current-headers
9069 (vectorp gnus-current-headers))
9070 (gnus-mode-string-quote
9071 (mail-header-subject gnus-current-headers)) ""))
9073 gnus-tmp-header);; passed as argument to any user-format-funcs
9074 (setq mode-string (eval mformat))
9075 (setq max-len (max 4 (if gnus-mode-non-string-length
9077 gnus-mode-non-string-length)
9078 (length mode-string))))
9079 ;; We might have to chop a bit of the string off...
9080 (when (> (length mode-string) max-len)
9082 (concat (gnus-truncate-string mode-string (- max-len 3))
9084 ;; Pad the mode string a bit.
9085 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
9086 ;; Update the mode line.
9087 (setq mode-line-buffer-identification
9088 (gnus-mode-line-buffer-identification
9089 (list mode-string)))
9090 (set-buffer-modified-p t))))
9092 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
9093 "Go through the HEADERS list and add all Xrefs to a hash table.
9094 The resulting hash table is returned, or nil if no Xrefs were found."
9095 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
9096 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
9097 (xref-hashtb (make-vector 63 0))
9098 start group entry number xrefs header)
9100 (setq header (pop headers))
9101 (when (and (setq xrefs (mail-header-xref header))
9102 (not (memq (setq number (mail-header-number header))
9105 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
9106 (setq start (match-end 0))
9107 (setq group (if prefix
9108 (concat prefix (substring xrefs (match-beginning 1)
9110 (substring xrefs (match-beginning 1) (match-end 1))))
9112 (string-to-int (substring xrefs (match-beginning 2)
9114 (if (setq entry (gnus-gethash group xref-hashtb))
9115 (setcdr entry (cons number (cdr entry)))
9116 (gnus-sethash group (cons number nil) xref-hashtb)))))
9117 (and start xref-hashtb)))
9119 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
9120 "Look through all the headers and mark the Xrefs as read."
9121 (let ((virtual (gnus-virtual-group-p from-newsgroup))
9122 name entry info xref-hashtb idlist method nth4)
9124 (set-buffer gnus-group-buffer)
9125 (when (setq xref-hashtb
9126 (gnus-create-xref-hashtb from-newsgroup headers unreads))
9129 (unless (string= from-newsgroup (setq name (symbol-name group)))
9130 (setq idlist (symbol-value group))
9131 ;; Dead groups are not updated.
9133 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
9135 (if (stringp (setq nth4 (gnus-info-method info)))
9136 (setq nth4 (gnus-server-to-method nth4))))
9137 ;; Only do the xrefs if the group has the same
9138 ;; select method as the group we have just read.
9139 (or (gnus-methods-equal-p
9140 nth4 (gnus-find-method-for-group from-newsgroup))
9142 (equal nth4 (setq method (gnus-find-method-for-group
9144 (and (equal (car nth4) (car method))
9145 (equal (nth 1 nth4) (nth 1 method))))
9146 gnus-use-cross-reference
9147 (or (not (eq gnus-use-cross-reference t))
9149 ;; Only do cross-references on subscribed
9150 ;; groups, if that is what is wanted.
9151 (<= (gnus-info-level info) gnus-level-subscribed))
9152 (gnus-group-make-articles-read name idlist))))
9155 (defun gnus-group-make-articles-read (group articles)
9157 (entry (gnus-gethash group gnus-newsrc-hashtb))
9158 (info (nth 2 entry))
9159 (active (gnus-active group))
9161 ;; First peel off all illegal article numbers.
9163 (let ((ids articles)
9167 (if (and first (> id (cdr active)))
9169 ;; We'll end up in this situation in one particular
9170 ;; obscure situation. If you re-scan a group and get
9171 ;; a new article that is cross-posted to a different
9172 ;; group that has not been re-scanned, you might get
9173 ;; crossposted article that has a higher number than
9174 ;; Gnus believes possible. So we re-activate this
9175 ;; group as well. This might mean doing the
9176 ;; crossposting thingy will *increase* the number
9177 ;; of articles in some groups. Tsk, tsk.
9178 (setq active (or (gnus-activate-group group) active))))
9179 (if (or (> id (cdr active))
9180 (< id (car active)))
9181 (setq articles (delq id articles)))
9182 (setq ids (cdr ids)))))
9183 ;; If the read list is nil, we init it.
9185 (null (gnus-info-read info))
9187 (gnus-info-set-read info (cons 1 (1- (car active)))))
9188 ;; Then we add the read articles to the range.
9193 (gnus-info-read info) (setq articles (sort articles '<)))))
9194 ;; Then we have to re-compute how many unread
9195 ;; articles there are in this group.
9200 (setq num (- (1+ (cdr active)) (car active))))
9201 ((not (listp (cdr range)))
9202 (setq num (- (cdr active) (- (1+ (cdr range))
9206 (if (numberp (car range))
9208 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
9209 (setq range (cdr range)))
9210 (setq num (- (cdr active) num))))
9211 ;; Update the number of unread articles.
9213 ;; Update the group buffer.
9214 (gnus-group-update-group group t)))))
9216 (defun gnus-methods-equal-p (m1 m2)
9217 (let ((m1 (or m1 gnus-select-method))
9218 (m2 (or m2 gnus-select-method)))
9220 (and (eq (car m1) (car m2))
9221 (or (not (memq 'address (assoc (symbol-name (car m1))
9222 gnus-valid-select-methods)))
9223 (equal (nth 1 m1) (nth 1 m2)))))))
9225 (defsubst gnus-header-value ()
9226 (buffer-substring (match-end 0) (gnus-point-at-eol)))
9228 (defvar gnus-newsgroup-none-id 0)
9230 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
9231 (let ((cur nntp-server-buffer)
9234 (save-excursion (set-buffer gnus-summary-buffer)
9235 gnus-newsgroup-dependencies)))
9236 headers id id-dep ref-dep end ref)
9238 (set-buffer nntp-server-buffer)
9239 (run-hooks 'gnus-parse-headers-hook)
9240 (let ((case-fold-search t)
9241 in-reply-to header p lines)
9242 (goto-char (point-min))
9243 ;; Search to the beginning of the next header. Error messages
9244 ;; do not begin with 2 or 3.
9245 (while (re-search-forward "^[23][0-9]+ " nil t)
9248 ;; This implementation of this function, with nine
9249 ;; search-forwards instead of the one re-search-forward and
9250 ;; a case (which basically was the old function) is actually
9251 ;; about twice as fast, even though it looks messier. You
9252 ;; can't have everything, I guess. Speed and elegance
9253 ;; doesn't always go hand in hand.
9262 (narrow-to-region (point)
9263 (or (and (search-forward "\n.\n" nil t)
9269 (if (search-forward "\nsubject: " nil t)
9270 (gnus-header-value) "(none)"))
9274 (if (search-forward "\nfrom: " nil t)
9275 (gnus-header-value) "(nobody)"))
9279 (if (search-forward "\ndate: " nil t)
9280 (gnus-header-value) ""))
9284 (if (search-forward "\nmessage-id: " nil t)
9285 (setq id (gnus-header-value))
9286 ;; If there was no message-id, we just fake one to make
9287 ;; subsequent routines simpler.
9288 (setq id (concat "none+"
9290 (setq gnus-newsgroup-none-id
9291 (1+ gnus-newsgroup-none-id)))))))
9295 (if (search-forward "\nreferences: " nil t)
9304 (search-backward ">" end t)
9307 (search-backward "<" end t)
9309 ;; Get the references from the in-reply-to header if there
9310 ;; were no references and the in-reply-to header looks
9312 (if (and (search-forward "\nin-reply-to: " nil t)
9313 (setq in-reply-to (gnus-header-value))
9314 (string-match "<[^>]+>" in-reply-to))
9315 (setq ref (substring in-reply-to (match-beginning 0)
9323 (if (search-forward "\nlines: " nil t)
9324 (if (numberp (setq lines (read cur)))
9330 (and (search-forward "\nxref: " nil t)
9331 (gnus-header-value)))))
9332 ;; We do the threading while we read the headers. The
9333 ;; message-id and the last reference are both entered into
9334 ;; the same hash table. Some tippy-toeing around has to be
9335 ;; done in case an article has arrived before the article
9336 ;; which it refers to.
9337 (if (boundp (setq id-dep (intern id dependencies)))
9338 (if (and (car (symbol-value id-dep))
9340 ;; An article with this Message-ID has already
9341 ;; been seen, so we ignore this one, except we add
9342 ;; any additional Xrefs (in case the two articles
9343 ;; came from different servers).
9345 (mail-header-set-xref
9346 (car (symbol-value id-dep))
9347 (concat (or (mail-header-xref
9348 (car (symbol-value id-dep))) "")
9349 (or (mail-header-xref header) "")))
9351 (setcar (symbol-value id-dep) header))
9352 (set id-dep (list header)))
9354 (if (boundp (setq ref-dep (intern ref dependencies)))
9355 (setcdr (symbol-value ref-dep)
9356 (nconc (cdr (symbol-value ref-dep))
9357 (list (symbol-value id-dep))))
9358 (set ref-dep (list nil (symbol-value id-dep))))
9359 (setq headers (cons header headers)))
9360 (goto-char (point-max))
9362 (nreverse headers)))))
9364 ;; The following macros and functions were written by Felix Lee
9365 ;; <flee@cse.psu.edu>.
9367 (defmacro gnus-nov-read-integer ()
9369 (if (= (following-char) ?\t)
9371 (let ((num (condition-case nil (read buffer) (error nil))))
9372 (if (numberp num) num 0)))
9373 (or (eobp) (forward-char 1))))
9375 (defmacro gnus-nov-skip-field ()
9376 '(search-forward "\t" eol 'move))
9378 (defmacro gnus-nov-field ()
9379 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
9381 ;; Goes through the xover lines and returns a list of vectors
9382 (defun gnus-get-newsgroup-headers-xover (sequence &optional
9383 force-new dependencies)
9384 "Parse the news overview data in the server buffer, and return a
9385 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
9386 ;; Get the Xref when the users reads the articles since most/some
9387 ;; NNTP servers do not include Xrefs when using XOVER.
9388 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
9389 (let ((cur nntp-server-buffer)
9390 (dependencies (or dependencies gnus-newsgroup-dependencies))
9391 number headers header)
9393 (set-buffer nntp-server-buffer)
9394 ;; Allow the user to mangle the headers before parsing them.
9395 (run-hooks 'gnus-parse-headers-hook)
9396 (goto-char (point-min))
9397 (while (and sequence (not (eobp)))
9398 (setq number (read cur))
9399 (while (and sequence (< (car sequence) number))
9400 (setq sequence (cdr sequence)))
9402 (eq number (car sequence))
9404 (setq sequence (cdr sequence))
9406 (inline (gnus-nov-parse-line
9407 number dependencies force-new)))
9408 (setq headers (cons header headers)))))
9410 (setq headers (nreverse headers)))
9413 ;; This function has to be called with point after the article number
9414 ;; on the beginning of the line.
9415 (defun gnus-nov-parse-line (number dependencies &optional force-new)
9417 (eol (gnus-point-at-eol))
9418 (buffer (current-buffer))
9419 header ref id id-dep ref-dep)
9421 ;; overview: [num subject from date id refs chars lines misc]
9422 (narrow-to-region (point) eol)
9423 (or (eobp) (forward-char))
9429 (gnus-nov-field) ; subject
9430 (gnus-nov-field) ; from
9431 (gnus-nov-field) ; date
9432 (setq id (or (gnus-nov-field)
9435 (setq none (1+ none)))))) ; id
9438 (let ((beg (point)))
9439 (search-forward "\t" eol)
9440 (if (search-backward ">" beg t)
9444 (search-backward "<" beg t)))
9446 (gnus-nov-field)) ; refs
9447 (gnus-nov-read-integer) ; chars
9448 (gnus-nov-read-integer) ; lines
9449 (if (= (following-char) ?\n)
9451 (gnus-nov-field)) ; misc
9454 (gnus-error 4 "Strange nov line")
9460 ;; We build the thread tree.
9462 (if (boundp (setq id-dep (intern id dependencies)))
9463 (if (and (car (symbol-value id-dep))
9465 ;; An article with this Message-ID has already been seen,
9466 ;; so we ignore this one, except we add any additional
9467 ;; Xrefs (in case the two articles came from different
9470 (mail-header-set-xref
9471 (car (symbol-value id-dep))
9472 (concat (or (mail-header-xref
9473 (car (symbol-value id-dep))) "")
9474 (or (mail-header-xref header) "")))
9476 (setcar (symbol-value id-dep) header))
9477 (set id-dep (list header))))
9479 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
9480 (setcdr (symbol-value ref-dep)
9481 (nconc (cdr (symbol-value ref-dep))
9482 (list (symbol-value id-dep))))
9483 (set ref-dep (list nil (symbol-value id-dep)))))
9486 (defun gnus-article-get-xrefs ()
9487 "Fill in the Xref value in `gnus-current-headers', if necessary.
9488 This is meant to be called in `gnus-article-internal-prepare-hook'."
9489 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
9490 gnus-current-headers)))
9491 (or (not gnus-use-cross-reference)
9493 (and (mail-header-xref headers)
9494 (not (string= (mail-header-xref headers) "")))
9495 (let ((case-fold-search t)
9498 (nnheader-narrow-to-headers)
9499 (goto-char (point-min))
9500 (if (or (and (eq (downcase (following-char)) ?x)
9501 (looking-at "Xref:"))
9502 (search-forward "\nXref:" nil t))
9504 (goto-char (1+ (match-end 0)))
9505 (setq xref (buffer-substring (point)
9506 (progn (end-of-line) (point))))
9507 (mail-header-set-xref headers xref))))))))
9509 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
9510 "Find article ID and insert the summary line for that article."
9511 (let ((header (if (and old-header use-old-header)
9512 old-header (gnus-read-header id)))
9513 (number (and (numberp id) id))
9516 ;; Rebuild the thread that this article is part of and go to the
9517 ;; article we have fetched.
9518 (when (and (not gnus-show-threads)
9520 (when (setq pos (text-property-any
9521 (point-min) (point-max) 'gnus-number
9522 (mail-header-number old-header)))
9525 (gnus-data-remove (mail-header-number old-header))))
9527 (mail-header-set-number header (mail-header-number old-header)))
9528 (setq gnus-newsgroup-sparse
9529 (delq (setq number (mail-header-number header))
9530 gnus-newsgroup-sparse))
9531 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
9532 (gnus-rebuild-thread (mail-header-id header))
9533 (gnus-summary-goto-subject number nil t))
9534 (when (and (numberp number)
9536 ;; We have to update the boundaries even if we can't fetch the
9537 ;; article if ID is a number -- so that the next `P' or `N'
9538 ;; command will fetch the previous (or next) article even
9539 ;; if the one we tried to fetch this time has been canceled.
9540 (and (> number gnus-newsgroup-end)
9541 (setq gnus-newsgroup-end number))
9542 (and (< number gnus-newsgroup-begin)
9543 (setq gnus-newsgroup-begin number))
9544 (setq gnus-newsgroup-unselected
9545 (delq number gnus-newsgroup-unselected)))
9546 ;; Report back a success?
9547 (and header (mail-header-number header))))
9549 (defun gnus-summary-work-articles (n)
9550 "Return a list of articles to be worked upon. The prefix argument,
9551 the list of process marked articles, and the current article will be
9552 taken into consideration."
9555 ;; A numerical prefix has been given.
9556 (let ((backward (< n 0))
9557 (n (abs (prefix-numeric-value n)))
9562 (push (setq article (gnus-summary-article-number))
9565 (gnus-summary-find-prev nil article)
9566 (gnus-summary-find-next nil article)))
9568 (nreverse articles)))
9569 ((and (boundp 'transient-mark-mode)
9572 ;; Work on the region between point and mark.
9573 (let ((max (max (point) (mark)))
9576 (goto-char (min (point) (mark)))
9579 (push (setq article (gnus-summary-article-number)) articles)
9580 (gnus-summary-find-next nil article)
9582 (nreverse articles))))
9583 (gnus-newsgroup-processable
9584 ;; There are process-marked articles present.
9585 (reverse gnus-newsgroup-processable))
9587 ;; Just return the current article.
9588 (list (gnus-summary-article-number)))))
9590 (defun gnus-summary-search-group (&optional backward use-level)
9591 "Search for next unread newsgroup.
9592 If optional argument BACKWARD is non-nil, search backward instead."
9594 (set-buffer gnus-group-buffer)
9595 (if (gnus-group-search-forward
9596 backward nil (if use-level (gnus-group-group-level) nil))
9597 (gnus-group-group-name))))
9599 (defun gnus-summary-best-group (&optional exclude-group)
9600 "Find the name of the best unread group.
9601 If EXCLUDE-GROUP, do not go to this group."
9603 (set-buffer gnus-group-buffer)
9605 (gnus-group-best-unread-group exclude-group))))
9607 (defun gnus-summary-find-next (&optional unread article backward)
9608 (if backward (gnus-summary-find-prev)
9609 (let* ((dummy (gnus-summary-article-intangible-p))
9610 (article (or article (gnus-summary-article-number)))
9611 (arts (gnus-data-find-list article))
9613 (when (and (not dummy)
9614 (or (not gnus-summary-check-current)
9616 (not (gnus-data-unread-p (car arts)))))
9617 (setq arts (cdr arts)))
9622 (when (gnus-data-unread-p (car arts))
9623 (setq result (car arts)
9625 (setq arts (cdr arts)))
9628 (goto-char (gnus-data-pos result))
9629 (gnus-data-number result)))))
9631 (defun gnus-summary-find-prev (&optional unread article)
9632 (let* ((eobp (eobp))
9633 (article (or article (gnus-summary-article-number)))
9634 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
9636 (when (and (not eobp)
9637 (or (not gnus-summary-check-current)
9639 (not (gnus-data-unread-p (car arts)))))
9640 (setq arts (cdr arts)))
9645 (and (gnus-data-unread-p (car arts))
9646 (setq result (car arts)
9648 (setq arts (cdr arts)))
9652 (goto-char (gnus-data-pos result))
9653 (gnus-data-number result)))))
9655 (defun gnus-summary-find-subject (subject &optional unread backward article)
9656 (let* ((simp-subject (gnus-simplify-subject-fully subject))
9657 (article (or article (gnus-summary-article-number)))
9658 (articles (gnus-data-list backward))
9659 (arts (gnus-data-find-list article articles))
9661 (when (or (not gnus-summary-check-current)
9663 (not (gnus-data-unread-p (car arts))))
9664 (setq arts (cdr arts)))
9666 (and (or (not unread)
9667 (gnus-data-unread-p (car arts)))
9668 (vectorp (gnus-data-header (car arts)))
9670 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
9671 (setq result (car arts)
9673 (setq arts (cdr arts)))
9675 (goto-char (gnus-data-pos result))
9676 (gnus-data-number result))))
9678 (defun gnus-summary-search-forward (&optional unread subject backward)
9679 "Search forward for an article.
9680 If UNREAD, look for unread articles. If SUBJECT, look for
9681 articles with that subject. If BACKWARD, search backward instead."
9682 (cond (subject (gnus-summary-find-subject subject unread backward))
9683 (backward (gnus-summary-find-prev unread))
9684 (t (gnus-summary-find-next unread))))
9686 (defun gnus-recenter (&optional n)
9687 "Center point in window and redisplay frame.
9688 Also do horizontal recentering."
9690 (when (and gnus-auto-center-summary
9691 (not (eq gnus-auto-center-summary 'vertical)))
9692 (gnus-horizontal-recenter))
9695 (defun gnus-summary-recenter ()
9696 "Center point in the summary window.
9697 If `gnus-auto-center-summary' is nil, or the article buffer isn't
9698 displayed, no centering will be performed."
9699 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
9700 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
9701 (let* ((top (cond ((< (window-height) 4) 0)
9702 ((< (window-height) 7) 1)
9704 (height (1- (window-height)))
9705 (bottom (save-excursion (goto-char (point-max))
9706 (forward-line (- height))
9708 (window (get-buffer-window (current-buffer))))
9709 ;; The user has to want it.
9710 (when gnus-auto-center-summary
9711 (when (get-buffer-window gnus-article-buffer)
9712 ;; Only do recentering when the article buffer is displayed,
9713 ;; Set the window start to either `bottom', which is the biggest
9714 ;; possible valid number, or the second line from the top,
9715 ;; whichever is the least.
9717 window (min bottom (save-excursion
9718 (forward-line (- top)) (point)))))
9719 ;; Do horizontal recentering while we're at it.
9720 (when (and (get-buffer-window (current-buffer) t)
9721 (not (eq gnus-auto-center-summary 'vertical)))
9722 (let ((selected (selected-window)))
9723 (select-window (get-buffer-window (current-buffer) t))
9724 (gnus-summary-position-point)
9725 (gnus-horizontal-recenter)
9726 (select-window selected))))))
9728 (defun gnus-horizontal-recenter ()
9729 "Recenter the current buffer horizontally."
9730 (if (< (current-column) (/ (window-width) 2))
9731 (set-window-hscroll (get-buffer-window (current-buffer) t) 0)
9732 (let* ((orig (point))
9733 (end (window-end (get-buffer-window (current-buffer) t)))
9735 ;; Find the longest line currently displayed in the window.
9736 (goto-char (window-start))
9737 (while (and (not (eobp))
9740 (setq max (max max (current-column)))
9743 ;; Scroll horizontally to center (sort of) the point.
9744 (if (> max (window-width))
9746 (get-buffer-window (current-buffer) t)
9747 (min (- (current-column) (/ (window-width) 3))
9748 (+ 2 (- max (window-width)))))
9749 (set-window-hscroll (get-buffer-window (current-buffer) t) 0))
9752 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
9753 (defun gnus-short-group-name (group &optional levels)
9754 "Collapse GROUP name LEVELS."
9761 (while (string-match "\\." group skip)
9762 (setq skip (match-end 0)
9765 (if (string-match ":" group)
9766 (setq foreign (substring group 0 (match-end 0))
9767 group (substring group (match-end 0))))
9769 (if (and (string-match "\\." group)
9770 (> levels (- gnus-group-uncollapsed-levels 1)))
9771 (setq name (concat name (substring group 0 1))
9772 group (substring group (match-end 0))
9774 name (concat name "."))
9775 (setq name (concat foreign name group)
9779 (defun gnus-summary-jump-to-group (newsgroup)
9780 "Move point to NEWSGROUP in group mode buffer."
9781 ;; Keep update point of group mode buffer if visible.
9782 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
9783 (save-window-excursion
9784 ;; Take care of tree window mode.
9785 (if (get-buffer-window gnus-group-buffer)
9786 (pop-to-buffer gnus-group-buffer))
9787 (gnus-group-jump-to-group newsgroup))
9789 ;; Take care of tree window mode.
9790 (if (get-buffer-window gnus-group-buffer)
9791 (pop-to-buffer gnus-group-buffer)
9792 (set-buffer gnus-group-buffer))
9793 (gnus-group-jump-to-group newsgroup))))
9795 ;; This function returns a list of article numbers based on the
9796 ;; difference between the ranges of read articles in this group and
9797 ;; the range of active articles.
9798 (defun gnus-list-of-unread-articles (group)
9799 (let* ((read (gnus-info-read (gnus-get-info group)))
9800 (active (gnus-active group))
9803 ;; If none are read, then all are unread.
9805 (setq first (car active))
9806 ;; If the range of read articles is a single range, then the
9807 ;; first unread article is the article after the last read
9808 ;; article. Sounds logical, doesn't it?
9809 (if (not (listp (cdr read)))
9810 (setq first (1+ (cdr read)))
9811 ;; `read' is a list of ranges.
9812 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
9817 (while (< first nlast)
9818 (setq unread (cons first unread))
9819 (setq first (1+ first))))
9820 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
9821 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
9822 (setq read (cdr read)))))
9823 ;; And add the last unread articles.
9824 (while (<= first last)
9825 (setq unread (cons first unread))
9826 (setq first (1+ first)))
9827 ;; Return the list of unread articles.
9830 (defun gnus-list-of-read-articles (group)
9831 "Return a list of unread, unticked and non-dormant articles."
9832 (let* ((info (gnus-get-info group))
9833 (marked (gnus-info-marks info))
9834 (active (gnus-active group)))
9836 (gnus-set-difference
9837 (gnus-sorted-complement
9838 (gnus-uncompress-range active)
9839 (gnus-list-of-unread-articles group))
9841 (gnus-uncompress-range (cdr (assq 'dormant marked)))
9842 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
9844 ;; Various summary commands
9846 (defun gnus-summary-universal-argument (arg)
9847 "Perform any operation on all articles that are process/prefixed."
9849 (gnus-set-global-variables)
9850 (let ((articles (gnus-summary-work-articles arg))
9857 (substitute-command-keys
9858 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
9861 (gnus-error 1 "Undefined key")
9864 (gnus-summary-goto-subject (setq article (pop articles)))
9865 (command-execute func)
9866 (gnus-summary-remove-process-mark article)))))
9867 (gnus-summary-position-point))
9869 (defun gnus-summary-toggle-truncation (&optional arg)
9870 "Toggle truncation of summary lines.
9871 With arg, turn line truncation on iff arg is positive."
9873 (setq truncate-lines
9874 (if (null arg) (not truncate-lines)
9875 (> (prefix-numeric-value arg) 0)))
9878 (defun gnus-summary-reselect-current-group (&optional all rescan)
9879 "Exit and then reselect the current newsgroup.
9880 The prefix argument ALL means to select all articles."
9882 (gnus-set-global-variables)
9883 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
9884 (error "Ephemeral groups can't be reselected"))
9885 (let ((current-subject (gnus-summary-article-number))
9886 (group gnus-newsgroup-name))
9887 (setq gnus-newsgroup-begin nil)
9889 ;; We have to adjust the point of group mode buffer because the
9890 ;; current point was moved to the next unread newsgroup by
9892 (gnus-summary-jump-to-group group)
9895 (gnus-group-get-new-news-this-group 1)))
9896 (gnus-group-read-group all t)
9897 (gnus-summary-goto-subject current-subject)))
9899 (defun gnus-summary-rescan-group (&optional all)
9900 "Exit the newsgroup, ask for new articles, and select the newsgroup."
9902 (gnus-summary-reselect-current-group all t))
9904 (defun gnus-summary-update-info ()
9905 (let* ((group gnus-newsgroup-name))
9906 (when gnus-newsgroup-kill-headers
9907 (setq gnus-newsgroup-killed
9908 (gnus-compress-sequence
9910 (gnus-set-sorted-intersection
9911 (gnus-uncompress-range gnus-newsgroup-killed)
9912 (setq gnus-newsgroup-unselected
9913 (sort gnus-newsgroup-unselected '<)))
9914 (setq gnus-newsgroup-unreads
9915 (sort gnus-newsgroup-unreads '<))) t)))
9916 (unless (listp (cdr gnus-newsgroup-killed))
9917 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
9918 (let ((headers gnus-newsgroup-headers))
9919 (run-hooks 'gnus-exit-group-hook)
9920 (unless gnus-save-score
9921 (setq gnus-newsgroup-scored nil))
9922 ;; Set the new ranges of read articles.
9923 (gnus-update-read-articles
9924 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
9925 ;; Set the current article marks.
9927 ;; Do the cross-ref thing.
9928 (when gnus-use-cross-reference
9929 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
9930 ;; Do adaptive scoring, and possibly save score files.
9931 (when gnus-newsgroup-adaptive
9932 (gnus-score-adaptive))
9933 (when gnus-use-scoring
9935 ;; Do not switch windows but change the buffer to work.
9936 (set-buffer gnus-group-buffer)
9937 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
9938 (gnus-group-update-group group)))))
9940 (defun gnus-summary-exit (&optional temporary)
9941 "Exit reading current newsgroup, and then return to group selection mode.
9942 gnus-exit-group-hook is called with no arguments if that value is non-nil."
9944 (gnus-set-global-variables)
9945 (gnus-kill-save-kill-buffer)
9946 (let* ((group gnus-newsgroup-name)
9947 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
9949 (buf (current-buffer)))
9950 (run-hooks 'gnus-summary-prepare-exit-hook)
9951 ;; If we have several article buffers, we kill them at exit.
9952 (unless gnus-single-article-buffer
9953 (gnus-kill-buffer gnus-original-article-buffer)
9954 (setq gnus-article-current nil))
9955 (when gnus-use-cache
9956 (gnus-cache-possibly-remove-articles)
9957 (gnus-cache-save-buffers))
9958 (when gnus-use-trees
9959 (gnus-tree-close group))
9960 ;; Make all changes in this group permanent.
9962 (gnus-summary-update-info))
9963 (gnus-close-group group)
9964 ;; Make sure where I was, and go to next newsgroup.
9965 (set-buffer gnus-group-buffer)
9967 (gnus-group-jump-to-group group))
9968 (run-hooks 'gnus-summary-exit-hook)
9970 (gnus-group-next-unread-group 1))
9973 ;; If we have several article buffers, we kill them at exit.
9974 (unless gnus-single-article-buffer
9975 (gnus-kill-buffer gnus-article-buffer)
9976 (gnus-kill-buffer gnus-original-article-buffer)
9977 (setq gnus-article-current nil))
9979 (if (not gnus-kill-summary-on-exit)
9980 (gnus-deaden-summary)
9981 ;; We set all buffer-local variables to nil. It is unclear why
9982 ;; this is needed, but if we don't, buffer-local variables are
9983 ;; not garbage-collected, it seems. This would the lead to en
9984 ;; ever-growing Emacs.
9985 (gnus-summary-clear-local-variables)
9986 (when (get-buffer gnus-article-buffer)
9987 (bury-buffer gnus-article-buffer))
9988 ;; We clear the global counterparts of the buffer-local
9989 ;; variables as well, just to be on the safe side.
9990 (gnus-configure-windows 'group 'force)
9991 (gnus-summary-clear-local-variables)
9992 ;; Return to group mode buffer.
9993 (if (eq mode 'gnus-summary-mode)
9994 (gnus-kill-buffer buf)))
9995 (setq gnus-current-select-method gnus-select-method)
9996 (pop-to-buffer gnus-group-buffer)
9997 ;; Clear the current group name.
9998 (if (not quit-config)
10000 (gnus-group-jump-to-group group)
10001 (gnus-group-next-unread-group 1)
10002 (gnus-configure-windows 'group 'force))
10003 (if (not (buffer-name (car quit-config)))
10004 (gnus-configure-windows 'group 'force)
10005 (set-buffer (car quit-config))
10006 (and (eq major-mode 'gnus-summary-mode)
10007 (gnus-set-global-variables))
10008 (gnus-configure-windows (cdr quit-config))))
10009 (unless quit-config
10010 (setq gnus-newsgroup-name nil)))))
10012 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
10013 (defun gnus-summary-exit-no-update (&optional no-questions)
10014 "Quit reading current newsgroup without updating read article info."
10016 (gnus-set-global-variables)
10017 (let* ((group gnus-newsgroup-name)
10018 (quit-config (gnus-group-quit-config group)))
10019 (when (or no-questions
10021 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
10022 ;; If we have several article buffers, we kill them at exit.
10023 (unless gnus-single-article-buffer
10024 (gnus-kill-buffer gnus-article-buffer)
10025 (gnus-kill-buffer gnus-original-article-buffer)
10026 (setq gnus-article-current nil))
10027 (if (not gnus-kill-summary-on-exit)
10028 (gnus-deaden-summary)
10029 (gnus-close-group group)
10030 (gnus-summary-clear-local-variables)
10031 (set-buffer gnus-group-buffer)
10032 (gnus-summary-clear-local-variables)
10033 (when (get-buffer gnus-summary-buffer)
10034 (kill-buffer gnus-summary-buffer)))
10035 (unless gnus-single-article-buffer
10036 (setq gnus-article-current nil))
10037 (when gnus-use-trees
10038 (gnus-tree-close group))
10039 (when (get-buffer gnus-article-buffer)
10040 (bury-buffer gnus-article-buffer))
10041 ;; Return to the group buffer.
10042 (gnus-configure-windows 'group 'force)
10043 ;; Clear the current group name.
10044 (setq gnus-newsgroup-name nil)
10045 (when (equal (gnus-group-group-name) group)
10046 (gnus-group-next-unread-group 1))
10048 (if (not (buffer-name (car quit-config)))
10049 (gnus-configure-windows 'group 'force)
10050 (set-buffer (car quit-config))
10051 (when (eq major-mode 'gnus-summary-mode)
10052 (gnus-set-global-variables))
10053 (gnus-configure-windows (cdr quit-config)))))))
10055 ;;; Dead summaries.
10057 (defvar gnus-dead-summary-mode-map nil)
10059 (if gnus-dead-summary-mode-map
10061 (setq gnus-dead-summary-mode-map (make-keymap))
10062 (suppress-keymap gnus-dead-summary-mode-map)
10063 (substitute-key-definition
10064 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
10065 (let ((keys '("\C-d" "\r" "\177")))
10067 (define-key gnus-dead-summary-mode-map
10068 (pop keys) 'gnus-summary-wake-up-the-dead))))
10070 (defvar gnus-dead-summary-mode nil
10071 "Minor mode for Gnus summary buffers.")
10073 (defun gnus-dead-summary-mode (&optional arg)
10074 "Minor mode for Gnus summary buffers."
10076 (when (eq major-mode 'gnus-summary-mode)
10077 (make-local-variable 'gnus-dead-summary-mode)
10078 (setq gnus-dead-summary-mode
10079 (if (null arg) (not gnus-dead-summary-mode)
10080 (> (prefix-numeric-value arg) 0)))
10081 (when gnus-dead-summary-mode
10082 (unless (assq 'gnus-dead-summary-mode minor-mode-alist)
10083 (push '(gnus-dead-summary-mode " Dead") minor-mode-alist))
10084 (unless (assq 'gnus-dead-summary-mode minor-mode-map-alist)
10085 (push (cons 'gnus-dead-summary-mode gnus-dead-summary-mode-map)
10086 minor-mode-map-alist)))))
10088 (defun gnus-deaden-summary ()
10089 "Make the current summary buffer into a dead summary buffer."
10090 ;; Kill any previous dead summary buffer.
10091 (when (and gnus-dead-summary
10092 (buffer-name gnus-dead-summary))
10094 (set-buffer gnus-dead-summary)
10095 (when gnus-dead-summary-mode
10096 (kill-buffer (current-buffer)))))
10097 ;; Make this the current dead summary.
10098 (setq gnus-dead-summary (current-buffer))
10099 (gnus-dead-summary-mode 1)
10100 (let ((name (buffer-name)))
10101 (when (string-match "Summary" name)
10103 (concat (substring name 0 (match-beginning 0)) "Dead "
10104 (substring name (match-beginning 0))) t))))
10106 (defun gnus-kill-or-deaden-summary (buffer)
10107 "Kill or deaden the summary BUFFER."
10108 (when (and (buffer-name buffer)
10109 (not gnus-single-article-buffer))
10111 (set-buffer buffer)
10112 (gnus-kill-buffer gnus-article-buffer)
10113 (gnus-kill-buffer gnus-original-article-buffer)))
10114 (cond (gnus-kill-summary-on-exit
10115 (when (and gnus-use-trees
10116 (and (get-buffer buffer)
10117 (buffer-name (get-buffer buffer))))
10119 (set-buffer (get-buffer buffer))
10120 (gnus-tree-close gnus-newsgroup-name)))
10121 (gnus-kill-buffer buffer))
10122 ((and (get-buffer buffer)
10123 (buffer-name (get-buffer buffer)))
10125 (set-buffer buffer)
10126 (gnus-deaden-summary)))))
10128 (defun gnus-summary-wake-up-the-dead (&rest args)
10129 "Wake up the dead summary buffer."
10131 (gnus-dead-summary-mode -1)
10132 (let ((name (buffer-name)))
10133 (when (string-match "Dead " name)
10135 (concat (substring name 0 (match-beginning 0))
10136 (substring name (match-end 0))) t)))
10137 (gnus-message 3 "This dead summary is now alive again"))
10139 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
10140 (defun gnus-summary-fetch-faq (&optional faq-dir)
10141 "Fetch the FAQ for the current group.
10142 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
10146 (if current-prefix-arg
10148 "Faq dir: " (and (listp gnus-group-faq-directory)
10149 gnus-group-faq-directory)))))
10150 (let (gnus-faq-buffer)
10151 (and (setq gnus-faq-buffer
10152 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
10153 (gnus-configure-windows 'summary-faq))))
10155 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
10156 (defun gnus-summary-describe-group (&optional force)
10157 "Describe the current newsgroup."
10159 (gnus-group-describe-group force gnus-newsgroup-name))
10161 (defun gnus-summary-describe-briefly ()
10162 "Describe summary mode commands briefly."
10165 (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")))
10167 ;; Walking around group mode buffer from summary mode.
10169 (defun gnus-summary-next-group (&optional no-article target-group backward)
10170 "Exit current newsgroup and then select next unread newsgroup.
10171 If prefix argument NO-ARTICLE is non-nil, no article is selected
10172 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
10173 previous group instead."
10175 (gnus-set-global-variables)
10176 (let ((current-group gnus-newsgroup-name)
10177 (current-buffer (current-buffer))
10179 ;; First we semi-exit this group to update Xrefs and all variables.
10180 ;; We can't do a real exit, because the window conf must remain
10181 ;; the same in case the user is prompted for info, and we don't
10182 ;; want the window conf to change before that...
10183 (gnus-summary-exit t)
10184 (while (not entered)
10185 ;; Then we find what group we are supposed to enter.
10186 (set-buffer gnus-group-buffer)
10187 (gnus-group-jump-to-group current-group)
10190 (if (eq gnus-keep-same-level 'best)
10191 (gnus-summary-best-group gnus-newsgroup-name)
10192 (gnus-summary-search-group backward gnus-keep-same-level))))
10193 (if (not target-group)
10194 ;; There are no further groups, so we return to the group
10197 (gnus-message 5 "Returning to the group buffer")
10199 (set-buffer current-buffer)
10200 (gnus-summary-exit))
10201 ;; We try to enter the target group.
10202 (gnus-group-jump-to-group target-group)
10203 (let ((unreads (gnus-group-group-unread)))
10204 (if (and (or (eq t unreads)
10205 (and unreads (not (zerop unreads))))
10206 (gnus-summary-read-group
10207 target-group nil no-article current-buffer))
10209 (setq current-group target-group
10210 target-group nil)))))))
10212 (defun gnus-summary-prev-group (&optional no-article)
10213 "Exit current newsgroup and then select previous unread newsgroup.
10214 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
10216 (gnus-summary-next-group no-article nil t))
10218 ;; Walking around summary lines.
10220 (defun gnus-summary-first-subject (&optional unread)
10221 "Go to the first unread subject.
10222 If UNREAD is non-nil, go to the first unread article.
10223 Returns the article selected or nil if there are no unread articles."
10228 ((null gnus-newsgroup-data)
10229 (gnus-message 3 "No articles in the group")
10231 ;; Pick the first article.
10233 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
10234 (gnus-data-number (car gnus-newsgroup-data)))
10235 ;; No unread articles.
10236 ((null gnus-newsgroup-unreads)
10237 (gnus-message 3 "No more unread articles")
10239 ;; Find the first unread article.
10241 (let ((data gnus-newsgroup-data))
10243 (not (gnus-data-unread-p (car data))))
10244 (setq data (cdr data)))
10247 (goto-char (gnus-data-pos (car data)))
10248 (gnus-data-number (car data)))))))
10249 (gnus-summary-position-point)))
10251 (defun gnus-summary-next-subject (n &optional unread dont-display)
10252 "Go to next N'th summary line.
10253 If N is negative, go to the previous N'th subject line.
10254 If UNREAD is non-nil, only unread articles are selected.
10255 The difference between N and the actual number of steps taken is
10258 (let ((backward (< n 0))
10260 (while (and (> n 0)
10262 (gnus-summary-find-prev unread)
10263 (gnus-summary-find-next unread)))
10265 (if (/= 0 n) (gnus-message 7 "No more%s articles"
10266 (if unread " unread" "")))
10267 (unless dont-display
10268 (gnus-summary-recenter)
10269 (gnus-summary-position-point))
10272 (defun gnus-summary-next-unread-subject (n)
10273 "Go to next N'th unread summary line."
10275 (gnus-summary-next-subject n t))
10277 (defun gnus-summary-prev-subject (n &optional unread)
10278 "Go to previous N'th summary line.
10279 If optional argument UNREAD is non-nil, only unread article is selected."
10281 (gnus-summary-next-subject (- n) unread))
10283 (defun gnus-summary-prev-unread-subject (n)
10284 "Go to previous N'th unread summary line."
10286 (gnus-summary-next-subject (- n) t))
10288 (defun gnus-summary-goto-subject (article &optional force silent)
10289 "Go the subject line of ARTICLE.
10290 If FORCE, also allow jumping to articles not currently shown."
10292 (data (gnus-data-find article)))
10293 ;; We read in the article if we have to.
10296 (gnus-summary-insert-subject article (and (vectorp force) force) t)
10297 (setq data (gnus-data-find article)))
10302 (gnus-message 3 "Can't find article %d" article))
10304 (goto-char (gnus-data-pos data))
10307 ;; Walking around summary lines with displaying articles.
10309 (defun gnus-summary-expand-window (&optional arg)
10310 "Make the summary buffer take up the entire Emacs frame.
10311 Given a prefix, will force an `article' buffer configuration."
10313 (gnus-set-global-variables)
10315 (gnus-configure-windows 'article 'force)
10316 (gnus-configure-windows 'summary 'force)))
10318 (defun gnus-summary-display-article (article &optional all-header)
10319 "Display ARTICLE in article buffer."
10320 (gnus-set-global-variables)
10324 (if gnus-summary-display-article-function
10325 (funcall gnus-summary-display-article-function article all-header)
10326 (gnus-article-prepare article all-header))
10327 (run-hooks 'gnus-select-article-hook)
10328 (unless (zerop gnus-current-article)
10329 (gnus-summary-goto-subject gnus-current-article))
10330 (gnus-summary-recenter)
10331 (when gnus-use-trees
10332 (gnus-possibly-generate-tree article)
10333 (gnus-highlight-selected-tree article))
10334 ;; Successfully display article.
10335 (gnus-article-set-window-start
10336 (cdr (assq article gnus-newsgroup-bookmarks))))))
10338 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
10339 "Select the current article.
10340 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
10341 non-nil, the article will be re-fetched even if it already present in
10342 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
10344 ;; Make sure we are in the summary buffer to work around bbdb bug.
10345 (unless (eq major-mode 'gnus-summary-mode)
10346 (set-buffer gnus-summary-buffer))
10347 (let ((article (or article (gnus-summary-article-number)))
10348 (all-headers (not (not all-headers))) ;Must be T or NIL.
10349 gnus-summary-display-article-function
10352 (gnus-summary-article-pseudo-p article)
10353 (error "This is a pseudo-article."))
10356 (set-buffer gnus-summary-buffer)
10357 (if (or (and gnus-single-article-buffer
10358 (or (null gnus-current-article)
10359 (null gnus-article-current)
10360 (null (get-buffer gnus-article-buffer))
10361 (not (eq article (cdr gnus-article-current)))
10362 (not (equal (car gnus-article-current)
10363 gnus-newsgroup-name))))
10364 (and (not gnus-single-article-buffer)
10365 (or (null gnus-current-article)
10366 (not (eq gnus-current-article article))))
10368 ;; The requested article is different from the current article.
10370 (gnus-summary-display-article article all-headers)
10371 (setq did article))
10372 (if (or all-headers gnus-show-all-headers)
10373 (gnus-article-show-all-headers))
10376 (gnus-article-set-window-start
10377 (cdr (assq article gnus-newsgroup-bookmarks)))))))
10379 (defun gnus-summary-set-current-mark (&optional current-mark)
10380 "Obsolete function."
10383 (defun gnus-summary-next-article (&optional unread subject backward push)
10384 "Select the next article.
10385 If UNREAD, only unread articles are selected.
10386 If SUBJECT, only articles with SUBJECT are selected.
10387 If BACKWARD, the previous article is selected instead of the next."
10389 (gnus-set-global-variables)
10391 ;; Is there such an article?
10392 ((and (gnus-summary-search-forward unread subject backward)
10393 (or (gnus-summary-display-article (gnus-summary-article-number))
10394 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
10395 (gnus-summary-position-point))
10396 ;; If not, we try the first unread, if that is wanted.
10398 gnus-auto-select-same
10399 (or (gnus-summary-first-unread-article)
10400 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
10401 (gnus-summary-position-point)
10402 (gnus-message 6 "Wrapped"))
10403 ;; Try to get next/previous article not displayed in this group.
10404 ((and gnus-auto-extend-newsgroup
10405 (not unread) (not subject))
10406 (gnus-summary-goto-article
10407 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
10409 ;; Go to next/previous group.
10411 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
10412 (gnus-summary-jump-to-group gnus-newsgroup-name))
10413 (let ((cmd last-command-char)
10415 (if (eq gnus-keep-same-level 'best)
10416 (gnus-summary-best-group gnus-newsgroup-name)
10417 (gnus-summary-search-group backward gnus-keep-same-level))))
10418 ;; For some reason, the group window gets selected. We change
10420 (select-window (get-buffer-window (current-buffer)))
10421 ;; Select next unread newsgroup automagically.
10423 ((or (not gnus-auto-select-next)
10425 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
10426 ((or (eq gnus-auto-select-next 'quietly)
10427 (and (eq gnus-auto-select-next 'slightly-quietly)
10429 (and (eq gnus-auto-select-next 'almost-quietly)
10430 (gnus-summary-last-article-p)))
10432 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
10433 (gnus-summary-exit)
10434 (gnus-message 7 "No more%s articles (%s)..."
10435 (if unread " unread" "")
10436 (if group (concat "selecting " group)
10438 (gnus-summary-next-group nil group backward)))
10440 (gnus-summary-walk-group-buffer
10441 gnus-newsgroup-name cmd unread backward)))))))
10443 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward)
10444 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
10445 (?\C-p (gnus-group-prev-unread-group 1))))
10446 keve key group ended)
10448 (set-buffer gnus-group-buffer)
10449 (gnus-summary-jump-to-group from-group)
10451 (if (eq gnus-keep-same-level 'best)
10452 (gnus-summary-best-group gnus-newsgroup-name)
10453 (gnus-summary-search-group backward gnus-keep-same-level))))
10456 5 "No more%s articles%s" (if unread " unread" "")
10458 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
10459 (format " (Type %s for %s [%s])"
10460 (single-key-description cmd) group
10461 (car (gnus-gethash group gnus-newsrc-hashtb)))
10462 (format " (Type %s to exit %s)"
10463 (single-key-description cmd)
10464 gnus-newsgroup-name)))
10465 ;; Confirm auto selection.
10466 (setq key (car (setq keve (gnus-read-event-char))))
10469 ((assq key keystrokes)
10470 (let ((obuf (current-buffer)))
10471 (switch-to-buffer gnus-group-buffer)
10473 (gnus-group-jump-to-group group))
10474 (eval (cadr (assq key keystrokes)))
10475 (setq group (gnus-group-group-name))
10476 (switch-to-buffer obuf))
10479 (if (or (not group)
10480 (gnus-ephemeral-group-p gnus-newsgroup-name))
10481 (gnus-summary-exit)
10482 (gnus-summary-next-group nil group backward)))
10484 (push (cdr keve) unread-command-events))))))
10486 (defun gnus-read-event-char ()
10487 "Get the next event."
10488 (let ((event (read-event)))
10489 (cons (and (numberp event) event) event)))
10491 (defun gnus-summary-next-unread-article ()
10492 "Select unread article after current one."
10494 (gnus-summary-next-article t (and gnus-auto-select-same
10495 (gnus-summary-article-subject))))
10497 (defun gnus-summary-prev-article (&optional unread subject)
10498 "Select the article after the current one.
10499 If UNREAD is non-nil, only unread articles are selected."
10501 (gnus-summary-next-article unread subject t))
10503 (defun gnus-summary-prev-unread-article ()
10504 "Select unred article before current one."
10506 (gnus-summary-prev-article t (and gnus-auto-select-same
10507 (gnus-summary-article-subject))))
10509 (defun gnus-summary-next-page (&optional lines circular)
10510 "Show next page of the selected article.
10511 If at the end of the current article, select the next article.
10512 LINES says how many lines should be scrolled up.
10514 If CIRCULAR is non-nil, go to the start of the article instead of
10515 selecting the next article when reaching the end of the current
10518 (setq gnus-summary-buffer (current-buffer))
10519 (gnus-set-global-variables)
10520 (let ((article (gnus-summary-article-number))
10522 (gnus-configure-windows 'article)
10523 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
10524 (if (and (eq gnus-summary-goto-unread 'never)
10525 (not (gnus-summary-last-article-p article)))
10526 (gnus-summary-next-article)
10527 (gnus-summary-next-unread-article))
10528 (if (or (null gnus-current-article)
10529 (null gnus-article-current)
10530 (/= article (cdr gnus-article-current))
10531 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10532 ;; Selected subject is different from current article's.
10533 (gnus-summary-display-article article)
10534 (gnus-eval-in-buffer-window gnus-article-buffer
10535 (setq endp (gnus-article-next-page lines)))
10538 (gnus-summary-beginning-of-article))
10540 (gnus-message 3 "End of message"))
10542 (if (and (eq gnus-summary-goto-unread 'never)
10543 (not (gnus-summary-last-article-p article)))
10544 (gnus-summary-next-article)
10545 (gnus-summary-next-unread-article)))))))
10546 (gnus-summary-recenter)
10547 (gnus-summary-position-point)))
10549 (defun gnus-summary-prev-page (&optional lines)
10550 "Show previous page of selected article.
10551 Argument LINES specifies lines to be scrolled down."
10553 (gnus-set-global-variables)
10554 (let ((article (gnus-summary-article-number)))
10555 (gnus-configure-windows 'article)
10556 (if (or (null gnus-current-article)
10557 (null gnus-article-current)
10558 (/= article (cdr gnus-article-current))
10559 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10560 ;; Selected subject is different from current article's.
10561 (gnus-summary-display-article article)
10562 (gnus-summary-recenter)
10563 (gnus-eval-in-buffer-window gnus-article-buffer
10564 (gnus-article-prev-page lines))))
10565 (gnus-summary-position-point))
10567 (defun gnus-summary-scroll-up (lines)
10568 "Scroll up (or down) one line current article.
10569 Argument LINES specifies lines to be scrolled up (or down if negative)."
10571 (gnus-set-global-variables)
10572 (gnus-configure-windows 'article)
10573 (gnus-summary-show-thread)
10574 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
10575 (gnus-eval-in-buffer-window gnus-article-buffer
10577 (if (gnus-article-next-page lines)
10578 (gnus-message 3 "End of message")))
10580 (gnus-article-prev-page (- lines))))))
10581 (gnus-summary-recenter)
10582 (gnus-summary-position-point))
10584 (defun gnus-summary-next-same-subject ()
10585 "Select next article which has the same subject as current one."
10587 (gnus-set-global-variables)
10588 (gnus-summary-next-article nil (gnus-summary-article-subject)))
10590 (defun gnus-summary-prev-same-subject ()
10591 "Select previous article which has the same subject as current one."
10593 (gnus-set-global-variables)
10594 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
10596 (defun gnus-summary-next-unread-same-subject ()
10597 "Select next unread article which has the same subject as current one."
10599 (gnus-set-global-variables)
10600 (gnus-summary-next-article t (gnus-summary-article-subject)))
10602 (defun gnus-summary-prev-unread-same-subject ()
10603 "Select previous unread article which has the same subject as current one."
10605 (gnus-set-global-variables)
10606 (gnus-summary-prev-article t (gnus-summary-article-subject)))
10608 (defun gnus-summary-first-unread-article ()
10609 "Select the first unread article.
10610 Return nil if there are no unread articles."
10612 (gnus-set-global-variables)
10614 (if (gnus-summary-first-subject t)
10616 (gnus-summary-show-thread)
10617 (gnus-summary-first-subject t)
10618 (gnus-summary-display-article (gnus-summary-article-number))))
10619 (gnus-summary-position-point)))
10621 (defun gnus-summary-best-unread-article ()
10622 "Select the unread article with the highest score."
10624 (gnus-set-global-variables)
10625 (let ((best -1000000)
10626 (data gnus-newsgroup-data)
10629 (and (gnus-data-unread-p (car data))
10631 (gnus-summary-article-score (gnus-data-number (car data))))
10634 article (gnus-data-number (car data))))
10635 (setq data (cdr data)))
10638 (gnus-summary-goto-article article)
10639 (error "No unread articles"))
10640 (gnus-summary-position-point))))
10642 (defun gnus-summary-last-subject ()
10643 "Go to the last displayed subject line in the group."
10644 (let ((article (gnus-data-number (car (gnus-data-list t)))))
10646 (gnus-summary-goto-subject article))))
10648 (defun gnus-summary-goto-article (article &optional all-headers force)
10649 "Fetch ARTICLE and display it if it exists.
10650 If ALL-HEADERS is non-nil, no header lines are hidden."
10656 (mapcar (lambda (number) (list (int-to-string number)))
10657 gnus-newsgroup-limit)))
10661 (if (gnus-summary-goto-subject article force)
10662 (gnus-summary-display-article article all-headers)
10663 (gnus-message 4 "Couldn't go to article %s" article) nil)
10664 (gnus-summary-position-point)))
10666 (defun gnus-summary-goto-last-article ()
10667 "Go to the previously read article."
10670 (and gnus-last-article
10671 (gnus-summary-goto-article gnus-last-article))
10672 (gnus-summary-position-point)))
10674 (defun gnus-summary-pop-article (number)
10675 "Pop one article off the history and go to the previous.
10676 NUMBER articles will be popped off."
10679 (setq gnus-newsgroup-history
10680 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
10682 (gnus-summary-goto-article (car to))
10683 (error "Article history empty")))
10684 (gnus-summary-position-point))
10686 ;; Summary commands and functions for limiting the summary buffer.
10688 (defun gnus-summary-limit-to-articles (n)
10689 "Limit the summary buffer to the next N articles.
10690 If not given a prefix, use the process marked articles instead."
10692 (gnus-set-global-variables)
10694 (let ((articles (gnus-summary-work-articles n)))
10695 (setq gnus-newsgroup-processable nil)
10696 (gnus-summary-limit articles))
10697 (gnus-summary-position-point)))
10699 (defun gnus-summary-pop-limit (&optional total)
10700 "Restore the previous limit.
10701 If given a prefix, remove all limits."
10703 (gnus-set-global-variables)
10705 (setq gnus-newsgroup-limits
10706 (list (mapcar (lambda (h) (mail-header-number h))
10707 gnus-newsgroup-headers))))
10708 (unless gnus-newsgroup-limits
10709 (error "No limit to pop"))
10711 (gnus-summary-limit nil 'pop)
10712 (gnus-summary-position-point)))
10714 (defun gnus-summary-limit-to-subject (subject &optional header)
10715 "Limit the summary buffer to articles that have subjects that match a regexp."
10716 (interactive "sRegexp: ")
10718 (setq header "subject"))
10719 (when (not (equal "" subject))
10721 (let ((articles (gnus-summary-find-matching
10722 (or header "subject") subject 'all)))
10723 (or articles (error "Found no matches for \"%s\"" subject))
10724 (gnus-summary-limit articles))
10725 (gnus-summary-position-point))))
10727 (defun gnus-summary-limit-to-author (from)
10728 "Limit the summary buffer to articles that have authors that match a regexp."
10729 (interactive "sRegexp: ")
10730 (gnus-summary-limit-to-subject from "from"))
10732 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10734 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10736 (defun gnus-summary-limit-to-unread (&optional all)
10737 "Limit the summary buffer to articles that are not marked as read.
10738 If ALL is non-nil, limit strictly to unread articles."
10741 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
10742 (gnus-summary-limit-to-marks
10743 ;; Concat all the marks that say that an article is read and have
10745 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
10746 gnus-killed-mark gnus-kill-file-mark
10747 gnus-low-score-mark gnus-expirable-mark
10748 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark)
10751 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10752 (make-obsolete 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10754 (defun gnus-summary-limit-to-marks (marks &optional reverse)
10755 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
10756 If REVERSE, limit the summary buffer to articles that are not marked
10757 with MARKS. MARKS can either be a string of marks or a list of marks.
10758 Returns how many articles were removed."
10759 (interactive "sMarks: ")
10760 (gnus-set-global-variables)
10762 (let ((data gnus-newsgroup-data)
10763 (marks (if (listp marks) marks
10764 (append marks nil))) ; Transform to list.
10767 (and (if reverse (not (memq (gnus-data-mark (car data)) marks))
10768 (memq (gnus-data-mark (car data)) marks))
10769 (setq articles (cons (gnus-data-number (car data)) articles)))
10770 (setq data (cdr data)))
10771 (gnus-summary-limit articles))
10772 (gnus-summary-position-point)))
10774 (defun gnus-summary-limit-to-score (&optional score)
10775 "Limit to articles with score at or above SCORE."
10777 (gnus-set-global-variables)
10778 (setq score (if score
10779 (prefix-numeric-value score)
10780 (or gnus-summary-default-score 0)))
10781 (let ((data gnus-newsgroup-data)
10784 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
10786 (push (gnus-data-number (car data)) articles))
10787 (setq data (cdr data)))
10789 (gnus-summary-limit articles)
10790 (gnus-summary-position-point))))
10792 (defun gnus-summary-limit-include-dormant ()
10793 "Display all the hidden articles that are marked as dormant."
10795 (gnus-set-global-variables)
10796 (or gnus-newsgroup-dormant
10797 (error "There are no dormant articles in this group"))
10799 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
10800 (gnus-summary-position-point)))
10802 (defun gnus-summary-limit-exclude-dormant ()
10803 "Hide all dormant articles."
10805 (gnus-set-global-variables)
10807 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
10808 (gnus-summary-position-point)))
10810 (defun gnus-summary-limit-exclude-childless-dormant ()
10811 "Hide all dormant articles that have no children."
10813 (gnus-set-global-variables)
10814 (let ((data (gnus-data-list t))
10815 articles d children)
10816 ;; Find all articles that are either not dormant or have
10818 (while (setq d (pop data))
10819 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
10820 (and (setq children
10821 (gnus-article-children (gnus-data-number d)))
10824 (when (memq (car children) articles)
10829 (push (gnus-data-number d) articles)))
10830 ;; Do the limiting.
10832 (gnus-summary-limit articles)
10833 (gnus-summary-position-point))))
10835 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
10836 "Mark all unread excluded articles as read.
10837 If ALL, mark even excluded ticked and dormants as read."
10839 (let ((articles (gnus-sorted-complement
10841 (mapcar (lambda (h) (mail-header-number h))
10842 gnus-newsgroup-headers)
10844 (sort gnus-newsgroup-limit '<)))
10846 (setq gnus-newsgroup-unreads nil)
10848 (setq gnus-newsgroup-dormant nil
10849 gnus-newsgroup-marked nil
10850 gnus-newsgroup-reads
10852 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
10853 gnus-newsgroup-reads))
10854 (while (setq article (pop articles))
10855 (unless (or (memq article gnus-newsgroup-dormant)
10856 (memq article gnus-newsgroup-marked))
10857 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
10859 (defun gnus-summary-limit (articles &optional pop)
10861 ;; We pop the previous limit off the stack and use that.
10862 (setq articles (car gnus-newsgroup-limits)
10863 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
10864 ;; We use the new limit, so we push the old limit on the stack.
10865 (setq gnus-newsgroup-limits
10866 (cons gnus-newsgroup-limit gnus-newsgroup-limits)))
10868 (setq gnus-newsgroup-limit articles)
10869 (let ((total (length gnus-newsgroup-data))
10870 (data (gnus-data-find-list (gnus-summary-article-number)))
10872 ;; This will do all the work of generating the new summary buffer
10873 ;; according to the new limit.
10874 (gnus-summary-prepare)
10875 ;; Hide any threads, possibly.
10876 (and gnus-show-threads
10877 gnus-thread-hide-subtree
10878 (gnus-summary-hide-all-threads))
10879 ;; Try to return to the article you were at, or one in the
10882 ;; We try to find some article after the current one.
10884 (and (gnus-summary-goto-subject
10885 (gnus-data-number (car data)) nil t)
10888 (setq data (cdr data))))
10890 ;; If there is no data, that means that we were after the last
10891 ;; article. The same goes when we can't find any articles
10892 ;; after the current one.
10894 (goto-char (point-max))
10895 (gnus-summary-find-prev)))
10896 ;; We return how many articles were removed from the summary
10897 ;; buffer as a result of the new limit.
10898 (- total (length gnus-newsgroup-data))))
10900 (defsubst gnus-invisible-cut-children (threads)
10903 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
10908 (defsubst gnus-cut-thread (thread)
10909 "Go forwards in the thread until we find an article that we want to display."
10910 (when (or (eq gnus-fetch-old-headers 'some)
10911 (eq gnus-build-sparse-threads 'some)
10912 (eq gnus-build-sparse-threads 'more))
10913 ;; Deal with old-fetched headers and sparse threads.
10917 (memq (mail-header-number (car thread)) gnus-newsgroup-sparse)
10918 (memq (mail-header-number (car thread)) gnus-newsgroup-ancient))
10919 (or (<= (length (cdr thread)) 1)
10920 (gnus-invisible-cut-children (cdr thread))))
10921 (setq thread (cadr thread))))
10924 (defun gnus-cut-threads (threads)
10925 "Cut off all uninteresting articles from the beginning of threads."
10926 (when (or (eq gnus-fetch-old-headers 'some)
10927 (eq gnus-build-sparse-threads 'some)
10928 (eq gnus-build-sparse-threads 'more))
10929 (let ((th threads))
10931 (setcar th (gnus-cut-thread (car th)))
10932 (setq th (cdr th)))))
10933 ;; Remove nixed out threads.
10934 (delq nil threads))
10936 (defun gnus-summary-initial-limit (&optional show-if-empty)
10937 "Figure out what the initial limit is supposed to be on group entry.
10938 This entails weeding out unwanted dormants, low-scored articles,
10939 fetch-old-headers verbiage, and so on."
10940 ;; Most groups have nothing to remove.
10941 (if (or gnus-inhibit-limiting
10942 (and (null gnus-newsgroup-dormant)
10943 (not (eq gnus-fetch-old-headers 'some))
10944 (null gnus-summary-expunge-below)
10945 (not (eq gnus-build-sparse-threads 'some))
10946 (not (eq gnus-build-sparse-threads 'more))
10947 (null gnus-thread-expunge-below)
10948 (not gnus-use-nocem)))
10950 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10951 (setq gnus-newsgroup-limit nil)
10954 (unless (car (symbol-value node))
10955 ;; These threads have no parents -- they are roots.
10956 (let ((nodes (cdr (symbol-value node)))
10959 (if (and gnus-thread-expunge-below
10960 (< (gnus-thread-total-score (car nodes))
10961 gnus-thread-expunge-below))
10962 (gnus-expunge-thread (pop nodes))
10963 (setq thread (pop nodes))
10964 (gnus-summary-limit-children thread))))))
10965 gnus-newsgroup-dependencies)
10966 ;; If this limitation resulted in an empty group, we might
10967 ;; pop the previous limit and use it instead.
10968 (when (and (not gnus-newsgroup-limit)
10970 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
10971 gnus-newsgroup-limit))
10973 (defun gnus-summary-limit-children (thread)
10974 "Return 1 if this subthread is visible and 0 if it is not."
10975 ;; First we get the number of visible children to this thread. This
10976 ;; is done by recursing down the thread using this function, so this
10977 ;; will really go down to a leaf article first, before slowly
10978 ;; working its way up towards the root.
10982 (apply '+ (mapcar 'gnus-summary-limit-children
10985 (number (mail-header-number (car thread)))
10988 ;; If this article is dormant and has absolutely no visible
10989 ;; children, then this article isn't visible.
10990 (and (memq number gnus-newsgroup-dormant)
10992 ;; If this is "fetch-old-headered" and there is only one
10993 ;; visible child (or less), then we don't want this article.
10994 (and (eq gnus-fetch-old-headers 'some)
10995 (memq number gnus-newsgroup-ancient)
10997 ;; If this is a sparsely inserted article with no children,
10998 ;; we don't want it.
10999 (and (eq gnus-build-sparse-threads 'some)
11000 (memq number gnus-newsgroup-sparse)
11002 ;; If we use expunging, and this article is really
11003 ;; low-scored, then we don't want this article.
11004 (when (and gnus-summary-expunge-below
11006 (or (cdr (assq number gnus-newsgroup-scored))
11007 gnus-summary-default-score))
11008 gnus-summary-expunge-below))
11009 ;; We increase the expunge-tally here, but that has
11010 ;; nothing to do with the limits, really.
11011 (incf gnus-newsgroup-expunged-tally)
11012 ;; We also mark as read here, if that's wanted.
11013 (when (and gnus-summary-mark-below
11014 (< score gnus-summary-mark-below))
11015 (setq gnus-newsgroup-unreads
11016 (delq number gnus-newsgroup-unreads))
11017 (if gnus-newsgroup-auto-expire
11018 (push number gnus-newsgroup-expirable)
11019 (push (cons number gnus-low-score-mark)
11020 gnus-newsgroup-reads)))
11022 (and gnus-use-nocem
11023 (gnus-nocem-unwanted-article-p (mail-header-id (car thread)))))
11024 ;; Nope, invisible article.
11026 ;; Ok, this article is to be visible, so we add it to the limit
11028 (setq gnus-newsgroup-limit (cons number gnus-newsgroup-limit))
11031 (defun gnus-expunge-thread (thread)
11032 "Mark all articles in THREAD as read."
11033 (let* ((number (mail-header-number (car thread))))
11034 (incf gnus-newsgroup-expunged-tally)
11035 ;; We also mark as read here, if that's wanted.
11036 (setq gnus-newsgroup-unreads
11037 (delq number gnus-newsgroup-unreads))
11038 (if gnus-newsgroup-auto-expire
11039 (push number gnus-newsgroup-expirable)
11040 (push (cons number gnus-low-score-mark)
11041 gnus-newsgroup-reads)))
11042 ;; Go recursively through all subthreads.
11043 (mapcar 'gnus-expunge-thread (cdr thread)))
11045 ;; Summary article oriented commands
11047 (defun gnus-summary-refer-parent-article (n)
11048 "Refer parent article N times.
11049 The difference between N and the number of articles fetched is returned."
11051 (gnus-set-global-variables)
11055 (let* ((header (gnus-summary-article-header))
11057 ;; If we try to find the parent of the currently
11058 ;; displayed article, then we take a look at the actual
11059 ;; References header, since this is slightly more
11060 ;; reliable than the References field we got from the
11062 (if (and (eq (mail-header-number header)
11063 (cdr gnus-article-current))
11064 (equal gnus-newsgroup-name
11065 (car gnus-article-current)))
11067 (set-buffer gnus-original-article-buffer)
11068 (nnheader-narrow-to-headers)
11070 (message-fetch-field "references")
11072 ;; It's not the current article, so we take a bet on
11073 ;; the value we got from the server.
11074 (mail-header-references header))))
11075 (if (setq ref (or ref (mail-header-references header)))
11076 (or (gnus-summary-refer-article (gnus-parent-id ref))
11077 (gnus-message 1 "Couldn't find parent"))
11078 (gnus-message 1 "No references in article %d"
11079 (gnus-summary-article-number))
11082 (gnus-summary-position-point)
11085 (defun gnus-summary-refer-references ()
11086 "Fetch all articles mentioned in the References header.
11087 Return how many articles were fetched."
11089 (gnus-set-global-variables)
11090 (let ((ref (mail-header-references (gnus-summary-article-header)))
11091 (current (gnus-summary-article-number))
11093 ;; For each Message-ID in the References header...
11094 (while (string-match "<[^>]*>" ref)
11096 ;; ... fetch that article.
11097 (gnus-summary-refer-article
11098 (prog1 (match-string 0 ref)
11099 (setq ref (substring ref (match-end 0))))))
11100 (gnus-summary-goto-subject current)
11101 (gnus-summary-position-point)
11104 (defun gnus-summary-refer-article (message-id)
11105 "Fetch an article specified by MESSAGE-ID."
11106 (interactive "sMessage-ID: ")
11107 (when (and (stringp message-id)
11108 (not (zerop (length message-id))))
11109 ;; Construct the correct Message-ID if necessary.
11110 ;; Suggested by tale@pawl.rpi.edu.
11111 (unless (string-match "^<" message-id)
11112 (setq message-id (concat "<" message-id)))
11113 (unless (string-match ">$" message-id)
11114 (setq message-id (concat message-id ">")))
11115 (let* ((header (gnus-id-to-header message-id))
11116 (sparse (and header
11117 (memq (mail-header-number header)
11118 gnus-newsgroup-sparse))))
11121 ;; The article is present in the buffer, to we just go to it.
11122 (gnus-summary-goto-article
11123 (mail-header-number header) nil header)
11125 (gnus-summary-update-article (mail-header-number header))))
11126 ;; We fetch the article
11127 (let ((gnus-override-method
11128 (and (gnus-news-group-p gnus-newsgroup-name)
11129 gnus-refer-article-method))
11131 ;; Start the special refer-article method, if necessary.
11132 (when (and gnus-refer-article-method
11133 (gnus-news-group-p gnus-newsgroup-name))
11134 (gnus-check-server gnus-refer-article-method))
11135 ;; Fetch the header, and display the article.
11136 (if (setq number (gnus-summary-insert-subject message-id))
11137 (gnus-summary-select-article nil nil nil number)
11138 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
11140 (defun gnus-summary-enter-digest-group (&optional force)
11141 "Enter a digest group based on the current article."
11143 (gnus-set-global-variables)
11144 (gnus-summary-select-article)
11145 (let ((name (format "%s-%d"
11146 (gnus-group-prefixed-name
11147 gnus-newsgroup-name (list 'nndoc ""))
11148 gnus-current-article))
11149 (ogroup gnus-newsgroup-name)
11150 (case-fold-search t)
11151 (buf (current-buffer))
11154 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
11155 (insert-buffer-substring gnus-original-article-buffer)
11157 (goto-char (point-min))
11158 (or (search-forward "\n\n" nil t) (point)))
11159 (goto-char (point-min))
11160 (delete-matching-lines "^\\(Path\\):\\|^From ")
11163 (if (gnus-group-read-ephemeral-group
11164 name `(nndoc ,name (nndoc-address
11166 (nndoc-article-type ,(if force 'digest 'guess))) t)
11167 ;; Make all postings to this group go to the parent group.
11168 (nconc (gnus-info-params (gnus-get-info name))
11169 (list (cons 'to-group ogroup)))
11170 ;; Couldn't select this doc group.
11171 (switch-to-buffer buf)
11172 (gnus-set-global-variables)
11173 (gnus-configure-windows 'summary)
11174 (gnus-message 3 "Article couldn't be entered?"))
11175 (kill-buffer dig))))
11177 (defun gnus-summary-isearch-article (&optional regexp-p)
11178 "Do incremental search forward on the current article.
11179 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
11181 (gnus-set-global-variables)
11182 (gnus-summary-select-article)
11183 (gnus-configure-windows 'article)
11184 (gnus-eval-in-buffer-window gnus-article-buffer
11185 (goto-char (point-min))
11186 (isearch-forward regexp-p)))
11188 (defun gnus-summary-search-article-forward (regexp &optional backward)
11189 "Search for an article containing REGEXP forward.
11190 If BACKWARD, search backward instead."
11193 (format "Search article %s (regexp%s): "
11194 (if current-prefix-arg "backward" "forward")
11195 (if gnus-last-search-regexp
11196 (concat ", default " gnus-last-search-regexp)
11198 current-prefix-arg))
11199 (gnus-set-global-variables)
11200 (if (string-equal regexp "")
11201 (setq regexp (or gnus-last-search-regexp ""))
11202 (setq gnus-last-search-regexp regexp))
11203 (unless (gnus-summary-search-article regexp backward)
11204 (error "Search failed: \"%s\"" regexp)))
11206 (defun gnus-summary-search-article-backward (regexp)
11207 "Search for an article containing REGEXP backward."
11210 (format "Search article backward (regexp%s): "
11211 (if gnus-last-search-regexp
11212 (concat ", default " gnus-last-search-regexp)
11214 (gnus-summary-search-article-forward regexp 'backward))
11216 (defun gnus-summary-search-article (regexp &optional backward)
11217 "Search for an article containing REGEXP.
11218 Optional argument BACKWARD means do search for backward.
11219 `gnus-select-article-hook' is not called during the search."
11220 (let ((gnus-select-article-hook nil) ;Disable hook.
11221 (gnus-article-display-hook nil)
11222 (gnus-mark-article-hook nil) ;Inhibit marking as read.
11225 're-search-backward 're-search-forward))
11226 (sum (current-buffer))
11228 (gnus-save-hidden-threads
11229 (gnus-summary-select-article)
11230 (set-buffer gnus-article-buffer)
11234 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
11236 (re-search-backward regexp nil t)
11237 (re-search-forward regexp nil t))
11238 ;; We found the regexp.
11240 (setq found 'found)
11241 (beginning-of-line)
11243 (get-buffer-window (current-buffer))
11247 ;; We didn't find it, so we go to the next article.
11249 (if (not (if backward (gnus-summary-find-prev)
11250 (gnus-summary-find-next)))
11251 ;; No more articles.
11253 ;; Select the next article and adjust point.
11254 (gnus-summary-select-article)
11255 (set-buffer gnus-article-buffer)
11257 (goto-char (if backward (point-max) (point-min))))))
11258 (gnus-message 7 ""))
11259 ;; Return whether we found the regexp.
11260 (when (eq found 'found)
11261 (gnus-summary-show-thread)
11262 (gnus-summary-goto-subject gnus-current-article)
11263 (gnus-summary-position-point)
11266 (defun gnus-summary-find-matching (header regexp &optional backward unread
11268 "Return a list of all articles that match REGEXP on HEADER.
11269 The search stars on the current article and goes forwards unless
11270 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
11271 If UNREAD is non-nil, only unread articles will
11272 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
11273 in the comparisons."
11274 (let ((data (if (eq backward 'all) gnus-newsgroup-data
11275 (gnus-data-find-list
11276 (gnus-summary-article-number) (gnus-data-list backward))))
11277 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
11278 (case-fold-search (not not-case-fold))
11280 (or (fboundp (intern (concat "mail-header-" header)))
11281 (error "%s is not a valid header" header))
11283 (setq d (car data))
11284 (and (or (not unread) ; We want all articles...
11285 (gnus-data-unread-p d)) ; Or just unreads.
11286 (vectorp (gnus-data-header d)) ; It's not a pseudo.
11287 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
11288 (setq articles (cons (gnus-data-number d) articles))) ; Success!
11289 (setq data (cdr data)))
11290 (nreverse articles)))
11292 (defun gnus-summary-execute-command (header regexp command &optional backward)
11293 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
11294 If HEADER is an empty string (or nil), the match is done on the entire
11295 article. If BACKWARD (the prefix) is non-nil, search backward instead."
11297 (list (let ((completion-ignore-case t))
11300 (mapcar (lambda (string) (list string))
11301 '("Number" "Subject" "From" "Lines" "Date"
11302 "Message-ID" "Xref" "References" "Body"))
11303 nil 'require-match))
11304 (read-string "Regexp: ")
11305 (read-key-sequence "Command: ")
11306 current-prefix-arg))
11307 (when (equal header "Body")
11309 (gnus-set-global-variables)
11310 ;; Hidden thread subtrees must be searched as well.
11311 (gnus-summary-show-all-threads)
11312 ;; We don't want to change current point nor window configuration.
11314 (save-window-excursion
11315 (gnus-message 6 "Executing %s..." (key-description command))
11316 ;; We'd like to execute COMMAND interactively so as to give arguments.
11317 (gnus-execute header regexp
11318 `(lambda () (call-interactively ',(key-binding command)))
11320 (gnus-message 6 "Executing %s...done" (key-description command)))))
11322 (defun gnus-summary-beginning-of-article ()
11323 "Scroll the article back to the beginning."
11325 (gnus-set-global-variables)
11326 (gnus-summary-select-article)
11327 (gnus-configure-windows 'article)
11328 (gnus-eval-in-buffer-window gnus-article-buffer
11330 (goto-char (point-min))
11331 (and gnus-break-pages (gnus-narrow-to-page))))
11333 (defun gnus-summary-end-of-article ()
11334 "Scroll to the end of the article."
11336 (gnus-set-global-variables)
11337 (gnus-summary-select-article)
11338 (gnus-configure-windows 'article)
11339 (gnus-eval-in-buffer-window gnus-article-buffer
11341 (goto-char (point-max))
11343 (and gnus-break-pages (gnus-narrow-to-page))))
11345 (defun gnus-summary-show-article (&optional arg)
11346 "Force re-fetching of the current article.
11347 If ARG (the prefix) is non-nil, show the raw article without any
11348 article massaging functions being run."
11350 (gnus-set-global-variables)
11352 ;; Select the article the normal way.
11353 (gnus-summary-select-article nil 'force)
11354 ;; Bind the article treatment functions to nil.
11355 (let ((gnus-have-all-headers t)
11356 gnus-article-display-hook
11357 gnus-article-prepare-hook
11360 (gnus-summary-select-article nil 'force)))
11361 (gnus-summary-goto-subject gnus-current-article)
11362 ; (gnus-configure-windows 'article)
11363 (gnus-summary-position-point))
11365 (defun gnus-summary-verbose-headers (&optional arg)
11366 "Toggle permanent full header display.
11367 If ARG is a positive number, turn header display on.
11368 If ARG is a negative number, turn header display off."
11370 (gnus-set-global-variables)
11371 (gnus-summary-toggle-header arg)
11372 (setq gnus-show-all-headers
11373 (cond ((or (not (numberp arg))
11375 (not gnus-show-all-headers))
11379 (defun gnus-summary-toggle-header (&optional arg)
11380 "Show the headers if they are hidden, or hide them if they are shown.
11381 If ARG is a positive number, show the entire header.
11382 If ARG is a negative number, hide the unwanted header lines."
11384 (gnus-set-global-variables)
11386 (set-buffer gnus-article-buffer)
11387 (let* ((buffer-read-only nil)
11388 (inhibit-point-motion-hooks t)
11389 (hidden (text-property-any
11390 (goto-char (point-min)) (search-forward "\n\n")
11393 (goto-char (point-min))
11394 (when (search-forward "\n\n" nil t)
11395 (delete-region (point-min) (1- (point))))
11396 (goto-char (point-min))
11398 (set-buffer gnus-original-article-buffer)
11399 (goto-char (point-min))
11400 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
11401 (insert-buffer-substring gnus-original-article-buffer 1 e)
11402 (let ((gnus-inhibit-hiding t))
11403 (run-hooks 'gnus-article-display-hook))
11404 (if (or (not hidden) (and (numberp arg) (< arg 0)))
11405 (gnus-article-hide-headers)))))
11407 (defun gnus-summary-show-all-headers ()
11408 "Make all header lines visible."
11410 (gnus-set-global-variables)
11411 (gnus-article-show-all-headers))
11413 (defun gnus-summary-toggle-mime (&optional arg)
11414 "Toggle MIME processing.
11415 If ARG is a positive number, turn MIME processing on."
11417 (gnus-set-global-variables)
11418 (setq gnus-show-mime
11419 (if (null arg) (not gnus-show-mime)
11420 (> (prefix-numeric-value arg) 0)))
11421 (gnus-summary-select-article t 'force))
11423 (defun gnus-summary-caesar-message (&optional arg)
11424 "Caesar rotate the current article by 13.
11425 The numerical prefix specifies how manu places to rotate each letter
11428 (gnus-set-global-variables)
11429 (gnus-summary-select-article)
11430 (let ((mail-header-separator ""))
11431 (gnus-eval-in-buffer-window gnus-article-buffer
11434 (let ((start (window-start))
11436 (message-caesar-buffer-body arg)
11437 (set-window-start (get-buffer-window (current-buffer)) start))))))
11439 (defun gnus-summary-stop-page-breaking ()
11440 "Stop page breaking in the current article."
11442 (gnus-set-global-variables)
11443 (gnus-summary-select-article)
11444 (gnus-eval-in-buffer-window gnus-article-buffer
11447 (defun gnus-summary-move-article (&optional n to-newsgroup select-method action)
11448 "Move the current article to a different newsgroup.
11449 If N is a positive number, move the N next articles.
11450 If N is a negative number, move the N previous articles.
11451 If N is nil and any articles have been marked with the process mark,
11452 move those articles instead.
11453 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11454 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
11455 re-spool using this method.
11457 For this function to work, both the current newsgroup and the
11458 newsgroup that you want to move to have to support the `request-move'
11459 and `request-accept' functions."
11461 (unless action (setq action 'move))
11462 (gnus-set-global-variables)
11463 ;; Check whether the source group supports the required functions.
11464 (cond ((and (eq action 'move)
11465 (not (gnus-check-backend-function
11466 'request-move-article gnus-newsgroup-name)))
11467 (error "The current group does not support article moving"))
11468 ((and (eq action 'crosspost)
11469 (not (gnus-check-backend-function
11470 'request-replace-article gnus-newsgroup-name)))
11471 (error "The current group does not support article editing")))
11472 (let ((articles (gnus-summary-work-articles n))
11473 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
11474 (names '((move "Move" "Moving")
11475 (copy "Copy" "Copying")
11476 (crosspost "Crosspost" "Crossposting")))
11477 (copy-buf (save-excursion
11478 (nnheader-set-temp-buffer " *copy article*")))
11479 art-group to-method new-xref article to-groups)
11480 (unless (assq action names)
11481 (error "Unknown action %s" action))
11482 ;; Read the newsgroup name.
11483 (when (and (not to-newsgroup)
11484 (not select-method))
11486 (gnus-read-move-group-name
11487 (cadr (assq action names))
11488 (symbol-value (intern (format "gnus-current-%s-group" action)))
11490 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
11491 (setq to-method (or select-method
11492 (gnus-group-name-to-method to-newsgroup)))
11493 ;; Check the method we are to move this article to...
11494 (or (gnus-check-backend-function 'request-accept-article (car to-method))
11495 (error "%s does not support article copying" (car to-method)))
11496 (or (gnus-check-server to-method)
11497 (error "Can't open server %s" (car to-method)))
11498 (gnus-message 6 "%s to %s: %s..."
11499 (caddr (assq action names))
11500 (or (car select-method) to-newsgroup) articles)
11502 (setq article (pop articles))
11506 ;; Move the article.
11508 (gnus-request-move-article
11509 article ; Article to move
11510 gnus-newsgroup-name ; From newsgrouo
11511 (nth 1 (gnus-find-method-for-group
11512 gnus-newsgroup-name)) ; Server
11513 (list 'gnus-request-accept-article
11514 to-newsgroup (list 'quote select-method)
11515 (not articles)) ; Accept form
11516 (not articles))) ; Only save nov last time
11517 ;; Copy the article.
11520 (set-buffer copy-buf)
11521 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11522 (gnus-request-accept-article
11523 to-newsgroup select-method (not articles))))
11524 ;; Crosspost the article.
11525 ((eq action 'crosspost)
11526 (let ((xref (mail-header-xref (gnus-summary-article-header article))))
11527 (setq new-xref (concat gnus-newsgroup-name ":" article))
11528 (if (and xref (not (string= xref "")))
11530 (when (string-match "^Xref: " xref)
11531 (setq xref (substring xref (match-end 0))))
11532 (setq new-xref (concat xref " " new-xref)))
11533 (setq new-xref (concat (system-name) " " new-xref)))
11535 (set-buffer copy-buf)
11536 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11537 (nnheader-replace-header "xref" new-xref)
11538 (gnus-request-accept-article
11539 to-newsgroup select-method (not articles)))))))
11540 (if (not art-group)
11541 (gnus-message 1 "Couldn't %s article %s"
11542 (cadr (assq action names)) article)
11545 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
11547 (gnus-group-prefixed-name
11550 (gnus-find-method-for-group to-newsgroup)))
11551 gnus-newsrc-hashtb)))
11552 (info (nth 2 entry))
11553 (to-group (gnus-info-group info)))
11554 ;; Update the group that has been moved to.
11556 (memq action '(move copy)))
11557 (unless (member to-group to-groups)
11558 (push to-group to-groups))
11560 (unless (memq article gnus-newsgroup-unreads)
11561 (gnus-info-set-read
11562 info (gnus-add-to-range (gnus-info-read info)
11563 (list (cdr art-group)))))
11565 ;; Copy any marks over to the new group.
11566 (let ((marks gnus-article-mark-lists)
11567 (to-article (cdr art-group)))
11569 ;; See whether the article is to be put in the cache.
11570 (when gnus-use-cache
11571 (gnus-cache-possibly-enter-article
11572 to-group to-article
11573 (let ((header (copy-sequence
11574 (gnus-summary-article-header article))))
11575 (mail-header-set-number header to-article)
11577 (memq article gnus-newsgroup-marked)
11578 (memq article gnus-newsgroup-dormant)
11579 (memq article gnus-newsgroup-unreads)))
11582 (when (memq article (symbol-value
11583 (intern (format "gnus-newsgroup-%s"
11585 ;; If the other group is the same as this group,
11586 ;; then we have to add the mark to the list.
11587 (when (equal to-group gnus-newsgroup-name)
11588 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
11591 (intern (format "gnus-newsgroup-%s"
11593 ;; Copy mark to other group.
11594 (gnus-add-marked-articles
11595 to-group (cdar marks) (list to-article) info))
11596 (setq marks (cdr marks)))))
11598 ;; Update the Xref header in this article to point to
11599 ;; the new crossposted article we have just created.
11600 (when (eq action 'crosspost)
11602 (set-buffer copy-buf)
11603 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11604 (nnheader-replace-header
11605 "xref" (concat new-xref " " (gnus-group-prefixed-name
11606 (car art-group) to-method)
11607 ":" (cdr art-group)))
11608 (gnus-request-replace-article
11609 article gnus-newsgroup-name (current-buffer)))))
11611 (gnus-summary-goto-subject article)
11612 (when (eq action 'move)
11613 (gnus-summary-mark-article article gnus-canceled-mark)))
11614 (gnus-summary-remove-process-mark article))
11615 ;; Re-activate all groups that have been moved to.
11617 (gnus-activate-group (pop to-groups)))
11619 (gnus-kill-buffer copy-buf)
11620 (gnus-summary-position-point)
11621 (gnus-set-mode-line 'summary)))
11623 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
11624 "Move the current article to a different newsgroup.
11625 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11626 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
11627 re-spool using this method."
11629 (gnus-summary-move-article n nil select-method 'copy))
11631 (defun gnus-summary-crosspost-article (&optional n)
11632 "Crosspost the current article to some other group."
11634 (gnus-summary-move-article n nil nil 'crosspost))
11636 (defvar gnus-summary-respool-default-method nil
11637 "Default method for respooling an article.
11638 If nil, use to the current newsgroup method.")
11640 (defun gnus-summary-respool-article (&optional n method)
11641 "Respool the current article.
11642 The article will be squeezed through the mail spooling process again,
11643 which means that it will be put in some mail newsgroup or other
11644 depending on `nnmail-split-methods'.
11645 If N is a positive number, respool the N next articles.
11646 If N is a negative number, respool the N previous articles.
11647 If N is nil and any articles have been marked with the process mark,
11648 respool those articles instead.
11650 Respooling can be done both from mail groups and \"real\" newsgroups.
11651 In the former case, the articles in question will be moved from the
11652 current group into whatever groups they are destined to. In the
11653 latter case, they will be copied into the relevant groups."
11655 (list current-prefix-arg
11656 (let* ((methods (gnus-methods-using 'respool))
11658 (symbol-name (or gnus-summary-respool-default-method
11659 (car (gnus-find-method-for-group
11660 gnus-newsgroup-name)))))
11662 (gnus-completing-read
11663 methname "What backend do you want to use when respooling?"
11664 methods nil t nil 'gnus-method-history))
11667 ((zerop (length (setq ms (gnus-servers-using-backend method))))
11668 (list (intern method) ""))
11672 (cdr (completing-read
11674 (mapcar (lambda (m) (cons (cadr m) m)) ms) nil t)))))))
11675 (gnus-set-global-variables)
11677 (error "No method given for respooling"))
11678 (if (assoc (symbol-name
11679 (car (gnus-find-method-for-group gnus-newsgroup-name)))
11680 (gnus-methods-using 'respool))
11681 (gnus-summary-move-article n nil method)
11682 (gnus-summary-copy-article n nil method)))
11684 (defun gnus-summary-import-article (file)
11685 "Import a random file into a mail newsgroup."
11686 (interactive "fImport file: ")
11687 (gnus-set-global-variables)
11688 (let ((group gnus-newsgroup-name)
11689 (now (current-time))
11691 (or (gnus-check-backend-function 'request-accept-article group)
11692 (error "%s does not support article importing" group))
11693 (or (file-readable-p file)
11694 (not (file-regular-p file))
11695 (error "Can't read %s" file))
11697 (set-buffer (get-buffer-create " *import file*"))
11698 (buffer-disable-undo (current-buffer))
11700 (insert-file-contents file)
11701 (goto-char (point-min))
11702 (unless (nnheader-article-p)
11703 ;; This doesn't look like an article, so we fudge some headers.
11704 (setq atts (file-attributes file)
11705 lines (count-lines (point-min) (point-max)))
11706 (insert "From: " (read-string "From: ") "\n"
11707 "Subject: " (read-string "Subject: ") "\n"
11708 "Date: " (timezone-make-date-arpa-standard
11709 (current-time-string (nth 5 atts))
11710 (current-time-zone now)
11711 (current-time-zone now)) "\n"
11712 "Message-ID: " (message-make-message-id) "\n"
11713 "Lines: " (int-to-string lines) "\n"
11714 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
11715 (gnus-request-accept-article group nil t)
11716 (kill-buffer (current-buffer)))))
11718 (defun gnus-summary-expire-articles (&optional now)
11719 "Expire all articles that are marked as expirable in the current group."
11721 (gnus-set-global-variables)
11722 (when (gnus-check-backend-function
11723 'request-expire-articles gnus-newsgroup-name)
11724 ;; This backend supports expiry.
11725 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
11726 (expirable (if total
11727 (gnus-list-of-read-articles gnus-newsgroup-name)
11728 (setq gnus-newsgroup-expirable
11729 (sort gnus-newsgroup-expirable '<))))
11730 (expiry-wait (if now 'immediate
11731 (gnus-group-get-parameter
11732 gnus-newsgroup-name 'expiry-wait)))
11735 ;; There are expirable articles in this group, so we run them
11736 ;; through the expiry process.
11737 (gnus-message 6 "Expiring articles...")
11738 ;; The list of articles that weren't expired is returned.
11740 (let ((nnmail-expiry-wait-function nil)
11741 (nnmail-expiry-wait expiry-wait))
11742 (setq es (gnus-request-expire-articles
11743 expirable gnus-newsgroup-name)))
11744 (setq es (gnus-request-expire-articles
11745 expirable gnus-newsgroup-name)))
11746 (or total (setq gnus-newsgroup-expirable es))
11747 ;; We go through the old list of expirable, and mark all
11748 ;; really expired articles as nonexistent.
11749 (unless (eq es expirable) ;If nothing was expired, we don't mark.
11750 (let ((gnus-use-cache nil))
11752 (unless (memq (car expirable) es)
11753 (when (gnus-data-find (car expirable))
11754 (gnus-summary-mark-article
11755 (car expirable) gnus-canceled-mark)))
11756 (setq expirable (cdr expirable)))))
11757 (gnus-message 6 "Expiring articles...done")))))
11759 (defun gnus-summary-expire-articles-now ()
11760 "Expunge all expirable articles in the current group.
11761 This means that *all* articles that are marked as expirable will be
11762 deleted forever, right now."
11764 (gnus-set-global-variables)
11765 (or gnus-expert-user
11767 "Are you really, really, really sure you want to delete all these messages? ")
11769 (gnus-summary-expire-articles t))
11771 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
11772 (defun gnus-summary-delete-article (&optional n)
11773 "Delete the N next (mail) articles.
11774 This command actually deletes articles. This is not a marking
11775 command. The article will disappear forever from your life, never to
11777 If N is negative, delete backwards.
11778 If N is nil and articles have been marked with the process mark,
11779 delete these instead."
11781 (gnus-set-global-variables)
11782 (or (gnus-check-backend-function 'request-expire-articles
11783 gnus-newsgroup-name)
11784 (error "The current newsgroup does not support article deletion."))
11785 ;; Compute the list of articles to delete.
11786 (let ((articles (gnus-summary-work-articles n))
11788 (if (and gnus-novice-user
11789 (not (gnus-y-or-n-p
11790 (format "Do you really want to delete %s forever? "
11791 (if (> (length articles) 1)
11792 (format "these %s articles" (length articles))
11793 "this article")))))
11795 ;; Delete the articles.
11796 (setq not-deleted (gnus-request-expire-articles
11797 articles gnus-newsgroup-name 'force))
11799 (gnus-summary-remove-process-mark (car articles))
11800 ;; The backend might not have been able to delete the article
11802 (or (memq (car articles) not-deleted)
11803 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
11804 (setq articles (cdr articles))))
11805 (gnus-summary-position-point)
11806 (gnus-set-mode-line 'summary)
11809 (defun gnus-summary-edit-article (&optional force)
11810 "Enter into a buffer and edit the current article.
11811 This will have permanent effect only in mail groups.
11812 If FORCE is non-nil, allow editing of articles even in read-only
11816 (set-buffer gnus-summary-buffer)
11817 (gnus-set-global-variables)
11818 (when (and (not force)
11819 (gnus-group-read-only-p))
11820 (error "The current newsgroup does not support article editing."))
11821 (gnus-summary-select-article t nil t)
11822 (gnus-configure-windows 'article)
11823 (select-window (get-buffer-window gnus-article-buffer))
11824 (gnus-message 6 "C-c C-c to end edits")
11825 (setq buffer-read-only nil)
11827 (use-local-map (copy-keymap (current-local-map)))
11828 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
11829 (buffer-enable-undo)
11831 (goto-char (point-min))
11832 (search-forward "\n\n" nil t)))
11834 (defun gnus-summary-edit-article-done ()
11835 "Make edits to the current article permanent."
11837 (if (gnus-group-read-only-p)
11839 (gnus-summary-edit-article-postpone)
11841 1 "The current newsgroup does not support article editing."))
11842 (let ((buf (format "%s" (buffer-string))))
11845 (if (not (gnus-request-replace-article
11846 (cdr gnus-article-current) (car gnus-article-current)
11848 (error "Couldn't replace article.")
11849 (gnus-article-mode)
11850 (use-local-map gnus-article-mode-map)
11851 (setq buffer-read-only t)
11852 (buffer-disable-undo (current-buffer))
11853 (gnus-configure-windows 'summary)
11854 (gnus-summary-update-article (cdr gnus-article-current))
11855 (when gnus-use-cache
11856 (gnus-cache-update-article
11857 (car gnus-article-current) (cdr gnus-article-current)))
11858 (when gnus-keep-backlog
11859 (gnus-backlog-remove-article
11860 (car gnus-article-current) (cdr gnus-article-current))))
11862 (when (get-buffer gnus-original-article-buffer)
11863 (set-buffer gnus-original-article-buffer)
11864 (setq gnus-original-article nil)))
11865 (setq gnus-article-current nil
11866 gnus-current-article nil)
11867 (run-hooks 'gnus-article-display-hook)
11868 (and (gnus-visual-p 'summary-highlight 'highlight)
11869 (run-hooks 'gnus-visual-mark-article-hook)))))
11871 (defun gnus-summary-edit-article-postpone ()
11872 "Postpone changes to the current article."
11874 (gnus-article-mode)
11875 (use-local-map gnus-article-mode-map)
11876 (setq buffer-read-only t)
11877 (buffer-disable-undo (current-buffer))
11878 (gnus-configure-windows 'summary)
11879 (and (gnus-visual-p 'summary-highlight 'highlight)
11880 (run-hooks 'gnus-visual-mark-article-hook)))
11882 (defun gnus-summary-respool-query ()
11883 "Query where the respool algorithm would put this article."
11885 (gnus-set-global-variables)
11886 (gnus-summary-select-article)
11888 (set-buffer gnus-article-buffer)
11890 (goto-char (point-min))
11891 (search-forward "\n\n")
11892 (narrow-to-region (point-min) (point))
11893 (pp-eval-expression
11894 (list 'quote (mapcar 'car (nnmail-article-group 'identity)))))))
11896 ;; Summary marking commands.
11898 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
11899 "Mark articles which has the same subject as read, and then select the next.
11900 If UNMARK is positive, remove any kind of mark.
11901 If UNMARK is negative, tick articles."
11903 (gnus-set-global-variables)
11905 (setq unmark (prefix-numeric-value unmark)))
11907 (gnus-summary-mark-same-subject
11908 (gnus-summary-article-subject) unmark)))
11909 ;; Select next unread article. If auto-select-same mode, should
11910 ;; select the first unread article.
11911 (gnus-summary-next-article t (and gnus-auto-select-same
11912 (gnus-summary-article-subject)))
11913 (gnus-message 7 "%d article%s marked as %s"
11914 count (if (= count 1) " is" "s are")
11915 (if unmark "unread" "read"))))
11917 (defun gnus-summary-kill-same-subject (&optional unmark)
11918 "Mark articles which has the same subject as read.
11919 If UNMARK is positive, remove any kind of mark.
11920 If UNMARK is negative, tick articles."
11922 (gnus-set-global-variables)
11924 (setq unmark (prefix-numeric-value unmark)))
11926 (gnus-summary-mark-same-subject
11927 (gnus-summary-article-subject) unmark)))
11928 ;; If marked as read, go to next unread subject.
11930 ;; Go to next unread subject.
11931 (gnus-summary-next-subject 1 t))
11932 (gnus-message 7 "%d articles are marked as %s"
11933 count (if unmark "unread" "read"))))
11935 (defun gnus-summary-mark-same-subject (subject &optional unmark)
11936 "Mark articles with same SUBJECT as read, and return marked number.
11937 If optional argument UNMARK is positive, remove any kinds of marks.
11938 If optional argument UNMARK is negative, mark articles as unread instead."
11942 ((null unmark) ; Mark as read.
11945 (gnus-summary-mark-article-as-read gnus-killed-mark)
11946 (gnus-summary-show-thread) t)
11947 (gnus-summary-find-subject subject))
11948 (setq count (1+ count))))
11949 ((> unmark 0) ; Tick.
11952 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
11953 (gnus-summary-show-thread) t)
11954 (gnus-summary-find-subject subject))
11955 (setq count (1+ count))))
11956 (t ; Mark as unread.
11959 (gnus-summary-mark-article-as-unread gnus-unread-mark)
11960 (gnus-summary-show-thread) t)
11961 (gnus-summary-find-subject subject))
11962 (setq count (1+ count)))))
11963 (gnus-set-mode-line 'summary)
11964 ;; Return the number of marked articles.
11967 (defun gnus-summary-mark-as-processable (n &optional unmark)
11968 "Set the process mark on the next N articles.
11969 If N is negative, mark backward instead. If UNMARK is non-nil, remove
11970 the process mark instead. The difference between N and the actual
11971 number of articles marked is returned."
11973 (gnus-set-global-variables)
11974 (let ((backward (< n 0))
11979 (gnus-summary-remove-process-mark
11980 (gnus-summary-article-number))
11981 (gnus-summary-set-process-mark (gnus-summary-article-number)))
11982 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
11984 (if (/= 0 n) (gnus-message 7 "No more articles"))
11985 (gnus-summary-recenter)
11986 (gnus-summary-position-point)
11989 (defun gnus-summary-unmark-as-processable (n)
11990 "Remove the process mark from the next N articles.
11991 If N is negative, mark backward instead. The difference between N and
11992 the actual number of articles marked is returned."
11994 (gnus-set-global-variables)
11995 (gnus-summary-mark-as-processable n t))
11997 (defun gnus-summary-unmark-all-processable ()
11998 "Remove the process mark from all articles."
12000 (gnus-set-global-variables)
12002 (while gnus-newsgroup-processable
12003 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
12004 (gnus-summary-position-point))
12006 (defun gnus-summary-mark-as-expirable (n)
12007 "Mark N articles forward as expirable.
12008 If N is negative, mark backward instead. The difference between N and
12009 the actual number of articles marked is returned."
12011 (gnus-set-global-variables)
12012 (gnus-summary-mark-forward n gnus-expirable-mark))
12014 (defun gnus-summary-mark-article-as-replied (article)
12015 "Mark ARTICLE replied and update the summary line."
12016 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
12017 (let ((buffer-read-only nil))
12018 (when (gnus-summary-goto-subject article)
12019 (gnus-summary-update-secondary-mark article))))
12021 (defun gnus-summary-set-bookmark (article)
12022 "Set a bookmark in current article."
12023 (interactive (list (gnus-summary-article-number)))
12024 (gnus-set-global-variables)
12025 (if (or (not (get-buffer gnus-article-buffer))
12026 (not gnus-current-article)
12027 (not gnus-article-current)
12028 (not (equal gnus-newsgroup-name (car gnus-article-current))))
12029 (error "No current article selected"))
12030 ;; Remove old bookmark, if one exists.
12031 (let ((old (assq article gnus-newsgroup-bookmarks)))
12032 (if old (setq gnus-newsgroup-bookmarks
12033 (delq old gnus-newsgroup-bookmarks))))
12034 ;; Set the new bookmark, which is on the form
12035 ;; (article-number . line-number-in-body).
12036 (setq gnus-newsgroup-bookmarks
12040 (set-buffer gnus-article-buffer)
12044 (goto-char (point-min))
12045 (search-forward "\n\n" nil t)
12048 gnus-newsgroup-bookmarks))
12049 (gnus-message 6 "A bookmark has been added to the current article."))
12051 (defun gnus-summary-remove-bookmark (article)
12052 "Remove the bookmark from the current article."
12053 (interactive (list (gnus-summary-article-number)))
12054 (gnus-set-global-variables)
12055 ;; Remove old bookmark, if one exists.
12056 (let ((old (assq article gnus-newsgroup-bookmarks)))
12059 (setq gnus-newsgroup-bookmarks
12060 (delq old gnus-newsgroup-bookmarks))
12061 (gnus-message 6 "Removed bookmark."))
12062 (gnus-message 6 "No bookmark in current article."))))
12064 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
12065 (defun gnus-summary-mark-as-dormant (n)
12066 "Mark N articles forward as dormant.
12067 If N is negative, mark backward instead. The difference between N and
12068 the actual number of articles marked is returned."
12070 (gnus-set-global-variables)
12071 (gnus-summary-mark-forward n gnus-dormant-mark))
12073 (defun gnus-summary-set-process-mark (article)
12074 "Set the process mark on ARTICLE and update the summary line."
12075 (setq gnus-newsgroup-processable
12077 (delq article gnus-newsgroup-processable)))
12078 (when (gnus-summary-goto-subject article)
12079 (gnus-summary-show-thread)
12080 (gnus-summary-update-secondary-mark article)))
12082 (defun gnus-summary-remove-process-mark (article)
12083 "Remove the process mark from ARTICLE and update the summary line."
12084 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
12085 (when (gnus-summary-goto-subject article)
12086 (gnus-summary-show-thread)
12087 (gnus-summary-update-secondary-mark article)))
12089 (defun gnus-summary-set-saved-mark (article)
12090 "Set the process mark on ARTICLE and update the summary line."
12091 (push article gnus-newsgroup-saved)
12092 (when (gnus-summary-goto-subject article)
12093 (gnus-summary-update-secondary-mark article)))
12095 (defun gnus-summary-mark-forward (n &optional mark no-expire)
12096 "Mark N articles as read forwards.
12097 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
12098 The difference between N and the actual number of articles marked is
12101 (gnus-set-global-variables)
12102 (let ((backward (< n 0))
12103 (gnus-summary-goto-unread
12104 (and gnus-summary-goto-unread
12105 (not (eq gnus-summary-goto-unread 'never))
12106 (not (memq mark (list gnus-unread-mark
12107 gnus-ticked-mark gnus-dormant-mark)))))
12109 (mark (or mark gnus-del-mark)))
12110 (while (and (> n 0)
12111 (gnus-summary-mark-article nil mark no-expire)
12112 (zerop (gnus-summary-next-subject
12114 (and gnus-summary-goto-unread
12115 (not (eq gnus-summary-goto-unread 'never)))
12118 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
12119 (gnus-summary-recenter)
12120 (gnus-summary-position-point)
12121 (gnus-set-mode-line 'summary)
12124 (defun gnus-summary-mark-article-as-read (mark)
12125 "Mark the current article quickly as read with MARK."
12126 (let ((article (gnus-summary-article-number)))
12127 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12128 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12129 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12130 (setq gnus-newsgroup-reads
12131 (cons (cons article mark) gnus-newsgroup-reads))
12132 ;; Possibly remove from cache, if that is used.
12133 (and gnus-use-cache (gnus-cache-enter-remove-article article))
12134 ;; Allow the backend to change the mark.
12135 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
12136 ;; Check for auto-expiry.
12137 (when (and gnus-newsgroup-auto-expire
12138 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
12139 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
12140 (= mark gnus-ancient-mark)
12141 (= mark gnus-read-mark) (= mark gnus-souped-mark)))
12142 (setq mark gnus-expirable-mark)
12143 (push article gnus-newsgroup-expirable))
12144 ;; Set the mark in the buffer.
12145 (gnus-summary-update-mark mark 'unread)
12148 (defun gnus-summary-mark-article-as-unread (mark)
12149 "Mark the current article quickly as unread with MARK."
12150 (let ((article (gnus-summary-article-number)))
12152 (gnus-error 1 "Unmarkable article")
12153 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12154 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12155 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
12156 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
12157 (cond ((= mark gnus-ticked-mark)
12158 (push article gnus-newsgroup-marked))
12159 ((= mark gnus-dormant-mark)
12160 (push article gnus-newsgroup-dormant))
12162 (push article gnus-newsgroup-unreads)))
12163 (setq gnus-newsgroup-reads
12164 (delq (assq article gnus-newsgroup-reads)
12165 gnus-newsgroup-reads))
12167 ;; See whether the article is to be put in the cache.
12168 (and gnus-use-cache
12169 (vectorp (gnus-summary-article-header article))
12171 (gnus-cache-possibly-enter-article
12172 gnus-newsgroup-name article
12173 (gnus-summary-article-header article)
12174 (= mark gnus-ticked-mark)
12175 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
12178 (gnus-summary-update-mark mark 'unread))
12181 (defun gnus-summary-mark-article (&optional article mark no-expire)
12182 "Mark ARTICLE with MARK. MARK can be any character.
12183 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
12184 `??' (dormant) and `?E' (expirable).
12185 If MARK is nil, then the default character `?D' is used.
12186 If ARTICLE is nil, then the article on the current line will be
12188 ;; The mark might be a string.
12189 (and (stringp mark)
12190 (setq mark (aref mark 0)))
12191 ;; If no mark is given, then we check auto-expiring.
12192 (and (not no-expire)
12193 gnus-newsgroup-auto-expire
12195 (and (numberp mark)
12196 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
12197 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
12198 (= mark gnus-read-mark) (= mark gnus-souped-mark))))
12199 (setq mark gnus-expirable-mark))
12200 (let* ((mark (or mark gnus-del-mark))
12201 (article (or article (gnus-summary-article-number))))
12202 (or article (error "No article on current line"))
12203 (if (or (= mark gnus-unread-mark)
12204 (= mark gnus-ticked-mark)
12205 (= mark gnus-dormant-mark))
12206 (gnus-mark-article-as-unread article mark)
12207 (gnus-mark-article-as-read article mark))
12209 ;; See whether the article is to be put in the cache.
12210 (and gnus-use-cache
12211 (not (= mark gnus-canceled-mark))
12212 (vectorp (gnus-summary-article-header article))
12214 (gnus-cache-possibly-enter-article
12215 gnus-newsgroup-name article
12216 (gnus-summary-article-header article)
12217 (= mark gnus-ticked-mark)
12218 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
12220 (if (gnus-summary-goto-subject article nil t)
12221 (let ((buffer-read-only nil))
12222 (gnus-summary-show-thread)
12224 (gnus-summary-update-mark mark 'unread)
12227 (defun gnus-summary-update-secondary-mark (article)
12228 "Update the secondary (read, process, cache) mark."
12229 (gnus-summary-update-mark
12230 (cond ((memq article gnus-newsgroup-processable)
12232 ((memq article gnus-newsgroup-cached)
12234 ((memq article gnus-newsgroup-replied)
12236 ((memq article gnus-newsgroup-saved)
12238 (t gnus-unread-mark))
12240 (when (gnus-visual-p 'summary-highlight 'highlight)
12241 (run-hooks 'gnus-summary-update-hook))
12244 (defun gnus-summary-update-mark (mark type)
12245 (beginning-of-line)
12246 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
12247 (buffer-read-only nil))
12249 (<= (+ forward (point)) (point-max)))
12250 ;; Go to the right position on the line.
12251 (goto-char (+ forward (point)))
12252 ;; Replace the old mark with the new mark.
12253 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
12254 ;; Optionally update the marks by some user rule.
12255 (when (eq type 'unread)
12256 (gnus-data-set-mark
12257 (gnus-data-find (gnus-summary-article-number)) mark)
12258 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
12260 (defun gnus-mark-article-as-read (article &optional mark)
12261 "Enter ARTICLE in the pertinent lists and remove it from others."
12262 ;; Make the article expirable.
12263 (let ((mark (or mark gnus-del-mark)))
12264 (if (= mark gnus-expirable-mark)
12265 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
12266 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
12267 ;; Remove from unread and marked lists.
12268 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12269 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12270 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12271 (push (cons article mark) gnus-newsgroup-reads)
12272 ;; Possibly remove from cache, if that is used.
12273 (when gnus-use-cache
12274 (gnus-cache-enter-remove-article article))))
12276 (defun gnus-mark-article-as-unread (article &optional mark)
12277 "Enter ARTICLE in the pertinent lists and remove it from others."
12278 (let ((mark (or mark gnus-ticked-mark)))
12279 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12280 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12281 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
12282 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12283 (cond ((= mark gnus-ticked-mark)
12284 (push article gnus-newsgroup-marked))
12285 ((= mark gnus-dormant-mark)
12286 (push article gnus-newsgroup-dormant))
12288 (push article gnus-newsgroup-unreads)))
12289 (setq gnus-newsgroup-reads
12290 (delq (assq article gnus-newsgroup-reads)
12291 gnus-newsgroup-reads))))
12293 (defalias 'gnus-summary-mark-as-unread-forward
12294 'gnus-summary-tick-article-forward)
12295 (make-obsolete 'gnus-summary-mark-as-unread-forward
12296 'gnus-summary-tick-article-forward)
12297 (defun gnus-summary-tick-article-forward (n)
12298 "Tick N articles forwards.
12299 If N is negative, tick backwards instead.
12300 The difference between N and the number of articles ticked is returned."
12302 (gnus-summary-mark-forward n gnus-ticked-mark))
12304 (defalias 'gnus-summary-mark-as-unread-backward
12305 'gnus-summary-tick-article-backward)
12306 (make-obsolete 'gnus-summary-mark-as-unread-backward
12307 'gnus-summary-tick-article-backward)
12308 (defun gnus-summary-tick-article-backward (n)
12309 "Tick N articles backwards.
12310 The difference between N and the number of articles ticked is returned."
12312 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
12314 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
12315 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
12316 (defun gnus-summary-tick-article (&optional article clear-mark)
12317 "Mark current article as unread.
12318 Optional 1st argument ARTICLE specifies article number to be marked as unread.
12319 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
12321 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
12322 gnus-ticked-mark)))
12324 (defun gnus-summary-mark-as-read-forward (n)
12325 "Mark N articles as read forwards.
12326 If N is negative, mark backwards instead.
12327 The difference between N and the actual number of articles marked is
12330 (gnus-summary-mark-forward n gnus-del-mark t))
12332 (defun gnus-summary-mark-as-read-backward (n)
12333 "Mark the N articles as read backwards.
12334 The difference between N and the actual number of articles marked is
12337 (gnus-summary-mark-forward (- n) gnus-del-mark t))
12339 (defun gnus-summary-mark-as-read (&optional article mark)
12340 "Mark current article as read.
12341 ARTICLE specifies the article to be marked as read.
12342 MARK specifies a string to be inserted at the beginning of the line."
12343 (gnus-summary-mark-article article mark))
12345 (defun gnus-summary-clear-mark-forward (n)
12346 "Clear marks from N articles forward.
12347 If N is negative, clear backward instead.
12348 The difference between N and the number of marks cleared is returned."
12350 (gnus-summary-mark-forward n gnus-unread-mark))
12352 (defun gnus-summary-clear-mark-backward (n)
12353 "Clear marks from N articles backward.
12354 The difference between N and the number of marks cleared is returned."
12356 (gnus-summary-mark-forward (- n) gnus-unread-mark))
12358 (defun gnus-summary-mark-unread-as-read ()
12359 "Intended to be used by `gnus-summary-mark-article-hook'."
12360 (when (memq gnus-current-article gnus-newsgroup-unreads)
12361 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
12363 (defun gnus-summary-mark-read-and-unread-as-read ()
12364 "Intended to be used by `gnus-summary-mark-article-hook'."
12365 (let ((mark (gnus-summary-article-mark)))
12366 (when (or (gnus-unread-mark-p mark)
12367 (gnus-read-mark-p mark))
12368 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
12370 (defun gnus-summary-mark-region-as-read (point mark all)
12371 "Mark all unread articles between point and mark as read.
12372 If given a prefix, mark all articles between point and mark as read,
12373 even ticked and dormant ones."
12374 (interactive "r\nP")
12378 (beginning-of-line)
12383 (memq (setq article (gnus-summary-article-number))
12384 gnus-newsgroup-unreads))
12385 (gnus-summary-mark-article article gnus-del-mark))
12387 (gnus-summary-find-next))))))
12389 (defun gnus-summary-mark-below (score mark)
12390 "Mark articles with score less than SCORE with MARK."
12391 (interactive "P\ncMark: ")
12392 (gnus-set-global-variables)
12393 (setq score (if score
12394 (prefix-numeric-value score)
12395 (or gnus-summary-default-score 0)))
12397 (set-buffer gnus-summary-buffer)
12398 (goto-char (point-min))
12401 (and (< (gnus-summary-article-score) score)
12402 (gnus-summary-mark-article nil mark))
12403 (gnus-summary-find-next)))))
12405 (defun gnus-summary-kill-below (&optional score)
12406 "Mark articles with score below SCORE as read."
12408 (gnus-set-global-variables)
12409 (gnus-summary-mark-below score gnus-killed-mark))
12411 (defun gnus-summary-clear-above (&optional score)
12412 "Clear all marks from articles with score above SCORE."
12414 (gnus-set-global-variables)
12415 (gnus-summary-mark-above score gnus-unread-mark))
12417 (defun gnus-summary-tick-above (&optional score)
12418 "Tick all articles with score above SCORE."
12420 (gnus-set-global-variables)
12421 (gnus-summary-mark-above score gnus-ticked-mark))
12423 (defun gnus-summary-mark-above (score mark)
12424 "Mark articles with score over SCORE with MARK."
12425 (interactive "P\ncMark: ")
12426 (gnus-set-global-variables)
12427 (setq score (if score
12428 (prefix-numeric-value score)
12429 (or gnus-summary-default-score 0)))
12431 (set-buffer gnus-summary-buffer)
12432 (goto-char (point-min))
12434 (if (> (gnus-summary-article-score) score)
12435 (gnus-summary-mark-article nil mark))
12437 (gnus-summary-find-next)))))
12439 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
12440 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
12441 (defun gnus-summary-limit-include-expunged ()
12442 "Display all the hidden articles that were expunged for low scores."
12444 (gnus-set-global-variables)
12445 (let ((buffer-read-only nil))
12446 (let ((scored gnus-newsgroup-scored)
12449 (or (gnus-summary-goto-subject (caar scored))
12450 (and (setq h (gnus-summary-article-header (caar scored)))
12451 (< (cdar scored) gnus-summary-expunge-below)
12452 (setq headers (cons h headers))))
12453 (setq scored (cdr scored)))
12454 (or headers (error "No expunged articles hidden."))
12455 (goto-char (point-min))
12456 (gnus-summary-prepare-unthreaded (nreverse headers)))
12457 (goto-char (point-min))
12458 (gnus-summary-position-point)))
12460 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
12461 "Mark all articles not marked as unread in this newsgroup as read.
12462 If prefix argument ALL is non-nil, all articles are marked as read.
12463 If QUIETLY is non-nil, no questions will be asked.
12464 If TO-HERE is non-nil, it should be a point in the buffer. All
12465 articles before this point will be marked as read.
12466 The number of articles marked as read is returned."
12468 (gnus-set-global-variables)
12471 (not gnus-interactive-catchup) ;Without confirmation?
12475 "Mark absolutely all articles as read? "
12476 "Mark all unread articles as read? ")))
12478 (not gnus-newsgroup-adaptive)
12479 (not gnus-newsgroup-auto-expire))
12482 (setq gnus-newsgroup-marked nil
12483 gnus-newsgroup-dormant nil))
12484 (setq gnus-newsgroup-unreads nil))
12485 ;; We actually mark all articles as canceled, which we
12486 ;; have to do when using auto-expiry or adaptive scoring.
12487 (gnus-summary-show-all-threads)
12488 (if (gnus-summary-first-subject (not all))
12490 (if to-here (< (point) to-here) t)
12491 (gnus-summary-mark-article-as-read gnus-catchup-mark)
12492 (gnus-summary-find-next (not all)))))
12494 (setq gnus-newsgroup-unreads nil))
12495 (gnus-set-mode-line 'summary)))
12496 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
12497 (if (and (not to-here) (eq 'nnvirtual (car method)))
12498 (nnvirtual-catchup-group
12499 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
12500 (gnus-summary-position-point)))
12502 (defun gnus-summary-catchup-to-here (&optional all)
12503 "Mark all unticked articles before the current one as read.
12504 If ALL is non-nil, also mark ticked and dormant articles as read."
12506 (gnus-set-global-variables)
12508 (gnus-save-hidden-threads
12509 (let ((beg (point)))
12510 ;; We check that there are unread articles.
12511 (when (or all (gnus-summary-find-prev))
12512 (gnus-summary-catchup all t beg)))))
12513 (gnus-summary-position-point))
12515 (defun gnus-summary-catchup-all (&optional quietly)
12516 "Mark all articles in this newsgroup as read."
12518 (gnus-set-global-variables)
12519 (gnus-summary-catchup t quietly))
12521 (defun gnus-summary-catchup-and-exit (&optional all quietly)
12522 "Mark all articles not marked as unread in this newsgroup as read, then exit.
12523 If prefix argument ALL is non-nil, all articles are marked as read."
12525 (gnus-set-global-variables)
12526 (gnus-summary-catchup all quietly nil 'fast)
12527 ;; Select next newsgroup or exit.
12528 (if (eq gnus-auto-select-next 'quietly)
12529 (gnus-summary-next-group nil)
12530 (gnus-summary-exit)))
12532 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
12533 "Mark all articles in this newsgroup as read, and then exit."
12535 (gnus-set-global-variables)
12536 (gnus-summary-catchup-and-exit t quietly))
12538 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
12539 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
12540 "Mark all articles in this group as read and select the next group.
12541 If given a prefix, mark all articles, unread as well as ticked, as
12544 (gnus-set-global-variables)
12546 (gnus-summary-catchup all))
12547 (gnus-summary-next-article t nil nil t))
12549 ;; Thread-based commands.
12551 (defun gnus-summary-articles-in-thread (&optional article)
12552 "Return a list of all articles in the current thread.
12553 If ARTICLE is non-nil, return all articles in the thread that starts
12554 with that article."
12555 (let* ((article (or article (gnus-summary-article-number)))
12556 (data (gnus-data-find-list article))
12557 (top-level (gnus-data-level (car data)))
12559 (cond ((null gnus-thread-operation-ignore-subject)
12560 (gnus-simplify-subject-re
12561 (mail-header-subject (gnus-data-header (car data)))))
12562 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
12563 (gnus-simplify-subject-fuzzy
12564 (mail-header-subject (gnus-data-header (car data)))))
12566 (end-point (save-excursion
12567 (if (gnus-summary-go-to-next-thread)
12568 (point) (point-max))))
12571 (< (gnus-data-pos (car data)) end-point))
12572 (when (or (not top-subject)
12573 (string= top-subject
12574 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
12575 (gnus-simplify-subject-fuzzy
12576 (mail-header-subject
12577 (gnus-data-header (car data))))
12578 (gnus-simplify-subject-re
12579 (mail-header-subject
12580 (gnus-data-header (car data)))))))
12581 (push (gnus-data-number (car data)) articles))
12582 (unless (and (setq data (cdr data))
12583 (> (gnus-data-level (car data)) top-level))
12585 ;; Return the list of articles.
12586 (nreverse articles)))
12588 (defun gnus-summary-rethread-current ()
12589 "Rethread the thread the current article is part of."
12591 (gnus-set-global-variables)
12592 (let* ((gnus-show-threads t)
12593 (article (gnus-summary-article-number))
12594 (id (mail-header-id (gnus-summary-article-header)))
12595 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
12597 (error "No article on the current line"))
12598 (gnus-rebuild-thread id)
12599 (gnus-summary-goto-subject article)))
12601 (defun gnus-summary-reparent-thread ()
12602 "Make current article child of the marked (or previous) article.
12604 Note that the re-threading will only work if `gnus-thread-ignore-subject'
12605 is non-nil or the Subject: of both articles are the same."
12607 (or (not (gnus-group-read-only-p))
12608 (error "The current newsgroup does not support article editing."))
12609 (or (<= (length gnus-newsgroup-processable) 1)
12610 (error "No more than one article may be marked."))
12611 (save-window-excursion
12612 (let ((gnus-article-buffer " *reparent*")
12613 (current-article (gnus-summary-article-number))
12614 ; first grab the marked article, otherwise one line up.
12615 (parent-article (if (not (null gnus-newsgroup-processable))
12616 (car gnus-newsgroup-processable)
12618 (if (eq (forward-line -1) 0)
12619 (gnus-summary-article-number)
12620 (error "Beginning of summary buffer."))))))
12621 (or (not (eq current-article parent-article))
12622 (error "An article may not be self-referential."))
12623 (let ((message-id (mail-header-id
12624 (gnus-summary-article-header parent-article))))
12625 (or (and message-id (not (equal message-id "")))
12626 (error "No message-id in desired parent."))
12627 (gnus-summary-select-article t t nil current-article)
12628 (set-buffer gnus-article-buffer)
12629 (setq buffer-read-only nil)
12630 (let ((buf (format "%s" (buffer-string))))
12633 (goto-char (point-min))
12634 (if (search-forward-regexp "^References: " nil t)
12635 (insert message-id " " )
12636 (insert "References: " message-id "\n"))
12637 (or (gnus-request-replace-article current-article
12638 (car gnus-article-current)
12639 gnus-article-buffer)
12640 (error "Couldn't replace article."))
12641 (set-buffer gnus-summary-buffer)
12642 (gnus-summary-unmark-all-processable)
12643 (gnus-summary-rethread-current)
12644 (gnus-message 3 "Article %d is now the child of article %d."
12645 current-article parent-article)))))
12647 (defun gnus-summary-toggle-threads (&optional arg)
12648 "Toggle showing conversation threads.
12649 If ARG is positive number, turn showing conversation threads on."
12651 (gnus-set-global-variables)
12652 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
12653 (setq gnus-show-threads
12654 (if (null arg) (not gnus-show-threads)
12655 (> (prefix-numeric-value arg) 0)))
12656 (gnus-summary-prepare)
12657 (gnus-summary-goto-subject current)
12658 (gnus-summary-position-point)))
12660 (defun gnus-summary-show-all-threads ()
12661 "Show all threads."
12663 (gnus-set-global-variables)
12665 (let ((buffer-read-only nil))
12666 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
12667 (gnus-summary-position-point))
12669 (defun gnus-summary-show-thread ()
12670 "Show thread subtrees.
12671 Returns nil if no thread was there to be shown."
12673 (gnus-set-global-variables)
12674 (let ((buffer-read-only nil)
12676 ;; first goto end then to beg, to have point at beg after let
12677 (end (progn (end-of-line) (point)))
12678 (beg (progn (beginning-of-line) (point))))
12680 ;; Any hidden lines here?
12681 (search-forward "\r" end t)
12682 (subst-char-in-region beg end ?\^M ?\n t)
12684 (gnus-summary-position-point))))
12686 (defun gnus-summary-hide-all-threads ()
12687 "Hide all thread subtrees."
12689 (gnus-set-global-variables)
12691 (goto-char (point-min))
12692 (gnus-summary-hide-thread)
12693 (while (zerop (gnus-summary-next-thread 1 t))
12694 (gnus-summary-hide-thread)))
12695 (gnus-summary-position-point))
12697 (defun gnus-summary-hide-thread ()
12698 "Hide thread subtrees.
12699 Returns nil if no threads were there to be hidden."
12701 (gnus-set-global-variables)
12702 (let ((buffer-read-only nil)
12704 (article (gnus-summary-article-number)))
12706 ;; Go forward until either the buffer ends or the subthread
12708 (when (and (not (eobp))
12709 (or (zerop (gnus-summary-next-thread 1 t))
12710 (goto-char (point-max))))
12712 (if (and (> (point) start)
12713 (search-backward "\n" start t))
12715 (subst-char-in-region start (point) ?\n ?\^M)
12716 (gnus-summary-goto-subject article))
12719 ;;(gnus-summary-position-point)
12722 (defun gnus-summary-go-to-next-thread (&optional previous)
12723 "Go to the same level (or less) next thread.
12724 If PREVIOUS is non-nil, go to previous thread instead.
12725 Return the article number moved to, or nil if moving was impossible."
12726 (let ((level (gnus-summary-thread-level))
12727 (way (if previous -1 1))
12730 (while (and (not (eobp))
12731 (< level (gnus-summary-thread-level)))
12732 (forward-line way))
12739 (gnus-summary-article-number)
12740 (goto-char beg)))))
12742 (defun gnus-summary-go-to-next-thread-old (&optional previous)
12743 "Go to the same level (or less) next thread.
12744 If PREVIOUS is non-nil, go to previous thread instead.
12745 Return the article number moved to, or nil if moving was impossible."
12746 (if (and (eq gnus-summary-make-false-root 'dummy)
12747 (gnus-summary-article-intangible-p))
12748 (let ((beg (point)))
12749 (while (and (zerop (forward-line 1))
12750 (not (gnus-summary-article-intangible-p))
12751 (not (zerop (save-excursion
12752 (gnus-summary-thread-level))))))
12758 (let* ((level (gnus-summary-thread-level))
12759 (article (gnus-summary-article-number))
12760 (data (cdr (gnus-data-find-list article (gnus-data-list previous))))
12763 (if (<= (gnus-data-level (car data)) level)
12764 (setq oart (gnus-data-number (car data))
12766 (setq data (cdr data))))
12768 (gnus-summary-goto-subject oart)))))
12770 (defun gnus-summary-next-thread (n &optional silent)
12771 "Go to the same level next N'th thread.
12772 If N is negative, search backward instead.
12773 Returns the difference between N and the number of skips actually
12776 If SILENT, don't output messages."
12778 (gnus-set-global-variables)
12779 (let ((backward (< n 0))
12782 (while (and (> n 0)
12783 (gnus-summary-go-to-next-thread backward))
12786 (gnus-summary-position-point))
12787 (when (and (not silent) (/= 0 n))
12788 (gnus-message 7 "No more threads"))
12791 (defun gnus-summary-prev-thread (n)
12792 "Go to the same level previous N'th thread.
12793 Returns the difference between N and the number of skips actually
12796 (gnus-set-global-variables)
12797 (gnus-summary-next-thread (- n)))
12799 (defun gnus-summary-go-down-thread ()
12800 "Go down one level in the current thread."
12801 (let ((children (gnus-summary-article-children)))
12803 (gnus-summary-goto-subject (car children)))))
12805 (defun gnus-summary-go-up-thread ()
12806 "Go up one level in the current thread."
12807 (let ((parent (gnus-summary-article-parent)))
12809 (gnus-summary-goto-subject parent))))
12811 (defun gnus-summary-down-thread (n)
12812 "Go down thread N steps.
12813 If N is negative, go up instead.
12814 Returns the difference between N and how many steps down that were
12817 (gnus-set-global-variables)
12820 (while (and (> n 0)
12821 (if up (gnus-summary-go-up-thread)
12822 (gnus-summary-go-down-thread)))
12824 (gnus-summary-position-point)
12825 (if (/= 0 n) (gnus-message 7 "Can't go further"))
12828 (defun gnus-summary-up-thread (n)
12829 "Go up thread N steps.
12830 If N is negative, go up instead.
12831 Returns the difference between N and how many steps down that were
12834 (gnus-set-global-variables)
12835 (gnus-summary-down-thread (- n)))
12837 (defun gnus-summary-top-thread ()
12838 "Go to the top of the thread."
12840 (gnus-set-global-variables)
12841 (while (gnus-summary-go-up-thread))
12842 (gnus-summary-article-number))
12844 (defun gnus-summary-kill-thread (&optional unmark)
12845 "Mark articles under current thread as read.
12846 If the prefix argument is positive, remove any kinds of marks.
12847 If the prefix argument is negative, tick articles instead."
12849 (gnus-set-global-variables)
12851 (setq unmark (prefix-numeric-value unmark)))
12852 (let ((articles (gnus-summary-articles-in-thread)))
12854 ;; Expand the thread.
12855 (gnus-summary-show-thread)
12856 ;; Mark all the articles.
12858 (gnus-summary-goto-subject (car articles))
12859 (cond ((null unmark)
12860 (gnus-summary-mark-article-as-read gnus-killed-mark))
12862 (gnus-summary-mark-article-as-unread gnus-unread-mark))
12864 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
12865 (setq articles (cdr articles))))
12866 ;; Hide killed subtrees.
12868 gnus-thread-hide-killed
12869 (gnus-summary-hide-thread))
12870 ;; If marked as read, go to next unread subject.
12872 ;; Go to next unread subject.
12873 (gnus-summary-next-subject 1 t)))
12874 (gnus-set-mode-line 'summary))
12876 ;; Summary sorting commands
12878 (defun gnus-summary-sort-by-number (&optional reverse)
12879 "Sort summary buffer by article number.
12880 Argument REVERSE means reverse order."
12882 (gnus-summary-sort 'number reverse))
12884 (defun gnus-summary-sort-by-author (&optional reverse)
12885 "Sort summary buffer by author name alphabetically.
12886 If case-fold-search is non-nil, case of letters is ignored.
12887 Argument REVERSE means reverse order."
12889 (gnus-summary-sort 'author reverse))
12891 (defun gnus-summary-sort-by-subject (&optional reverse)
12892 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
12893 If case-fold-search is non-nil, case of letters is ignored.
12894 Argument REVERSE means reverse order."
12896 (gnus-summary-sort 'subject reverse))
12898 (defun gnus-summary-sort-by-date (&optional reverse)
12899 "Sort summary buffer by date.
12900 Argument REVERSE means reverse order."
12902 (gnus-summary-sort 'date reverse))
12904 (defun gnus-summary-sort-by-score (&optional reverse)
12905 "Sort summary buffer by score.
12906 Argument REVERSE means reverse order."
12908 (gnus-summary-sort 'score reverse))
12910 (defun gnus-summary-sort (predicate reverse)
12911 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
12912 (gnus-set-global-variables)
12913 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
12914 (article (intern (format "gnus-article-sort-by-%s" predicate)))
12915 (gnus-thread-sort-functions
12920 (,thread t2 t1)))))
12921 (gnus-article-sort-functions
12926 (,article t2 t1)))))
12928 (gnus-summary-prepare-hook nil))
12929 ;; We do the sorting by regenerating the threads.
12930 (gnus-summary-prepare)
12931 ;; Hide subthreads if needed.
12932 (when (and gnus-show-threads gnus-thread-hide-subtree)
12933 (gnus-summary-hide-all-threads)))
12934 ;; If in async mode, we send some info to the backend.
12935 (when gnus-newsgroup-async
12936 (gnus-request-asynchronous
12937 gnus-newsgroup-name gnus-newsgroup-data)))
12939 (defun gnus-sortable-date (date)
12940 "Make sortable string by string-lessp from DATE.
12941 Timezone package is used."
12944 (setq date (inline (timezone-fix-time
12946 (aref (inline (timezone-parse-date date)) 4))))
12948 (timezone-make-sortable-date
12949 (aref date 0) (aref date 1) (aref date 2)
12951 (timezone-make-time-string
12952 (aref date 3) (aref date 4) (aref date 5))))))
12955 ;; Summary saving commands.
12957 (defun gnus-summary-save-article (&optional n not-saved)
12958 "Save the current article using the default saver function.
12959 If N is a positive number, save the N next articles.
12960 If N is a negative number, save the N previous articles.
12961 If N is nil and any articles have been marked with the process mark,
12962 save those articles instead.
12963 The variable `gnus-default-article-saver' specifies the saver function."
12965 (gnus-set-global-variables)
12966 (let ((articles (gnus-summary-work-articles n))
12967 (save-buffer (save-excursion
12968 (nnheader-set-temp-buffer " *Gnus Save*")))
12969 file header article)
12971 (setq header (gnus-summary-article-header
12972 (setq article (pop articles))))
12973 (if (not (vectorp header))
12974 ;; This is a pseudo-article.
12975 (if (assq 'name header)
12976 (gnus-copy-file (cdr (assq 'name header)))
12977 (gnus-message 1 "Article %d is unsaveable" article))
12978 ;; This is a real article.
12979 (save-window-excursion
12980 (gnus-summary-select-article t nil nil article))
12982 (set-buffer save-buffer)
12984 (insert-buffer-substring gnus-original-article-buffer))
12985 (unless gnus-save-all-headers
12986 ;; Remove headers accoring to `gnus-saved-headers'.
12987 (let ((gnus-visible-headers
12988 (or gnus-saved-headers gnus-visible-headers))
12989 (gnus-article-buffer save-buffer))
12990 (gnus-article-hide-headers 1 t)))
12991 (save-window-excursion
12992 (if (not gnus-default-article-saver)
12993 (error "No default saver is defined.")
12994 ;; !!! Magic! The saving functions all save
12995 ;; `gnus-original-article-buffer' (or so they think),
12996 ;; but we bind that variable to our save-buffer.
12997 (set-buffer gnus-article-buffer)
12998 (let ((gnus-original-article-buffer save-buffer))
12999 (set-buffer gnus-summary-buffer)
13000 (setq file (funcall
13001 gnus-default-article-saver
13003 ((not gnus-prompt-before-saving)
13005 ((eq gnus-prompt-before-saving 'always)
13008 (gnus-summary-remove-process-mark article)
13010 (gnus-summary-set-saved-mark article))))
13011 (gnus-kill-buffer save-buffer)
13012 (gnus-summary-position-point)
13015 (defun gnus-summary-pipe-output (&optional arg)
13016 "Pipe the current article to a subprocess.
13017 If N is a positive number, pipe the N next articles.
13018 If N is a negative number, pipe the N previous articles.
13019 If N is nil and any articles have been marked with the process mark,
13020 pipe those articles instead."
13022 (gnus-set-global-variables)
13023 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
13024 (gnus-summary-save-article arg t))
13025 (gnus-configure-windows 'pipe))
13027 (defun gnus-summary-save-article-mail (&optional arg)
13028 "Append the current article to an mail file.
13029 If N is a positive number, save the N next articles.
13030 If N is a negative number, save the N previous articles.
13031 If N is nil and any articles have been marked with the process mark,
13032 save those articles instead."
13034 (gnus-set-global-variables)
13035 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
13036 (gnus-summary-save-article arg)))
13038 (defun gnus-summary-save-article-rmail (&optional arg)
13039 "Append the current article to an rmail file.
13040 If N is a positive number, save the N next articles.
13041 If N is a negative number, save the N previous articles.
13042 If N is nil and any articles have been marked with the process mark,
13043 save those articles instead."
13045 (gnus-set-global-variables)
13046 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
13047 (gnus-summary-save-article arg)))
13049 (defun gnus-summary-save-article-file (&optional arg)
13050 "Append the current article to a file.
13051 If N is a positive number, save the N next articles.
13052 If N is a negative number, save the N previous articles.
13053 If N is nil and any articles have been marked with the process mark,
13054 save those articles instead."
13056 (gnus-set-global-variables)
13057 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
13058 (gnus-summary-save-article arg)))
13060 (defun gnus-summary-save-article-body-file (&optional arg)
13061 "Append the current article body to a file.
13062 If N is a positive number, save the N next articles.
13063 If N is a negative number, save the N previous articles.
13064 If N is nil and any articles have been marked with the process mark,
13065 save those articles instead."
13067 (gnus-set-global-variables)
13068 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
13069 (gnus-summary-save-article arg)))
13071 (defun gnus-get-split-value (methods)
13072 "Return a value based on the split METHODS."
13073 (let (split-name method result match)
13076 (set-buffer gnus-original-article-buffer)
13078 (nnheader-narrow-to-headers)
13080 (goto-char (point-min))
13081 (setq method (pop methods))
13082 (setq match (car method))
13085 ;; Regular expression.
13087 (re-search-forward match nil t)
13089 ((gnus-functionp match)
13093 (setq result (funcall match gnus-newsgroup-name))))
13098 (setq result (eval match)))))
13099 (setq split-name (append (cdr method) split-name))
13100 (cond ((stringp result)
13101 (push result split-name))
13103 (setq split-name (append result split-name)))))))))
13106 (defun gnus-read-move-group-name (prompt default articles prefix)
13107 "Read a group name."
13108 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
13109 (minibuffer-confirm-incomplete nil) ; XEmacs
13116 (assoc (symbol-name
13117 (car (gnus-find-method-for-group
13119 gnus-valid-select-methods))
13120 (push (list (symbol-name g)) group-map)))
13121 gnus-active-hashtb))
13123 (format "%s %s to:"
13125 (if (> (length articles) 1)
13126 (format "these %d articles" (length articles))
13131 (gnus-completing-read default prom
13132 group-map nil nil prefix
13133 'gnus-group-history))
13134 ((= 1 (length split-name))
13135 (gnus-completing-read (car split-name) prom group-map
13137 'gnus-group-history))
13139 (gnus-completing-read nil prom
13140 (mapcar (lambda (el) (list el))
13141 (nreverse split-name))
13143 'gnus-group-history)))))
13145 (if (or (string= to-newsgroup "")
13146 (string= to-newsgroup prefix))
13147 (setq to-newsgroup (or default "")))
13148 (or (gnus-active to-newsgroup)
13149 (gnus-activate-group to-newsgroup)
13150 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
13152 (or (gnus-request-create-group
13153 to-newsgroup (gnus-group-name-to-method to-newsgroup))
13154 (error "Couldn't create group %s" to-newsgroup)))
13155 (error "No such group: %s" to-newsgroup)))
13158 (defun gnus-read-save-file-name (prompt default-name)
13159 (let* ((split-name (gnus-get-split-value gnus-split-methods))
13161 ;; Let the split methods have their say.
13163 ;; No split name was found.
13166 (concat prompt " (default "
13167 (file-name-nondirectory default-name) ") ")
13168 (file-name-directory default-name)
13170 ;; A single split name was found
13171 ((= 1 (length split-name))
13172 (let* ((name (car split-name))
13173 (dir (cond ((file-directory-p name)
13174 (file-name-as-directory name))
13175 ((file-exists-p name) name)
13176 (t gnus-article-save-directory))))
13178 (concat prompt " (default " name ") ")
13180 ;; A list of splits was found.
13182 (setq split-name (nreverse split-name))
13184 (let ((file-name-history (nconc split-name file-name-history)))
13187 (concat prompt " (`M-p' for defaults) ")
13188 gnus-article-save-directory
13189 (car split-name))))
13190 (car (push result file-name-history)))))))
13191 ;; If we have read a directory, we append the default file name.
13192 (when (file-directory-p file)
13193 (setq file (concat (file-name-as-directory file)
13194 (file-name-nondirectory default-name))))
13195 ;; Possibly translate some charaters.
13196 (nnheader-translate-file-chars file)))
13198 (defun gnus-article-archive-name (group)
13199 "Return the first instance of an \"Archive-name\" in the current buffer."
13200 (let ((case-fold-search t))
13201 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
13202 (match-string 1))))
13204 (defun gnus-summary-save-in-rmail (&optional filename)
13205 "Append this article to Rmail file.
13206 Optional argument FILENAME specifies file name.
13207 Directory to save to is default to `gnus-article-save-directory'."
13209 (gnus-set-global-variables)
13210 (let ((default-name
13211 (funcall gnus-rmail-save-name gnus-newsgroup-name
13212 gnus-current-headers gnus-newsgroup-last-rmail)))
13214 (cond ((eq filename 'default)
13216 (filename filename)
13217 (t (gnus-read-save-file-name
13218 "Save in rmail file:" default-name))))
13219 (gnus-make-directory (file-name-directory filename))
13220 (gnus-eval-in-buffer-window gnus-original-article-buffer
13224 (gnus-output-to-rmail filename))))
13225 ;; Remember the directory name to save articles
13226 (setq gnus-newsgroup-last-rmail filename)))
13228 (defun gnus-summary-save-in-mail (&optional filename)
13229 "Append this article to Unix mail file.
13230 Optional argument FILENAME specifies file name.
13231 Directory to save to is default to `gnus-article-save-directory'."
13233 (gnus-set-global-variables)
13234 (let ((default-name
13235 (funcall gnus-mail-save-name gnus-newsgroup-name
13236 gnus-current-headers gnus-newsgroup-last-mail)))
13238 (cond ((eq filename 'default)
13240 (filename filename)
13241 (t (gnus-read-save-file-name
13242 "Save in Unix mail file:" default-name))))
13244 (expand-file-name filename
13246 (file-name-directory default-name))))
13247 (gnus-make-directory (file-name-directory filename))
13248 (gnus-eval-in-buffer-window gnus-original-article-buffer
13252 (if (and (file-readable-p filename) (mail-file-babyl-p filename))
13253 (gnus-output-to-rmail filename)
13254 (let ((mail-use-rfc822 t))
13255 (rmail-output filename 1 t t))))))
13256 ;; Remember the directory name to save articles.
13257 (setq gnus-newsgroup-last-mail filename)))
13259 (defun gnus-summary-save-in-file (&optional filename)
13260 "Append this article to file.
13261 Optional argument FILENAME specifies file name.
13262 Directory to save to is default to `gnus-article-save-directory'."
13264 (gnus-set-global-variables)
13265 (let ((default-name
13266 (funcall gnus-file-save-name gnus-newsgroup-name
13267 gnus-current-headers gnus-newsgroup-last-file)))
13269 (cond ((eq filename 'default)
13271 (filename filename)
13272 (t (gnus-read-save-file-name
13273 "Save in file:" default-name))))
13274 (gnus-make-directory (file-name-directory filename))
13275 (gnus-eval-in-buffer-window gnus-original-article-buffer
13279 (gnus-output-to-file filename))))
13280 ;; Remember the directory name to save articles.
13281 (setq gnus-newsgroup-last-file filename)))
13283 (defun gnus-summary-save-body-in-file (&optional filename)
13284 "Append this article body to a file.
13285 Optional argument FILENAME specifies file name.
13286 The directory to save in defaults to `gnus-article-save-directory'."
13288 (gnus-set-global-variables)
13289 (let ((default-name
13290 (funcall gnus-file-save-name gnus-newsgroup-name
13291 gnus-current-headers gnus-newsgroup-last-file)))
13293 (cond ((eq filename 'default)
13295 (filename filename)
13296 (t (gnus-read-save-file-name
13297 "Save body in file:" default-name))))
13298 (gnus-make-directory (file-name-directory filename))
13299 (gnus-eval-in-buffer-window gnus-article-buffer
13303 (goto-char (point-min))
13304 (and (search-forward "\n\n" nil t)
13305 (narrow-to-region (point) (point-max)))
13306 (gnus-output-to-file filename))))
13307 ;; Remember the directory name to save articles.
13308 (setq gnus-newsgroup-last-file filename)))
13310 (defun gnus-summary-save-in-pipe (&optional command)
13311 "Pipe this article to subprocess."
13313 (gnus-set-global-variables)
13315 (cond ((eq command 'default)
13316 gnus-last-shell-command)
13318 (t (read-string "Shell command on article: "
13319 gnus-last-shell-command))))
13320 (if (string-equal command "")
13321 (setq command gnus-last-shell-command))
13322 (gnus-eval-in-buffer-window gnus-article-buffer
13325 (shell-command-on-region (point-min) (point-max) command nil)))
13326 (setq gnus-last-shell-command command))
13328 ;; Summary extract commands
13330 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
13331 (let ((buffer-read-only nil)
13332 (article (gnus-summary-article-number))
13334 (or (gnus-summary-goto-subject article)
13335 (error (format "No such article: %d" article)))
13336 (gnus-summary-position-point)
13337 ;; If all commands are to be bunched up on one line, we collect
13339 (if gnus-view-pseudos-separately
13341 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
13344 (setq action (cdr (assq 'action (car ps))))
13345 (setq files (list (cdr (assq 'name (car ps)))))
13346 (while (and ps (cdr ps)
13347 (string= (or action "1")
13348 (or (cdr (assq 'action (cadr ps))) "2")))
13349 (setq files (cons (cdr (assq 'name (cadr ps))) files))
13350 (setcdr ps (cddr ps)))
13353 (if (not (string-match "%s" action))
13354 (setq files (cons " " files)))
13355 (setq files (cons " " files))
13356 (and (assq 'execute (car ps))
13357 (setcdr (assq 'execute (car ps))
13358 (funcall (if (string-match "%s" action)
13361 (mapconcat (lambda (f) f) files " ")))))
13362 (setq ps (cdr ps)))))
13363 (if (and gnus-view-pseudos (not not-view))
13365 (and (assq 'execute (car pslist))
13366 (gnus-execute-command (cdr (assq 'execute (car pslist)))
13367 (eq gnus-view-pseudos 'not-confirm)))
13368 (setq pslist (cdr pslist)))
13371 (setq after-article (or (cdr (assq 'article (car pslist)))
13372 (gnus-summary-article-number)))
13373 (gnus-summary-goto-subject after-article)
13376 (insert " " (file-name-nondirectory
13377 (cdr (assq 'name (car pslist))))
13378 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
13380 (forward-line -1) ; back to `b'
13381 (gnus-add-text-properties
13382 b (1- e) (list 'gnus-number gnus-reffed-article-number
13383 gnus-mouse-face-prop gnus-mouse-face))
13385 after-article gnus-reffed-article-number
13386 gnus-unread-mark b (car pslist) 0 (- e b))
13387 (push gnus-reffed-article-number gnus-newsgroup-unreads)
13388 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
13389 (setq pslist (cdr pslist)))))))
13391 (defun gnus-pseudos< (p1 p2)
13392 (let ((c1 (cdr (assq 'action p1)))
13393 (c2 (cdr (assq 'action p2))))
13394 (and c1 c2 (string< c1 c2))))
13396 (defun gnus-request-pseudo-article (props)
13397 (cond ((assq 'execute props)
13398 (gnus-execute-command (cdr (assq 'execute props)))))
13399 (let ((gnus-current-article (gnus-summary-article-number)))
13400 (run-hooks 'gnus-mark-article-hook)))
13402 (defun gnus-execute-command (command &optional automatic)
13404 (gnus-article-setup-buffer)
13405 (set-buffer gnus-article-buffer)
13406 (setq buffer-read-only nil)
13407 (let ((command (if automatic command (read-string "Command: " command)))
13408 ;; Just binding this here doesn't help, because there might
13409 ;; be output from the process after exiting the scope of
13411 ;; (buffer-read-only nil)
13414 (insert "$ " command "\n\n")
13415 (if gnus-view-pseudo-asynchronously
13416 (start-process "gnus-execute" nil shell-file-name
13417 shell-command-switch command)
13418 (call-process shell-file-name nil t nil
13419 shell-command-switch command)))))
13421 (defun gnus-copy-file (file &optional to)
13424 (list (read-file-name "Copy file: " default-directory)
13425 (read-file-name "Copy file to: " default-directory)))
13426 (gnus-set-global-variables)
13427 (or to (setq to (read-file-name "Copy file to: " default-directory)))
13428 (and (file-directory-p to)
13429 (setq to (concat (file-name-as-directory to)
13430 (file-name-nondirectory file))))
13431 (copy-file file to))
13433 ;; Summary kill commands.
13435 (defun gnus-summary-edit-global-kill (article)
13436 "Edit the \"global\" kill file."
13437 (interactive (list (gnus-summary-article-number)))
13438 (gnus-set-global-variables)
13439 (gnus-group-edit-global-kill article))
13441 (defun gnus-summary-edit-local-kill ()
13442 "Edit a local kill file applied to the current newsgroup."
13444 (gnus-set-global-variables)
13445 (setq gnus-current-headers (gnus-summary-article-header))
13446 (gnus-set-global-variables)
13447 (gnus-group-edit-local-kill
13448 (gnus-summary-article-number) gnus-newsgroup-name))
13452 ;;; Gnus article mode
13455 (put 'gnus-article-mode 'mode-class 'special)
13457 (if gnus-article-mode-map
13459 (setq gnus-article-mode-map (make-keymap))
13460 (suppress-keymap gnus-article-mode-map)
13462 (gnus-define-keys gnus-article-mode-map
13463 " " gnus-article-goto-next-page
13464 "\177" gnus-article-goto-prev-page
13465 [delete] gnus-article-goto-prev-page
13466 "\C-c^" gnus-article-refer-article
13467 "h" gnus-article-show-summary
13468 "s" gnus-article-show-summary
13469 "\C-c\C-m" gnus-article-mail
13470 "?" gnus-article-describe-briefly
13471 gnus-mouse-2 gnus-article-push-button
13472 "\r" gnus-article-press-button
13473 "\t" gnus-article-next-button
13474 "\M-\t" gnus-article-prev-button
13475 "<" beginning-of-bnuffer
13477 "\C-c\C-b" gnus-bug)
13479 (substitute-key-definition
13480 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map))
13482 (defun gnus-article-mode ()
13483 "Major mode for displaying an article.
13485 All normal editing commands are switched off.
13487 The following commands are available:
13489 \\<gnus-article-mode-map>
13490 \\[gnus-article-next-page]\t Scroll the article one page forwards
13491 \\[gnus-article-prev-page]\t Scroll the article one page backwards
13492 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
13493 \\[gnus-article-show-summary]\t Display the summary buffer
13494 \\[gnus-article-mail]\t Send a reply to the address near point
13495 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
13496 \\[gnus-info-find-node]\t Go to the Gnus info node"
13498 (when (and menu-bar-mode
13499 (gnus-visual-p 'article-menu 'menu))
13500 (gnus-article-make-menu-bar))
13501 (kill-all-local-variables)
13502 (gnus-simplify-mode-line)
13503 (setq mode-name "Article")
13504 (setq major-mode 'gnus-article-mode)
13505 (make-local-variable 'minor-mode-alist)
13506 (or (assq 'gnus-show-mime minor-mode-alist)
13507 (setq minor-mode-alist
13508 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
13509 (use-local-map gnus-article-mode-map)
13510 (make-local-variable 'page-delimiter)
13511 (setq page-delimiter gnus-page-delimiter)
13512 (buffer-disable-undo (current-buffer))
13513 (setq buffer-read-only t) ;Disable modification
13514 (run-hooks 'gnus-article-mode-hook))
13516 (defun gnus-article-setup-buffer ()
13517 "Initialize the article buffer."
13518 (let* ((name (if gnus-single-article-buffer "*Article*"
13519 (concat "*Article " gnus-newsgroup-name "*")))
13521 (progn (string-match "\\*Article" name)
13522 (concat " *Original Article"
13523 (substring name (match-end 0))))))
13524 (setq gnus-article-buffer name)
13525 (setq gnus-original-article-buffer original)
13526 ;; This might be a variable local to the summary buffer.
13527 (unless gnus-single-article-buffer
13529 (set-buffer gnus-summary-buffer)
13530 (setq gnus-article-buffer name)
13531 (setq gnus-original-article-buffer original)
13532 (gnus-set-global-variables))
13533 (make-local-variable 'gnus-summary-buffer))
13534 ;; Init original article buffer.
13536 (set-buffer (get-buffer-create gnus-original-article-buffer))
13537 (buffer-disable-undo (current-buffer))
13538 (setq major-mode 'gnus-original-article-mode)
13539 (make-local-variable 'gnus-original-article))
13540 (if (get-buffer name)
13543 (buffer-disable-undo (current-buffer))
13544 (setq buffer-read-only t)
13545 (gnus-add-current-to-buffer-list)
13546 (or (eq major-mode 'gnus-article-mode)
13547 (gnus-article-mode))
13550 (set-buffer (get-buffer-create name))
13551 (gnus-add-current-to-buffer-list)
13552 (gnus-article-mode)
13553 (current-buffer)))))
13555 ;; Set article window start at LINE, where LINE is the number of lines
13556 ;; from the head of the article.
13557 (defun gnus-article-set-window-start (&optional line)
13559 (get-buffer-window gnus-article-buffer t)
13561 (set-buffer gnus-article-buffer)
13562 (goto-char (point-min))
13565 (gnus-message 6 "Moved to bookmark")
13566 (search-forward "\n\n" nil t)
13567 (forward-line line)
13570 (defun gnus-kill-all-overlays ()
13571 "Delete all overlays in the current buffer."
13572 (when (fboundp 'overlay-lists)
13573 (let* ((overlayss (overlay-lists))
13574 (buffer-read-only nil)
13575 (overlays (nconc (car overlayss) (cdr overlayss))))
13577 (delete-overlay (pop overlays))))))
13579 (defun gnus-request-article-this-buffer (article group)
13580 "Get an article and insert it into this buffer."
13581 (let (do-update-line)
13585 (gnus-kill-all-overlays)
13586 (setq group (or group gnus-newsgroup-name))
13588 ;; Open server if it has closed.
13589 (gnus-check-server (gnus-find-method-for-group group))
13591 ;; Using `gnus-request-article' directly will insert the article into
13592 ;; `nntp-server-buffer' - so we'll save some time by not having to
13593 ;; copy it from the server buffer into the article buffer.
13595 ;; We only request an article by message-id when we do not have the
13596 ;; headers for it, so we'll have to get those.
13597 (when (stringp article)
13598 (let ((gnus-override-method gnus-refer-article-method))
13599 (gnus-read-header article)))
13601 ;; If the article number is negative, that means that this article
13602 ;; doesn't belong in this newsgroup (possibly), so we find its
13603 ;; message-id and request it by id instead of number.
13604 (when (and (numberp article)
13605 gnus-summary-buffer
13606 (get-buffer gnus-summary-buffer)
13607 (buffer-name (get-buffer gnus-summary-buffer)))
13609 (set-buffer gnus-summary-buffer)
13610 (let ((header (gnus-summary-article-header article)))
13613 ((memq article gnus-newsgroup-sparse)
13614 ;; This is a sparse gap article.
13615 (setq do-update-line article)
13616 (setq article (mail-header-id header))
13617 (let ((gnus-override-method gnus-refer-article-method))
13618 (gnus-read-header article))
13619 (setq gnus-newsgroup-sparse
13620 (delq article gnus-newsgroup-sparse)))
13622 ;; It's a real article.
13623 (setq article (mail-header-id header)))
13625 ;; It is an extracted pseudo-article.
13626 (setq article 'pseudo)
13627 (gnus-request-pseudo-article header))))
13629 (let ((method (gnus-find-method-for-group
13630 gnus-newsgroup-name)))
13631 (if (not (eq (car method) 'nneething))
13633 (let ((dir (concat (file-name-as-directory (nth 1 method))
13634 (mail-header-subject header))))
13635 (if (file-directory-p dir)
13637 (setq article 'nneething)
13638 (gnus-group-enter-directory dir)))))))))
13641 ;; Refuse to select canceled articles.
13642 ((and (numberp article)
13643 gnus-summary-buffer
13644 (get-buffer gnus-summary-buffer)
13645 (buffer-name (get-buffer gnus-summary-buffer))
13646 (eq (cdr (save-excursion
13647 (set-buffer gnus-summary-buffer)
13648 (assq article gnus-newsgroup-reads)))
13649 gnus-canceled-mark))
13651 ;; We first check `gnus-original-article-buffer'.
13652 ((and (get-buffer gnus-original-article-buffer)
13655 (set-buffer gnus-original-article-buffer)
13656 (and (equal (car gnus-original-article) group)
13657 (eq (cdr gnus-original-article) article))))
13658 (insert-buffer-substring gnus-original-article-buffer)
13660 ;; Check the backlog.
13661 ((and gnus-keep-backlog
13662 (gnus-backlog-request-article group article (current-buffer)))
13664 ;; Check the cache.
13665 ((and gnus-use-cache
13667 (gnus-cache-request-article article group))
13669 ;; Get the article and put into the article buffer.
13670 ((or (stringp article) (numberp article))
13671 (let ((gnus-override-method
13672 (and (stringp article) gnus-refer-article-method))
13673 (buffer-read-only nil))
13675 (gnus-kill-all-overlays)
13676 (if (gnus-request-article article group (current-buffer))
13678 (and gnus-keep-backlog
13680 (gnus-backlog-enter-article
13681 group article (current-buffer)))
13683 ;; It was a pseudo.
13686 ;; Take the article from the original article buffer
13687 ;; and place it in the buffer it's supposed to be in.
13688 (when (and (get-buffer gnus-article-buffer)
13689 ;;(numberp article)
13690 (equal (buffer-name (current-buffer))
13691 (buffer-name (get-buffer gnus-article-buffer))))
13693 (if (get-buffer gnus-original-article-buffer)
13694 (set-buffer (get-buffer gnus-original-article-buffer))
13695 (set-buffer (get-buffer-create gnus-original-article-buffer))
13696 (buffer-disable-undo (current-buffer))
13697 (setq major-mode 'gnus-original-article-mode)
13698 (setq buffer-read-only t)
13699 (gnus-add-current-to-buffer-list))
13700 (let (buffer-read-only)
13702 (insert-buffer-substring gnus-article-buffer))
13703 (setq gnus-original-article (cons group article))))
13705 ;; Update sparse articles.
13706 (when (and do-update-line
13707 (or (numberp article)
13708 (stringp article)))
13709 (let ((buf (current-buffer)))
13710 (set-buffer gnus-summary-buffer)
13711 (gnus-summary-update-article do-update-line)
13712 (gnus-summary-goto-subject do-update-line nil t)
13713 (set-window-point (get-buffer-window (current-buffer) t)
13715 (set-buffer buf))))))
13717 (defun gnus-read-header (id &optional header)
13718 "Read the headers of article ID and enter them into the Gnus system."
13719 (let ((group gnus-newsgroup-name)
13720 (gnus-override-method
13721 (and (gnus-news-group-p gnus-newsgroup-name)
13722 gnus-refer-article-method))
13724 ;; First we check to see whether the header in question is already
13727 ;; This is a Message-ID.
13728 (setq header (or header (gnus-id-to-header id)))
13729 ;; This is an article number.
13730 (setq header (or header (gnus-summary-article-header id))))
13732 (not (memq (mail-header-number header) gnus-newsgroup-sparse)))
13733 ;; We have found the header.
13735 ;; We have to really fetch the header to this article.
13736 (when (setq where (gnus-request-head id group))
13738 (set-buffer nntp-server-buffer)
13739 (goto-char (point-max))
13741 (goto-char (point-min))
13745 ((cdr where) (cdr where))
13746 (header (mail-header-number header))
13747 (t gnus-reffed-article-number))
13749 (insert " Article retrieved.\n"))
13751 ; (memq (mail-header-number header) gnus-newsgroup-sparse))
13752 ; (setcar (gnus-id-to-thread id) nil))
13753 (if (not (setq header (car (gnus-get-newsgroup-headers))))
13754 () ; Malformed head.
13755 (unless (memq (mail-header-number header) gnus-newsgroup-sparse)
13756 (if (and (stringp id)
13757 (not (string= (gnus-group-real-name group)
13759 ;; If we fetched by Message-ID and the article came
13760 ;; from a different group, we fudge some bogus article
13761 ;; numbers for this article.
13762 (mail-header-set-number header gnus-reffed-article-number))
13763 (decf gnus-reffed-article-number)
13764 (gnus-remove-header (mail-header-number header))
13765 (push header gnus-newsgroup-headers)
13766 (setq gnus-current-headers header)
13767 (push (mail-header-number header) gnus-newsgroup-limit))
13770 (defun gnus-remove-header (number)
13771 "Remove header NUMBER from `gnus-newsgroup-headers'."
13772 (if (and gnus-newsgroup-headers
13773 (= number (mail-header-number (car gnus-newsgroup-headers))))
13774 (pop gnus-newsgroup-headers)
13775 (let ((headers gnus-newsgroup-headers))
13776 (while (and (cdr headers)
13777 (not (= number (mail-header-number (cadr headers)))))
13779 (when (cdr headers)
13780 (setcdr headers (cddr headers))))))
13782 (defun gnus-article-prepare (article &optional all-headers header)
13783 "Prepare ARTICLE in article mode buffer.
13784 ARTICLE should either be an article number or a Message-ID.
13785 If ARTICLE is an id, HEADER should be the article headers.
13786 If ALL-HEADERS is non-nil, no headers are hidden."
13788 ;; Make sure we start in a summary buffer.
13789 (unless (eq major-mode 'gnus-summary-mode)
13790 (set-buffer gnus-summary-buffer))
13791 (setq gnus-summary-buffer (current-buffer))
13792 ;; Make sure the connection to the server is alive.
13793 (unless (gnus-server-opened
13794 (gnus-find-method-for-group gnus-newsgroup-name))
13795 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
13796 (gnus-request-group gnus-newsgroup-name t))
13797 (let* ((article (if header (mail-header-number header) article))
13798 (summary-buffer (current-buffer))
13799 (internal-hook gnus-article-internal-prepare-hook)
13800 (group gnus-newsgroup-name)
13803 (gnus-article-setup-buffer)
13804 (set-buffer gnus-article-buffer)
13805 ;; Deactivate active regions.
13806 (when (and (boundp 'transient-mark-mode)
13807 transient-mark-mode)
13808 (setq mark-active nil))
13809 (if (not (setq result (let ((buffer-read-only nil))
13810 (gnus-request-article-this-buffer
13812 ;; There is no such article.
13814 (when (and (numberp article)
13815 (not (memq article gnus-newsgroup-sparse)))
13816 (setq gnus-article-current
13817 (cons gnus-newsgroup-name article))
13818 (set-buffer gnus-summary-buffer)
13819 (setq gnus-current-article article)
13820 (gnus-summary-mark-article article gnus-canceled-mark))
13821 (unless (memq article gnus-newsgroup-sparse)
13823 1 "No such article (may have expired or been canceled)")))
13824 (if (or (eq result 'pseudo) (eq result 'nneething))
13827 (set-buffer summary-buffer)
13828 (setq gnus-last-article gnus-current-article
13829 gnus-newsgroup-history (cons gnus-current-article
13830 gnus-newsgroup-history)
13831 gnus-current-article 0
13832 gnus-current-headers nil
13833 gnus-article-current nil)
13834 (if (eq result 'nneething)
13835 (gnus-configure-windows 'summary)
13836 (gnus-configure-windows 'article))
13837 (gnus-set-global-variables))
13838 (gnus-set-mode-line 'article))
13839 ;; The result from the `request' was an actual article -
13840 ;; or at least some text that is now displayed in the
13842 (if (and (numberp article)
13843 (not (eq article gnus-current-article)))
13844 ;; Seems like a new article has been selected.
13845 ;; `gnus-current-article' must be an article number.
13847 (set-buffer summary-buffer)
13848 (setq gnus-last-article gnus-current-article
13849 gnus-newsgroup-history (cons gnus-current-article
13850 gnus-newsgroup-history)
13851 gnus-current-article article
13852 gnus-current-headers
13853 (gnus-summary-article-header gnus-current-article)
13854 gnus-article-current
13855 (cons gnus-newsgroup-name gnus-current-article))
13856 (unless (vectorp gnus-current-headers)
13857 (setq gnus-current-headers nil))
13858 (gnus-summary-show-thread)
13859 (run-hooks 'gnus-mark-article-hook)
13860 (gnus-set-mode-line 'summary)
13861 (and (gnus-visual-p 'article-highlight 'highlight)
13862 (run-hooks 'gnus-visual-mark-article-hook))
13863 ;; Set the global newsgroup variables here.
13864 ;; Suggested by Jim Sisolak
13865 ;; <sisolak@trans4.neep.wisc.edu>.
13866 (gnus-set-global-variables)
13867 (setq gnus-have-all-headers
13868 (or all-headers gnus-show-all-headers))
13869 (and gnus-use-cache
13870 (vectorp (gnus-summary-article-header article))
13871 (gnus-cache-possibly-enter-article
13873 (gnus-summary-article-header article)
13874 (memq article gnus-newsgroup-marked)
13875 (memq article gnus-newsgroup-dormant)
13876 (memq article gnus-newsgroup-unreads)))))
13877 (when (or (numberp article)
13879 ;; Hooks for getting information from the article.
13880 ;; This hook must be called before being narrowed.
13881 (let (buffer-read-only)
13882 (run-hooks 'internal-hook)
13883 (run-hooks 'gnus-article-prepare-hook)
13884 ;; Decode MIME message.
13886 (if (or (not gnus-strict-mime)
13887 (gnus-fetch-field "Mime-Version"))
13888 (funcall gnus-show-mime-method)
13889 (funcall gnus-decode-encoded-word-method)))
13890 ;; Perform the article display hooks.
13891 (run-hooks 'gnus-article-display-hook))
13893 (goto-char (point-min))
13894 (and gnus-break-pages (gnus-narrow-to-page)))
13895 (gnus-set-mode-line 'article)
13896 (gnus-configure-windows 'article)
13897 (goto-char (point-min))
13900 (defun gnus-article-show-all-headers ()
13901 "Show all article headers in article mode buffer."
13903 (gnus-article-setup-buffer)
13904 (set-buffer gnus-article-buffer)
13905 (let ((buffer-read-only nil))
13906 (gnus-unhide-text (point-min) (point-max)))))
13908 (defun gnus-article-hide-headers-if-wanted ()
13909 "Hide unwanted headers if `gnus-have-all-headers' is nil.
13910 Provided for backwards compatibility."
13911 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers)
13912 gnus-inhibit-hiding
13913 (gnus-article-hide-headers)))
13915 (defsubst gnus-article-header-rank ()
13916 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
13917 (let ((list gnus-sorted-header-list)
13920 (when (looking-at (car list))
13922 (setq list (cdr list))
13926 (defun gnus-article-hide-headers (&optional arg delete)
13927 "Toggle whether to hide unwanted headers and possibly sort them as well.
13928 If given a negative prefix, always show; if given a positive prefix,
13930 (interactive (gnus-hidden-arg))
13931 (if (gnus-article-check-hidden-text 'headers arg)
13932 ;; Show boring headers as well.
13933 (gnus-article-show-hidden-text 'boring-headers)
13934 ;; This function might be inhibited.
13935 (unless gnus-inhibit-hiding
13937 (set-buffer gnus-article-buffer)
13939 (let ((buffer-read-only nil)
13940 (props (nconc (list 'gnus-type 'headers)
13941 gnus-hidden-properties))
13942 (max (1+ (length gnus-sorted-header-list)))
13943 (ignored (when (not (stringp gnus-visible-headers))
13944 (cond ((stringp gnus-ignored-headers)
13945 gnus-ignored-headers)
13946 ((listp gnus-ignored-headers)
13947 (mapconcat 'identity gnus-ignored-headers
13950 (cond ((stringp gnus-visible-headers)
13951 gnus-visible-headers)
13952 ((and gnus-visible-headers
13953 (listp gnus-visible-headers))
13954 (mapconcat 'identity gnus-visible-headers "\\|"))))
13955 (inhibit-point-motion-hooks t)
13957 ;; First we narrow to just the headers.
13959 (goto-char (point-min))
13960 ;; Hide any "From " lines at the beginning of (mail) articles.
13961 (while (looking-at "From ")
13965 (delete-region (point-min) (point))
13966 (gnus-hide-text (point-min) (point) props)))
13967 ;; Then treat the rest of the header lines.
13970 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
13971 ;; Then we use the two regular expressions
13972 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
13973 ;; select which header lines is to remain visible in the
13975 (goto-char (point-min))
13976 (while (re-search-forward "^[^ \t]*:" nil t)
13977 (beginning-of-line)
13978 ;; We add the headers we want to keep to a list and delete
13979 ;; them from the buffer.
13980 (gnus-put-text-property
13981 (point) (1+ (point)) 'message-rank
13982 (if (or (and visible (looking-at visible))
13984 (not (looking-at ignored))))
13985 (gnus-article-header-rank)
13988 (message-sort-headers-1)
13989 (when (setq beg (text-property-any
13990 (point-min) (point-max) 'message-rank (+ 2 max)))
13991 ;; We make the unwanted headers invisible.
13993 (delete-region beg (point-max))
13994 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
13995 (gnus-hide-text-type beg (point-max) 'headers))
13996 ;; Work around XEmacs lossage.
13997 (gnus-put-text-property (point-min) beg 'invisible nil))))))))
13999 (defun gnus-article-hide-boring-headers (&optional arg)
14000 "Toggle hiding of headers that aren't very interesting.
14001 If given a negative prefix, always show; if given a positive prefix,
14003 (interactive (gnus-hidden-arg))
14004 (unless (gnus-article-check-hidden-text 'boring-headers arg)
14006 (set-buffer gnus-article-buffer)
14008 (let ((buffer-read-only nil)
14009 (list gnus-boring-article-headers)
14010 (inhibit-point-motion-hooks t)
14012 (nnheader-narrow-to-headers)
14014 (setq elem (pop list))
14015 (goto-char (point-min))
14017 ;; Hide empty headers.
14019 (while (re-search-forward "^[^:]+:[ \t]\n[^ \t]" nil t)
14021 (gnus-hide-text-type
14022 (progn (beginning-of-line) (point))
14025 (if (re-search-forward "^[^ \t]" nil t)
14026 (match-beginning 0)
14029 ;; Hide boring Newsgroups header.
14030 ((eq elem 'newsgroups)
14031 (when (equal (message-fetch-field "newsgroups")
14032 (gnus-group-real-name gnus-newsgroup-name))
14033 (gnus-article-hide-header "newsgroups")))
14034 ((eq elem 'followup-to)
14035 (when (equal (message-fetch-field "followup-to")
14036 (message-fetch-field "newsgroups"))
14037 (gnus-article-hide-header "followup-to")))
14038 ((eq elem 'reply-to)
14039 (let ((from (message-fetch-field "from"))
14040 (reply-to (message-fetch-field "reply-to")))
14044 (nth 1 (funcall gnus-extract-address-components from))
14045 (nth 1 (funcall gnus-extract-address-components
14047 (gnus-article-hide-header "reply-to"))))
14049 (let ((date (message-fetch-field "date")))
14051 (< (gnus-days-between date (current-time-string))
14053 (gnus-article-hide-header "date")))))))))))
14055 (defun gnus-article-hide-header (header)
14057 (goto-char (point-min))
14058 (when (re-search-forward (concat "^" header ":") nil t)
14059 (gnus-hide-text-type
14060 (progn (beginning-of-line) (point))
14063 (if (re-search-forward "^[^ \t]" nil t)
14064 (match-beginning 0)
14066 'boring-headers))))
14068 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
14069 (defun gnus-article-treat-overstrike ()
14070 "Translate overstrikes into bold text."
14073 (set-buffer gnus-article-buffer)
14074 (let ((buffer-read-only nil))
14075 (while (search-forward "\b" nil t)
14076 (let ((next (following-char))
14077 (previous (char-after (- (point) 2))))
14079 ((eq next previous)
14080 (gnus-put-text-property (- (point) 2) (point) 'invisible t)
14081 (gnus-put-text-property (point) (1+ (point)) 'face 'bold))
14083 (gnus-put-text-property (1- (point)) (1+ (point)) 'invisible t)
14084 (gnus-put-text-property
14085 (- (point) 2) (1- (point)) 'face 'underline))
14087 (gnus-put-text-property (- (point) 2) (point) 'invisible t)
14088 (gnus-put-text-property
14089 (point) (1+ (point)) 'face 'underline))))))))
14091 (defun gnus-article-word-wrap ()
14092 "Format too long lines."
14095 (set-buffer gnus-article-buffer)
14096 (let ((buffer-read-only nil))
14098 (goto-char (point-min))
14099 (search-forward "\n\n" nil t)
14101 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
14102 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
14103 (adaptive-fill-mode t))
14104 (while (not (eobp))
14105 (and (>= (current-column) (min fill-column (window-width)))
14106 (/= (preceding-char) ?:)
14107 (fill-paragraph nil))
14108 (end-of-line 2))))))
14110 (defun gnus-article-remove-cr ()
14111 "Remove carriage returns from an article."
14114 (set-buffer gnus-article-buffer)
14115 (let ((buffer-read-only nil))
14116 (goto-char (point-min))
14117 (while (search-forward "\r" nil t)
14118 (replace-match "" t t)))))
14120 (defun gnus-article-remove-trailing-blank-lines ()
14121 "Remove all trailing blank lines from the article."
14124 (set-buffer gnus-article-buffer)
14125 (let ((buffer-read-only nil))
14126 (goto-char (point-max))
14130 (while (looking-at "^[ \t]*$")
14135 (defun gnus-article-display-x-face (&optional force)
14136 "Look for an X-Face header and display it if present."
14137 (interactive (list 'force))
14139 (set-buffer gnus-article-buffer)
14140 ;; Delete the old process, if any.
14141 (when (process-status "gnus-x-face")
14142 (delete-process "gnus-x-face"))
14143 (let ((inhibit-point-motion-hooks t)
14144 (case-fold-search nil)
14147 (nnheader-narrow-to-headers)
14148 (setq from (message-fetch-field "from"))
14149 (goto-char (point-min))
14150 (when (and gnus-article-x-face-command
14152 ;; Check whether this face is censored.
14153 (not gnus-article-x-face-too-ugly)
14154 (and gnus-article-x-face-too-ugly from
14155 (not (string-match gnus-article-x-face-too-ugly
14157 ;; Has to be present.
14158 (re-search-forward "^X-Face: " nil t))
14159 ;; We now have the area of the buffer where the X-Face is stored.
14160 (let ((beg (point))
14161 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
14162 ;; We display the face.
14163 (if (symbolp gnus-article-x-face-command)
14164 ;; The command is a lisp function, so we call it.
14165 (if (gnus-functionp gnus-article-x-face-command)
14166 (funcall gnus-article-x-face-command beg end)
14167 (error "%s is not a function" gnus-article-x-face-command))
14168 ;; The command is a string, so we interpret the command
14169 ;; as a, well, command, and fork it off.
14170 (let ((process-connection-type nil))
14171 (process-kill-without-query
14173 "gnus-x-face" nil shell-file-name shell-command-switch
14174 gnus-article-x-face-command))
14175 (process-send-region "gnus-x-face" beg end)
14176 (process-send-eof "gnus-x-face")))))))))
14178 (defalias 'gnus-headers-decode-quoted-printable 'gnus-decode-rfc1522)
14179 (defun gnus-decode-rfc1522 ()
14180 "Hack to remove QP encoding from headers."
14181 (let ((case-fold-search t)
14182 (inhibit-point-motion-hooks t)
14183 (buffer-read-only nil)
14187 (goto-char (point-min))
14188 (or (search-forward "\n\n" nil t) (point-max)))
14190 (while (re-search-forward
14191 "=\\?iso-8859-1\\?q\\?\\([^?\t\n]*\\)\\?=" nil t)
14192 (setq string (match-string 1))
14193 (narrow-to-region (match-beginning 0) (match-end 0))
14194 (delete-region (point-min) (point-max))
14196 (gnus-mime-decode-quoted-printable (goto-char (point-min)) (point-max))
14197 (subst-char-in-region (point-min) (point-max) ?_ ? )
14199 (goto-char (point-min))))))
14201 (defun gnus-article-de-quoted-unreadable (&optional force)
14202 "Do a naive translation of a quoted-printable-encoded article.
14203 This is in no way, shape or form meant as a replacement for real MIME
14204 processing, but is simply a stop-gap measure until MIME support is
14206 If FORCE, decode the article whether it is marked as quoted-printable
14208 (interactive (list 'force))
14210 (set-buffer gnus-article-buffer)
14211 (let ((case-fold-search t)
14212 (buffer-read-only nil)
14213 (type (gnus-fetch-field "content-transfer-encoding")))
14214 (gnus-decode-rfc1522)
14216 (and type (string-match "quoted-printable" (downcase type))))
14217 (goto-char (point-min))
14218 (search-forward "\n\n" nil 'move)
14219 (gnus-mime-decode-quoted-printable (point) (point-max))))))
14221 (defun gnus-mime-decode-quoted-printable (from to)
14222 "Decode Quoted-Printable in the region between FROM and TO."
14225 (while (search-forward "=" to t)
14226 (cond ((eq (following-char) ?\n)
14229 ((looking-at "[0-9A-F][0-9A-F]")
14230 (subst-char-in-region
14231 (1- (point)) (point) ?=
14232 (hexl-hex-string-to-integer
14233 (buffer-substring (point) (+ 2 (point)))))
14237 ((gnus-message 3 "Malformed MIME quoted-printable message")))))
14239 (defun gnus-article-hide-pgp (&optional arg)
14240 "Toggle hiding of any PGP headers and signatures in the current article.
14241 If given a negative prefix, always show; if given a positive prefix,
14243 (interactive (gnus-hidden-arg))
14244 (unless (gnus-article-check-hidden-text 'pgp arg)
14246 (set-buffer gnus-article-buffer)
14247 (let ((props (nconc (list 'gnus-type 'pgp) gnus-hidden-properties))
14248 buffer-read-only beg end)
14250 (goto-char (point-min))
14251 ;; Hide the "header".
14252 (and (search-forward "\n-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
14253 (gnus-hide-text (match-beginning 0) (match-end 0) props))
14255 ;; Hide the actual signature.
14256 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
14257 (setq end (1+ (match-beginning 0)))
14260 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
14262 ;; Perhaps we shouldn't hide to the end of the buffer
14263 ;; if there is no end to the signature?
14266 ;; Hide "- " PGP quotation markers.
14267 (when (and beg end)
14268 (narrow-to-region beg end)
14269 (goto-char (point-min))
14270 (while (re-search-forward "^- " nil t)
14271 (gnus-hide-text (match-beginning 0) (match-end 0) props))
14274 (defun gnus-article-hide-signature (&optional arg)
14275 "Hide the signature in the current article.
14276 If given a negative prefix, always show; if given a positive prefix,
14278 (interactive (gnus-hidden-arg))
14279 (unless (gnus-article-check-hidden-text 'signature arg)
14281 (set-buffer gnus-article-buffer)
14283 (let ((buffer-read-only nil))
14284 (when (gnus-narrow-to-signature)
14285 (gnus-hide-text-type (point-min) (point-max) 'signature)))))))
14287 (defun gnus-article-strip-leading-blank-lines ()
14288 "Remove all blank lines from the beginning of the article."
14291 (set-buffer gnus-article-buffer)
14292 (let (buffer-read-only)
14293 (goto-char (point-min))
14294 (when (search-forward "\n\n" nil t)
14295 (while (looking-at "[ \t]$")
14296 (gnus-delete-line))))))
14298 (defvar mime::preview/content-list)
14299 (defvar mime::preview-content-info/point-min)
14300 (defun gnus-narrow-to-signature ()
14301 "Narrow to the signature."
14303 (if (and (boundp 'mime::preview/content-list)
14304 mime::preview/content-list)
14305 (let ((pcinfo (car (last mime::preview/content-list))))
14308 (funcall (intern "mime::preview-content-info/point-min") pcinfo)
14311 (goto-char (point-max))
14312 (when (re-search-backward gnus-signature-separator nil t)
14314 (when (or (null gnus-signature-limit)
14315 (and (numberp gnus-signature-limit)
14316 (< (- (point-max) (point)) gnus-signature-limit))
14317 (and (gnus-functionp gnus-signature-limit)
14318 (funcall gnus-signature-limit))
14319 (and (stringp gnus-signature-limit)
14320 (not (re-search-forward gnus-signature-limit nil t))))
14321 (narrow-to-region (point) (point-max))
14324 (defun gnus-hidden-arg ()
14325 "Return the current prefix arg as a number, or 0 if no prefix."
14326 (list (if current-prefix-arg
14327 (prefix-numeric-value current-prefix-arg)
14330 (defun gnus-article-check-hidden-text (type arg)
14331 "Return nil if hiding is necessary.
14332 Arg can be nil or a number. Nil and positive means hide, negative
14333 means show, 0 means toggle."
14335 (set-buffer gnus-article-buffer)
14336 (let ((hide (gnus-article-hidden-text-p type)))
14342 (gnus-article-show-hidden-text type))
14344 (if (eq hide 'hidden)
14345 (gnus-article-show-hidden-text type)
14348 (defun gnus-article-hidden-text-p (type)
14349 "Say whether the current buffer contains hidden text of type TYPE."
14350 (let ((pos (text-property-any (point-min) (point-max) 'gnus-type type)))
14352 (if (get-text-property pos 'invisible)
14356 (defun gnus-article-hide (&optional arg force)
14357 "Hide all the gruft in the current article.
14358 This means that PGP stuff, signatures, cited text and (some)
14359 headers will be hidden.
14360 If given a prefix, show the hidden text instead."
14361 (interactive (list current-prefix-arg 'force))
14362 (gnus-article-hide-headers arg)
14363 (gnus-article-hide-pgp arg)
14364 (gnus-article-hide-citation-maybe arg force)
14365 (gnus-article-hide-signature arg))
14367 (defun gnus-article-show-hidden-text (type &optional hide)
14368 "Show all hidden text of type TYPE.
14369 If HIDE, hide the text instead."
14371 (set-buffer gnus-article-buffer)
14372 (let ((buffer-read-only nil)
14373 (inhibit-point-motion-hooks t)
14375 (while (gnus-goto-char (text-property-any
14376 beg (point-max) 'gnus-type type))
14380 (gnus-hide-text beg (point) gnus-hidden-properties)
14381 (gnus-unhide-text beg (point)))
14382 (setq beg (point)))
14385 (defvar gnus-article-time-units
14386 `((year . ,(* 365.25 24 60 60))
14387 (week . ,(* 7 24 60 60))
14388 (day . ,(* 24 60 60))
14389 (hour . ,(* 60 60))
14392 "Mapping from time units to seconds.")
14394 (defun gnus-article-date-ut (&optional type highlight)
14395 "Convert DATE date to universal time in the current article.
14396 If TYPE is `local', convert to local time; if it is `lapsed', output
14397 how much time has lapsed since DATE."
14398 (interactive (list 'ut t))
14399 (let* ((header (or gnus-current-headers
14400 (gnus-summary-article-header) ""))
14401 (date (and (vectorp header) (mail-header-date header)))
14402 (date-regexp "^Date: \\|^X-Sent: ")
14403 (now (current-time))
14404 (inhibit-point-motion-hooks t)
14406 (when (and date (not (string= date "")))
14408 (set-buffer gnus-article-buffer)
14410 (nnheader-narrow-to-headers)
14411 (let ((buffer-read-only nil))
14412 ;; Delete any old Date headers.
14413 (if (re-search-forward date-regexp nil t)
14415 (setq bface (get-text-property (gnus-point-at-bol) 'face)
14416 eface (get-text-property (1- (gnus-point-at-eol))
14418 (message-remove-header date-regexp t)
14419 (beginning-of-line))
14420 (goto-char (point-max)))
14421 (insert (gnus-make-date-line date type))
14422 ;; Do highlighting.
14424 (when (and (gnus-visual-p 'article-highlight 'highlight)
14425 (looking-at "\\([^:]+\\): *\\(.*\\)$"))
14426 (gnus-put-text-property (match-beginning 1) (match-end 1)
14428 (gnus-put-text-property (match-beginning 2) (match-end 2)
14429 'face eface))))))))
14431 (defun gnus-make-date-line (date type)
14432 "Return a DATE line of TYPE."
14434 ;; Convert to the local timezone. We have to slap a
14435 ;; `condition-case' round the calls to the timezone
14436 ;; functions since they aren't particularly resistant to
14439 (concat "Date: " (condition-case ()
14440 (timezone-make-date-arpa-standard date)
14443 ;; Convert to Universal Time.
14447 (timezone-make-date-arpa-standard date nil "UT")
14450 ;; Get the original date from the article.
14451 ((eq type 'original)
14452 (concat "Date: " date "\n"))
14453 ;; Do an X-Sent lapsed format.
14455 ;; If the date is seriously mangled, the timezone
14456 ;; functions are liable to bug out, so we condition-case
14457 ;; the entire thing.
14458 (let* ((now (current-time))
14463 (timezone-make-date-arpa-standard
14464 (current-time-string now)
14465 (current-time-zone now) "UT"))
14467 (timezone-make-date-arpa-standard
14470 (real-sec (+ (* (float (car real-time)) 65536)
14472 (sec (abs real-sec))
14475 ((equal real-time '(0 0))
14476 "X-Sent: Unknown\n")
14482 ;; This is a bit convoluted, but basically we go
14483 ;; through the time units for years, weeks, etc,
14484 ;; and divide things to see whether that results
14485 ;; in positive answers.
14488 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
14489 ;; The (remaining) seconds are too few to
14490 ;; be divided into this time unit.
14492 ;; It's big enough, so we output it.
14493 (setq sec (- sec (* num (cdr unit))))
14495 (concat (if prev ", " "") (int-to-string
14497 " " (symbol-name (car unit))
14498 (if (> num 1) "s" ""))
14500 gnus-article-time-units "")
14501 ;; If dates are odd, then it might appear like the
14502 ;; article was sent in the future.
14505 " in the future\n"))))))
14507 (error "Unknown conversion type: %s" type))))
14509 (defun gnus-article-date-local (&optional highlight)
14510 "Convert the current article date to the local timezone."
14511 (interactive (list t))
14512 (gnus-article-date-ut 'local highlight))
14514 (defun gnus-article-date-original (&optional highlight)
14515 "Convert the current article date to what it was originally.
14516 This is only useful if you have used some other date conversion
14517 function and want to see what the date was before converting."
14518 (interactive (list t))
14519 (gnus-article-date-ut 'original highlight))
14521 (defun gnus-article-date-lapsed (&optional highlight)
14522 "Convert the current article date to time lapsed since it was sent."
14523 (interactive (list t))
14524 (gnus-article-date-ut 'lapsed highlight))
14526 (defun gnus-article-maybe-highlight ()
14527 "Do some article highlighting if `gnus-visual' is non-nil."
14528 (if (gnus-visual-p 'article-highlight 'highlight)
14529 (gnus-article-highlight-some)))
14531 ;;; Article savers.
14533 (defun gnus-output-to-rmail (file-name)
14534 "Append the current article to an Rmail file named FILE-NAME."
14536 ;; Most of these codes are borrowed from rmailout.el.
14537 (setq file-name (expand-file-name file-name))
14538 (setq rmail-default-rmail-file file-name)
14539 (let ((artbuf (current-buffer))
14540 (tmpbuf (get-buffer-create " *Gnus-output*")))
14542 (or (get-file-buffer file-name)
14543 (file-exists-p file-name)
14544 (if (gnus-yes-or-no-p
14545 (concat "\"" file-name "\" does not exist, create it? "))
14546 (let ((file-buffer (create-file-buffer file-name)))
14548 (set-buffer file-buffer)
14549 (rmail-insert-rmail-file-header)
14550 (let ((require-final-newline nil))
14551 (write-region (point-min) (point-max) file-name t 1)))
14552 (kill-buffer file-buffer))
14553 (error "Output file does not exist")))
14554 (set-buffer tmpbuf)
14555 (buffer-disable-undo (current-buffer))
14557 (insert-buffer-substring artbuf)
14558 (gnus-convert-article-to-rmail)
14559 ;; Decide whether to append to a file or to an Emacs buffer.
14560 (let ((outbuf (get-file-buffer file-name)))
14562 (append-to-file (point-min) (point-max) file-name)
14563 ;; File has been visited, in buffer OUTBUF.
14564 (set-buffer outbuf)
14565 (let ((buffer-read-only nil)
14566 (msg (and (boundp 'rmail-current-message)
14567 (symbol-value 'rmail-current-message))))
14568 ;; If MSG is non-nil, buffer is in RMAIL mode.
14571 (narrow-to-region (point-max) (point-max))))
14572 (insert-buffer-substring tmpbuf)
14575 (goto-char (point-min))
14577 (search-backward "\^_")
14578 (narrow-to-region (point) (point-max))
14579 (goto-char (1+ (point-min)))
14580 (rmail-count-new-messages t)
14581 (rmail-show-message msg)))))))
14582 (kill-buffer tmpbuf)))
14584 (defun gnus-output-to-file (file-name)
14585 "Append the current article to a file named FILE-NAME."
14586 (let ((artbuf (current-buffer)))
14587 (nnheader-temp-write nil
14588 (insert-buffer-substring artbuf)
14589 ;; Append newline at end of the buffer as separator, and then
14590 ;; save it to file.
14591 (goto-char (point-max))
14593 (append-to-file (point-min) (point-max) file-name))))
14595 (defun gnus-convert-article-to-rmail ()
14596 "Convert article in current buffer to Rmail message format."
14597 (let ((buffer-read-only nil))
14598 ;; Convert article directly into Babyl format.
14599 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
14600 (goto-char (point-min))
14601 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
14602 (while (search-forward "\n\^_" nil t) ;single char
14603 (replace-match "\n^_" t t)) ;2 chars: "^" and "_"
14604 (goto-char (point-max))
14607 (defun gnus-narrow-to-page (&optional arg)
14608 "Narrow the article buffer to a page.
14609 If given a numerical ARG, move forward ARG pages."
14611 (setq arg (if arg (prefix-numeric-value arg) 0))
14613 (set-buffer gnus-article-buffer)
14614 (goto-char (point-min))
14616 (when (gnus-visual-p 'page-marker)
14617 (let ((buffer-read-only nil))
14618 (gnus-remove-text-with-property 'gnus-prev)
14619 (gnus-remove-text-with-property 'gnus-next)))
14622 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
14624 (re-search-forward page-delimiter nil 'move arg)))
14625 (goto-char (match-end 0)))
14628 (if (re-search-forward page-delimiter nil 'move)
14629 (match-beginning 0)
14631 (when (and (gnus-visual-p 'page-marker)
14632 (not (= (point-min) 1)))
14634 (goto-char (point-min))
14635 (gnus-insert-prev-page-button)))
14636 (when (and (gnus-visual-p 'page-marker)
14637 (not (= (1- (point-max)) (buffer-size))))
14639 (goto-char (point-max))
14640 (gnus-insert-next-page-button)))))
14642 ;; Article mode commands
14644 (defun gnus-article-goto-next-page ()
14645 "Show the next page of the article."
14647 (when (gnus-article-next-page)
14648 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
14650 (defun gnus-article-goto-prev-page ()
14651 "Show the next page of the article."
14653 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))
14654 (gnus-article-prev-page nil)))
14656 (defun gnus-article-next-page (&optional lines)
14657 "Show the next page of the current article.
14658 If end of article, return non-nil. Otherwise return nil.
14659 Argument LINES specifies lines to be scrolled up."
14661 (move-to-window-line -1)
14662 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
14663 (if (save-excursion
14665 (and (pos-visible-in-window-p) ;Not continuation line.
14667 ;; Nothing in this page.
14668 (if (or (not gnus-break-pages)
14671 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
14673 (gnus-narrow-to-page 1) ;Go to next page.
14675 ;; More in this page.
14679 ;; Long lines may cause an end-of-buffer error.
14680 (goto-char (point-max))))
14681 (move-to-window-line 0)
14684 (defun gnus-article-prev-page (&optional lines)
14685 "Show previous page of current article.
14686 Argument LINES specifies lines to be scrolled down."
14688 (move-to-window-line 0)
14689 (if (and gnus-break-pages
14691 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
14693 (gnus-narrow-to-page -1) ;Go to previous page.
14694 (goto-char (point-max))
14698 (scroll-down lines)
14700 (move-to-window-line 0))))
14702 (defun gnus-article-refer-article ()
14703 "Read article specified by message-id around point."
14705 (let ((point (point)))
14706 (search-forward ">" nil t) ;Move point to end of "<....>".
14707 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
14708 (let ((message-id (match-string 1)))
14710 (set-buffer gnus-summary-buffer)
14711 (gnus-summary-refer-article message-id))
14712 (goto-char (point))
14713 (error "No references around point"))))
14715 (defun gnus-article-show-summary ()
14716 "Reconfigure windows to show summary buffer."
14718 (gnus-configure-windows 'article)
14719 (gnus-summary-goto-subject gnus-current-article))
14721 (defun gnus-article-describe-briefly ()
14722 "Describe article mode commands briefly."
14725 (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")))
14727 (defun gnus-article-summary-command ()
14728 "Execute the last keystroke in the summary buffer."
14730 (let ((obuf (current-buffer))
14731 (owin (current-window-configuration))
14733 (switch-to-buffer gnus-summary-buffer 'norecord)
14734 (setq func (lookup-key (current-local-map) (this-command-keys)))
14735 (call-interactively func)
14737 (set-window-configuration owin)
14738 (set-window-point (get-buffer-window (current-buffer)) (point))))
14740 (defun gnus-article-summary-command-nosave ()
14741 "Execute the last keystroke in the summary buffer."
14744 (pop-to-buffer gnus-summary-buffer 'norecord)
14745 (setq func (lookup-key (current-local-map) (this-command-keys)))
14746 (call-interactively func)))
14748 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
14749 "Read a summary buffer key sequence and execute it from the article buffer."
14752 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
14753 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
14754 "=" "^" "\M-^" "|"))
14757 (set-buffer gnus-summary-buffer)
14758 (push (or key last-command-event) unread-command-events)
14759 (setq keys (read-key-sequence nil)))
14762 (if (member keys nosaves)
14764 (pop-to-buffer gnus-summary-buffer 'norecord)
14765 (if (setq func (lookup-key (current-local-map) keys))
14766 (call-interactively func)
14768 (let ((obuf (current-buffer))
14769 (owin (current-window-configuration))
14772 (if not-restore-window
14773 (pop-to-buffer gnus-summary-buffer 'norecord)
14774 (switch-to-buffer gnus-summary-buffer 'norecord))
14775 (setq in-buffer (current-buffer))
14776 (if (setq func (lookup-key (current-local-map) keys))
14777 (call-interactively func)
14779 (when (eq in-buffer (current-buffer))
14781 (unless not-restore-window
14782 (set-window-configuration owin))
14783 (set-window-point (get-buffer-window (current-buffer)) opoint))))))
14787 ;;; Kill file handling.
14791 (defalias 'gnus-batch-kill 'gnus-batch-score)
14793 (defun gnus-batch-score ()
14794 "Run batched scoring.
14795 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
14796 Newsgroups is a list of strings in Bnews format. If you want to score
14797 the comp hierarchy, you'd say \"comp.all\". If you would not like to
14798 score the alt hierarchy, you'd say \"!alt.all\"."
14801 (gnus-newsrc-parse-options
14802 (apply (function concat)
14803 (mapcar (lambda (g) (concat g " "))
14804 command-line-args-left))))
14805 (gnus-expert-user t)
14806 (nnmail-spool-file nil)
14807 (gnus-use-dribble-file nil)
14808 (yes (car yes-and-no))
14809 (no (cdr yes-and-no))
14811 ;; Disable verbose message.
14812 gnus-novice-user gnus-large-newsgroup)
14813 ;; Eat all arguments.
14814 (setq command-line-args-left nil)
14817 ;; Apply kills to specified newsgroups in command line arguments.
14818 (setq newsrc (cdr gnus-newsrc-alist))
14820 (setq group (caar newsrc))
14821 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
14822 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed)
14824 (or (eq (car entry) t)
14825 (not (zerop (car entry)))))
14826 (if yes (string-match yes group) t)
14827 (or (null no) (not (string-match no group))))
14829 (gnus-summary-read-group group nil t nil t)
14830 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
14831 (gnus-summary-exit))))
14832 (setq newsrc (cdr newsrc)))
14834 (switch-to-buffer gnus-group-buffer)
14835 (gnus-group-save-newsrc)))
14837 (defun gnus-apply-kill-file ()
14838 "Apply a kill file to the current newsgroup.
14839 Returns the number of articles marked as read."
14840 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
14841 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14842 (gnus-apply-kill-file-internal)
14845 (defun gnus-kill-save-kill-buffer ()
14846 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14847 (when (get-file-buffer file)
14849 (set-buffer (get-file-buffer file))
14850 (and (buffer-modified-p) (save-buffer))
14851 (kill-buffer (current-buffer))))))
14853 (defvar gnus-kill-file-name "KILL"
14854 "Suffix of the kill files.")
14856 (defun gnus-newsgroup-kill-file (newsgroup)
14857 "Return the name of a kill file name for NEWSGROUP.
14858 If NEWSGROUP is nil, return the global kill file name instead."
14860 ;; The global KILL file is placed at top of the directory.
14861 ((or (null newsgroup)
14862 (string-equal newsgroup ""))
14863 (expand-file-name gnus-kill-file-name
14864 gnus-kill-files-directory))
14865 ;; Append ".KILL" to newsgroup name.
14866 ((gnus-use-long-file-name 'not-kill)
14867 (expand-file-name (concat (gnus-newsgroup-savable-name newsgroup)
14868 "." gnus-kill-file-name)
14869 gnus-kill-files-directory))
14870 ;; Place "KILL" under the hierarchical directory.
14872 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
14873 "/" gnus-kill-file-name)
14874 gnus-kill-files-directory))))
14881 (defvar gnus-dribble-ignore nil)
14882 (defvar gnus-dribble-eval-file nil)
14884 (defun gnus-dribble-file-name ()
14885 "Return the dribble file for the current .newsrc."
14887 (if gnus-dribble-directory
14888 (concat (file-name-as-directory gnus-dribble-directory)
14889 (file-name-nondirectory gnus-current-startup-file))
14890 gnus-current-startup-file)
14893 (defun gnus-dribble-enter (string)
14894 "Enter STRING into the dribble buffer."
14895 (if (and (not gnus-dribble-ignore)
14896 gnus-dribble-buffer
14897 (buffer-name gnus-dribble-buffer))
14898 (let ((obuf (current-buffer)))
14899 (set-buffer gnus-dribble-buffer)
14900 (insert string "\n")
14901 (set-window-point (get-buffer-window (current-buffer)) (point-max))
14902 (set-buffer obuf))))
14904 (defun gnus-dribble-read-file ()
14905 "Read the dribble file from disk."
14906 (let ((dribble-file (gnus-dribble-file-name)))
14908 (set-buffer (setq gnus-dribble-buffer
14910 (file-name-nondirectory dribble-file))))
14911 (gnus-add-current-to-buffer-list)
14913 (setq buffer-file-name dribble-file)
14915 (buffer-disable-undo (current-buffer))
14916 (bury-buffer (current-buffer))
14917 (set-buffer-modified-p nil)
14918 (let ((auto (make-auto-save-file-name))
14919 (gnus-dribble-ignore t)
14921 (when (or (file-exists-p auto) (file-exists-p dribble-file))
14922 ;; Load whichever file is newest -- the auto save file
14923 ;; or the "real" file.
14924 (if (file-newer-than-file-p auto dribble-file)
14925 (insert-file-contents auto)
14926 (insert-file-contents dribble-file))
14927 (unless (zerop (buffer-size))
14928 (set-buffer-modified-p t))
14929 ;; Set the file modes to reflect the .newsrc file modes.
14931 (when (and (file-exists-p gnus-current-startup-file)
14932 (setq modes (file-modes gnus-current-startup-file)))
14933 (set-file-modes dribble-file modes))
14934 ;; Possibly eval the file later.
14935 (when (gnus-y-or-n-p
14936 "Auto-save file exists. Do you want to read it? ")
14937 (setq gnus-dribble-eval-file t)))))))
14939 (defun gnus-dribble-eval-file ()
14940 (when gnus-dribble-eval-file
14941 (setq gnus-dribble-eval-file nil)
14943 (let ((gnus-dribble-ignore t))
14944 (set-buffer gnus-dribble-buffer)
14945 (eval-buffer (current-buffer))))))
14947 (defun gnus-dribble-delete-file ()
14948 (when (file-exists-p (gnus-dribble-file-name))
14949 (delete-file (gnus-dribble-file-name)))
14950 (when gnus-dribble-buffer
14952 (set-buffer gnus-dribble-buffer)
14953 (let ((auto (make-auto-save-file-name)))
14954 (if (file-exists-p auto)
14955 (delete-file auto))
14957 (set-buffer-modified-p nil)))))
14959 (defun gnus-dribble-save ()
14960 (when (and gnus-dribble-buffer
14961 (buffer-name gnus-dribble-buffer))
14963 (set-buffer gnus-dribble-buffer)
14966 (defun gnus-dribble-clear ()
14967 (when (gnus-buffer-exists-p gnus-dribble-buffer)
14969 (set-buffer gnus-dribble-buffer)
14971 (set-buffer-modified-p nil)
14972 (setq buffer-saved-size (buffer-size)))))
14976 ;;; Server Communication
14979 (defun gnus-start-news-server (&optional confirm)
14980 "Open a method for getting news.
14981 If CONFIRM is non-nil, the user will be asked for an NNTP server."
14983 (if gnus-current-select-method
14984 ;; Stream is already opened.
14986 ;; Open NNTP server.
14987 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
14990 ;; Read server name with completion.
14991 (setq gnus-nntp-server
14992 (completing-read "NNTP server: "
14993 (mapcar (lambda (server) (list server))
14994 (cons (list gnus-nntp-server)
14995 gnus-secondary-servers))
14996 nil nil gnus-nntp-server))))
14998 (if (and gnus-nntp-server
14999 (stringp gnus-nntp-server)
15000 (not (string= gnus-nntp-server "")))
15001 (setq gnus-select-method
15002 (cond ((or (string= gnus-nntp-server "")
15003 (string= gnus-nntp-server "::"))
15004 (list 'nnspool (system-name)))
15005 ((string-match "^:" gnus-nntp-server)
15006 (list 'nnmh gnus-nntp-server
15007 (list 'nnmh-directory
15008 (file-name-as-directory
15010 (concat "~/" (substring
15011 gnus-nntp-server 1)))))
15012 (list 'nnmh-get-new-mail nil)))
15014 (list 'nntp gnus-nntp-server)))))
15016 (setq how (car gnus-select-method))
15017 (cond ((eq how 'nnspool)
15019 (gnus-message 5 "Looking up local news spool..."))
15022 (gnus-message 5 "Looking up mh spool..."))
15025 (setq gnus-current-select-method gnus-select-method)
15026 (run-hooks 'gnus-open-server-hook)
15028 ;; gnus-open-server-hook might have opened it
15029 (gnus-server-opened gnus-select-method)
15030 (gnus-open-server gnus-select-method)
15033 "%s (%s) open error: '%s'. Continue? "
15034 (car gnus-select-method) (cadr gnus-select-method)
15035 (gnus-status-message gnus-select-method)))
15036 (gnus-error 1 "Couldn't open server on %s"
15037 (nth 1 gnus-select-method))))))
15039 (defun gnus-check-group (group)
15040 "Try to make sure that the server where GROUP exists is alive."
15041 (let ((method (gnus-find-method-for-group group)))
15042 (or (gnus-server-opened method)
15043 (gnus-open-server method))))
15045 (defun gnus-check-server (&optional method silent)
15046 "Check whether the connection to METHOD is down.
15047 If METHOD is nil, use `gnus-select-method'.
15048 If it is down, start it up (again)."
15049 (let ((method (or method gnus-select-method)))
15050 ;; Transform virtual server names into select methods.
15051 (when (stringp method)
15052 (setq method (gnus-server-to-method method)))
15053 (if (gnus-server-opened method)
15054 ;; The stream is already opened.
15056 ;; Open the server.
15058 (gnus-message 5 "Opening %s server%s..." (car method)
15059 (if (equal (nth 1 method) "") ""
15060 (format " on %s" (nth 1 method)))))
15061 (run-hooks 'gnus-open-server-hook)
15063 (gnus-open-server method)
15067 (defun gnus-get-function (method function &optional noerror)
15068 "Return a function symbol based on METHOD and FUNCTION."
15069 ;; Translate server names into methods.
15071 (error "Attempted use of a nil select method"))
15072 (when (stringp method)
15073 (setq method (gnus-server-to-method method)))
15074 (let ((func (intern (format "%s-%s" (car method) function))))
15075 ;; If the functions isn't bound, we require the backend in
15077 (unless (fboundp func)
15078 (require (car method))
15079 (when (and (not (fboundp func))
15081 ;; This backend doesn't implement this function.
15082 (error "No such function: %s" func)))
15087 ;;; Interface functions to the backends.
15090 (defun gnus-open-server (method)
15091 "Open a connection to METHOD."
15092 (when (stringp method)
15093 (setq method (gnus-server-to-method method)))
15094 (let ((elem (assoc method gnus-opened-servers)))
15095 ;; If this method was previously denied, we just return nil.
15096 (if (eq (nth 1 elem) 'denied)
15098 (gnus-message 1 "Denied server")
15100 ;; Open the server.
15102 (funcall (gnus-get-function method 'open-server)
15103 (nth 1 method) (nthcdr 2 method))))
15104 ;; If this hasn't been opened before, we add it to the list.
15106 (setq elem (list method nil)
15107 gnus-opened-servers (cons elem gnus-opened-servers)))
15108 ;; Set the status of this server.
15109 (setcar (cdr elem) (if result 'ok 'denied))
15110 ;; Return the result from the "open" call.
15113 (defun gnus-close-server (method)
15114 "Close the connection to METHOD."
15115 (when (stringp method)
15116 (setq method (gnus-server-to-method method)))
15117 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
15119 (defun gnus-request-list (method)
15120 "Request the active file from METHOD."
15121 (when (stringp method)
15122 (setq method (gnus-server-to-method method)))
15123 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
15125 (defun gnus-request-list-newsgroups (method)
15126 "Request the newsgroups file from METHOD."
15127 (when (stringp method)
15128 (setq method (gnus-server-to-method method)))
15129 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
15131 (defun gnus-request-newgroups (date method)
15132 "Request all new groups since DATE from METHOD."
15133 (when (stringp method)
15134 (setq method (gnus-server-to-method method)))
15135 (funcall (gnus-get-function method 'request-newgroups)
15136 date (nth 1 method)))
15138 (defun gnus-server-opened (method)
15139 "Check whether a connection to METHOD has been opened."
15140 (when (stringp method)
15141 (setq method (gnus-server-to-method method)))
15142 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
15144 (defun gnus-status-message (method)
15145 "Return the status message from METHOD.
15146 If METHOD is a string, it is interpreted as a group name. The method
15147 this group uses will be queried."
15148 (let ((method (if (stringp method) (gnus-find-method-for-group method)
15150 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
15152 (defun gnus-request-group (group &optional dont-check method)
15153 "Request GROUP. If DONT-CHECK, no information is required."
15154 (let ((method (or method (gnus-find-method-for-group group))))
15155 (when (stringp method)
15156 (setq method (gnus-server-to-method method)))
15157 (funcall (gnus-get-function method 'request-group)
15158 (gnus-group-real-name group) (nth 1 method) dont-check)))
15160 (defun gnus-request-asynchronous (group &optional articles)
15161 "Request that GROUP behave asynchronously.
15162 ARTICLES is the `data' of the group."
15163 (let ((method (gnus-find-method-for-group group)))
15164 (funcall (gnus-get-function method 'request-asynchronous)
15165 (gnus-group-real-name group) (nth 1 method) articles)))
15167 (defun gnus-list-active-group (group)
15168 "Request active information on GROUP."
15169 (let ((method (gnus-find-method-for-group group))
15170 (func 'list-active-group))
15171 (when (gnus-check-backend-function func group)
15172 (funcall (gnus-get-function method func)
15173 (gnus-group-real-name group) (nth 1 method)))))
15175 (defun gnus-request-group-description (group)
15176 "Request a description of GROUP."
15177 (let ((method (gnus-find-method-for-group group))
15178 (func 'request-group-description))
15179 (when (gnus-check-backend-function func group)
15180 (funcall (gnus-get-function method func)
15181 (gnus-group-real-name group) (nth 1 method)))))
15183 (defun gnus-close-group (group)
15184 "Request the GROUP be closed."
15185 (let ((method (gnus-find-method-for-group group)))
15186 (funcall (gnus-get-function method 'close-group)
15187 (gnus-group-real-name group) (nth 1 method))))
15189 (defun gnus-retrieve-headers (articles group &optional fetch-old)
15190 "Request headers for ARTICLES in GROUP.
15191 If FETCH-OLD, retrieve all headers (or some subset thereof) in the group."
15192 (let ((method (gnus-find-method-for-group group)))
15193 (if (and gnus-use-cache (numberp (car articles)))
15194 (gnus-cache-retrieve-headers articles group fetch-old)
15195 (funcall (gnus-get-function method 'retrieve-headers)
15196 articles (gnus-group-real-name group) (nth 1 method)
15199 (defun gnus-retrieve-groups (groups method)
15200 "Request active information on GROUPS from METHOD."
15201 (when (stringp method)
15202 (setq method (gnus-server-to-method method)))
15203 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method)))
15205 (defun gnus-request-type (group &optional article)
15206 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
15207 (let ((method (gnus-find-method-for-group group)))
15208 (if (not (gnus-check-backend-function 'request-type (car method)))
15210 (funcall (gnus-get-function method 'request-type)
15211 (gnus-group-real-name group) article))))
15213 (defun gnus-request-update-mark (group article mark)
15214 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
15215 (let ((method (gnus-find-method-for-group group)))
15216 (if (not (gnus-check-backend-function 'request-update-mark (car method)))
15218 (funcall (gnus-get-function method 'request-update-mark)
15219 (gnus-group-real-name group) article mark))))
15221 (defun gnus-request-article (article group &optional buffer)
15222 "Request the ARTICLE in GROUP.
15223 ARTICLE can either be an article number or an article Message-ID.
15224 If BUFFER, insert the article in that group."
15225 (let ((method (gnus-find-method-for-group group)))
15226 (funcall (gnus-get-function method 'request-article)
15227 article (gnus-group-real-name group) (nth 1 method) buffer)))
15229 (defun gnus-request-head (article group)
15230 "Request the head of ARTICLE in GROUP."
15231 (let* ((method (gnus-find-method-for-group group))
15232 (head (gnus-get-function method 'request-head t)))
15234 (funcall head article (gnus-group-real-name group) (nth 1 method))
15235 (let ((res (gnus-request-article article group)))
15238 (set-buffer nntp-server-buffer)
15239 (goto-char (point-min))
15240 (when (search-forward "\n\n" nil t)
15241 (delete-region (1- (point)) (point-max)))
15242 (nnheader-fold-continuation-lines)))
15245 (defun gnus-request-body (article group)
15246 "Request the body of ARTICLE in GROUP."
15247 (let ((method (gnus-find-method-for-group group)))
15248 (funcall (gnus-get-function method 'request-body)
15249 article (gnus-group-real-name group) (nth 1 method))))
15251 (defun gnus-request-post (method)
15252 "Post the current buffer using METHOD."
15253 (when (stringp method)
15254 (setq method (gnus-server-to-method method)))
15255 (funcall (gnus-get-function method 'request-post) (nth 1 method)))
15257 (defun gnus-request-scan (group method)
15258 "Request a SCAN being performed in GROUP from METHOD.
15259 If GROUP is nil, all groups on METHOD are scanned."
15260 (let ((method (if group (gnus-find-method-for-group group) method)))
15261 (funcall (gnus-get-function method 'request-scan)
15262 (and group (gnus-group-real-name group)) (nth 1 method))))
15264 (defsubst gnus-request-update-info (info method)
15265 "Request that METHOD update INFO."
15266 (when (stringp method)
15267 (setq method (gnus-server-to-method method)))
15268 (when (gnus-check-backend-function 'request-update-info (car method))
15269 (funcall (gnus-get-function method 'request-update-info)
15270 (gnus-group-real-name (gnus-info-group info))
15271 info (nth 1 method))))
15273 (defun gnus-request-expire-articles (articles group &optional force)
15274 (let ((method (gnus-find-method-for-group group)))
15275 (funcall (gnus-get-function method 'request-expire-articles)
15276 articles (gnus-group-real-name group) (nth 1 method)
15279 (defun gnus-request-move-article
15280 (article group server accept-function &optional last)
15281 (let ((method (gnus-find-method-for-group group)))
15282 (funcall (gnus-get-function method 'request-move-article)
15283 article (gnus-group-real-name group)
15284 (nth 1 method) accept-function last)))
15286 (defun gnus-request-accept-article (group method &optional last)
15287 ;; Make sure there's a newline at the end of the article.
15288 (when (stringp method)
15289 (setq method (gnus-server-to-method method)))
15290 (when (and (not method)
15292 (setq method (gnus-group-name-to-method group)))
15293 (goto-char (point-max))
15296 (let ((func (car (or method (gnus-find-method-for-group group)))))
15297 (funcall (intern (format "%s-request-accept-article" func))
15298 (if (stringp group) (gnus-group-real-name group) group)
15302 (defun gnus-request-replace-article (article group buffer)
15303 (let ((func (car (gnus-find-method-for-group group))))
15304 (funcall (intern (format "%s-request-replace-article" func))
15305 article (gnus-group-real-name group) buffer)))
15307 (defun gnus-request-associate-buffer (group)
15308 (let ((method (gnus-find-method-for-group group)))
15309 (funcall (gnus-get-function method 'request-associate-buffer)
15310 (gnus-group-real-name group))))
15312 (defun gnus-request-restore-buffer (article group)
15313 "Request a new buffer restored to the state of ARTICLE."
15314 (let ((method (gnus-find-method-for-group group)))
15315 (funcall (gnus-get-function method 'request-restore-buffer)
15316 article (gnus-group-real-name group) (nth 1 method))))
15318 (defun gnus-request-create-group (group &optional method)
15319 (when (stringp method)
15320 (setq method (gnus-server-to-method method)))
15321 (let ((method (or method (gnus-find-method-for-group group))))
15322 (funcall (gnus-get-function method 'request-create-group)
15323 (gnus-group-real-name group) (nth 1 method))))
15325 (defun gnus-request-delete-group (group &optional force)
15326 (let ((method (gnus-find-method-for-group group)))
15327 (funcall (gnus-get-function method 'request-delete-group)
15328 (gnus-group-real-name group) force (nth 1 method))))
15330 (defun gnus-request-rename-group (group new-name)
15331 (let ((method (gnus-find-method-for-group group)))
15332 (funcall (gnus-get-function method 'request-rename-group)
15333 (gnus-group-real-name group)
15334 (gnus-group-real-name new-name) (nth 1 method))))
15336 (defun gnus-member-of-valid (symbol group)
15337 "Find out if GROUP has SYMBOL as part of its \"valid\" spec."
15338 (memq symbol (assoc
15339 (symbol-name (car (gnus-find-method-for-group group)))
15340 gnus-valid-select-methods)))
15342 (defun gnus-method-option-p (method option)
15343 "Return non-nil if select METHOD has OPTION as a parameter."
15344 (when (stringp method)
15345 (setq method (gnus-server-to-method method)))
15346 (memq option (assoc (format "%s" (car method))
15347 gnus-valid-select-methods)))
15349 (defun gnus-server-extend-method (group method)
15350 ;; This function "extends" a virtual server. If the server is
15351 ;; "hello", and the select method is ("hello" (my-var "something"))
15352 ;; in the group "alt.alt", this will result in a new virtual server
15353 ;; called "hello+alt.alt".
15355 (gnus-copy-sequence
15356 (if (equal (car method) "native") gnus-select-method
15357 (cdr (assoc (car method) gnus-server-alist))))))
15358 (setcar (cdr entry) (concat (nth 1 entry) "+" group))
15359 (nconc entry (cdr method))))
15361 (defun gnus-group-name-to-method (group)
15362 "Return a select method suitable for GROUP."
15363 (if (string-match ":" group)
15364 (let ((server (substring group 0 (match-beginning 0))))
15365 (if (string-match "\\+" server)
15366 (list (intern (substring server 0 (match-beginning 0)))
15367 (substring server (match-end 0)))
15368 (list (intern server) "")))
15369 gnus-select-method))
15371 (defun gnus-find-method-for-group (group &optional info)
15372 "Find the select method that GROUP uses."
15373 (or gnus-override-method
15375 gnus-select-method)
15376 (let ((info (or info (gnus-get-info group)))
15379 (not (setq method (gnus-info-method info)))
15380 (equal method "native"))
15383 (cond ((stringp method)
15384 (gnus-server-to-method method))
15385 ((stringp (car method))
15386 (gnus-server-extend-method group method))
15389 (cond ((equal (cadr method) "")
15391 ((null (cadr method))
15392 (list (car method) ""))
15394 (gnus-server-add-address method)))))))
15396 (defun gnus-check-backend-function (func group)
15397 "Check whether GROUP supports function FUNC."
15398 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
15400 (fboundp (intern (format "%s-%s" method func)))))
15402 (defun gnus-methods-using (feature)
15403 "Find all methods that have FEATURE."
15404 (let ((valids gnus-valid-select-methods)
15407 (if (memq feature (car valids))
15408 (setq outs (cons (car valids) outs)))
15409 (setq valids (cdr valids)))
15414 ;;; Active & Newsrc File Handling
15417 (defun gnus-setup-news (&optional rawfile level dont-connect)
15418 "Setup news information.
15419 If RAWFILE is non-nil, the .newsrc file will also be read.
15420 If LEVEL is non-nil, the news will be set up at level LEVEL."
15421 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile)))))
15424 ;; Clear some variables to re-initialize news information.
15425 (setq gnus-newsrc-alist nil
15426 gnus-active-hashtb nil)
15427 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
15428 (gnus-read-newsrc-file rawfile))
15430 (when (and (not (assoc "archive" gnus-server-alist))
15431 gnus-message-archive-method)
15432 (push (cons "archive" gnus-message-archive-method)
15433 gnus-server-alist))
15435 ;; If we don't read the complete active file, we fill in the
15437 (if (or (null gnus-read-active-file)
15438 (eq gnus-read-active-file 'some))
15439 (gnus-update-active-hashtb-from-killed))
15441 ;; Read the active file and create `gnus-active-hashtb'.
15442 ;; If `gnus-read-active-file' is nil, then we just create an empty
15443 ;; hash table. The partial filling out of the hash table will be
15444 ;; done in `gnus-get-unread-articles'.
15445 (and gnus-read-active-file
15447 (gnus-read-active-file))
15449 (or gnus-active-hashtb
15450 (setq gnus-active-hashtb (make-vector 4095 0)))
15452 ;; Initialize the cache.
15453 (when gnus-use-cache
15456 ;; Possibly eval the dribble file.
15457 (and init (or gnus-use-dribble-file gnus-slave) (gnus-dribble-eval-file))
15459 ;; Slave Gnusii should then clear the dribble buffer.
15460 (when (and init gnus-slave)
15461 (gnus-dribble-clear))
15463 (gnus-update-format-specifications)
15465 ;; See whether we need to read the description file.
15466 (if (and (string-match "%[-,0-9]*D" gnus-group-line-format)
15467 (not gnus-description-hashtb)
15469 gnus-read-active-file)
15470 (gnus-read-all-descriptions-files))
15472 ;; Find new newsgroups and treat them.
15473 (if (and init gnus-check-new-newsgroups (not level)
15474 (gnus-check-server gnus-select-method))
15475 (gnus-find-new-newsgroups))
15477 ;; We might read in new NoCeM messages here.
15478 (when (and gnus-use-nocem
15480 (not dont-connect))
15481 (gnus-nocem-scan-groups))
15483 ;; Find the number of unread articles in each non-dead group.
15484 (let ((gnus-read-active-file (and (not level) gnus-read-active-file)))
15485 (gnus-get-unread-articles level))
15487 (if (and init gnus-check-bogus-newsgroups
15488 gnus-read-active-file (not level)
15489 (gnus-server-opened gnus-select-method))
15490 (gnus-check-bogus-newsgroups))))
15492 (defun gnus-find-new-newsgroups (&optional arg)
15493 "Search for new newsgroups and add them.
15494 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
15495 The `-n' option line from .newsrc is respected.
15496 If ARG (the prefix), use the `ask-server' method to query
15497 the server for new groups."
15499 (let ((check (if (or (and arg (not (listp gnus-check-new-newsgroups)))
15500 (null gnus-read-active-file)
15501 (eq gnus-read-active-file 'some))
15502 'ask-server gnus-check-new-newsgroups)))
15503 (unless (gnus-check-first-time-used)
15504 (if (or (consp check)
15505 (eq check 'ask-server))
15506 ;; Ask the server for new groups.
15507 (gnus-ask-server-for-new-groups)
15508 ;; Go through the active hashtb and look for new groups.
15510 group new-newsgroups)
15511 (gnus-message 5 "Looking for new newsgroups...")
15512 (unless gnus-have-read-active-file
15513 (gnus-read-active-file))
15514 (setq gnus-newsrc-last-checked-date (current-time-string))
15515 (unless gnus-killed-hashtb
15516 (gnus-make-hashtable-from-killed))
15517 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
15518 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
15521 (if (or (null (setq group (symbol-name sym)))
15523 (null (symbol-value sym))
15524 (gnus-gethash group gnus-killed-hashtb)
15525 (gnus-gethash group gnus-newsrc-hashtb))
15527 (let ((do-sub (gnus-matches-options-n group)))
15529 ((eq do-sub 'subscribe)
15530 (setq groups (1+ groups))
15531 (gnus-sethash group group gnus-killed-hashtb)
15532 (funcall gnus-subscribe-options-newsgroup-method group))
15533 ((eq do-sub 'ignore)
15536 (setq groups (1+ groups))
15537 (gnus-sethash group group gnus-killed-hashtb)
15538 (if gnus-subscribe-hierarchical-interactive
15539 (setq new-newsgroups (cons group new-newsgroups))
15540 (funcall gnus-subscribe-newsgroup-method group)))))))
15541 gnus-active-hashtb)
15542 (when new-newsgroups
15543 (gnus-subscribe-hierarchical-interactive new-newsgroups))
15544 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
15546 (gnus-message 6 "%d new newsgroup%s arrived."
15547 groups (if (> groups 1) "s have" " has"))
15548 (gnus-message 6 "No new newsgroups.")))))))
15550 (defun gnus-matches-options-n (group)
15551 ;; Returns `subscribe' if the group is to be unconditionally
15552 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
15553 ;; no match for the group.
15555 ;; First we check the two user variables.
15557 ((and gnus-options-subscribe
15558 (string-match gnus-options-subscribe group))
15560 ((and gnus-auto-subscribed-groups
15561 (string-match gnus-auto-subscribed-groups group))
15563 ((and gnus-options-not-subscribe
15564 (string-match gnus-options-not-subscribe group))
15566 ;; Then we go through the list that was retrieved from the .newsrc
15567 ;; file. This list has elements on the form
15568 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
15569 ;; is in the reverse order of the options line) is returned.
15571 (let ((regs gnus-newsrc-options-n))
15573 (not (string-match (caar regs) group)))
15574 (setq regs (cdr regs)))
15575 (and regs (cdar regs))))))
15577 (defun gnus-ask-server-for-new-groups ()
15578 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
15579 (methods (cons gnus-select-method
15581 (when gnus-message-archive-method
15584 (and (consp gnus-check-new-newsgroups)
15585 gnus-check-new-newsgroups)
15586 gnus-secondary-select-methods))))
15588 (new-date (current-time-string))
15589 group new-newsgroups got-new method hashtb
15590 gnus-override-subscribe-method)
15591 ;; Go through both primary and secondary select methods and
15592 ;; request new newsgroups.
15593 (while (setq method (gnus-server-get-method nil (pop methods)))
15594 (setq new-newsgroups nil)
15595 (setq gnus-override-subscribe-method method)
15596 (when (and (gnus-check-server method)
15597 (gnus-request-newgroups date method))
15600 (setq hashtb (gnus-make-hashtable 100))
15601 (set-buffer nntp-server-buffer)
15602 ;; Enter all the new groups into a hashtable.
15603 (gnus-active-to-gnus-format method hashtb 'ignore))
15604 ;; Now all new groups from `method' are in `hashtb'.
15606 (lambda (group-sym)
15607 (if (or (null (setq group (symbol-name group-sym)))
15608 (not (boundp group-sym))
15609 (null (symbol-value group-sym))
15610 (gnus-gethash group gnus-newsrc-hashtb)
15611 (member group gnus-zombie-list)
15612 (member group gnus-killed-list))
15613 ;; The group is already known.
15615 ;; Make this group active.
15616 (when (symbol-value group-sym)
15617 (gnus-set-active group (symbol-value group-sym)))
15618 ;; Check whether we want it or not.
15619 (let ((do-sub (gnus-matches-options-n group)))
15621 ((eq do-sub 'subscribe)
15623 (gnus-sethash group group gnus-killed-hashtb)
15624 (funcall gnus-subscribe-options-newsgroup-method group))
15625 ((eq do-sub 'ignore)
15629 (gnus-sethash group group gnus-killed-hashtb)
15630 (if gnus-subscribe-hierarchical-interactive
15631 (push group new-newsgroups)
15632 (funcall gnus-subscribe-newsgroup-method group)))))))
15634 (when new-newsgroups
15635 (gnus-subscribe-hierarchical-interactive new-newsgroups)))
15636 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
15638 (gnus-message 6 "%d new newsgroup%s arrived."
15639 groups (if (> groups 1) "s have" " has")))
15640 (and got-new (setq gnus-newsrc-last-checked-date new-date))
15643 (defun gnus-check-first-time-used ()
15644 (if (or (> (length gnus-newsrc-alist) 1)
15645 (file-exists-p gnus-startup-file)
15646 (file-exists-p (concat gnus-startup-file ".el"))
15647 (file-exists-p (concat gnus-startup-file ".eld")))
15649 (gnus-message 6 "First time user; subscribing you to default groups")
15650 (unless (gnus-read-active-file-p)
15651 (gnus-read-active-file))
15652 (setq gnus-newsrc-last-checked-date (current-time-string))
15653 (let ((groups gnus-default-subscribed-newsgroups)
15657 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
15660 (if (null (setq group (symbol-name sym)))
15662 (let ((do-sub (gnus-matches-options-n group)))
15664 ((eq do-sub 'subscribe)
15665 (gnus-sethash group group gnus-killed-hashtb)
15666 (funcall gnus-subscribe-options-newsgroup-method group))
15667 ((eq do-sub 'ignore)
15670 (setq gnus-killed-list (cons group gnus-killed-list)))))))
15671 gnus-active-hashtb)
15673 (if (gnus-active (car groups))
15674 (gnus-group-change-level
15675 (car groups) gnus-level-default-subscribed gnus-level-killed))
15676 (setq groups (cdr groups)))
15677 (gnus-group-make-help-group)
15678 (and gnus-novice-user
15679 (gnus-message 7 "`A k' to list killed groups"))))))
15681 (defun gnus-subscribe-group (group previous &optional method)
15682 (gnus-group-change-level
15684 (list t group gnus-level-default-subscribed nil nil method)
15686 gnus-level-default-subscribed gnus-level-killed previous t))
15688 ;; `gnus-group-change-level' is the fundamental function for changing
15689 ;; subscription levels of newsgroups. This might mean just changing
15690 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
15691 ;; again, which subscribes/unsubscribes a group, which is equally
15692 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
15693 ;; from 8-9 to 1-7 means that you remove the group from the list of
15694 ;; killed (or zombie) groups and add them to the (kinda) subscribed
15695 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
15696 ;; which is trivial.
15697 ;; ENTRY can either be a string (newsgroup name) or a list (if
15698 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
15699 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
15701 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
15702 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
15704 (defun gnus-group-change-level (entry level &optional oldlevel
15705 previous fromkilled)
15706 (let (group info active num)
15707 ;; Glean what info we can from the arguments
15709 (if fromkilled (setq group (nth 1 entry))
15710 (setq group (car (nth 2 entry))))
15711 (setq group entry))
15712 (if (and (stringp entry)
15714 (< oldlevel gnus-level-zombie))
15715 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
15716 (if (and (not oldlevel)
15718 (setq oldlevel (gnus-info-level (nth 2 entry)))
15719 (setq oldlevel (or oldlevel 9)))
15720 (if (stringp previous)
15721 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
15723 (if (and (>= oldlevel gnus-level-zombie)
15724 (gnus-gethash group gnus-newsrc-hashtb))
15725 ;; We are trying to subscribe a group that is already
15729 (or (gnus-ephemeral-group-p group)
15730 (gnus-dribble-enter
15731 (format "(gnus-group-change-level %S %S %S %S %S)"
15732 group level oldlevel (car (nth 2 previous)) fromkilled)))
15734 ;; Then we remove the newgroup from any old structures, if needed.
15735 ;; If the group was killed, we remove it from the killed or zombie
15736 ;; list. If not, and it is in fact going to be killed, we remove
15737 ;; it from the newsrc hash table and assoc.
15739 ((>= oldlevel gnus-level-zombie)
15740 (if (= oldlevel gnus-level-zombie)
15741 (setq gnus-zombie-list (delete group gnus-zombie-list))
15742 (setq gnus-killed-list (delete group gnus-killed-list))))
15744 (if (and (>= level gnus-level-zombie)
15747 (gnus-sethash (car (nth 2 entry)) nil gnus-newsrc-hashtb)
15749 (setcdr (gnus-gethash (car (nth 3 entry))
15750 gnus-newsrc-hashtb)
15752 (setcdr (cdr entry) (cdddr entry))))))
15754 ;; Finally we enter (if needed) the list where it is supposed to
15755 ;; go, and change the subscription level. If it is to be killed,
15756 ;; we enter it into the killed or zombie list.
15758 ((>= level gnus-level-zombie)
15759 ;; Remove from the hash table.
15760 (gnus-sethash group nil gnus-newsrc-hashtb)
15761 ;; We do not enter foreign groups into the list of dead
15763 (unless (gnus-group-foreign-p group)
15764 (if (= level gnus-level-zombie)
15765 (setq gnus-zombie-list (cons group gnus-zombie-list))
15766 (setq gnus-killed-list (cons group gnus-killed-list)))))
15768 ;; If the list is to be entered into the newsrc assoc, and
15769 ;; it was killed, we have to create an entry in the newsrc
15770 ;; hashtb format and fix the pointers in the newsrc assoc.
15771 (if (< oldlevel gnus-level-zombie)
15772 ;; It was alive, and it is going to stay alive, so we
15773 ;; just change the level and don't change any pointers or
15774 ;; hash table entries.
15775 (setcar (cdaddr entry) level)
15777 (setq info (cdr entry)
15779 (setq active (gnus-active group))
15781 (if active (- (1+ (cdr active)) (car active)) t))
15782 ;; Check whether the group is foreign. If so, the
15783 ;; foreign select method has to be entered into the
15785 (let ((method (or gnus-override-subscribe-method
15786 (gnus-group-method group))))
15787 (if (eq method gnus-select-method)
15788 (setq info (list group level nil))
15789 (setq info (list group level nil nil method)))))
15792 (let ((p gnus-newsrc-alist))
15796 (setq entry (cons info (cddr previous)))
15799 (setcdr (cdr previous) entry)
15800 (gnus-sethash group (cons num (cdr previous))
15801 gnus-newsrc-hashtb))
15802 (setcdr previous entry)
15803 (gnus-sethash group (cons num previous)
15804 gnus-newsrc-hashtb))
15806 (setcdr (gnus-gethash (caadr entry) gnus-newsrc-hashtb) entry)))))
15807 (when gnus-group-change-level-function
15808 (funcall gnus-group-change-level-function group level oldlevel)))))
15810 (defun gnus-kill-newsgroup (newsgroup)
15811 "Obsolete function. Kills a newsgroup."
15812 (gnus-group-change-level
15813 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed))
15815 (defun gnus-check-bogus-newsgroups (&optional confirm)
15816 "Remove bogus newsgroups.
15817 If CONFIRM is non-nil, the user has to confirm the deletion of every
15819 (let ((newsrc (cdr gnus-newsrc-alist))
15820 bogus group entry info)
15821 (gnus-message 5 "Checking bogus newsgroups...")
15822 (unless (gnus-read-active-file-p)
15823 (gnus-read-active-file))
15824 (when (gnus-read-active-file-p)
15825 ;; Find all bogus newsgroup that are subscribed.
15827 (setq info (pop newsrc)
15828 group (gnus-info-group info))
15829 (unless (or (gnus-active group) ; Active
15830 (gnus-info-method info) ; Foreign
15832 (not (gnus-y-or-n-p
15833 (format "Remove bogus newsgroup: %s " group)))))
15834 ;; Found a bogus newsgroup.
15835 (push group bogus)))
15836 ;; Remove all bogus subscribed groups by first killing them, and
15837 ;; then removing them from the list of killed groups.
15839 (when (setq entry (gnus-gethash (setq group (pop bogus))
15840 gnus-newsrc-hashtb))
15841 (gnus-group-change-level entry gnus-level-killed)
15842 (setq gnus-killed-list (delete group gnus-killed-list))))
15843 ;; Then we remove all bogus groups from the list of killed and
15844 ;; zombie groups. They are are removed without confirmation.
15845 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
15848 (setq killed (symbol-value (car dead-lists)))
15850 (unless (gnus-active (setq group (pop killed)))
15851 ;; The group is bogus.
15852 ;; !!!Slow as hell.
15853 (set (car dead-lists)
15854 (delete group (symbol-value (car dead-lists))))))
15855 (setq dead-lists (cdr dead-lists))))
15856 (gnus-message 5 "Checking bogus newsgroups...done"))))
15858 (defun gnus-check-duplicate-killed-groups ()
15859 "Remove duplicates from the list of killed groups."
15861 (let ((killed gnus-killed-list))
15863 (gnus-message 9 "%d" (length killed))
15864 (setcdr killed (delete (car killed) (cdr killed)))
15865 (setq killed (cdr killed)))))
15867 ;; We want to inline a function from gnus-cache, so we cheat here:
15870 (require 'gnus-cache))
15872 (defun gnus-get-unread-articles-in-group (info active &optional update)
15874 ;; Allow the backend to update the info in the group.
15876 (gnus-request-update-info
15877 info (gnus-find-method-for-group (gnus-info-group info))))
15878 (gnus-activate-group (gnus-info-group info) nil t))
15879 (let* ((range (gnus-info-read info))
15881 ;; If a cache is present, we may have to alter the active info.
15882 (when (and gnus-use-cache info)
15883 (inline (gnus-cache-possibly-alter-active
15884 (gnus-info-group info) active)))
15885 ;; Modify the list of read articles according to what articles
15886 ;; are available; then tally the unread articles and add the
15887 ;; number to the group hash table entry.
15889 ((zerop (cdr active))
15892 (setq num (- (1+ (cdr active)) (car active))))
15893 ((not (listp (cdr range)))
15894 ;; Fix a single (num . num) range according to the
15895 ;; active hash table.
15896 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
15897 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
15898 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
15899 ;; Compute number of unread articles.
15900 (setq num (max 0 (- (cdr active) (- (1+ (cdr range)) (car range))))))
15902 ;; The read list is a list of ranges. Fix them according to
15903 ;; the active hash table.
15904 ;; First peel off any elements that are below the lower
15906 (while (and (cdr range)
15908 (or (and (atom (cadr range)) (cadr range))
15910 (if (numberp (car range))
15913 (or (and (numberp (cadr range))
15916 (setcdr (car range)
15917 (or (and (numberp (nth 1 range)) (nth 1 range))
15919 (setcdr range (cddr range)))
15920 ;; Adjust the first element to be the same as the lower limit.
15921 (if (and (not (atom (car range)))
15922 (< (cdar range) (car active)))
15923 (setcdr (car range) (1- (car active))))
15924 ;; Then we want to peel off any elements that are higher
15925 ;; than the upper active limit.
15926 (let ((srange range))
15927 ;; Go past all legal elements.
15928 (while (and (cdr srange)
15929 (<= (or (and (atom (cadr srange))
15931 (caadr srange)) (cdr active)))
15932 (setq srange (cdr srange)))
15934 ;; Nuke all remaining illegal elements.
15935 (setcdr srange nil))
15937 ;; Adjust the final element.
15938 (if (and (not (atom (car srange)))
15939 (> (cdar srange) (cdr active)))
15940 (setcdr (car srange) (cdr active))))
15941 ;; Compute the number of unread articles.
15943 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
15945 (or (and (atom (car range)) (car range))
15947 (setq range (cdr range)))
15948 (setq num (max 0 (- (cdr active) num)))))
15949 ;; Set the number of unread articles.
15951 (setcar (gnus-gethash (gnus-info-group info) gnus-newsrc-hashtb) num))
15954 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
15955 ;; and compute how many unread articles there are in each group.
15956 (defun gnus-get-unread-articles (&optional level)
15957 (let* ((newsrc (cdr gnus-newsrc-alist))
15958 (level (or level gnus-activate-level (1+ gnus-level-subscribed)))
15961 (cond ((and gnus-activate-foreign-newsgroups
15962 (not (numberp gnus-activate-foreign-newsgroups)))
15963 (1+ gnus-level-subscribed))
15964 ((numberp gnus-activate-foreign-newsgroups)
15965 gnus-activate-foreign-newsgroups)
15968 info group active method)
15969 (gnus-message 5 "Checking new news...")
15972 (setq active (gnus-active (setq group (gnus-info-group
15973 (setq info (pop newsrc))))))
15975 ;; Check newsgroups. If the user doesn't want to check them, or
15976 ;; they can't be checked (for instance, if the news server can't
15977 ;; be reached) we just set the number of unread articles in this
15978 ;; newsgroup to t. This means that Gnus thinks that there are
15979 ;; unread articles, but it has no idea how many.
15980 (if (and (setq method (gnus-info-method info))
15981 (not (gnus-server-equal
15983 (setq method (gnus-server-get-method nil method))))
15984 (not (gnus-secondary-method-p method)))
15985 ;; These groups are foreign. Check the level.
15986 (when (<= (gnus-info-level info) foreign-level)
15987 (setq active (gnus-activate-group group 'scan))
15988 (unless (inline (gnus-virtual-group-p group))
15989 (inline (gnus-close-group group)))
15990 (when (fboundp (intern (concat (symbol-name (car method))
15991 "-request-update-info")))
15992 (inline (gnus-request-update-info info method))))
15993 ;; These groups are native or secondary.
15994 (when (and (<= (gnus-info-level info) level)
15995 (not gnus-read-active-file))
15996 (setq active (gnus-activate-group group 'scan))
15997 (inline (gnus-close-group group))))
15999 ;; Get the number of unread articles in the group.
16001 (inline (gnus-get-unread-articles-in-group info active))
16002 ;; The group couldn't be reached, so we nix out the number of
16003 ;; unread articles and stuff.
16004 (gnus-set-active group nil)
16005 (setcar (gnus-gethash group gnus-newsrc-hashtb) t)))
16007 (gnus-message 5 "Checking new news...done")))
16009 ;; Create a hash table out of the newsrc alist. The `car's of the
16010 ;; alist elements are used as keys.
16011 (defun gnus-make-hashtable-from-newsrc-alist ()
16012 (let ((alist gnus-newsrc-alist)
16013 (ohashtb gnus-newsrc-hashtb)
16015 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
16017 (setq prev (setq gnus-newsrc-alist
16018 (if (equal (caar gnus-newsrc-alist)
16021 (cons (list "dummy.group" 0 nil) alist)))))
16025 (cons (and ohashtb (car (gnus-gethash (caar alist) ohashtb)))
16027 gnus-newsrc-hashtb)
16029 alist (cdr alist)))))
16031 (defun gnus-make-hashtable-from-killed ()
16032 "Create a hash table from the killed and zombie lists."
16033 (let ((lists '(gnus-killed-list gnus-zombie-list))
16035 (setq gnus-killed-hashtb
16036 (gnus-make-hashtable
16037 (+ (length gnus-killed-list) (length gnus-zombie-list))))
16038 (while (setq list (pop lists))
16039 (setq list (symbol-value list))
16041 (gnus-sethash (car list) (pop list) gnus-killed-hashtb)))))
16043 (defun gnus-activate-group (group &optional scan dont-check)
16044 ;; Check whether a group has been activated or not.
16045 ;; If SCAN, request a scan of that group as well.
16046 (let ((method (gnus-find-method-for-group group))
16048 (and (gnus-check-server method)
16049 ;; We escape all bugs and quit here to make it possible to
16050 ;; continue if a group is so out-there that it reports bugs
16054 (gnus-check-backend-function 'request-scan (car method))
16055 (gnus-request-scan group method))
16058 (gnus-request-group group dont-check)
16062 (set-buffer nntp-server-buffer)
16063 (goto-char (point-min))
16064 ;; Parse the result we got from `gnus-request-group'.
16065 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
16067 (goto-char (match-beginning 1))
16069 group (setq active (cons (read (current-buffer))
16070 (read (current-buffer)))))
16071 ;; Return the new active info.
16074 (defun gnus-update-read-articles (group unread)
16075 "Update the list of read and ticked articles in GROUP using the
16076 UNREAD and TICKED lists.
16077 Note: UNSELECTED has to be sorted over `<'.
16078 Returns whether the updating was successful."
16079 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
16080 (entry (gnus-gethash group gnus-newsrc-hashtb))
16081 (info (nth 2 entry))
16083 (unread (sort (copy-sequence unread) '<))
16085 (if (or (not info) (not active))
16086 ;; There is no info on this group if it was, in fact,
16087 ;; killed. Gnus stores no information on killed groups, so
16088 ;; there's nothing to be done.
16089 ;; One could store the information somewhere temporarily,
16090 ;; perhaps... Hmmm...
16092 ;; Remove any negative articles numbers.
16093 (while (and unread (< (car unread) 0))
16094 (setq unread (cdr unread)))
16095 ;; Remove any expired article numbers
16096 (while (and unread (< (car unread) (car active)))
16097 (setq unread (cdr unread)))
16098 ;; Compute the ranges of read articles by looking at the list of
16099 ;; unread articles.
16101 (if (/= (car unread) prev)
16102 (setq read (cons (if (= prev (1- (car unread))) prev
16103 (cons prev (1- (car unread)))) read)))
16104 (setq prev (1+ (car unread)))
16105 (setq unread (cdr unread)))
16106 (when (<= prev (cdr active))
16107 (setq read (cons (cons prev (cdr active)) read)))
16108 ;; Enter this list into the group info.
16109 (gnus-info-set-read
16110 info (if (> (length read) 1) (nreverse read) read))
16111 ;; Set the number of unread articles in gnus-newsrc-hashtb.
16112 (gnus-get-unread-articles-in-group info (gnus-active group))
16115 (defun gnus-make-articles-unread (group articles)
16116 "Mark ARTICLES in GROUP as unread."
16117 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
16118 (gnus-gethash (gnus-group-real-name group)
16119 gnus-newsrc-hashtb))))
16120 (ranges (gnus-info-read info))
16123 (when (gnus-member-of-range
16124 (setq article (pop articles)) ranges)
16125 (setq news (cons article news))))
16127 (gnus-info-set-read
16128 info (gnus-remove-from-range (gnus-info-read info) (nreverse news)))
16129 (gnus-group-update-group group t))))
16131 ;; Enter all dead groups into the hashtb.
16132 (defun gnus-update-active-hashtb-from-killed ()
16133 (let ((hashtb (setq gnus-active-hashtb (make-vector 4095 0)))
16134 (lists (list gnus-killed-list gnus-zombie-list))
16137 (setq killed (car lists))
16139 (gnus-sethash (car killed) nil hashtb)
16140 (setq killed (cdr killed)))
16141 (setq lists (cdr lists)))))
16143 (defun gnus-get-killed-groups ()
16144 "Go through the active hashtb and all all unknown groups as killed."
16145 ;; First make sure active file has been read.
16146 (unless (gnus-read-active-file-p)
16147 (let ((gnus-read-active-file t))
16148 (gnus-read-active-file)))
16149 (or gnus-killed-hashtb (gnus-make-hashtable-from-killed))
16150 ;; Go through all newsgroups that are known to Gnus - enlarge kill list.
16154 (group (symbol-name sym)))
16155 (if (or (null group)
16156 (gnus-gethash group gnus-killed-hashtb)
16157 (gnus-gethash group gnus-newsrc-hashtb))
16159 (let ((do-sub (gnus-matches-options-n group)))
16160 (if (or (eq do-sub 'subscribe) (eq do-sub 'ignore))
16162 (setq groups (1+ groups))
16163 (setq gnus-killed-list
16164 (cons group gnus-killed-list))
16165 (gnus-sethash group group gnus-killed-hashtb))))))
16166 gnus-active-hashtb))
16168 ;; Get the active file(s) from the backend(s).
16169 (defun gnus-read-active-file ()
16170 (gnus-group-set-mode-line)
16173 (if (gnus-check-server gnus-select-method)
16174 ;; The native server is available.
16175 (cons gnus-select-method gnus-secondary-select-methods)
16176 ;; The native server is down, so we just do the
16178 gnus-secondary-select-methods)
16179 ;; Also read from the archive server.
16180 (when gnus-message-archive-method
16181 (list "archive"))))
16183 (setq gnus-have-read-active-file nil)
16185 (set-buffer nntp-server-buffer)
16187 (let* ((method (if (stringp (car methods))
16188 (gnus-server-get-method nil (car methods))
16190 (where (nth 1 method))
16191 (mesg (format "Reading active file%s via %s..."
16192 (if (and where (not (zerop (length where))))
16193 (concat " from " where) "")
16195 (gnus-message 5 mesg)
16196 (when (gnus-check-server method)
16197 ;; Request that the backend scan its incoming messages.
16198 (and (gnus-check-backend-function 'request-scan (car method))
16199 (gnus-request-scan nil method))
16201 ((and (eq gnus-read-active-file 'some)
16202 (gnus-check-backend-function 'retrieve-groups (car method)))
16203 (let ((newsrc (cdr gnus-newsrc-alist))
16204 (gmethod (gnus-server-get-method nil method))
16206 (while (setq info (pop newsrc))
16207 (when (gnus-server-equal
16208 (gnus-find-method-for-group
16209 (gnus-info-group info) info)
16211 (push (gnus-group-real-name (gnus-info-group info))
16214 (gnus-check-server method)
16215 (setq list-type (gnus-retrieve-groups groups method))
16219 1.2 "Cannot read partial active file from %s server."
16221 ((eq list-type 'active)
16222 (gnus-active-to-gnus-format method gnus-active-hashtb))
16224 (gnus-groups-to-gnus-format method gnus-active-hashtb))))))
16226 (if (not (gnus-request-list method))
16227 (unless (equal method gnus-message-archive-method)
16228 (gnus-error 1 "Cannot read active file from %s server."
16230 (gnus-message 5 mesg)
16231 (gnus-active-to-gnus-format method gnus-active-hashtb)
16232 ;; We mark this active file as read.
16233 (push method gnus-have-read-active-file)
16234 (gnus-message 5 "%sdone" mesg))))))
16235 (setq methods (cdr methods))))))
16237 ;; Read an active file and place the results in `gnus-active-hashtb'.
16238 (defun gnus-active-to-gnus-format (&optional method hashtb ignore-errors)
16240 (setq method gnus-select-method))
16241 (let ((cur (current-buffer))
16243 (if (and gnus-active-hashtb
16244 (not (equal method gnus-select-method)))
16246 (setq gnus-active-hashtb
16247 (if (equal method gnus-select-method)
16248 (gnus-make-hashtable
16249 (count-lines (point-min) (point-max)))
16250 (gnus-make-hashtable 4096)))))))
16251 ;; Delete unnecessary lines.
16252 (goto-char (point-min))
16253 (while (search-forward "\nto." nil t)
16254 (delete-region (1+ (match-beginning 0))
16255 (progn (forward-line 1) (point))))
16256 (or (string= gnus-ignored-newsgroups "")
16258 (goto-char (point-min))
16259 (delete-matching-lines gnus-ignored-newsgroups)))
16260 ;; Make the group names readable as a lisp expression even if they
16261 ;; contain special characters.
16262 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
16263 (goto-char (point-max))
16264 (while (re-search-backward "[][';?()#]" nil t)
16266 ;; If these are groups from a foreign select method, we insert the
16267 ;; group prefix in front of the group names.
16268 (and method (not (gnus-server-equal
16269 (gnus-server-get-method nil method)
16270 (gnus-server-get-method nil gnus-select-method)))
16271 (let ((prefix (gnus-group-prefixed-name "" method)))
16272 (goto-char (point-min))
16273 (while (and (not (eobp))
16274 (progn (insert prefix)
16275 (zerop (forward-line 1)))))))
16276 ;; Store the active file in a hash table.
16277 (goto-char (point-min))
16278 (if (string-match "%[oO]" gnus-group-line-format)
16279 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
16280 ;; If we want information on moderated groups, we use this
16282 (let* ((mod-hashtb (make-vector 7 0))
16283 (m (intern "m" mod-hashtb))
16285 (while (not (eobp))
16286 (condition-case nil
16288 (narrow-to-region (point) (gnus-point-at-eol))
16289 (setq group (let ((obarray hashtb)) (read cur)))
16290 (if (and (numberp (setq max (read cur)))
16291 (numberp (setq min (read cur)))
16293 (skip-chars-forward " \t")
16295 (or (= (following-char) ?=)
16296 (= (following-char) ?x)
16297 (= (following-char) ?j)))))
16298 (set group (cons min max))
16300 ;; Enter moderated groups into a list.
16301 (if (eq (let ((obarray mod-hashtb)) (read cur)) m)
16302 (setq gnus-moderated-list
16303 (cons (symbol-name group) gnus-moderated-list))))
16310 ;; And if we do not care about moderation, we use this loop,
16311 ;; which is faster.
16312 (let (group max min)
16313 (while (not (eobp))
16316 (narrow-to-region (point) (gnus-point-at-eol))
16317 ;; group gets set to a symbol interned in the hash table
16318 ;; (what a hack!!) - jwz
16319 (setq group (let ((obarray hashtb)) (read cur)))
16320 (if (and (numberp (setq max (read cur)))
16321 (numberp (setq min (read cur)))
16323 (skip-chars-forward " \t")
16325 (or (= (following-char) ?=)
16326 (= (following-char) ?x)
16327 (= (following-char) ?j)))))
16328 (set group (cons min max))
16336 (gnus-message 3 "Warning - illegal active: %s"
16338 (gnus-point-at-bol) (gnus-point-at-eol)))))))
16340 (forward-line 1))))))
16342 (defun gnus-groups-to-gnus-format (method &optional hashtb)
16343 ;; Parse a "groups" active file.
16344 (let ((cur (current-buffer))
16346 (if (and method gnus-active-hashtb)
16348 (setq gnus-active-hashtb
16349 (gnus-make-hashtable
16350 (count-lines (point-min) (point-max)))))))
16351 (prefix (and method
16352 (not (gnus-server-equal
16353 (gnus-server-get-method nil method)
16354 (gnus-server-get-method nil gnus-select-method)))
16355 (gnus-group-prefixed-name "" method))))
16357 (goto-char (point-min))
16358 ;; We split this into to separate loops, one with the prefix
16359 ;; and one without to speed the reading up somewhat.
16361 (let (min max opoint group)
16362 (while (not (eobp))
16365 (read cur) (read cur)
16366 (setq min (read cur)
16369 (skip-chars-forward " \t")
16372 (set (let ((obarray hashtb)) (read cur))
16374 (error (and group (symbolp group) (set group nil))))
16376 (let (min max group)
16377 (while (not (eobp))
16379 (if (= (following-char) ?2)
16381 (read cur) (read cur)
16382 (setq min (read cur)
16384 (set (setq group (let ((obarray hashtb)) (read cur)))
16386 (error (and group (symbolp group) (set group nil))))
16387 (forward-line 1))))))
16389 (defun gnus-read-newsrc-file (&optional force)
16390 "Read startup file.
16391 If FORCE is non-nil, the .newsrc file is read."
16392 ;; Reset variables that might be defined in the .newsrc.eld file.
16393 (let ((variables gnus-variable-list))
16395 (set (car variables) nil)
16396 (setq variables (cdr variables))))
16397 (let* ((newsrc-file gnus-current-startup-file)
16398 (quick-file (concat newsrc-file ".el")))
16400 ;; We always load the .newsrc.eld file. If always contains
16401 ;; much information that can not be gotten from the .newsrc
16402 ;; file (ticked articles, killed groups, foreign methods, etc.)
16403 (gnus-read-newsrc-el-file quick-file)
16405 (if (and (file-exists-p gnus-current-startup-file)
16407 (and (file-newer-than-file-p newsrc-file quick-file)
16408 (file-newer-than-file-p newsrc-file
16409 (concat quick-file "d")))
16410 (not gnus-newsrc-alist)))
16411 ;; We read the .newsrc file. Note that if there if a
16412 ;; .newsrc.eld file exists, it has already been read, and
16413 ;; the `gnus-newsrc-hashtb' has been created. While reading
16414 ;; the .newsrc file, Gnus will only use the information it
16415 ;; can find there for changing the data already read -
16416 ;; ie. reading the .newsrc file will not trash the data
16417 ;; already read (except for read articles).
16419 (gnus-message 5 "Reading %s..." newsrc-file)
16420 (set-buffer (find-file-noselect newsrc-file))
16421 (buffer-disable-undo (current-buffer))
16422 (gnus-newsrc-to-gnus-format)
16423 (kill-buffer (current-buffer))
16424 (gnus-message 5 "Reading %s...done" newsrc-file)))
16426 ;; Read any slave files.
16428 (gnus-master-read-slave-newsrc))
16430 ;; Convert old to new.
16431 (gnus-convert-old-newsrc))))
16433 (defun gnus-continuum-version (version)
16434 "Return VERSION as a floating point number."
16435 (when (or (string-match "^\\([^ ]+\\)? ?Gnus v?\\([0-9.]+\\)$" version)
16436 (string-match "^\\(.?\\)gnus-\\([0-9.]+\\)$" version))
16437 (let* ((alpha (and (match-beginning 1) (match-string 1 version)))
16438 (number (match-string 2 version))
16440 (string-match "\\([0-9]\\)\\.\\([0-9]+\\)\\.?\\([0-9]+\\)?" number)
16441 (setq major (string-to-number (match-string 1 number)))
16442 (setq minor (string-to-number (match-string 2 number)))
16443 (setq least (if (match-beginning 3)
16444 (string-to-number (match-string 3 number))
16448 (format "%s00%02d%02d"
16450 ((member alpha '("(ding)" "d")) "4.99")
16451 ((member alpha '("September" "s")) "5.01")
16452 ((member alpha '("Red" "r")) "5.03"))
16454 (format "%d.%02d%02d" major minor least))))))
16456 (defun gnus-convert-old-newsrc ()
16457 "Convert old newsrc into the new format, if needed."
16458 (let ((fcv (and gnus-newsrc-file-version
16459 (gnus-continuum-version gnus-newsrc-file-version))))
16461 ;; No .newsrc.eld file was loaded.
16463 ;; Gnus 5 .newsrc.eld was loaded.
16464 ((< fcv (gnus-continuum-version "September Gnus v0.1"))
16465 (gnus-convert-old-ticks)))))
16467 (defun gnus-convert-old-ticks ()
16468 (let ((newsrc (cdr gnus-newsrc-alist))
16469 marks info dormant ticked)
16470 (while (setq info (pop newsrc))
16471 (when (setq marks (gnus-info-marks info))
16472 (setq dormant (cdr (assq 'dormant marks))
16473 ticked (cdr (assq 'tick marks)))
16474 (when (or dormant ticked)
16475 (gnus-info-set-read
16478 (gnus-info-read info)
16479 (nconc (gnus-uncompress-range dormant)
16480 (gnus-uncompress-range ticked)))))))))
16482 (defun gnus-read-newsrc-el-file (file)
16483 (let ((ding-file (concat file "d")))
16484 ;; We always, always read the .eld file.
16485 (gnus-message 5 "Reading %s..." ding-file)
16486 (let (gnus-newsrc-assoc)
16487 (condition-case nil
16488 (load ding-file t t t)
16490 (gnus-error 1 "Error in %s" ding-file)))
16491 (when gnus-newsrc-assoc
16492 (setq gnus-newsrc-alist gnus-newsrc-assoc)))
16493 (gnus-make-hashtable-from-newsrc-alist)
16494 (when (file-newer-than-file-p file ding-file)
16495 ;; Old format quick file
16496 (gnus-message 5 "Reading %s..." file)
16497 ;; The .el file is newer than the .eld file, so we read that one
16499 (gnus-read-old-newsrc-el-file file))))
16501 ;; Parse the old-style quick startup file
16502 (defun gnus-read-old-newsrc-el-file (file)
16503 (let (newsrc killed marked group m info)
16505 (let ((gnus-killed-assoc nil)
16506 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc)
16508 (condition-case nil
16511 (setq newsrc gnus-newsrc-assoc
16512 killed gnus-killed-assoc
16513 marked gnus-marked-assoc)))
16514 (setq gnus-newsrc-alist nil)
16515 (while (setq group (pop newsrc))
16516 (if (setq info (gnus-get-info (car group)))
16518 (gnus-info-set-read info (cddr group))
16519 (gnus-info-set-level
16520 info (if (nth 1 group) gnus-level-default-subscribed
16521 gnus-level-default-unsubscribed))
16522 (setq gnus-newsrc-alist (cons info gnus-newsrc-alist)))
16525 (if (nth 1 group) gnus-level-default-subscribed
16526 gnus-level-default-unsubscribed)
16528 gnus-newsrc-alist))
16529 ;; Copy marks into info.
16530 (when (setq m (assoc (car group) marked))
16531 (unless (nthcdr 3 info)
16532 (nconc info (list nil)))
16533 (gnus-info-set-marks
16534 info (list (cons 'tick (gnus-compress-sequence
16535 (sort (cdr m) '<) t))))))
16536 (setq newsrc killed)
16538 (setcar newsrc (caar newsrc))
16539 (setq newsrc (cdr newsrc)))
16540 (setq gnus-killed-list killed))
16541 ;; The .el file version of this variable does not begin with
16542 ;; "options", while the .eld version does, so we just add it if it
16545 gnus-newsrc-options
16547 (and (not (string-match "^ *options" gnus-newsrc-options))
16548 (setq gnus-newsrc-options (concat "options " gnus-newsrc-options)))
16549 (and (not (string-match "\n$" gnus-newsrc-options))
16550 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n")))
16551 ;; Finally, if we read some options lines, we parse them.
16552 (or (string= gnus-newsrc-options "")
16553 (gnus-newsrc-parse-options gnus-newsrc-options))))
16555 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))
16556 (gnus-make-hashtable-from-newsrc-alist)))
16558 (defun gnus-make-newsrc-file (file)
16559 "Make server dependent file name by catenating FILE and server host name."
16560 (let* ((file (expand-file-name file nil))
16561 (real-file (concat file "-" (nth 1 gnus-select-method))))
16562 (if (or (file-exists-p real-file)
16563 (file-exists-p (concat real-file ".el"))
16564 (file-exists-p (concat real-file ".eld")))
16567 (defun gnus-newsrc-to-gnus-format ()
16568 (setq gnus-newsrc-options "")
16569 (setq gnus-newsrc-options-n nil)
16571 (or gnus-active-hashtb
16572 (setq gnus-active-hashtb (make-vector 4095 0)))
16573 (let ((buf (current-buffer))
16574 (already-read (> (length gnus-newsrc-alist) 1))
16575 group subscribed options-symbol newsrc Options-symbol
16577 (goto-char (point-min))
16578 ;; We intern the symbol `options' in the active hashtb so that we
16579 ;; can `eq' against it later.
16580 (set (setq options-symbol (intern "options" gnus-active-hashtb)) nil)
16581 (set (setq Options-symbol (intern "Options" gnus-active-hashtb)) nil)
16583 (while (not (eobp))
16584 ;; We first read the first word on the line by narrowing and
16585 ;; then reading into `gnus-active-hashtb'. Most groups will
16586 ;; already exist in that hashtb, so this will save some string
16590 (progn (skip-chars-forward "^ \t!:\n") (point)))
16591 (goto-char (point-min))
16593 (and (/= (point-min) (point-max))
16594 (let ((obarray gnus-active-hashtb)) (read buf))))
16596 ;; Now, the symbol we have read is either `options' or a group
16597 ;; name. If it is an options line, we just add it to a string.
16599 ((or (eq symbol options-symbol)
16600 (eq symbol Options-symbol))
16601 (setq gnus-newsrc-options
16602 ;; This concating is quite inefficient, but since our
16603 ;; thorough studies show that approx 99.37% of all
16604 ;; .newsrc files only contain a single options line, we
16605 ;; don't give a damn, frankly, my dear.
16606 (concat gnus-newsrc-options
16608 (gnus-point-at-bol)
16609 ;; Options may continue on the next line.
16610 (or (and (re-search-forward "^[^ \t]" nil 'move)
16611 (progn (beginning-of-line) (point)))
16615 ;; Group names can be just numbers.
16616 (when (numberp symbol)
16617 (setq symbol (intern (int-to-string symbol) gnus-active-hashtb)))
16618 (or (boundp symbol) (set symbol nil))
16619 ;; It was a group name.
16620 (setq subscribed (= (following-char) ?:)
16621 group (symbol-name symbol)
16624 ;; If the line ends here, this is clearly a buggy line, so
16625 ;; we put point a the beginning of line and let the cond
16626 ;; below do the error handling.
16627 (beginning-of-line)
16628 ;; We skip to the beginning of the ranges.
16629 (skip-chars-forward "!: \t"))
16630 ;; We are now at the beginning of the list of read articles.
16631 ;; We read them range by range.
16634 ((looking-at "[0-9]+")
16635 ;; We narrow and read a number instead of buffer-substring/
16636 ;; string-to-int because it's faster. narrow/widen is
16637 ;; faster than save-restriction/narrow, and save-restriction
16638 ;; produces a garbage object.
16640 (narrow-to-region (match-beginning 0) (match-end 0))
16643 ;; If the next character is a dash, then this is a range.
16644 (if (= (following-char) ?-)
16646 ;; We read the upper bound of the range.
16648 (if (not (looking-at "[0-9]+"))
16649 ;; This is a buggy line, by we pretend that
16650 ;; it's kinda OK. Perhaps the user should be
16652 (setq reads (cons num1 reads))
16657 (narrow-to-region (match-beginning 0)
16662 ;; It was just a simple number, so we add it to the
16664 (setq reads (cons num1 reads)))
16665 ;; If the next char in ?\n, then we have reached the end
16666 ;; of the line and return nil.
16667 (/= (following-char) ?\n))
16668 ((= (following-char) ?\n)
16669 ;; End of line, so we end.
16672 ;; Not numbers and not eol, so this might be a buggy
16675 ;; If it was eob instead of ?\n, we allow it.
16677 ;; The line was buggy.
16679 (gnus-error 3.1 "Mangled line: %s"
16680 (buffer-substring (gnus-point-at-bol)
16681 (gnus-point-at-eol)))))
16683 ;; Skip past ", ". Spaces are illegal in these ranges, but
16684 ;; we allow them, because it's a common mistake to put a
16685 ;; space after the comma.
16686 (skip-chars-forward ", "))
16688 ;; We have already read .newsrc.eld, so we gently update the
16689 ;; data in the hash table with the information we have just
16692 (let ((info (gnus-get-info group))
16695 ;; There is an entry for this file in the alist.
16697 (gnus-info-set-read info (nreverse reads))
16698 ;; We update the level very gently. In fact, we
16699 ;; only change it if there's been a status change
16700 ;; from subscribed to unsubscribed, or vice versa.
16701 (setq level (gnus-info-level info))
16702 (cond ((and (<= level gnus-level-subscribed)
16704 (setq level (if reads
16705 gnus-level-default-unsubscribed
16706 (1+ gnus-level-default-unsubscribed))))
16707 ((and (> level gnus-level-subscribed) subscribed)
16708 (setq level gnus-level-default-subscribed)))
16709 (gnus-info-set-level info level))
16710 ;; This is a new group.
16711 (setq info (list group
16713 gnus-level-default-subscribed
16715 (1+ gnus-level-subscribed)
16716 gnus-level-default-unsubscribed))
16717 (nreverse reads))))
16718 (setq newsrc (cons info newsrc))))))
16721 (setq newsrc (nreverse newsrc))
16723 (if (not already-read)
16725 ;; We now have two newsrc lists - `newsrc', which is what we
16726 ;; have read from .newsrc, and `gnus-newsrc-alist', which is
16727 ;; what we've read from .newsrc.eld. We have to merge these
16728 ;; lists. We do this by "attaching" any (foreign) groups in the
16729 ;; gnus-newsrc-alist to the (native) group that precedes them.
16730 (let ((rc (cdr gnus-newsrc-alist))
16731 (prev gnus-newsrc-alist)
16734 (or (null (nth 4 (car rc))) ; It's a native group.
16735 (assoc (caar rc) newsrc) ; It's already in the alist.
16736 (if (setq entry (assoc (caar prev) newsrc))
16737 (setcdr (setq mentry (memq entry newsrc))
16738 (cons (car rc) (cdr mentry)))
16739 (setq newsrc (cons (car rc) newsrc))))
16743 (setq gnus-newsrc-alist newsrc)
16744 ;; We make the newsrc hashtb.
16745 (gnus-make-hashtable-from-newsrc-alist)
16747 ;; Finally, if we read some options lines, we parse them.
16748 (or (string= gnus-newsrc-options "")
16749 (gnus-newsrc-parse-options gnus-newsrc-options))))
16751 ;; Parse options lines to find "options -n !all rec.all" and stuff.
16752 ;; The return value will be a list on the form
16753 ;; ((regexp1 . ignore)
16754 ;; (regexp2 . subscribe)...)
16755 ;; When handling new newsgroups, groups that match a `ignore' regexp
16756 ;; will be ignored, and groups that match a `subscribe' regexp will be
16757 ;; subscribed. A line like
16758 ;; options -n !all rec.all
16759 ;; will lead to a list that looks like
16760 ;; (("^rec\\..+" . subscribe)
16761 ;; ("^.+" . ignore))
16762 ;; So all "rec.*" groups will be subscribed, while all the other
16763 ;; groups will be ignored. Note that "options -n !all rec.all" is very
16764 ;; different from "options -n rec.all !all".
16765 (defun gnus-newsrc-parse-options (options)
16768 (gnus-set-work-buffer)
16769 (insert (regexp-quote options))
16770 ;; First we treat all continuation lines.
16771 (goto-char (point-min))
16772 (while (re-search-forward "\n[ \t]+" nil t)
16773 (replace-match " " t t))
16774 ;; Then we transform all "all"s into ".+"s.
16775 (goto-char (point-min))
16776 (while (re-search-forward "\\ball\\b" nil t)
16777 (replace-match ".+" t t))
16778 (goto-char (point-min))
16779 ;; We remove all other options than the "-n" ones.
16780 (while (re-search-forward "[ \t]-[^n][^-]*" nil t)
16781 (replace-match " ")
16783 (goto-char (point-min))
16785 ;; We are only interested in "options -n" lines - we
16786 ;; ignore the other option lines.
16787 (while (re-search-forward "[ \t]-n" nil t)
16789 (or (save-excursion
16790 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t)
16792 (gnus-point-at-eol)))
16793 ;; Search for all "words"...
16794 (while (re-search-forward "[^ \t,\n]+" eol t)
16795 (if (= (char-after (match-beginning 0)) ?!)
16796 ;; If the word begins with a bang (!), this is a "not"
16797 ;; spec. We put this spec (minus the bang) and the
16798 ;; symbol `ignore' into the list.
16799 (setq out (cons (cons (concat
16800 "^" (buffer-substring
16801 (1+ (match-beginning 0))
16804 ;; There was no bang, so this is a "yes" spec.
16805 (setq out (cons (cons (concat "^" (match-string 0))
16806 'subscribe) out)))))
16808 (setq gnus-newsrc-options-n out))))
16810 (defun gnus-save-newsrc-file (&optional force)
16811 "Save .newsrc file."
16812 ;; Note: We cannot save .newsrc file if all newsgroups are removed
16813 ;; from the variable gnus-newsrc-alist.
16814 (when (and (or gnus-newsrc-alist gnus-killed-list)
16815 gnus-current-startup-file)
16817 (if (and (or gnus-use-dribble-file gnus-slave)
16819 (or (not gnus-dribble-buffer)
16820 (not (buffer-name gnus-dribble-buffer))
16821 (zerop (save-excursion
16822 (set-buffer gnus-dribble-buffer)
16824 (gnus-message 4 "(No changes need to be saved)")
16825 (run-hooks 'gnus-save-newsrc-hook)
16827 (gnus-slave-save-newsrc)
16829 (when gnus-save-newsrc-file
16830 (gnus-message 5 "Saving %s..." gnus-current-startup-file)
16831 (gnus-gnus-to-newsrc-format)
16832 (gnus-message 5 "Saving %s...done" gnus-current-startup-file))
16833 ;; Save .newsrc.eld.
16834 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
16835 (make-local-variable 'version-control)
16836 (setq version-control 'never)
16837 (setq buffer-file-name
16838 (concat gnus-current-startup-file ".eld"))
16839 (setq default-directory (file-name-directory buffer-file-name))
16840 (gnus-add-current-to-buffer-list)
16841 (buffer-disable-undo (current-buffer))
16843 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file)
16844 (gnus-gnus-to-quick-newsrc-format)
16845 (run-hooks 'gnus-save-quick-newsrc-hook)
16847 (kill-buffer (current-buffer))
16849 5 "Saving %s.eld...done" gnus-current-startup-file))
16850 (gnus-dribble-delete-file)
16851 (gnus-group-set-mode-line)))))
16853 (defun gnus-gnus-to-quick-newsrc-format ()
16854 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
16855 (insert ";; Gnus startup file.\n")
16856 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
16857 (insert ";; to read .newsrc.\n")
16858 (insert "(setq gnus-newsrc-file-version "
16859 (prin1-to-string gnus-version) ")\n")
16861 (if gnus-save-killed-list gnus-variable-list
16862 ;; Remove the `gnus-killed-list' from the list of variables
16863 ;; to be saved, if required.
16864 (delq 'gnus-killed-list (copy-sequence gnus-variable-list))))
16865 ;; Peel off the "dummy" group.
16866 (gnus-newsrc-alist (cdr gnus-newsrc-alist))
16868 ;; Insert the variables into the file.
16870 (when (and (boundp (setq variable (pop variables)))
16871 (symbol-value variable))
16872 (insert "(setq " (symbol-name variable) " '")
16873 (prin1 (symbol-value variable) (current-buffer))
16876 (defun gnus-gnus-to-newsrc-format ()
16877 ;; Generate and save the .newsrc file.
16879 (set-buffer (create-file-buffer gnus-current-startup-file))
16880 (let ((newsrc (cdr gnus-newsrc-alist))
16881 (standard-output (current-buffer))
16882 info ranges range method)
16883 (setq buffer-file-name gnus-current-startup-file)
16884 (setq default-directory (file-name-directory buffer-file-name))
16885 (buffer-disable-undo (current-buffer))
16888 (if gnus-newsrc-options (insert gnus-newsrc-options))
16889 ;; Write subscribed and unsubscribed.
16890 (while (setq info (pop newsrc))
16891 ;; Don't write foreign groups to .newsrc.
16892 (when (or (null (setq method (gnus-info-method info)))
16893 (equal method "native")
16894 (gnus-server-equal method gnus-select-method))
16895 (insert (gnus-info-group info)
16896 (if (> (gnus-info-level info) gnus-level-subscribed)
16898 (when (setq ranges (gnus-info-read info))
16900 (if (not (listp (cdr ranges)))
16901 (if (= (car ranges) (cdr ranges))
16902 (princ (car ranges))
16903 (princ (car ranges))
16905 (princ (cdr ranges)))
16906 (while (setq range (pop ranges))
16907 (if (or (atom range) (= (car range) (cdr range)))
16908 (princ (or (and (atom range) range) (car range)))
16909 (princ (car range))
16911 (princ (cdr range)))
16912 (if ranges (insert ",")))))
16914 (make-local-variable 'version-control)
16915 (setq version-control 'never)
16916 ;; It has been reported that sometime the modtime on the .newsrc
16917 ;; file seems to be off. We really do want to overwrite it, so
16918 ;; we clear the modtime here before saving. It's a bit odd,
16920 ;; sometimes the modtime clear isn't sufficient. most brute force:
16921 ;; delete the silly thing entirely first. but this fails to provide
16922 ;; such niceties as .newsrc~ creation.
16923 (if gnus-modtime-botch
16924 (delete-file gnus-startup-file)
16925 (clear-visited-file-modtime))
16926 (run-hooks 'gnus-save-standard-newsrc-hook)
16928 (kill-buffer (current-buffer)))))
16932 ;;; Slave functions.
16935 (defun gnus-slave-save-newsrc ()
16937 (set-buffer gnus-dribble-buffer)
16939 (make-temp-name (concat gnus-current-startup-file "-slave-"))))
16940 (write-region (point-min) (point-max) slave-name nil 'nomesg))))
16942 (defun gnus-master-read-slave-newsrc ()
16945 (file-name-directory gnus-current-startup-file)
16949 (file-name-nondirectory gnus-current-startup-file)
16953 (if (not slave-files)
16954 () ; There are no slave files to read.
16955 (gnus-message 7 "Reading slave newsrcs...")
16957 (set-buffer (get-buffer-create " *gnus slave*"))
16958 (buffer-disable-undo (current-buffer))
16960 (sort (mapcar (lambda (file)
16961 (list (nth 5 (file-attributes file)) file))
16964 (or (< (caar f1) (caar f2))
16965 (< (nth 1 (car f1)) (nth 1 (car f2)))))))
16968 (setq file (nth 1 (car slave-files)))
16969 (insert-file-contents file)
16970 (if (condition-case ()
16972 (eval-buffer (current-buffer))
16975 (gnus-error 3.2 "Possible error in %s" file)
16977 (or gnus-slave ; Slaves shouldn't delete these files.
16981 (setq slave-files (cdr slave-files))))
16982 (gnus-message 7 "Reading slave newsrcs...done"))))
16986 ;;; Group description.
16989 (defun gnus-read-all-descriptions-files ()
16990 (let ((methods (cons gnus-select-method
16992 (when gnus-message-archive-method
16994 gnus-secondary-select-methods))))
16996 (gnus-read-descriptions-file (car methods))
16997 (setq methods (cdr methods)))
17000 (defun gnus-read-descriptions-file (&optional method)
17001 (let ((method (or method gnus-select-method))
17003 (when (stringp method)
17004 (setq method (gnus-server-to-method method)))
17005 ;; We create the hashtable whether we manage to read the desc file
17006 ;; to avoid trying to re-read after a failed read.
17007 (or gnus-description-hashtb
17008 (setq gnus-description-hashtb
17009 (gnus-make-hashtable (length gnus-active-hashtb))))
17010 ;; Mark this method's desc file as read.
17011 (gnus-sethash (gnus-group-prefixed-name "" method) "Has read"
17012 gnus-description-hashtb)
17014 (gnus-message 5 "Reading descriptions file via %s..." (car method))
17016 ((not (gnus-check-server method))
17017 (gnus-message 1 "Couldn't open server")
17019 ((not (gnus-request-list-newsgroups method))
17020 (gnus-message 1 "Couldn't read newsgroups descriptions")
17025 (set-buffer nntp-server-buffer)
17026 (goto-char (point-min))
17027 (when (or (search-forward "\n.\n" nil t)
17028 (goto-char (point-max)))
17029 (beginning-of-line)
17030 (narrow-to-region (point-min) (point)))
17031 ;; If these are groups from a foreign select method, we insert the
17032 ;; group prefix in front of the group names.
17033 (and method (not (gnus-server-equal
17034 (gnus-server-get-method nil method)
17035 (gnus-server-get-method nil gnus-select-method)))
17036 (let ((prefix (gnus-group-prefixed-name "" method)))
17037 (goto-char (point-min))
17038 (while (and (not (eobp))
17039 (progn (insert prefix)
17040 (zerop (forward-line 1)))))))
17041 (goto-char (point-min))
17042 (while (not (eobp))
17043 ;; If we get an error, we set group to 0, which is not a
17047 (let ((obarray gnus-description-hashtb))
17048 ;; Group is set to a symbol interned in this
17050 (read nntp-server-buffer))
17052 (skip-chars-forward " \t")
17053 ;; ... which leads to this line being effectively ignored.
17054 (and (symbolp group)
17055 (set group (buffer-substring
17056 (point) (progn (end-of-line) (point)))))
17057 (forward-line 1))))
17058 (gnus-message 5 "Reading descriptions file...done")
17061 (defun gnus-group-get-description (group)
17062 "Get the description of a group by sending XGTITLE to the server."
17063 (when (gnus-request-group-description group)
17065 (set-buffer nntp-server-buffer)
17066 (goto-char (point-min))
17067 (when (looking-at "[^ \t]+[ \t]+\\(.*\\)")
17068 (match-string 1)))))
17072 ;;; Buffering of read articles.
17075 (defvar gnus-backlog-buffer " *Gnus Backlog*")
17076 (defvar gnus-backlog-articles nil)
17077 (defvar gnus-backlog-hashtb nil)
17079 (defun gnus-backlog-buffer ()
17080 "Return the backlog buffer."
17081 (or (get-buffer gnus-backlog-buffer)
17083 (set-buffer (get-buffer-create gnus-backlog-buffer))
17084 (buffer-disable-undo (current-buffer))
17085 (setq buffer-read-only t)
17086 (gnus-add-current-to-buffer-list)
17087 (get-buffer gnus-backlog-buffer))))
17089 (defun gnus-backlog-setup ()
17090 "Initialize backlog variables."
17091 (unless gnus-backlog-hashtb
17092 (setq gnus-backlog-hashtb (make-vector 1023 0))))
17094 (gnus-add-shutdown 'gnus-backlog-shutdown 'gnus)
17096 (defun gnus-backlog-shutdown ()
17097 "Clear all backlog variables and buffers."
17098 (when (get-buffer gnus-backlog-buffer)
17099 (kill-buffer gnus-backlog-buffer))
17100 (setq gnus-backlog-hashtb nil
17101 gnus-backlog-articles nil))
17103 (defun gnus-backlog-enter-article (group number buffer)
17104 (gnus-backlog-setup)
17105 (let ((ident (intern (concat group ":" (int-to-string number))
17106 gnus-backlog-hashtb))
17108 (if (memq ident gnus-backlog-articles)
17109 () ; It's already kept.
17110 ;; Remove the oldest article, if necessary.
17111 (and (numberp gnus-keep-backlog)
17112 (>= (length gnus-backlog-articles) gnus-keep-backlog)
17113 (gnus-backlog-remove-oldest-article))
17114 (setq gnus-backlog-articles (cons ident gnus-backlog-articles))
17115 ;; Insert the new article.
17117 (set-buffer (gnus-backlog-buffer))
17118 (let (buffer-read-only)
17119 (goto-char (point-max))
17120 (or (bolp) (insert "\n"))
17122 (insert-buffer-substring buffer)
17123 ;; Tag the beginning of the article with the ident.
17124 (gnus-put-text-property b (1+ b) 'gnus-backlog ident))))))
17126 (defun gnus-backlog-remove-oldest-article ()
17128 (set-buffer (gnus-backlog-buffer))
17129 (goto-char (point-min))
17130 (if (zerop (buffer-size))
17131 () ; The buffer is empty.
17132 (let ((ident (get-text-property (point) 'gnus-backlog))
17134 ;; Remove the ident from the list of articles.
17136 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
17137 ;; Delete the article itself.
17139 (point) (next-single-property-change
17140 (1+ (point)) 'gnus-backlog nil (point-max)))))))
17142 (defun gnus-backlog-remove-article (group number)
17143 "Remove article NUMBER in GROUP from the backlog."
17144 (when (numberp number)
17145 (gnus-backlog-setup)
17146 (let ((ident (intern (concat group ":" (int-to-string number))
17147 gnus-backlog-hashtb))
17149 (when (memq ident gnus-backlog-articles)
17150 ;; It was in the backlog.
17152 (set-buffer (gnus-backlog-buffer))
17153 (let (buffer-read-only)
17154 (when (setq beg (text-property-any
17155 (point-min) (point-max) 'gnus-backlog
17157 ;; Find the end (i. e., the beginning of the next article).
17159 (next-single-property-change
17160 (1+ beg) 'gnus-backlog (current-buffer) (point-max)))
17161 (delete-region beg end)
17165 (defun gnus-backlog-request-article (group number buffer)
17166 (when (numberp number)
17167 (gnus-backlog-setup)
17168 (let ((ident (intern (concat group ":" (int-to-string number))
17169 gnus-backlog-hashtb))
17171 (when (memq ident gnus-backlog-articles)
17172 ;; It was in the backlog.
17174 (set-buffer (gnus-backlog-buffer))
17175 (if (not (setq beg (text-property-any
17176 (point-min) (point-max) 'gnus-backlog
17178 ;; It wasn't in the backlog after all.
17180 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
17181 ;; Find the end (i. e., the beginning of the next article).
17183 (next-single-property-change
17184 (1+ beg) 'gnus-backlog (current-buffer) (point-max)))))
17185 (let ((buffer-read-only nil))
17187 (insert-buffer-substring gnus-backlog-buffer beg end)
17190 ;; Allow redefinition of Gnus functions.
17192 (gnus-ems-redefine)
17196 ;;; gnus.el ends here