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 ?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.17"
1734 "Version number for this version of Gnus.")
1736 (defconst gnus-version (format "Gnus v%s" gnus-version-number)
1737 "Version string for this version of Gnus.")
1739 (defvar gnus-info-nodes
1740 '((gnus-group-mode "(gnus)The Group Buffer")
1741 (gnus-summary-mode "(gnus)The Summary Buffer")
1742 (gnus-article-mode "(gnus)The Article Buffer"))
1743 "Alist of major modes and related Info nodes.")
1745 (defvar gnus-group-buffer "*Group*")
1746 (defvar gnus-summary-buffer "*Summary*")
1747 (defvar gnus-article-buffer "*Article*")
1748 (defvar gnus-server-buffer "*Server*")
1750 (defvar gnus-work-buffer " *gnus work*")
1752 (defvar gnus-original-article-buffer " *Original Article*")
1753 (defvar gnus-original-article nil)
1755 (defvar gnus-buffer-list nil
1756 "Gnus buffers that should be killed on exit.")
1758 (defvar gnus-slave nil
1759 "Whether this Gnus is a slave or not.")
1761 (defvar gnus-variable-list
1762 '(gnus-newsrc-options gnus-newsrc-options-n
1763 gnus-newsrc-last-checked-date
1764 gnus-newsrc-alist gnus-server-alist
1765 gnus-killed-list gnus-zombie-list
1766 gnus-topic-topology gnus-topic-alist
1768 "Gnus variables saved in the quick startup file.")
1770 (defvar gnus-newsrc-options nil
1771 "Options line in the .newsrc file.")
1773 (defvar gnus-newsrc-options-n nil
1774 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1776 (defvar gnus-newsrc-last-checked-date nil
1777 "Date Gnus last asked server for new newsgroups.")
1779 (defvar gnus-topic-topology nil
1780 "The complete topic hierarchy.")
1782 (defvar gnus-topic-alist nil
1783 "The complete topic-group alist.")
1785 (defvar gnus-newsrc-alist nil
1786 "Assoc list of read articles.
1787 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1789 (defvar gnus-newsrc-hashtb nil
1790 "Hashtable of gnus-newsrc-alist.")
1792 (defvar gnus-killed-list nil
1793 "List of killed newsgroups.")
1795 (defvar gnus-killed-hashtb nil
1796 "Hash table equivalent of gnus-killed-list.")
1798 (defvar gnus-zombie-list nil
1799 "List of almost dead newsgroups.")
1801 (defvar gnus-description-hashtb nil
1802 "Descriptions of newsgroups.")
1804 (defvar gnus-list-of-killed-groups nil
1805 "List of newsgroups that have recently been killed by the user.")
1807 (defvar gnus-active-hashtb nil
1808 "Hashtable of active articles.")
1810 (defvar gnus-moderated-list nil
1811 "List of moderated newsgroups.")
1813 (defvar gnus-group-marked nil)
1815 (defvar gnus-current-startup-file nil
1816 "Startup file for the current host.")
1818 (defvar gnus-last-search-regexp nil
1819 "Default regexp for article search command.")
1821 (defvar gnus-last-shell-command nil
1822 "Default shell command on article.")
1824 (defvar gnus-current-select-method nil
1825 "The current method for selecting a newsgroup.")
1827 (defvar gnus-group-list-mode nil)
1829 (defvar gnus-article-internal-prepare-hook nil)
1831 (defvar gnus-newsgroup-name nil)
1832 (defvar gnus-newsgroup-begin nil)
1833 (defvar gnus-newsgroup-end nil)
1834 (defvar gnus-newsgroup-last-rmail nil)
1835 (defvar gnus-newsgroup-last-mail nil)
1836 (defvar gnus-newsgroup-last-folder nil)
1837 (defvar gnus-newsgroup-last-file nil)
1838 (defvar gnus-newsgroup-auto-expire nil)
1839 (defvar gnus-newsgroup-active nil)
1841 (defvar gnus-newsgroup-data nil)
1842 (defvar gnus-newsgroup-data-reverse nil)
1843 (defvar gnus-newsgroup-limit nil)
1844 (defvar gnus-newsgroup-limits nil)
1846 (defvar gnus-newsgroup-unreads nil
1847 "List of unread articles in the current newsgroup.")
1849 (defvar gnus-newsgroup-unselected nil
1850 "List of unselected unread articles in the current newsgroup.")
1852 (defvar gnus-newsgroup-reads nil
1853 "Alist of read articles and article marks in the current newsgroup.")
1855 (defvar gnus-newsgroup-expunged-tally nil)
1857 (defvar gnus-newsgroup-marked nil
1858 "List of ticked articles in the current newsgroup (a subset of unread art).")
1860 (defvar gnus-newsgroup-killed nil
1861 "List of ranges of articles that have been through the scoring process.")
1863 (defvar gnus-newsgroup-cached nil
1864 "List of articles that come from the article cache.")
1866 (defvar gnus-newsgroup-saved nil
1867 "List of articles that have been saved.")
1869 (defvar gnus-newsgroup-kill-headers nil)
1871 (defvar gnus-newsgroup-replied nil
1872 "List of articles that have been replied to in the current newsgroup.")
1874 (defvar gnus-newsgroup-expirable nil
1875 "List of articles in the current newsgroup that can be expired.")
1877 (defvar gnus-newsgroup-processable nil
1878 "List of articles in the current newsgroup that can be processed.")
1880 (defvar gnus-newsgroup-bookmarks nil
1881 "List of articles in the current newsgroup that have bookmarks.")
1883 (defvar gnus-newsgroup-dormant nil
1884 "List of dormant articles in the current newsgroup.")
1886 (defvar gnus-newsgroup-scored nil
1887 "List of scored articles in the current newsgroup.")
1889 (defvar gnus-newsgroup-headers nil
1890 "List of article headers in the current newsgroup.")
1892 (defvar gnus-newsgroup-threads nil)
1894 (defvar gnus-newsgroup-prepared nil
1895 "Whether the current group has been prepared properly.")
1897 (defvar gnus-newsgroup-ancient nil
1898 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1900 (defvar gnus-newsgroup-sparse nil)
1902 (defvar gnus-current-article nil)
1903 (defvar gnus-article-current nil)
1904 (defvar gnus-current-headers nil)
1905 (defvar gnus-have-all-headers nil)
1906 (defvar gnus-last-article nil)
1907 (defvar gnus-newsgroup-history nil)
1908 (defvar gnus-current-kill-article nil)
1910 ;; Save window configuration.
1911 (defvar gnus-prev-winconf nil)
1913 (defvar gnus-summary-mark-positions nil)
1914 (defvar gnus-group-mark-positions nil)
1916 (defvar gnus-reffed-article-number nil)
1918 ;;; Let the byte-compiler know that we know about this variable.
1919 (defvar rmail-default-rmail-file)
1921 (defvar gnus-cache-removable-articles nil)
1923 (defvar gnus-dead-summary nil)
1925 (defconst gnus-summary-local-variables
1926 '(gnus-newsgroup-name
1927 gnus-newsgroup-begin gnus-newsgroup-end
1928 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1929 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1930 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1931 gnus-newsgroup-unselected gnus-newsgroup-marked
1932 gnus-newsgroup-reads gnus-newsgroup-saved
1933 gnus-newsgroup-replied gnus-newsgroup-expirable
1934 gnus-newsgroup-processable gnus-newsgroup-killed
1935 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1936 gnus-newsgroup-headers gnus-newsgroup-threads
1937 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1938 gnus-current-article gnus-current-headers gnus-have-all-headers
1939 gnus-last-article gnus-article-internal-prepare-hook
1940 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1941 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1942 gnus-newsgroup-async gnus-thread-expunge-below
1943 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1944 (gnus-summary-mark-below . global)
1945 gnus-newsgroup-active gnus-scores-exclude-files
1946 gnus-newsgroup-history gnus-newsgroup-ancient
1947 gnus-newsgroup-sparse
1948 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1949 gnus-newsgroup-adaptive-score-file
1950 (gnus-newsgroup-expunged-tally . 0)
1951 gnus-cache-removable-articles gnus-newsgroup-cached
1952 gnus-newsgroup-data gnus-newsgroup-data-reverse
1953 gnus-newsgroup-limit gnus-newsgroup-limits)
1954 "Variables that are buffer-local to the summary buffers.")
1956 (defconst gnus-bug-message
1957 "Sending a bug report to the Gnus Towers.
1958 ========================================
1960 The buffer below is a mail buffer. When you press `C-c C-c', it will
1961 be sent to the Gnus Bug Exterminators.
1963 At the bottom of the buffer you'll see lots of variable settings.
1964 Please do not delete those. They will tell the Bug People what your
1965 environment is, so that it will be easier to locate the bugs.
1967 If you have found a bug that makes Emacs go \"beep\", set
1968 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
1969 and include the backtrace in your bug report.
1971 Please describe the bug in annoying, painstaking detail.
1973 Thank you for your help in stamping out bugs.
1976 ;;; End of variables.
1978 ;; Define some autoload functions Gnus might use.
1981 ;; This little mapcar goes through the list below and marks the
1982 ;; symbols in question as autoloaded functions.
1985 (let ((interactive (nth 1 (memq ':interactive package))))
1989 (when (consp function)
1990 (setq keymap (car (memq 'keymap function)))
1991 (setq function (car function)))
1992 (autoload function (car package) nil interactive keymap)))
1993 (if (eq (nth 1 package) ':interactive)
1996 '(("metamail" metamail-buffer)
1997 ("info" Info-goto-node)
1998 ("hexl" hexl-hex-string-to-integer)
1999 ("pp" pp pp-to-string pp-eval-expression)
2000 ("mail-extr" mail-extract-address-components)
2001 ("nnmail" nnmail-split-fancy nnmail-article-group)
2002 ("nnvirtual" nnvirtual-catchup-group)
2003 ("timezone" timezone-make-date-arpa-standard timezone-fix-time
2004 timezone-make-sortable-date timezone-make-time-string)
2005 ("rmailout" rmail-output)
2006 ("rmail" rmail-insert-rmail-file-header rmail-count-new-messages
2008 ("gnus-soup" :interactive t
2009 gnus-group-brew-soup gnus-brew-soup gnus-soup-add-article
2010 gnus-soup-send-replies gnus-soup-save-areas gnus-soup-pack-packet)
2011 ("nnsoup" nnsoup-pack-replies)
2012 ("gnus-scomo" :interactive t gnus-score-mode)
2013 ("gnus-mh" gnus-mh-mail-setup gnus-summary-save-article-folder
2014 gnus-Folder-save-name gnus-folder-save-name)
2015 ("gnus-mh" :interactive t gnus-summary-save-in-folder)
2016 ("gnus-vis" gnus-group-make-menu-bar gnus-summary-make-menu-bar
2017 gnus-server-make-menu-bar gnus-article-make-menu-bar
2018 gnus-browse-make-menu-bar gnus-highlight-selected-summary
2019 gnus-summary-highlight-line gnus-carpal-setup-buffer
2020 gnus-group-highlight-line
2021 gnus-article-add-button gnus-insert-next-page-button
2022 gnus-insert-prev-page-button gnus-visual-turn-off-edit-menu)
2023 ("gnus-vis" :interactive t
2024 gnus-article-push-button gnus-article-press-button
2025 gnus-article-highlight gnus-article-highlight-some
2026 gnus-article-highlight-headers gnus-article-highlight-signature
2027 gnus-article-add-buttons gnus-article-add-buttons-to-head
2028 gnus-article-next-button gnus-article-prev-button)
2029 ("gnus-demon" gnus-demon-add-nocem gnus-demon-add-scanmail
2030 gnus-demon-add-disconnection gnus-demon-add-handler
2031 gnus-demon-remove-handler)
2032 ("gnus-demon" :interactive t
2033 gnus-demon-init gnus-demon-cancel)
2034 ("gnus-salt" gnus-highlight-selected-tree gnus-possibly-generate-tree
2035 gnus-tree-open gnus-tree-close)
2036 ("gnus-nocem" gnus-nocem-scan-groups gnus-nocem-close
2037 gnus-nocem-unwanted-article-p)
2038 ("gnus-srvr" gnus-enter-server-buffer gnus-server-set-info)
2039 ("gnus-srvr" gnus-browse-foreign-server)
2040 ("gnus-cite" :interactive t
2041 gnus-article-highlight-citation gnus-article-hide-citation-maybe
2042 gnus-article-hide-citation gnus-article-fill-cited-article
2043 gnus-article-hide-citation-in-followups)
2044 ("gnus-kill" gnus-kill gnus-apply-kill-file-internal
2045 gnus-kill-file-edit-file gnus-kill-file-raise-followups-to-author
2046 gnus-execute gnus-expunge)
2047 ("gnus-cache" gnus-cache-possibly-enter-article gnus-cache-save-buffers
2048 gnus-cache-possibly-remove-articles gnus-cache-request-article
2049 gnus-cache-retrieve-headers gnus-cache-possibly-alter-active
2050 gnus-cache-enter-remove-article gnus-cached-article-p
2051 gnus-cache-open gnus-cache-close gnus-cache-update-article)
2052 ("gnus-cache" :interactive t gnus-jog-cache gnus-cache-enter-article
2053 gnus-cache-remove-article)
2054 ("gnus-score" :interactive t
2055 gnus-summary-increase-score gnus-summary-lower-score
2056 gnus-score-flush-cache gnus-score-close
2057 gnus-score-raise-same-subject-and-select
2058 gnus-score-raise-same-subject gnus-score-default
2059 gnus-score-raise-thread gnus-score-lower-same-subject-and-select
2060 gnus-score-lower-same-subject gnus-score-lower-thread
2061 gnus-possibly-score-headers gnus-summary-raise-score
2062 gnus-summary-set-score gnus-summary-current-score)
2064 (gnus-summary-score-map keymap) gnus-score-save gnus-score-headers
2065 gnus-current-score-file-nondirectory gnus-score-adaptive
2066 gnus-score-find-trace gnus-score-file-name)
2067 ("gnus-edit" :interactive t gnus-score-customize)
2068 ("gnus-topic" :interactive t gnus-topic-mode)
2069 ("gnus-topic" gnus-topic-remove-group)
2070 ("gnus-salt" :interactive t gnus-pick-mode gnus-binary-mode)
2071 ("gnus-uu" (gnus-uu-extract-map keymap) (gnus-uu-mark-map keymap))
2072 ("gnus-uu" :interactive t
2073 gnus-uu-digest-mail-forward gnus-uu-digest-post-forward
2074 gnus-uu-mark-series gnus-uu-mark-region gnus-uu-mark-buffer
2075 gnus-uu-mark-by-regexp gnus-uu-mark-all
2076 gnus-uu-mark-sparse gnus-uu-mark-thread gnus-uu-decode-uu
2077 gnus-uu-decode-uu-and-save gnus-uu-decode-unshar
2078 gnus-uu-decode-unshar-and-save gnus-uu-decode-save
2079 gnus-uu-decode-binhex gnus-uu-decode-uu-view
2080 gnus-uu-decode-uu-and-save-view gnus-uu-decode-unshar-view
2081 gnus-uu-decode-unshar-and-save-view gnus-uu-decode-save-view
2082 gnus-uu-decode-binhex-view)
2083 ("gnus-msg" (gnus-summary-send-map keymap)
2084 gnus-mail-yank-original gnus-mail-send-and-exit
2085 gnus-article-mail gnus-new-mail gnus-mail-reply)
2086 ("gnus-msg" :interactive t
2087 gnus-group-post-news gnus-group-mail gnus-summary-post-news
2088 gnus-summary-followup gnus-summary-followup-with-original
2089 gnus-summary-cancel-article gnus-summary-supersede-article
2090 gnus-post-news gnus-inews-news
2091 gnus-summary-reply gnus-summary-reply-with-original
2092 gnus-summary-mail-forward gnus-summary-mail-other-window
2094 ("gnus-picon" :interactive t gnus-article-display-picons
2095 gnus-group-display-picons gnus-picons-article-display-x-face)
2096 ("gnus-gl" bbb-login bbb-logout bbb-grouplens-group-p
2097 gnus-grouplens-mode)
2098 ("gnus-vm" gnus-vm-mail-setup)
2099 ("gnus-vm" :interactive t gnus-summary-save-in-vm
2100 gnus-summary-save-article-vm))))
2104 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2105 ;; If you want the cursor to go somewhere else, set these two
2106 ;; functions in some startup hook to whatever you want.
2107 (defalias 'gnus-summary-position-point 'gnus-goto-colon)
2108 (defalias 'gnus-group-position-point 'gnus-goto-colon)
2110 ;;; Various macros and substs.
2112 (defun gnus-header-from (header)
2113 (mail-header-from header))
2115 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
2116 "Pop to BUFFER, evaluate FORMS, and then return to the original window."
2117 (let ((tempvar (make-symbol "GnusStartBufferWindow"))
2118 (w (make-symbol "w"))
2119 (buf (make-symbol "buf")))
2120 `(let* ((,tempvar (selected-window))
2122 (,w (get-buffer-window ,buf 'visible)))
2127 (pop-to-buffer ,buf))
2129 (select-window ,tempvar)))))
2131 (put 'gnus-eval-in-buffer-window 'lisp-indent-function 1)
2132 (put 'gnus-eval-in-buffer-window 'lisp-indent-hook 1)
2133 (put 'gnus-eval-in-buffer-window 'edebug-form-spec '(form body))
2135 (defmacro gnus-gethash (string hashtable)
2136 "Get hash value of STRING in HASHTABLE."
2137 `(symbol-value (intern-soft ,string ,hashtable)))
2139 (defmacro gnus-sethash (string value hashtable)
2140 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2141 `(set (intern ,string ,hashtable) ,value))
2143 (defmacro gnus-intern-safe (string hashtable)
2144 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2145 `(let ((symbol (intern ,string ,hashtable)))
2150 (defmacro gnus-group-unread (group)
2151 "Get the currently computed number of unread articles in GROUP."
2152 `(car (gnus-gethash ,group gnus-newsrc-hashtb)))
2154 (defmacro gnus-group-entry (group)
2155 "Get the newsrc entry for GROUP."
2156 `(gnus-gethash ,group gnus-newsrc-hashtb))
2158 (defmacro gnus-active (group)
2159 "Get active info on GROUP."
2160 `(gnus-gethash ,group gnus-active-hashtb))
2162 (defmacro gnus-set-active (group active)
2163 "Set GROUP's active info."
2164 `(gnus-sethash ,group ,active gnus-active-hashtb))
2166 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2167 ;; function `substring' might cut on a middle of multi-octet
2169 (defun gnus-truncate-string (str width)
2170 (substring str 0 width))
2172 ;; Added by Geoffrey T. Dairiki <dairiki@u.washington.edu>. A safe way
2173 ;; to limit the length of a string. This function is necessary since
2174 ;; `(substr "abc" 0 30)' pukes with "Args out of range".
2175 (defsubst gnus-limit-string (str width)
2176 (if (> (length str) width)
2177 (substring str 0 width)
2180 (defsubst gnus-simplify-subject-re (subject)
2181 "Remove \"Re:\" from subject lines."
2182 (if (string-match "^[Rr][Ee]: *" subject)
2183 (substring subject (match-end 0))
2186 (defsubst gnus-functionp (form)
2187 "Return non-nil if FORM is funcallable."
2188 (or (and (symbolp form) (fboundp form))
2189 (and (listp form) (eq (car form) 'lambda))))
2191 (defsubst gnus-goto-char (point)
2192 (and point (goto-char point)))
2194 (defmacro gnus-buffer-exists-p (buffer)
2195 `(let ((buffer ,buffer))
2197 (funcall (if (stringp buffer) 'get-buffer 'buffer-name)
2200 (defmacro gnus-kill-buffer (buffer)
2201 `(let ((buf ,buffer))
2202 (if (gnus-buffer-exists-p buf)
2203 (kill-buffer buf))))
2205 (defsubst gnus-point-at-bol ()
2206 "Return point at the beginning of the line."
2213 (defsubst gnus-point-at-eol ()
2214 "Return point at the end of the line."
2221 (defun gnus-alive-p ()
2222 "Say whether Gnus is running or not."
2223 (and gnus-group-buffer
2224 (get-buffer gnus-group-buffer)))
2226 (defun gnus-delete-first (elt list)
2227 "Delete by side effect the first occurrence of ELT as a member of LIST."
2228 (if (equal (car list) elt)
2231 (while (and (cdr list)
2232 (not (equal (cadr list) elt)))
2233 (setq list (cdr list)))
2235 (setcdr list (cddr list)))
2238 ;; Delete the current line (and the next N lines.);
2239 (defmacro gnus-delete-line (&optional n)
2240 `(delete-region (progn (beginning-of-line) (point))
2241 (progn (forward-line ,(or n 1)) (point))))
2243 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
2244 (defvar gnus-init-inhibit nil)
2245 (defun gnus-read-init-file (&optional inhibit-next)
2246 (if gnus-init-inhibit
2247 (setq gnus-init-inhibit nil)
2248 (setq gnus-init-inhibit inhibit-next)
2250 (or (and (file-exists-p gnus-init-file)
2251 ;; Don't try to load a directory.
2252 (not (file-directory-p gnus-init-file)))
2253 (file-exists-p (concat gnus-init-file ".el"))
2254 (file-exists-p (concat gnus-init-file ".elc")))
2256 (load gnus-init-file nil t)
2258 (error "Error in %s: %s" gnus-init-file var))))))
2260 ;; Info access macros.
2262 (defmacro gnus-info-group (info)
2264 (defmacro gnus-info-rank (info)
2266 (defmacro gnus-info-read (info)
2268 (defmacro gnus-info-marks (info)
2270 (defmacro gnus-info-method (info)
2272 (defmacro gnus-info-params (info)
2275 (defmacro gnus-info-level (info)
2276 `(let ((rank (gnus-info-rank ,info)))
2280 (defmacro gnus-info-score (info)
2281 `(let ((rank (gnus-info-rank ,info)))
2282 (or (and (consp rank) (cdr rank)) 0)))
2284 (defmacro gnus-info-set-group (info group)
2285 `(setcar ,info ,group))
2286 (defmacro gnus-info-set-rank (info rank)
2287 `(setcar (nthcdr 1 ,info) ,rank))
2288 (defmacro gnus-info-set-read (info read)
2289 `(setcar (nthcdr 2 ,info) ,read))
2290 (defmacro gnus-info-set-marks (info marks)
2291 `(setcar (nthcdr 3 ,info) ,marks))
2292 (defmacro gnus-info-set-method (info method)
2293 `(setcar (nthcdr 4 ,info) ,method))
2294 (defmacro gnus-info-set-params (info params)
2295 `(setcar (nthcdr 5 ,info) ,params))
2297 (defmacro gnus-info-set-level (info level)
2298 `(let ((rank (cdr ,info)))
2299 (if (consp (car rank))
2300 (setcar (car rank) ,level)
2301 (setcar rank ,level))))
2302 (defmacro gnus-info-set-score (info score)
2303 `(let ((rank (cdr ,info)))
2304 (if (consp (car rank))
2305 (setcdr (car rank) ,score)
2306 (setcar rank (cons (car rank) ,score)))))
2308 (defmacro gnus-get-info (group)
2309 `(nth 2 (gnus-gethash ,group gnus-newsrc-hashtb)))
2311 (defun gnus-byte-code (func)
2312 "Return a form that can be `eval'ed based on FUNC."
2313 (let ((fval (symbol-function func)))
2314 (if (byte-code-function-p fval)
2315 (let ((flist (append fval nil)))
2316 (setcar flist 'byte-code)
2318 (cons 'progn (cddr fval)))))
2320 ;; Find out whether the gnus-visual TYPE is wanted.
2321 (defun gnus-visual-p (&optional type class)
2322 (and gnus-visual ; Has to be non-nil, at least.
2323 (if (not type) ; We don't care about type.
2325 (if (listp gnus-visual) ; It's a list, so we check it.
2326 (or (memq type gnus-visual)
2327 (memq class gnus-visual))
2330 ;;; Load the compatability functions.
2340 (defvar gnus-shutdown-alist nil)
2342 (defun gnus-add-shutdown (function &rest symbols)
2343 "Run FUNCTION whenever one of SYMBOLS is shut down."
2344 (push (cons function symbols) gnus-shutdown-alist))
2346 (defun gnus-shutdown (symbol)
2347 "Shut down everything that waits for SYMBOL."
2348 (let ((alist gnus-shutdown-alist)
2350 (while (setq entry (pop alist))
2351 (when (memq symbol (cdr entry))
2352 (funcall (car entry))))))
2356 ;; Format specs. The chunks below are the machine-generated forms
2357 ;; that are to be evaled as the result of the default format strings.
2358 ;; We write them in here to get them byte-compiled. That way the
2359 ;; default actions will be quite fast, while still retaining the full
2360 ;; flexibility of the user-defined format specs.
2362 ;; First we have lots of dummy defvars to let the compiler know these
2363 ;; are really dynamic variables.
2365 (defvar gnus-tmp-unread)
2366 (defvar gnus-tmp-replied)
2367 (defvar gnus-tmp-score-char)
2368 (defvar gnus-tmp-indentation)
2369 (defvar gnus-tmp-opening-bracket)
2370 (defvar gnus-tmp-lines)
2371 (defvar gnus-tmp-name)
2372 (defvar gnus-tmp-closing-bracket)
2373 (defvar gnus-tmp-subject-or-nil)
2374 (defvar gnus-tmp-subject)
2375 (defvar gnus-tmp-marked)
2376 (defvar gnus-tmp-marked-mark)
2377 (defvar gnus-tmp-subscribed)
2378 (defvar gnus-tmp-process-marked)
2379 (defvar gnus-tmp-number-of-unread)
2380 (defvar gnus-tmp-group-name)
2381 (defvar gnus-tmp-group)
2382 (defvar gnus-tmp-article-number)
2383 (defvar gnus-tmp-unread-and-unselected)
2384 (defvar gnus-tmp-news-method)
2385 (defvar gnus-tmp-news-server)
2386 (defvar gnus-tmp-article-number)
2387 (defvar gnus-mouse-face)
2388 (defvar gnus-mouse-face-prop)
2390 (defun gnus-summary-line-format-spec ()
2391 (insert gnus-tmp-unread gnus-tmp-replied
2392 gnus-tmp-score-char gnus-tmp-indentation)
2393 (gnus-put-text-property
2397 gnus-tmp-opening-bracket
2398 (format "%4d: %-20s"
2400 (if (> (length gnus-tmp-name) 20)
2401 (substring gnus-tmp-name 0 20)
2403 gnus-tmp-closing-bracket)
2405 gnus-mouse-face-prop gnus-mouse-face)
2406 (insert " " gnus-tmp-subject-or-nil "\n"))
2408 (defvar gnus-summary-line-format-spec
2409 (gnus-byte-code 'gnus-summary-line-format-spec))
2411 (defun gnus-summary-dummy-line-format-spec ()
2413 (gnus-put-text-property
2418 gnus-mouse-face-prop gnus-mouse-face)
2419 (insert " " gnus-tmp-subject "\n"))
2421 (defvar gnus-summary-dummy-line-format-spec
2422 (gnus-byte-code 'gnus-summary-dummy-line-format-spec))
2424 (defun gnus-group-line-format-spec ()
2425 (insert gnus-tmp-marked-mark gnus-tmp-subscribed
2426 gnus-tmp-process-marked
2427 gnus-group-indentation
2428 (format "%5s: " gnus-tmp-number-of-unread))
2429 (gnus-put-text-property
2432 (insert gnus-tmp-group "\n")
2434 gnus-mouse-face-prop gnus-mouse-face))
2435 (defvar gnus-group-line-format-spec
2436 (gnus-byte-code 'gnus-group-line-format-spec))
2438 (defvar gnus-format-specs
2439 `((version . ,emacs-version)
2440 (group ,gnus-group-line-format ,gnus-group-line-format-spec)
2441 (summary-dummy ,gnus-summary-dummy-line-format
2442 ,gnus-summary-dummy-line-format-spec)
2443 (summary ,gnus-summary-line-format ,gnus-summary-line-format-spec)))
2445 (defvar gnus-article-mode-line-format-spec nil)
2446 (defvar gnus-summary-mode-line-format-spec nil)
2447 (defvar gnus-group-mode-line-format-spec nil)
2449 ;;; Phew. All that gruft is over, fortunately.
2453 ;;; Gnus Utility Functions
2456 (defun gnus-extract-address-components (from)
2458 ;; First find the address - the thing with the @ in it. This may
2459 ;; not be accurate in mail addresses, but does the trick most of
2460 ;; the time in news messages.
2461 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
2462 (setq address (substring from (match-beginning 0) (match-end 0))))
2463 ;; Then we check whether the "name <address>" format is used.
2465 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2466 ;; Linear white space is not required.
2467 (string-match (concat "[ \t]*<" (regexp-quote address) ">") from)
2468 (and (setq name (substring from 0 (match-beginning 0)))
2469 ;; Strip any quotes from the name.
2470 (string-match "\".*\"" name)
2471 (setq name (substring name 1 (1- (match-end 0))))))
2472 ;; If not, then "address (name)" is used.
2474 (and (string-match "(.+)" from)
2475 (setq name (substring from (1+ (match-beginning 0))
2476 (1- (match-end 0)))))
2477 (and (string-match "()" from)
2478 (setq name address))
2479 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>.
2480 ;; XOVER might not support folded From headers.
2481 (and (string-match "(.*" from)
2482 (setq name (substring from (1+ (match-beginning 0))
2484 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2485 (list (or name from) (or address from))))
2487 (defun gnus-fetch-field (field)
2488 "Return the value of the header FIELD of current article."
2491 (let ((case-fold-search t)
2492 (inhibit-point-motion-hooks t))
2493 (nnheader-narrow-to-headers)
2494 (message-fetch-field field)))))
2496 (defun gnus-goto-colon ()
2498 (search-forward ":" (gnus-point-at-eol) t))
2501 (defun gnus-update-format (var)
2502 "Update the format specification near point."
2507 ;; Find the end of the current word.
2508 (re-search-forward "[ \t\n]" nil t)
2510 (when (re-search-backward "\\(gnus-[-a-z]+-line-format\\)" nil t)
2511 (match-string 1)))))
2512 (let* ((type (intern (progn (string-match "gnus-\\([-a-z]+\\)-line" var)
2513 (match-string 1 var))))
2514 (entry (assq type gnus-format-specs))
2517 (setq gnus-format-specs (delq entry gnus-format-specs)))
2519 (intern (format "%s-spec" var))
2520 (gnus-parse-format (setq value (symbol-value (intern var)))
2521 (symbol-value (intern (format "%s-alist" var)))
2522 (not (string-match "mode" var))))
2523 (setq spec (symbol-value (intern (format "%s-spec" var))))
2524 (push (list type value spec) gnus-format-specs)
2526 (pop-to-buffer "*Gnus Format*")
2528 (lisp-interaction-mode)
2529 (insert (pp-to-string spec))))
2531 (defun gnus-update-format-specifications (&optional force)
2532 "Update all (necessary) format specifications."
2533 ;; Make the indentation array.
2534 (gnus-make-thread-indent-array)
2536 ;; See whether all the stored info needs to be flushed.
2538 (not (equal emacs-version
2539 (cdr (assq 'version gnus-format-specs)))))
2540 (setq gnus-format-specs nil))
2542 ;; Go through all the formats and see whether they need updating.
2543 (let ((types '(summary summary-dummy group
2544 summary-mode group-mode article-mode))
2545 new-format entry type val)
2546 (while (setq type (pop types))
2547 ;; Jump to the proper buffer to find out the value of
2548 ;; the variable, if possible. (It may be buffer-local.)
2550 (let ((buffer (intern (format "gnus-%s-buffer" type)))
2552 (when (and (boundp buffer)
2553 (setq val (symbol-value buffer))
2555 (buffer-name (get-buffer val)))
2556 (set-buffer (get-buffer val)))
2557 (setq new-format (symbol-value
2558 (intern (format "gnus-%s-line-format" type))))))
2559 (setq entry (cdr (assq type gnus-format-specs)))
2561 (equal (car entry) new-format))
2562 ;; Use the old format.
2563 (set (intern (format "gnus-%s-line-format-spec" type))
2565 ;; This is a new format.
2567 (if (not (stringp new-format))
2568 ;; This is a function call or something.
2570 ;; This is a "real" format.
2574 (intern (format "gnus-%s-line-format-alist"
2575 (if (eq type 'article-mode)
2576 'summary-mode type))))
2577 (not (string-match "mode$" (symbol-name type))))))
2578 ;; Enter the new format spec into the list.
2581 (setcar (cdr entry) val)
2582 (setcar entry new-format))
2583 (push (list type new-format val) gnus-format-specs))
2584 (set (intern (format "gnus-%s-line-format-spec" type)) val))))
2586 (unless (assq 'version gnus-format-specs)
2587 (push (cons 'version emacs-version) gnus-format-specs))
2589 (gnus-update-group-mark-positions)
2590 (gnus-update-summary-mark-positions))
2592 (defun gnus-update-summary-mark-positions ()
2593 "Compute where the summary marks are to go."
2595 (when (and gnus-summary-buffer
2596 (get-buffer gnus-summary-buffer)
2597 (buffer-name (get-buffer gnus-summary-buffer)))
2598 (set-buffer gnus-summary-buffer))
2599 (let ((gnus-replied-mark 129)
2600 (gnus-score-below-mark 130)
2601 (gnus-score-over-mark 130)
2604 (spec gnus-summary-line-format-spec)
2607 (gnus-set-work-buffer)
2608 (let ((gnus-summary-line-format-spec spec))
2609 (gnus-summary-insert-line
2610 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2611 (goto-char (point-min))
2612 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2614 (goto-char (point-min))
2615 (push (cons 'replied (and (search-forward "\201" nil t)
2618 (goto-char (point-min))
2619 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2621 (setq gnus-summary-mark-positions pos))))
2623 (defun gnus-update-group-mark-positions ()
2625 (let ((gnus-process-mark 128)
2626 (gnus-group-marked '("dummy.group"))
2627 (gnus-active-hashtb (make-vector 10 0)))
2628 (gnus-set-active "dummy.group" '(0 . 0))
2629 (gnus-set-work-buffer)
2630 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
2631 (goto-char (point-min))
2632 (setq gnus-group-mark-positions
2633 (list (cons 'process (and (search-forward "\200" nil t)
2634 (- (point) 2))))))))
2636 (defvar gnus-mouse-face-0 'highlight)
2637 (defvar gnus-mouse-face-1 'highlight)
2638 (defvar gnus-mouse-face-2 'highlight)
2639 (defvar gnus-mouse-face-3 'highlight)
2640 (defvar gnus-mouse-face-4 'highlight)
2642 (defun gnus-mouse-face-function (form type)
2643 `(gnus-put-text-property
2644 (point) (progn ,@form (point))
2645 gnus-mouse-face-prop
2648 `(quote ,(symbol-value (intern (format "gnus-mouse-face-%d" type)))))))
2650 (defvar gnus-face-0 'bold)
2651 (defvar gnus-face-1 'italic)
2652 (defvar gnus-face-2 'bold-italic)
2653 (defvar gnus-face-3 'bold)
2654 (defvar gnus-face-4 'bold)
2656 (defun gnus-face-face-function (form type)
2657 `(gnus-put-text-property
2658 (point) (progn ,@form (point))
2659 'face ',(symbol-value (intern (format "gnus-face-%d" type)))))
2661 (defun gnus-max-width-function (el max-width)
2662 (or (numberp max-width) (signal 'wrong-type-argument '(numberp max-width)))
2664 `(if (> (length ,el) ,max-width)
2665 (substring ,el 0 ,max-width)
2667 `(let ((val (eval ,el)))
2669 (setq val (int-to-string val)))
2670 (if (> (length val) ,max-width)
2671 (substring val 0 ,max-width)
2674 (defun gnus-parse-format (format spec-alist &optional insert)
2675 ;; This function parses the FORMAT string with the help of the
2676 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
2677 ;; string. If the FORMAT string contains the specifiers %( and %)
2678 ;; the text between them will have the mouse-face text property.
2680 "\\`\\(.*\\)%[0-9]?[{(]\\(.*\\)%[0-9]?[})]\\(.*\n?\\)\\'"
2682 (gnus-parse-complex-format format spec-alist)
2683 ;; This is a simple format.
2684 (gnus-parse-simple-format format spec-alist insert)))
2686 (defun gnus-parse-complex-format (format spec-alist)
2688 (gnus-set-work-buffer)
2690 (goto-char (point-min))
2691 (while (re-search-forward "\"" nil t)
2692 (replace-match "\\\"" nil t))
2693 (goto-char (point-min))
2695 (while (re-search-forward "%\\([0-9]+\\)?\\([{}()]\\)" nil t)
2696 (let ((number (if (match-beginning 1)
2697 (match-string 1) "0"))
2698 (delim (aref (match-string 2) 0)))
2699 (if (or (= delim ?\() (= delim ?\{))
2700 (replace-match (concat "\"(" (if (= delim ?\() "mouse" "face")
2702 (replace-match "\")\""))))
2703 (goto-char (point-max))
2705 (goto-char (point-min))
2706 (let ((form (read (current-buffer))))
2707 (cons 'progn (gnus-complex-form-to-spec form spec-alist)))))
2709 (defun gnus-complex-form-to-spec (form spec-alist)
2714 (gnus-parse-simple-format sform spec-alist t)
2715 (funcall (intern (format "gnus-%s-face-function" (car sform)))
2716 (gnus-complex-form-to-spec (cddr sform) spec-alist)
2720 (defun gnus-parse-simple-format (format spec-alist &optional insert)
2721 ;; This function parses the FORMAT string with the help of the
2722 ;; SPEC-ALIST and returns a list that can be eval'ed to return a
2725 spec flist fstring newspec elem beg result dontinsert)
2727 (gnus-set-work-buffer)
2729 (goto-char (point-min))
2730 (while (re-search-forward "%[-0-9]*\\(,[0-9]+\\)?\\([^0-9]\\)\\(.\\)?"
2732 (if (= (setq spec (string-to-char (match-string 2))) ?%)
2734 beg (1+ (match-beginning 0)))
2735 ;; First check if there are any specs that look anything like
2736 ;; "%12,12A", ie. with a "max width specification". These have
2737 ;; to be treated specially.
2738 (if (setq beg (match-beginning 1))
2742 (1+ (match-beginning 1)) (match-end 1))))
2744 (setq beg (match-beginning 2)))
2745 ;; Find the specification from `spec-alist'.
2746 (unless (setq elem (cdr (assq spec spec-alist)))
2747 (setq elem '("*" ?s)))
2748 ;; Treat user defined format specifiers specially.
2749 (when (eq (car elem) 'gnus-tmp-user-defined)
2752 (list (intern (concat "gnus-user-format-function-"
2754 'gnus-tmp-header) ?s))
2755 (delete-region (match-beginning 3) (match-end 3)))
2756 (if (not (zerop max-width))
2757 (let ((el (car elem)))
2758 (cond ((= (cadr elem) ?c)
2759 (setq el (list 'char-to-string el)))
2761 (setq el (list 'int-to-string el))))
2762 (setq flist (cons (gnus-max-width-function el max-width)
2766 (setq flist (cons (car elem) flist))
2767 (setq newspec (cadr elem)))))
2768 ;; Remove the old specification (and possibly a ",12" string).
2769 (delete-region beg (match-end 2))
2770 ;; Insert the new specification.
2773 (setq fstring (buffer-substring 1 (point-max))))
2774 ;; Do some postprocessing to increase efficiency.
2779 ((string= fstring "")
2781 ;; Not a format string.
2782 ((not (string-match "%" fstring))
2784 ;; A format string with just a single string spec.
2785 ((string= fstring "%s")
2787 ;; A single character.
2788 ((string= fstring "%c")
2791 ((string= fstring "%d")
2794 (list `(princ ,(car flist)))
2795 (list `(int-to-string ,(car flist)))))
2796 ;; Just lots of chars and strings.
2797 ((string-match "\\`\\(%[cs]\\)+\\'" fstring)
2799 ;; A single string spec at the beginning of the spec.
2800 ((string-match "\\`%[sc][^%]+\\'" fstring)
2801 (list (car flist) (substring fstring 2)))
2802 ;; A single string spec in the middle of the spec.
2803 ((string-match "\\`\\([^%]+\\)%[sc]\\([^%]+\\)\\'" fstring)
2804 (list (match-string 1 fstring) (car flist) (match-string 2 fstring)))
2805 ;; A single string spec in the end of the spec.
2806 ((string-match "\\`\\([^%]+\\)%[sc]\\'" fstring)
2807 (list (match-string 1 fstring) (car flist)))
2808 ;; A more complex spec.
2810 (list (cons 'format (cons fstring (nreverse flist)))))))
2816 (cons 'insert result)))
2817 (cond ((stringp result)
2820 (cons 'concat result))
2823 (defun gnus-eval-format (format &optional alist props)
2824 "Eval the format variable FORMAT, using ALIST.
2825 If PROPS, insert the result."
2826 (let ((form (gnus-parse-format format alist props)))
2828 (gnus-add-text-properties (point) (progn (eval form) (point)) props)
2831 (defun gnus-remove-text-with-property (prop)
2832 "Delete all text in the current buffer with text property PROP."
2834 (goto-char (point-min))
2836 (while (get-text-property (point) prop)
2838 (goto-char (next-single-property-change (point) prop nil (point-max))))))
2840 (defun gnus-set-work-buffer ()
2841 (if (get-buffer gnus-work-buffer)
2843 (set-buffer gnus-work-buffer)
2845 (set-buffer (get-buffer-create gnus-work-buffer))
2846 (kill-all-local-variables)
2847 (buffer-disable-undo (current-buffer))
2848 (gnus-add-current-to-buffer-list)))
2850 ;; Article file names when saving.
2852 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2853 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2854 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
2855 Otherwise, it is like ~/News/news/group/num."
2858 (concat (if (gnus-use-long-file-name 'not-save)
2859 (gnus-capitalize-newsgroup newsgroup)
2860 (gnus-newsgroup-directory-form newsgroup))
2861 "/" (int-to-string (mail-header-number headers)))
2862 gnus-article-save-directory)))
2864 (string-equal (file-name-directory default)
2865 (file-name-directory last-file))
2866 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2868 (or last-file default))))
2870 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2871 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2872 If variable `gnus-use-long-file-name' is non-nil, it is
2873 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2876 (concat (if (gnus-use-long-file-name 'not-save)
2878 (gnus-newsgroup-directory-form newsgroup))
2879 "/" (int-to-string (mail-header-number headers)))
2880 gnus-article-save-directory)))
2882 (string-equal (file-name-directory default)
2883 (file-name-directory last-file))
2884 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2886 (or last-file default))))
2888 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2889 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2890 If variable `gnus-use-long-file-name' is non-nil, it is
2891 ~/News/News.group. Otherwise, it is like ~/News/news/group/news."
2894 (if (gnus-use-long-file-name 'not-save)
2895 (gnus-capitalize-newsgroup newsgroup)
2896 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2897 gnus-article-save-directory)))
2899 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2900 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2901 If variable `gnus-use-long-file-name' is non-nil, it is
2902 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2905 (if (gnus-use-long-file-name 'not-save)
2907 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2908 gnus-article-save-directory)))
2910 ;; For subscribing new newsgroup
2912 (defun gnus-subscribe-hierarchical-interactive (groups)
2913 (let ((groups (sort groups 'string<))
2914 prefixes prefix start ans group starts)
2916 (setq prefixes (list "^"))
2917 (while (and groups prefixes)
2918 (while (not (string-match (car prefixes) (car groups)))
2919 (setq prefixes (cdr prefixes)))
2920 (setq prefix (car prefixes))
2921 (setq start (1- (length prefix)))
2922 (if (and (string-match "[^\\.]\\." (car groups) start)
2925 (concat "^" (substring (car groups) 0 (match-end 0))))
2926 (string-match prefix (cadr groups)))
2928 (setq prefixes (cons prefix prefixes))
2929 (message "Descend hierarchy %s? ([y]nsq): "
2930 (substring prefix 1 (1- (length prefix))))
2931 (while (not (memq (setq ans (read-char)) '(?y ?\n ?n ?s ?q)))
2933 (message "Descend hierarchy %s? ([y]nsq): "
2934 (substring prefix 1 (1- (length prefix)))))
2937 (string-match prefix
2938 (setq group (car groups))))
2939 (setq gnus-killed-list
2940 (cons group gnus-killed-list))
2941 (gnus-sethash group group gnus-killed-hashtb)
2942 (setq groups (cdr groups)))
2943 (setq starts (cdr starts)))
2946 (string-match prefix
2947 (setq group (car groups))))
2948 (gnus-sethash group group gnus-killed-hashtb)
2949 (gnus-subscribe-alphabetically (car groups))
2950 (setq groups (cdr groups)))
2951 (setq starts (cdr starts)))
2954 (setq group (car groups))
2955 (setq gnus-killed-list (cons group gnus-killed-list))
2956 (gnus-sethash group group gnus-killed-hashtb)
2957 (setq groups (cdr groups))))
2959 (message "Subscribe %s? ([n]yq)" (car groups))
2960 (while (not (memq (setq ans (read-char)) '(?y ?\n ?q ?n)))
2962 (message "Subscribe %s? ([n]yq)" (car groups)))
2963 (setq group (car groups))
2965 (gnus-subscribe-alphabetically (car groups))
2966 (gnus-sethash group group gnus-killed-hashtb))
2969 (setq group (car groups))
2970 (setq gnus-killed-list (cons group gnus-killed-list))
2971 (gnus-sethash group group gnus-killed-hashtb)
2972 (setq groups (cdr groups))))
2974 (setq gnus-killed-list (cons group gnus-killed-list))
2975 (gnus-sethash group group gnus-killed-hashtb)))
2976 (setq groups (cdr groups)))))))
2978 (defun gnus-subscribe-randomly (newsgroup)
2979 "Subscribe new NEWSGROUP by making it the first newsgroup."
2980 (gnus-subscribe-newsgroup newsgroup))
2982 (defun gnus-subscribe-alphabetically (newgroup)
2983 "Subscribe new NEWSGROUP and insert it in alphabetical order."
2984 (let ((groups (cdr gnus-newsrc-alist))
2986 (while (and (not before) groups)
2987 (if (string< newgroup (caar groups))
2988 (setq before (caar groups))
2989 (setq groups (cdr groups))))
2990 (gnus-subscribe-newsgroup newgroup before)))
2992 (defun gnus-subscribe-hierarchically (newgroup)
2993 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
2994 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2996 (set-buffer (find-file-noselect gnus-current-startup-file))
2997 (let ((groupkey newgroup)
2999 (while (and (not before) groupkey)
3000 (goto-char (point-min))
3002 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
3003 (while (and (re-search-forward groupkey-re nil t)
3005 (setq before (match-string 1))
3006 (string< before newgroup)))))
3007 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
3009 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
3010 (substring groupkey (match-beginning 1) (match-end 1)))))
3011 (gnus-subscribe-newsgroup newgroup before))))
3013 (defun gnus-subscribe-interactively (group)
3014 "Subscribe the new GROUP interactively.
3015 It is inserted in hierarchical newsgroup order if subscribed. If not,
3017 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " group))
3018 (gnus-subscribe-hierarchically group)
3019 (push group gnus-killed-list)))
3021 (defun gnus-subscribe-zombies (group)
3022 "Make the new GROUP into a zombie group."
3023 (push group gnus-zombie-list))
3025 (defun gnus-subscribe-killed (group)
3026 "Make the new GROUP a killed group."
3027 (push group gnus-killed-list))
3029 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
3030 "Subscribe new NEWSGROUP.
3031 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
3032 the first newsgroup."
3033 ;; We subscribe the group by changing its level to `subscribed'.
3034 (gnus-group-change-level
3035 newsgroup gnus-level-default-subscribed
3036 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
3037 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))
3041 (defun gnus-newsgroup-directory-form (newsgroup)
3042 "Make hierarchical directory name from NEWSGROUP name."
3043 (let ((newsgroup (gnus-newsgroup-savable-name newsgroup))
3044 (len (length newsgroup))
3046 ;; If this is a foreign group, we don't want to translate the
3048 (if (setq idx (string-match ":" newsgroup))
3049 (aset newsgroup idx ?/)
3051 ;; Replace all occurrences of `.' with `/'.
3053 (if (= (aref newsgroup idx) ?.)
3054 (aset newsgroup idx ?/))
3055 (setq idx (1+ idx)))
3058 (defun gnus-newsgroup-savable-name (group)
3059 ;; Replace any slashes in a group name (eg. an ange-ftp nndoc group)
3061 (nnheader-replace-chars-in-string group ?/ ?.))
3063 (defun gnus-make-directory (dir)
3064 "Make DIRECTORY recursively."
3065 ;; Why don't we use `(make-directory dir 'parents)'? That's just one
3066 ;; of the many mysteries of the universe.
3067 (let* ((dir (expand-file-name dir default-directory))
3069 (if (string-match "/$" dir)
3070 (setq dir (substring dir 0 (match-beginning 0))))
3071 ;; First go down the path until we find a directory that exists.
3072 (while (not (file-exists-p dir))
3073 (setq dirs (cons dir dirs))
3074 (string-match "/[^/]+$" dir)
3075 (setq dir (substring dir 0 (match-beginning 0))))
3076 ;; Then create all the subdirs.
3077 (while (and dirs (not err))
3079 (make-directory (car dirs))
3080 (error (setq err t)))
3081 (setq dirs (cdr dirs)))
3082 ;; We return whether we were successful or not.
3085 (defun gnus-capitalize-newsgroup (newsgroup)
3086 "Capitalize NEWSGROUP name."
3087 (and (not (zerop (length newsgroup)))
3088 (concat (char-to-string (upcase (aref newsgroup 0)))
3089 (substring newsgroup 1))))
3091 ;; Various... things.
3093 (defun gnus-simplify-subject (subject &optional re-only)
3094 "Remove `Re:' and words in parentheses.
3095 If RE-ONLY is non-nil, strip leading `Re:'s only."
3096 (let ((case-fold-search t)) ;Ignore case.
3097 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
3098 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
3099 (setq subject (substring subject (match-end 0))))
3100 ;; Remove uninteresting prefixes.
3101 (if (and (not re-only)
3102 gnus-simplify-ignored-prefixes
3103 (string-match gnus-simplify-ignored-prefixes subject))
3104 (setq subject (substring subject (match-end 0))))
3105 ;; Remove words in parentheses from end.
3107 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
3108 (setq subject (substring subject 0 (match-beginning 0)))))
3109 ;; Return subject string.
3112 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
3114 ;; Written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
3115 (defun gnus-simplify-buffer-fuzzy ()
3116 (let ((case-fold-search t))
3117 (goto-char (point-min))
3118 (while (search-forward "\t" nil t)
3119 (replace-match " " t t))
3120 (goto-char (point-min))
3121 (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *" nil t)
3122 (goto-char (match-beginning 0))
3124 (looking-at "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
3125 (looking-at "^[[].*: .*[]]$"))
3126 (goto-char (point-min))
3127 (while (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *"
3129 (replace-match "" t t))
3130 (goto-char (point-min))
3131 (while (re-search-forward "^[[].*: .*[]]$" nil t)
3132 (goto-char (match-end 0))
3135 (progn (goto-char (match-beginning 0)))
3136 (re-search-forward ":"))))
3137 (goto-char (point-min))
3138 (while (re-search-forward " *[[{(][^()\n]*[]})] *$" nil t)
3139 (replace-match "" t t))
3140 (goto-char (point-min))
3141 (while (re-search-forward " +" nil t)
3142 (replace-match " " t t))
3143 (goto-char (point-min))
3144 (while (re-search-forward " $" nil t)
3145 (replace-match "" t t))
3146 (goto-char (point-min))
3147 (while (re-search-forward "^ +" nil t)
3148 (replace-match "" t t))
3149 (goto-char (point-min))
3150 (when gnus-simplify-subject-fuzzy-regexp
3151 (if (listp gnus-simplify-subject-fuzzy-regexp)
3152 (let ((list gnus-simplify-subject-fuzzy-regexp))
3154 (goto-char (point-min))
3155 (while (re-search-forward (car list) nil t)
3156 (replace-match "" t t))
3157 (setq list (cdr list))))
3158 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
3159 (replace-match "" t t))))))
3161 (defun gnus-simplify-subject-fuzzy (subject)
3162 "Siplify a subject string fuzzily."
3164 (gnus-set-work-buffer)
3165 (let ((case-fold-search t))
3167 (inline (gnus-simplify-buffer-fuzzy))
3170 ;; Add the current buffer to the list of buffers to be killed on exit.
3171 (defun gnus-add-current-to-buffer-list ()
3172 (or (memq (current-buffer) gnus-buffer-list)
3173 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list))))
3175 (defun gnus-string> (s1 s2)
3176 (not (or (string< s1 s2)
3179 (defun gnus-read-active-file-p ()
3180 "Say whether the active file has been read from `gnus-select-method'."
3181 (memq gnus-select-method gnus-have-read-active-file))
3183 ;;; General various misc type functions.
3185 (defun gnus-clear-system ()
3186 "Clear all variables and buffers."
3187 ;; Clear Gnus variables.
3188 (let ((variables gnus-variable-list))
3190 (set (car variables) nil)
3191 (setq variables (cdr variables))))
3192 ;; Clear other internal variables.
3193 (setq gnus-list-of-killed-groups nil
3194 gnus-have-read-active-file nil
3195 gnus-newsrc-alist nil
3196 gnus-newsrc-hashtb nil
3197 gnus-killed-list nil
3198 gnus-zombie-list nil
3199 gnus-killed-hashtb nil
3200 gnus-active-hashtb nil
3201 gnus-moderated-list nil
3202 gnus-description-hashtb nil
3203 gnus-current-headers nil
3204 gnus-thread-indent-array nil
3205 gnus-newsgroup-headers nil
3206 gnus-newsgroup-name nil
3207 gnus-server-alist nil
3208 gnus-group-list-mode nil
3209 gnus-opened-servers nil
3210 gnus-current-select-method nil)
3211 (gnus-shutdown 'gnus)
3212 ;; Kill the startup file.
3213 (and gnus-current-startup-file
3214 (get-file-buffer gnus-current-startup-file)
3215 (kill-buffer (get-file-buffer gnus-current-startup-file)))
3216 ;; Clear the dribble buffer.
3217 (gnus-dribble-clear)
3218 ;; Kill global KILL file buffer.
3219 (when (get-file-buffer (gnus-newsgroup-kill-file nil))
3220 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
3221 (gnus-kill-buffer nntp-server-buffer)
3222 ;; Kill Gnus buffers.
3223 (while gnus-buffer-list
3224 (gnus-kill-buffer (pop gnus-buffer-list)))
3225 ;; Remove Gnus frames.
3226 (while gnus-created-frames
3227 (when (frame-live-p (car gnus-created-frames))
3228 ;; We slap a condition-case around this `delete-frame' to ensure
3229 ;; agains errors if we try do delete the single frame that's left.
3231 (delete-frame (car gnus-created-frames))
3233 (pop gnus-created-frames)))
3235 (defun gnus-windows-old-to-new (setting)
3236 ;; First we take care of the really, really old Gnus 3 actions.
3237 (when (symbolp setting)
3239 ;; Take care of ooold GNUS 3.x values.
3240 (cond ((eq setting 'SelectArticle) 'article)
3241 ((memq setting '(SelectSubject ExpandSubject)) 'summary)
3242 ((memq setting '(SelectNewsgroup ExitNewsgroup)) 'group)
3244 (if (or (listp setting)
3245 (not (and gnus-window-configuration
3246 (memq setting '(group summary article)))))
3248 (let* ((setting (if (eq setting 'group)
3249 (if (assq 'newsgroup gnus-window-configuration)
3251 'newsgroups) setting))
3252 (elem (cadr (assq setting gnus-window-configuration)))
3253 (total (apply '+ elem))
3254 (types '(group summary article))
3255 (pbuf (if (eq setting 'newsgroups) 'group 'summary))
3260 (or (not (numberp (nth i elem)))
3261 (zerop (nth i elem))
3263 (setq perc (/ (float (nth 0 elem)) total))
3264 (setq out (cons (if (eq pbuf (nth i types))
3265 (vector (nth i types) perc 'point)
3266 (vector (nth i types) perc))
3269 (list (nreverse out)))))
3272 (defun gnus-add-configuration (conf)
3273 "Add the window configuration CONF to `gnus-buffer-configuration'."
3274 (setq gnus-buffer-configuration
3275 (cons conf (delq (assq (car conf) gnus-buffer-configuration)
3276 gnus-buffer-configuration))))
3278 (defvar gnus-frame-list nil)
3280 (defun gnus-configure-frame (split &optional window)
3281 "Split WINDOW according to SPLIT."
3283 (setq window (get-buffer-window (current-buffer))))
3284 (select-window window)
3285 ;; This might be an old-stylee buffer config.
3286 (when (vectorp split)
3287 (setq split (append split nil)))
3288 (when (or (consp (car split))
3289 (vectorp (car split)))
3291 (push 'vertical split))
3292 ;; The SPLIT might be something that is to be evaled to
3293 ;; return a new SPLIT.
3294 (while (and (not (assq (car split) gnus-window-to-buffer))
3295 (gnus-functionp (car split)))
3296 (setq split (eval split)))
3297 (let* ((type (car split))
3299 (len (if (eq type 'horizontal) (window-width) (window-height)))
3301 (window-min-width (or gnus-window-min-width window-min-width))
3302 (window-min-height (or gnus-window-min-height window-min-height))
3303 s result new-win rest comp-subs size sub)
3305 ;; Nothing to do here.
3307 ;; Don't switch buffers.
3309 (and (memq 'point split) window))
3310 ;; This is a buffer to be selected.
3311 ((not (memq type '(frame horizontal vertical)))
3312 (let ((buffer (cond ((stringp type) type)
3313 (t (cdr (assq type gnus-window-to-buffer)))))
3316 (error "Illegal buffer type: %s" type))
3317 (unless (setq buf (get-buffer (if (symbolp buffer)
3318 (symbol-value buffer) buffer)))
3319 (setq buf (get-buffer-create (if (symbolp buffer)
3320 (symbol-value buffer) buffer))))
3321 (switch-to-buffer buf)
3322 ;; We return the window if it has the `point' spec.
3323 (and (memq 'point split) window)))
3324 ;; This is a frame split.
3326 (unless gnus-frame-list
3327 (setq gnus-frame-list (list (window-frame
3328 (get-buffer-window (current-buffer))))))
3330 params frame fresult)
3331 (while (< i (length subs))
3332 ;; Frame parameter is gotten from the sub-split.
3333 (setq params (cadr (elt subs i)))
3334 ;; It should be a list.
3335 (unless (listp params)
3337 ;; Create a new frame?
3338 (unless (setq frame (elt gnus-frame-list i))
3339 (nconc gnus-frame-list (list (setq frame (make-frame params))))
3340 (push frame gnus-created-frames))
3341 ;; Is the old frame still alive?
3342 (unless (frame-live-p frame)
3343 (setcar (nthcdr i gnus-frame-list)
3344 (setq frame (make-frame params))))
3345 ;; Select the frame in question and do more splits there.
3346 (select-frame frame)
3347 (setq fresult (or (gnus-configure-frame (elt subs i)) fresult))
3349 ;; Select the frame that has the selected buffer.
3351 (select-frame (window-frame fresult)))))
3352 ;; This is a normal split.
3354 (when (> (length subs) 0)
3355 ;; First we have to compute the sizes of all new windows.
3357 (setq sub (append (pop subs) nil))
3358 (while (and (not (assq (car sub) gnus-window-to-buffer))
3359 (gnus-functionp (car sub)))
3360 (setq sub (eval sub)))
3362 (push sub comp-subs)
3363 (setq size (cadar comp-subs))
3364 (cond ((equal size 1.0)
3365 (setq rest (car comp-subs))
3368 (setq s (floor (* size len))))
3372 (error "Illegal size: %s" size)))
3373 ;; Try to make sure that we are inside the safe limits.
3375 ((eq type 'horizontal)
3376 (setq s (max s window-min-width)))
3377 ((eq type 'vertical)
3378 (setq s (max s window-min-height))))
3379 (setcar (cdar comp-subs) s)
3381 ;; Take care of the "1.0" spec.
3383 (setcar (cdr rest) (- len total))
3384 (error "No 1.0 specs in %s" split))
3385 ;; The we do the actual splitting in a nice recursive
3387 (setq comp-subs (nreverse comp-subs))
3389 (if (null (cdr comp-subs))
3390 (setq new-win window)
3392 (split-window window (cadar comp-subs)
3393 (eq type 'horizontal))))
3394 (setq result (or (gnus-configure-frame
3395 (car comp-subs) window) result))
3396 (select-window new-win)
3397 (setq window new-win)
3398 (setq comp-subs (cdr comp-subs))))
3399 ;; Return the proper window, if any.
3401 (select-window result))))))
3403 (defvar gnus-frame-split-p nil)
3405 (defun gnus-configure-windows (setting &optional force)
3406 (setq setting (gnus-windows-old-to-new setting))
3407 (let ((split (if (symbolp setting)
3408 (cadr (assq setting gnus-buffer-configuration))
3412 (setq gnus-frame-split-p nil)
3415 (error "No such setting: %s" setting))
3417 (if (and (setq all-visible (gnus-all-windows-visible-p split))
3419 ;; All the windows mentioned are already visible, so we just
3420 ;; put point in the assigned buffer, and do not touch the
3422 (select-window all-visible)
3424 ;; Either remove all windows or just remove all Gnus windows.
3425 (let ((frame (selected-frame)))
3427 (if gnus-use-full-window
3428 ;; We want to remove all other windows.
3429 (if (not gnus-frame-split-p)
3430 ;; This is not a `frame' split, so we ignore the
3432 (delete-other-windows)
3433 ;; This is a `frame' split, so we delete all windows
3437 (unless (eq (cdr (assq 'minibuffer
3438 (frame-parameters frame)))
3440 (select-frame frame)
3441 (delete-other-windows)))
3443 ;; Just remove some windows.
3444 (gnus-remove-some-windows)
3445 (switch-to-buffer nntp-server-buffer))
3446 (select-frame frame)))
3448 (switch-to-buffer nntp-server-buffer)
3449 (gnus-configure-frame split (get-buffer-window (current-buffer))))))
3451 (defun gnus-all-windows-visible-p (split)
3452 "Say whether all buffers in SPLIT are currently visible.
3453 In particular, the value returned will be the window that
3455 (let ((stack (list split))
3457 type buffer win buf)
3458 (while (and (setq split (pop stack))
3460 ;; Be backwards compatible.
3461 (when (vectorp split)
3462 (setq split (append split nil)))
3463 (when (or (consp (car split))
3464 (vectorp (car split)))
3466 (push 'vertical split))
3467 ;; The SPLIT might be something that is to be evaled to
3468 ;; return a new SPLIT.
3469 (while (and (not (assq (car split) gnus-window-to-buffer))
3470 (gnus-functionp (car split)))
3471 (setq split (eval split)))
3473 (setq type (elt split 0))
3478 ((not (memq type '(horizontal vertical frame)))
3479 (setq buffer (cond ((stringp type) type)
3480 (t (cdr (assq type gnus-window-to-buffer)))))
3482 (error "Illegal buffer type: %s" type))
3483 (when (setq buf (get-buffer (if (symbolp buffer)
3484 (symbol-value buffer)
3486 (setq win (get-buffer-window buf t)))
3488 (when (memq 'point split)
3489 (setq all-visible win))
3490 (setq all-visible nil)))
3492 (when (eq type 'frame)
3493 (setq gnus-frame-split-p t))
3494 (setq stack (append (cddr split) stack)))))
3495 (unless (eq all-visible t)
3498 (defun gnus-window-top-edge (&optional window)
3499 (nth 1 (window-edges window)))
3501 (defun gnus-remove-some-windows ()
3502 (let ((buffers gnus-window-to-buffer)
3503 buf bufs lowest-buf lowest)
3505 ;; Remove windows on all known Gnus buffers.
3507 (setq buf (cdar buffers))
3509 (setq buf (and (boundp buf) (symbol-value buf))))
3511 (get-buffer-window buf)
3513 (setq bufs (cons buf bufs))
3515 (if (or (not lowest)
3516 (< (gnus-window-top-edge) lowest))
3518 (setq lowest (gnus-window-top-edge))
3519 (setq lowest-buf buf)))))
3520 (setq buffers (cdr buffers)))
3521 ;; Remove windows on *all* summary buffers.
3524 (let ((buf (window-buffer win)))
3525 (if (string-match "^\\*Summary" (buffer-name buf))
3527 (setq bufs (cons buf bufs))
3529 (if (or (not lowest)
3530 (< (gnus-window-top-edge) lowest))
3532 (setq lowest-buf buf)
3533 (setq lowest (gnus-window-top-edge)))))))))
3536 (pop-to-buffer lowest-buf)
3537 (switch-to-buffer nntp-server-buffer)))
3539 (and (not (eq (car bufs) lowest-buf))
3540 (delete-windows-on (car bufs)))
3541 (setq bufs (cdr bufs))))))
3543 (defun gnus-version (&optional arg)
3544 "Version number of this version of Gnus.
3545 If ARG, insert string at point."
3547 (let ((methods gnus-valid-select-methods)
3550 ;; Go through all the legal select methods and add their version
3551 ;; numbers to the total version string. Only the backends that are
3552 ;; currently in use will have their message numbers taken into
3555 (setq meth (intern (concat (caar methods) "-version")))
3557 (stringp (symbol-value meth))
3558 (setq mess (concat mess "; " (symbol-value meth))))
3559 (setq methods (cdr methods)))
3561 (insert (message mess))
3564 (defun gnus-info-find-node ()
3565 "Find Info documentation of Gnus."
3567 ;; Enlarge info window if needed.
3568 (let ((mode major-mode)
3570 (Info-goto-node (cadr (assq mode gnus-info-nodes)))
3571 (setq gnus-info-buffer (current-buffer))
3572 (gnus-configure-windows 'info)))
3574 (defun gnus-days-between (date1 date2)
3575 ;; Return the number of days between date1 and date2.
3576 (- (gnus-day-number date1) (gnus-day-number date2)))
3578 (defun gnus-day-number (date)
3579 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
3580 (timezone-parse-date date))))
3581 (timezone-absolute-from-gregorian
3582 (nth 1 dat) (nth 2 dat) (car dat))))
3584 (defun gnus-encode-date (date)
3585 "Convert DATE to internal time."
3586 (let* ((parse (timezone-parse-date date))
3587 (date (mapcar (lambda (d) (and d (string-to-int d))) parse))
3588 (time (mapcar 'string-to-int (timezone-parse-time (aref parse 3)))))
3589 (encode-time (caddr time) (cadr time) (car time)
3590 (caddr date) (cadr date) (car date) (nth 4 date))))
3592 (defun gnus-time-minus (t1 t2)
3593 "Subtract two internal times."
3594 (let ((borrow (< (cadr t1) (cadr t2))))
3595 (list (- (car t1) (car t2) (if borrow 1 0))
3596 (- (+ (if borrow 65536 0) (cadr t1)) (cadr t2)))))
3598 (defun gnus-file-newer-than (file date)
3599 (let ((fdate (nth 5 (file-attributes file))))
3600 (or (> (car fdate) (car date))
3601 (and (= (car fdate) (car date))
3602 (> (nth 1 fdate) (nth 1 date))))))
3604 (defmacro gnus-local-set-keys (&rest plist)
3605 "Set the keys in PLIST in the current keymap."
3606 `(gnus-define-keys-1 (current-local-map) ',plist))
3608 (defmacro gnus-define-keys (keymap &rest plist)
3609 "Define all keys in PLIST in KEYMAP."
3610 `(gnus-define-keys-1 (quote ,keymap) (quote ,plist)))
3612 (put 'gnus-define-keys 'lisp-indent-function 1)
3613 (put 'gnus-define-keys 'lisp-indent-hook 1)
3614 (put 'gnus-define-keymap 'lisp-indent-function 1)
3615 (put 'gnus-define-keymap 'lisp-indent-hook 1)
3617 (defmacro gnus-define-keymap (keymap &rest plist)
3618 "Define all keys in PLIST in KEYMAP."
3619 `(gnus-define-keys-1 ,keymap (quote ,plist)))
3621 (defun gnus-define-keys-1 (keymap plist)
3623 (error "Can't set keys in a null keymap"))
3624 (cond ((symbolp keymap)
3625 (setq keymap (symbol-value keymap)))
3628 (set (car keymap) nil)
3629 (define-prefix-command (car keymap))
3630 (define-key (symbol-value (caddr keymap)) (cadr keymap) (car keymap))
3631 (setq keymap (symbol-value (car keymap)))))
3634 (when (symbolp (setq key (pop plist)))
3635 (setq key (symbol-value key)))
3636 (define-key keymap key (pop plist)))))
3638 (defun gnus-group-read-only-p (&optional group)
3639 "Check whether GROUP supports editing or not.
3640 If GROUP is nil, `gnus-newsgroup-name' will be checked instead. Note
3641 that that variable is buffer-local to the summary buffers."
3642 (let ((group (or group gnus-newsgroup-name)))
3643 (not (gnus-check-backend-function 'request-replace-article group))))
3645 (defun gnus-group-total-expirable-p (group)
3646 "Check whether GROUP is total-expirable or not."
3647 (let ((params (gnus-info-params (gnus-get-info group))))
3648 (or (memq 'total-expire params)
3649 (cdr (assq 'total-expire params)) ; (total-expire . t)
3650 (and gnus-total-expirable-newsgroups ; Check var.
3651 (string-match gnus-total-expirable-newsgroups group)))))
3653 (defun gnus-group-auto-expirable-p (group)
3654 "Check whether GROUP is total-expirable or not."
3655 (let ((params (gnus-info-params (gnus-get-info group))))
3656 (or (memq 'auto-expire params)
3657 (cdr (assq 'auto-expire params)) ; (auto-expire . t)
3658 (and gnus-auto-expirable-newsgroups ; Check var.
3659 (string-match gnus-auto-expirable-newsgroups group)))))
3661 (defun gnus-virtual-group-p (group)
3662 "Say whether GROUP is virtual or not."
3663 (memq 'virtual (assoc (symbol-name (car (gnus-find-method-for-group group)))
3664 gnus-valid-select-methods)))
3666 (defun gnus-news-group-p (group &optional article)
3667 "Return non-nil if GROUP (and ARTICLE) come from a news server."
3668 (or (gnus-member-of-valid 'post group) ; Ordinary news group.
3669 (and (gnus-member-of-valid 'post-mail group) ; Combined group.
3670 (eq (gnus-request-type group article) 'news))))
3672 (defsubst gnus-simplify-subject-fully (subject)
3673 "Simplify a subject string according to the user's wishes."
3675 ((null gnus-summary-gather-subject-limit)
3676 (gnus-simplify-subject-re subject))
3677 ((eq gnus-summary-gather-subject-limit 'fuzzy)
3678 (gnus-simplify-subject-fuzzy subject))
3679 ((numberp gnus-summary-gather-subject-limit)
3680 (gnus-limit-string (gnus-simplify-subject-re subject)
3681 gnus-summary-gather-subject-limit))
3685 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
3686 "Check whether two subjects are equal. If optional argument
3687 simple-first is t, first argument is already simplified."
3689 ((null simple-first)
3690 (equal (gnus-simplify-subject-fully s1)
3691 (gnus-simplify-subject-fully s2)))
3694 (gnus-simplify-subject-fully s2)))))
3696 ;; Returns a list of writable groups.
3697 (defun gnus-writable-groups ()
3698 (let ((alist gnus-newsrc-alist)
3700 (while (setq group (car (pop alist)))
3701 (unless (gnus-group-read-only-p group)
3702 (push group groups)))
3705 (defun gnus-completing-read (default prompt &rest args)
3706 ;; Like `completing-read', except that DEFAULT is the default argument.
3707 (let* ((prompt (if default
3708 (concat prompt " (default " default ") ")
3709 (concat prompt " ")))
3710 (answer (apply 'completing-read prompt args)))
3711 (if (or (null answer) (zerop (length answer)))
3715 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
3717 (defun gnus-y-or-n-p (prompt)
3722 (defun gnus-yes-or-no-p (prompt)
3724 (yes-or-no-p prompt)
3727 ;; Check whether to use long file names.
3728 (defun gnus-use-long-file-name (symbol)
3729 ;; The variable has to be set...
3730 (and gnus-use-long-file-name
3731 ;; If it isn't a list, then we return t.
3732 (or (not (listp gnus-use-long-file-name))
3733 ;; If it is a list, and the list contains `symbol', we
3735 (not (memq symbol gnus-use-long-file-name)))))
3737 ;; I suspect there's a better way, but I haven't taken the time to do
3738 ;; it yet. -erik selberg@cs.washington.edu
3739 (defun gnus-dd-mmm (messy-date)
3740 "Return a string like DD-MMM from a big messy string"
3741 (let ((datevec (condition-case () (timezone-parse-date messy-date)
3747 ;; Make sure leading zeroes are stripped.
3748 (number-to-string (string-to-number (aref datevec 2)))
3752 (nth (1- (string-to-number (aref datevec 1)))
3753 timezone-months-assoc))
3756 (defun gnus-mode-string-quote (string)
3757 "Quote all \"%\" in STRING."
3759 (gnus-set-work-buffer)
3761 (goto-char (point-min))
3762 (while (search-forward "%" nil t)
3766 ;; Make a hash table (default and minimum size is 255).
3767 ;; Optional argument HASHSIZE specifies the table size.
3768 (defun gnus-make-hashtable (&optional hashsize)
3769 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0))
3771 ;; Make a number that is suitable for hashing; bigger than MIN and one
3773 (defun gnus-create-hash-size (min)
3779 ;; Show message if message has a lower level than `gnus-verbose'.
3780 ;; Guideline for numbers:
3781 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages
3782 ;; for things that take a long time, 7 - not very important messages
3783 ;; on stuff, 9 - messages inside loops.
3784 (defun gnus-message (level &rest args)
3785 (if (<= level gnus-verbose)
3786 (apply 'message args)
3787 ;; We have to do this format thingy here even if the result isn't
3788 ;; shown - the return value has to be the same as the return value
3790 (apply 'format args)))
3792 (defun gnus-error (level &rest args)
3793 "Beep an error if `gnus-verbose' is on LEVEL or less."
3794 (when (<= (floor level) gnus-verbose)
3795 (apply 'message args)
3798 (when (and (floatp level)
3799 (not (zerop (setq duration (* 10 (- level (floor level)))))))
3800 (sit-for duration))))
3803 ;; Generate a unique new group name.
3804 (defun gnus-generate-new-group-name (leaf)
3807 (while (gnus-gethash name gnus-newsrc-hashtb)
3808 (setq name (concat leaf "<" (int-to-string (setq num (1+ num))) ">")))
3811 (defsubst gnus-hide-text (b e props)
3812 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
3813 (gnus-add-text-properties b e props)
3814 (when (memq 'intangible props)
3815 (gnus-put-text-property (max (1- b) (point-min))
3816 b 'intangible (cddr (memq 'intangible props)))))
3818 (defsubst gnus-unhide-text (b e)
3819 "Remove hidden text properties from region between B and E."
3820 (remove-text-properties b e gnus-hidden-properties)
3821 (when (memq 'intangible gnus-hidden-properties)
3822 (gnus-put-text-property (max (1- b) (point-min))
3823 b 'intangible nil)))
3825 (defun gnus-hide-text-type (b e type)
3826 "Hide text of TYPE between B and E."
3827 (gnus-hide-text b e (cons 'gnus-type (cons type gnus-hidden-properties))))
3829 (defun gnus-parent-headers (headers &optional generation)
3830 "Return the headers of the GENERATIONeth parent of HEADERS."
3832 (setq generation 1))
3833 (let (references parent)
3834 (while (and headers (not (zerop generation)))
3835 (setq references (mail-header-references headers))
3836 (when (and references
3837 (setq parent (gnus-parent-id references))
3838 (setq headers (car (gnus-id-to-thread parent))))
3842 (defun gnus-parent-id (references)
3843 "Return the last Message-ID in REFERENCES."
3844 (when (and references
3845 (string-match "\\(<[^\n<>]+>\\)[ \t\n]*\\'" references))
3846 (substring references (match-beginning 1) (match-end 1))))
3848 (defun gnus-split-references (references)
3849 "Return a list of Message-IDs in REFERENCES."
3852 (while (string-match "<[^>]+>" references beg)
3853 (push (substring references (match-beginning 0) (setq beg (match-end 0)))
3857 (defun gnus-buffer-live-p (buffer)
3858 "Say whether BUFFER is alive or not."
3861 (buffer-name (get-buffer buffer))))
3863 (defun gnus-ephemeral-group-p (group)
3864 "Say whether GROUP is ephemeral or not."
3865 (gnus-group-get-parameter group 'quit-config))
3867 (defun gnus-group-quit-config (group)
3868 "Return the quit-config of GROUP."
3869 (gnus-group-get-parameter group 'quit-config))
3871 (defun gnus-simplify-mode-line ()
3872 "Make mode lines a bit simpler."
3873 (setq mode-line-modified "-- ")
3874 (when (listp mode-line-format)
3875 (make-local-variable 'mode-line-format)
3876 (setq mode-line-format (copy-sequence mode-line-format))
3877 (when (equal (nth 3 mode-line-format) " ")
3878 (setcar (nthcdr 3 mode-line-format) " "))))
3880 ;;; List and range functions
3882 (defun gnus-last-element (list)
3883 "Return last element of LIST."
3885 (setq list (cdr list)))
3888 (defun gnus-copy-sequence (list)
3889 "Do a complete, total copy of a list."
3890 (if (and (consp list) (not (consp (cdr list))))
3891 (cons (car list) (cdr list))
3892 (mapcar (lambda (elem) (if (consp elem)
3893 (if (consp (cdr elem))
3894 (gnus-copy-sequence elem)
3895 (cons (car elem) (cdr elem)))
3899 (defun gnus-set-difference (list1 list2)
3900 "Return a list of elements of LIST1 that do not appear in LIST2."
3901 (let ((list1 (copy-sequence list1)))
3903 (setq list1 (delq (car list2) list1))
3904 (setq list2 (cdr list2)))
3907 (defun gnus-sorted-complement (list1 list2)
3908 "Return a list of elements of LIST1 that do not appear in LIST2.
3909 Both lists have to be sorted over <."
3911 (if (or (null list1) (null list2))
3913 (while (and list1 list2)
3914 (cond ((= (car list1) (car list2))
3915 (setq list1 (cdr list1)
3917 ((< (car list1) (car list2))
3918 (setq out (cons (car list1) out))
3919 (setq list1 (cdr list1)))
3921 (setq out (cons (car list2) out))
3922 (setq list2 (cdr list2)))))
3923 (nconc (nreverse out) (or list1 list2)))))
3925 (defun gnus-intersection (list1 list2)
3928 (if (memq (car list2) list1)
3929 (setq result (cons (car list2) result)))
3930 (setq list2 (cdr list2)))
3933 (defun gnus-sorted-intersection (list1 list2)
3934 ;; LIST1 and LIST2 have to be sorted over <.
3936 (while (and list1 list2)
3937 (cond ((= (car list1) (car list2))
3938 (setq out (cons (car list1) out)
3941 ((< (car list1) (car list2))
3942 (setq list1 (cdr list1)))
3944 (setq list2 (cdr list2)))))
3947 (defun gnus-set-sorted-intersection (list1 list2)
3948 ;; LIST1 and LIST2 have to be sorted over <.
3949 ;; This function modifies LIST1.
3950 (let* ((top (cons nil list1))
3952 (while (and list1 list2)
3953 (cond ((= (car list1) (car list2))
3957 ((< (car list1) (car list2))
3958 (setcdr prev (cdr list1))
3959 (setq list1 (cdr list1)))
3961 (setq list2 (cdr list2)))))
3965 (defun gnus-compress-sequence (numbers &optional always-list)
3966 "Convert list of numbers to a list of ranges or a single range.
3967 If ALWAYS-LIST is non-nil, this function will always release a list of
3969 (let* ((first (car numbers))
3970 (last (car numbers))
3974 (if (not (listp (cdr numbers)))
3977 (cond ((= last (car numbers)) nil) ;Omit duplicated number
3978 ((= (1+ last) (car numbers)) ;Still in sequence
3979 (setq last (car numbers)))
3980 (t ;End of one sequence
3982 (cons (if (= first last) first
3983 (cons first last)) result))
3984 (setq first (car numbers))
3985 (setq last (car numbers))))
3986 (setq numbers (cdr numbers)))
3987 (if (and (not always-list) (null result))
3988 (if (= first last) (list first) (cons first last))
3989 (nreverse (cons (if (= first last) first (cons first last))
3992 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
3993 (defun gnus-uncompress-range (ranges)
3994 "Expand a list of ranges into a list of numbers.
3995 RANGES is either a single range on the form `(num . num)' or a list of
3997 (let (first last result)
4001 ((not (listp (cdr ranges)))
4002 (setq first (car ranges))
4003 (setq last (cdr ranges))
4004 (while (<= first last)
4005 (setq result (cons first result))
4006 (setq first (1+ first)))
4010 (if (atom (car ranges))
4011 (if (numberp (car ranges))
4012 (setq result (cons (car ranges) result)))
4013 (setq first (caar ranges))
4014 (setq last (cdar ranges))
4015 (while (<= first last)
4016 (setq result (cons first result))
4017 (setq first (1+ first))))
4018 (setq ranges (cdr ranges)))
4019 (nreverse result)))))
4021 (defun gnus-add-to-range (ranges list)
4022 "Return a list of ranges that has all articles from both RANGES and LIST.
4023 Note: LIST has to be sorted over `<'."
4025 (gnus-compress-sequence list t)
4026 (setq list (copy-sequence list))
4027 (or (listp (cdr ranges))
4028 (setq ranges (list ranges)))
4030 ilist lowest highest temp)
4031 (while (and ranges list)
4033 (setq lowest (or (and (atom (car ranges)) (car ranges))
4035 (while (and list (cdr list) (< (cadr list) lowest))
4036 (setq list (cdr list)))
4037 (if (< (car ilist) lowest)
4040 (setq list (cdr list))
4042 (setq out (nconc (gnus-compress-sequence ilist t) out))))
4043 (setq highest (or (and (atom (car ranges)) (car ranges))
4045 (while (and list (<= (car list) highest))
4046 (setq list (cdr list)))
4047 (setq ranges (cdr ranges)))
4049 (setq out (nconc (gnus-compress-sequence list t) out)))
4050 (setq out (sort out (lambda (r1 r2)
4051 (< (or (and (atom r1) r1) (car r1))
4052 (or (and (atom r2) r2) (car r2))))))
4055 (if (atom (car ranges))
4057 (if (atom (cadr ranges))
4058 (if (= (1+ (car ranges)) (cadr ranges))
4060 (setcar ranges (cons (car ranges)
4062 (setcdr ranges (cddr ranges))))
4063 (if (= (1+ (car ranges)) (caadr ranges))
4065 (setcar (cadr ranges) (car ranges))
4066 (setcar ranges (cadr ranges))
4067 (setcdr ranges (cddr ranges))))))
4069 (if (atom (cadr ranges))
4070 (if (= (1+ (cdar ranges)) (cadr ranges))
4072 (setcdr (car ranges) (cadr ranges))
4073 (setcdr ranges (cddr ranges))))
4074 (if (= (1+ (cdar ranges)) (caadr ranges))
4076 (setcdr (car ranges) (cdadr ranges))
4077 (setcdr ranges (cddr ranges)))))))
4078 (setq ranges (cdr ranges)))
4081 (defun gnus-remove-from-range (ranges list)
4082 "Return a list of ranges that has all articles from LIST removed from RANGES.
4083 Note: LIST has to be sorted over `<'."
4084 ;; !!! This function shouldn't look like this, but I've got a headache.
4085 (gnus-compress-sequence
4086 (gnus-sorted-complement
4087 (gnus-uncompress-range ranges) list)))
4089 (defun gnus-member-of-range (number ranges)
4090 (if (not (listp (cdr ranges)))
4091 (and (>= number (car ranges))
4092 (<= number (cdr ranges)))
4095 (if (numberp (car ranges))
4096 (>= number (car ranges))
4097 (>= number (caar ranges)))
4099 (if (if (numberp (car ranges))
4100 (= number (car ranges))
4101 (and (>= number (caar ranges))
4102 (<= number (cdar ranges))))
4103 (setq not-stop nil))
4104 (setq ranges (cdr ranges)))
4107 (defun gnus-range-length (range)
4108 "Return the length RANGE would have if uncompressed."
4109 (length (gnus-uncompress-range range)))
4111 (defun gnus-sublist-p (list sublist)
4112 "Test whether all elements in SUBLIST are members of LIST."
4115 (unless (memq (pop sublist) list)
4125 (defvar gnus-group-mode-map nil)
4126 (put 'gnus-group-mode 'mode-class 'special)
4128 (unless gnus-group-mode-map
4129 (setq gnus-group-mode-map (make-keymap))
4130 (suppress-keymap gnus-group-mode-map)
4132 (gnus-define-keys gnus-group-mode-map
4133 " " gnus-group-read-group
4134 "=" gnus-group-select-group
4135 "\r" gnus-group-select-group
4136 "\M-\r" gnus-group-quick-select-group
4137 "j" gnus-group-jump-to-group
4138 "n" gnus-group-next-unread-group
4139 "p" gnus-group-prev-unread-group
4140 "\177" gnus-group-prev-unread-group
4141 [delete] gnus-group-prev-unread-group
4142 "N" gnus-group-next-group
4143 "P" gnus-group-prev-group
4144 "\M-n" gnus-group-next-unread-group-same-level
4145 "\M-p" gnus-group-prev-unread-group-same-level
4146 "," gnus-group-best-unread-group
4147 "." gnus-group-first-unread-group
4148 "u" gnus-group-unsubscribe-current-group
4149 "U" gnus-group-unsubscribe-group
4150 "c" gnus-group-catchup-current
4151 "C" gnus-group-catchup-current-all
4152 "l" gnus-group-list-groups
4153 "L" gnus-group-list-all-groups
4155 "g" gnus-group-get-new-news
4156 "\M-g" gnus-group-get-new-news-this-group
4157 "R" gnus-group-restart
4158 "r" gnus-group-read-init-file
4159 "B" gnus-group-browse-foreign-server
4160 "b" gnus-group-check-bogus-groups
4161 "F" gnus-find-new-newsgroups
4162 "\C-c\C-d" gnus-group-describe-group
4163 "\M-d" gnus-group-describe-all-groups
4164 "\C-c\C-a" gnus-group-apropos
4165 "\C-c\M-\C-a" gnus-group-description-apropos
4166 "a" gnus-group-post-news
4167 "\ek" gnus-group-edit-local-kill
4168 "\eK" gnus-group-edit-global-kill
4169 "\C-k" gnus-group-kill-group
4170 "\C-y" gnus-group-yank-group
4171 "\C-w" gnus-group-kill-region
4172 "\C-x\C-t" gnus-group-transpose-groups
4173 "\C-c\C-l" gnus-group-list-killed
4174 "\C-c\C-x" gnus-group-expire-articles
4175 "\C-c\M-\C-x" gnus-group-expire-all-groups
4177 "s" gnus-group-save-newsrc
4178 "z" gnus-group-suspend
4179 "Z" gnus-group-clear-dribble
4182 "?" gnus-group-describe-briefly
4183 "\C-c\C-i" gnus-info-find-node
4184 "\M-e" gnus-group-edit-group-method
4185 "^" gnus-group-enter-server-mode
4186 gnus-mouse-2 gnus-mouse-pick-group
4187 "<" beginning-of-buffer
4190 "\C-c\C-s" gnus-group-sort-groups
4192 "\C-c\M-g" gnus-activate-all-groups
4193 "\M-&" gnus-group-universal-argument
4194 "#" gnus-group-mark-group
4195 "\M-#" gnus-group-unmark-group)
4197 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
4198 "m" gnus-group-mark-group
4199 "u" gnus-group-unmark-group
4200 "w" gnus-group-mark-region
4201 "m" gnus-group-mark-buffer
4202 "r" gnus-group-mark-regexp
4203 "U" gnus-group-unmark-all-groups)
4205 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
4206 "d" gnus-group-make-directory-group
4207 "h" gnus-group-make-help-group
4208 "a" gnus-group-make-archive-group
4209 "k" gnus-group-make-kiboze-group
4210 "m" gnus-group-make-group
4211 "E" gnus-group-edit-group
4212 "e" gnus-group-edit-group-method
4213 "p" gnus-group-edit-group-parameters
4214 "v" gnus-group-add-to-virtual
4215 "V" gnus-group-make-empty-virtual
4216 "D" gnus-group-enter-directory
4217 "f" gnus-group-make-doc-group
4218 "r" gnus-group-rename-group
4219 "\177" gnus-group-delete-group
4220 [delete] gnus-group-delete-group)
4222 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
4223 "b" gnus-group-brew-soup
4224 "w" gnus-soup-save-areas
4225 "s" gnus-soup-send-replies
4226 "p" gnus-soup-pack-packet
4227 "r" nnsoup-pack-replies)
4229 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
4230 "s" gnus-group-sort-groups
4231 "a" gnus-group-sort-groups-by-alphabet
4232 "u" gnus-group-sort-groups-by-unread
4233 "l" gnus-group-sort-groups-by-level
4234 "v" gnus-group-sort-groups-by-score
4235 "r" gnus-group-sort-groups-by-rank
4236 "m" gnus-group-sort-groups-by-method)
4238 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
4239 "k" gnus-group-list-killed
4240 "z" gnus-group-list-zombies
4241 "s" gnus-group-list-groups
4242 "u" gnus-group-list-all-groups
4243 "A" gnus-group-list-active
4244 "a" gnus-group-apropos
4245 "d" gnus-group-description-apropos
4246 "m" gnus-group-list-matching
4247 "M" gnus-group-list-all-matching
4248 "l" gnus-group-list-level)
4250 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
4251 "f" gnus-score-flush-cache)
4253 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
4254 "f" gnus-group-fetch-faq)
4256 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
4257 "l" gnus-group-set-current-level
4258 "t" gnus-group-unsubscribe-current-group
4259 "s" gnus-group-unsubscribe-group
4260 "k" gnus-group-kill-group
4261 "y" gnus-group-yank-group
4262 "w" gnus-group-kill-region
4263 "\C-k" gnus-group-kill-level
4264 "z" gnus-group-kill-all-zombies))
4266 (defun gnus-group-mode ()
4267 "Major mode for reading news.
4269 All normal editing commands are switched off.
4270 \\<gnus-group-mode-map>
4271 The group buffer lists (some of) the groups available. For instance,
4272 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
4273 lists all zombie groups.
4275 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
4276 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
4278 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
4280 The following commands are available:
4282 \\{gnus-group-mode-map}"
4284 (when (and menu-bar-mode
4285 (gnus-visual-p 'group-menu 'menu))
4286 (gnus-group-make-menu-bar))
4287 (kill-all-local-variables)
4288 (gnus-simplify-mode-line)
4289 (setq major-mode 'gnus-group-mode)
4290 (setq mode-name "Group")
4291 (gnus-group-set-mode-line)
4292 (setq mode-line-process nil)
4293 (use-local-map gnus-group-mode-map)
4294 (buffer-disable-undo (current-buffer))
4295 (setq truncate-lines t)
4296 (setq buffer-read-only t)
4297 (gnus-make-local-hook 'post-command-hook)
4298 (gnus-add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
4299 (run-hooks 'gnus-group-mode-hook))
4301 (defun gnus-clear-inboxes-moved ()
4302 (setq nnmail-moved-inboxes nil))
4304 (defun gnus-mouse-pick-group (e)
4305 "Enter the group under the mouse pointer."
4308 (gnus-group-read-group nil))
4310 ;; Look at LEVEL and find out what the level is really supposed to be.
4311 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
4312 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
4313 (defun gnus-group-default-level (&optional level number-or-nil)
4315 (gnus-group-use-permanent-levels
4316 (or (setq gnus-group-use-permanent-levels
4317 (or level (if (numberp gnus-group-use-permanent-levels)
4318 gnus-group-use-permanent-levels
4319 (or gnus-group-default-list-level
4320 gnus-level-subscribed))))
4321 gnus-group-default-list-level gnus-level-subscribed))
4325 (or level gnus-group-default-list-level gnus-level-subscribed))))
4328 (defun gnus-slave-no-server (&optional arg)
4329 "Read network news as a slave, without connecting to local server"
4331 (gnus-no-server arg t))
4334 (defun gnus-no-server (&optional arg slave)
4336 If ARG is a positive number, Gnus will use that as the
4337 startup level. If ARG is nil, Gnus will be started at level 2.
4338 If ARG is non-nil and not a positive number, Gnus will
4339 prompt the user for the name of an NNTP server to use.
4340 As opposed to `gnus', this command will not connect to the local server."
4342 (let ((val (or arg (1- gnus-level-default-subscribed))))
4344 (make-local-variable 'gnus-group-use-permanent-levels)
4345 (setq gnus-group-use-permanent-levels val)))
4348 (defun gnus-slave (&optional arg)
4349 "Read news as a slave."
4351 (gnus arg nil 'slave))
4354 (defun gnus-other-frame (&optional arg)
4355 "Pop up a frame to read news."
4357 (if (get-buffer gnus-group-buffer)
4358 (let ((pop-up-frames t))
4360 (select-frame (make-frame))
4364 (defun gnus (&optional arg dont-connect slave)
4366 If ARG is non-nil and a positive number, Gnus will use that as the
4367 startup level. If ARG is non-nil and not a positive number, Gnus will
4368 prompt the user for the name of an NNTP server to use."
4371 (if (get-buffer gnus-group-buffer)
4373 (switch-to-buffer gnus-group-buffer)
4374 (gnus-group-get-new-news))
4377 (nnheader-init-server-buffer)
4378 (gnus-read-init-file)
4379 (setq gnus-slave slave)
4381 (gnus-group-setup-buffer)
4382 (let ((buffer-read-only nil))
4384 (if (not gnus-inhibit-startup-message)
4386 (gnus-group-startup-message)
4389 (let ((level (and (numberp arg) (> arg 0) arg))
4395 (gnus-start-news-server (and arg (not level))))))
4396 (if (and (not dont-connect)
4399 (run-hooks 'gnus-startup-hook)
4400 ;; NNTP server is successfully open.
4402 ;; Find the current startup file name.
4403 (setq gnus-current-startup-file
4404 (gnus-make-newsrc-file gnus-startup-file))
4406 ;; Read the dribble file.
4407 (when (or gnus-slave gnus-use-dribble-file)
4408 (gnus-dribble-read-file))
4410 ;; Allow using GroupLens predictions.
4411 (when gnus-use-grouplens
4413 (add-hook 'gnus-summary-mode-hook 'gnus-grouplens-mode))
4415 (gnus-summary-make-display-table)
4416 ;; Do the actual startup.
4417 (gnus-setup-news nil level dont-connect)
4418 ;; Generate the group buffer.
4419 (gnus-group-list-groups level)
4420 (gnus-group-first-unread-group)
4421 (gnus-configure-windows 'group)
4422 (gnus-group-set-mode-line))))))
4424 (defun gnus-unload ()
4425 "Unload all Gnus features."
4427 (or (boundp 'load-history)
4428 (error "Sorry, `gnus-unload' is not implemented in this Emacs version."))
4429 (let ((history load-history)
4432 (and (string-match "^\\(gnus\\|nn\\)" (caar history))
4433 (setq feature (cdr (assq 'provide (car history))))
4434 (unload-feature feature 'force))
4435 (setq history (cdr history)))))
4437 (defun gnus-compile ()
4438 "Byte-compile the user-defined format specs."
4440 (let ((entries gnus-format-specs)
4441 entry gnus-tmp-func)
4443 (gnus-message 7 "Compiling format specs...")
4446 (setq entry (pop entries))
4447 (if (eq (car entry) 'version)
4448 (setq gnus-format-specs (delq entry gnus-format-specs))
4449 (when (and (listp (caddr entry))
4450 (not (eq 'byte-code (caaddr entry))))
4451 (fset 'gnus-tmp-func
4452 `(lambda () ,(caddr entry)))
4453 (byte-compile 'gnus-tmp-func)
4454 (setcar (cddr entry) (gnus-byte-code 'gnus-tmp-func)))))
4456 (push (cons 'version emacs-version) gnus-format-specs)
4458 (gnus-message 7 "Compiling user specs...done"))))
4460 (defun gnus-indent-rigidly (start end arg)
4461 "Indent rigidly using only spaces and no tabs."
4464 (narrow-to-region start end)
4465 (indent-rigidly start end arg)
4466 (goto-char (point-min))
4467 (while (search-forward "\t" nil t)
4468 (replace-match " " t t)))))
4470 (defun gnus-group-startup-message (&optional x y)
4471 "Insert startup message in current buffer."
4472 ;; Insert the message.
4477 _ ___ __ ___ __ _ ___
4496 ;; And then hack it.
4497 (gnus-indent-rigidly (point-min) (point-max)
4498 (/ (max (- (window-width) (or x 46)) 0) 2))
4499 (goto-char (point-min))
4501 (let* ((pheight (count-lines (point-min) (point-max)))
4502 (wheight (window-height))
4503 (rest (- wheight pheight)))
4504 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
4506 (goto-char (point-min))
4507 (and (search-forward "Praxis" nil t)
4508 (gnus-put-text-property (match-beginning 0) (match-end 0) 'face 'bold))
4509 (goto-char (point-min))
4510 (let* ((mode-string (gnus-group-set-mode-line)))
4511 (setq mode-line-buffer-identification
4512 (list (concat gnus-version (substring (car mode-string) 4))))
4513 (set-buffer-modified-p t)))
4515 (defun gnus-group-setup-buffer ()
4516 (or (get-buffer gnus-group-buffer)
4518 (switch-to-buffer gnus-group-buffer)
4519 (gnus-add-current-to-buffer-list)
4521 (and gnus-carpal (gnus-carpal-setup-buffer 'group)))))
4523 (defun gnus-group-list-groups (&optional level unread lowest)
4524 "List newsgroups with level LEVEL or lower that have unread articles.
4525 Default is all subscribed groups.
4526 If argument UNREAD is non-nil, groups with no unread articles are also
4528 (interactive (list (if current-prefix-arg
4529 (prefix-numeric-value current-prefix-arg)
4531 (gnus-group-default-level nil t)
4532 gnus-group-default-list-level
4533 gnus-level-subscribed))))
4535 (setq level (car gnus-group-list-mode)
4536 unread (cdr gnus-group-list-mode)))
4537 (setq level (gnus-group-default-level level))
4538 (gnus-group-setup-buffer) ;May call from out of group buffer
4539 (gnus-update-format-specifications)
4540 (let ((case-fold-search nil)
4541 (props (text-properties-at (gnus-point-at-bol)))
4542 (group (gnus-group-group-name)))
4543 (set-buffer gnus-group-buffer)
4544 (funcall gnus-group-prepare-function level unread lowest)
4545 (if (zerop (buffer-size))
4546 (gnus-message 5 gnus-no-groups-message)
4547 (goto-char (point-max))
4548 (when (or (not gnus-group-goto-next-group-function)
4549 (not (funcall gnus-group-goto-next-group-function
4552 ;; Go to the first group with unread articles.
4553 (gnus-group-search-forward t)
4554 ;; Find the right group to put point on. If the current group
4555 ;; has disappeared in the new listing, try to find the next
4556 ;; one. If no next one can be found, just leave point at the
4557 ;; first newsgroup in the buffer.
4558 (if (not (gnus-goto-char
4560 (point-min) (point-max)
4561 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
4562 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
4564 (not (gnus-goto-char
4566 (point-min) (point-max) 'gnus-group
4568 (caar newsrc) gnus-active-hashtb)))))
4569 (setq newsrc (cdr newsrc)))
4570 (or newsrc (progn (goto-char (point-max))
4571 (forward-line -1)))))))
4572 ;; Adjust cursor point.
4573 (gnus-group-position-point))))
4575 (defun gnus-group-list-level (level &optional all)
4576 "List groups on LEVEL.
4577 If ALL (the prefix), also list groups that have no unread articles."
4578 (interactive "nList groups on level: \nP")
4579 (gnus-group-list-groups level all level))
4581 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
4582 "List all newsgroups with unread articles of level LEVEL or lower.
4583 If ALL is non-nil, list groups that have no unread articles.
4584 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
4585 If REGEXP, only list groups matching REGEXP."
4586 (set-buffer gnus-group-buffer)
4587 (let ((buffer-read-only nil)
4588 (newsrc (cdr gnus-newsrc-alist))
4589 (lowest (or lowest 1))
4590 info clevel unread group params)
4592 (if (< lowest gnus-level-zombie)
4593 ;; List living groups.
4595 (setq info (car newsrc)
4596 group (gnus-info-group info)
4597 params (gnus-info-params info)
4599 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
4600 (and unread ; This group might be bogus
4602 (string-match regexp group))
4603 (<= (setq clevel (gnus-info-level info)) level)
4605 (or all ; We list all groups?
4606 (if (eq unread t) ; Unactivated?
4607 gnus-group-list-inactive-groups ; We list unactivated
4608 (> unread 0)) ; We list groups with unread articles
4609 (and gnus-list-groups-with-ticked-articles
4610 (cdr (assq 'tick (gnus-info-marks info))))
4611 ; And groups with tickeds
4612 ;; Check for permanent visibility.
4613 (and gnus-permanently-visible-groups
4614 (string-match gnus-permanently-visible-groups
4616 (memq 'visible params)
4617 (cdr (assq 'visible params)))
4618 (gnus-group-insert-group-line
4619 group (gnus-info-level info)
4620 (gnus-info-marks info) unread (gnus-info-method info)))))
4622 ;; List dead groups.
4623 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
4624 (gnus-group-prepare-flat-list-dead
4625 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
4626 gnus-level-zombie ?Z
4628 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
4629 (gnus-group-prepare-flat-list-dead
4630 (setq gnus-killed-list (sort gnus-killed-list 'string<))
4631 gnus-level-killed ?K regexp))
4633 (gnus-group-set-mode-line)
4634 (setq gnus-group-list-mode (cons level all))
4635 (run-hooks 'gnus-group-prepare-hook)))
4637 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
4638 ;; List zombies and killed lists somewhat faster, which was
4639 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
4640 ;; this by ignoring the group format specification altogether.
4643 ;; This loop is used when listing groups that match some
4646 (setq group (pop groups))
4647 (when (string-match regexp group)
4648 (gnus-add-text-properties
4649 (point) (prog1 (1+ (point))
4650 (insert " " mark " *: " group "\n"))
4651 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4653 'gnus-level level))))
4654 ;; This loop is used when listing all groups.
4656 (gnus-add-text-properties
4657 (point) (prog1 (1+ (point))
4658 (insert " " mark " *: "
4659 (setq group (pop groups)) "\n"))
4660 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4662 'gnus-level level))))))
4664 (defmacro gnus-group-real-name (group)
4665 "Find the real name of a foreign newsgroup."
4666 `(let ((gname ,group))
4667 (if (string-match ":[^:]+$" gname)
4668 (substring gname (1+ (match-beginning 0)))
4671 (defsubst gnus-server-add-address (method)
4672 (let ((method-name (symbol-name (car method))))
4673 (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
4674 (not (assq (intern (concat method-name "-address")) method)))
4675 (append method (list (list (intern (concat method-name "-address"))
4679 (defsubst gnus-server-get-method (group method)
4680 ;; Input either a server name, and extended server name, or a
4681 ;; select method, and return a select method.
4682 (cond ((stringp method)
4683 (gnus-server-to-method method))
4684 ((equal method gnus-select-method)
4686 ((and (stringp (car method)) group)
4687 (gnus-server-extend-method group method))
4688 ((and method (not group)
4689 (equal (cadr method) ""))
4692 (gnus-server-add-address method))))
4694 (defun gnus-server-to-method (server)
4695 "Map virtual server names to select methods."
4697 ;; Is this a method, perhaps?
4698 (and server (listp server) server)
4699 ;; Perhaps this is the native server?
4700 (and (equal server "native") gnus-select-method)
4701 ;; It should be in the server alist.
4702 (cdr (assoc server gnus-server-alist))
4703 ;; If not, we look through all the opened server
4704 ;; to see whether we can find it there.
4705 (let ((opened gnus-opened-servers))
4707 (not (equal server (format "%s:%s" (caaar opened)
4712 (defmacro gnus-method-equal (ss1 ss2)
4713 "Say whether two servers are equal."
4717 (and (= (length s1) (length s2))
4719 (while (and s1 (member (car s1) s2))
4723 (defun gnus-server-equal (m1 m2)
4724 "Say whether two methods are equal."
4725 (let ((m1 (cond ((null m1) gnus-select-method)
4726 ((stringp m1) (gnus-server-to-method m1))
4728 (m2 (cond ((null m2) gnus-select-method)
4729 ((stringp m2) (gnus-server-to-method m2))
4731 (gnus-method-equal m1 m2)))
4733 (defun gnus-servers-using-backend (backend)
4734 "Return a list of known servers using BACKEND."
4735 (let ((opened gnus-opened-servers)
4738 (when (eq backend (caaar opened))
4739 (push (caar opened) out))
4743 (defun gnus-group-prefixed-name (group method)
4744 "Return the whole name from GROUP and METHOD."
4745 (and (stringp method) (setq method (gnus-server-to-method method)))
4746 (concat (format "%s" (car method))
4748 (or (assoc (format "%s" (car method))
4749 (gnus-methods-using 'address))
4750 (gnus-server-equal method gnus-message-archive-method))
4752 (not (string= (nth 1 method) "")))
4753 (concat "+" (nth 1 method)))
4756 (defun gnus-group-real-prefix (group)
4757 "Return the prefix of the current group name."
4758 (if (string-match "^[^:]+:" group)
4759 (substring group 0 (match-end 0))
4762 (defun gnus-group-method (group)
4763 "Return the server or method used for selecting GROUP."
4764 (let ((prefix (gnus-group-real-prefix group)))
4765 (if (equal prefix "")
4767 (let ((servers gnus-opened-servers)
4769 backend possible found)
4770 (if (string-match "^[^\\+]+\\+" prefix)
4771 (setq backend (intern (substring prefix 0 (1- (match-end 0))))
4772 server (substring prefix (match-end 0) (1- (length prefix))))
4773 (setq backend (intern (substring prefix 0 (1- (length prefix))))))
4775 (when (eq (caaar servers) backend)
4776 (setq possible (caar servers))
4777 (when (equal (cadaar servers) server)
4778 (setq found (caar servers))))
4780 (or (car (rassoc found gnus-server-alist))
4782 (car (rassoc possible gnus-server-alist))
4784 (list backend server))))))
4786 (defsubst gnus-secondary-method-p (method)
4787 "Return whether METHOD is a secondary select method."
4788 (let ((methods gnus-secondary-select-methods)
4789 (gmethod (gnus-server-get-method nil method)))
4791 (not (equal (gnus-server-get-method nil (car methods))
4793 (setq methods (cdr methods)))
4796 (defun gnus-group-foreign-p (group)
4797 "Say whether a group is foreign or not."
4798 (and (not (gnus-group-native-p group))
4799 (not (gnus-group-secondary-p group))))
4801 (defun gnus-group-native-p (group)
4802 "Say whether the group is native or not."
4803 (not (string-match ":" group)))
4805 (defun gnus-group-secondary-p (group)
4806 "Say whether the group is secondary or not."
4807 (gnus-secondary-method-p (gnus-find-method-for-group group)))
4809 (defun gnus-group-get-parameter (group &optional symbol)
4810 "Returns the group parameters for GROUP.
4811 If SYMBOL, return the value of that symbol in the group parameters."
4812 (let ((params (gnus-info-params (gnus-get-info group))))
4814 (gnus-group-parameter-value params symbol)
4817 (defun gnus-group-parameter-value (params symbol)
4818 "Return the value of SYMBOL in group PARAMS."
4819 (or (car (memq symbol params)) ; It's either a simple symbol
4820 (cdr (assq symbol params)))) ; or a cons.
4822 (defun gnus-group-add-parameter (group param)
4823 "Add parameter PARAM to GROUP."
4824 (let ((info (gnus-get-info group)))
4826 () ; This is a dead group. We just ignore it.
4827 ;; Cons the new param to the old one and update.
4828 (gnus-group-set-info (cons param (gnus-info-params info))
4831 (defun gnus-group-set-parameter (group name value)
4832 "Set parameter NAME to VALUE in GROUP."
4833 (let ((info (gnus-get-info group)))
4835 () ; This is a dead group. We just ignore it.
4836 (let ((old-params (gnus-info-params info))
4837 (new-params (list (cons name value))))
4839 (if (or (not (listp (car old-params)))
4840 (not (eq (caar old-params) name)))
4841 (setq new-params (append new-params (list (car old-params)))))
4842 (setq old-params (cdr old-params)))
4843 (gnus-group-set-info new-params group 'params)))))
4845 (defun gnus-group-add-score (group &optional score)
4846 "Add SCORE to the GROUP score.
4847 If SCORE is nil, add 1 to the score of GROUP."
4848 (let ((info (gnus-get-info group)))
4850 (gnus-info-set-score info (+ (gnus-info-score info) (or score 1))))))
4852 (defun gnus-summary-bubble-group ()
4853 "Increase the score of the current group.
4854 This is a handy function to add to `gnus-summary-exit-hook' to
4855 increase the score of each group you read."
4856 (gnus-group-add-score gnus-newsgroup-name))
4858 (defun gnus-group-set-info (info &optional method-only-group part)
4859 (let* ((entry (gnus-gethash
4860 (or method-only-group (gnus-info-group info))
4861 gnus-newsrc-hashtb))
4863 (info (if method-only-group (nth 2 entry) info))
4865 (when method-only-group
4867 (error "Trying to change non-existent group %s" method-only-group))
4868 ;; We have received parts of the actual group info - either the
4869 ;; select method or the group parameters. We first check
4870 ;; whether we have to extend the info, and if so, do that.
4871 (let ((len (length info))
4872 (total (if (eq part 'method) 5 6)))
4874 (setcdr (nthcdr (1- len) info)
4875 (make-list (- total len) nil)))
4876 ;; Then we enter the new info.
4877 (setcar (nthcdr (1- total) info) part-info)))
4879 ;; This is a new group, so we just create it.
4881 (set-buffer gnus-group-buffer)
4882 (setq method (gnus-info-method info))
4883 (when (gnus-server-equal method "native")
4886 (set-buffer gnus-group-buffer)
4888 ;; It's a foreign group...
4889 (gnus-group-make-group
4890 (gnus-group-real-name (gnus-info-group info))
4891 (if (stringp method) method
4892 (prin1-to-string (car method)))
4894 (nth 1 (gnus-info-method info))))
4895 ;; It's a native group.
4896 (gnus-group-make-group (gnus-info-group info))))
4897 (gnus-message 6 "Note: New group created")
4899 (gnus-gethash (gnus-group-prefixed-name
4900 (gnus-group-real-name (gnus-info-group info))
4901 (or (gnus-info-method info) gnus-select-method))
4902 gnus-newsrc-hashtb))))
4903 ;; Whether it was a new group or not, we now have the entry, so we
4904 ;; can do the update.
4907 (setcar (nthcdr 2 entry) info)
4908 (when (and (not (eq (car entry) t))
4909 (gnus-active (gnus-info-group info)))
4910 (setcar entry (length (gnus-list-of-unread-articles (car info))))))
4911 (error "No such group: %s" (gnus-info-group info)))))
4913 (defun gnus-group-set-method-info (group select-method)
4914 (gnus-group-set-info select-method group 'method))
4916 (defun gnus-group-set-params-info (group params)
4917 (gnus-group-set-info params group 'params))
4919 (defun gnus-group-update-group-line ()
4920 "Update the current line in the group buffer."
4921 (let* ((buffer-read-only nil)
4922 (group (gnus-group-group-name))
4923 (entry (and group (gnus-gethash group gnus-newsrc-hashtb)))
4924 gnus-group-indentation)
4926 (not (gnus-ephemeral-group-p group))
4928 (concat "(gnus-group-set-info '"
4929 (prin1-to-string (nth 2 entry)) ")")))
4930 (setq gnus-group-indentation (gnus-group-group-indentation))
4932 (gnus-group-insert-group-line-info group)
4934 (gnus-group-position-point)))
4936 (defun gnus-group-insert-group-line-info (group)
4937 "Insert GROUP on the current line."
4938 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
4942 ;; (Un)subscribed group.
4943 (setq info (nth 2 entry))
4944 (gnus-group-insert-group-line
4945 group (gnus-info-level info) (gnus-info-marks info)
4946 (or (car entry) t) (gnus-info-method info)))
4947 ;; This group is dead.
4948 (gnus-group-insert-group-line
4950 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
4952 (if (setq active (gnus-active group))
4953 (- (1+ (cdr active)) (car active)) 0)
4956 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
4957 gnus-tmp-marked number
4959 "Insert a group line in the group buffer."
4960 (let* ((gnus-tmp-active (gnus-active gnus-tmp-group))
4961 (gnus-tmp-number-total
4963 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
4965 (gnus-tmp-number-of-unread
4966 (if (numberp number) (int-to-string (max 0 number))
4968 (gnus-tmp-number-of-read
4969 (if (numberp number)
4970 (int-to-string (max 0 (- gnus-tmp-number-total number)))
4972 (gnus-tmp-subscribed
4973 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
4974 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
4975 ((= gnus-tmp-level gnus-level-zombie) ?Z)
4977 (gnus-tmp-qualified-group (gnus-group-real-name gnus-tmp-group))
4978 (gnus-tmp-newsgroup-description
4979 (if gnus-description-hashtb
4980 (or (gnus-gethash gnus-tmp-group gnus-description-hashtb) "")
4983 (if (member gnus-tmp-group gnus-moderated-list) ?m ? ))
4984 (gnus-tmp-moderated-string
4985 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
4987 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
4988 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
4989 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
4990 (gnus-tmp-news-method-string
4992 (format "(%s:%s)" (car gnus-tmp-method)
4993 (cadr gnus-tmp-method)) ""))
4994 (gnus-tmp-marked-mark
4995 (if (and (numberp number)
4997 (cdr (assq 'tick gnus-tmp-marked)))
4999 (gnus-tmp-process-marked
5000 (if (member gnus-tmp-group gnus-group-marked)
5001 gnus-process-mark ? ))
5003 (or (and gnus-use-grouplens
5004 (bbb-grouplens-group-p gnus-tmp-group))
5006 (buffer-read-only nil)
5007 header gnus-tmp-header) ; passed as parameter to user-funcs.
5009 (gnus-add-text-properties
5013 (eval gnus-group-line-format-spec))
5014 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
5015 gnus-unread ,(if (numberp number)
5016 (string-to-int gnus-tmp-number-of-unread)
5018 gnus-marked ,gnus-tmp-marked-mark
5019 gnus-indentation ,gnus-group-indentation
5020 gnus-level ,gnus-tmp-level))
5021 (when (inline (gnus-visual-p 'group-highlight 'highlight))
5023 (run-hooks 'gnus-group-update-hook)
5025 ;; Allow XEmacs to remove front-sticky text properties.
5026 (gnus-group-remove-excess-properties)))
5028 (defun gnus-group-update-group (group &optional visible-only)
5029 "Update all lines where GROUP appear.
5030 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
5033 (set-buffer gnus-group-buffer)
5034 ;; The buffer may be narrowed.
5037 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
5039 found buffer-read-only)
5040 ;; Enter the current status into the dribble buffer.
5041 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
5042 (if (and entry (not (gnus-ephemeral-group-p group)))
5044 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
5046 ;; Find all group instances. If topics are in use, each group
5047 ;; may be listed in more than once.
5048 (while (setq loc (text-property-any
5049 loc (point-max) 'gnus-group ident))
5052 (let ((gnus-group-indentation (gnus-group-group-indentation)))
5054 (gnus-group-insert-group-line-info group)
5057 (run-hooks 'gnus-group-update-group-hook)))
5058 (setq loc (1+ loc)))
5059 (unless (or found visible-only)
5060 ;; No such line in the buffer, find out where it's supposed to
5061 ;; go, and insert it there (or at the end of the buffer).
5062 (if gnus-goto-missing-group-function
5063 (funcall gnus-goto-missing-group-function group)
5064 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
5065 (while (and entry (car entry)
5069 (point-min) (point-max)
5070 'gnus-group (gnus-intern-safe
5071 (caar entry) gnus-active-hashtb)))))
5072 (setq entry (cdr entry)))
5073 (or entry (goto-char (point-max)))))
5074 ;; Finally insert the line.
5075 (let ((gnus-group-indentation (gnus-group-group-indentation)))
5076 (gnus-group-insert-group-line-info group)
5079 (run-hooks 'gnus-group-update-group-hook))))
5080 (gnus-group-set-mode-line)))))
5082 (defun gnus-group-set-mode-line ()
5083 "Update the mode line in the group buffer."
5084 (when (memq 'group gnus-updated-mode-lines)
5085 ;; Yes, we want to keep this mode line updated.
5087 (set-buffer gnus-group-buffer)
5088 (let* ((gformat (or gnus-group-mode-line-format-spec
5089 (setq gnus-group-mode-line-format-spec
5091 gnus-group-mode-line-format
5092 gnus-group-mode-line-format-alist))))
5093 (gnus-tmp-news-server (cadr gnus-select-method))
5094 (gnus-tmp-news-method (car gnus-select-method))
5095 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
5097 gnus-tmp-header ;Dummy binding for user-defined formats
5098 ;; Get the resulting string.
5099 (mode-string (eval gformat)))
5100 ;; Say whether the dribble buffer has been modified.
5101 (setq mode-line-modified
5102 (if (and gnus-dribble-buffer
5103 (buffer-name gnus-dribble-buffer)
5104 (buffer-modified-p gnus-dribble-buffer)
5106 (set-buffer gnus-dribble-buffer)
5107 (not (zerop (buffer-size)))))
5109 ;; If the line is too long, we chop it off.
5110 (when (> (length mode-string) max-len)
5111 (setq mode-string (substring mode-string 0 (- max-len 4))))
5113 (setq mode-line-buffer-identification
5115 (set-buffer-modified-p t))))))
5117 (defun gnus-group-group-name ()
5118 "Get the name of the newsgroup on the current line."
5119 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
5120 (and group (symbol-name group))))
5122 (defun gnus-group-group-level ()
5123 "Get the level of the newsgroup on the current line."
5124 (get-text-property (gnus-point-at-bol) 'gnus-level))
5126 (defun gnus-group-group-indentation ()
5127 "Get the indentation of the newsgroup on the current line."
5128 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
5129 (and gnus-group-indentation-function
5130 (funcall gnus-group-indentation-function))
5133 (defun gnus-group-group-unread ()
5134 "Get the number of unread articles of the newsgroup on the current line."
5135 (get-text-property (gnus-point-at-bol) 'gnus-unread))
5137 (defun gnus-group-search-forward (&optional backward all level first-too)
5138 "Find the next newsgroup with unread articles.
5139 If BACKWARD is non-nil, find the previous newsgroup instead.
5140 If ALL is non-nil, just find any newsgroup.
5141 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
5143 If FIRST-TOO, the current line is also eligible as a target."
5144 (let ((way (if backward -1 1))
5145 (low gnus-level-killed)
5148 (if (and backward (progn (beginning-of-line)) (bobp))
5150 (or first-too (forward-line way))
5158 (get-text-property (point) 'gnus-unread)))
5159 (and (numberp unread) (> unread 0)))
5160 (setq lev (get-text-property (point)
5162 (<= lev gnus-level-subscribed)))
5164 (and (setq lev (get-text-property (point)
5173 (zerop (forward-line way)))))
5175 (progn (gnus-group-position-point) t)
5176 (goto-char (or pos beg))
5179 ;;; Gnus group mode commands
5183 (defun gnus-group-mark-group (n &optional unmark no-advance)
5184 "Mark the current group."
5186 (let ((buffer-read-only nil)
5190 (when (setq group (gnus-group-group-name))
5194 (or (cdr (assq 'process gnus-group-mark-positions)) 2))
5199 (setq gnus-group-marked (delete group gnus-group-marked)))
5201 (setq gnus-group-marked
5202 (cons group (delete group gnus-group-marked)))))
5203 (or no-advance (gnus-group-next-group 1))
5205 (gnus-summary-position-point)
5208 (defun gnus-group-unmark-group (n)
5209 "Remove the mark from the current group."
5211 (gnus-group-mark-group n 'unmark)
5212 (gnus-group-position-point))
5214 (defun gnus-group-unmark-all-groups ()
5215 "Unmark all groups."
5217 (let ((groups gnus-group-marked))
5220 (gnus-group-remove-mark (pop groups)))))
5221 (gnus-group-position-point))
5223 (defun gnus-group-mark-region (unmark beg end)
5224 "Mark all groups between point and mark.
5225 If UNMARK, remove the mark instead."
5226 (interactive "P\nr")
5227 (let ((num (count-lines beg end)))
5230 (- num (gnus-group-mark-group num unmark)))))
5232 (defun gnus-group-mark-buffer (&optional unmark)
5233 "Mark all groups in the buffer.
5234 If UNMARK, remove the mark instead."
5236 (gnus-group-mark-region unmark (point-min) (point-max)))
5238 (defun gnus-group-mark-regexp (regexp)
5239 "Mark all groups that match some regexp."
5240 (interactive "sMark (regexp): ")
5241 (let ((alist (cdr gnus-newsrc-alist))
5244 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
5245 (gnus-group-set-mark group))))
5246 (gnus-group-position-point))
5248 (defun gnus-group-remove-mark (group)
5249 "Remove the process mark from GROUP and move point there.
5250 Return nil if the group isn't displayed."
5251 (if (gnus-group-goto-group group)
5253 (gnus-group-mark-group 1 'unmark t)
5255 (setq gnus-group-marked
5256 (delete group gnus-group-marked))
5259 (defun gnus-group-set-mark (group)
5260 "Set the process mark on GROUP."
5261 (if (gnus-group-goto-group group)
5263 (gnus-group-mark-group 1 nil t))
5264 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
5266 (defun gnus-group-universal-argument (arg &optional groups func)
5267 "Perform any command on all groups accoring to the process/prefix convention."
5269 (let ((groups (or groups (gnus-group-process-prefix arg)))
5271 (if (eq (setq func (or func
5274 (substitute-command-keys
5275 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
5277 (gnus-error 1 "Undefined key")
5279 (gnus-group-remove-mark (setq group (pop groups)))
5280 (command-execute func))))
5281 (gnus-group-position-point))
5283 (defun gnus-group-process-prefix (n)
5284 "Return a list of groups to work on.
5285 Take into consideration N (the prefix) and the list of marked groups."
5288 (setq n (prefix-numeric-value n))
5289 ;; There is a prefix, so we return a list of the N next
5291 (let ((way (if (< n 0) -1 1))
5296 (setq group (gnus-group-group-name)))
5297 (setq groups (cons group groups))
5299 (gnus-group-next-group way)))
5301 ((and (boundp 'transient-mark-mode)
5303 (boundp 'mark-active)
5305 ;; Work on the region between point and mark.
5306 (let ((max (max (point) (mark)))
5309 (goto-char (min (point) (mark)))
5312 (push (gnus-group-group-name) groups)
5313 (zerop (gnus-group-next-group 1))
5315 (nreverse groups))))
5317 ;; No prefix, but a list of marked articles.
5318 (reverse gnus-group-marked))
5320 ;; Neither marked articles or a prefix, so we return the
5322 (let ((group (gnus-group-group-name)))
5323 (and group (list group))))))
5325 ;; Selecting groups.
5327 (defun gnus-group-read-group (&optional all no-article group)
5328 "Read news in this newsgroup.
5329 If the prefix argument ALL is non-nil, already read articles become
5330 readable. IF ALL is a number, fetch this number of articles. If the
5331 optional argument NO-ARTICLE is non-nil, no article will be
5332 auto-selected upon group entry. If GROUP is non-nil, fetch that
5335 (let ((group (or group (gnus-group-group-name)))
5336 number active marked entry)
5337 (or group (error "No group on current line"))
5338 (setq marked (nth 3 (nth 2 (setq entry (gnus-gethash
5339 group gnus-newsrc-hashtb)))))
5340 ;; This group might be a dead group. In that case we have to get
5341 ;; the number of unread articles from `gnus-active-hashtb'.
5343 (cond ((numberp all) all)
5345 ((setq active (gnus-active group))
5346 (- (1+ (cdr active)) (car active)))))
5347 (gnus-summary-read-group
5348 group (or all (and (numberp number)
5349 (zerop (+ number (length (cdr (assq 'tick marked)))
5350 (length (cdr (assq 'dormant marked)))))))
5353 (defun gnus-group-select-group (&optional all)
5354 "Select this newsgroup.
5355 No article is selected automatically.
5356 If ALL is non-nil, already read articles become readable.
5357 If ALL is a number, fetch this number of articles."
5359 (gnus-group-read-group all t))
5361 (defun gnus-group-quick-select-group (&optional all)
5362 "Select the current group \"quickly\".
5363 This means that no highlighting or scoring will be performed."
5366 gnus-score-find-score-files-function
5367 gnus-apply-kill-hook
5368 gnus-summary-expunge-below)
5369 (gnus-group-read-group all t)))
5371 (defun gnus-group-visible-select-group (&optional all)
5372 "Select the current group without hiding any articles."
5374 (let ((gnus-inhibit-limiting t))
5375 (gnus-group-read-group all t)))
5378 (defun gnus-fetch-group (group)
5379 "Start Gnus if necessary and enter GROUP.
5380 Returns whether the fetching was successful or not."
5381 (interactive "sGroup name: ")
5382 (or (get-buffer gnus-group-buffer)
5384 (gnus-group-read-group nil nil group))
5386 ;; Enter a group that is not in the group buffer. Non-nil is returned
5387 ;; if selection was successful.
5388 (defun gnus-group-read-ephemeral-group
5389 (group method &optional activate quit-config)
5390 (let ((group (if (gnus-group-foreign-p group) group
5391 (gnus-group-prefixed-name group method))))
5394 `(t nil (,group ,gnus-level-default-subscribed nil nil ,method
5395 ((quit-config . ,(if quit-config quit-config
5396 (cons (current-buffer) 'summary))))))
5398 (set-buffer gnus-group-buffer)
5399 (or (gnus-check-server method)
5400 (error "Unable to contact server: %s" (gnus-status-message method)))
5401 (if activate (or (gnus-request-group group)
5402 (error "Couldn't request group")))
5404 (gnus-group-read-group t t group)
5408 (defun gnus-group-jump-to-group (group)
5409 "Jump to newsgroup GROUP."
5411 (list (completing-read
5412 "Group: " gnus-active-hashtb nil
5413 (gnus-read-active-file-p)
5415 'gnus-group-history)))
5417 (when (equal group "")
5418 (error "Empty group name"))
5420 (when (string-match "[\000-\032]" group)
5421 (error "Control characters in group: %s" group))
5423 (let ((b (text-property-any
5424 (point-min) (point-max)
5425 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
5426 (unless (gnus-ephemeral-group-p group)
5428 ;; Either go to the line in the group buffer...
5430 ;; ... or insert the line.
5433 (gnus-activate-group group)
5434 (error "%s error: %s" group (gnus-status-message group)))
5436 (gnus-group-update-group group)
5437 (goto-char (text-property-any
5438 (point-min) (point-max)
5439 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))
5440 ;; Adjust cursor point.
5441 (gnus-group-position-point)))
5443 (defun gnus-group-goto-group (group)
5444 "Goto to newsgroup GROUP."
5446 (let ((b (text-property-any (point-min) (point-max)
5447 'gnus-group (gnus-intern-safe
5448 group gnus-active-hashtb))))
5449 (and b (goto-char b)))))
5451 (defun gnus-group-next-group (n)
5452 "Go to next N'th newsgroup.
5453 If N is negative, search backward instead.
5454 Returns the difference between N and the number of skips actually
5457 (gnus-group-next-unread-group n t))
5459 (defun gnus-group-next-unread-group (n &optional all level)
5460 "Go to next N'th unread newsgroup.
5461 If N is negative, search backward instead.
5462 If ALL is non-nil, choose any newsgroup, unread or not.
5463 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
5464 such group can be found, the next group with a level higher than
5466 Returns the difference between N and the number of skips actually
5469 (let ((backward (< n 0))
5472 (gnus-group-search-forward
5473 backward (or (not gnus-group-goto-unread) all) level))
5475 (if (/= 0 n) (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
5476 (if level " on this level or higher" "")))
5479 (defun gnus-group-prev-group (n)
5480 "Go to previous N'th newsgroup.
5481 Returns the difference between N and the number of skips actually
5484 (gnus-group-next-unread-group (- n) t))
5486 (defun gnus-group-prev-unread-group (n)
5487 "Go to previous N'th unread newsgroup.
5488 Returns the difference between N and the number of skips actually
5491 (gnus-group-next-unread-group (- n)))
5493 (defun gnus-group-next-unread-group-same-level (n)
5494 "Go to next N'th unread newsgroup on the same level.
5495 If N is negative, search backward instead.
5496 Returns the difference between N and the number of skips actually
5499 (gnus-group-next-unread-group n t (gnus-group-group-level))
5500 (gnus-group-position-point))
5502 (defun gnus-group-prev-unread-group-same-level (n)
5503 "Go to next N'th unread newsgroup on the same level.
5504 Returns the difference between N and the number of skips actually
5507 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
5508 (gnus-group-position-point))
5510 (defun gnus-group-best-unread-group (&optional exclude-group)
5511 "Go to the group with the highest level.
5512 If EXCLUDE-GROUP, do not go to that group."
5514 (goto-char (point-min))
5518 (setq unread (get-text-property (point) 'gnus-unread))
5519 (if (and (numberp unread) (> unread 0))
5521 (if (and (get-text-property (point) 'gnus-level)
5522 (< (get-text-property (point) 'gnus-level) best)
5523 (or (not exclude-group)
5524 (not (equal exclude-group (gnus-group-group-name)))))
5526 (setq best (get-text-property (point) 'gnus-level))
5527 (setq best-point (point))))))
5529 (if best-point (goto-char best-point))
5530 (gnus-summary-position-point)
5531 (and best-point (gnus-group-group-name))))
5533 (defun gnus-group-first-unread-group ()
5534 "Go to the first group with unread articles."
5537 (let ((opoint (point))
5539 (goto-char (point-min))
5540 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
5541 (and (numberp unread) ; Not a topic.
5542 (not (zerop unread))) ; Has unread articles.
5543 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
5546 nil)) ; Not success.
5547 (gnus-group-position-point)))
5549 (defun gnus-group-enter-server-mode ()
5550 "Jump to the server buffer."
5552 (gnus-enter-server-buffer))
5554 (defun gnus-group-make-group (name &optional method address)
5555 "Add a new newsgroup.
5556 The user will be prompted for a NAME, for a select METHOD, and an
5560 (read-string "Group name: ")
5563 "Method: " (append gnus-valid-select-methods gnus-server-alist)
5564 nil t nil 'gnus-method-history)))
5565 (cond ((assoc method gnus-valid-select-methods)
5567 (if (memq 'prompt-address
5568 (assoc method gnus-valid-select-methods))
5569 (read-string "Address: ")
5571 ((assoc method gnus-server-alist)
5574 (list method ""))))))
5576 (let* ((meth (and method (if address (list (intern method) address)
5578 (nname (if method (gnus-group-prefixed-name name meth) name))
5580 (when (gnus-gethash nname gnus-newsrc-hashtb)
5581 (error "Group %s already exists" nname))
5582 ;; Subscribe to the new group.
5583 (gnus-group-change-level
5584 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
5585 gnus-level-default-subscribed gnus-level-killed
5586 (and (gnus-group-group-name)
5587 (gnus-gethash (gnus-group-group-name)
5588 gnus-newsrc-hashtb))
5591 (gnus-set-active nname (cons 1 0))
5592 (or (gnus-ephemeral-group-p name)
5594 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")")))
5596 (gnus-group-insert-group-line-info nname)
5598 (gnus-group-position-point)
5600 ;; Load the backend and try to make the backend create
5601 ;; the group as well.
5602 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
5604 gnus-valid-select-methods)
5606 (gnus-check-server meth)
5607 (and (gnus-check-backend-function 'request-create-group nname)
5608 (gnus-request-create-group nname))
5611 (defun gnus-group-delete-group (group &optional force)
5612 "Delete the current group.
5613 If FORCE (the prefix) is non-nil, all the articles in the group will
5614 be deleted. This is \"deleted\" as in \"removed forever from the face
5615 of the Earth\". There is no undo."
5617 (list (gnus-group-group-name)
5618 current-prefix-arg))
5619 (or group (error "No group to rename"))
5620 (or (gnus-check-backend-function 'request-delete-group group)
5621 (error "This backend does not support group deletion"))
5623 (if (not (gnus-yes-or-no-p
5625 "Do you really want to delete %s%s? "
5626 group (if force " and all its contents" ""))))
5628 (gnus-message 6 "Deleting group %s..." group)
5629 (if (not (gnus-request-delete-group group force))
5630 (gnus-error 3 "Couldn't delete group %s" group)
5631 (gnus-message 6 "Deleting group %s...done" group)
5632 (gnus-group-goto-group group)
5633 (gnus-group-kill-group 1 t)
5634 (gnus-sethash group nil gnus-active-hashtb)
5636 (gnus-group-position-point)))
5638 (defun gnus-group-rename-group (group new-name)
5641 (gnus-group-group-name)
5643 (or (gnus-check-backend-function
5644 'request-rename-group (gnus-group-group-name))
5645 (error "This backend does not support renaming groups"))
5646 (read-string "New group name: "))))
5648 (or (gnus-check-backend-function 'request-rename-group group)
5649 (error "This backend does not support renaming groups"))
5651 (or group (error "No group to rename"))
5652 (and (string-match "^[ \t]*$" new-name)
5653 (error "Not a valid group name"))
5655 ;; We find the proper prefixed name.
5657 (gnus-group-prefixed-name
5658 (gnus-group-real-name new-name)
5659 (gnus-info-method (gnus-get-info group))))
5661 (gnus-message 6 "Renaming group %s to %s..." group new-name)
5663 (if (not (gnus-request-rename-group group new-name))
5664 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
5665 ;; We rename the group internally by killing it...
5666 (gnus-group-goto-group group)
5667 (gnus-group-kill-group)
5668 ;; ... changing its name ...
5669 (setcar (cdar gnus-list-of-killed-groups) new-name)
5670 ;; ... and then yanking it. Magic!
5671 (gnus-group-yank-group)
5672 (gnus-set-active new-name (gnus-active group))
5673 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
5675 (gnus-group-position-point)))
5677 (defun gnus-group-edit-group (group &optional part)
5678 "Edit the group on the current line."
5679 (interactive (list (gnus-group-group-name)))
5680 (let* ((part (or part 'info))
5681 (done-func `(lambda ()
5682 "Exit editing mode and update the information."
5684 (gnus-group-edit-group-done ',part ,group)))
5685 (winconf (current-window-configuration))
5687 (or group (error "No group on current line"))
5688 (or (setq info (gnus-get-info group))
5689 (error "Killed group; can't be edited"))
5690 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5691 (gnus-configure-windows 'edit-group)
5692 (gnus-add-current-to-buffer-list)
5694 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
5695 (use-local-map (copy-keymap emacs-lisp-mode-map))
5696 (local-set-key "\C-c\C-c" done-func)
5697 (make-local-variable 'gnus-prev-winconf)
5698 (setq gnus-prev-winconf winconf)
5703 ";; Type `C-c C-c' after editing the select method.\n\n")
5705 ";; Type `C-c C-c' after editing the group parameters.\n\n")
5707 ";; Type `C-c C-c' after editing the group info.\n\n")))
5710 (cond ((eq part 'method)
5711 (or (gnus-info-method info) "native"))
5713 (gnus-info-params info))
5717 (defun gnus-group-edit-group-method (group)
5718 "Edit the select method of GROUP."
5719 (interactive (list (gnus-group-group-name)))
5720 (gnus-group-edit-group group 'method))
5722 (defun gnus-group-edit-group-parameters (group)
5723 "Edit the group parameters of GROUP."
5724 (interactive (list (gnus-group-group-name)))
5725 (gnus-group-edit-group group 'params))
5727 (defun gnus-group-edit-group-done (part group)
5728 "Get info from buffer, update variables and jump to the group buffer."
5729 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5730 (goto-char (point-min))
5731 (let* ((form (read (current-buffer)))
5732 (winconf gnus-prev-winconf)
5733 (method (cond ((eq part 'info) (nth 4 form))
5734 ((eq part 'method) form)
5736 (info (cond ((eq part 'info) form)
5737 ((eq part 'method) (gnus-get-info group))
5740 (if (or (not method)
5742 gnus-select-method method))
5743 (gnus-group-real-name (car info))
5744 (gnus-group-prefixed-name
5745 (gnus-group-real-name (car info)) method))
5747 (when (and new-group
5748 (not (equal new-group group)))
5749 (when (gnus-group-goto-group group)
5750 (gnus-group-kill-group 1))
5751 (gnus-activate-group new-group))
5753 (if (and info new-group)
5755 (setq info (gnus-copy-sequence info))
5756 (setcar info new-group)
5757 (unless (gnus-server-equal method "native")
5758 (unless (nthcdr 3 info)
5759 (nconc info (list nil nil)))
5760 (unless (nthcdr 4 info)
5761 (nconc info (list nil)))
5762 (gnus-info-set-method info method))
5763 (gnus-group-set-info info))
5764 (gnus-group-set-info form (or new-group group) part))
5765 (kill-buffer (current-buffer))
5766 (and winconf (set-window-configuration winconf))
5767 (set-buffer gnus-group-buffer)
5768 (gnus-group-update-group (or new-group group))
5769 (gnus-group-position-point)))
5771 (defun gnus-group-make-help-group ()
5772 "Create the Gnus documentation group."
5774 (let ((path load-path)
5775 (name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
5777 (and (gnus-gethash name gnus-newsrc-hashtb)
5778 (error "Documentation group already exists"))
5780 (setq dir (file-name-as-directory (expand-file-name (pop path)))
5782 (when (or (file-exists-p (setq file (concat dir "gnus-tut.txt")))
5784 (setq file (concat (file-name-directory
5785 (directory-file-name dir))
5786 "etc/gnus-tut.txt"))))
5789 (gnus-message 1 "Couldn't find doc group")
5790 (gnus-group-make-group
5791 (gnus-group-real-name name)
5792 (list 'nndoc "gnus-help"
5793 (list 'nndoc-address file)
5794 (list 'nndoc-article-type 'mbox)))))
5795 (gnus-group-position-point))
5797 (defun gnus-group-make-doc-group (file type)
5798 "Create a group that uses a single file as the source."
5800 (list (read-file-name "File name: ")
5801 (and current-prefix-arg 'ask)))
5802 (when (eq type 'ask)
5807 "%sFile type (mbox, babyl, digest, forward, mmfd, guess) [mbdfag]: "
5809 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
5810 ((= char ?b) 'babyl)
5811 ((= char ?d) 'digest)
5812 ((= char ?f) 'forward)
5814 (t (setq err (format "%c unknown. " char))
5817 (let* ((file (expand-file-name file))
5818 (name (gnus-generate-new-group-name
5819 (gnus-group-prefixed-name
5820 (file-name-nondirectory file) '(nndoc "")))))
5821 (gnus-group-make-group
5822 (gnus-group-real-name name)
5823 (list 'nndoc (file-name-nondirectory file)
5824 (list 'nndoc-address file)
5825 (list 'nndoc-article-type (or type 'guess))))))
5827 (defun gnus-group-make-archive-group (&optional all)
5828 "Create the (ding) Gnus archive group of the most recent articles.
5829 Given a prefix, create a full group."
5831 (let ((group (gnus-group-prefixed-name
5832 (if all "ding.archives" "ding.recent") '(nndir ""))))
5833 (and (gnus-gethash group gnus-newsrc-hashtb)
5834 (error "Archive group already exists"))
5835 (gnus-group-make-group
5836 (gnus-group-real-name group)
5837 (list 'nndir (if all "hpc" "edu")
5838 (list 'nndir-directory
5839 (if all gnus-group-archive-directory
5840 gnus-group-recent-archive-directory))))))
5842 (defun gnus-group-make-directory-group (dir)
5843 "Create an nndir group.
5844 The user will be prompted for a directory. The contents of this
5845 directory will be used as a newsgroup. The directory should contain
5846 mail messages or news articles in files that have numeric names."
5848 (list (read-file-name "Create group from directory: ")))
5849 (or (file-exists-p dir) (error "No such directory"))
5850 (or (file-directory-p dir) (error "Not a directory"))
5854 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
5856 (gnus-group-prefixed-name
5857 (concat (file-name-as-directory (directory-file-name dir))
5860 (setq ext (format "<%d>" (setq i (1+ i)))))
5861 (gnus-group-make-group
5862 (gnus-group-real-name group)
5863 (list 'nndir group (list 'nndir-directory dir)))))
5865 (defun gnus-group-make-kiboze-group (group address scores)
5866 "Create an nnkiboze group.
5867 The user will be prompted for a name, a regexp to match groups, and
5868 score file entries for articles to include in the group."
5871 (read-string "nnkiboze group name: ")
5872 (read-string "Source groups (regexp): ")
5873 (let ((headers (mapcar (lambda (group) (list group))
5874 '("subject" "from" "number" "date" "message-id"
5875 "references" "chars" "lines" "xref"
5876 "followup" "all" "body" "head")))
5877 scores header regexp regexps)
5878 (while (not (equal "" (setq header (completing-read
5879 "Match on header: " headers nil t))))
5881 (while (not (equal "" (setq regexp (read-string
5882 (format "Match on %s (string): "
5884 (setq regexps (cons (list regexp nil nil 'r) regexps)))
5885 (setq scores (cons (cons header regexps) scores)))
5887 (gnus-group-make-group group "nnkiboze" address)
5888 (nnheader-temp-write (gnus-score-file-name (concat "nnkiboze:" group))
5889 (let (emacs-lisp-mode-hook)
5890 (pp scores (current-buffer)))))
5892 (defun gnus-group-add-to-virtual (n vgroup)
5893 "Add the current group to a virtual group."
5895 (list current-prefix-arg
5896 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
5898 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
5899 (error "%s is not an nnvirtual group" vgroup))
5900 (let* ((groups (gnus-group-process-prefix n))
5901 (method (gnus-info-method (gnus-get-info vgroup))))
5902 (setcar (cdr method)
5904 (nth 1 method) "\\|"
5907 (gnus-group-remove-mark s)
5908 (concat "\\(^" (regexp-quote s) "$\\)"))
5910 (gnus-group-position-point))
5912 (defun gnus-group-make-empty-virtual (group)
5913 "Create a new, fresh, empty virtual group."
5914 (interactive "sCreate new, empty virtual group: ")
5915 (let* ((method (list 'nnvirtual "^$"))
5916 (pgroup (gnus-group-prefixed-name group method)))
5917 ;; Check whether it exists already.
5918 (and (gnus-gethash pgroup gnus-newsrc-hashtb)
5919 (error "Group %s already exists." pgroup))
5920 ;; Subscribe the new group after the group on the current line.
5921 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
5922 (gnus-group-update-group pgroup)
5924 (gnus-group-position-point)))
5926 (defun gnus-group-enter-directory (dir)
5927 "Enter an ephemeral nneething group."
5928 (interactive "DDirectory to read: ")
5929 (let* ((method (list 'nneething dir))
5930 (leaf (gnus-group-prefixed-name
5931 (file-name-nondirectory (directory-file-name dir))
5933 (name (gnus-generate-new-group-name leaf)))
5934 (let ((nneething-read-only t))
5935 (or (gnus-group-read-ephemeral-group
5937 (cons (current-buffer) (if (eq major-mode 'gnus-summary-mode)
5939 (error "Couldn't enter %s" dir)))))
5941 ;; Group sorting commands
5942 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
5944 (defun gnus-group-sort-groups (func &optional reverse)
5945 "Sort the group buffer according to FUNC.
5946 If REVERSE, reverse the sorting order."
5947 (interactive (list gnus-group-sort-function
5948 current-prefix-arg))
5950 ((not (listp func)) func)
5952 ((= 1 (length func)) (car func))
5954 ,(gnus-make-sort-function
5955 (reverse func)))))))
5956 ;; We peel off the dummy group from the alist.
5958 (when (equal (car (gnus-info-group gnus-newsrc-alist)) "dummy.group")
5959 (pop gnus-newsrc-alist))
5961 (setq gnus-newsrc-alist
5962 (sort gnus-newsrc-alist func))
5964 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
5965 ;; Regenerate the hash table.
5966 (gnus-make-hashtable-from-newsrc-alist)
5967 (gnus-group-list-groups))))
5969 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
5970 "Sort the group buffer alphabetically by group name.
5971 If REVERSE, sort in reverse order."
5973 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
5975 (defun gnus-group-sort-groups-by-unread (&optional reverse)
5976 "Sort the group buffer by number of unread articles.
5977 If REVERSE, sort in reverse order."
5979 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
5981 (defun gnus-group-sort-groups-by-level (&optional reverse)
5982 "Sort the group buffer by group level.
5983 If REVERSE, sort in reverse order."
5985 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
5987 (defun gnus-group-sort-groups-by-score (&optional reverse)
5988 "Sort the group buffer by group score.
5989 If REVERSE, sort in reverse order."
5991 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
5993 (defun gnus-group-sort-groups-by-rank (&optional reverse)
5994 "Sort the group buffer by group rank.
5995 If REVERSE, sort in reverse order."
5997 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
5999 (defun gnus-group-sort-groups-by-method (&optional reverse)
6000 "Sort the group buffer alphabetically by backend name.
6001 If REVERSE, sort in reverse order."
6003 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
6005 (defun gnus-group-sort-by-alphabet (info1 info2)
6006 "Sort alphabetically."
6007 (string< (gnus-info-group info1) (gnus-info-group info2)))
6009 (defun gnus-group-sort-by-unread (info1 info2)
6010 "Sort by number of unread articles."
6011 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
6012 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
6013 (< (or (and (numberp n1) n1) 0)
6014 (or (and (numberp n2) n2) 0))))
6016 (defun gnus-group-sort-by-level (info1 info2)
6018 (< (gnus-info-level info1) (gnus-info-level info2)))
6020 (defun gnus-group-sort-by-method (info1 info2)
6021 "Sort alphabetically by backend name."
6022 (string< (symbol-name (car (gnus-find-method-for-group
6023 (gnus-info-group info1) info1)))
6024 (symbol-name (car (gnus-find-method-for-group
6025 (gnus-info-group info2) info2)))))
6027 (defun gnus-group-sort-by-score (info1 info2)
6028 "Sort by group score."
6029 (< (gnus-info-score info1) (gnus-info-score info2)))
6031 (defun gnus-group-sort-by-rank (info1 info2)
6032 "Sort by level and score."
6033 (let ((level1 (gnus-info-level info1))
6034 (level2 (gnus-info-level info2)))
6035 (or (< level1 level2)
6036 (and (= level1 level2)
6037 (> (gnus-info-score info1) (gnus-info-score info2))))))
6039 ;; Group catching up.
6041 (defun gnus-group-clear-data (n)
6042 "Clear all marks and read ranges from the current group."
6044 (let ((groups (gnus-group-process-prefix n))
6046 (while (setq group (pop groups))
6047 (setq info (gnus-get-info group))
6048 (gnus-info-set-read info nil)
6049 (when (gnus-info-marks info)
6050 (gnus-info-set-marks info nil))
6051 (gnus-get-unread-articles-in-group info (gnus-active group) t)
6052 (when (gnus-group-goto-group group)
6053 (gnus-group-remove-mark group)
6054 (gnus-group-update-group-line)))))
6056 (defun gnus-group-catchup-current (&optional n all)
6057 "Mark all articles not marked as unread in current newsgroup as read.
6058 If prefix argument N is numeric, the ARG next newsgroups will be
6059 caught up. If ALL is non-nil, marked articles will also be marked as
6060 read. Cross references (Xref: header) of articles are ignored.
6061 The difference between N and actual number of newsgroups that were
6062 caught up is returned."
6064 (unless (gnus-group-group-name)
6065 (error "No group on the current line"))
6066 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
6070 "Do you really want to mark all articles as read? "
6071 "Mark all unread articles as read? "))))
6073 (let ((groups (gnus-group-process-prefix n))
6076 ;; Virtual groups have to be given special treatment.
6077 (let ((method (gnus-find-method-for-group (car groups))))
6078 (if (eq 'nnvirtual (car method))
6079 (nnvirtual-catchup-group
6080 (gnus-group-real-name (car groups)) (nth 1 method) all)))
6081 (gnus-group-remove-mark (car groups))
6082 (if (>= (gnus-group-group-level) gnus-level-zombie)
6083 (gnus-message 2 "Dead groups can't be caught up")
6085 (gnus-group-goto-group (car groups))
6086 (gnus-group-catchup (car groups) all))
6087 (gnus-group-update-group-line)
6088 (setq ret (1+ ret))))
6089 (setq groups (cdr groups)))
6090 (gnus-group-next-unread-group 1)
6093 (defun gnus-group-catchup-current-all (&optional n)
6094 "Mark all articles in current newsgroup as read.
6095 Cross references (Xref: header) of articles are ignored."
6097 (gnus-group-catchup-current n 'all))
6099 (defun gnus-group-catchup (group &optional all)
6100 "Mark all articles in GROUP as read.
6101 If ALL is non-nil, all articles are marked as read.
6102 The return value is the number of articles that were marked as read,
6103 or nil if no action could be taken."
6104 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
6106 ;; Do the updating only if the newsgroup isn't killed.
6107 (if (not (numberp (car entry)))
6108 (gnus-message 1 "Can't catch up; non-active group")
6109 ;; Do auto-expirable marks if that's required.
6110 (when (gnus-group-auto-expirable-p group)
6111 (gnus-add-marked-articles
6112 group 'expire (gnus-list-of-unread-articles group))
6114 (let ((marks (nth 3 (nth 2 entry))))
6115 (gnus-add-marked-articles
6116 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))
6117 (gnus-add-marked-articles
6118 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))))))
6120 (gnus-update-read-articles group nil)
6121 ;; Also nix out the lists of marks and dormants.
6123 (gnus-add-marked-articles group 'tick nil nil 'force)
6124 (gnus-add-marked-articles group 'dormant nil nil 'force))
6125 (run-hooks 'gnus-group-catchup-group-hook)
6128 (defun gnus-group-expire-articles (&optional n)
6129 "Expire all expirable articles in the current newsgroup."
6131 (let ((groups (gnus-group-process-prefix n))
6134 (error "No groups to expire"))
6135 (while (setq group (pop groups))
6136 (gnus-group-remove-mark group)
6137 (when (gnus-check-backend-function 'request-expire-articles group)
6138 (gnus-message 6 "Expiring articles in %s..." group)
6139 (let* ((info (gnus-get-info group))
6140 (expirable (if (gnus-group-total-expirable-p group)
6141 (cons nil (gnus-list-of-read-articles group))
6142 (assq 'expire (gnus-info-marks info))))
6143 (expiry-wait (gnus-group-get-parameter group 'expiry-wait)))
6147 (gnus-compress-sequence
6149 ;; We set the expiry variables to the groupp
6151 (let ((nnmail-expiry-wait-function nil)
6152 (nnmail-expiry-wait expiry-wait))
6153 (gnus-request-expire-articles
6154 (gnus-uncompress-sequence (cdr expirable)) group))
6155 ;; Just expire using the normal expiry values.
6156 (gnus-request-expire-articles
6157 (gnus-uncompress-sequence (cdr expirable)) group)))))
6158 (gnus-message 6 "Expiring articles in %s...done" group)))
6159 (gnus-group-position-point))))
6161 (defun gnus-group-expire-all-groups ()
6162 "Expire all expirable articles in all newsgroups."
6165 (gnus-message 5 "Expiring...")
6166 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
6167 (cdr gnus-newsrc-alist))))
6168 (gnus-group-expire-articles nil)))
6169 (gnus-group-position-point)
6170 (gnus-message 5 "Expiring...done"))
6172 (defun gnus-group-set-current-level (n level)
6173 "Set the level of the next N groups to LEVEL."
6178 (let ((s (read-string
6179 (format "Level (default %s): "
6180 (or (gnus-group-group-level)
6181 gnus-level-default-subscribed)))))
6182 (if (string-match "^\\s-*$" s)
6183 (int-to-string (or (gnus-group-group-level)
6184 gnus-level-default-subscribed))
6186 (or (and (>= level 1) (<= level gnus-level-killed))
6187 (error "Illegal level: %d" level))
6188 (let ((groups (gnus-group-process-prefix n))
6190 (while (setq group (pop groups))
6191 (gnus-group-remove-mark group)
6192 (gnus-message 6 "Changed level of %s from %d to %d"
6193 group (or (gnus-group-group-level) gnus-level-killed)
6195 (gnus-group-change-level
6196 group level (or (gnus-group-group-level) gnus-level-killed))
6197 (gnus-group-update-group-line)))
6198 (gnus-group-position-point))
6200 (defun gnus-group-unsubscribe-current-group (&optional n)
6201 "Toggle subscription of the current group.
6202 If given numerical prefix, toggle the N next groups."
6204 (let ((groups (gnus-group-process-prefix n))
6207 (setq group (car groups)
6208 groups (cdr groups))
6209 (gnus-group-remove-mark group)
6210 (gnus-group-unsubscribe-group
6211 group (if (<= (gnus-group-group-level) gnus-level-subscribed)
6212 gnus-level-default-unsubscribed
6213 gnus-level-default-subscribed) t)
6214 (gnus-group-update-group-line))
6215 (gnus-group-next-group 1)))
6217 (defun gnus-group-unsubscribe-group (group &optional level silent)
6218 "Toggle subscription to GROUP.
6219 Killed newsgroups are subscribed. If SILENT, don't try to update the
6222 (list (completing-read
6223 "Group: " gnus-active-hashtb nil
6224 (gnus-read-active-file-p)
6226 'gnus-group-history)))
6227 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
6229 ((string-match "^[ \t]$" group)
6230 (error "Empty group name"))
6232 ;; Toggle subscription flag.
6233 (gnus-group-change-level
6234 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
6235 gnus-level-subscribed)
6236 (1+ gnus-level-subscribed)
6237 gnus-level-default-subscribed)))
6239 (gnus-group-update-group group)))
6240 ((and (stringp group)
6241 (or (not (gnus-read-active-file-p))
6242 (gnus-active group)))
6243 ;; Add new newsgroup.
6244 (gnus-group-change-level
6246 (if level level gnus-level-default-subscribed)
6247 (or (and (member group gnus-zombie-list)
6250 (and (gnus-group-group-name)
6251 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
6253 (gnus-group-update-group group)))
6254 (t (error "No such newsgroup: %s" group)))
6255 (gnus-group-position-point)))
6257 (defun gnus-group-transpose-groups (n)
6258 "Move the current newsgroup up N places.
6259 If given a negative prefix, move down instead. The difference between
6260 N and the number of steps taken is returned."
6262 (or (gnus-group-group-name)
6263 (error "No group on current line"))
6264 (gnus-group-kill-group 1)
6266 (forward-line (- n))
6267 (gnus-group-yank-group)
6268 (gnus-group-position-point)))
6270 (defun gnus-group-kill-all-zombies ()
6271 "Kill all zombie newsgroups."
6273 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
6274 (setq gnus-zombie-list nil)
6275 (gnus-group-list-groups))
6277 (defun gnus-group-kill-region (begin end)
6278 "Kill newsgroups in current region (excluding current point).
6279 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
6294 (beginning-of-line) ;Important when LINES < 1
6295 (gnus-group-kill-group lines)))
6297 (defun gnus-group-kill-group (&optional n discard)
6298 "Kill the next N groups.
6299 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
6300 However, only groups that were alive can be yanked; already killed
6301 groups or zombie groups can't be yanked.
6302 The return value is the name of the group that was killed, or a list
6305 (let ((buffer-read-only nil)
6306 (groups (gnus-group-process-prefix n))
6307 group entry level out)
6308 (if (< (length groups) 10)
6309 ;; This is faster when there are few groups.
6311 (push (setq group (pop groups)) out)
6312 (gnus-group-remove-mark group)
6313 (setq level (gnus-group-group-level))
6315 (when (and (not discard)
6316 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
6317 (push (cons (car entry) (nth 2 entry))
6318 gnus-list-of-killed-groups))
6319 (gnus-group-change-level
6320 (if entry entry group) gnus-level-killed (if entry nil level)))
6321 ;; If there are lots and lots of groups to be killed, we use
6322 ;; this thing instead.
6324 (setq groups (nreverse groups))
6326 (gnus-group-remove-mark (setq group (pop groups)))
6328 (push group gnus-killed-list)
6329 (setq gnus-newsrc-alist
6330 (delq (assoc group gnus-newsrc-alist)
6332 (when gnus-group-change-level-function
6333 (funcall gnus-group-change-level-function group 9 3))
6335 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
6336 (push (cons (car entry) (nth 2 entry))
6337 gnus-list-of-killed-groups)
6338 (setcdr (cdr entry) (cdddr entry)))
6339 ((member group gnus-zombie-list)
6340 (setq gnus-zombie-list (delete group gnus-zombie-list)))))
6341 (gnus-make-hashtable-from-newsrc-alist)))
6343 (gnus-group-position-point)
6344 (if (< (length out) 2) (car out) (nreverse out))))
6346 (defun gnus-group-yank-group (&optional arg)
6347 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
6348 inserting it before the current newsgroup. The numeric ARG specifies
6349 how many newsgroups are to be yanked. The name of the newsgroup yanked
6350 is returned, or (if several groups are yanked) a list of yanked groups
6353 (setq arg (or arg 1))
6354 (let (info group prev out)
6355 (while (>= (decf arg) 0)
6356 (if (not (setq info (pop gnus-list-of-killed-groups)))
6357 (error "No more newsgroups to yank"))
6358 (push (setq group (nth 1 info)) out)
6359 ;; Find which newsgroup to insert this one before - search
6360 ;; backward until something suitable is found. If there are no
6361 ;; other newsgroups in this buffer, just make this newsgroup the
6363 (setq prev (gnus-group-group-name))
6364 (gnus-group-change-level
6365 info (gnus-info-level (cdr info)) gnus-level-killed
6366 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
6368 (gnus-group-insert-group-line-info group))
6370 (gnus-group-position-point)
6371 (if (< (length out) 2) (car out) (nreverse out))))
6373 (defun gnus-group-kill-level (level)
6374 "Kill all groups that is on a certain LEVEL."
6375 (interactive "nKill all groups on level: ")
6377 ((= level gnus-level-zombie)
6378 (setq gnus-killed-list
6379 (nconc gnus-zombie-list gnus-killed-list))
6380 (setq gnus-zombie-list nil))
6381 ((and (< level gnus-level-zombie)
6383 (or gnus-expert-user
6386 "Do you really want to kill all groups on level %d? "
6388 (let* ((prev gnus-newsrc-alist)
6391 (if (= (gnus-info-level level) level)
6392 (setcdr prev (cdr alist))
6394 (setq alist (cdr alist)))
6395 (gnus-make-hashtable-from-newsrc-alist)
6396 (gnus-group-list-groups)))
6398 (error "Can't kill; illegal level: %d" level))))
6400 (defun gnus-group-list-all-groups (&optional arg)
6401 "List all newsgroups with level ARG or lower.
6402 Default is gnus-level-unsubscribed, which lists all subscribed and most
6403 unsubscribed groups."
6405 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
6407 ;; Redefine this to list ALL killed groups if prefix arg used.
6408 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
6409 (defun gnus-group-list-killed (&optional arg)
6410 "List all killed newsgroups in the group buffer.
6411 If ARG is non-nil, list ALL killed groups known to Gnus. This may
6412 entail asking the server for the groups."
6414 ;; Find all possible killed newsgroups if arg.
6416 (gnus-get-killed-groups))
6417 (if (not gnus-killed-list)
6418 (gnus-message 6 "No killed groups")
6419 (let (gnus-group-list-mode)
6420 (funcall gnus-group-prepare-function
6421 gnus-level-killed t gnus-level-killed))
6422 (goto-char (point-min)))
6423 (gnus-group-position-point))
6425 (defun gnus-group-list-zombies ()
6426 "List all zombie newsgroups in the group buffer."
6428 (if (not gnus-zombie-list)
6429 (gnus-message 6 "No zombie groups")
6430 (let (gnus-group-list-mode)
6431 (funcall gnus-group-prepare-function
6432 gnus-level-zombie t gnus-level-zombie))
6433 (goto-char (point-min)))
6434 (gnus-group-position-point))
6436 (defun gnus-group-list-active ()
6437 "List all groups that are available from the server(s)."
6439 ;; First we make sure that we have really read the active file.
6440 (unless (gnus-read-active-file-p)
6441 (let ((gnus-read-active-file t))
6442 (gnus-read-active-file)))
6443 ;; Find all groups and sort them.
6451 (setq list (cons (symbol-name sym) list))))
6455 (buffer-read-only nil))
6458 (gnus-group-insert-group-line-info (pop groups)))
6459 (goto-char (point-min))))
6461 (defun gnus-activate-all-groups (level)
6462 "Activate absolutely all groups."
6463 (interactive (list 7))
6464 (let ((gnus-activate-level level)
6465 (gnus-activate-foreign-newsgroups level))
6466 (gnus-group-get-new-news)))
6468 (defun gnus-group-get-new-news (&optional arg)
6469 "Get newly arrived articles.
6470 If ARG is a number, it specifies which levels you are interested in
6471 re-scanning. If ARG is non-nil and not a number, this will force
6472 \"hard\" re-reading of the active files from all servers."
6474 (run-hooks 'gnus-get-new-news-hook)
6475 ;; We might read in new NoCeM messages here.
6476 (when (and gnus-use-nocem
6478 (gnus-nocem-scan-groups))
6479 ;; If ARG is not a number, then we read the active file.
6480 (when (and arg (not (numberp arg)))
6481 (let ((gnus-read-active-file t))
6482 (gnus-read-active-file))
6485 (setq arg (gnus-group-default-level arg t))
6486 (if (and gnus-read-active-file (not arg))
6488 (gnus-read-active-file)
6489 (gnus-get-unread-articles arg))
6490 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
6491 (gnus-get-unread-articles arg)))
6492 (run-hooks 'gnus-after-getting-new-news-hook)
6493 (gnus-group-list-groups))
6495 (defun gnus-group-get-new-news-this-group (&optional n)
6496 "Check for newly arrived news in the current group (and the N-1 next groups).
6497 The difference between N and the number of newsgroup checked is returned.
6498 If N is negative, this group and the N-1 previous groups will be checked."
6500 (let* ((groups (gnus-group-process-prefix n))
6501 (ret (if (numberp n) (- n (length groups)) 0))
6502 (beg (unless n (point)))
6504 (while (setq group (pop groups))
6505 (gnus-group-remove-mark group)
6506 (if (gnus-activate-group group 'scan)
6508 (gnus-get-unread-articles-in-group
6509 (gnus-get-info group) (gnus-active group) t)
6510 (unless (gnus-virtual-group-p group)
6511 (gnus-close-group group))
6512 (gnus-group-update-group group))
6513 (gnus-error 3 "%s error: %s" group (gnus-status-message group))))
6514 (when beg (goto-char beg))
6515 (when gnus-goto-next-group-when-activating
6516 (gnus-group-next-unread-group 1 t))
6517 (gnus-summary-position-point)
6520 (defun gnus-group-fetch-faq (group &optional faq-dir)
6521 "Fetch the FAQ for the current group."
6524 (and (gnus-group-group-name)
6525 (gnus-group-real-name (gnus-group-group-name)))
6526 (cond (current-prefix-arg
6528 "Faq dir: " (and (listp gnus-group-faq-directory)
6529 (mapcar (lambda (file) (list file))
6530 gnus-group-faq-directory)))))))
6532 (setq faq-dir (if (listp gnus-group-faq-directory)
6533 (car gnus-group-faq-directory)
6534 gnus-group-faq-directory)))
6535 (or group (error "No group name given"))
6536 (let ((file (concat (file-name-as-directory faq-dir)
6537 (gnus-group-real-name group))))
6538 (if (not (file-exists-p file))
6539 (error "No such file: %s" file)
6542 (defun gnus-group-describe-group (force &optional group)
6543 "Display a description of the current newsgroup."
6544 (interactive (list current-prefix-arg (gnus-group-group-name)))
6545 (and force (setq gnus-description-hashtb nil))
6546 (let ((method (gnus-find-method-for-group group))
6548 (or group (error "No group name given"))
6549 (and (or (and gnus-description-hashtb
6550 ;; We check whether this group's method has been
6551 ;; queried for a description file.
6553 (gnus-group-prefixed-name "" method)
6554 gnus-description-hashtb))
6555 (setq desc (gnus-group-get-description group))
6556 (gnus-read-descriptions-file method))
6558 (or desc (gnus-gethash group gnus-description-hashtb)
6559 "No description available")))))
6561 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6562 (defun gnus-group-describe-all-groups (&optional force)
6563 "Pop up a buffer with descriptions of all newsgroups."
6565 (and force (setq gnus-description-hashtb nil))
6566 (if (not (or gnus-description-hashtb
6567 (gnus-read-all-descriptions-files)))
6568 (error "Couldn't request descriptions file"))
6569 (let ((buffer-read-only nil)
6575 (insert (format " *: %-20s %s\n" (symbol-name group)
6576 (symbol-value group)))
6577 (gnus-add-text-properties
6578 b (1+ b) (list 'gnus-group group
6579 'gnus-unread t 'gnus-marked nil
6580 'gnus-level (1+ gnus-level-subscribed))))
6581 gnus-description-hashtb)
6582 (goto-char (point-min))
6583 (gnus-group-position-point)))
6585 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
6586 (defun gnus-group-apropos (regexp &optional search-description)
6587 "List all newsgroups that have names that match a regexp."
6588 (interactive "sGnus apropos (regexp): ")
6590 (obuf (current-buffer))
6592 ;; Go through all newsgroups that are known to Gnus.
6595 (and (symbol-name group)
6596 (string-match regexp (symbol-name group))
6597 (setq groups (cons (symbol-name group) groups))))
6599 ;; Also go through all descriptions that are known to Gnus.
6600 (when search-description
6603 (and (string-match regexp (symbol-value group))
6604 (gnus-active (symbol-name group))
6605 (setq groups (cons (symbol-name group) groups))))
6606 gnus-description-hashtb))
6608 (gnus-message 3 "No groups matched \"%s\"." regexp)
6609 ;; Print out all the groups.
6611 (pop-to-buffer "*Gnus Help*")
6612 (buffer-disable-undo (current-buffer))
6614 (setq groups (sort groups 'string<))
6616 ;; Groups may be entered twice into the list of groups.
6617 (if (not (string= (car groups) prev))
6619 (insert (setq prev (car groups)) "\n")
6620 (if (and gnus-description-hashtb
6621 (setq des (gnus-gethash (car groups)
6622 gnus-description-hashtb)))
6623 (insert " " des "\n"))))
6624 (setq groups (cdr groups)))
6625 (goto-char (point-min))))
6626 (pop-to-buffer obuf)))
6628 (defun gnus-group-description-apropos (regexp)
6629 "List all newsgroups that have names or descriptions that match a regexp."
6630 (interactive "sGnus description apropos (regexp): ")
6631 (if (not (or gnus-description-hashtb
6632 (gnus-read-all-descriptions-files)))
6633 (error "Couldn't request descriptions file"))
6634 (gnus-group-apropos regexp t))
6636 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6637 (defun gnus-group-list-matching (level regexp &optional all lowest)
6638 "List all groups with unread articles that match REGEXP.
6639 If the prefix LEVEL is non-nil, it should be a number that says which
6640 level to cut off listing groups.
6641 If ALL, also list groups with no unread articles.
6642 If LOWEST, don't list groups with level lower than LOWEST.
6644 This command may read the active file."
6645 (interactive "P\nsList newsgroups matching: ")
6646 ;; First make sure active file has been read.
6648 (> (prefix-numeric-value level) gnus-level-killed))
6649 (gnus-get-killed-groups))
6650 (gnus-group-prepare-flat (or level gnus-level-subscribed)
6651 all (or lowest 1) regexp)
6652 (goto-char (point-min))
6653 (gnus-group-position-point))
6655 (defun gnus-group-list-all-matching (level regexp &optional lowest)
6656 "List all groups that match REGEXP.
6657 If the prefix LEVEL is non-nil, it should be a number that says which
6658 level to cut off listing groups.
6659 If LOWEST, don't list groups with level lower than LOWEST."
6660 (interactive "P\nsList newsgroups matching: ")
6661 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
6663 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
6664 (defun gnus-group-save-newsrc (&optional force)
6665 "Save the Gnus startup files.
6666 If FORCE, force saving whether it is necessary or not."
6668 (gnus-save-newsrc-file force))
6670 (defun gnus-group-restart (&optional arg)
6671 "Force Gnus to read the .newsrc file."
6673 (when (gnus-yes-or-no-p
6674 (format "Are you sure you want to read %s? "
6675 gnus-current-startup-file))
6676 (gnus-save-newsrc-file)
6677 (gnus-setup-news 'force)
6678 (gnus-group-list-groups arg)))
6680 (defun gnus-group-read-init-file ()
6681 "Read the Gnus elisp init file."
6683 (gnus-read-init-file))
6685 (defun gnus-group-check-bogus-groups (&optional silent)
6686 "Check bogus newsgroups.
6687 If given a prefix, don't ask for confirmation before removing a bogus
6690 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
6691 (gnus-group-list-groups))
6693 (defun gnus-group-edit-global-kill (&optional article group)
6694 "Edit the global kill file.
6695 If GROUP, edit that local kill file instead."
6697 (setq gnus-current-kill-article article)
6698 (gnus-kill-file-edit-file group)
6701 (substitute-command-keys
6702 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
6703 (if group "local" "global")))))
6705 (defun gnus-group-edit-local-kill (article group)
6706 "Edit a local kill file."
6707 (interactive (list nil (gnus-group-group-name)))
6708 (gnus-group-edit-global-kill article group))
6710 (defun gnus-group-force-update ()
6711 "Update `.newsrc' file."
6713 (gnus-save-newsrc-file))
6715 (defun gnus-group-suspend ()
6716 "Suspend the current Gnus session.
6717 In fact, cleanup buffers except for group mode buffer.
6718 The hook gnus-suspend-gnus-hook is called before actually suspending."
6720 (run-hooks 'gnus-suspend-gnus-hook)
6721 ;; Kill Gnus buffers except for group mode buffer.
6722 (let ((group-buf (get-buffer gnus-group-buffer)))
6723 ;; Do this on a separate list in case the user does a ^G before we finish
6724 (let ((gnus-buffer-list
6725 (delq group-buf (delq gnus-dribble-buffer
6726 (append gnus-buffer-list nil)))))
6727 (while gnus-buffer-list
6728 (gnus-kill-buffer (car gnus-buffer-list))
6729 (setq gnus-buffer-list (cdr gnus-buffer-list))))
6732 (setq gnus-buffer-list (list group-buf))
6733 (bury-buffer group-buf)
6734 (delete-windows-on group-buf t)))))
6736 (defun gnus-group-clear-dribble ()
6737 "Clear all information from the dribble buffer."
6739 (gnus-dribble-clear)
6740 (gnus-message 7 "Cleared dribble buffer"))
6742 (defun gnus-group-exit ()
6743 "Quit reading news after updating .newsrc.eld and .newsrc.
6744 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6747 (or noninteractive ;For gnus-batch-kill
6748 (not gnus-interactive-exit) ;Without confirmation
6750 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
6751 (run-hooks 'gnus-exit-gnus-hook)
6752 ;; Offer to save data from non-quitted summary buffers.
6753 (gnus-offer-save-summaries)
6754 ;; Save the newsrc file(s).
6755 (gnus-save-newsrc-file)
6757 (gnus-close-backends)
6758 ;; Reset everything.
6760 ;; Allow the user to do things after cleaning up.
6761 (run-hooks 'gnus-after-exiting-gnus-hook)))
6763 (defun gnus-close-backends ()
6764 ;; Send a close request to all backends that support such a request.
6765 (let ((methods gnus-valid-select-methods)
6768 (if (fboundp (setq func (intern (concat (caar methods)
6769 "-request-close"))))
6771 (setq methods (cdr methods)))))
6773 (defun gnus-group-quit ()
6774 "Quit reading news without updating .newsrc.eld or .newsrc.
6775 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6777 (when (or noninteractive ;For gnus-batch-kill
6778 (zerop (buffer-size))
6779 (not (gnus-server-opened gnus-select-method))
6781 (not gnus-current-startup-file)
6783 (format "Quit reading news without saving %s? "
6784 (file-name-nondirectory gnus-current-startup-file))))
6785 (run-hooks 'gnus-exit-gnus-hook)
6786 (if gnus-use-full-window
6787 (delete-other-windows)
6788 (gnus-remove-some-windows))
6790 (gnus-close-backends)
6792 ;; Allow the user to do things after cleaning up.
6793 (run-hooks 'gnus-after-exiting-gnus-hook)))
6795 (defun gnus-offer-save-summaries ()
6796 "Offer to save all active summary buffers."
6798 (let ((buflist (buffer-list))
6800 ;; Go through all buffers and find all summaries.
6802 (and (setq bufname (buffer-name (car buflist)))
6803 (string-match "Summary" bufname)
6805 (set-buffer bufname)
6806 ;; We check that this is, indeed, a summary buffer.
6807 (and (eq major-mode 'gnus-summary-mode)
6808 ;; Also make sure this isn't bogus.
6809 gnus-newsgroup-prepared))
6810 (push bufname buffers))
6811 (setq buflist (cdr buflist)))
6812 ;; Go through all these summary buffers and offer to save them.
6815 "Update summary buffer %s? "
6816 (lambda (buf) (set-buffer buf) (gnus-summary-exit))
6819 (defun gnus-group-describe-briefly ()
6820 "Give a one line description of the group mode commands."
6822 (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")))
6824 (defun gnus-group-browse-foreign-server (method)
6825 "Browse a foreign news server.
6826 If called interactively, this function will ask for a select method
6827 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
6828 If not, METHOD should be a list where the first element is the method
6829 and the second element is the address."
6831 (list (let ((how (completing-read
6833 (append gnus-valid-select-methods gnus-server-alist)
6834 nil t (cons "nntp" 0) 'gnus-method-history)))
6835 ;; We either got a backend name or a virtual server name.
6836 ;; If the first, we also need an address.
6837 (if (assoc how gnus-valid-select-methods)
6839 ;; Suggested by mapjph@bath.ac.uk.
6842 (mapcar (lambda (server) (list server))
6843 gnus-secondary-servers)))
6844 ;; We got a server name, so we find the method.
6845 (gnus-server-to-method how)))))
6846 (gnus-browse-foreign-server method))
6850 ;;; Gnus summary mode
6853 (defvar gnus-summary-mode-map nil)
6855 (put 'gnus-summary-mode 'mode-class 'special)
6857 (unless gnus-summary-mode-map
6858 (setq gnus-summary-mode-map (make-keymap))
6859 (suppress-keymap gnus-summary-mode-map)
6861 ;; Non-orthogonal keys
6863 (gnus-define-keys gnus-summary-mode-map
6864 " " gnus-summary-next-page
6865 "\177" gnus-summary-prev-page
6866 [delete] gnus-summary-prev-page
6867 "\r" gnus-summary-scroll-up
6868 "n" gnus-summary-next-unread-article
6869 "p" gnus-summary-prev-unread-article
6870 "N" gnus-summary-next-article
6871 "P" gnus-summary-prev-article
6872 "\M-\C-n" gnus-summary-next-same-subject
6873 "\M-\C-p" gnus-summary-prev-same-subject
6874 "\M-n" gnus-summary-next-unread-subject
6875 "\M-p" gnus-summary-prev-unread-subject
6876 "." gnus-summary-first-unread-article
6877 "," gnus-summary-best-unread-article
6878 "\M-s" gnus-summary-search-article-forward
6879 "\M-r" gnus-summary-search-article-backward
6880 "<" gnus-summary-beginning-of-article
6881 ">" gnus-summary-end-of-article
6882 "j" gnus-summary-goto-article
6883 "^" gnus-summary-refer-parent-article
6884 "\M-^" gnus-summary-refer-article
6885 "u" gnus-summary-tick-article-forward
6886 "!" gnus-summary-tick-article-forward
6887 "U" gnus-summary-tick-article-backward
6888 "d" gnus-summary-mark-as-read-forward
6889 "D" gnus-summary-mark-as-read-backward
6890 "E" gnus-summary-mark-as-expirable
6891 "\M-u" gnus-summary-clear-mark-forward
6892 "\M-U" gnus-summary-clear-mark-backward
6893 "k" gnus-summary-kill-same-subject-and-select
6894 "\C-k" gnus-summary-kill-same-subject
6895 "\M-\C-k" gnus-summary-kill-thread
6896 "\M-\C-l" gnus-summary-lower-thread
6897 "e" gnus-summary-edit-article
6898 "#" gnus-summary-mark-as-processable
6899 "\M-#" gnus-summary-unmark-as-processable
6900 "\M-\C-t" gnus-summary-toggle-threads
6901 "\M-\C-s" gnus-summary-show-thread
6902 "\M-\C-h" gnus-summary-hide-thread
6903 "\M-\C-f" gnus-summary-next-thread
6904 "\M-\C-b" gnus-summary-prev-thread
6905 "\M-\C-u" gnus-summary-up-thread
6906 "\M-\C-d" gnus-summary-down-thread
6907 "&" gnus-summary-execute-command
6908 "c" gnus-summary-catchup-and-exit
6909 "\C-w" gnus-summary-mark-region-as-read
6910 "\C-t" gnus-summary-toggle-truncation
6911 "?" gnus-summary-mark-as-dormant
6912 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
6913 "\C-c\C-s\C-n" gnus-summary-sort-by-number
6914 "\C-c\C-s\C-a" gnus-summary-sort-by-author
6915 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
6916 "\C-c\C-s\C-d" gnus-summary-sort-by-date
6917 "\C-c\C-s\C-i" gnus-summary-sort-by-score
6918 "=" gnus-summary-expand-window
6919 "\C-x\C-s" gnus-summary-reselect-current-group
6920 "\M-g" gnus-summary-rescan-group
6921 "w" gnus-summary-stop-page-breaking
6922 "\C-c\C-r" gnus-summary-caesar-message
6923 "\M-t" gnus-summary-toggle-mime
6924 "f" gnus-summary-followup
6925 "F" gnus-summary-followup-with-original
6926 "C" gnus-summary-cancel-article
6927 "r" gnus-summary-reply
6928 "R" gnus-summary-reply-with-original
6929 "\C-c\C-f" gnus-summary-mail-forward
6930 "o" gnus-summary-save-article
6931 "\C-o" gnus-summary-save-article-mail
6932 "|" gnus-summary-pipe-output
6933 "\M-k" gnus-summary-edit-local-kill
6934 "\M-K" gnus-summary-edit-global-kill
6936 "\C-c\C-d" gnus-summary-describe-group
6937 "q" gnus-summary-exit
6938 "Q" gnus-summary-exit-no-update
6939 "\C-c\C-i" gnus-info-find-node
6940 gnus-mouse-2 gnus-mouse-pick-article
6941 "m" gnus-summary-mail-other-window
6942 "a" gnus-summary-post-news
6943 "x" gnus-summary-limit-to-unread
6944 "s" gnus-summary-isearch-article
6945 "t" gnus-article-hide-headers
6946 "g" gnus-summary-show-article
6947 "l" gnus-summary-goto-last-article
6948 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
6949 "\C-d" gnus-summary-enter-digest-group
6951 "*" gnus-cache-enter-article
6952 "\M-*" gnus-cache-remove-article
6953 "\M-&" gnus-summary-universal-argument
6954 "\C-l" gnus-recenter
6955 "I" gnus-summary-increase-score
6956 "L" gnus-summary-lower-score
6958 "V" gnus-summary-score-map
6959 "X" gnus-uu-extract-map
6960 "S" gnus-summary-send-map)
6962 ;; Sort of orthogonal keymap
6963 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
6964 "t" gnus-summary-tick-article-forward
6965 "!" gnus-summary-tick-article-forward
6966 "d" gnus-summary-mark-as-read-forward
6967 "r" gnus-summary-mark-as-read-forward
6968 "c" gnus-summary-clear-mark-forward
6969 " " gnus-summary-clear-mark-forward
6970 "e" gnus-summary-mark-as-expirable
6971 "x" gnus-summary-mark-as-expirable
6972 "?" gnus-summary-mark-as-dormant
6973 "b" gnus-summary-set-bookmark
6974 "B" gnus-summary-remove-bookmark
6975 "#" gnus-summary-mark-as-processable
6976 "\M-#" gnus-summary-unmark-as-processable
6977 "S" gnus-summary-limit-include-expunged
6978 "C" gnus-summary-catchup
6979 "H" gnus-summary-catchup-to-here
6980 "\C-c" gnus-summary-catchup-all
6981 "k" gnus-summary-kill-same-subject-and-select
6982 "K" gnus-summary-kill-same-subject
6983 "P" gnus-uu-mark-map)
6985 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mode-map)
6986 "c" gnus-summary-clear-above
6987 "u" gnus-summary-tick-above
6988 "m" gnus-summary-mark-above
6989 "k" gnus-summary-kill-below)
6991 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
6992 "/" gnus-summary-limit-to-subject
6993 "n" gnus-summary-limit-to-articles
6994 "w" gnus-summary-pop-limit
6995 "s" gnus-summary-limit-to-subject
6996 "a" gnus-summary-limit-to-author
6997 "u" gnus-summary-limit-to-unread
6998 "m" gnus-summary-limit-to-marks
6999 "v" gnus-summary-limit-to-score
7000 "D" gnus-summary-limit-include-dormant
7001 "d" gnus-summary-limit-exclude-dormant
7002 ;; "t" gnus-summary-limit-exclude-thread
7003 "E" gnus-summary-limit-include-expunged
7004 "c" gnus-summary-limit-exclude-childless-dormant
7005 "C" gnus-summary-limit-mark-excluded-as-read)
7007 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
7008 "n" gnus-summary-next-unread-article
7009 "p" gnus-summary-prev-unread-article
7010 "N" gnus-summary-next-article
7011 "P" gnus-summary-prev-article
7012 "\C-n" gnus-summary-next-same-subject
7013 "\C-p" gnus-summary-prev-same-subject
7014 "\M-n" gnus-summary-next-unread-subject
7015 "\M-p" gnus-summary-prev-unread-subject
7016 "f" gnus-summary-first-unread-article
7017 "b" gnus-summary-best-unread-article
7018 "j" gnus-summary-goto-article
7019 "g" gnus-summary-goto-subject
7020 "l" gnus-summary-goto-last-article
7021 "p" gnus-summary-pop-article)
7023 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
7024 "k" gnus-summary-kill-thread
7025 "l" gnus-summary-lower-thread
7026 "i" gnus-summary-raise-thread
7027 "T" gnus-summary-toggle-threads
7028 "t" gnus-summary-rethread-current
7029 "^" gnus-summary-reparent-thread
7030 "s" gnus-summary-show-thread
7031 "S" gnus-summary-show-all-threads
7032 "h" gnus-summary-hide-thread
7033 "H" gnus-summary-hide-all-threads
7034 "n" gnus-summary-next-thread
7035 "p" gnus-summary-prev-thread
7036 "u" gnus-summary-up-thread
7037 "o" gnus-summary-top-thread
7038 "d" gnus-summary-down-thread
7039 "#" gnus-uu-mark-thread
7040 "\M-#" gnus-uu-unmark-thread)
7042 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
7043 "c" gnus-summary-catchup-and-exit
7044 "C" gnus-summary-catchup-all-and-exit
7045 "E" gnus-summary-exit-no-update
7046 "Q" gnus-summary-exit
7047 "Z" gnus-summary-exit
7048 "n" gnus-summary-catchup-and-goto-next-group
7049 "R" gnus-summary-reselect-current-group
7050 "G" gnus-summary-rescan-group
7051 "N" gnus-summary-next-group
7052 "P" gnus-summary-prev-group)
7054 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
7055 " " gnus-summary-next-page
7056 "n" gnus-summary-next-page
7057 "\177" gnus-summary-prev-page
7058 [delete] gnus-summary-prev-page
7059 "p" gnus-summary-prev-page
7060 "\r" gnus-summary-scroll-up
7061 "<" gnus-summary-beginning-of-article
7062 ">" gnus-summary-end-of-article
7063 "b" gnus-summary-beginning-of-article
7064 "e" gnus-summary-end-of-article
7065 "^" gnus-summary-refer-parent-article
7066 "r" gnus-summary-refer-parent-article
7067 "R" gnus-summary-refer-references
7068 "g" gnus-summary-show-article
7069 "s" gnus-summary-isearch-article)
7071 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
7072 "b" gnus-article-add-buttons
7073 "B" gnus-article-add-buttons-to-head
7074 "o" gnus-article-treat-overstrike
7075 ;; "w" gnus-article-word-wrap
7076 "w" gnus-article-fill-cited-article
7077 "c" gnus-article-remove-cr
7078 "L" gnus-article-remove-trailing-blank-lines
7079 "q" gnus-article-de-quoted-unreadable
7080 "f" gnus-article-display-x-face
7081 "l" gnus-summary-stop-page-breaking
7082 "r" gnus-summary-caesar-message
7083 "t" gnus-article-hide-headers
7084 "v" gnus-summary-verbose-headers
7085 "m" gnus-summary-toggle-mime)
7087 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
7088 "a" gnus-article-hide
7089 "h" gnus-article-hide-headers
7090 "b" gnus-article-hide-boring-headers
7091 "s" gnus-article-hide-signature
7092 "c" gnus-article-hide-citation
7093 "p" gnus-article-hide-pgp
7094 "\C-c" gnus-article-hide-citation-maybe)
7096 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
7097 "a" gnus-article-highlight
7098 "h" gnus-article-highlight-headers
7099 "c" gnus-article-highlight-citation
7100 "s" gnus-article-highlight-signature)
7102 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
7103 "z" gnus-article-date-ut
7104 "u" gnus-article-date-ut
7105 "l" gnus-article-date-local
7106 "e" gnus-article-date-lapsed
7107 "o" gnus-article-date-original)
7109 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
7111 "f" gnus-summary-fetch-faq
7112 "d" gnus-summary-describe-group
7113 "h" gnus-summary-describe-briefly
7114 "i" gnus-info-find-node)
7116 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
7117 "e" gnus-summary-expire-articles
7118 "\M-\C-e" gnus-summary-expire-articles-now
7119 "\177" gnus-summary-delete-article
7120 [delete] gnus-summary-delete-article
7121 "m" gnus-summary-move-article
7122 "r" gnus-summary-respool-article
7123 "w" gnus-summary-edit-article
7124 "c" gnus-summary-copy-article
7125 "B" gnus-summary-crosspost-article
7126 "q" gnus-summary-respool-query
7127 "i" gnus-summary-import-article)
7129 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
7130 "o" gnus-summary-save-article
7131 "m" gnus-summary-save-article-mail
7132 "r" gnus-summary-save-article-rmail
7133 "f" gnus-summary-save-article-file
7134 "b" gnus-summary-save-article-body-file
7135 "h" gnus-summary-save-article-folder
7136 "v" gnus-summary-save-article-vm
7137 "p" gnus-summary-pipe-output
7138 "s" gnus-soup-add-article)
7143 (defun gnus-summary-mode (&optional group)
7144 "Major mode for reading articles.
7146 All normal editing commands are switched off.
7147 \\<gnus-summary-mode-map>
7148 Each line in this buffer represents one article. To read an
7149 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
7150 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
7153 You can also post articles and send mail from this buffer. To
7154 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
7155 of an article, type `\\[gnus-summary-reply]'.
7157 There are approx. one gazillion commands you can execute in this
7158 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
7160 The following commands are available:
7162 \\{gnus-summary-mode-map}"
7164 (when (and menu-bar-mode
7165 (gnus-visual-p 'summary-menu 'menu))
7166 (gnus-summary-make-menu-bar))
7167 (kill-all-local-variables)
7168 (gnus-summary-make-local-variables)
7169 (gnus-make-thread-indent-array)
7170 (gnus-simplify-mode-line)
7171 (setq major-mode 'gnus-summary-mode)
7172 (setq mode-name "Summary")
7173 (make-local-variable 'minor-mode-alist)
7174 (use-local-map gnus-summary-mode-map)
7175 (buffer-disable-undo (current-buffer))
7176 (setq buffer-read-only t) ;Disable modification
7177 (setq truncate-lines t)
7178 (setq selective-display t)
7179 (setq selective-display-ellipses t) ;Display `...'
7180 (setq buffer-display-table gnus-summary-display-table)
7181 (setq gnus-newsgroup-name group)
7182 (make-local-variable 'gnus-summary-line-format)
7183 (make-local-variable 'gnus-summary-line-format-spec)
7184 (make-local-variable 'gnus-summary-mark-positions)
7185 (run-hooks 'gnus-summary-mode-hook))
7187 (defun gnus-summary-make-local-variables ()
7188 "Make all the local summary buffer variables."
7189 (let ((locals gnus-summary-local-variables)
7191 (while (setq local (pop locals))
7194 (if (eq (cdr local) 'global)
7195 ;; Copy the global value of the variable.
7196 (setq global (symbol-value (car local)))
7197 ;; Use the value from the list.
7198 (setq global (eval (cdr local))))
7199 (make-local-variable (car local))
7200 (set (car local) global))
7201 ;; Simple nil-valued local variable.
7202 (make-local-variable local)
7205 (defun gnus-summary-make-display-table ()
7206 ;; Change the display table. Odd characters have a tendency to mess
7207 ;; up nicely formatted displays - we make all possible glyphs
7208 ;; display only a single character.
7210 ;; We start from the standard display table, if any.
7211 (setq gnus-summary-display-table
7212 (or (copy-sequence standard-display-table)
7213 (make-display-table)))
7214 ;; Nix out all the control chars...
7216 (while (>= (setq i (1- i)) 0)
7217 (aset gnus-summary-display-table i [??])))
7218 ;; ... but not newline and cr, of course. (cr is necessary for the
7219 ;; selective display).
7220 (aset gnus-summary-display-table ?\n nil)
7221 (aset gnus-summary-display-table ?\r nil)
7222 ;; We nix out any glyphs over 126 that are not set already.
7224 (while (>= (setq i (1- i)) 127)
7225 ;; Only modify if the entry is nil.
7226 (or (aref gnus-summary-display-table i)
7227 (aset gnus-summary-display-table i [??])))))
7229 (defun gnus-summary-clear-local-variables ()
7230 (let ((locals gnus-summary-local-variables))
7232 (if (consp (car locals))
7233 (and (vectorp (caar locals))
7234 (set (caar locals) nil))
7235 (and (vectorp (car locals))
7236 (set (car locals) nil)))
7237 (setq locals (cdr locals)))))
7239 ;; Summary data functions.
7241 (defmacro gnus-data-number (data)
7244 (defmacro gnus-data-set-number (data number)
7245 `(setcar ,data ,number))
7247 (defmacro gnus-data-mark (data)
7250 (defmacro gnus-data-set-mark (data mark)
7251 `(setcar (nthcdr 1 ,data) ,mark))
7253 (defmacro gnus-data-pos (data)
7256 (defmacro gnus-data-set-pos (data pos)
7257 `(setcar (nthcdr 2 ,data) ,pos))
7259 (defmacro gnus-data-header (data)
7262 (defmacro gnus-data-level (data)
7265 (defmacro gnus-data-unread-p (data)
7266 `(= (nth 1 ,data) gnus-unread-mark))
7268 (defmacro gnus-data-pseudo-p (data)
7269 `(consp (nth 3 ,data)))
7271 (defmacro gnus-data-find (number)
7272 `(assq ,number gnus-newsgroup-data))
7274 (defmacro gnus-data-find-list (number &optional data)
7275 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
7276 (memq (assq ,number bdata)
7279 (defmacro gnus-data-make (number mark pos header level)
7280 `(list ,number ,mark ,pos ,header ,level))
7282 (defun gnus-data-enter (after-article number mark pos header level offset)
7283 (let ((data (gnus-data-find-list after-article)))
7284 (or data (error "No such article: %d" after-article))
7285 (setcdr data (cons (gnus-data-make number mark pos header level)
7287 (setq gnus-newsgroup-data-reverse nil)
7288 (gnus-data-update-list (cddr data) offset)))
7290 (defun gnus-data-enter-list (after-article list &optional offset)
7292 (let ((data (and after-article (gnus-data-find-list after-article)))
7294 (or data (not after-article) (error "No such article: %d" after-article))
7295 ;; Find the last element in the list to be spliced into the main
7298 (setq list (cdr list)))
7301 (setcdr list gnus-newsgroup-data)
7302 (setq gnus-newsgroup-data ilist)
7303 (and offset (gnus-data-update-list (cdr list) offset)))
7304 (setcdr list (cdr data))
7306 (and offset (gnus-data-update-list (cdr data) offset)))
7307 (setq gnus-newsgroup-data-reverse nil))))
7309 (defun gnus-data-remove (article &optional offset)
7310 (let ((data gnus-newsgroup-data))
7311 (if (= (gnus-data-number (car data)) article)
7312 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
7313 gnus-newsgroup-data-reverse nil)
7315 (and (= (gnus-data-number (cadr data)) article)
7317 (setcdr data (cddr data))
7318 (and offset (gnus-data-update-list (cdr data) offset))
7320 gnus-newsgroup-data-reverse nil)))
7321 (setq data (cdr data))))))
7323 (defmacro gnus-data-list (backward)
7325 (or gnus-newsgroup-data-reverse
7326 (setq gnus-newsgroup-data-reverse
7327 (reverse gnus-newsgroup-data)))
7328 gnus-newsgroup-data))
7330 (defun gnus-data-update-list (data offset)
7331 "Add OFFSET to the POS of all data entries in DATA."
7333 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
7334 (setq data (cdr data))))
7336 (defun gnus-data-compute-positions ()
7337 "Compute the positions of all articles."
7338 (let ((data gnus-newsgroup-data)
7341 (when (setq pos (text-property-any
7342 (point-min) (point-max)
7343 'gnus-number (gnus-data-number (car data))))
7344 (gnus-data-set-pos (car data) (+ pos 3)))
7345 (setq data (cdr data)))))
7347 (defun gnus-summary-article-pseudo-p (article)
7348 "Say whether this article is a pseudo article or not."
7349 (not (vectorp (gnus-data-header (gnus-data-find article)))))
7351 (defun gnus-article-parent-p (number)
7352 "Say whether this article is a parent or not."
7353 (let ((data (gnus-data-find-list number)))
7354 (and (cdr data) ; There has to be an article after...
7355 (< (gnus-data-level (car data)) ; And it has to have a higher level.
7356 (gnus-data-level (nth 1 data))))))
7358 (defun gnus-article-children (number)
7359 "Return a list of all children to NUMBER."
7360 (let* ((data (gnus-data-find-list number))
7361 (level (gnus-data-level (car data)))
7363 (setq data (cdr data))
7365 (= (gnus-data-level (car data)) (1+ level)))
7366 (push (gnus-data-number (car data)) children)
7367 (setq data (cdr data)))
7370 (defmacro gnus-summary-skip-intangible ()
7371 "If the current article is intangible, then jump to a different article."
7372 '(let ((to (get-text-property (point) 'gnus-intangible)))
7373 (and to (gnus-summary-goto-subject to))))
7375 (defmacro gnus-summary-article-intangible-p ()
7376 "Say whether this article is intangible or not."
7377 '(get-text-property (point) 'gnus-intangible))
7379 ;; Some summary mode macros.
7381 (defmacro gnus-summary-article-number ()
7382 "The article number of the article on the current line.
7383 If there isn's an article number here, then we return the current
7386 (gnus-summary-skip-intangible)
7387 (or (get-text-property (point) 'gnus-number)
7388 (gnus-summary-last-subject))))
7390 (defmacro gnus-summary-article-header (&optional number)
7391 `(gnus-data-header (gnus-data-find
7392 ,(or number '(gnus-summary-article-number)))))
7394 (defmacro gnus-summary-thread-level (&optional number)
7395 `(if (and (eq gnus-summary-make-false-root 'dummy)
7396 (get-text-property (point) 'gnus-intangible))
7398 (gnus-data-level (gnus-data-find
7399 ,(or number '(gnus-summary-article-number))))))
7401 (defmacro gnus-summary-article-mark (&optional number)
7402 `(gnus-data-mark (gnus-data-find
7403 ,(or number '(gnus-summary-article-number)))))
7405 (defmacro gnus-summary-article-pos (&optional number)
7406 `(gnus-data-pos (gnus-data-find
7407 ,(or number '(gnus-summary-article-number)))))
7409 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
7410 (defmacro gnus-summary-article-subject (&optional number)
7411 "Return current subject string or nil if nothing."
7414 `(gnus-data-header (assq ,number gnus-newsgroup-data))
7415 '(gnus-data-header (assq (gnus-summary-article-number)
7416 gnus-newsgroup-data)))))
7419 (mail-header-subject headers))))
7421 (defmacro gnus-summary-article-score (&optional number)
7422 "Return current article score."
7423 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
7424 gnus-newsgroup-scored))
7425 gnus-summary-default-score 0))
7427 (defun gnus-summary-article-children (&optional number)
7428 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
7429 (level (gnus-data-level (car data)))
7431 (while (and (setq data (cdr data))
7432 (> (setq l (gnus-data-level (car data))) level))
7433 (and (= (1+ level) l)
7434 (setq children (cons (gnus-data-number (car data))
7436 (nreverse children)))
7438 (defun gnus-summary-article-parent (&optional number)
7439 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
7440 (gnus-data-list t)))
7441 (level (gnus-data-level (car data))))
7443 () ; This is a root.
7444 ;; We search until we find an article with a level less than
7445 ;; this one. That function has to be the parent.
7446 (while (and (setq data (cdr data))
7447 (not (< (gnus-data-level (car data)) level))))
7448 (and data (gnus-data-number (car data))))))
7450 (defun gnus-unread-mark-p (mark)
7451 "Say whether MARK is the unread mark."
7452 (= mark gnus-unread-mark))
7454 (defun gnus-read-mark-p (mark)
7455 "Say whether MARK is one of the marks that mark as read.
7456 This is all marks except unread, ticked, dormant, and expirable."
7457 (not (or (= mark gnus-unread-mark)
7458 (= mark gnus-ticked-mark)
7459 (= mark gnus-dormant-mark)
7460 (= mark gnus-expirable-mark))))
7462 ;; Saving hidden threads.
7464 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
7465 (put 'gnus-save-hidden-threads 'lisp-indent-hook 0)
7466 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
7468 (defmacro gnus-save-hidden-threads (&rest forms)
7469 "Save hidden threads, eval FORMS, and restore the hidden threads."
7470 (let ((config (make-symbol "config")))
7471 `(let ((,config (gnus-hidden-threads-configuration)))
7475 (gnus-restore-hidden-threads-configuration ,config)))))
7477 (defun gnus-hidden-threads-configuration ()
7478 "Return the current hidden threads configuration."
7481 (goto-char (point-min))
7482 (while (search-forward "\r" nil t)
7483 (push (1- (point)) config))
7486 (defun gnus-restore-hidden-threads-configuration (config)
7487 "Restore hidden threads configuration from CONFIG."
7488 (let (point buffer-read-only)
7489 (while (setq point (pop config))
7490 (when (and (< point (point-max))
7492 (= (following-char) ?\n))
7493 (subst-char-in-region point (1+ point) ?\n ?\r)))))
7495 ;; Various summary mode internalish functions.
7497 (defun gnus-mouse-pick-article (e)
7500 (gnus-summary-next-page nil t))
7502 (defun gnus-summary-setup-buffer (group)
7503 "Initialize summary buffer."
7504 (let ((buffer (concat "*Summary " group "*")))
7505 (if (get-buffer buffer)
7508 (setq gnus-summary-buffer (current-buffer))
7509 (not gnus-newsgroup-prepared))
7510 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
7511 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
7512 (gnus-add-current-to-buffer-list)
7513 (gnus-summary-mode group)
7515 (gnus-carpal-setup-buffer 'summary))
7516 (unless gnus-single-article-buffer
7517 (make-local-variable 'gnus-article-buffer)
7518 (make-local-variable 'gnus-article-current)
7519 (make-local-variable 'gnus-original-article-buffer))
7520 (setq gnus-newsgroup-name group)
7523 (defun gnus-set-global-variables ()
7524 ;; Set the global equivalents of the summary buffer-local variables
7525 ;; to the latest values they had. These reflect the summary buffer
7526 ;; that was in action when the last article was fetched.
7527 (when (eq major-mode 'gnus-summary-mode)
7528 (setq gnus-summary-buffer (current-buffer))
7529 (let ((name gnus-newsgroup-name)
7530 (marked gnus-newsgroup-marked)
7531 (unread gnus-newsgroup-unreads)
7532 (headers gnus-current-headers)
7533 (data gnus-newsgroup-data)
7534 (summary gnus-summary-buffer)
7535 (article-buffer gnus-article-buffer)
7536 (original gnus-original-article-buffer)
7537 (gac gnus-article-current)
7538 (score-file gnus-current-score-file))
7540 (set-buffer gnus-group-buffer)
7541 (setq gnus-newsgroup-name name)
7542 (setq gnus-newsgroup-marked marked)
7543 (setq gnus-newsgroup-unreads unread)
7544 (setq gnus-current-headers headers)
7545 (setq gnus-newsgroup-data data)
7546 (setq gnus-article-current gac)
7547 (setq gnus-summary-buffer summary)
7548 (setq gnus-article-buffer article-buffer)
7549 (setq gnus-original-article-buffer original)
7550 (setq gnus-current-score-file score-file)))))
7552 (defun gnus-summary-last-article-p (&optional article)
7553 "Return whether ARTICLE is the last article in the buffer."
7554 (if (not (setq article (or article (gnus-summary-article-number))))
7555 t ; All non-existant numbers are the last article. :-)
7556 (not (cdr (gnus-data-find-list article)))))
7558 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
7559 "Insert a dummy root in the summary buffer."
7561 (gnus-add-text-properties
7562 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
7563 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
7565 (defun gnus-make-thread-indent-array ()
7567 (unless (and gnus-thread-indent-array
7568 (= gnus-thread-indent-level gnus-thread-indent-array-level))
7569 (setq gnus-thread-indent-array (make-vector 201 "")
7570 gnus-thread-indent-array-level gnus-thread-indent-level)
7572 (aset gnus-thread-indent-array n
7573 (make-string (* n gnus-thread-indent-level) ? ))
7576 (defun gnus-summary-insert-line
7577 (gnus-tmp-header gnus-tmp-level gnus-tmp-current gnus-tmp-unread
7578 gnus-tmp-replied gnus-tmp-expirable gnus-tmp-subject-or-nil
7579 &optional gnus-tmp-dummy gnus-tmp-score gnus-tmp-process)
7580 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
7581 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
7582 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
7583 (gnus-tmp-score-char
7584 (if (or (null gnus-summary-default-score)
7585 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
7586 gnus-summary-zcore-fuzz)) ?
7587 (if (< gnus-tmp-score gnus-summary-default-score)
7588 gnus-score-below-mark gnus-score-over-mark)))
7589 (gnus-tmp-replied (cond (gnus-tmp-process gnus-process-mark)
7590 ((memq gnus-tmp-current gnus-newsgroup-cached)
7592 (gnus-tmp-replied gnus-replied-mark)
7593 ((memq gnus-tmp-current gnus-newsgroup-saved)
7595 (t gnus-unread-mark)))
7596 (gnus-tmp-from (mail-header-from gnus-tmp-header))
7599 ((string-match "(.+)" gnus-tmp-from)
7600 (substring gnus-tmp-from
7601 (1+ (match-beginning 0)) (1- (match-end 0))))
7602 ((string-match "<[^>]+> *$" gnus-tmp-from)
7603 (let ((beg (match-beginning 0)))
7604 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
7605 (substring gnus-tmp-from (1+ (match-beginning 0))
7606 (1- (match-end 0))))
7607 (substring gnus-tmp-from 0 beg))))
7609 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
7610 (gnus-tmp-number (mail-header-number gnus-tmp-header))
7611 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
7612 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
7613 (buffer-read-only nil))
7614 (when (string= gnus-tmp-name "")
7615 (setq gnus-tmp-name gnus-tmp-from))
7616 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
7617 (gnus-put-text-property
7619 (progn (eval gnus-summary-line-format-spec) (point))
7620 'gnus-number gnus-tmp-number)
7621 (when (gnus-visual-p 'summary-highlight 'highlight)
7623 (run-hooks 'gnus-summary-update-hook)
7626 (defun gnus-summary-update-line (&optional dont-update)
7627 ;; Update summary line after change.
7628 (when (and gnus-summary-default-score
7629 (not gnus-summary-inhibit-highlight))
7630 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
7631 (article (gnus-summary-article-number))
7632 (score (gnus-summary-article-score article)))
7634 (if (and gnus-summary-mark-below
7635 (< (gnus-summary-article-score)
7636 gnus-summary-mark-below))
7637 ;; This article has a low score, so we mark it as read.
7638 (when (memq article gnus-newsgroup-unreads)
7639 (gnus-summary-mark-article-as-read gnus-low-score-mark))
7640 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
7641 ;; This article was previously marked as read on account
7642 ;; of a low score, but now it has risen, so we mark it as
7644 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
7645 (gnus-summary-update-mark
7646 (if (or (null gnus-summary-default-score)
7647 (<= (abs (- score gnus-summary-default-score))
7648 gnus-summary-zcore-fuzz)) ?
7649 (if (< score gnus-summary-default-score)
7650 gnus-score-below-mark gnus-score-over-mark)) 'score))
7651 ;; Do visual highlighting.
7652 (when (gnus-visual-p 'summary-highlight 'highlight)
7653 (run-hooks 'gnus-summary-update-hook)))))
7655 (defvar gnus-tmp-new-adopts nil)
7657 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
7658 ;; Sum up all elements (and sub-elements) in a list.
7660 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
7662 ((and (consp thread) (cdr thread))
7665 'gnus-summary-number-of-articles-in-thread (cdr thread))))
7668 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
7671 (when (and level (zerop level) gnus-tmp-new-adopts)
7674 'gnus-summary-number-of-articles-in-thread
7675 gnus-tmp-new-adopts))))
7677 (if (> number 1) gnus-not-empty-thread-mark
7678 gnus-empty-thread-mark)
7681 (defun gnus-summary-set-local-parameters (group)
7682 "Go through the local params of GROUP and set all variable specs in that list."
7683 (let ((params (gnus-info-params (gnus-get-info group)))
7686 (setq elem (car params)
7687 params (cdr params))
7688 (and (consp elem) ; Has to be a cons.
7689 (consp (cdr elem)) ; The cdr has to be a list.
7690 (symbolp (car elem)) ; Has to be a symbol in there.
7691 (not (memq (car elem)
7692 '(quit-config to-address to-list to-group)))
7693 (progn ; So we set it.
7694 (make-local-variable (car elem))
7695 (set (car elem) (eval (nth 1 elem))))))))
7697 (defun gnus-summary-read-group (group &optional show-all no-article
7698 kill-buffer no-display)
7699 "Start reading news in newsgroup GROUP.
7700 If SHOW-ALL is non-nil, already read articles are also listed.
7701 If NO-ARTICLE is non-nil, no article is selected initially.
7702 If NO-DISPLAY, don't generate a summary buffer."
7703 (gnus-message 5 "Retrieving newsgroup: %s..." group)
7704 (let* ((new-group (gnus-summary-setup-buffer group))
7705 (quit-config (gnus-group-quit-config group))
7706 (did-select (and new-group (gnus-select-newsgroup group show-all))))
7708 ;; This summary buffer exists already, so we just select it.
7710 (gnus-set-global-variables)
7712 (gnus-kill-or-deaden-summary kill-buffer))
7713 (gnus-configure-windows 'summary 'force)
7714 (gnus-set-mode-line 'summary)
7715 (gnus-summary-position-point)
7718 ;; We couldn't select this group.
7720 (when (and (eq major-mode 'gnus-summary-mode)
7721 (not (equal (current-buffer) kill-buffer)))
7722 (kill-buffer (current-buffer))
7723 (if (not quit-config)
7725 (set-buffer gnus-group-buffer)
7726 (gnus-group-jump-to-group group)
7727 (gnus-group-next-unread-group 1))
7728 (if (not (buffer-name (car quit-config)))
7729 (gnus-configure-windows 'group 'force)
7730 (set-buffer (car quit-config))
7731 (and (eq major-mode 'gnus-summary-mode)
7732 (gnus-set-global-variables))
7733 (gnus-configure-windows (cdr quit-config)))))
7734 (gnus-message 3 "Can't select group")
7736 ;; The user did a `C-g' while prompting for number of articles,
7737 ;; so we exit this group.
7738 ((eq did-select 'quit)
7739 (and (eq major-mode 'gnus-summary-mode)
7740 (not (equal (current-buffer) kill-buffer))
7741 (kill-buffer (current-buffer)))
7743 (gnus-kill-or-deaden-summary kill-buffer))
7744 (if (not quit-config)
7746 (set-buffer gnus-group-buffer)
7747 (gnus-group-jump-to-group group)
7748 (gnus-group-next-unread-group 1)
7749 (gnus-configure-windows 'group 'force))
7750 (if (not (buffer-name (car quit-config)))
7751 (gnus-configure-windows 'group 'force)
7752 (set-buffer (car quit-config))
7753 (and (eq major-mode 'gnus-summary-mode)
7754 (gnus-set-global-variables))
7755 (gnus-configure-windows (cdr quit-config))))
7756 ;; Finally signal the quit.
7758 ;; The group was successfully selected.
7760 (gnus-set-global-variables)
7761 ;; Save the active value in effect when the group was entered.
7762 (setq gnus-newsgroup-active
7764 (gnus-active gnus-newsgroup-name)))
7765 ;; You can change the summary buffer in some way with this hook.
7766 (run-hooks 'gnus-select-group-hook)
7767 ;; Set any local variables in the group parameters.
7768 (gnus-summary-set-local-parameters gnus-newsgroup-name)
7769 (gnus-update-format-specifications)
7770 ;; Do score processing.
7771 (when gnus-use-scoring
7772 (gnus-possibly-score-headers))
7773 ;; Check whether to fill in the gaps in the threads.
7774 (when gnus-build-sparse-threads
7775 (gnus-build-sparse-threads))
7776 ;; Find the initial limit.
7777 (if gnus-show-threads
7779 (let ((gnus-newsgroup-dormant nil))
7780 (gnus-summary-initial-limit show-all))
7781 (gnus-summary-initial-limit show-all))
7782 (setq gnus-newsgroup-limit
7784 (lambda (header) (mail-header-number header))
7785 gnus-newsgroup-headers)))
7786 ;; Generate the summary buffer.
7788 (gnus-summary-prepare))
7789 (when gnus-use-trees
7790 (gnus-tree-open group)
7791 (setq gnus-summary-highlight-line-function
7792 'gnus-tree-highlight-article))
7793 ;; If the summary buffer is empty, but there are some low-scored
7794 ;; articles or some excluded dormants, we include these in the
7796 (when (and (zerop (buffer-size))
7798 (cond (gnus-newsgroup-dormant
7799 (gnus-summary-limit-include-dormant))
7800 ((and gnus-newsgroup-scored show-all)
7801 (gnus-summary-limit-include-expunged))))
7802 ;; Function `gnus-apply-kill-file' must be called in this hook.
7803 (run-hooks 'gnus-apply-kill-hook)
7804 (if (and (zerop (buffer-size))
7807 ;; This newsgroup is empty.
7808 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
7809 (gnus-message 6 "No unread news")
7811 (gnus-kill-or-deaden-summary kill-buffer))
7812 ;; Return nil from this function.
7814 ;; Hide conversation thread subtrees. We cannot do this in
7815 ;; gnus-summary-prepare-hook since kill processing may not
7816 ;; work with hidden articles.
7817 (and gnus-show-threads
7818 gnus-thread-hide-subtree
7819 (gnus-summary-hide-all-threads))
7820 ;; Show first unread article if requested.
7821 (if (and (not no-article)
7823 gnus-newsgroup-unreads
7824 gnus-auto-select-first)
7825 (unless (if (eq gnus-auto-select-first 'best)
7826 (gnus-summary-best-unread-article)
7827 (gnus-summary-first-unread-article))
7828 (gnus-configure-windows 'summary))
7829 ;; Don't select any articles, just move point to the first
7830 ;; article in the group.
7831 (goto-char (point-min))
7832 (gnus-summary-position-point)
7833 (gnus-set-mode-line 'summary)
7834 (gnus-configure-windows 'summary 'force))
7835 ;; If we are in async mode, we send some info to the backend.
7836 (when gnus-newsgroup-async
7837 (gnus-request-asynchronous gnus-newsgroup-name gnus-newsgroup-data))
7839 (gnus-kill-or-deaden-summary kill-buffer))
7840 (when (get-buffer-window gnus-group-buffer t)
7841 ;; Gotta use windows, because recenter does wierd stuff if
7842 ;; the current buffer ain't the displayed window.
7843 (let ((owin (selected-window)))
7844 (select-window (get-buffer-window gnus-group-buffer t))
7845 (when (gnus-group-goto-group group)
7847 (select-window owin))))
7848 ;; Mark this buffer as "prepared".
7849 (setq gnus-newsgroup-prepared t)
7852 (defun gnus-summary-prepare ()
7853 "Generate the summary buffer."
7854 (let ((buffer-read-only nil))
7856 (setq gnus-newsgroup-data nil
7857 gnus-newsgroup-data-reverse nil)
7858 (run-hooks 'gnus-summary-generate-hook)
7859 ;; Generate the buffer, either with threads or without.
7860 (when gnus-newsgroup-headers
7861 (gnus-summary-prepare-threads
7862 (if gnus-show-threads
7863 (gnus-sort-gathered-threads
7864 (funcall gnus-summary-thread-gathering-function
7866 (gnus-cut-threads (gnus-make-threads)))))
7867 ;; Unthreaded display.
7868 (gnus-sort-articles gnus-newsgroup-headers))))
7869 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
7870 ;; Call hooks for modifying summary buffer.
7871 (goto-char (point-min))
7872 (run-hooks 'gnus-summary-prepare-hook)))
7874 (defun gnus-gather-threads-by-subject (threads)
7875 "Gather threads by looking at Subject headers."
7876 (if (not gnus-summary-make-false-root)
7878 (let ((hashtb (gnus-make-hashtable 1023))
7881 subject hthread whole-subject)
7883 (setq whole-subject (mail-header-subject (caar threads)))
7886 ;; Truncate the subject.
7887 ((numberp gnus-summary-gather-subject-limit)
7888 (setq subject (gnus-simplify-subject-re whole-subject))
7889 (if (> (length subject) gnus-summary-gather-subject-limit)
7890 (substring subject 0 gnus-summary-gather-subject-limit)
7892 ;; Fuzzily simplify it.
7893 ((eq 'fuzzy gnus-summary-gather-subject-limit)
7894 (gnus-simplify-subject-fuzzy whole-subject))
7895 ;; Just remove the leading "Re:".
7897 (gnus-simplify-subject-re whole-subject))))
7899 (if (and gnus-summary-gather-exclude-subject
7900 (string-match gnus-summary-gather-exclude-subject
7902 () ; We don't want to do anything with this article.
7903 ;; We simplify the subject before looking it up in the
7906 (if (setq hthread (gnus-gethash subject hashtb))
7908 ;; We enter a dummy root into the thread, if we
7909 ;; haven't done that already.
7910 (unless (stringp (caar hthread))
7911 (setcar hthread (list whole-subject (car hthread))))
7912 ;; We add this new gathered thread to this gathered
7914 (setcdr (car hthread)
7915 (nconc (cdar hthread) (list (car threads))))
7916 ;; Remove it from the list of threads.
7917 (setcdr prev (cdr threads))
7918 (setq threads prev))
7919 ;; Enter this thread into the hash table.
7920 (gnus-sethash subject threads hashtb)))
7922 (setq threads (cdr threads)))
7925 (defun gnus-gather-threads-by-references (threads)
7926 "Gather threads by looking at References headers."
7927 (let ((idhashtb (gnus-make-hashtable 1023))
7928 (thhashtb (gnus-make-hashtable 1023))
7931 ids references id gthread gid entered)
7933 (when (setq references (mail-header-references (caar threads)))
7934 (setq id (mail-header-id (caar threads)))
7935 (setq ids (gnus-split-references references))
7938 (if (not (setq gid (gnus-gethash (car ids) idhashtb)))
7940 (gnus-sethash (car ids) id idhashtb)
7941 (gnus-sethash id threads thhashtb))
7942 (setq gthread (gnus-gethash gid thhashtb))
7944 ;; We enter a dummy root into the thread, if we
7945 ;; haven't done that already.
7946 (unless (stringp (caar gthread))
7947 (setcar gthread (list (mail-header-subject (caar gthread))
7949 ;; We add this new gathered thread to this gathered
7951 (setcdr (car gthread)
7952 (nconc (cdar gthread) (list (car threads)))))
7953 ;; Add it into the thread hash table.
7954 (gnus-sethash id gthread thhashtb)
7956 ;; Remove it from the list of threads.
7957 (setcdr prev (cdr threads))
7958 (setq threads prev))
7959 (setq ids (cdr ids))))
7961 (setq threads (cdr threads)))
7964 (defun gnus-sort-gathered-threads (threads)
7965 "Sort subtreads inside each gathered thread by article number."
7966 (let ((result threads))
7968 (when (stringp (caar threads))
7969 (setcdr (car threads)
7970 (sort (cdar threads) 'gnus-thread-sort-by-number)))
7971 (setq threads (cdr threads)))
7974 (defun gnus-make-threads ()
7975 "Go through the dependency hashtb and find the roots. Return all threads."
7979 (unless (car (symbol-value refs))
7980 ;; These threads do not refer back to any other articles,
7981 ;; so they're roots.
7982 (setq threads (append (cdr (symbol-value refs)) threads))))
7983 gnus-newsgroup-dependencies)
7986 (defun gnus-build-sparse-threads ()
7987 (let ((headers gnus-newsgroup-headers)
7988 (deps gnus-newsgroup-dependencies)
7989 header references generation relations
7990 cthread subject child end pthread relation)
7991 ;; First we create an alist of generations/relations, where
7992 ;; generations is how much we trust the ralation, and the relation
7994 (gnus-message 7 "Making sparse threads...")
7996 (nnheader-set-temp-buffer " *gnus sparse threads*")
7997 (while (setq header (pop headers))
7998 (when (and (setq references (mail-header-references header))
7999 (not (string= references "")))
8001 (setq child (mail-header-id header)
8002 subject (mail-header-subject header))
8004 (while (search-backward ">" nil t)
8005 (setq end (1+ (point)))
8006 (when (search-backward "<" nil t)
8007 (push (list (incf generation)
8008 child (setq child (buffer-substring (point) end))
8011 (push (list (1+ generation) child nil subject) relations)
8013 (kill-buffer (current-buffer)))
8014 ;; Sort over trustworthiness.
8015 (setq relations (sort relations (lambda (r1 r2) (< (car r1) (car r2)))))
8016 (while (setq relation (pop relations))
8017 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
8018 (unless (car (symbol-value cthread))
8019 ;; Make this article the parent of these threads.
8020 (setcar (symbol-value cthread)
8021 (vector gnus-reffed-article-number
8025 (or (caddr relation) "") 0 0 "")))
8026 (set cthread (list (vector gnus-reffed-article-number
8028 "" "" (cadr relation)
8029 (or (caddr relation) "") 0 0 ""))))
8030 (push gnus-reffed-article-number gnus-newsgroup-limit)
8031 (push gnus-reffed-article-number gnus-newsgroup-sparse)
8032 (push (cons gnus-reffed-article-number gnus-sparse-mark)
8033 gnus-newsgroup-reads)
8034 (decf gnus-reffed-article-number)
8035 ;; Make this new thread the child of its parent.
8036 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
8037 (setcdr (symbol-value pthread)
8038 (nconc (cdr (symbol-value pthread))
8039 (list (symbol-value cthread))))
8040 (set pthread (list nil (symbol-value cthread))))))
8041 (gnus-message 7 "Making sparse threads...done")))
8043 (defun gnus-build-old-threads ()
8044 ;; Look at all the articles that refer back to old articles, and
8045 ;; fetch the headers for the articles that aren't there. This will
8046 ;; build complete threads - if the roots haven't been expired by the
8051 (when (not (car (symbol-value refs)))
8052 (setq heads (cdr (symbol-value refs)))
8054 (if (memq (mail-header-number (caar heads))
8055 gnus-newsgroup-dormant)
8056 (setq heads (cdr heads))
8057 (setq id (symbol-name refs))
8058 (while (and (setq id (gnus-build-get-header id))
8059 (not (car (gnus-gethash
8060 id gnus-newsgroup-dependencies)))))
8061 (setq heads nil)))))
8062 gnus-newsgroup-dependencies)))
8064 (defun gnus-build-get-header (id)
8065 ;; Look through the buffer of NOV lines and find the header to
8066 ;; ID. Enter this line into the dependencies hash table, and return
8067 ;; the id of the parent article (if any).
8068 (let ((deps gnus-newsgroup-dependencies)
8072 (set-buffer nntp-server-buffer)
8073 (goto-char (point-min))
8074 (while (and (not found) (search-forward id nil t))
8076 (setq found (looking-at
8077 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
8078 (regexp-quote id))))
8079 (or found (beginning-of-line 2)))
8083 (setq header (gnus-nov-parse-line
8084 (read (current-buffer)) deps))
8085 (gnus-parent-id (mail-header-references header)))))
8087 (let ((number (mail-header-number header)))
8088 (push number gnus-newsgroup-limit)
8089 (push header gnus-newsgroup-headers)
8090 (if (memq number gnus-newsgroup-unselected)
8092 (push number gnus-newsgroup-unreads)
8093 (setq gnus-newsgroup-unselected
8094 (delq number gnus-newsgroup-unselected)))
8095 (push number gnus-newsgroup-ancient)))))))
8097 (defun gnus-summary-update-article (article &optional iheader)
8098 "Update ARTICLE in the summary buffer."
8099 (set-buffer gnus-summary-buffer)
8100 (let* ((header (or iheader (gnus-summary-article-header article)))
8101 (id (mail-header-id header))
8102 (data (gnus-data-find article))
8103 (thread (gnus-id-to-thread id))
8104 (references (mail-header-references header))
8109 (not (equal "" references)))
8112 (buffer-read-only nil)
8114 (number (mail-header-number header))
8117 ;; !!! Should this be in or not?
8119 (setcar thread nil))
8121 (delq thread parent))
8122 (if (gnus-summary-insert-subject id header iheader)
8123 ;; Set the (possibly) new article number in the data structure.
8124 (gnus-data-set-number data (gnus-id-to-article id))
8128 (defun gnus-rebuild-thread (id)
8129 "Rebuild the thread containing ID."
8130 (let ((buffer-read-only nil)
8131 current thread data)
8132 (if (not gnus-show-threads)
8133 (setq thread (list (car (gnus-id-to-thread id))))
8134 ;; Get the thread this article is part of.
8135 (setq thread (gnus-remove-thread id)))
8136 (setq current (save-excursion
8137 (and (zerop (forward-line -1))
8138 (gnus-summary-article-number))))
8139 ;; If this is a gathered thread, we have to go some re-gathering.
8140 (when (stringp (car thread))
8141 (let ((subject (car thread))
8143 (setq thread (cdr thread))
8145 (unless (memq (setq thr (gnus-id-to-thread
8147 (mail-header-id (caar thread)))))
8150 (setq thread (cdr thread)))
8151 ;; We now have all (unique) roots.
8152 (if (= (length roots) 1)
8153 ;; All the loose roots are now one solid root.
8154 (setq thread (car roots))
8155 (setq thread (cons subject (gnus-sort-threads roots))))))
8157 ;; We then insert this thread into the summary buffer.
8158 (let (gnus-newsgroup-data gnus-newsgroup-threads)
8159 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
8160 (setq data (nreverse gnus-newsgroup-data))
8161 (setq threads gnus-newsgroup-threads))
8162 ;; We splice the new data into the data structure.
8163 (gnus-data-enter-list current data)
8164 (gnus-data-compute-positions)
8165 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
8167 (defun gnus-number-to-header (number)
8168 "Return the header for article NUMBER."
8169 (let ((headers gnus-newsgroup-headers))
8171 (not (= number (mail-header-number (car headers)))))
8176 (defun gnus-id-to-thread (id)
8177 "Return the (sub-)thread where ID appears."
8178 (gnus-gethash id gnus-newsgroup-dependencies))
8180 (defun gnus-id-to-article (id)
8181 "Return the article number of ID."
8182 (let ((thread (gnus-id-to-thread id)))
8185 (mail-header-number (car thread)))))
8187 (defun gnus-id-to-header (id)
8188 "Return the article headers of ID."
8189 (car (gnus-id-to-thread id)))
8191 (defun gnus-article-displayed-root-p (article)
8192 "Say whether ARTICLE is a root(ish) article."
8193 (let ((level (gnus-summary-thread-level article))
8194 (refs (mail-header-references (gnus-summary-article-header article)))
8200 ((null (gnus-parent-id refs)) t)
8202 (null (setq particle (gnus-id-to-article
8203 (gnus-parent-id refs))))
8204 (null (gnus-summary-thread-level particle)))))))
8206 (defun gnus-root-id (id)
8207 "Return the id of the root of the thread where ID appears."
8209 (while (and id (setq prev (car (gnus-gethash
8210 id gnus-newsgroup-dependencies))))
8212 id (gnus-parent-id (mail-header-references prev))))
8215 (defun gnus-remove-thread (id &optional dont-remove)
8216 "Remove the thread that has ID in it."
8217 (let ((dep gnus-newsgroup-dependencies)
8218 headers thread last-id)
8219 ;; First go up in this thread until we find the root.
8220 (setq last-id (gnus-root-id id))
8221 (setq headers (list (car (gnus-id-to-thread last-id))
8222 (caadr (gnus-id-to-thread last-id))))
8223 ;; We have now found the real root of this thread. It might have
8224 ;; been gathered into some loose thread, so we have to search
8225 ;; through the threads to find the thread we wanted.
8226 (let ((threads gnus-newsgroup-threads)
8229 (setq sub (car threads))
8230 (if (stringp (car sub))
8231 ;; This is a gathered threads, so we look at the roots
8232 ;; below it to find whether this article in in this
8235 (setq sub (cdr sub))
8237 (when (member (caar sub) headers)
8238 (setq thread (car threads)
8241 (setq sub (cdr sub))))
8242 ;; It's an ordinary thread, so we check it.
8243 (when (eq (car sub) (car headers))
8246 (setq threads (cdr threads)))
8247 ;; If this article is in no thread, then it's a root.
8250 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
8251 (setq thread (gnus-gethash last-id dep)))
8254 thread ; We return this thread.
8256 (if (stringp (car thread))
8258 ;; If we use dummy roots, then we have to remove the
8259 ;; dummy root as well.
8260 (when (eq gnus-summary-make-false-root 'dummy)
8263 (setq thread (cdr thread))
8265 (gnus-remove-thread-1 (car thread))
8266 (setq thread (cdr thread))))
8267 (gnus-remove-thread-1 thread))))))))
8269 (defun gnus-remove-thread-1 (thread)
8270 "Remove the thread THREAD recursively."
8271 (let ((number (mail-header-number (car thread)))
8273 (when (setq pos (text-property-any
8274 (point-min) (point-max) 'gnus-number number))
8277 (gnus-data-remove number))
8278 (setq thread (cdr thread))
8280 (gnus-remove-thread-1 (pop thread)))))
8282 (defun gnus-sort-threads (threads)
8284 (if (not gnus-thread-sort-functions)
8286 (let ((func (if (= 1 (length gnus-thread-sort-functions))
8287 (car gnus-thread-sort-functions)
8289 ,(gnus-make-sort-function
8290 (reverse gnus-thread-sort-functions))))))
8291 (gnus-message 7 "Sorting threads...")
8294 (gnus-message 7 "Sorting threads...done")))))
8296 (defun gnus-sort-articles (articles)
8298 (when gnus-article-sort-functions
8299 (let ((func (if (= 1 (length gnus-article-sort-functions))
8300 (car gnus-article-sort-functions)
8302 ,(gnus-make-sort-function
8303 (reverse gnus-article-sort-functions))))))
8304 (gnus-message 7 "Sorting articles...")
8306 (setq gnus-newsgroup-headers (sort articles func))
8307 (gnus-message 7 "Sorting articles...done")))))
8309 (defun gnus-make-sort-function (funs)
8310 "Return a composite sort condition based on the functions in FUNC."
8312 `(or (,(car funs) t1 t2)
8313 (and (not (,(car funs) t2 t1))
8314 ,(gnus-make-sort-function (cdr funs))))
8315 `(,(car funs) t1 t2)))
8317 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
8318 (defmacro gnus-thread-header (thread)
8319 ;; Return header of first article in THREAD.
8320 ;; Note that THREAD must never, ever be anything else than a variable -
8321 ;; using some other form will lead to serious barfage.
8322 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
8323 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
8324 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
8327 (defsubst gnus-article-sort-by-number (h1 h2)
8328 "Sort articles by article number."
8329 (< (mail-header-number h1)
8330 (mail-header-number h2)))
8332 (defun gnus-thread-sort-by-number (h1 h2)
8333 "Sort threads by root article number."
8334 (gnus-article-sort-by-number
8335 (gnus-thread-header h1) (gnus-thread-header h2)))
8337 (defsubst gnus-article-sort-by-author (h1 h2)
8338 "Sort articles by root author."
8340 (let ((extract (funcall
8341 gnus-extract-address-components
8342 (mail-header-from h1))))
8343 (or (car extract) (cdr extract)))
8344 (let ((extract (funcall
8345 gnus-extract-address-components
8346 (mail-header-from h2))))
8347 (or (car extract) (cdr extract)))))
8349 (defun gnus-thread-sort-by-author (h1 h2)
8350 "Sort threads by root author."
8351 (gnus-article-sort-by-author
8352 (gnus-thread-header h1) (gnus-thread-header h2)))
8354 (defsubst gnus-article-sort-by-subject (h1 h2)
8355 "Sort articles by root subject."
8357 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
8358 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
8360 (defun gnus-thread-sort-by-subject (h1 h2)
8361 "Sort threads by root subject."
8362 (gnus-article-sort-by-subject
8363 (gnus-thread-header h1) (gnus-thread-header h2)))
8365 (defsubst gnus-article-sort-by-date (h1 h2)
8366 "Sort articles by root article date."
8368 (inline (gnus-sortable-date (mail-header-date h1)))
8369 (inline (gnus-sortable-date (mail-header-date h2)))))
8371 (defun gnus-thread-sort-by-date (h1 h2)
8372 "Sort threads by root article date."
8373 (gnus-article-sort-by-date
8374 (gnus-thread-header h1) (gnus-thread-header h2)))
8376 (defsubst gnus-article-sort-by-score (h1 h2)
8377 "Sort articles by root article score.
8378 Unscored articles will be counted as having a score of zero."
8379 (> (or (cdr (assq (mail-header-number h1)
8380 gnus-newsgroup-scored))
8381 gnus-summary-default-score 0)
8382 (or (cdr (assq (mail-header-number h2)
8383 gnus-newsgroup-scored))
8384 gnus-summary-default-score 0)))
8386 (defun gnus-thread-sort-by-score (h1 h2)
8387 "Sort threads by root article score."
8388 (gnus-article-sort-by-score
8389 (gnus-thread-header h1) (gnus-thread-header h2)))
8391 (defun gnus-thread-sort-by-total-score (h1 h2)
8392 "Sort threads by the sum of all scores in the thread.
8393 Unscored articles will be counted as having a score of zero."
8394 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
8396 (defun gnus-thread-total-score (thread)
8397 ;; This function find the total score of THREAD.
8398 (cond ((null thread)
8401 (if (stringp (car thread))
8402 (apply gnus-thread-score-function 0
8403 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
8404 (gnus-thread-total-score-1 thread)))
8406 (gnus-thread-total-score-1 (list thread)))))
8408 (defun gnus-thread-total-score-1 (root)
8409 ;; This function find the total score of the thread below ROOT.
8410 (setq root (car root))
8411 (apply gnus-thread-score-function
8412 (or (cdr (assq (mail-header-number root) gnus-newsgroup-scored))
8413 gnus-summary-default-score 0)
8414 (mapcar 'gnus-thread-total-score
8415 (cdr (gnus-gethash (mail-header-id root)
8416 gnus-newsgroup-dependencies)))))
8418 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8419 (defvar gnus-tmp-prev-subject nil)
8420 (defvar gnus-tmp-false-parent nil)
8421 (defvar gnus-tmp-root-expunged nil)
8422 (defvar gnus-tmp-dummy-line nil)
8424 (defun gnus-summary-prepare-threads (threads)
8425 "Prepare summary buffer from THREADS and indentation LEVEL.
8426 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
8427 or a straight list of headers."
8428 (gnus-message 7 "Generating summary...")
8430 (setq gnus-newsgroup-threads threads)
8433 (let ((gnus-tmp-level 0)
8434 (default-score (or gnus-summary-default-score 0))
8435 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
8436 thread number subject stack state gnus-tmp-gathered beg-match
8437 new-roots gnus-tmp-new-adopts thread-end
8438 gnus-tmp-header gnus-tmp-unread
8439 gnus-tmp-replied gnus-tmp-subject-or-nil
8440 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
8441 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
8442 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
8444 (setq gnus-tmp-prev-subject nil)
8446 (if (vectorp (car threads))
8447 ;; If this is a straight (sic) list of headers, then a
8448 ;; threaded summary display isn't required, so we just create
8449 ;; an unthreaded one.
8450 (gnus-summary-prepare-unthreaded threads)
8452 ;; Do the threaded display.
8454 (while (or threads stack gnus-tmp-new-adopts new-roots)
8456 (if (and (= gnus-tmp-level 0)
8457 (not (setq gnus-tmp-dummy-line nil))
8460 (not gnus-tmp-false-parent)
8461 (or gnus-tmp-new-adopts new-roots))
8462 (if gnus-tmp-new-adopts
8463 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
8464 thread (list (car gnus-tmp-new-adopts))
8465 gnus-tmp-header (caar thread)
8466 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
8468 (setq thread (list (car new-roots))
8469 gnus-tmp-header (caar thread)
8470 new-roots (cdr new-roots))))
8473 ;; If there are some threads, we do them before the
8474 ;; threads on the stack.
8475 (setq thread threads
8476 gnus-tmp-header (caar thread))
8477 ;; There were no current threads, so we pop something off
8479 (setq state (car stack)
8480 gnus-tmp-level (car state)
8483 gnus-tmp-header (caar thread))))
8485 (setq gnus-tmp-false-parent nil)
8486 (setq gnus-tmp-root-expunged nil)
8487 (setq thread-end nil)
8489 (if (stringp gnus-tmp-header)
8490 ;; The header is a dummy root.
8492 ((eq gnus-summary-make-false-root 'adopt)
8493 ;; We let the first article adopt the rest.
8494 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
8496 (setq gnus-tmp-gathered
8498 (lambda (h) (mail-header-number (car h)))
8501 (setq thread (cons (list (caar thread)
8504 (setq gnus-tmp-level -1
8505 gnus-tmp-false-parent t))
8506 ((eq gnus-summary-make-false-root 'empty)
8507 ;; We print adopted articles with empty subject fields.
8508 (setq gnus-tmp-gathered
8510 (lambda (h) (mail-header-number (car h)))
8513 (setq gnus-tmp-level -1))
8514 ((eq gnus-summary-make-false-root 'dummy)
8515 ;; We remember that we probably want to output a dummy
8517 (setq gnus-tmp-dummy-line gnus-tmp-header)
8518 (setq gnus-tmp-prev-subject gnus-tmp-header))
8520 ;; We do not make a root for the gathered
8521 ;; sub-threads at all.
8522 (setq gnus-tmp-level -1)))
8524 (setq number (mail-header-number gnus-tmp-header)
8525 subject (mail-header-subject gnus-tmp-header))
8528 ;; If the thread has changed subject, we might want to make
8529 ;; this subthread into a root.
8530 ((and (null gnus-thread-ignore-subject)
8531 (not (zerop gnus-tmp-level))
8532 gnus-tmp-prev-subject
8534 (gnus-subject-equal gnus-tmp-prev-subject subject))))
8535 (setq new-roots (nconc new-roots (list (car thread)))
8537 gnus-tmp-header nil))
8538 ;; If the article lies outside the current limit,
8539 ;; then we do not display it.
8540 ((and (not (memq number gnus-newsgroup-limit))
8541 (not gnus-tmp-dummy-line))
8542 (setq gnus-tmp-gathered
8544 (lambda (h) (mail-header-number (car h)))
8547 (setq gnus-tmp-new-adopts (if (cdar thread)
8548 (append gnus-tmp-new-adopts
8550 gnus-tmp-new-adopts)
8552 gnus-tmp-header nil)
8553 (when (zerop gnus-tmp-level)
8554 (setq gnus-tmp-root-expunged t)))
8555 ;; Perhaps this article is to be marked as read?
8556 ((and gnus-summary-mark-below
8557 (< (or (cdr (assq number gnus-newsgroup-scored))
8559 gnus-summary-mark-below)
8560 ;; Don't touch sparse articles.
8561 (not (memq number gnus-newsgroup-sparse))
8562 (not (memq number gnus-newsgroup-ancient)))
8563 (setq gnus-newsgroup-unreads
8564 (delq number gnus-newsgroup-unreads))
8565 (if gnus-newsgroup-auto-expire
8566 (push number gnus-newsgroup-expirable)
8567 (push (cons number gnus-low-score-mark)
8568 gnus-newsgroup-reads))))
8570 (when gnus-tmp-header
8571 ;; We may have an old dummy line to output before this
8573 (when gnus-tmp-dummy-line
8574 (gnus-summary-insert-dummy-line
8575 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
8576 (setq gnus-tmp-dummy-line nil))
8578 ;; Compute the mark.
8582 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8583 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8584 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8585 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8586 (t (or (cdr (assq number gnus-newsgroup-reads))
8587 gnus-ancient-mark))))
8589 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
8590 gnus-tmp-header gnus-tmp-level)
8591 gnus-newsgroup-data)
8593 ;; Actually insert the line.
8595 gnus-tmp-subject-or-nil
8597 ((and gnus-thread-ignore-subject
8598 gnus-tmp-prev-subject
8599 (not (inline (gnus-subject-equal
8600 gnus-tmp-prev-subject subject))))
8602 ((zerop gnus-tmp-level)
8603 (if (and (eq gnus-summary-make-false-root 'empty)
8604 (memq number gnus-tmp-gathered)
8605 gnus-tmp-prev-subject
8606 (inline (gnus-subject-equal
8607 gnus-tmp-prev-subject subject)))
8608 gnus-summary-same-subject
8610 (t gnus-summary-same-subject)))
8611 (if (and (eq gnus-summary-make-false-root 'adopt)
8612 (= gnus-tmp-level 1)
8613 (memq number gnus-tmp-gathered))
8614 (setq gnus-tmp-opening-bracket ?\<
8615 gnus-tmp-closing-bracket ?\>)
8616 (setq gnus-tmp-opening-bracket ?\[
8617 gnus-tmp-closing-bracket ?\]))
8619 gnus-tmp-indentation
8620 (aref gnus-thread-indent-array gnus-tmp-level)
8621 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
8622 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
8623 gnus-summary-default-score 0)
8625 (if (or (null gnus-summary-default-score)
8626 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
8627 gnus-summary-zcore-fuzz)) ?
8628 (if (< gnus-tmp-score gnus-summary-default-score)
8629 gnus-score-below-mark gnus-score-over-mark))
8631 (cond ((memq number gnus-newsgroup-processable)
8633 ((memq number gnus-newsgroup-cached)
8635 ((memq number gnus-newsgroup-replied)
8637 (t gnus-unread-mark))
8638 gnus-tmp-from (mail-header-from gnus-tmp-header)
8641 ((string-match "(.+)" gnus-tmp-from)
8642 (substring gnus-tmp-from
8643 (1+ (match-beginning 0)) (1- (match-end 0))))
8644 ((string-match "<[^>]+> *$" gnus-tmp-from)
8645 (setq beg-match (match-beginning 0))
8646 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
8647 (substring gnus-tmp-from (1+ (match-beginning 0))
8648 (1- (match-end 0))))
8649 (substring gnus-tmp-from 0 beg-match)))
8651 (when (string= gnus-tmp-name "")
8652 (setq gnus-tmp-name gnus-tmp-from))
8653 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
8654 (gnus-put-text-property
8656 (progn (eval gnus-summary-line-format-spec) (point))
8657 'gnus-number number)
8660 (run-hooks 'gnus-summary-update-hook)
8663 (setq gnus-tmp-prev-subject subject)))
8665 (when (nth 1 thread)
8666 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
8667 (incf gnus-tmp-level)
8668 (setq threads (if thread-end nil (cdar thread)))
8670 (setq gnus-tmp-level 0)))))
8671 (gnus-message 7 "Generating summary...done"))
8673 (defun gnus-summary-prepare-unthreaded (headers)
8674 "Generate an unthreaded summary buffer based on HEADERS."
8675 (let (header number mark)
8678 ;; We may have to root out some bad articles...
8679 (when (memq (setq number (mail-header-number
8680 (setq header (pop headers))))
8681 gnus-newsgroup-limit)
8682 ;; Mark article as read when it has a low score.
8683 (when (and gnus-summary-mark-below
8684 (< (or (cdr (assq number gnus-newsgroup-scored))
8685 gnus-summary-default-score 0)
8686 gnus-summary-mark-below)
8687 (not (memq number gnus-newsgroup-ancient)))
8688 (setq gnus-newsgroup-unreads
8689 (delq number gnus-newsgroup-unreads))
8690 (if gnus-newsgroup-auto-expire
8691 (push number gnus-newsgroup-expirable)
8692 (push (cons number gnus-low-score-mark)
8693 gnus-newsgroup-reads)))
8697 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8698 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8699 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8700 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8701 (t (or (cdr (assq number gnus-newsgroup-reads))
8702 gnus-ancient-mark))))
8703 (setq gnus-newsgroup-data
8704 (cons (gnus-data-make number mark (1+ (point)) header 0)
8705 gnus-newsgroup-data))
8706 (gnus-summary-insert-line
8707 header 0 nil mark (memq number gnus-newsgroup-replied)
8708 (memq number gnus-newsgroup-expirable)
8709 (mail-header-subject header) nil
8710 (cdr (assq number gnus-newsgroup-scored))
8711 (memq number gnus-newsgroup-processable))))))
8713 (defun gnus-select-newsgroup (group &optional read-all)
8714 "Select newsgroup GROUP.
8715 If READ-ALL is non-nil, all articles in the group are selected."
8716 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
8717 (info (nth 2 entry))
8718 articles fetched-articles cached)
8720 (or (gnus-check-server
8721 (setq gnus-current-select-method (gnus-find-method-for-group group)))
8722 (error "Couldn't open server"))
8724 (or (and entry (not (eq (car entry) t))) ; Either it's active...
8725 (gnus-activate-group group) ; Or we can activate it...
8726 (progn ; Or we bug out.
8727 (when (equal major-mode 'gnus-summary-mode)
8728 (kill-buffer (current-buffer)))
8729 (error "Couldn't request group %s: %s"
8730 group (gnus-status-message group))))
8732 (unless (gnus-request-group group t)
8733 (when (equal major-mode 'gnus-summary-mode)
8734 (kill-buffer (current-buffer)))
8735 (error "Couldn't request group %s: %s"
8736 group (gnus-status-message group)))
8738 (setq gnus-newsgroup-name group)
8739 (setq gnus-newsgroup-unselected nil)
8740 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
8742 (and gnus-asynchronous
8743 (gnus-check-backend-function
8744 'request-asynchronous gnus-newsgroup-name)
8745 (setq gnus-newsgroup-async
8746 (gnus-request-asynchronous gnus-newsgroup-name)))
8748 ;; Adjust and set lists of article marks.
8750 (gnus-adjust-marked-articles info))
8752 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8753 (when (gnus-virtual-group-p group)
8754 (setq cached gnus-newsgroup-cached))
8756 (setq gnus-newsgroup-unreads
8757 (gnus-set-difference
8758 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
8759 gnus-newsgroup-dormant))
8761 (setq gnus-newsgroup-processable nil)
8763 (setq articles (gnus-articles-to-read group read-all))
8767 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
8769 ((eq articles 0) nil)
8771 ;; Init the dependencies hash table.
8772 (setq gnus-newsgroup-dependencies
8773 (gnus-make-hashtable (length articles)))
8774 ;; Retrieve the headers and read them in.
8775 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8776 (setq gnus-newsgroup-headers
8778 (setq gnus-headers-retrieved-by
8779 (gnus-retrieve-headers
8780 articles gnus-newsgroup-name
8781 ;; We might want to fetch old headers, but
8782 ;; not if there is only 1 article.
8783 (and gnus-fetch-old-headers
8785 (not (eq gnus-fetch-old-headers 'some))
8786 (not (numberp gnus-fetch-old-headers)))
8787 (> (length articles) 1))))))
8788 (gnus-get-newsgroup-headers-xover articles)
8789 (gnus-get-newsgroup-headers)))
8790 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
8792 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8794 (setq gnus-newsgroup-cached cached))
8796 ;; Set the initial limit.
8797 (setq gnus-newsgroup-limit (copy-sequence articles))
8798 ;; Remove canceled articles from the list of unread articles.
8799 (setq gnus-newsgroup-unreads
8800 (gnus-set-sorted-intersection
8801 gnus-newsgroup-unreads
8802 (setq fetched-articles
8803 (mapcar (lambda (headers) (mail-header-number headers))
8804 gnus-newsgroup-headers))))
8805 ;; Removed marked articles that do not exist.
8806 (gnus-update-missing-marks
8807 (gnus-sorted-complement fetched-articles articles))
8808 ;; We might want to build some more threads first.
8809 (and gnus-fetch-old-headers
8810 (eq gnus-headers-retrieved-by 'nov)
8811 (gnus-build-old-threads))
8812 ;; Check whether auto-expire is to be done in this group.
8813 (setq gnus-newsgroup-auto-expire
8814 (gnus-group-auto-expirable-p group))
8815 ;; Set up the article buffer now, if necessary.
8816 (unless gnus-single-article-buffer
8817 (gnus-article-setup-buffer))
8818 ;; First and last article in this newsgroup.
8819 (when gnus-newsgroup-headers
8820 (setq gnus-newsgroup-begin
8821 (mail-header-number (car gnus-newsgroup-headers))
8824 (gnus-last-element gnus-newsgroup-headers))))
8825 (setq gnus-reffed-article-number -1)
8826 ;; GROUP is successfully selected.
8827 (or gnus-newsgroup-headers t)))))
8829 (defun gnus-articles-to-read (group read-all)
8830 ;; Find out what articles the user wants to read.
8832 ;; Select all articles if `read-all' is non-nil, or if there
8833 ;; are no unread articles.
8835 (and (zerop (length gnus-newsgroup-marked))
8836 (zerop (length gnus-newsgroup-unreads))))
8837 (gnus-uncompress-range (gnus-active group))
8838 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
8839 (copy-sequence gnus-newsgroup-unreads))
8841 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
8842 (scored (length scored-list))
8843 (number (length articles))
8844 (marked (+ (length gnus-newsgroup-marked)
8845 (length gnus-newsgroup-dormant)))
8853 ((and (or (<= scored marked) (= scored number))
8854 (numberp gnus-large-newsgroup)
8855 (> number gnus-large-newsgroup))
8859 "How many articles from %s (default %d): "
8860 gnus-newsgroup-name number))))
8861 (if (string-match "^[ \t]*$" input) number input)))
8862 ((and (> scored marked) (< scored number)
8863 (> (- scored number) 20))
8866 (format "%s %s (%d scored, %d total): "
8867 "How many articles from"
8868 group scored number))))
8869 (if (string-match "^[ \t]*$" input)
8873 (setq select (if (stringp select) (string-to-number select) select))
8874 (if (or (null select) (zerop select))
8876 (if (and (not (zerop scored)) (<= (abs select) scored))
8878 (setq articles (sort scored-list '<))
8879 (setq number (length articles)))
8880 (setq articles (copy-sequence articles)))
8882 (if (< (abs select) number)
8884 ;; Select the N oldest articles.
8885 (setcdr (nthcdr (1- (abs select)) articles) nil)
8886 ;; Select the N most recent articles.
8887 (setq articles (nthcdr (- number select) articles))))
8888 (setq gnus-newsgroup-unselected
8889 (gnus-sorted-intersection
8890 gnus-newsgroup-unreads
8891 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
8894 (defun gnus-killed-articles (killed articles)
8897 (if (inline (gnus-member-of-range (car articles) killed))
8898 (setq out (cons (car articles) out)))
8899 (setq articles (cdr articles)))
8902 (defun gnus-uncompress-marks (marks)
8903 "Uncompress the mark ranges in MARKS."
8904 (let ((uncompressed '(score bookmark))
8907 (if (memq (caar marks) uncompressed)
8908 (push (car marks) out)
8909 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
8910 (setq marks (cdr marks)))
8913 (defun gnus-adjust-marked-articles (info)
8914 "Set all article lists and remove all marks that are no longer legal."
8915 (let* ((marked-lists (gnus-info-marks info))
8916 (active (gnus-active (gnus-info-group info)))
8919 (types gnus-article-mark-lists)
8920 (uncompressed '(score bookmark))
8921 marks var articles article mark)
8924 (setq marks (pop marked-lists))
8925 (set (setq var (intern (format "gnus-newsgroup-%s"
8926 (car (rassq (setq mark (car marks))
8928 (if (memq (car marks) uncompressed) (cdr marks)
8929 (gnus-uncompress-range (cdr marks))))
8931 (setq articles (symbol-value var))
8933 ;; All articles have to be subsets of the active articles.
8935 ;; Adjust "simple" lists.
8936 ((memq mark '(tick dormant expirable reply killed save))
8938 (when (or (< (setq article (pop articles)) min) (> article max))
8939 (set var (delq article (symbol-value var))))))
8941 ((memq mark '(score bookmark))
8943 (when (or (< (car (setq article (pop articles))) min)
8944 (> (car article) max))
8945 (set var (delq article (symbol-value var))))))))))
8947 (defun gnus-update-missing-marks (missing)
8948 "Go through the list of MISSING articles and remove them mark lists."
8950 (let ((types gnus-article-mark-lists)
8952 ;; Go through all types.
8954 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
8955 (when (symbol-value var)
8956 ;; This list has articles. So we delete all missing articles
8960 (set var (delq (pop m) (symbol-value var)))))))))
8962 (defun gnus-update-marks ()
8963 "Enter the various lists of marked articles into the newsgroup info list."
8964 (let ((types gnus-article-mark-lists)
8965 (info (gnus-get-info gnus-newsgroup-name))
8966 (uncompressed '(score bookmark killed))
8967 type list newmarked symbol)
8969 ;; Add all marks lists that are non-nil to the list of marks lists.
8971 (setq type (pop types))
8972 (when (setq list (symbol-value
8974 (intern (format "gnus-newsgroup-%s"
8976 (push (cons (cdr type)
8977 (if (memq (cdr type) uncompressed) list
8978 (gnus-compress-sequence (set symbol (sort list '<)) t)))
8981 ;; Enter these new marks into the info of the group.
8983 (setcar (nthcdr 3 info) newmarked)
8984 ;; Add the marks lists to the end of the info.
8986 (setcdr (nthcdr 2 info) (list newmarked))))
8988 ;; Cut off the end of the info if there's nothing else there.
8992 (when (nthcdr (decf i) info)
8993 (setcdr (nthcdr i info) nil)))))))
8995 (defun gnus-add-marked-articles (group type articles &optional info force)
8996 ;; Add ARTICLES of TYPE to the info of GROUP.
8997 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
8998 ;; add, but replace marked articles of TYPE with ARTICLES.
8999 (let ((info (or info (gnus-get-info group)))
9000 (uncompressed '(score bookmark killed))
9003 (and (not (setq marked (nthcdr 3 info)))
9005 (setcdr (nthcdr 2 info)
9006 (list (list (cons type (gnus-compress-sequence
9008 (and (not (setq m (assq type (car marked))))
9011 (cons (cons type (gnus-compress-sequence articles t) )
9015 (setcar (nthcdr 3 info)
9016 (delq (assq type (car marked)) (car marked)))
9017 (setcdr m (gnus-compress-sequence articles t)))
9018 (setcdr m (gnus-compress-sequence
9019 (sort (nconc (gnus-uncompress-range (cdr m))
9020 (copy-sequence articles)) '<) t))))))
9022 (defun gnus-set-mode-line (where)
9023 "This function sets the mode line of the article or summary buffers.
9024 If WHERE is `summary', the summary mode line format will be used."
9025 ;; Is this mode line one we keep updated?
9026 (when (memq where gnus-updated-mode-lines)
9029 ;; We evaluate this in the summary buffer since these
9030 ;; variables are buffer-local to that buffer.
9031 (set-buffer gnus-summary-buffer)
9032 ;; We bind all these variables that are used in the `eval' form
9034 (let* ((mformat (symbol-value
9036 (format "gnus-%s-mode-line-format-spec" where))))
9037 (gnus-tmp-group-name gnus-newsgroup-name)
9038 (gnus-tmp-article-number (or gnus-current-article 0))
9039 (gnus-tmp-unread gnus-newsgroup-unreads)
9040 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
9041 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
9042 (gnus-tmp-unread-and-unselected
9043 (cond ((and (zerop gnus-tmp-unread-and-unticked)
9044 (zerop gnus-tmp-unselected)) "")
9045 ((zerop gnus-tmp-unselected)
9046 (format "{%d more}" gnus-tmp-unread-and-unticked))
9047 (t (format "{%d(+%d) more}"
9048 gnus-tmp-unread-and-unticked
9049 gnus-tmp-unselected))))
9051 (if (and gnus-current-headers
9052 (vectorp gnus-current-headers))
9053 (gnus-mode-string-quote
9054 (mail-header-subject gnus-current-headers)) ""))
9056 gnus-tmp-header);; passed as argument to any user-format-funcs
9057 (setq mode-string (eval mformat))
9058 (setq max-len (max 4 (if gnus-mode-non-string-length
9060 gnus-mode-non-string-length)
9061 (length mode-string))))
9062 ;; We might have to chop a bit of the string off...
9063 (when (> (length mode-string) max-len)
9065 (concat (gnus-truncate-string mode-string (- max-len 3))
9067 ;; Pad the mode string a bit.
9068 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
9069 ;; Update the mode line.
9070 (setq mode-line-buffer-identification (list mode-string))
9071 (set-buffer-modified-p t))))
9073 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
9074 "Go through the HEADERS list and add all Xrefs to a hash table.
9075 The resulting hash table is returned, or nil if no Xrefs were found."
9076 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
9077 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
9078 (xref-hashtb (make-vector 63 0))
9079 start group entry number xrefs header)
9081 (setq header (pop headers))
9082 (when (and (setq xrefs (mail-header-xref header))
9083 (not (memq (setq number (mail-header-number header))
9086 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
9087 (setq start (match-end 0))
9088 (setq group (if prefix
9089 (concat prefix (substring xrefs (match-beginning 1)
9091 (substring xrefs (match-beginning 1) (match-end 1))))
9093 (string-to-int (substring xrefs (match-beginning 2)
9095 (if (setq entry (gnus-gethash group xref-hashtb))
9096 (setcdr entry (cons number (cdr entry)))
9097 (gnus-sethash group (cons number nil) xref-hashtb)))))
9098 (and start xref-hashtb)))
9100 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
9101 "Look through all the headers and mark the Xrefs as read."
9102 (let ((virtual (gnus-virtual-group-p from-newsgroup))
9103 name entry info xref-hashtb idlist method nth4)
9105 (set-buffer gnus-group-buffer)
9106 (when (setq xref-hashtb
9107 (gnus-create-xref-hashtb from-newsgroup headers unreads))
9110 (unless (string= from-newsgroup (setq name (symbol-name group)))
9111 (setq idlist (symbol-value group))
9112 ;; Dead groups are not updated.
9114 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
9116 (if (stringp (setq nth4 (gnus-info-method info)))
9117 (setq nth4 (gnus-server-to-method nth4))))
9118 ;; Only do the xrefs if the group has the same
9119 ;; select method as the group we have just read.
9120 (or (gnus-methods-equal-p
9121 nth4 (gnus-find-method-for-group from-newsgroup))
9123 (equal nth4 (setq method (gnus-find-method-for-group
9125 (and (equal (car nth4) (car method))
9126 (equal (nth 1 nth4) (nth 1 method))))
9127 gnus-use-cross-reference
9128 (or (not (eq gnus-use-cross-reference t))
9130 ;; Only do cross-references on subscribed
9131 ;; groups, if that is what is wanted.
9132 (<= (gnus-info-level info) gnus-level-subscribed))
9133 (gnus-group-make-articles-read name idlist))))
9136 (defun gnus-group-make-articles-read (group articles)
9138 (entry (gnus-gethash group gnus-newsrc-hashtb))
9139 (info (nth 2 entry))
9140 (active (gnus-active group))
9142 ;; First peel off all illegal article numbers.
9144 (let ((ids articles)
9148 (if (and first (> id (cdr active)))
9150 ;; We'll end up in this situation in one particular
9151 ;; obscure situation. If you re-scan a group and get
9152 ;; a new article that is cross-posted to a different
9153 ;; group that has not been re-scanned, you might get
9154 ;; crossposted article that has a higher number than
9155 ;; Gnus believes possible. So we re-activate this
9156 ;; group as well. This might mean doing the
9157 ;; crossposting thingy will *increase* the number
9158 ;; of articles in some groups. Tsk, tsk.
9159 (setq active (or (gnus-activate-group group) active))))
9160 (if (or (> id (cdr active))
9161 (< id (car active)))
9162 (setq articles (delq id articles)))
9163 (setq ids (cdr ids)))))
9164 ;; If the read list is nil, we init it.
9166 (null (gnus-info-read info))
9168 (gnus-info-set-read info (cons 1 (1- (car active)))))
9169 ;; Then we add the read articles to the range.
9174 (gnus-info-read info) (setq articles (sort articles '<)))))
9175 ;; Then we have to re-compute how many unread
9176 ;; articles there are in this group.
9181 (setq num (- (1+ (cdr active)) (car active))))
9182 ((not (listp (cdr range)))
9183 (setq num (- (cdr active) (- (1+ (cdr range))
9187 (if (numberp (car range))
9189 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
9190 (setq range (cdr range)))
9191 (setq num (- (cdr active) num))))
9192 ;; Update the number of unread articles.
9194 ;; Update the group buffer.
9195 (gnus-group-update-group group t)))))
9197 (defun gnus-methods-equal-p (m1 m2)
9198 (let ((m1 (or m1 gnus-select-method))
9199 (m2 (or m2 gnus-select-method)))
9201 (and (eq (car m1) (car m2))
9202 (or (not (memq 'address (assoc (symbol-name (car m1))
9203 gnus-valid-select-methods)))
9204 (equal (nth 1 m1) (nth 1 m2)))))))
9206 (defsubst gnus-header-value ()
9209 (if (re-search-forward "^[^ \t]" nil t)
9213 (gnus-point-at-eol))))
9215 (defvar gnus-newsgroup-none-id 0)
9217 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
9218 (let ((cur nntp-server-buffer)
9221 (save-excursion (set-buffer gnus-summary-buffer)
9222 gnus-newsgroup-dependencies)))
9223 headers id id-dep ref-dep end ref)
9225 (set-buffer nntp-server-buffer)
9226 (run-hooks 'gnus-parse-headers-hook)
9227 (let ((case-fold-search t)
9228 in-reply-to header p lines)
9229 (goto-char (point-min))
9230 ;; Search to the beginning of the next header. Error messages
9231 ;; do not begin with 2 or 3.
9232 (while (re-search-forward "^[23][0-9]+ " nil t)
9235 ;; This implementation of this function, with nine
9236 ;; search-forwards instead of the one re-search-forward and
9237 ;; a case (which basically was the old function) is actually
9238 ;; about twice as fast, even though it looks messier. You
9239 ;; can't have everything, I guess. Speed and elegance
9240 ;; doesn't always go hand in hand.
9249 (narrow-to-region (point)
9250 (or (and (search-forward "\n.\n" nil t)
9256 (if (search-forward "\nsubject: " nil t)
9257 (gnus-header-value) "(none)"))
9261 (if (search-forward "\nfrom: " nil t)
9262 (gnus-header-value) "(nobody)"))
9266 (if (search-forward "\ndate: " nil t)
9267 (gnus-header-value) ""))
9271 (if (search-forward "\nmessage-id: " nil t)
9272 (setq id (gnus-header-value))
9273 ;; If there was no message-id, we just fake one to make
9274 ;; subsequent routines simpler.
9275 (setq id (concat "none+"
9277 (setq gnus-newsgroup-none-id
9278 (1+ gnus-newsgroup-none-id)))))))
9282 (if (search-forward "\nreferences: " nil t)
9291 (search-backward ">" end t)
9294 (search-backward "<" end t)
9296 ;; Get the references from the in-reply-to header if there
9297 ;; were no references and the in-reply-to header looks
9299 (if (and (search-forward "\nin-reply-to: " nil t)
9300 (setq in-reply-to (gnus-header-value))
9301 (string-match "<[^>]+>" in-reply-to))
9302 (setq ref (substring in-reply-to (match-beginning 0)
9310 (if (search-forward "\nlines: " nil t)
9311 (if (numberp (setq lines (read cur)))
9317 (and (search-forward "\nxref: " nil t)
9318 (gnus-header-value)))))
9319 ;; We do the threading while we read the headers. The
9320 ;; message-id and the last reference are both entered into
9321 ;; the same hash table. Some tippy-toeing around has to be
9322 ;; done in case an article has arrived before the article
9323 ;; which it refers to.
9324 (if (boundp (setq id-dep (intern id dependencies)))
9325 (if (and (car (symbol-value id-dep))
9327 ;; An article with this Message-ID has already
9328 ;; been seen, so we ignore this one, except we add
9329 ;; any additional Xrefs (in case the two articles
9330 ;; came from different servers).
9332 (mail-header-set-xref
9333 (car (symbol-value id-dep))
9334 (concat (or (mail-header-xref
9335 (car (symbol-value id-dep))) "")
9336 (or (mail-header-xref header) "")))
9338 (setcar (symbol-value id-dep) header))
9339 (set id-dep (list header)))
9341 (if (boundp (setq ref-dep (intern ref dependencies)))
9342 (setcdr (symbol-value ref-dep)
9343 (nconc (cdr (symbol-value ref-dep))
9344 (list (symbol-value id-dep))))
9345 (set ref-dep (list nil (symbol-value id-dep))))
9346 (setq headers (cons header headers)))
9347 (goto-char (point-max))
9349 (nreverse headers)))))
9351 ;; The following macros and functions were written by Felix Lee
9352 ;; <flee@cse.psu.edu>.
9354 (defmacro gnus-nov-read-integer ()
9356 (if (= (following-char) ?\t)
9358 (let ((num (condition-case nil (read buffer) (error nil))))
9359 (if (numberp num) num 0)))
9360 (or (eobp) (forward-char 1))))
9362 (defmacro gnus-nov-skip-field ()
9363 '(search-forward "\t" eol 'move))
9365 (defmacro gnus-nov-field ()
9366 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
9368 ;; Goes through the xover lines and returns a list of vectors
9369 (defun gnus-get-newsgroup-headers-xover (sequence &optional
9370 force-new dependencies)
9371 "Parse the news overview data in the server buffer, and return a
9372 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
9373 ;; Get the Xref when the users reads the articles since most/some
9374 ;; NNTP servers do not include Xrefs when using XOVER.
9375 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
9376 (let ((cur nntp-server-buffer)
9377 (dependencies (or dependencies gnus-newsgroup-dependencies))
9378 number headers header)
9380 (set-buffer nntp-server-buffer)
9381 ;; Allow the user to mangle the headers before parsing them.
9382 (run-hooks 'gnus-parse-headers-hook)
9383 (goto-char (point-min))
9384 (while (and sequence (not (eobp)))
9385 (setq number (read cur))
9386 (while (and sequence (< (car sequence) number))
9387 (setq sequence (cdr sequence)))
9389 (eq number (car sequence))
9391 (setq sequence (cdr sequence))
9393 (inline (gnus-nov-parse-line
9394 number dependencies force-new)))
9395 (setq headers (cons header headers)))))
9397 (setq headers (nreverse headers)))
9400 ;; This function has to be called with point after the article number
9401 ;; on the beginning of the line.
9402 (defun gnus-nov-parse-line (number dependencies &optional force-new)
9404 (eol (gnus-point-at-eol))
9405 (buffer (current-buffer))
9406 header ref id id-dep ref-dep)
9408 ;; overview: [num subject from date id refs chars lines misc]
9409 (narrow-to-region (point) eol)
9410 (or (eobp) (forward-char))
9416 (gnus-nov-field) ; subject
9417 (gnus-nov-field) ; from
9418 (gnus-nov-field) ; date
9419 (setq id (or (gnus-nov-field)
9422 (setq none (1+ none)))))) ; id
9425 (let ((beg (point)))
9426 (search-forward "\t" eol)
9427 (if (search-backward ">" beg t)
9431 (search-backward "<" beg t)))
9433 (gnus-nov-field)) ; refs
9434 (gnus-nov-read-integer) ; chars
9435 (gnus-nov-read-integer) ; lines
9436 (if (= (following-char) ?\n)
9438 (gnus-nov-field)) ; misc
9441 (gnus-error 4 "Strange nov line")
9447 ;; We build the thread tree.
9449 (if (boundp (setq id-dep (intern id dependencies)))
9450 (if (and (car (symbol-value id-dep))
9452 ;; An article with this Message-ID has already been seen,
9453 ;; so we ignore this one, except we add any additional
9454 ;; Xrefs (in case the two articles came from different
9457 (mail-header-set-xref
9458 (car (symbol-value id-dep))
9459 (concat (or (mail-header-xref
9460 (car (symbol-value id-dep))) "")
9461 (or (mail-header-xref header) "")))
9463 (setcar (symbol-value id-dep) header))
9464 (set id-dep (list header))))
9466 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
9467 (setcdr (symbol-value ref-dep)
9468 (nconc (cdr (symbol-value ref-dep))
9469 (list (symbol-value id-dep))))
9470 (set ref-dep (list nil (symbol-value id-dep)))))
9473 (defun gnus-article-get-xrefs ()
9474 "Fill in the Xref value in `gnus-current-headers', if necessary.
9475 This is meant to be called in `gnus-article-internal-prepare-hook'."
9476 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
9477 gnus-current-headers)))
9478 (or (not gnus-use-cross-reference)
9480 (and (mail-header-xref headers)
9481 (not (string= (mail-header-xref headers) "")))
9482 (let ((case-fold-search t)
9485 (nnheader-narrow-to-headers)
9486 (goto-char (point-min))
9487 (if (or (and (eq (downcase (following-char)) ?x)
9488 (looking-at "Xref:"))
9489 (search-forward "\nXref:" nil t))
9491 (goto-char (1+ (match-end 0)))
9492 (setq xref (buffer-substring (point)
9493 (progn (end-of-line) (point))))
9494 (mail-header-set-xref headers xref))))))))
9496 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
9497 "Find article ID and insert the summary line for that article."
9498 (let ((header (if (and old-header use-old-header)
9499 old-header (gnus-read-header id)))
9500 (number (and (numberp id) id))
9503 ;; Rebuild the thread that this article is part of and go to the
9504 ;; article we have fetched.
9505 (when (and (not gnus-show-threads)
9507 (when (setq pos (text-property-any
9508 (point-min) (point-max) 'gnus-number
9509 (mail-header-number old-header)))
9512 (gnus-data-remove (mail-header-number old-header))))
9514 (mail-header-set-number header (mail-header-number old-header)))
9515 (setq gnus-newsgroup-sparse
9516 (delq (setq number (mail-header-number header))
9517 gnus-newsgroup-sparse))
9518 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
9519 (gnus-rebuild-thread (mail-header-id header))
9520 (gnus-summary-goto-subject number nil t))
9521 (when (and (numberp number)
9523 ;; We have to update the boundaries even if we can't fetch the
9524 ;; article if ID is a number -- so that the next `P' or `N'
9525 ;; command will fetch the previous (or next) article even
9526 ;; if the one we tried to fetch this time has been canceled.
9527 (and (> number gnus-newsgroup-end)
9528 (setq gnus-newsgroup-end number))
9529 (and (< number gnus-newsgroup-begin)
9530 (setq gnus-newsgroup-begin number))
9531 (setq gnus-newsgroup-unselected
9532 (delq number gnus-newsgroup-unselected)))
9533 ;; Report back a success?
9534 (and header (mail-header-number header))))
9536 (defun gnus-summary-work-articles (n)
9537 "Return a list of articles to be worked upon. The prefix argument,
9538 the list of process marked articles, and the current article will be
9539 taken into consideration."
9541 ((and n (numberp n))
9542 ;; A numerical prefix has been given.
9543 (let ((backward (< n 0))
9549 (push (setq article (gnus-summary-article-number))
9552 (gnus-summary-find-prev nil article)
9553 (gnus-summary-find-next nil article)))
9555 (nreverse articles)))
9556 ((and (boundp 'transient-mark-mode)
9559 ;; Work on the region between point and mark.
9560 (let ((max (max (point) (mark)))
9563 (goto-char (min (point) (mark)))
9566 (push (setq article (gnus-summary-article-number)) articles)
9567 (gnus-summary-find-next nil article)
9569 (nreverse articles))))
9570 (gnus-newsgroup-processable
9571 ;; There are process-marked articles present.
9572 (reverse gnus-newsgroup-processable))
9574 ;; Just return the current article.
9575 (list (gnus-summary-article-number)))))
9577 (defun gnus-summary-search-group (&optional backward use-level)
9578 "Search for next unread newsgroup.
9579 If optional argument BACKWARD is non-nil, search backward instead."
9581 (set-buffer gnus-group-buffer)
9582 (if (gnus-group-search-forward
9583 backward nil (if use-level (gnus-group-group-level) nil))
9584 (gnus-group-group-name))))
9586 (defun gnus-summary-best-group (&optional exclude-group)
9587 "Find the name of the best unread group.
9588 If EXCLUDE-GROUP, do not go to this group."
9590 (set-buffer gnus-group-buffer)
9592 (gnus-group-best-unread-group exclude-group))))
9594 (defun gnus-summary-find-next (&optional unread article backward)
9595 (if backward (gnus-summary-find-prev)
9596 (let* ((dummy (gnus-summary-article-intangible-p))
9597 (article (or article (gnus-summary-article-number)))
9598 (arts (gnus-data-find-list article))
9600 (when (and (not dummy)
9601 (or (not gnus-summary-check-current)
9603 (not (gnus-data-unread-p (car arts)))))
9604 (setq arts (cdr arts)))
9609 (when (gnus-data-unread-p (car arts))
9610 (setq result (car arts)
9612 (setq arts (cdr arts)))
9615 (goto-char (gnus-data-pos result))
9616 (gnus-data-number result)))))
9618 (defun gnus-summary-find-prev (&optional unread article)
9619 (let* ((eobp (eobp))
9620 (article (or article (gnus-summary-article-number)))
9621 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
9623 (when (and (not eobp)
9624 (or (not gnus-summary-check-current)
9626 (not (gnus-data-unread-p (car arts)))))
9627 (setq arts (cdr arts)))
9632 (and (gnus-data-unread-p (car arts))
9633 (setq result (car arts)
9635 (setq arts (cdr arts)))
9639 (goto-char (gnus-data-pos result))
9640 (gnus-data-number result)))))
9642 (defun gnus-summary-find-subject (subject &optional unread backward article)
9643 (let* ((simp-subject (gnus-simplify-subject-fully subject))
9644 (article (or article (gnus-summary-article-number)))
9645 (articles (gnus-data-list backward))
9646 (arts (gnus-data-find-list article articles))
9648 (when (or (not gnus-summary-check-current)
9650 (not (gnus-data-unread-p (car arts))))
9651 (setq arts (cdr arts)))
9653 (and (or (not unread)
9654 (gnus-data-unread-p (car arts)))
9655 (vectorp (gnus-data-header (car arts)))
9657 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
9658 (setq result (car arts)
9660 (setq arts (cdr arts)))
9662 (goto-char (gnus-data-pos result))
9663 (gnus-data-number result))))
9665 (defun gnus-summary-search-forward (&optional unread subject backward)
9666 "Search forward for an article.
9667 If UNREAD, look for unread articles. If SUBJECT, look for
9668 articles with that subject. If BACKWARD, search backward instead."
9669 (cond (subject (gnus-summary-find-subject subject unread backward))
9670 (backward (gnus-summary-find-prev unread))
9671 (t (gnus-summary-find-next unread))))
9673 (defun gnus-recenter (&optional n)
9674 "Center point in window and redisplay frame.
9675 Also do horizontal recentering."
9677 (when (and gnus-auto-center-summary
9678 (not (eq gnus-auto-center-summary 'vertical)))
9679 (gnus-horizontal-recenter))
9682 (defun gnus-summary-recenter ()
9683 "Center point in the summary window.
9684 If `gnus-auto-center-summary' is nil, or the article buffer isn't
9685 displayed, no centering will be performed."
9686 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
9687 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
9688 (let* ((top (cond ((< (window-height) 4) 0)
9689 ((< (window-height) 7) 1)
9691 (height (1- (window-height)))
9692 (bottom (save-excursion (goto-char (point-max))
9693 (forward-line (- height))
9695 (window (get-buffer-window (current-buffer))))
9696 ;; The user has to want it.
9697 (when gnus-auto-center-summary
9698 (when (get-buffer-window gnus-article-buffer)
9699 ;; Only do recentering when the article buffer is displayed,
9700 ;; Set the window start to either `bottom', which is the biggest
9701 ;; possible valid number, or the second line from the top,
9702 ;; whichever is the least.
9704 window (min bottom (save-excursion
9705 (forward-line (- top)) (point)))))
9706 ;; Do horizontal recentering while we're at it.
9707 (when (and (get-buffer-window (current-buffer) t)
9708 (not (eq gnus-auto-center-summary 'vertical)))
9709 (let ((selected (selected-window)))
9710 (select-window (get-buffer-window (current-buffer) t))
9711 (gnus-summary-position-point)
9712 (gnus-horizontal-recenter)
9713 (select-window selected))))))
9715 (defun gnus-horizontal-recenter ()
9716 "Recenter the current buffer horizontally."
9717 (if (< (current-column) (/ (window-width) 2))
9718 (set-window-hscroll (get-buffer-window (current-buffer) t) 0)
9719 (let* ((orig (point))
9720 (end (window-end (get-buffer-window (current-buffer) t)))
9722 ;; Find the longest line currently displayed in the window.
9723 (goto-char (window-start))
9724 (while (and (not (eobp))
9727 (setq max (max max (current-column)))
9730 ;; Scroll horizontally to center (sort of) the point.
9731 (if (> max (window-width))
9733 (get-buffer-window (current-buffer) t)
9734 (min (- (current-column) (/ (window-width) 3))
9735 (+ 2 (- max (window-width)))))
9736 (set-window-hscroll (get-buffer-window (current-buffer) t) 0))
9739 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
9740 (defun gnus-short-group-name (group &optional levels)
9741 "Collapse GROUP name LEVELS."
9748 (while (string-match "\\." group skip)
9749 (setq skip (match-end 0)
9752 (if (string-match ":" group)
9753 (setq foreign (substring group 0 (match-end 0))
9754 group (substring group (match-end 0))))
9756 (if (and (string-match "\\." group)
9757 (> levels (- gnus-group-uncollapsed-levels 1)))
9758 (setq name (concat name (substring group 0 1))
9759 group (substring group (match-end 0))
9761 name (concat name "."))
9762 (setq name (concat foreign name group)
9766 (defun gnus-summary-jump-to-group (newsgroup)
9767 "Move point to NEWSGROUP in group mode buffer."
9768 ;; Keep update point of group mode buffer if visible.
9769 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
9770 (save-window-excursion
9771 ;; Take care of tree window mode.
9772 (if (get-buffer-window gnus-group-buffer)
9773 (pop-to-buffer gnus-group-buffer))
9774 (gnus-group-jump-to-group newsgroup))
9776 ;; Take care of tree window mode.
9777 (if (get-buffer-window gnus-group-buffer)
9778 (pop-to-buffer gnus-group-buffer)
9779 (set-buffer gnus-group-buffer))
9780 (gnus-group-jump-to-group newsgroup))))
9782 ;; This function returns a list of article numbers based on the
9783 ;; difference between the ranges of read articles in this group and
9784 ;; the range of active articles.
9785 (defun gnus-list-of-unread-articles (group)
9786 (let* ((read (gnus-info-read (gnus-get-info group)))
9787 (active (gnus-active group))
9790 ;; If none are read, then all are unread.
9792 (setq first (car active))
9793 ;; If the range of read articles is a single range, then the
9794 ;; first unread article is the article after the last read
9795 ;; article. Sounds logical, doesn't it?
9796 (if (not (listp (cdr read)))
9797 (setq first (1+ (cdr read)))
9798 ;; `read' is a list of ranges.
9799 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
9804 (while (< first nlast)
9805 (setq unread (cons first unread))
9806 (setq first (1+ first))))
9807 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
9808 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
9809 (setq read (cdr read)))))
9810 ;; And add the last unread articles.
9811 (while (<= first last)
9812 (setq unread (cons first unread))
9813 (setq first (1+ first)))
9814 ;; Return the list of unread articles.
9817 (defun gnus-list-of-read-articles (group)
9818 "Return a list of unread, unticked and non-dormant articles."
9819 (let* ((info (gnus-get-info group))
9820 (marked (gnus-info-marks info))
9821 (active (gnus-active group)))
9823 (gnus-set-difference
9824 (gnus-sorted-complement
9825 (gnus-uncompress-range active)
9826 (gnus-list-of-unread-articles group))
9828 (gnus-uncompress-range (cdr (assq 'dormant marked)))
9829 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
9831 ;; Various summary commands
9833 (defun gnus-summary-universal-argument (arg)
9834 "Perform any operation on all articles that are process/prefixed."
9836 (gnus-set-global-variables)
9837 (let ((articles (gnus-summary-work-articles arg))
9844 (substitute-command-keys
9845 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
9848 (gnus-error 1 "Undefined key")
9851 (gnus-summary-goto-subject (setq article (pop articles)))
9852 (command-execute func)
9853 (gnus-summary-remove-process-mark article)))))
9854 (gnus-summary-position-point))
9856 (defun gnus-summary-toggle-truncation (&optional arg)
9857 "Toggle truncation of summary lines.
9858 With arg, turn line truncation on iff arg is positive."
9860 (setq truncate-lines
9861 (if (null arg) (not truncate-lines)
9862 (> (prefix-numeric-value arg) 0)))
9865 (defun gnus-summary-reselect-current-group (&optional all rescan)
9866 "Exit and then reselect the current newsgroup.
9867 The prefix argument ALL means to select all articles."
9869 (gnus-set-global-variables)
9870 (let ((current-subject (gnus-summary-article-number))
9871 (group gnus-newsgroup-name))
9872 (setq gnus-newsgroup-begin nil)
9874 ;; We have to adjust the point of group mode buffer because the
9875 ;; current point was moved to the next unread newsgroup by
9877 (gnus-summary-jump-to-group group)
9880 (gnus-group-get-new-news-this-group 1)))
9881 (gnus-group-read-group all t)
9882 (gnus-summary-goto-subject current-subject)))
9884 (defun gnus-summary-rescan-group (&optional all)
9885 "Exit the newsgroup, ask for new articles, and select the newsgroup."
9887 (gnus-summary-reselect-current-group all t))
9889 (defun gnus-summary-update-info ()
9890 (let* ((group gnus-newsgroup-name))
9891 (when gnus-newsgroup-kill-headers
9892 (setq gnus-newsgroup-killed
9893 (gnus-compress-sequence
9895 (gnus-set-sorted-intersection
9896 (gnus-uncompress-range gnus-newsgroup-killed)
9897 (setq gnus-newsgroup-unselected
9898 (sort gnus-newsgroup-unselected '<)))
9899 (setq gnus-newsgroup-unreads
9900 (sort gnus-newsgroup-unreads '<))) t)))
9901 (unless (listp (cdr gnus-newsgroup-killed))
9902 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
9903 (let ((headers gnus-newsgroup-headers))
9904 (run-hooks 'gnus-exit-group-hook)
9905 (unless gnus-save-score
9906 (setq gnus-newsgroup-scored nil))
9907 ;; Set the new ranges of read articles.
9908 (gnus-update-read-articles
9909 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
9910 ;; Set the current article marks.
9912 ;; Do the cross-ref thing.
9913 (when gnus-use-cross-reference
9914 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
9915 ;; Do adaptive scoring, and possibly save score files.
9916 (when gnus-newsgroup-adaptive
9917 (gnus-score-adaptive))
9918 (when gnus-use-scoring
9920 ;; Do not switch windows but change the buffer to work.
9921 (set-buffer gnus-group-buffer)
9922 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
9923 (gnus-group-update-group group)))))
9925 (defun gnus-summary-exit (&optional temporary)
9926 "Exit reading current newsgroup, and then return to group selection mode.
9927 gnus-exit-group-hook is called with no arguments if that value is non-nil."
9929 (gnus-set-global-variables)
9930 (gnus-kill-save-kill-buffer)
9931 (let* ((group gnus-newsgroup-name)
9932 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
9934 (buf (current-buffer)))
9935 (run-hooks 'gnus-summary-prepare-exit-hook)
9936 ;; If we have several article buffers, we kill them at exit.
9937 (unless gnus-single-article-buffer
9938 (gnus-kill-buffer gnus-original-article-buffer)
9939 (setq gnus-article-current nil))
9940 (when gnus-use-cache
9941 (gnus-cache-possibly-remove-articles)
9942 (gnus-cache-save-buffers))
9943 (when gnus-use-trees
9944 (gnus-tree-close group))
9945 ;; Make all changes in this group permanent.
9947 (gnus-summary-update-info))
9948 (gnus-close-group group)
9949 ;; Make sure where I was, and go to next newsgroup.
9950 (set-buffer gnus-group-buffer)
9952 (gnus-group-jump-to-group group))
9953 (run-hooks 'gnus-summary-exit-hook)
9955 (gnus-group-next-unread-group 1))
9958 ;; If we have several article buffers, we kill them at exit.
9959 (unless gnus-single-article-buffer
9960 (gnus-kill-buffer gnus-article-buffer)
9961 (gnus-kill-buffer gnus-original-article-buffer)
9962 (setq gnus-article-current nil))
9964 (if (not gnus-kill-summary-on-exit)
9965 (gnus-deaden-summary)
9966 ;; We set all buffer-local variables to nil. It is unclear why
9967 ;; this is needed, but if we don't, buffer-local variables are
9968 ;; not garbage-collected, it seems. This would the lead to en
9969 ;; ever-growing Emacs.
9970 (gnus-summary-clear-local-variables)
9971 (when (get-buffer gnus-article-buffer)
9972 (bury-buffer gnus-article-buffer))
9973 ;; We clear the global counterparts of the buffer-local
9974 ;; variables as well, just to be on the safe side.
9975 (gnus-configure-windows 'group 'force)
9976 (gnus-summary-clear-local-variables)
9977 ;; Return to group mode buffer.
9978 (if (eq mode 'gnus-summary-mode)
9979 (gnus-kill-buffer buf)))
9980 (setq gnus-current-select-method gnus-select-method)
9981 (pop-to-buffer gnus-group-buffer)
9982 ;; Clear the current group name.
9983 (if (not quit-config)
9985 (gnus-group-jump-to-group group)
9986 (gnus-group-next-unread-group 1)
9987 (gnus-configure-windows 'group 'force))
9988 (if (not (buffer-name (car quit-config)))
9989 (gnus-configure-windows 'group 'force)
9990 (set-buffer (car quit-config))
9991 (and (eq major-mode 'gnus-summary-mode)
9992 (gnus-set-global-variables))
9993 (gnus-configure-windows (cdr quit-config))))
9995 (setq gnus-newsgroup-name nil)))))
9997 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
9998 (defun gnus-summary-exit-no-update (&optional no-questions)
9999 "Quit reading current newsgroup without updating read article info."
10001 (gnus-set-global-variables)
10002 (let* ((group gnus-newsgroup-name)
10003 (quit-config (gnus-group-quit-config group)))
10004 (when (or no-questions
10006 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
10007 ;; If we have several article buffers, we kill them at exit.
10008 (unless gnus-single-article-buffer
10009 (gnus-kill-buffer gnus-article-buffer)
10010 (gnus-kill-buffer gnus-original-article-buffer)
10011 (setq gnus-article-current nil))
10012 (if (not gnus-kill-summary-on-exit)
10013 (gnus-deaden-summary)
10014 (gnus-close-group group)
10015 (gnus-summary-clear-local-variables)
10016 (set-buffer gnus-group-buffer)
10017 (gnus-summary-clear-local-variables)
10018 (when (get-buffer gnus-summary-buffer)
10019 (kill-buffer gnus-summary-buffer)))
10020 (unless gnus-single-article-buffer
10021 (setq gnus-article-current nil))
10022 (when gnus-use-trees
10023 (gnus-tree-close group))
10024 (when (get-buffer gnus-article-buffer)
10025 (bury-buffer gnus-article-buffer))
10026 ;; Return to the group buffer.
10027 (gnus-configure-windows 'group 'force)
10028 ;; Clear the current group name.
10029 (setq gnus-newsgroup-name nil)
10030 (when (equal (gnus-group-group-name) group)
10031 (gnus-group-next-unread-group 1))
10033 (if (not (buffer-name (car quit-config)))
10034 (gnus-configure-windows 'group 'force)
10035 (set-buffer (car quit-config))
10036 (when (eq major-mode 'gnus-summary-mode)
10037 (gnus-set-global-variables))
10038 (gnus-configure-windows (cdr quit-config)))))))
10040 ;;; Dead summaries.
10042 (defvar gnus-dead-summary-mode-map nil)
10044 (if gnus-dead-summary-mode-map
10046 (setq gnus-dead-summary-mode-map (make-keymap))
10047 (suppress-keymap gnus-dead-summary-mode-map)
10048 (substitute-key-definition
10049 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
10050 (let ((keys '("\C-d" "\r" "\177")))
10052 (define-key gnus-dead-summary-mode-map
10053 (pop keys) 'gnus-summary-wake-up-the-dead))))
10055 (defvar gnus-dead-summary-mode nil
10056 "Minor mode for Gnus summary buffers.")
10058 (defun gnus-dead-summary-mode (&optional arg)
10059 "Minor mode for Gnus summary buffers."
10061 (when (eq major-mode 'gnus-summary-mode)
10062 (make-local-variable 'gnus-dead-summary-mode)
10063 (setq gnus-dead-summary-mode
10064 (if (null arg) (not gnus-dead-summary-mode)
10065 (> (prefix-numeric-value arg) 0)))
10066 (when gnus-dead-summary-mode
10067 (unless (assq 'gnus-dead-summary-mode minor-mode-alist)
10068 (push '(gnus-dead-summary-mode " Dead") minor-mode-alist))
10069 (unless (assq 'gnus-dead-summary-mode minor-mode-map-alist)
10070 (push (cons 'gnus-dead-summary-mode gnus-dead-summary-mode-map)
10071 minor-mode-map-alist)))))
10073 (defun gnus-deaden-summary ()
10074 "Make the current summary buffer into a dead summary buffer."
10075 ;; Kill any previous dead summary buffer.
10076 (when (and gnus-dead-summary
10077 (buffer-name gnus-dead-summary))
10079 (set-buffer gnus-dead-summary)
10080 (when gnus-dead-summary-mode
10081 (kill-buffer (current-buffer)))))
10082 ;; Make this the current dead summary.
10083 (setq gnus-dead-summary (current-buffer))
10084 (gnus-dead-summary-mode 1)
10085 (let ((name (buffer-name)))
10086 (when (string-match "Summary" name)
10088 (concat (substring name 0 (match-beginning 0)) "Dead "
10089 (substring name (match-beginning 0))) t))))
10091 (defun gnus-kill-or-deaden-summary (buffer)
10092 "Kill or deaden the summary BUFFER."
10093 (when (and (buffer-name buffer)
10094 (not gnus-single-article-buffer))
10096 (set-buffer buffer)
10097 (gnus-kill-buffer gnus-article-buffer)
10098 (gnus-kill-buffer gnus-original-article-buffer)))
10099 (cond (gnus-kill-summary-on-exit
10100 (when (and gnus-use-trees
10101 (and (get-buffer buffer)
10102 (buffer-name (get-buffer buffer))))
10104 (set-buffer (get-buffer buffer))
10105 (gnus-tree-close gnus-newsgroup-name)))
10106 (gnus-kill-buffer buffer))
10107 ((and (get-buffer buffer)
10108 (buffer-name (get-buffer buffer)))
10110 (set-buffer buffer)
10111 (gnus-deaden-summary)))))
10113 (defun gnus-summary-wake-up-the-dead (&rest args)
10114 "Wake up the dead summary buffer."
10116 (gnus-dead-summary-mode -1)
10117 (let ((name (buffer-name)))
10118 (when (string-match "Dead " name)
10120 (concat (substring name 0 (match-beginning 0))
10121 (substring name (match-end 0))) t)))
10122 (gnus-message 3 "This dead summary is now alive again"))
10124 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
10125 (defun gnus-summary-fetch-faq (&optional faq-dir)
10126 "Fetch the FAQ for the current group.
10127 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
10131 (if current-prefix-arg
10133 "Faq dir: " (and (listp gnus-group-faq-directory)
10134 gnus-group-faq-directory)))))
10135 (let (gnus-faq-buffer)
10136 (and (setq gnus-faq-buffer
10137 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
10138 (gnus-configure-windows 'summary-faq))))
10140 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
10141 (defun gnus-summary-describe-group (&optional force)
10142 "Describe the current newsgroup."
10144 (gnus-group-describe-group force gnus-newsgroup-name))
10146 (defun gnus-summary-describe-briefly ()
10147 "Describe summary mode commands briefly."
10150 (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")))
10152 ;; Walking around group mode buffer from summary mode.
10154 (defun gnus-summary-next-group (&optional no-article target-group backward)
10155 "Exit current newsgroup and then select next unread newsgroup.
10156 If prefix argument NO-ARTICLE is non-nil, no article is selected
10157 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
10158 previous group instead."
10160 (gnus-set-global-variables)
10161 (let ((current-group gnus-newsgroup-name)
10162 (current-buffer (current-buffer))
10164 ;; First we semi-exit this group to update Xrefs and all variables.
10165 ;; We can't do a real exit, because the window conf must remain
10166 ;; the same in case the user is prompted for info, and we don't
10167 ;; want the window conf to change before that...
10168 (gnus-summary-exit t)
10169 (while (not entered)
10170 ;; Then we find what group we are supposed to enter.
10171 (set-buffer gnus-group-buffer)
10172 (gnus-group-jump-to-group current-group)
10175 (if (eq gnus-keep-same-level 'best)
10176 (gnus-summary-best-group gnus-newsgroup-name)
10177 (gnus-summary-search-group backward gnus-keep-same-level))))
10178 (if (not target-group)
10179 ;; There are no further groups, so we return to the group
10182 (gnus-message 5 "Returning to the group buffer")
10184 (set-buffer current-buffer)
10185 (gnus-summary-exit))
10186 ;; We try to enter the target group.
10187 (gnus-group-jump-to-group target-group)
10188 (let ((unreads (gnus-group-group-unread)))
10189 (if (and (or (eq t unreads)
10190 (and unreads (not (zerop unreads))))
10191 (gnus-summary-read-group
10192 target-group nil no-article current-buffer))
10194 (setq current-group target-group
10195 target-group nil)))))))
10197 (defun gnus-summary-prev-group (&optional no-article)
10198 "Exit current newsgroup and then select previous unread newsgroup.
10199 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
10201 (gnus-summary-next-group no-article nil t))
10203 ;; Walking around summary lines.
10205 (defun gnus-summary-first-subject (&optional unread)
10206 "Go to the first unread subject.
10207 If UNREAD is non-nil, go to the first unread article.
10208 Returns the article selected or nil if there are no unread articles."
10213 ((null gnus-newsgroup-data)
10214 (gnus-message 3 "No articles in the group")
10216 ;; Pick the first article.
10218 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
10219 (gnus-data-number (car gnus-newsgroup-data)))
10220 ;; No unread articles.
10221 ((null gnus-newsgroup-unreads)
10222 (gnus-message 3 "No more unread articles")
10224 ;; Find the first unread article.
10226 (let ((data gnus-newsgroup-data))
10228 (not (gnus-data-unread-p (car data))))
10229 (setq data (cdr data)))
10232 (goto-char (gnus-data-pos (car data)))
10233 (gnus-data-number (car data)))))))
10234 (gnus-summary-position-point)))
10236 (defun gnus-summary-next-subject (n &optional unread dont-display)
10237 "Go to next N'th summary line.
10238 If N is negative, go to the previous N'th subject line.
10239 If UNREAD is non-nil, only unread articles are selected.
10240 The difference between N and the actual number of steps taken is
10243 (let ((backward (< n 0))
10245 (while (and (> n 0)
10247 (gnus-summary-find-prev unread)
10248 (gnus-summary-find-next unread)))
10250 (if (/= 0 n) (gnus-message 7 "No more%s articles"
10251 (if unread " unread" "")))
10252 (unless dont-display
10253 (gnus-summary-recenter)
10254 (gnus-summary-position-point))
10257 (defun gnus-summary-next-unread-subject (n)
10258 "Go to next N'th unread summary line."
10260 (gnus-summary-next-subject n t))
10262 (defun gnus-summary-prev-subject (n &optional unread)
10263 "Go to previous N'th summary line.
10264 If optional argument UNREAD is non-nil, only unread article is selected."
10266 (gnus-summary-next-subject (- n) unread))
10268 (defun gnus-summary-prev-unread-subject (n)
10269 "Go to previous N'th unread summary line."
10271 (gnus-summary-next-subject (- n) t))
10273 (defun gnus-summary-goto-subject (article &optional force silent)
10274 "Go the subject line of ARTICLE.
10275 If FORCE, also allow jumping to articles not currently shown."
10277 (data (gnus-data-find article)))
10278 ;; We read in the article if we have to.
10281 (gnus-summary-insert-subject article (and (vectorp force) force) t)
10282 (setq data (gnus-data-find article)))
10287 (gnus-message 3 "Can't find article %d" article))
10289 (goto-char (gnus-data-pos data))
10292 ;; Walking around summary lines with displaying articles.
10294 (defun gnus-summary-expand-window (&optional arg)
10295 "Make the summary buffer take up the entire Emacs frame.
10296 Given a prefix, will force an `article' buffer configuration."
10298 (gnus-set-global-variables)
10300 (gnus-configure-windows 'article 'force)
10301 (gnus-configure-windows 'summary 'force)))
10303 (defun gnus-summary-display-article (article &optional all-header)
10304 "Display ARTICLE in article buffer."
10305 (gnus-set-global-variables)
10309 (if gnus-summary-display-article-function
10310 (funcall gnus-summary-display-article-function article all-header)
10311 (gnus-article-prepare article all-header))
10312 (run-hooks 'gnus-select-article-hook)
10313 (unless (zerop gnus-current-article)
10314 (gnus-summary-goto-subject gnus-current-article))
10315 (gnus-summary-recenter)
10316 (when gnus-use-trees
10317 (gnus-possibly-generate-tree article)
10318 (gnus-highlight-selected-tree article))
10319 ;; Successfully display article.
10320 (gnus-article-set-window-start
10321 (cdr (assq article gnus-newsgroup-bookmarks))))))
10323 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
10324 "Select the current article.
10325 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
10326 non-nil, the article will be re-fetched even if it already present in
10327 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
10329 ;; Make sure we are in the summary buffer to work around bbdb bug.
10330 (unless (eq major-mode 'gnus-summary-mode)
10331 (set-buffer gnus-summary-buffer))
10332 (let ((article (or article (gnus-summary-article-number)))
10333 (all-headers (not (not all-headers))) ;Must be T or NIL.
10334 gnus-summary-display-article-function
10337 (gnus-summary-article-pseudo-p article)
10338 (error "This is a pseudo-article."))
10341 (set-buffer gnus-summary-buffer)
10342 (if (or (and gnus-single-article-buffer
10343 (or (null gnus-current-article)
10344 (null gnus-article-current)
10345 (null (get-buffer gnus-article-buffer))
10346 (not (eq article (cdr gnus-article-current)))
10347 (not (equal (car gnus-article-current)
10348 gnus-newsgroup-name))))
10349 (and (not gnus-single-article-buffer)
10350 (or (null gnus-current-article)
10351 (not (eq gnus-current-article article))))
10353 ;; The requested article is different from the current article.
10355 (gnus-summary-display-article article all-headers)
10356 (setq did article))
10357 (if (or all-headers gnus-show-all-headers)
10358 (gnus-article-show-all-headers))
10361 (gnus-article-set-window-start
10362 (cdr (assq article gnus-newsgroup-bookmarks)))))))
10364 (defun gnus-summary-set-current-mark (&optional current-mark)
10365 "Obsolete function."
10368 (defun gnus-summary-next-article (&optional unread subject backward push)
10369 "Select the next article.
10370 If UNREAD, only unread articles are selected.
10371 If SUBJECT, only articles with SUBJECT are selected.
10372 If BACKWARD, the previous article is selected instead of the next."
10374 (gnus-set-global-variables)
10376 ;; Is there such an article?
10377 ((and (gnus-summary-search-forward unread subject backward)
10378 (or (gnus-summary-display-article (gnus-summary-article-number))
10379 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
10380 (gnus-summary-position-point))
10381 ;; If not, we try the first unread, if that is wanted.
10383 gnus-auto-select-same
10384 (or (gnus-summary-first-unread-article)
10385 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
10386 (gnus-summary-position-point)
10387 (gnus-message 6 "Wrapped"))
10388 ;; Try to get next/previous article not displayed in this group.
10389 ((and gnus-auto-extend-newsgroup
10390 (not unread) (not subject))
10391 (gnus-summary-goto-article
10392 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
10394 ;; Go to next/previous group.
10396 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
10397 (gnus-summary-jump-to-group gnus-newsgroup-name))
10398 (let ((cmd last-command-char)
10400 (if (eq gnus-keep-same-level 'best)
10401 (gnus-summary-best-group gnus-newsgroup-name)
10402 (gnus-summary-search-group backward gnus-keep-same-level))))
10403 ;; For some reason, the group window gets selected. We change
10405 (select-window (get-buffer-window (current-buffer)))
10406 ;; Select next unread newsgroup automagically.
10408 ((or (not gnus-auto-select-next)
10410 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
10411 ((or (eq gnus-auto-select-next 'quietly)
10412 (and (eq gnus-auto-select-next 'slightly-quietly)
10414 (and (eq gnus-auto-select-next 'almost-quietly)
10415 (gnus-summary-last-article-p)))
10417 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
10418 (gnus-summary-exit)
10419 (gnus-message 7 "No more%s articles (%s)..."
10420 (if unread " unread" "")
10421 (if group (concat "selecting " group)
10423 (gnus-summary-next-group nil group backward)))
10425 (gnus-summary-walk-group-buffer
10426 gnus-newsgroup-name cmd unread backward)))))))
10428 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward)
10429 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
10430 (?\C-p (gnus-group-prev-unread-group 1))))
10431 keve key group ended)
10433 (set-buffer gnus-group-buffer)
10434 (gnus-summary-jump-to-group from-group)
10436 (if (eq gnus-keep-same-level 'best)
10437 (gnus-summary-best-group gnus-newsgroup-name)
10438 (gnus-summary-search-group backward gnus-keep-same-level))))
10441 5 "No more%s articles%s" (if unread " unread" "")
10443 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
10444 (format " (Type %s for %s [%s])"
10445 (single-key-description cmd) group
10446 (car (gnus-gethash group gnus-newsrc-hashtb)))
10447 (format " (Type %s to exit %s)"
10448 (single-key-description cmd)
10449 gnus-newsgroup-name)))
10450 ;; Confirm auto selection.
10451 (setq key (car (setq keve (gnus-read-event-char))))
10454 ((assq key keystrokes)
10455 (let ((obuf (current-buffer)))
10456 (switch-to-buffer gnus-group-buffer)
10458 (gnus-group-jump-to-group group))
10459 (eval (cadr (assq key keystrokes)))
10460 (setq group (gnus-group-group-name))
10461 (switch-to-buffer obuf))
10464 (if (or (not group)
10465 (gnus-ephemeral-group-p gnus-newsgroup-name))
10466 (gnus-summary-exit)
10467 (gnus-summary-next-group nil group backward)))
10469 (push (cdr keve) unread-command-events))))))
10471 (defun gnus-read-event-char ()
10472 "Get the next event."
10473 (let ((event (read-event)))
10474 (cons (and (numberp event) event) event)))
10476 (defun gnus-summary-next-unread-article ()
10477 "Select unread article after current one."
10479 (gnus-summary-next-article t (and gnus-auto-select-same
10480 (gnus-summary-article-subject))))
10482 (defun gnus-summary-prev-article (&optional unread subject)
10483 "Select the article after the current one.
10484 If UNREAD is non-nil, only unread articles are selected."
10486 (gnus-summary-next-article unread subject t))
10488 (defun gnus-summary-prev-unread-article ()
10489 "Select unred article before current one."
10491 (gnus-summary-prev-article t (and gnus-auto-select-same
10492 (gnus-summary-article-subject))))
10494 (defun gnus-summary-next-page (&optional lines circular)
10495 "Show next page of the selected article.
10496 If at the end of the current article, select the next article.
10497 LINES says how many lines should be scrolled up.
10499 If CIRCULAR is non-nil, go to the start of the article instead of
10500 selecting the next article when reaching the end of the current
10503 (setq gnus-summary-buffer (current-buffer))
10504 (gnus-set-global-variables)
10505 (let ((article (gnus-summary-article-number))
10507 (gnus-configure-windows 'article)
10508 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
10509 (if (and (eq gnus-summary-goto-unread 'never)
10510 (not (gnus-summary-last-article-p article)))
10511 (gnus-summary-next-article)
10512 (gnus-summary-next-unread-article))
10513 (if (or (null gnus-current-article)
10514 (null gnus-article-current)
10515 (/= article (cdr gnus-article-current))
10516 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10517 ;; Selected subject is different from current article's.
10518 (gnus-summary-display-article article)
10519 (gnus-eval-in-buffer-window gnus-article-buffer
10520 (setq endp (gnus-article-next-page lines)))
10523 (gnus-summary-beginning-of-article))
10525 (gnus-message 3 "End of message"))
10527 (if (and (eq gnus-summary-goto-unread 'never)
10528 (not (gnus-summary-last-article-p article)))
10529 (gnus-summary-next-article)
10530 (gnus-summary-next-unread-article)))))))
10531 (gnus-summary-recenter)
10532 (gnus-summary-position-point)))
10534 (defun gnus-summary-prev-page (&optional lines)
10535 "Show previous page of selected article.
10536 Argument LINES specifies lines to be scrolled down."
10538 (gnus-set-global-variables)
10539 (let ((article (gnus-summary-article-number)))
10540 (gnus-configure-windows 'article)
10541 (if (or (null gnus-current-article)
10542 (null gnus-article-current)
10543 (/= article (cdr gnus-article-current))
10544 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10545 ;; Selected subject is different from current article's.
10546 (gnus-summary-display-article article)
10547 (gnus-summary-recenter)
10548 (gnus-eval-in-buffer-window gnus-article-buffer
10549 (gnus-article-prev-page lines))))
10550 (gnus-summary-position-point))
10552 (defun gnus-summary-scroll-up (lines)
10553 "Scroll up (or down) one line current article.
10554 Argument LINES specifies lines to be scrolled up (or down if negative)."
10556 (gnus-set-global-variables)
10557 (gnus-configure-windows 'article)
10558 (gnus-summary-show-thread)
10559 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
10560 (gnus-eval-in-buffer-window gnus-article-buffer
10562 (if (gnus-article-next-page lines)
10563 (gnus-message 3 "End of message")))
10565 (gnus-article-prev-page (- lines))))))
10566 (gnus-summary-recenter)
10567 (gnus-summary-position-point))
10569 (defun gnus-summary-next-same-subject ()
10570 "Select next article which has the same subject as current one."
10572 (gnus-set-global-variables)
10573 (gnus-summary-next-article nil (gnus-summary-article-subject)))
10575 (defun gnus-summary-prev-same-subject ()
10576 "Select previous article which has the same subject as current one."
10578 (gnus-set-global-variables)
10579 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
10581 (defun gnus-summary-next-unread-same-subject ()
10582 "Select next unread article which has the same subject as current one."
10584 (gnus-set-global-variables)
10585 (gnus-summary-next-article t (gnus-summary-article-subject)))
10587 (defun gnus-summary-prev-unread-same-subject ()
10588 "Select previous unread article which has the same subject as current one."
10590 (gnus-set-global-variables)
10591 (gnus-summary-prev-article t (gnus-summary-article-subject)))
10593 (defun gnus-summary-first-unread-article ()
10594 "Select the first unread article.
10595 Return nil if there are no unread articles."
10597 (gnus-set-global-variables)
10599 (if (gnus-summary-first-subject t)
10601 (gnus-summary-show-thread)
10602 (gnus-summary-first-subject t)
10603 (gnus-summary-display-article (gnus-summary-article-number))))
10604 (gnus-summary-position-point)))
10606 (defun gnus-summary-best-unread-article ()
10607 "Select the unread article with the highest score."
10609 (gnus-set-global-variables)
10610 (let ((best -1000000)
10611 (data gnus-newsgroup-data)
10614 (and (gnus-data-unread-p (car data))
10616 (gnus-summary-article-score (gnus-data-number (car data))))
10619 article (gnus-data-number (car data))))
10620 (setq data (cdr data)))
10623 (gnus-summary-goto-article article)
10624 (error "No unread articles"))
10625 (gnus-summary-position-point))))
10627 (defun gnus-summary-last-subject ()
10628 "Go to the last displayed subject line in the group."
10629 (let ((article (gnus-data-number (car (gnus-data-list t)))))
10631 (gnus-summary-goto-subject article))))
10633 (defun gnus-summary-goto-article (article &optional all-headers force)
10634 "Fetch ARTICLE and display it if it exists.
10635 If ALL-HEADERS is non-nil, no header lines are hidden."
10641 (mapcar (lambda (number) (list (int-to-string number)))
10642 gnus-newsgroup-limit)))
10646 (if (gnus-summary-goto-subject article force)
10647 (gnus-summary-display-article article all-headers)
10648 (gnus-message 4 "Couldn't go to article %s" article) nil)
10649 (gnus-summary-position-point)))
10651 (defun gnus-summary-goto-last-article ()
10652 "Go to the previously read article."
10655 (and gnus-last-article
10656 (gnus-summary-goto-article gnus-last-article))
10657 (gnus-summary-position-point)))
10659 (defun gnus-summary-pop-article (number)
10660 "Pop one article off the history and go to the previous.
10661 NUMBER articles will be popped off."
10664 (setq gnus-newsgroup-history
10665 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
10667 (gnus-summary-goto-article (car to))
10668 (error "Article history empty")))
10669 (gnus-summary-position-point))
10671 ;; Summary commands and functions for limiting the summary buffer.
10673 (defun gnus-summary-limit-to-articles (n)
10674 "Limit the summary buffer to the next N articles.
10675 If not given a prefix, use the process marked articles instead."
10677 (gnus-set-global-variables)
10679 (let ((articles (gnus-summary-work-articles n)))
10680 (setq gnus-newsgroup-processable nil)
10681 (gnus-summary-limit articles))
10682 (gnus-summary-position-point)))
10684 (defun gnus-summary-pop-limit (&optional total)
10685 "Restore the previous limit.
10686 If given a prefix, remove all limits."
10688 (gnus-set-global-variables)
10690 (setq gnus-newsgroup-limits
10691 (list (mapcar (lambda (h) (mail-header-number h))
10692 gnus-newsgroup-headers))))
10693 (unless gnus-newsgroup-limits
10694 (error "No limit to pop"))
10696 (gnus-summary-limit nil 'pop)
10697 (gnus-summary-position-point)))
10699 (defun gnus-summary-limit-to-subject (subject &optional header)
10700 "Limit the summary buffer to articles that have subjects that match a regexp."
10701 (interactive "sRegexp: ")
10703 (setq header "subject"))
10704 (when (not (equal "" subject))
10706 (let ((articles (gnus-summary-find-matching
10707 (or header "subject") subject 'all)))
10708 (or articles (error "Found no matches for \"%s\"" subject))
10709 (gnus-summary-limit articles))
10710 (gnus-summary-position-point))))
10712 (defun gnus-summary-limit-to-author (from)
10713 "Limit the summary buffer to articles that have authors that match a regexp."
10714 (interactive "sRegexp: ")
10715 (gnus-summary-limit-to-subject from "from"))
10717 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10719 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10721 (defun gnus-summary-limit-to-unread (&optional all)
10722 "Limit the summary buffer to articles that are not marked as read.
10723 If ALL is non-nil, limit strictly to unread articles."
10726 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
10727 (gnus-summary-limit-to-marks
10728 ;; Concat all the marks that say that an article is read and have
10730 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
10731 gnus-killed-mark gnus-kill-file-mark
10732 gnus-low-score-mark gnus-expirable-mark
10733 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark)
10736 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10737 (make-obsolete 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10739 (defun gnus-summary-limit-to-marks (marks &optional reverse)
10740 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
10741 If REVERSE, limit the summary buffer to articles that are not marked
10742 with MARKS. MARKS can either be a string of marks or a list of marks.
10743 Returns how many articles were removed."
10744 (interactive "sMarks: ")
10745 (gnus-set-global-variables)
10747 (let ((data gnus-newsgroup-data)
10748 (marks (if (listp marks) marks
10749 (append marks nil))) ; Transform to list.
10752 (and (if reverse (not (memq (gnus-data-mark (car data)) marks))
10753 (memq (gnus-data-mark (car data)) marks))
10754 (setq articles (cons (gnus-data-number (car data)) articles)))
10755 (setq data (cdr data)))
10756 (gnus-summary-limit articles))
10757 (gnus-summary-position-point)))
10759 (defun gnus-summary-limit-to-score (&optional score)
10760 "Limit to articles with score at or above SCORE."
10762 (gnus-set-global-variables)
10763 (setq score (if score
10764 (prefix-numeric-value score)
10765 (or gnus-summary-default-score 0)))
10766 (let ((data gnus-newsgroup-data)
10769 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
10771 (push (gnus-data-number (car data)) articles))
10772 (setq data (cdr data)))
10774 (gnus-summary-limit articles)
10775 (gnus-summary-position-point))))
10777 (defun gnus-summary-limit-include-dormant ()
10778 "Display all the hidden articles that are marked as dormant."
10780 (gnus-set-global-variables)
10781 (or gnus-newsgroup-dormant
10782 (error "There are no dormant articles in this group"))
10784 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
10785 (gnus-summary-position-point)))
10787 (defun gnus-summary-limit-exclude-dormant ()
10788 "Hide all dormant articles."
10790 (gnus-set-global-variables)
10792 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
10793 (gnus-summary-position-point)))
10795 (defun gnus-summary-limit-exclude-childless-dormant ()
10796 "Hide all dormant articles that have no children."
10798 (gnus-set-global-variables)
10799 (let ((data (gnus-data-list t))
10800 articles d children)
10801 ;; Find all articles that are either not dormant or have
10803 (while (setq d (pop data))
10804 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
10805 (and (setq children
10806 (gnus-article-children (gnus-data-number d)))
10809 (when (memq (car children) articles)
10814 (push (gnus-data-number d) articles)))
10815 ;; Do the limiting.
10817 (gnus-summary-limit articles)
10818 (gnus-summary-position-point))))
10820 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
10821 "Mark all unread excluded articles as read.
10822 If ALL, mark even excluded ticked and dormants as read."
10824 (let ((articles (gnus-sorted-complement
10826 (mapcar (lambda (h) (mail-header-number h))
10827 gnus-newsgroup-headers)
10829 (sort gnus-newsgroup-limit '<)))
10831 (setq gnus-newsgroup-unreads nil)
10833 (setq gnus-newsgroup-dormant nil
10834 gnus-newsgroup-marked nil
10835 gnus-newsgroup-reads
10837 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
10838 gnus-newsgroup-reads))
10839 (while (setq article (pop articles))
10840 (unless (or (memq article gnus-newsgroup-dormant)
10841 (memq article gnus-newsgroup-marked))
10842 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
10844 (defun gnus-summary-limit (articles &optional pop)
10846 ;; We pop the previous limit off the stack and use that.
10847 (setq articles (car gnus-newsgroup-limits)
10848 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
10849 ;; We use the new limit, so we push the old limit on the stack.
10850 (setq gnus-newsgroup-limits
10851 (cons gnus-newsgroup-limit gnus-newsgroup-limits)))
10853 (setq gnus-newsgroup-limit articles)
10854 (let ((total (length gnus-newsgroup-data))
10855 (data (gnus-data-find-list (gnus-summary-article-number)))
10857 ;; This will do all the work of generating the new summary buffer
10858 ;; according to the new limit.
10859 (gnus-summary-prepare)
10860 ;; Hide any threads, possibly.
10861 (and gnus-show-threads
10862 gnus-thread-hide-subtree
10863 (gnus-summary-hide-all-threads))
10864 ;; Try to return to the article you were at, or one in the
10867 ;; We try to find some article after the current one.
10869 (and (gnus-summary-goto-subject
10870 (gnus-data-number (car data)) nil t)
10873 (setq data (cdr data))))
10875 ;; If there is no data, that means that we were after the last
10876 ;; article. The same goes when we can't find any articles
10877 ;; after the current one.
10879 (goto-char (point-max))
10880 (gnus-summary-find-prev)))
10881 ;; We return how many articles were removed from the summary
10882 ;; buffer as a result of the new limit.
10883 (- total (length gnus-newsgroup-data))))
10885 (defsubst gnus-invisible-cut-children (threads)
10888 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
10893 (defsubst gnus-cut-thread (thread)
10894 "Go forwards in the thread until we find an article that we want to display."
10895 (when (or (eq gnus-fetch-old-headers 'some)
10896 (eq gnus-build-sparse-threads 'some)
10897 (eq gnus-build-sparse-threads 'more))
10898 ;; Deal with old-fetched headers and sparse threads.
10902 (memq (mail-header-number (car thread)) gnus-newsgroup-sparse)
10903 (memq (mail-header-number (car thread)) gnus-newsgroup-ancient))
10904 (or (<= (length (cdr thread)) 1)
10905 (gnus-invisible-cut-children (cdr thread))))
10906 (setq thread (cadr thread))))
10909 (defun gnus-cut-threads (threads)
10910 "Cut off all uninteresting articles from the beginning of threads."
10911 (when (or (eq gnus-fetch-old-headers 'some)
10912 (eq gnus-build-sparse-threads 'some)
10913 (eq gnus-build-sparse-threads 'more))
10914 (let ((th threads))
10916 (setcar th (gnus-cut-thread (car th)))
10917 (setq th (cdr th)))))
10918 ;; Remove nixed out threads.
10919 (delq nil threads))
10921 (defun gnus-summary-initial-limit (&optional show-if-empty)
10922 "Figure out what the initial limit is supposed to be on group entry.
10923 This entails weeding out unwanted dormants, low-scored articles,
10924 fetch-old-headers verbiage, and so on."
10925 ;; Most groups have nothing to remove.
10926 (if (or gnus-inhibit-limiting
10927 (and (null gnus-newsgroup-dormant)
10928 (not (eq gnus-fetch-old-headers 'some))
10929 (null gnus-summary-expunge-below)
10930 (not (eq gnus-build-sparse-threads 'some))
10931 (not (eq gnus-build-sparse-threads 'more))
10932 (null gnus-thread-expunge-below)
10933 (not gnus-use-nocem)))
10935 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10936 (setq gnus-newsgroup-limit nil)
10939 (unless (car (symbol-value node))
10940 ;; These threads have no parents -- they are roots.
10941 (let ((nodes (cdr (symbol-value node)))
10944 (if (and gnus-thread-expunge-below
10945 (< (gnus-thread-total-score (car nodes))
10946 gnus-thread-expunge-below))
10947 (gnus-expunge-thread (pop nodes))
10948 (setq thread (pop nodes))
10949 (gnus-summary-limit-children thread))))))
10950 gnus-newsgroup-dependencies)
10951 ;; If this limitation resulted in an empty group, we might
10952 ;; pop the previous limit and use it instead.
10953 (when (and (not gnus-newsgroup-limit)
10955 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
10956 gnus-newsgroup-limit))
10958 (defun gnus-summary-limit-children (thread)
10959 "Return 1 if this subthread is visible and 0 if it is not."
10960 ;; First we get the number of visible children to this thread. This
10961 ;; is done by recursing down the thread using this function, so this
10962 ;; will really go down to a leaf article first, before slowly
10963 ;; working its way up towards the root.
10967 (apply '+ (mapcar 'gnus-summary-limit-children
10970 (number (mail-header-number (car thread)))
10973 ;; If this article is dormant and has absolutely no visible
10974 ;; children, then this article isn't visible.
10975 (and (memq number gnus-newsgroup-dormant)
10977 ;; If this is "fetch-old-headered" and there is only one
10978 ;; visible child (or less), then we don't want this article.
10979 (and (eq gnus-fetch-old-headers 'some)
10980 (memq number gnus-newsgroup-ancient)
10982 ;; If this is a sparsely inserted article with no children,
10983 ;; we don't want it.
10984 (and (eq gnus-build-sparse-threads 'some)
10985 (memq number gnus-newsgroup-sparse)
10987 ;; If we use expunging, and this article is really
10988 ;; low-scored, then we don't want this article.
10989 (when (and gnus-summary-expunge-below
10991 (or (cdr (assq number gnus-newsgroup-scored))
10992 gnus-summary-default-score))
10993 gnus-summary-expunge-below))
10994 ;; We increase the expunge-tally here, but that has
10995 ;; nothing to do with the limits, really.
10996 (incf gnus-newsgroup-expunged-tally)
10997 ;; We also mark as read here, if that's wanted.
10998 (when (and gnus-summary-mark-below
10999 (< score gnus-summary-mark-below))
11000 (setq gnus-newsgroup-unreads
11001 (delq number gnus-newsgroup-unreads))
11002 (if gnus-newsgroup-auto-expire
11003 (push number gnus-newsgroup-expirable)
11004 (push (cons number gnus-low-score-mark)
11005 gnus-newsgroup-reads)))
11007 (and gnus-use-nocem
11008 (gnus-nocem-unwanted-article-p (mail-header-id (car thread)))))
11009 ;; Nope, invisible article.
11011 ;; Ok, this article is to be visible, so we add it to the limit
11013 (setq gnus-newsgroup-limit (cons number gnus-newsgroup-limit))
11016 (defun gnus-expunge-thread (thread)
11017 "Mark all articles in THREAD as read."
11018 (let* ((number (mail-header-number (car thread))))
11019 (incf gnus-newsgroup-expunged-tally)
11020 ;; We also mark as read here, if that's wanted.
11021 (setq gnus-newsgroup-unreads
11022 (delq number gnus-newsgroup-unreads))
11023 (if gnus-newsgroup-auto-expire
11024 (push number gnus-newsgroup-expirable)
11025 (push (cons number gnus-low-score-mark)
11026 gnus-newsgroup-reads)))
11027 ;; Go recursively through all subthreads.
11028 (mapcar 'gnus-expunge-thread (cdr thread)))
11030 ;; Summary article oriented commands
11032 (defun gnus-summary-refer-parent-article (n)
11033 "Refer parent article N times.
11034 The difference between N and the number of articles fetched is returned."
11036 (gnus-set-global-variables)
11040 (let* ((header (gnus-summary-article-header))
11042 ;; If we try to find the parent of the currently
11043 ;; displayed article, then we take a look at the actual
11044 ;; References header, since this is slightly more
11045 ;; reliable than the References field we got from the
11047 (if (and (eq (mail-header-number header)
11048 (cdr gnus-article-current))
11049 (equal gnus-newsgroup-name
11050 (car gnus-article-current)))
11052 (set-buffer gnus-original-article-buffer)
11053 (nnheader-narrow-to-headers)
11055 (message-fetch-field "references")
11057 ;; It's not the current article, so we take a bet on
11058 ;; the value we got from the server.
11059 (mail-header-references header))))
11060 (if (setq ref (or ref (mail-header-references header)))
11061 (or (gnus-summary-refer-article (gnus-parent-id ref))
11062 (gnus-message 1 "Couldn't find parent"))
11063 (gnus-message 1 "No references in article %d"
11064 (gnus-summary-article-number))
11067 (gnus-summary-position-point)
11070 (defun gnus-summary-refer-references ()
11071 "Fetch all articles mentioned in the References header.
11072 Return how many articles were fetched."
11074 (gnus-set-global-variables)
11075 (let ((ref (mail-header-references (gnus-summary-article-header)))
11076 (current (gnus-summary-article-number))
11078 ;; For each Message-ID in the References header...
11079 (while (string-match "<[^>]*>" ref)
11081 ;; ... fetch that article.
11082 (gnus-summary-refer-article
11083 (prog1 (match-string 0 ref)
11084 (setq ref (substring ref (match-end 0))))))
11085 (gnus-summary-goto-subject current)
11086 (gnus-summary-position-point)
11089 (defun gnus-summary-refer-article (message-id)
11090 "Fetch an article specified by MESSAGE-ID."
11091 (interactive "sMessage-ID: ")
11092 (when (and (stringp message-id)
11093 (not (zerop (length message-id))))
11094 ;; Construct the correct Message-ID if necessary.
11095 ;; Suggested by tale@pawl.rpi.edu.
11096 (unless (string-match "^<" message-id)
11097 (setq message-id (concat "<" message-id)))
11098 (unless (string-match ">$" message-id)
11099 (setq message-id (concat message-id ">")))
11100 (let* ((header (gnus-id-to-header message-id))
11101 (sparse (and header
11102 (memq (mail-header-number header)
11103 gnus-newsgroup-sparse))))
11106 ;; The article is present in the buffer, to we just go to it.
11107 (gnus-summary-goto-article
11108 (mail-header-number header) nil header)
11110 (gnus-summary-update-article (mail-header-number header))))
11111 ;; We fetch the article
11112 (let ((gnus-override-method
11113 (and (gnus-news-group-p gnus-newsgroup-name)
11114 gnus-refer-article-method))
11116 ;; Start the special refer-article method, if necessary.
11117 (when (and gnus-refer-article-method
11118 (gnus-news-group-p gnus-newsgroup-name))
11119 (gnus-check-server gnus-refer-article-method))
11120 ;; Fetch the header, and display the article.
11121 (if (setq number (gnus-summary-insert-subject message-id))
11122 (gnus-summary-select-article nil nil nil number)
11123 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
11125 (defun gnus-summary-enter-digest-group (&optional force)
11126 "Enter a digest group based on the current article."
11128 (gnus-set-global-variables)
11129 (gnus-summary-select-article)
11130 (let ((name (format "%s-%d"
11131 (gnus-group-prefixed-name
11132 gnus-newsgroup-name (list 'nndoc ""))
11133 gnus-current-article))
11134 (ogroup gnus-newsgroup-name)
11135 (case-fold-search t)
11136 (buf (current-buffer))
11139 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
11140 (insert-buffer-substring gnus-original-article-buffer)
11142 (goto-char (point-min))
11143 (or (search-forward "\n\n" nil t) (point)))
11144 (goto-char (point-min))
11145 (delete-matching-lines "^\\(Path\\):\\|^From ")
11148 (if (gnus-group-read-ephemeral-group
11149 name `(nndoc ,name (nndoc-address
11151 (nndoc-article-type ,(if force 'digest 'guess))) t)
11152 ;; Make all postings to this group go to the parent group.
11153 (nconc (gnus-info-params (gnus-get-info name))
11154 (list (cons 'to-group ogroup)))
11155 ;; Couldn't select this doc group.
11156 (switch-to-buffer buf)
11157 (gnus-set-global-variables)
11158 (gnus-configure-windows 'summary)
11159 (gnus-message 3 "Article couldn't be entered?"))
11160 (kill-buffer dig))))
11162 (defun gnus-summary-isearch-article (&optional regexp-p)
11163 "Do incremental search forward on the current article.
11164 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
11166 (gnus-set-global-variables)
11167 (gnus-summary-select-article)
11168 (gnus-configure-windows 'article)
11169 (gnus-eval-in-buffer-window gnus-article-buffer
11170 (goto-char (point-min))
11171 (isearch-forward regexp-p)))
11173 (defun gnus-summary-search-article-forward (regexp &optional backward)
11174 "Search for an article containing REGEXP forward.
11175 If BACKWARD, search backward instead."
11178 (format "Search article %s (regexp%s): "
11179 (if current-prefix-arg "backward" "forward")
11180 (if gnus-last-search-regexp
11181 (concat ", default " gnus-last-search-regexp)
11183 current-prefix-arg))
11184 (gnus-set-global-variables)
11185 (if (string-equal regexp "")
11186 (setq regexp (or gnus-last-search-regexp ""))
11187 (setq gnus-last-search-regexp regexp))
11188 (unless (gnus-summary-search-article regexp backward)
11189 (error "Search failed: \"%s\"" regexp)))
11191 (defun gnus-summary-search-article-backward (regexp)
11192 "Search for an article containing REGEXP backward."
11195 (format "Search article backward (regexp%s): "
11196 (if gnus-last-search-regexp
11197 (concat ", default " gnus-last-search-regexp)
11199 (gnus-summary-search-article-forward regexp 'backward))
11201 (defun gnus-summary-search-article (regexp &optional backward)
11202 "Search for an article containing REGEXP.
11203 Optional argument BACKWARD means do search for backward.
11204 `gnus-select-article-hook' is not called during the search."
11205 (let ((gnus-select-article-hook nil) ;Disable hook.
11206 (gnus-article-display-hook nil)
11207 (gnus-mark-article-hook nil) ;Inhibit marking as read.
11210 're-search-backward 're-search-forward))
11211 (sum (current-buffer))
11213 (gnus-save-hidden-threads
11214 (gnus-summary-select-article)
11215 (set-buffer gnus-article-buffer)
11219 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
11221 (re-search-backward regexp nil t)
11222 (re-search-forward regexp nil t))
11223 ;; We found the regexp.
11225 (setq found 'found)
11226 (beginning-of-line)
11228 (get-buffer-window (current-buffer))
11232 ;; We didn't find it, so we go to the next article.
11234 (if (not (if backward (gnus-summary-find-prev)
11235 (gnus-summary-find-next)))
11236 ;; No more articles.
11238 ;; Select the next article and adjust point.
11239 (gnus-summary-select-article)
11240 (set-buffer gnus-article-buffer)
11242 (goto-char (if backward (point-max) (point-min))))))
11243 (gnus-message 7 ""))
11244 ;; Return whether we found the regexp.
11245 (when (eq found 'found)
11246 (gnus-summary-show-thread)
11247 (gnus-summary-goto-subject gnus-current-article)
11248 (gnus-summary-position-point)
11251 (defun gnus-summary-find-matching (header regexp &optional backward unread
11253 "Return a list of all articles that match REGEXP on HEADER.
11254 The search stars on the current article and goes forwards unless
11255 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
11256 If UNREAD is non-nil, only unread articles will
11257 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
11258 in the comparisons."
11259 (let ((data (if (eq backward 'all) gnus-newsgroup-data
11260 (gnus-data-find-list
11261 (gnus-summary-article-number) (gnus-data-list backward))))
11262 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
11263 (case-fold-search (not not-case-fold))
11265 (or (fboundp (intern (concat "mail-header-" header)))
11266 (error "%s is not a valid header" header))
11268 (setq d (car data))
11269 (and (or (not unread) ; We want all articles...
11270 (gnus-data-unread-p d)) ; Or just unreads.
11271 (vectorp (gnus-data-header d)) ; It's not a pseudo.
11272 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
11273 (setq articles (cons (gnus-data-number d) articles))) ; Success!
11274 (setq data (cdr data)))
11275 (nreverse articles)))
11277 (defun gnus-summary-execute-command (header regexp command &optional backward)
11278 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
11279 If HEADER is an empty string (or nil), the match is done on the entire
11280 article. If BACKWARD (the prefix) is non-nil, search backward instead."
11282 (list (let ((completion-ignore-case t))
11285 (mapcar (lambda (string) (list string))
11286 '("Number" "Subject" "From" "Lines" "Date"
11287 "Message-ID" "Xref" "References" "Body"))
11288 nil 'require-match))
11289 (read-string "Regexp: ")
11290 (read-key-sequence "Command: ")
11291 current-prefix-arg))
11292 (when (equal header "Body")
11294 (gnus-set-global-variables)
11295 ;; Hidden thread subtrees must be searched as well.
11296 (gnus-summary-show-all-threads)
11297 ;; We don't want to change current point nor window configuration.
11299 (save-window-excursion
11300 (gnus-message 6 "Executing %s..." (key-description command))
11301 ;; We'd like to execute COMMAND interactively so as to give arguments.
11302 (gnus-execute header regexp
11303 `(lambda () (call-interactively ',(key-binding command)))
11305 (gnus-message 6 "Executing %s...done" (key-description command)))))
11307 (defun gnus-summary-beginning-of-article ()
11308 "Scroll the article back to the beginning."
11310 (gnus-set-global-variables)
11311 (gnus-summary-select-article)
11312 (gnus-configure-windows 'article)
11313 (gnus-eval-in-buffer-window gnus-article-buffer
11315 (goto-char (point-min))
11316 (and gnus-break-pages (gnus-narrow-to-page))))
11318 (defun gnus-summary-end-of-article ()
11319 "Scroll to the end of the article."
11321 (gnus-set-global-variables)
11322 (gnus-summary-select-article)
11323 (gnus-configure-windows 'article)
11324 (gnus-eval-in-buffer-window gnus-article-buffer
11326 (goto-char (point-max))
11328 (and gnus-break-pages (gnus-narrow-to-page))))
11330 (defun gnus-summary-show-article (&optional arg)
11331 "Force re-fetching of the current article.
11332 If ARG (the prefix) is non-nil, show the raw article without any
11333 article massaging functions being run."
11335 (gnus-set-global-variables)
11337 ;; Select the article the normal way.
11338 (gnus-summary-select-article nil 'force)
11339 ;; Bind the article treatment functions to nil.
11340 (let ((gnus-have-all-headers t)
11341 gnus-article-display-hook
11342 gnus-article-prepare-hook
11345 (gnus-summary-select-article nil 'force)))
11346 (gnus-summary-goto-subject gnus-current-article)
11347 ; (gnus-configure-windows 'article)
11348 (gnus-summary-position-point))
11350 (defun gnus-summary-verbose-headers (&optional arg)
11351 "Toggle permanent full header display.
11352 If ARG is a positive number, turn header display on.
11353 If ARG is a negative number, turn header display off."
11355 (gnus-set-global-variables)
11356 (gnus-summary-toggle-header arg)
11357 (setq gnus-show-all-headers
11358 (cond ((or (not (numberp arg))
11360 (not gnus-show-all-headers))
11364 (defun gnus-summary-toggle-header (&optional arg)
11365 "Show the headers if they are hidden, or hide them if they are shown.
11366 If ARG is a positive number, show the entire header.
11367 If ARG is a negative number, hide the unwanted header lines."
11369 (gnus-set-global-variables)
11371 (set-buffer gnus-article-buffer)
11372 (let* ((buffer-read-only nil)
11373 (inhibit-point-motion-hooks t)
11374 (hidden (text-property-any
11375 (goto-char (point-min)) (search-forward "\n\n")
11378 (goto-char (point-min))
11379 (when (search-forward "\n\n" nil t)
11380 (delete-region (point-min) (1- (point))))
11381 (goto-char (point-min))
11383 (set-buffer gnus-original-article-buffer)
11384 (goto-char (point-min))
11385 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
11386 (insert-buffer-substring gnus-original-article-buffer 1 e)
11387 (let ((gnus-inhibit-hiding t))
11388 (run-hooks 'gnus-article-display-hook))
11389 (if (or (not hidden) (and (numberp arg) (< arg 0)))
11390 (gnus-article-hide-headers)))))
11392 (defun gnus-summary-show-all-headers ()
11393 "Make all header lines visible."
11395 (gnus-set-global-variables)
11396 (gnus-article-show-all-headers))
11398 (defun gnus-summary-toggle-mime (&optional arg)
11399 "Toggle MIME processing.
11400 If ARG is a positive number, turn MIME processing on."
11402 (gnus-set-global-variables)
11403 (setq gnus-show-mime
11404 (if (null arg) (not gnus-show-mime)
11405 (> (prefix-numeric-value arg) 0)))
11406 (gnus-summary-select-article t 'force))
11408 (defun gnus-summary-caesar-message (&optional arg)
11409 "Caesar rotate the current article by 13.
11410 The numerical prefix specifies how manu places to rotate each letter
11413 (gnus-set-global-variables)
11414 (gnus-summary-select-article)
11415 (let ((mail-header-separator ""))
11416 (gnus-eval-in-buffer-window gnus-article-buffer
11419 (let ((start (window-start))
11421 (message-caesar-buffer-body arg)
11422 (set-window-start (get-buffer-window (current-buffer)) start))))))
11424 (defun gnus-summary-stop-page-breaking ()
11425 "Stop page breaking in the current article."
11427 (gnus-set-global-variables)
11428 (gnus-summary-select-article)
11429 (gnus-eval-in-buffer-window gnus-article-buffer
11432 (defun gnus-summary-move-article (&optional n to-newsgroup select-method action)
11433 "Move the current article to a different newsgroup.
11434 If N is a positive number, move the N next articles.
11435 If N is a negative number, move the N previous articles.
11436 If N is nil and any articles have been marked with the process mark,
11437 move those articles instead.
11438 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11439 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
11440 re-spool using this method.
11442 For this function to work, both the current newsgroup and the
11443 newsgroup that you want to move to have to support the `request-move'
11444 and `request-accept' functions."
11446 (unless action (setq action 'move))
11447 (gnus-set-global-variables)
11448 ;; Check whether the source group supports the required functions.
11449 (cond ((and (eq action 'move)
11450 (not (gnus-check-backend-function
11451 'request-move-article gnus-newsgroup-name)))
11452 (error "The current group does not support article moving"))
11453 ((and (eq action 'crosspost)
11454 (not (gnus-check-backend-function
11455 'request-replace-article gnus-newsgroup-name)))
11456 (error "The current group does not support article editing")))
11457 (let ((articles (gnus-summary-work-articles n))
11458 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
11459 (names '((move "Move" "Moving")
11460 (copy "Copy" "Copying")
11461 (crosspost "Crosspost" "Crossposting")))
11462 (copy-buf (save-excursion
11463 (nnheader-set-temp-buffer " *copy article*")))
11464 art-group to-method new-xref article to-groups)
11465 (unless (assq action names)
11466 (error "Unknown action %s" action))
11467 ;; Read the newsgroup name.
11468 (when (and (not to-newsgroup)
11469 (not select-method))
11471 (gnus-read-move-group-name
11472 (cadr (assq action names))
11473 (symbol-value (intern (format "gnus-current-%s-group" action)))
11475 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
11476 (setq to-method (or select-method
11477 (gnus-find-method-for-group to-newsgroup)))
11478 ;; Check the method we are to move this article to...
11479 (or (gnus-check-backend-function 'request-accept-article (car to-method))
11480 (error "%s does not support article copying" (car to-method)))
11481 (or (gnus-check-server to-method)
11482 (error "Can't open server %s" (car to-method)))
11483 (gnus-message 6 "%s to %s: %s..."
11484 (caddr (assq action names))
11485 (or (car select-method) to-newsgroup) articles)
11487 (setq article (pop articles))
11491 ;; Move the article.
11493 (gnus-request-move-article
11494 article ; Article to move
11495 gnus-newsgroup-name ; From newsgrouo
11496 (nth 1 (gnus-find-method-for-group
11497 gnus-newsgroup-name)) ; Server
11498 (list 'gnus-request-accept-article
11499 to-newsgroup (list 'quote select-method)
11500 (not articles)) ; Accept form
11501 (not articles))) ; Only save nov last time
11502 ;; Copy the article.
11505 (set-buffer copy-buf)
11506 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11507 (gnus-request-accept-article
11508 to-newsgroup select-method (not articles))))
11509 ;; Crosspost the article.
11510 ((eq action 'crosspost)
11511 (let ((xref (mail-header-xref (gnus-summary-article-header article))))
11512 (setq new-xref (concat gnus-newsgroup-name ":" article))
11513 (if (and xref (not (string= xref "")))
11515 (when (string-match "^Xref: " xref)
11516 (setq xref (substring xref (match-end 0))))
11517 (setq new-xref (concat xref " " new-xref)))
11518 (setq new-xref (concat (system-name) " " new-xref)))
11520 (set-buffer copy-buf)
11521 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11522 (nnheader-replace-header "xref" new-xref)
11523 (gnus-request-accept-article
11524 to-newsgroup select-method (not articles)))))))
11525 (if (not art-group)
11526 (gnus-message 1 "Couldn't %s article %s"
11527 (cadr (assq action names)) article)
11530 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
11532 (gnus-group-prefixed-name
11535 (gnus-find-method-for-group to-newsgroup)))
11536 gnus-newsrc-hashtb)))
11537 (info (nth 2 entry))
11538 (to-group (gnus-info-group info)))
11539 ;; Update the group that has been moved to.
11541 (memq action '(move copy)))
11542 (unless (member to-group to-groups)
11543 (push to-group to-groups))
11545 (unless (memq article gnus-newsgroup-unreads)
11546 (gnus-info-set-read
11547 info (gnus-add-to-range (gnus-info-read info)
11548 (list (cdr art-group)))))
11550 ;; Copy any marks over to the new group.
11551 (let ((marks gnus-article-mark-lists)
11552 (to-article (cdr art-group)))
11554 ;; See whether the article is to be put in the cache.
11555 (when gnus-use-cache
11556 (gnus-cache-possibly-enter-article
11557 to-group to-article
11558 (let ((header (copy-sequence
11559 (gnus-summary-article-header article))))
11560 (mail-header-set-number header to-article)
11562 (memq article gnus-newsgroup-marked)
11563 (memq article gnus-newsgroup-dormant)
11564 (memq article gnus-newsgroup-unreads)))
11567 (when (memq article (symbol-value
11568 (intern (format "gnus-newsgroup-%s"
11570 ;; If the other group is the same as this group,
11571 ;; then we have to add the mark to the list.
11572 (when (equal to-group gnus-newsgroup-name)
11573 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
11576 (intern (format "gnus-newsgroup-%s"
11578 ;; Copy mark to other group.
11579 (gnus-add-marked-articles
11580 to-group (cdar marks) (list to-article) info))
11581 (setq marks (cdr marks)))))
11583 ;; Update the Xref header in this article to point to
11584 ;; the new crossposted article we have just created.
11585 (when (eq action 'crosspost)
11587 (set-buffer copy-buf)
11588 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11589 (nnheader-replace-header
11590 "xref" (concat new-xref " " (gnus-group-prefixed-name
11591 (car art-group) to-method)
11592 ":" (cdr art-group)))
11593 (gnus-request-replace-article
11594 article gnus-newsgroup-name (current-buffer)))))
11596 (gnus-summary-goto-subject article)
11597 (when (eq action 'move)
11598 (gnus-summary-mark-article article gnus-canceled-mark)))
11599 (gnus-summary-remove-process-mark article))
11600 ;; Re-activate all groups that have been moved to.
11602 (gnus-activate-group (pop to-groups)))
11604 (gnus-kill-buffer copy-buf)
11605 (gnus-summary-position-point)
11606 (gnus-set-mode-line 'summary)))
11608 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
11609 "Move the current article to a different newsgroup.
11610 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11611 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
11612 re-spool using this method."
11614 (gnus-summary-move-article n nil select-method 'copy))
11616 (defun gnus-summary-crosspost-article (&optional n)
11617 "Crosspost the current article to some other group."
11619 (gnus-summary-move-article n nil nil 'crosspost))
11621 (defvar gnus-summary-respool-default-method nil
11622 "Default method for respooling an article.
11623 If nil, use to the current newsgroup method.")
11625 (defun gnus-summary-respool-article (&optional n method)
11626 "Respool the current article.
11627 The article will be squeezed through the mail spooling process again,
11628 which means that it will be put in some mail newsgroup or other
11629 depending on `nnmail-split-methods'.
11630 If N is a positive number, respool the N next articles.
11631 If N is a negative number, respool the N previous articles.
11632 If N is nil and any articles have been marked with the process mark,
11633 respool those articles instead.
11635 Respooling can be done both from mail groups and \"real\" newsgroups.
11636 In the former case, the articles in question will be moved from the
11637 current group into whatever groups they are destined to. In the
11638 latter case, they will be copied into the relevant groups."
11640 (list current-prefix-arg
11641 (let* ((methods (gnus-methods-using 'respool))
11643 (symbol-name (or gnus-summary-respool-default-method
11644 (car (gnus-find-method-for-group
11645 gnus-newsgroup-name)))))
11647 (gnus-completing-read
11648 methname "What backend do you want to use when? "
11649 methods nil t nil 'gnus-method-history))
11652 ((zerop (length (setq ms (gnus-servers-using-backend method))))
11653 (list (intern method) ""))
11657 (cdr (completing-read
11659 (mapcar (lambda (m) (cons (cadr m) m)) ms) nil t)))))))
11660 (gnus-set-global-variables)
11662 (error "No method given for respooling"))
11663 (if (assoc (symbol-name
11664 (car (gnus-find-method-for-group gnus-newsgroup-name)))
11665 (gnus-methods-using 'respool))
11666 (gnus-summary-move-article n nil method)
11667 (gnus-summary-copy-article n nil method)))
11669 (defun gnus-summary-import-article (file)
11670 "Import a random file into a mail newsgroup."
11671 (interactive "fImport file: ")
11672 (gnus-set-global-variables)
11673 (let ((group gnus-newsgroup-name)
11674 (now (current-time))
11676 (or (gnus-check-backend-function 'request-accept-article group)
11677 (error "%s does not support article importing" group))
11678 (or (file-readable-p file)
11679 (not (file-regular-p file))
11680 (error "Can't read %s" file))
11682 (set-buffer (get-buffer-create " *import file*"))
11683 (buffer-disable-undo (current-buffer))
11685 (insert-file-contents file)
11686 (goto-char (point-min))
11687 (unless (nnheader-article-p)
11688 ;; This doesn't look like an article, so we fudge some headers.
11689 (setq atts (file-attributes file)
11690 lines (count-lines (point-min) (point-max)))
11691 (insert "From: " (read-string "From: ") "\n"
11692 "Subject: " (read-string "Subject: ") "\n"
11693 "Date: " (timezone-make-date-arpa-standard
11694 (current-time-string (nth 5 atts))
11695 (current-time-zone now)
11696 (current-time-zone now)) "\n"
11697 "Message-ID: " (message-make-message-id) "\n"
11698 "Lines: " (int-to-string lines) "\n"
11699 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
11700 (gnus-request-accept-article group nil t)
11701 (kill-buffer (current-buffer)))))
11703 (defun gnus-summary-expire-articles (&optional now)
11704 "Expire all articles that are marked as expirable in the current group."
11706 (gnus-set-global-variables)
11707 (when (gnus-check-backend-function
11708 'request-expire-articles gnus-newsgroup-name)
11709 ;; This backend supports expiry.
11710 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
11711 (expirable (if total
11712 (gnus-list-of-read-articles gnus-newsgroup-name)
11713 (setq gnus-newsgroup-expirable
11714 (sort gnus-newsgroup-expirable '<))))
11715 (expiry-wait (if now 'immediate
11716 (gnus-group-get-parameter
11717 gnus-newsgroup-name 'expiry-wait)))
11720 ;; There are expirable articles in this group, so we run them
11721 ;; through the expiry process.
11722 (gnus-message 6 "Expiring articles...")
11723 ;; The list of articles that weren't expired is returned.
11725 (let ((nnmail-expiry-wait-function nil)
11726 (nnmail-expiry-wait expiry-wait))
11727 (setq es (gnus-request-expire-articles
11728 expirable gnus-newsgroup-name)))
11729 (setq es (gnus-request-expire-articles
11730 expirable gnus-newsgroup-name)))
11731 (or total (setq gnus-newsgroup-expirable es))
11732 ;; We go through the old list of expirable, and mark all
11733 ;; really expired articles as nonexistent.
11734 (unless (eq es expirable) ;If nothing was expired, we don't mark.
11735 (let ((gnus-use-cache nil))
11737 (unless (memq (car expirable) es)
11738 (when (gnus-data-find (car expirable))
11739 (gnus-summary-mark-article
11740 (car expirable) gnus-canceled-mark)))
11741 (setq expirable (cdr expirable)))))
11742 (gnus-message 6 "Expiring articles...done")))))
11744 (defun gnus-summary-expire-articles-now ()
11745 "Expunge all expirable articles in the current group.
11746 This means that *all* articles that are marked as expirable will be
11747 deleted forever, right now."
11749 (gnus-set-global-variables)
11750 (or gnus-expert-user
11752 "Are you really, really, really sure you want to delete all these messages? ")
11754 (gnus-summary-expire-articles t))
11756 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
11757 (defun gnus-summary-delete-article (&optional n)
11758 "Delete the N next (mail) articles.
11759 This command actually deletes articles. This is not a marking
11760 command. The article will disappear forever from your life, never to
11762 If N is negative, delete backwards.
11763 If N is nil and articles have been marked with the process mark,
11764 delete these instead."
11766 (gnus-set-global-variables)
11767 (or (gnus-check-backend-function 'request-expire-articles
11768 gnus-newsgroup-name)
11769 (error "The current newsgroup does not support article deletion."))
11770 ;; Compute the list of articles to delete.
11771 (let ((articles (gnus-summary-work-articles n))
11773 (if (and gnus-novice-user
11774 (not (gnus-y-or-n-p
11775 (format "Do you really want to delete %s forever? "
11776 (if (> (length articles) 1)
11777 (format "these %s articles" (length articles))
11778 "this article")))))
11780 ;; Delete the articles.
11781 (setq not-deleted (gnus-request-expire-articles
11782 articles gnus-newsgroup-name 'force))
11784 (gnus-summary-remove-process-mark (car articles))
11785 ;; The backend might not have been able to delete the article
11787 (or (memq (car articles) not-deleted)
11788 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
11789 (setq articles (cdr articles))))
11790 (gnus-summary-position-point)
11791 (gnus-set-mode-line 'summary)
11794 (defun gnus-summary-edit-article (&optional force)
11795 "Enter into a buffer and edit the current article.
11796 This will have permanent effect only in mail groups.
11797 If FORCE is non-nil, allow editing of articles even in read-only
11801 (set-buffer gnus-summary-buffer)
11802 (gnus-set-global-variables)
11803 (when (and (not force)
11804 (gnus-group-read-only-p))
11805 (error "The current newsgroup does not support article editing."))
11806 (gnus-summary-select-article t nil t)
11807 (gnus-configure-windows 'article)
11808 (select-window (get-buffer-window gnus-article-buffer))
11809 (gnus-message 6 "C-c C-c to end edits")
11810 (setq buffer-read-only nil)
11812 (use-local-map (copy-keymap (current-local-map)))
11813 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
11814 (buffer-enable-undo)
11816 (goto-char (point-min))
11817 (search-forward "\n\n" nil t)))
11819 (defun gnus-summary-edit-article-done ()
11820 "Make edits to the current article permanent."
11822 (if (gnus-group-read-only-p)
11824 (gnus-summary-edit-article-postpone)
11826 1 "The current newsgroup does not support article editing."))
11827 (let ((buf (format "%s" (buffer-string))))
11830 (if (not (gnus-request-replace-article
11831 (cdr gnus-article-current) (car gnus-article-current)
11833 (error "Couldn't replace article.")
11834 (gnus-article-mode)
11835 (use-local-map gnus-article-mode-map)
11836 (setq buffer-read-only t)
11837 (buffer-disable-undo (current-buffer))
11838 (gnus-configure-windows 'summary)
11839 (gnus-summary-update-article (cdr gnus-article-current))
11840 (when gnus-use-cache
11841 (gnus-cache-update-article
11842 (car gnus-article-current) (cdr gnus-article-current)))
11843 (when gnus-keep-backlog
11844 (gnus-backlog-remove-article
11845 (car gnus-article-current) (cdr gnus-article-current))))
11847 (when (get-buffer gnus-original-article-buffer)
11848 (set-buffer gnus-original-article-buffer)
11849 (setq gnus-original-article nil)))
11850 (setq gnus-article-current nil
11851 gnus-current-article nil)
11852 (run-hooks 'gnus-article-display-hook)
11853 (and (gnus-visual-p 'summary-highlight 'highlight)
11854 (run-hooks 'gnus-visual-mark-article-hook)))))
11856 (defun gnus-summary-edit-article-postpone ()
11857 "Postpone changes to the current article."
11859 (gnus-article-mode)
11860 (use-local-map gnus-article-mode-map)
11861 (setq buffer-read-only t)
11862 (buffer-disable-undo (current-buffer))
11863 (gnus-configure-windows 'summary)
11864 (and (gnus-visual-p 'summary-highlight 'highlight)
11865 (run-hooks 'gnus-visual-mark-article-hook)))
11867 (defun gnus-summary-respool-query ()
11868 "Query where the respool algorithm would put this article."
11870 (gnus-set-global-variables)
11871 (gnus-summary-select-article)
11873 (set-buffer gnus-article-buffer)
11875 (goto-char (point-min))
11876 (search-forward "\n\n")
11877 (narrow-to-region (point-min) (point))
11878 (pp-eval-expression
11879 (list 'quote (mapcar 'car (nnmail-article-group 'identity)))))))
11881 ;; Summary marking commands.
11883 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
11884 "Mark articles which has the same subject as read, and then select the next.
11885 If UNMARK is positive, remove any kind of mark.
11886 If UNMARK is negative, tick articles."
11888 (gnus-set-global-variables)
11890 (setq unmark (prefix-numeric-value unmark)))
11892 (gnus-summary-mark-same-subject
11893 (gnus-summary-article-subject) unmark)))
11894 ;; Select next unread article. If auto-select-same mode, should
11895 ;; select the first unread article.
11896 (gnus-summary-next-article t (and gnus-auto-select-same
11897 (gnus-summary-article-subject)))
11898 (gnus-message 7 "%d article%s marked as %s"
11899 count (if (= count 1) " is" "s are")
11900 (if unmark "unread" "read"))))
11902 (defun gnus-summary-kill-same-subject (&optional unmark)
11903 "Mark articles which has the same subject as read.
11904 If UNMARK is positive, remove any kind of mark.
11905 If UNMARK is negative, tick articles."
11907 (gnus-set-global-variables)
11909 (setq unmark (prefix-numeric-value unmark)))
11911 (gnus-summary-mark-same-subject
11912 (gnus-summary-article-subject) unmark)))
11913 ;; If marked as read, go to next unread subject.
11915 ;; Go to next unread subject.
11916 (gnus-summary-next-subject 1 t))
11917 (gnus-message 7 "%d articles are marked as %s"
11918 count (if unmark "unread" "read"))))
11920 (defun gnus-summary-mark-same-subject (subject &optional unmark)
11921 "Mark articles with same SUBJECT as read, and return marked number.
11922 If optional argument UNMARK is positive, remove any kinds of marks.
11923 If optional argument UNMARK is negative, mark articles as unread instead."
11927 ((null unmark) ; Mark as read.
11930 (gnus-summary-mark-article-as-read gnus-killed-mark)
11931 (gnus-summary-show-thread) t)
11932 (gnus-summary-find-subject subject))
11933 (setq count (1+ count))))
11934 ((> unmark 0) ; Tick.
11937 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
11938 (gnus-summary-show-thread) t)
11939 (gnus-summary-find-subject subject))
11940 (setq count (1+ count))))
11941 (t ; Mark as unread.
11944 (gnus-summary-mark-article-as-unread gnus-unread-mark)
11945 (gnus-summary-show-thread) t)
11946 (gnus-summary-find-subject subject))
11947 (setq count (1+ count)))))
11948 (gnus-set-mode-line 'summary)
11949 ;; Return the number of marked articles.
11952 (defun gnus-summary-mark-as-processable (n &optional unmark)
11953 "Set the process mark on the next N articles.
11954 If N is negative, mark backward instead. If UNMARK is non-nil, remove
11955 the process mark instead. The difference between N and the actual
11956 number of articles marked is returned."
11958 (gnus-set-global-variables)
11959 (let ((backward (< n 0))
11964 (gnus-summary-remove-process-mark
11965 (gnus-summary-article-number))
11966 (gnus-summary-set-process-mark (gnus-summary-article-number)))
11967 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
11969 (if (/= 0 n) (gnus-message 7 "No more articles"))
11970 (gnus-summary-recenter)
11971 (gnus-summary-position-point)
11974 (defun gnus-summary-unmark-as-processable (n)
11975 "Remove the process mark from the next N articles.
11976 If N is negative, mark backward instead. The difference between N and
11977 the actual number of articles marked is returned."
11979 (gnus-set-global-variables)
11980 (gnus-summary-mark-as-processable n t))
11982 (defun gnus-summary-unmark-all-processable ()
11983 "Remove the process mark from all articles."
11985 (gnus-set-global-variables)
11987 (while gnus-newsgroup-processable
11988 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
11989 (gnus-summary-position-point))
11991 (defun gnus-summary-mark-as-expirable (n)
11992 "Mark N articles forward as expirable.
11993 If N is negative, mark backward instead. The difference between N and
11994 the actual number of articles marked is returned."
11996 (gnus-set-global-variables)
11997 (gnus-summary-mark-forward n gnus-expirable-mark))
11999 (defun gnus-summary-mark-article-as-replied (article)
12000 "Mark ARTICLE replied and update the summary line."
12001 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
12002 (let ((buffer-read-only nil))
12003 (when (gnus-summary-goto-subject article)
12004 (gnus-summary-update-secondary-mark article))))
12006 (defun gnus-summary-set-bookmark (article)
12007 "Set a bookmark in current article."
12008 (interactive (list (gnus-summary-article-number)))
12009 (gnus-set-global-variables)
12010 (if (or (not (get-buffer gnus-article-buffer))
12011 (not gnus-current-article)
12012 (not gnus-article-current)
12013 (not (equal gnus-newsgroup-name (car gnus-article-current))))
12014 (error "No current article selected"))
12015 ;; Remove old bookmark, if one exists.
12016 (let ((old (assq article gnus-newsgroup-bookmarks)))
12017 (if old (setq gnus-newsgroup-bookmarks
12018 (delq old gnus-newsgroup-bookmarks))))
12019 ;; Set the new bookmark, which is on the form
12020 ;; (article-number . line-number-in-body).
12021 (setq gnus-newsgroup-bookmarks
12025 (set-buffer gnus-article-buffer)
12029 (goto-char (point-min))
12030 (search-forward "\n\n" nil t)
12033 gnus-newsgroup-bookmarks))
12034 (gnus-message 6 "A bookmark has been added to the current article."))
12036 (defun gnus-summary-remove-bookmark (article)
12037 "Remove the bookmark from the current article."
12038 (interactive (list (gnus-summary-article-number)))
12039 (gnus-set-global-variables)
12040 ;; Remove old bookmark, if one exists.
12041 (let ((old (assq article gnus-newsgroup-bookmarks)))
12044 (setq gnus-newsgroup-bookmarks
12045 (delq old gnus-newsgroup-bookmarks))
12046 (gnus-message 6 "Removed bookmark."))
12047 (gnus-message 6 "No bookmark in current article."))))
12049 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
12050 (defun gnus-summary-mark-as-dormant (n)
12051 "Mark N articles forward as dormant.
12052 If N is negative, mark backward instead. The difference between N and
12053 the actual number of articles marked is returned."
12055 (gnus-set-global-variables)
12056 (gnus-summary-mark-forward n gnus-dormant-mark))
12058 (defun gnus-summary-set-process-mark (article)
12059 "Set the process mark on ARTICLE and update the summary line."
12060 (setq gnus-newsgroup-processable
12062 (delq article gnus-newsgroup-processable)))
12063 (when (gnus-summary-goto-subject article)
12064 (gnus-summary-show-thread)
12065 (gnus-summary-update-secondary-mark article)))
12067 (defun gnus-summary-remove-process-mark (article)
12068 "Remove the process mark from ARTICLE and update the summary line."
12069 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
12070 (when (gnus-summary-goto-subject article)
12071 (gnus-summary-show-thread)
12072 (gnus-summary-update-secondary-mark article)))
12074 (defun gnus-summary-set-saved-mark (article)
12075 "Set the process mark on ARTICLE and update the summary line."
12076 (push article gnus-newsgroup-saved)
12077 (when (gnus-summary-goto-subject article)
12078 (gnus-summary-update-secondary-mark article)))
12080 (defun gnus-summary-mark-forward (n &optional mark no-expire)
12081 "Mark N articles as read forwards.
12082 If N is negative, mark backwards instead.
12083 Mark with MARK. If MARK is ? , ?! or ??, articles will be
12085 The difference between N and the actual number of articles marked is
12088 (gnus-set-global-variables)
12089 (let ((backward (< n 0))
12090 (gnus-summary-goto-unread
12091 (and gnus-summary-goto-unread
12092 (not (eq gnus-summary-goto-unread 'never))
12093 (not (memq mark (list gnus-unread-mark
12094 gnus-ticked-mark gnus-dormant-mark)))))
12096 (mark (or mark gnus-del-mark)))
12097 (while (and (> n 0)
12098 (gnus-summary-mark-article nil mark no-expire)
12099 (zerop (gnus-summary-next-subject
12101 (and gnus-summary-goto-unread
12102 (not (eq gnus-summary-goto-unread 'never)))
12105 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
12106 (gnus-summary-recenter)
12107 (gnus-summary-position-point)
12108 (gnus-set-mode-line 'summary)
12111 (defun gnus-summary-mark-article-as-read (mark)
12112 "Mark the current article quickly as read with MARK."
12113 (let ((article (gnus-summary-article-number)))
12114 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12115 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12116 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12117 (setq gnus-newsgroup-reads
12118 (cons (cons article mark) gnus-newsgroup-reads))
12119 ;; Possibly remove from cache, if that is used.
12120 (and gnus-use-cache (gnus-cache-enter-remove-article article))
12121 ;; Allow the backend to change the mark.
12122 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
12123 ;; Check for auto-expiry.
12124 (when (and gnus-newsgroup-auto-expire
12125 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
12126 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
12127 (= mark gnus-ancient-mark)
12128 (= mark gnus-read-mark) (= mark gnus-souped-mark)))
12129 (setq mark gnus-expirable-mark)
12130 (push article gnus-newsgroup-expirable))
12131 ;; Set the mark in the buffer.
12132 (gnus-summary-update-mark mark 'unread)
12135 (defun gnus-summary-mark-article-as-unread (mark)
12136 "Mark the current article quickly as unread with MARK."
12137 (let ((article (gnus-summary-article-number)))
12138 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12139 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12140 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
12141 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
12142 (cond ((= mark gnus-ticked-mark)
12143 (push article gnus-newsgroup-marked))
12144 ((= mark gnus-dormant-mark)
12145 (push article gnus-newsgroup-dormant))
12147 (push article gnus-newsgroup-unreads)))
12148 (setq gnus-newsgroup-reads
12149 (delq (assq article gnus-newsgroup-reads)
12150 gnus-newsgroup-reads))
12152 ;; See whether the article is to be put in the cache.
12153 (and gnus-use-cache
12154 (vectorp (gnus-summary-article-header article))
12156 (gnus-cache-possibly-enter-article
12157 gnus-newsgroup-name article
12158 (gnus-summary-article-header article)
12159 (= mark gnus-ticked-mark)
12160 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
12163 (gnus-summary-update-mark mark 'unread)
12166 (defun gnus-summary-mark-article (&optional article mark no-expire)
12167 "Mark ARTICLE with MARK. MARK can be any character.
12168 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
12169 `??' (dormant) and `?E' (expirable).
12170 If MARK is nil, then the default character `?D' is used.
12171 If ARTICLE is nil, then the article on the current line will be
12173 ;; The mark might be a string.
12174 (and (stringp mark)
12175 (setq mark (aref mark 0)))
12176 ;; If no mark is given, then we check auto-expiring.
12177 (and (not no-expire)
12178 gnus-newsgroup-auto-expire
12180 (and (numberp mark)
12181 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
12182 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
12183 (= mark gnus-read-mark) (= mark gnus-souped-mark))))
12184 (setq mark gnus-expirable-mark))
12185 (let* ((mark (or mark gnus-del-mark))
12186 (article (or article (gnus-summary-article-number))))
12187 (or article (error "No article on current line"))
12188 (if (or (= mark gnus-unread-mark)
12189 (= mark gnus-ticked-mark)
12190 (= mark gnus-dormant-mark))
12191 (gnus-mark-article-as-unread article mark)
12192 (gnus-mark-article-as-read article mark))
12194 ;; See whether the article is to be put in the cache.
12195 (and gnus-use-cache
12196 (not (= mark gnus-canceled-mark))
12197 (vectorp (gnus-summary-article-header article))
12199 (gnus-cache-possibly-enter-article
12200 gnus-newsgroup-name article
12201 (gnus-summary-article-header article)
12202 (= mark gnus-ticked-mark)
12203 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
12205 (if (gnus-summary-goto-subject article nil t)
12206 (let ((buffer-read-only nil))
12207 (gnus-summary-show-thread)
12209 (gnus-summary-update-mark mark 'unread)
12212 (defun gnus-summary-update-secondary-mark (article)
12213 "Update the secondary (read, process, cache) mark."
12214 (gnus-summary-update-mark
12215 (cond ((memq article gnus-newsgroup-processable)
12217 ((memq article gnus-newsgroup-cached)
12219 ((memq article gnus-newsgroup-replied)
12221 ((memq article gnus-newsgroup-saved)
12223 (t gnus-unread-mark))
12225 (when (gnus-visual-p 'summary-highlight 'highlight)
12226 (run-hooks 'gnus-summary-update-hook))
12229 (defun gnus-summary-update-mark (mark type)
12230 (beginning-of-line)
12231 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
12232 (buffer-read-only nil))
12234 (<= (+ forward (point)) (point-max)))
12235 ;; Go to the right position on the line.
12236 (goto-char (+ forward (point)))
12237 ;; Replace the old mark with the new mark.
12238 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
12239 ;; Optionally update the marks by some user rule.
12240 (when (eq type 'unread)
12241 (gnus-data-set-mark
12242 (gnus-data-find (gnus-summary-article-number)) mark)
12243 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
12245 (defun gnus-mark-article-as-read (article &optional mark)
12246 "Enter ARTICLE in the pertinent lists and remove it from others."
12247 ;; Make the article expirable.
12248 (let ((mark (or mark gnus-del-mark)))
12249 (if (= mark gnus-expirable-mark)
12250 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
12251 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
12252 ;; Remove from unread and marked lists.
12253 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12254 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12255 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12256 (push (cons article mark) gnus-newsgroup-reads)
12257 ;; Possibly remove from cache, if that is used.
12258 (when gnus-use-cache
12259 (gnus-cache-enter-remove-article article))))
12261 (defun gnus-mark-article-as-unread (article &optional mark)
12262 "Enter ARTICLE in the pertinent lists and remove it from others."
12263 (let ((mark (or mark gnus-ticked-mark)))
12264 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12265 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12266 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
12267 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12268 (cond ((= mark gnus-ticked-mark)
12269 (push article gnus-newsgroup-marked))
12270 ((= mark gnus-dormant-mark)
12271 (push article gnus-newsgroup-dormant))
12273 (push article gnus-newsgroup-unreads)))
12274 (setq gnus-newsgroup-reads
12275 (delq (assq article gnus-newsgroup-reads)
12276 gnus-newsgroup-reads))))
12278 (defalias 'gnus-summary-mark-as-unread-forward
12279 'gnus-summary-tick-article-forward)
12280 (make-obsolete 'gnus-summary-mark-as-unread-forward
12281 'gnus-summary-tick-article-forward)
12282 (defun gnus-summary-tick-article-forward (n)
12283 "Tick N articles forwards.
12284 If N is negative, tick backwards instead.
12285 The difference between N and the number of articles ticked is returned."
12287 (gnus-summary-mark-forward n gnus-ticked-mark))
12289 (defalias 'gnus-summary-mark-as-unread-backward
12290 'gnus-summary-tick-article-backward)
12291 (make-obsolete 'gnus-summary-mark-as-unread-backward
12292 'gnus-summary-tick-article-backward)
12293 (defun gnus-summary-tick-article-backward (n)
12294 "Tick N articles backwards.
12295 The difference between N and the number of articles ticked is returned."
12297 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
12299 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
12300 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
12301 (defun gnus-summary-tick-article (&optional article clear-mark)
12302 "Mark current article as unread.
12303 Optional 1st argument ARTICLE specifies article number to be marked as unread.
12304 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
12306 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
12307 gnus-ticked-mark)))
12309 (defun gnus-summary-mark-as-read-forward (n)
12310 "Mark N articles as read forwards.
12311 If N is negative, mark backwards instead.
12312 The difference between N and the actual number of articles marked is
12315 (gnus-summary-mark-forward n gnus-del-mark t))
12317 (defun gnus-summary-mark-as-read-backward (n)
12318 "Mark the N articles as read backwards.
12319 The difference between N and the actual number of articles marked is
12322 (gnus-summary-mark-forward (- n) gnus-del-mark t))
12324 (defun gnus-summary-mark-as-read (&optional article mark)
12325 "Mark current article as read.
12326 ARTICLE specifies the article to be marked as read.
12327 MARK specifies a string to be inserted at the beginning of the line."
12328 (gnus-summary-mark-article article mark))
12330 (defun gnus-summary-clear-mark-forward (n)
12331 "Clear marks from N articles forward.
12332 If N is negative, clear backward instead.
12333 The difference between N and the number of marks cleared is returned."
12335 (gnus-summary-mark-forward n gnus-unread-mark))
12337 (defun gnus-summary-clear-mark-backward (n)
12338 "Clear marks from N articles backward.
12339 The difference between N and the number of marks cleared is returned."
12341 (gnus-summary-mark-forward (- n) gnus-unread-mark))
12343 (defun gnus-summary-mark-unread-as-read ()
12344 "Intended to be used by `gnus-summary-mark-article-hook'."
12345 (when (memq gnus-current-article gnus-newsgroup-unreads)
12346 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
12348 (defun gnus-summary-mark-read-and-unread-as-read ()
12349 "Intended to be used by `gnus-summary-mark-article-hook'."
12350 (let ((mark (gnus-summary-article-mark)))
12351 (when (or (gnus-unread-mark-p mark)
12352 (gnus-read-mark-p mark))
12353 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
12355 (defun gnus-summary-mark-region-as-read (point mark all)
12356 "Mark all unread articles between point and mark as read.
12357 If given a prefix, mark all articles between point and mark as read,
12358 even ticked and dormant ones."
12359 (interactive "r\nP")
12363 (beginning-of-line)
12368 (memq (setq article (gnus-summary-article-number))
12369 gnus-newsgroup-unreads))
12370 (gnus-summary-mark-article article gnus-del-mark))
12372 (gnus-summary-find-next))))))
12374 (defun gnus-summary-mark-below (score mark)
12375 "Mark articles with score less than SCORE with MARK."
12376 (interactive "P\ncMark: ")
12377 (gnus-set-global-variables)
12378 (setq score (if score
12379 (prefix-numeric-value score)
12380 (or gnus-summary-default-score 0)))
12382 (set-buffer gnus-summary-buffer)
12383 (goto-char (point-min))
12386 (and (< (gnus-summary-article-score) score)
12387 (gnus-summary-mark-article nil mark))
12388 (gnus-summary-find-next)))))
12390 (defun gnus-summary-kill-below (&optional score)
12391 "Mark articles with score below SCORE as read."
12393 (gnus-set-global-variables)
12394 (gnus-summary-mark-below score gnus-killed-mark))
12396 (defun gnus-summary-clear-above (&optional score)
12397 "Clear all marks from articles with score above SCORE."
12399 (gnus-set-global-variables)
12400 (gnus-summary-mark-above score gnus-unread-mark))
12402 (defun gnus-summary-tick-above (&optional score)
12403 "Tick all articles with score above SCORE."
12405 (gnus-set-global-variables)
12406 (gnus-summary-mark-above score gnus-ticked-mark))
12408 (defun gnus-summary-mark-above (score mark)
12409 "Mark articles with score over SCORE with MARK."
12410 (interactive "P\ncMark: ")
12411 (gnus-set-global-variables)
12412 (setq score (if score
12413 (prefix-numeric-value score)
12414 (or gnus-summary-default-score 0)))
12416 (set-buffer gnus-summary-buffer)
12417 (goto-char (point-min))
12419 (if (> (gnus-summary-article-score) score)
12420 (gnus-summary-mark-article nil mark))
12422 (gnus-summary-find-next)))))
12424 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
12425 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
12426 (defun gnus-summary-limit-include-expunged ()
12427 "Display all the hidden articles that were expunged for low scores."
12429 (gnus-set-global-variables)
12430 (let ((buffer-read-only nil))
12431 (let ((scored gnus-newsgroup-scored)
12434 (or (gnus-summary-goto-subject (caar scored))
12435 (and (setq h (gnus-summary-article-header (caar scored)))
12436 (< (cdar scored) gnus-summary-expunge-below)
12437 (setq headers (cons h headers))))
12438 (setq scored (cdr scored)))
12439 (or headers (error "No expunged articles hidden."))
12440 (goto-char (point-min))
12441 (gnus-summary-prepare-unthreaded (nreverse headers)))
12442 (goto-char (point-min))
12443 (gnus-summary-position-point)))
12445 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
12446 "Mark all articles not marked as unread in this newsgroup as read.
12447 If prefix argument ALL is non-nil, all articles are marked as read.
12448 If QUIETLY is non-nil, no questions will be asked.
12449 If TO-HERE is non-nil, it should be a point in the buffer. All
12450 articles before this point will be marked as read.
12451 The number of articles marked as read is returned."
12453 (gnus-set-global-variables)
12456 (not gnus-interactive-catchup) ;Without confirmation?
12460 "Mark absolutely all articles as read? "
12461 "Mark all unread articles as read? ")))
12463 (not gnus-newsgroup-adaptive)
12464 (not gnus-newsgroup-auto-expire))
12467 (setq gnus-newsgroup-marked nil
12468 gnus-newsgroup-dormant nil))
12469 (setq gnus-newsgroup-unreads nil))
12470 ;; We actually mark all articles as canceled, which we
12471 ;; have to do when using auto-expiry or adaptive scoring.
12472 (gnus-summary-show-all-threads)
12473 (if (gnus-summary-first-subject (not all))
12475 (if to-here (< (point) to-here) t)
12476 (gnus-summary-mark-article-as-read gnus-catchup-mark)
12477 (gnus-summary-find-next (not all)))))
12479 (setq gnus-newsgroup-unreads nil))
12480 (gnus-set-mode-line 'summary)))
12481 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
12482 (if (and (not to-here) (eq 'nnvirtual (car method)))
12483 (nnvirtual-catchup-group
12484 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
12485 (gnus-summary-position-point)))
12487 (defun gnus-summary-catchup-to-here (&optional all)
12488 "Mark all unticked articles before the current one as read.
12489 If ALL is non-nil, also mark ticked and dormant articles as read."
12491 (gnus-set-global-variables)
12493 (gnus-save-hidden-threads
12494 (let ((beg (point)))
12495 ;; We check that there are unread articles.
12496 (when (or all (gnus-summary-find-prev))
12497 (gnus-summary-catchup all t beg)))))
12498 (gnus-summary-position-point))
12500 (defun gnus-summary-catchup-all (&optional quietly)
12501 "Mark all articles in this newsgroup as read."
12503 (gnus-set-global-variables)
12504 (gnus-summary-catchup t quietly))
12506 (defun gnus-summary-catchup-and-exit (&optional all quietly)
12507 "Mark all articles not marked as unread in this newsgroup as read, then exit.
12508 If prefix argument ALL is non-nil, all articles are marked as read."
12510 (gnus-set-global-variables)
12511 (gnus-summary-catchup all quietly nil 'fast)
12512 ;; Select next newsgroup or exit.
12513 (if (eq gnus-auto-select-next 'quietly)
12514 (gnus-summary-next-group nil)
12515 (gnus-summary-exit)))
12517 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
12518 "Mark all articles in this newsgroup as read, and then exit."
12520 (gnus-set-global-variables)
12521 (gnus-summary-catchup-and-exit t quietly))
12523 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
12524 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
12525 "Mark all articles in this group as read and select the next group.
12526 If given a prefix, mark all articles, unread as well as ticked, as
12529 (gnus-set-global-variables)
12531 (gnus-summary-catchup all))
12532 (gnus-summary-next-article t nil nil t))
12534 ;; Thread-based commands.
12536 (defun gnus-summary-articles-in-thread (&optional article)
12537 "Return a list of all articles in the current thread.
12538 If ARTICLE is non-nil, return all articles in the thread that starts
12539 with that article."
12540 (let* ((article (or article (gnus-summary-article-number)))
12541 (data (gnus-data-find-list article))
12542 (top-level (gnus-data-level (car data)))
12544 (cond ((null gnus-thread-operation-ignore-subject)
12545 (gnus-simplify-subject-re
12546 (mail-header-subject (gnus-data-header (car data)))))
12547 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
12548 (gnus-simplify-subject-fuzzy
12549 (mail-header-subject (gnus-data-header (car data)))))
12551 (end-point (save-excursion
12552 (if (gnus-summary-go-to-next-thread)
12553 (point) (point-max))))
12556 (< (gnus-data-pos (car data)) end-point))
12557 (when (or (not top-subject)
12558 (string= top-subject
12559 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
12560 (gnus-simplify-subject-fuzzy
12561 (mail-header-subject
12562 (gnus-data-header (car data))))
12563 (gnus-simplify-subject-re
12564 (mail-header-subject
12565 (gnus-data-header (car data)))))))
12566 (push (gnus-data-number (car data)) articles))
12567 (unless (and (setq data (cdr data))
12568 (> (gnus-data-level (car data)) top-level))
12570 ;; Return the list of articles.
12571 (nreverse articles)))
12573 (defun gnus-summary-rethread-current ()
12574 "Rethread the thread the current article is part of."
12576 (gnus-set-global-variables)
12577 (let* ((gnus-show-threads t)
12578 (article (gnus-summary-article-number))
12579 (id (mail-header-id (gnus-summary-article-header)))
12580 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
12582 (error "No article on the current line"))
12583 (gnus-rebuild-thread id)
12584 (gnus-summary-goto-subject article)))
12586 (defun gnus-summary-reparent-thread ()
12587 "Make current article child of the marked (or previous) article.
12589 Note that the re-threading will only work if `gnus-thread-ignore-subject'
12590 is non-nil or the Subject: of both articles are the same."
12592 (or (not (gnus-group-read-only-p))
12593 (error "The current newsgroup does not support article editing."))
12594 (or (<= (length gnus-newsgroup-processable) 1)
12595 (error "No more than one article may be marked."))
12596 (save-window-excursion
12597 (let ((gnus-article-buffer " *reparent*")
12598 (current-article (gnus-summary-article-number))
12599 ; first grab the marked article, otherwise one line up.
12600 (parent-article (if (not (null gnus-newsgroup-processable))
12601 (car gnus-newsgroup-processable)
12603 (if (eq (forward-line -1) 0)
12604 (gnus-summary-article-number)
12605 (error "Beginning of summary buffer."))))))
12606 (or (not (eq current-article parent-article))
12607 (error "An article may not be self-referential."))
12608 (let ((message-id (mail-header-id
12609 (gnus-summary-article-header parent-article))))
12610 (or (and message-id (not (equal message-id "")))
12611 (error "No message-id in desired parent."))
12612 (gnus-summary-select-article t t nil current-article)
12613 (set-buffer gnus-article-buffer)
12614 (setq buffer-read-only nil)
12615 (let ((buf (format "%s" (buffer-string))))
12618 (goto-char (point-min))
12619 (if (search-forward-regexp "^References: " nil t)
12620 (insert message-id " " )
12621 (insert "References: " message-id "\n"))
12622 (or (gnus-request-replace-article current-article
12623 (car gnus-article-current)
12624 gnus-article-buffer)
12625 (error "Couldn't replace article."))
12626 (set-buffer gnus-summary-buffer)
12627 (gnus-summary-unmark-all-processable)
12628 (gnus-summary-rethread-current)
12629 (gnus-message 3 "Article %d is now the child of article %d."
12630 current-article parent-article)))))
12632 (defun gnus-summary-toggle-threads (&optional arg)
12633 "Toggle showing conversation threads.
12634 If ARG is positive number, turn showing conversation threads on."
12636 (gnus-set-global-variables)
12637 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
12638 (setq gnus-show-threads
12639 (if (null arg) (not gnus-show-threads)
12640 (> (prefix-numeric-value arg) 0)))
12641 (gnus-summary-prepare)
12642 (gnus-summary-goto-subject current)
12643 (gnus-summary-position-point)))
12645 (defun gnus-summary-show-all-threads ()
12646 "Show all threads."
12648 (gnus-set-global-variables)
12650 (let ((buffer-read-only nil))
12651 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
12652 (gnus-summary-position-point))
12654 (defun gnus-summary-show-thread ()
12655 "Show thread subtrees.
12656 Returns nil if no thread was there to be shown."
12658 (gnus-set-global-variables)
12659 (let ((buffer-read-only nil)
12661 ;; first goto end then to beg, to have point at beg after let
12662 (end (progn (end-of-line) (point)))
12663 (beg (progn (beginning-of-line) (point))))
12665 ;; Any hidden lines here?
12666 (search-forward "\r" end t)
12667 (subst-char-in-region beg end ?\^M ?\n t)
12669 (gnus-summary-position-point))))
12671 (defun gnus-summary-hide-all-threads ()
12672 "Hide all thread subtrees."
12674 (gnus-set-global-variables)
12676 (goto-char (point-min))
12677 (gnus-summary-hide-thread)
12678 (while (zerop (gnus-summary-next-thread 1 t))
12679 (gnus-summary-hide-thread)))
12680 (gnus-summary-position-point))
12682 (defun gnus-summary-hide-thread ()
12683 "Hide thread subtrees.
12684 Returns nil if no threads were there to be hidden."
12686 (gnus-set-global-variables)
12687 (let ((buffer-read-only nil)
12689 (article (gnus-summary-article-number)))
12691 ;; Go forward until either the buffer ends or the subthread
12693 (when (and (not (eobp))
12694 (or (zerop (gnus-summary-next-thread 1 t))
12695 (goto-char (point-max))))
12697 (if (and (> (point) start)
12698 (search-backward "\n" start t))
12700 (subst-char-in-region start (point) ?\n ?\^M)
12701 (gnus-summary-goto-subject article))
12704 ;;(gnus-summary-position-point)
12707 (defun gnus-summary-go-to-next-thread (&optional previous)
12708 "Go to the same level (or less) next thread.
12709 If PREVIOUS is non-nil, go to previous thread instead.
12710 Return the article number moved to, or nil if moving was impossible."
12711 (let ((level (gnus-summary-thread-level))
12712 (way (if previous -1 1))
12715 (while (and (not (eobp))
12716 (< level (gnus-summary-thread-level)))
12717 (forward-line way))
12724 (gnus-summary-article-number)
12725 (goto-char beg)))))
12727 (defun gnus-summary-go-to-next-thread-old (&optional previous)
12728 "Go to the same level (or less) next thread.
12729 If PREVIOUS is non-nil, go to previous thread instead.
12730 Return the article number moved to, or nil if moving was impossible."
12731 (if (and (eq gnus-summary-make-false-root 'dummy)
12732 (gnus-summary-article-intangible-p))
12733 (let ((beg (point)))
12734 (while (and (zerop (forward-line 1))
12735 (not (gnus-summary-article-intangible-p))
12736 (not (zerop (save-excursion
12737 (gnus-summary-thread-level))))))
12743 (let* ((level (gnus-summary-thread-level))
12744 (article (gnus-summary-article-number))
12745 (data (cdr (gnus-data-find-list article (gnus-data-list previous))))
12748 (if (<= (gnus-data-level (car data)) level)
12749 (setq oart (gnus-data-number (car data))
12751 (setq data (cdr data))))
12753 (gnus-summary-goto-subject oart)))))
12755 (defun gnus-summary-next-thread (n &optional silent)
12756 "Go to the same level next N'th thread.
12757 If N is negative, search backward instead.
12758 Returns the difference between N and the number of skips actually
12761 If SILENT, don't output messages."
12763 (gnus-set-global-variables)
12764 (let ((backward (< n 0))
12767 (while (and (> n 0)
12768 (gnus-summary-go-to-next-thread backward))
12771 (gnus-summary-position-point))
12772 (when (and (not silent) (/= 0 n))
12773 (gnus-message 7 "No more threads"))
12776 (defun gnus-summary-prev-thread (n)
12777 "Go to the same level previous N'th thread.
12778 Returns the difference between N and the number of skips actually
12781 (gnus-set-global-variables)
12782 (gnus-summary-next-thread (- n)))
12784 (defun gnus-summary-go-down-thread ()
12785 "Go down one level in the current thread."
12786 (let ((children (gnus-summary-article-children)))
12788 (gnus-summary-goto-subject (car children)))))
12790 (defun gnus-summary-go-up-thread ()
12791 "Go up one level in the current thread."
12792 (let ((parent (gnus-summary-article-parent)))
12794 (gnus-summary-goto-subject parent))))
12796 (defun gnus-summary-down-thread (n)
12797 "Go down thread N steps.
12798 If N is negative, go up instead.
12799 Returns the difference between N and how many steps down that were
12802 (gnus-set-global-variables)
12805 (while (and (> n 0)
12806 (if up (gnus-summary-go-up-thread)
12807 (gnus-summary-go-down-thread)))
12809 (gnus-summary-position-point)
12810 (if (/= 0 n) (gnus-message 7 "Can't go further"))
12813 (defun gnus-summary-up-thread (n)
12814 "Go up thread N steps.
12815 If N is negative, go up instead.
12816 Returns the difference between N and how many steps down that were
12819 (gnus-set-global-variables)
12820 (gnus-summary-down-thread (- n)))
12822 (defun gnus-summary-top-thread ()
12823 "Go to the top of the thread."
12825 (gnus-set-global-variables)
12826 (while (gnus-summary-go-up-thread))
12827 (gnus-summary-article-number))
12829 (defun gnus-summary-kill-thread (&optional unmark)
12830 "Mark articles under current thread as read.
12831 If the prefix argument is positive, remove any kinds of marks.
12832 If the prefix argument is negative, tick articles instead."
12834 (gnus-set-global-variables)
12836 (setq unmark (prefix-numeric-value unmark)))
12837 (let ((articles (gnus-summary-articles-in-thread)))
12839 ;; Expand the thread.
12840 (gnus-summary-show-thread)
12841 ;; Mark all the articles.
12843 (gnus-summary-goto-subject (car articles))
12844 (cond ((null unmark)
12845 (gnus-summary-mark-article-as-read gnus-killed-mark))
12847 (gnus-summary-mark-article-as-unread gnus-unread-mark))
12849 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
12850 (setq articles (cdr articles))))
12851 ;; Hide killed subtrees.
12853 gnus-thread-hide-killed
12854 (gnus-summary-hide-thread))
12855 ;; If marked as read, go to next unread subject.
12857 ;; Go to next unread subject.
12858 (gnus-summary-next-subject 1 t)))
12859 (gnus-set-mode-line 'summary))
12861 ;; Summary sorting commands
12863 (defun gnus-summary-sort-by-number (&optional reverse)
12864 "Sort summary buffer by article number.
12865 Argument REVERSE means reverse order."
12867 (gnus-summary-sort 'number reverse))
12869 (defun gnus-summary-sort-by-author (&optional reverse)
12870 "Sort summary buffer by author name alphabetically.
12871 If case-fold-search is non-nil, case of letters is ignored.
12872 Argument REVERSE means reverse order."
12874 (gnus-summary-sort 'author reverse))
12876 (defun gnus-summary-sort-by-subject (&optional reverse)
12877 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
12878 If case-fold-search is non-nil, case of letters is ignored.
12879 Argument REVERSE means reverse order."
12881 (gnus-summary-sort 'subject reverse))
12883 (defun gnus-summary-sort-by-date (&optional reverse)
12884 "Sort summary buffer by date.
12885 Argument REVERSE means reverse order."
12887 (gnus-summary-sort 'date reverse))
12889 (defun gnus-summary-sort-by-score (&optional reverse)
12890 "Sort summary buffer by score.
12891 Argument REVERSE means reverse order."
12893 (gnus-summary-sort 'score reverse))
12895 (defun gnus-summary-sort (predicate reverse)
12896 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
12897 (gnus-set-global-variables)
12898 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
12899 (article (intern (format "gnus-article-sort-by-%s" predicate)))
12900 (gnus-thread-sort-functions
12905 (,thread t2 t1)))))
12906 (gnus-article-sort-functions
12911 (,article t2 t1)))))
12913 (gnus-summary-prepare-hook nil))
12914 ;; We do the sorting by regenerating the threads.
12915 (gnus-summary-prepare)
12916 ;; Hide subthreads if needed.
12917 (when (and gnus-show-threads gnus-thread-hide-subtree)
12918 (gnus-summary-hide-all-threads)))
12919 ;; If in async mode, we send some info to the backend.
12920 (when gnus-newsgroup-async
12921 (gnus-request-asynchronous
12922 gnus-newsgroup-name gnus-newsgroup-data)))
12924 (defun gnus-sortable-date (date)
12925 "Make sortable string by string-lessp from DATE.
12926 Timezone package is used."
12929 (setq date (inline (timezone-fix-time
12931 (aref (inline (timezone-parse-date date)) 4))))
12933 (timezone-make-sortable-date
12934 (aref date 0) (aref date 1) (aref date 2)
12936 (timezone-make-time-string
12937 (aref date 3) (aref date 4) (aref date 5))))))
12940 ;; Summary saving commands.
12942 (defun gnus-summary-save-article (&optional n not-saved)
12943 "Save the current article using the default saver function.
12944 If N is a positive number, save the N next articles.
12945 If N is a negative number, save the N previous articles.
12946 If N is nil and any articles have been marked with the process mark,
12947 save those articles instead.
12948 The variable `gnus-default-article-saver' specifies the saver function."
12950 (gnus-set-global-variables)
12951 (let ((articles (gnus-summary-work-articles n))
12952 (save-buffer (save-excursion
12953 (nnheader-set-temp-buffer " *Gnus Save*")))
12954 file header article)
12956 (setq header (gnus-summary-article-header
12957 (setq article (pop articles))))
12958 (if (not (vectorp header))
12959 ;; This is a pseudo-article.
12960 (if (assq 'name header)
12961 (gnus-copy-file (cdr (assq 'name header)))
12962 (gnus-message 1 "Article %d is unsaveable" article))
12963 ;; This is a real article.
12964 (save-window-excursion
12965 (gnus-summary-select-article t nil nil article))
12967 (set-buffer save-buffer)
12969 (insert-buffer-substring gnus-original-article-buffer))
12970 (unless gnus-save-all-headers
12971 ;; Remove headers accoring to `gnus-saved-headers'.
12972 (let ((gnus-visible-headers
12973 (or gnus-saved-headers gnus-visible-headers))
12974 (gnus-article-buffer save-buffer))
12975 (gnus-article-hide-headers 1 t)))
12976 (save-window-excursion
12977 (if (not gnus-default-article-saver)
12978 (error "No default saver is defined.")
12979 ;; !!! Magic! The saving functions all save
12980 ;; `gnus-original-article-buffer' (or so they think),
12981 ;; but we bind that variable to our save-buffer.
12982 (set-buffer gnus-article-buffer)
12983 (let ((gnus-original-article-buffer save-buffer))
12984 (set-buffer gnus-summary-buffer)
12985 (setq file (funcall
12986 gnus-default-article-saver
12988 ((not gnus-prompt-before-saving)
12990 ((eq gnus-prompt-before-saving 'always)
12993 (gnus-summary-remove-process-mark article)
12995 (gnus-summary-set-saved-mark article))))
12996 (gnus-kill-buffer save-buffer)
12997 (gnus-summary-position-point)
13000 (defun gnus-summary-pipe-output (&optional arg)
13001 "Pipe the current article to a subprocess.
13002 If N is a positive number, pipe the N next articles.
13003 If N is a negative number, pipe the N previous articles.
13004 If N is nil and any articles have been marked with the process mark,
13005 pipe those articles instead."
13007 (gnus-set-global-variables)
13008 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
13009 (gnus-summary-save-article arg t))
13010 (gnus-configure-windows 'pipe))
13012 (defun gnus-summary-save-article-mail (&optional arg)
13013 "Append the current article to an mail file.
13014 If N is a positive number, save the N next articles.
13015 If N is a negative number, save the N previous articles.
13016 If N is nil and any articles have been marked with the process mark,
13017 save those articles instead."
13019 (gnus-set-global-variables)
13020 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
13021 (gnus-summary-save-article arg)))
13023 (defun gnus-summary-save-article-rmail (&optional arg)
13024 "Append the current article to an rmail file.
13025 If N is a positive number, save the N next articles.
13026 If N is a negative number, save the N previous articles.
13027 If N is nil and any articles have been marked with the process mark,
13028 save those articles instead."
13030 (gnus-set-global-variables)
13031 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
13032 (gnus-summary-save-article arg)))
13034 (defun gnus-summary-save-article-file (&optional arg)
13035 "Append the current article to a file.
13036 If N is a positive number, save the N next articles.
13037 If N is a negative number, save the N previous articles.
13038 If N is nil and any articles have been marked with the process mark,
13039 save those articles instead."
13041 (gnus-set-global-variables)
13042 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
13043 (gnus-summary-save-article arg)))
13045 (defun gnus-summary-save-article-body-file (&optional arg)
13046 "Append the current article body to a file.
13047 If N is a positive number, save the N next articles.
13048 If N is a negative number, save the N previous articles.
13049 If N is nil and any articles have been marked with the process mark,
13050 save those articles instead."
13052 (gnus-set-global-variables)
13053 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
13054 (gnus-summary-save-article arg)))
13056 (defun gnus-get-split-value (methods)
13057 "Return a value based on the split METHODS."
13058 (let (split-name method result match)
13061 (set-buffer gnus-original-article-buffer)
13063 (nnheader-narrow-to-headers)
13065 (goto-char (point-min))
13066 (setq method (pop methods))
13067 (setq match (car method))
13070 ;; Regular expression.
13072 (re-search-forward match nil t)
13074 ((gnus-functionp match)
13078 (setq result (funcall match gnus-newsgroup-name))))
13083 (setq result (eval match)))))
13084 (setq split-name (append (cdr method) split-name))
13085 (cond ((stringp result)
13086 (push result split-name))
13088 (setq split-name (append result split-name)))))))))
13091 (defun gnus-read-move-group-name (prompt default articles prefix)
13092 "Read a group name."
13093 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
13094 (minibuffer-confirm-incomplete nil) ; XEmacs
13101 (assoc (symbol-name
13102 (car (gnus-find-method-for-group
13104 gnus-valid-select-methods))
13105 (push (list (symbol-name g)) group-map)))
13106 gnus-active-hashtb))
13108 (format "%s %s to:"
13110 (if (> (length articles) 1)
13111 (format "these %d articles" (length articles))
13116 (gnus-completing-read default prom
13117 group-map nil nil prefix
13118 'gnus-group-history))
13119 ((= 1 (length split-name))
13120 (gnus-completing-read (car split-name) prom group-map
13122 'gnus-group-history))
13124 (gnus-completing-read nil prom
13125 (mapcar (lambda (el) (list el))
13126 (nreverse split-name))
13128 'gnus-group-history)))))
13130 (if (or (string= to-newsgroup "")
13131 (string= to-newsgroup prefix))
13132 (setq to-newsgroup (or default "")))
13133 (or (gnus-active to-newsgroup)
13134 (gnus-activate-group to-newsgroup)
13135 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
13137 (or (gnus-request-create-group to-newsgroup)
13138 (error "Couldn't create group %s" to-newsgroup)))
13139 (error "No such group: %s" to-newsgroup)))
13142 (defun gnus-read-save-file-name (prompt default-name)
13143 (let* ((split-name (gnus-get-split-value gnus-split-methods))
13145 ;; Let the split methods have their say.
13147 ;; No split name was found.
13150 (concat prompt " (default "
13151 (file-name-nondirectory default-name) ") ")
13152 (file-name-directory default-name)
13154 ;; A single split name was found
13155 ((= 1 (length split-name))
13157 (concat prompt " (default " (car split-name) ") ")
13158 gnus-article-save-directory
13159 (concat gnus-article-save-directory (car split-name))))
13160 ;; A list of splits was found.
13162 (setq split-name (nreverse split-name))
13164 (let ((file-name-history (nconc split-name file-name-history)))
13167 (concat prompt " (`M-p' for defaults) ")
13168 gnus-article-save-directory
13169 (car split-name))))
13170 (car (push result file-name-history)))))))
13171 ;; If we have read a directory, we append the default file name.
13172 (when (file-directory-p file)
13173 (setq file (concat (file-name-as-directory file)
13174 (file-name-nondirectory default-name))))
13175 ;; Possibly translate some charaters.
13176 (nnheader-translate-file-chars file)))
13178 (defun gnus-article-archive-name (group)
13179 "Return the first instance of an \"Archive-name\" in the current buffer."
13180 (let ((case-fold-search t))
13181 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
13182 (match-string 1))))
13184 (defun gnus-summary-save-in-rmail (&optional filename)
13185 "Append this article to Rmail file.
13186 Optional argument FILENAME specifies file name.
13187 Directory to save to is default to `gnus-article-save-directory'."
13189 (gnus-set-global-variables)
13190 (let ((default-name
13191 (funcall gnus-rmail-save-name gnus-newsgroup-name
13192 gnus-current-headers gnus-newsgroup-last-rmail)))
13194 (cond ((eq filename 'default)
13196 (filename filename)
13197 (t (gnus-read-save-file-name
13198 "Save in rmail file:" default-name))))
13199 (gnus-make-directory (file-name-directory filename))
13200 (gnus-eval-in-buffer-window gnus-original-article-buffer
13204 (gnus-output-to-rmail filename))))
13205 ;; Remember the directory name to save articles
13206 (setq gnus-newsgroup-last-rmail filename)))
13208 (defun gnus-summary-save-in-mail (&optional filename)
13209 "Append this article to Unix mail file.
13210 Optional argument FILENAME specifies file name.
13211 Directory to save to is default to `gnus-article-save-directory'."
13213 (gnus-set-global-variables)
13214 (let ((default-name
13215 (funcall gnus-mail-save-name gnus-newsgroup-name
13216 gnus-current-headers gnus-newsgroup-last-mail)))
13218 (cond ((eq filename 'default)
13220 (filename filename)
13221 (t (gnus-read-save-file-name
13222 "Save in Unix mail file:" default-name))))
13224 (expand-file-name filename
13226 (file-name-directory default-name))))
13227 (gnus-make-directory (file-name-directory filename))
13228 (gnus-eval-in-buffer-window gnus-original-article-buffer
13232 (if (and (file-readable-p filename) (mail-file-babyl-p filename))
13233 (gnus-output-to-rmail filename)
13234 (let ((mail-use-rfc822 t))
13235 (rmail-output filename 1 t t))))))
13236 ;; Remember the directory name to save articles.
13237 (setq gnus-newsgroup-last-mail filename)))
13239 (defun gnus-summary-save-in-file (&optional filename)
13240 "Append this article to file.
13241 Optional argument FILENAME specifies file name.
13242 Directory to save to is default to `gnus-article-save-directory'."
13244 (gnus-set-global-variables)
13245 (let ((default-name
13246 (funcall gnus-file-save-name gnus-newsgroup-name
13247 gnus-current-headers gnus-newsgroup-last-file)))
13249 (cond ((eq filename 'default)
13251 (filename filename)
13252 (t (gnus-read-save-file-name
13253 "Save in file:" default-name))))
13254 (gnus-make-directory (file-name-directory filename))
13255 (gnus-eval-in-buffer-window gnus-original-article-buffer
13259 (gnus-output-to-file filename))))
13260 ;; Remember the directory name to save articles.
13261 (setq gnus-newsgroup-last-file filename)))
13263 (defun gnus-summary-save-body-in-file (&optional filename)
13264 "Append this article body to a file.
13265 Optional argument FILENAME specifies file name.
13266 The directory to save in defaults to `gnus-article-save-directory'."
13268 (gnus-set-global-variables)
13269 (let ((default-name
13270 (funcall gnus-file-save-name gnus-newsgroup-name
13271 gnus-current-headers gnus-newsgroup-last-file)))
13273 (cond ((eq filename 'default)
13275 (filename filename)
13276 (t (gnus-read-save-file-name
13277 "Save body in file:" default-name))))
13278 (gnus-make-directory (file-name-directory filename))
13279 (gnus-eval-in-buffer-window gnus-article-buffer
13283 (goto-char (point-min))
13284 (and (search-forward "\n\n" nil t)
13285 (narrow-to-region (point) (point-max)))
13286 (gnus-output-to-file filename))))
13287 ;; Remember the directory name to save articles.
13288 (setq gnus-newsgroup-last-file filename)))
13290 (defun gnus-summary-save-in-pipe (&optional command)
13291 "Pipe this article to subprocess."
13293 (gnus-set-global-variables)
13295 (cond ((eq command 'default)
13296 gnus-last-shell-command)
13298 (t (read-string "Shell command on article: "
13299 gnus-last-shell-command))))
13300 (if (string-equal command "")
13301 (setq command gnus-last-shell-command))
13302 (gnus-eval-in-buffer-window gnus-article-buffer
13305 (shell-command-on-region (point-min) (point-max) command nil)))
13306 (setq gnus-last-shell-command command))
13308 ;; Summary extract commands
13310 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
13311 (let ((buffer-read-only nil)
13312 (article (gnus-summary-article-number))
13314 (or (gnus-summary-goto-subject article)
13315 (error (format "No such article: %d" article)))
13316 (gnus-summary-position-point)
13317 ;; If all commands are to be bunched up on one line, we collect
13319 (if gnus-view-pseudos-separately
13321 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
13324 (setq action (cdr (assq 'action (car ps))))
13325 (setq files (list (cdr (assq 'name (car ps)))))
13326 (while (and ps (cdr ps)
13327 (string= (or action "1")
13328 (or (cdr (assq 'action (cadr ps))) "2")))
13329 (setq files (cons (cdr (assq 'name (cadr ps))) files))
13330 (setcdr ps (cddr ps)))
13333 (if (not (string-match "%s" action))
13334 (setq files (cons " " files)))
13335 (setq files (cons " " files))
13336 (and (assq 'execute (car ps))
13337 (setcdr (assq 'execute (car ps))
13338 (funcall (if (string-match "%s" action)
13341 (mapconcat (lambda (f) f) files " ")))))
13342 (setq ps (cdr ps)))))
13343 (if (and gnus-view-pseudos (not not-view))
13345 (and (assq 'execute (car pslist))
13346 (gnus-execute-command (cdr (assq 'execute (car pslist)))
13347 (eq gnus-view-pseudos 'not-confirm)))
13348 (setq pslist (cdr pslist)))
13351 (setq after-article (or (cdr (assq 'article (car pslist)))
13352 (gnus-summary-article-number)))
13353 (gnus-summary-goto-subject after-article)
13356 (insert " " (file-name-nondirectory
13357 (cdr (assq 'name (car pslist))))
13358 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
13360 (forward-line -1) ; back to `b'
13361 (gnus-add-text-properties
13362 b (1- e) (list 'gnus-number gnus-reffed-article-number
13363 gnus-mouse-face-prop gnus-mouse-face))
13365 after-article gnus-reffed-article-number
13366 gnus-unread-mark b (car pslist) 0 (- e b))
13367 (push gnus-reffed-article-number gnus-newsgroup-unreads)
13368 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
13369 (setq pslist (cdr pslist)))))))
13371 (defun gnus-pseudos< (p1 p2)
13372 (let ((c1 (cdr (assq 'action p1)))
13373 (c2 (cdr (assq 'action p2))))
13374 (and c1 c2 (string< c1 c2))))
13376 (defun gnus-request-pseudo-article (props)
13377 (cond ((assq 'execute props)
13378 (gnus-execute-command (cdr (assq 'execute props)))))
13379 (let ((gnus-current-article (gnus-summary-article-number)))
13380 (run-hooks 'gnus-mark-article-hook)))
13382 (defun gnus-execute-command (command &optional automatic)
13384 (gnus-article-setup-buffer)
13385 (set-buffer gnus-article-buffer)
13386 (setq buffer-read-only nil)
13387 (let ((command (if automatic command (read-string "Command: " command)))
13388 ;; Just binding this here doesn't help, because there might
13389 ;; be output from the process after exiting the scope of
13391 ;; (buffer-read-only nil)
13394 (insert "$ " command "\n\n")
13395 (if gnus-view-pseudo-asynchronously
13396 (start-process "gnus-execute" nil "sh" "-c" command)
13397 (call-process "sh" nil t nil "-c" command)))))
13399 (defun gnus-copy-file (file &optional to)
13402 (list (read-file-name "Copy file: " default-directory)
13403 (read-file-name "Copy file to: " default-directory)))
13404 (gnus-set-global-variables)
13405 (or to (setq to (read-file-name "Copy file to: " default-directory)))
13406 (and (file-directory-p to)
13407 (setq to (concat (file-name-as-directory to)
13408 (file-name-nondirectory file))))
13409 (copy-file file to))
13411 ;; Summary kill commands.
13413 (defun gnus-summary-edit-global-kill (article)
13414 "Edit the \"global\" kill file."
13415 (interactive (list (gnus-summary-article-number)))
13416 (gnus-set-global-variables)
13417 (gnus-group-edit-global-kill article))
13419 (defun gnus-summary-edit-local-kill ()
13420 "Edit a local kill file applied to the current newsgroup."
13422 (gnus-set-global-variables)
13423 (setq gnus-current-headers (gnus-summary-article-header))
13424 (gnus-set-global-variables)
13425 (gnus-group-edit-local-kill
13426 (gnus-summary-article-number) gnus-newsgroup-name))
13430 ;;; Gnus article mode
13433 (put 'gnus-article-mode 'mode-class 'special)
13435 (if gnus-article-mode-map
13437 (setq gnus-article-mode-map (make-keymap))
13438 (suppress-keymap gnus-article-mode-map)
13440 (gnus-define-keys gnus-article-mode-map
13441 " " gnus-article-goto-next-page
13442 "\177" gnus-article-goto-prev-page
13443 [delete] gnus-article-goto-prev-page
13444 "\C-c^" gnus-article-refer-article
13445 "h" gnus-article-show-summary
13446 "s" gnus-article-show-summary
13447 "\C-c\C-m" gnus-article-mail
13448 "?" gnus-article-describe-briefly
13449 gnus-mouse-2 gnus-article-push-button
13450 "\r" gnus-article-press-button
13451 "\t" gnus-article-next-button
13452 "\M-\t" gnus-article-prev-button
13453 "\C-c\C-b" gnus-bug)
13455 (substitute-key-definition
13456 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map))
13458 (defun gnus-article-mode ()
13459 "Major mode for displaying an article.
13461 All normal editing commands are switched off.
13463 The following commands are available:
13465 \\<gnus-article-mode-map>
13466 \\[gnus-article-next-page]\t Scroll the article one page forwards
13467 \\[gnus-article-prev-page]\t Scroll the article one page backwards
13468 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
13469 \\[gnus-article-show-summary]\t Display the summary buffer
13470 \\[gnus-article-mail]\t Send a reply to the address near point
13471 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
13472 \\[gnus-info-find-node]\t Go to the Gnus info node"
13474 (when (and menu-bar-mode
13475 (gnus-visual-p 'article-menu 'menu))
13476 (gnus-article-make-menu-bar))
13477 (kill-all-local-variables)
13478 (gnus-simplify-mode-line)
13479 (setq mode-name "Article")
13480 (setq major-mode 'gnus-article-mode)
13481 (make-local-variable 'minor-mode-alist)
13482 (or (assq 'gnus-show-mime minor-mode-alist)
13483 (setq minor-mode-alist
13484 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
13485 (use-local-map gnus-article-mode-map)
13486 (make-local-variable 'page-delimiter)
13487 (setq page-delimiter gnus-page-delimiter)
13488 (buffer-disable-undo (current-buffer))
13489 (setq buffer-read-only t) ;Disable modification
13490 (run-hooks 'gnus-article-mode-hook))
13492 (defun gnus-article-setup-buffer ()
13493 "Initialize the article buffer."
13494 (let* ((name (if gnus-single-article-buffer "*Article*"
13495 (concat "*Article " gnus-newsgroup-name "*")))
13497 (progn (string-match "\\*Article" name)
13498 (concat " *Original Article"
13499 (substring name (match-end 0))))))
13500 (setq gnus-article-buffer name)
13501 (setq gnus-original-article-buffer original)
13502 ;; This might be a variable local to the summary buffer.
13503 (unless gnus-single-article-buffer
13505 (set-buffer gnus-summary-buffer)
13506 (setq gnus-article-buffer name)
13507 (setq gnus-original-article-buffer original)
13508 (gnus-set-global-variables))
13509 (make-local-variable 'gnus-summary-buffer))
13510 ;; Init original article buffer.
13512 (set-buffer (get-buffer-create gnus-original-article-buffer))
13513 (buffer-disable-undo (current-buffer))
13514 (setq major-mode 'gnus-original-article-mode)
13515 (make-local-variable 'gnus-original-article))
13516 (if (get-buffer name)
13519 (buffer-disable-undo (current-buffer))
13520 (setq buffer-read-only t)
13521 (gnus-add-current-to-buffer-list)
13522 (or (eq major-mode 'gnus-article-mode)
13523 (gnus-article-mode))
13526 (set-buffer (get-buffer-create name))
13527 (gnus-add-current-to-buffer-list)
13528 (gnus-article-mode)
13529 (current-buffer)))))
13531 ;; Set article window start at LINE, where LINE is the number of lines
13532 ;; from the head of the article.
13533 (defun gnus-article-set-window-start (&optional line)
13535 (get-buffer-window gnus-article-buffer t)
13537 (set-buffer gnus-article-buffer)
13538 (goto-char (point-min))
13541 (gnus-message 6 "Moved to bookmark")
13542 (search-forward "\n\n" nil t)
13543 (forward-line line)
13546 (defun gnus-kill-all-overlays ()
13547 "Delete all overlays in the current buffer."
13548 (when (fboundp 'overlay-lists)
13549 (let* ((overlayss (overlay-lists))
13550 (buffer-read-only nil)
13551 (overlays (nconc (car overlayss) (cdr overlayss))))
13553 (delete-overlay (pop overlays))))))
13555 (defun gnus-request-article-this-buffer (article group)
13556 "Get an article and insert it into this buffer."
13557 (let (do-update-line)
13561 (gnus-kill-all-overlays)
13562 (setq group (or group gnus-newsgroup-name))
13564 ;; Open server if it has closed.
13565 (gnus-check-server (gnus-find-method-for-group group))
13567 ;; Using `gnus-request-article' directly will insert the article into
13568 ;; `nntp-server-buffer' - so we'll save some time by not having to
13569 ;; copy it from the server buffer into the article buffer.
13571 ;; We only request an article by message-id when we do not have the
13572 ;; headers for it, so we'll have to get those.
13573 (when (stringp article)
13574 (let ((gnus-override-method gnus-refer-article-method))
13575 (gnus-read-header article)))
13577 ;; If the article number is negative, that means that this article
13578 ;; doesn't belong in this newsgroup (possibly), so we find its
13579 ;; message-id and request it by id instead of number.
13580 (when (and (numberp article)
13581 gnus-summary-buffer
13582 (get-buffer gnus-summary-buffer)
13583 (buffer-name (get-buffer gnus-summary-buffer)))
13585 (set-buffer gnus-summary-buffer)
13586 (let ((header (gnus-summary-article-header article)))
13589 ((memq article gnus-newsgroup-sparse)
13590 ;; This is a sparse gap article.
13591 (setq do-update-line article)
13592 (setq article (mail-header-id header))
13593 (let ((gnus-override-method gnus-refer-article-method))
13594 (gnus-read-header article))
13595 (setq gnus-newsgroup-sparse
13596 (delq article gnus-newsgroup-sparse)))
13598 ;; It's a real article.
13599 (setq article (mail-header-id header)))
13601 ;; It is an extracted pseudo-article.
13602 (setq article 'pseudo)
13603 (gnus-request-pseudo-article header))))
13605 (let ((method (gnus-find-method-for-group
13606 gnus-newsgroup-name)))
13607 (if (not (eq (car method) 'nneething))
13609 (let ((dir (concat (file-name-as-directory (nth 1 method))
13610 (mail-header-subject header))))
13611 (if (file-directory-p dir)
13613 (setq article 'nneething)
13614 (gnus-group-enter-directory dir)))))))))
13617 ;; Refuse to select canceled articles.
13618 ((and (numberp article)
13619 gnus-summary-buffer
13620 (get-buffer gnus-summary-buffer)
13621 (buffer-name (get-buffer gnus-summary-buffer))
13622 (eq (cdr (save-excursion
13623 (set-buffer gnus-summary-buffer)
13624 (assq article gnus-newsgroup-reads)))
13625 gnus-canceled-mark))
13627 ;; We first check `gnus-original-article-buffer'.
13628 ((and (get-buffer gnus-original-article-buffer)
13631 (set-buffer gnus-original-article-buffer)
13632 (and (equal (car gnus-original-article) group)
13633 (eq (cdr gnus-original-article) article))))
13634 (insert-buffer-substring gnus-original-article-buffer)
13636 ;; Check the backlog.
13637 ((and gnus-keep-backlog
13638 (gnus-backlog-request-article group article (current-buffer)))
13640 ;; Check the cache.
13641 ((and gnus-use-cache
13643 (gnus-cache-request-article article group))
13645 ;; Get the article and put into the article buffer.
13646 ((or (stringp article) (numberp article))
13647 (let ((gnus-override-method
13648 (and (stringp article) gnus-refer-article-method))
13649 (buffer-read-only nil))
13651 (gnus-kill-all-overlays)
13652 (if (gnus-request-article article group (current-buffer))
13654 (and gnus-keep-backlog
13656 (gnus-backlog-enter-article
13657 group article (current-buffer)))
13659 ;; It was a pseudo.
13662 ;; Take the article from the original article buffer
13663 ;; and place it in the buffer it's supposed to be in.
13664 (when (and (get-buffer gnus-article-buffer)
13665 ;;(numberp article)
13666 (equal (buffer-name (current-buffer))
13667 (buffer-name (get-buffer gnus-article-buffer))))
13669 (if (get-buffer gnus-original-article-buffer)
13670 (set-buffer (get-buffer gnus-original-article-buffer))
13671 (set-buffer (get-buffer-create gnus-original-article-buffer))
13672 (buffer-disable-undo (current-buffer))
13673 (setq major-mode 'gnus-original-article-mode)
13674 (setq buffer-read-only t)
13675 (gnus-add-current-to-buffer-list))
13676 (let (buffer-read-only)
13678 (insert-buffer-substring gnus-article-buffer))
13679 (setq gnus-original-article (cons group article))))
13681 ;; Update sparse articles.
13682 (when (and do-update-line
13683 (or (numberp article)
13684 (stringp article)))
13685 (let ((buf (current-buffer)))
13686 (set-buffer gnus-summary-buffer)
13687 (gnus-summary-update-article do-update-line)
13688 (gnus-summary-goto-subject do-update-line nil t)
13689 (set-window-point (get-buffer-window (current-buffer) t)
13691 (set-buffer buf))))))
13693 (defun gnus-read-header (id &optional header)
13694 "Read the headers of article ID and enter them into the Gnus system."
13695 (let ((group gnus-newsgroup-name)
13696 (gnus-override-method
13697 (and (gnus-news-group-p gnus-newsgroup-name)
13698 gnus-refer-article-method))
13700 ;; First we check to see whether the header in question is already
13703 ;; This is a Message-ID.
13704 (setq header (or header (gnus-id-to-header id)))
13705 ;; This is an article number.
13706 (setq header (or header (gnus-summary-article-header id))))
13708 (not (memq (mail-header-number header) gnus-newsgroup-sparse)))
13709 ;; We have found the header.
13711 ;; We have to really fetch the header to this article.
13713 (if (gnus-check-backend-function 'request-head group)
13714 (gnus-request-head id group)
13715 (gnus-request-article id group)))
13717 (set-buffer nntp-server-buffer)
13718 (and (search-forward "\n\n" nil t)
13719 (delete-region (1- (point)) (point-max)))
13720 (goto-char (point-max))
13722 (goto-char (point-min))
13726 ((cdr where) (cdr where))
13727 (header (mail-header-number header))
13728 (t gnus-reffed-article-number))
13730 (insert " Article retrieved.\n"))
13732 ; (memq (mail-header-number header) gnus-newsgroup-sparse))
13733 ; (setcar (gnus-id-to-thread id) nil))
13734 (if (not (setq header (car (gnus-get-newsgroup-headers))))
13735 () ; Malformed head.
13736 (unless (memq (mail-header-number header) gnus-newsgroup-sparse)
13737 (if (and (stringp id)
13738 (not (string= (gnus-group-real-name group)
13740 ;; If we fetched by Message-ID and the article came
13741 ;; from a different group, we fudge some bogus article
13742 ;; numbers for this article.
13743 (mail-header-set-number header gnus-reffed-article-number))
13744 (decf gnus-reffed-article-number)
13745 (gnus-remove-header (mail-header-number header))
13746 (push header gnus-newsgroup-headers)
13747 (setq gnus-current-headers header)
13748 (push (mail-header-number header) gnus-newsgroup-limit))
13751 (defun gnus-remove-header (number)
13752 "Remove header NUMBER from `gnus-newsgroup-headers'."
13753 (if (and gnus-newsgroup-headers
13754 (= number (mail-header-number (car gnus-newsgroup-headers))))
13755 (pop gnus-newsgroup-headers)
13756 (let ((headers gnus-newsgroup-headers))
13757 (while (and (cdr headers)
13758 (not (= number (mail-header-number (cadr headers)))))
13760 (when (cdr headers)
13761 (setcdr headers (cddr headers))))))
13763 (defun gnus-article-prepare (article &optional all-headers header)
13764 "Prepare ARTICLE in article mode buffer.
13765 ARTICLE should either be an article number or a Message-ID.
13766 If ARTICLE is an id, HEADER should be the article headers.
13767 If ALL-HEADERS is non-nil, no headers are hidden."
13769 ;; Make sure we start in a summary buffer.
13770 (unless (eq major-mode 'gnus-summary-mode)
13771 (set-buffer gnus-summary-buffer))
13772 (setq gnus-summary-buffer (current-buffer))
13773 ;; Make sure the connection to the server is alive.
13774 (unless (gnus-server-opened
13775 (gnus-find-method-for-group gnus-newsgroup-name))
13776 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
13777 (gnus-request-group gnus-newsgroup-name t))
13778 (let* ((article (if header (mail-header-number header) article))
13779 (summary-buffer (current-buffer))
13780 (internal-hook gnus-article-internal-prepare-hook)
13781 (group gnus-newsgroup-name)
13784 (gnus-article-setup-buffer)
13785 (set-buffer gnus-article-buffer)
13786 ;; Deactivate active regions.
13787 (when (and (boundp 'transient-mark-mode)
13788 transient-mark-mode)
13789 (setq mark-active nil))
13790 (if (not (setq result (let ((buffer-read-only nil))
13791 (gnus-request-article-this-buffer
13793 ;; There is no such article.
13795 (when (and (numberp article)
13796 (not (memq article gnus-newsgroup-sparse)))
13797 (setq gnus-article-current
13798 (cons gnus-newsgroup-name article))
13799 (set-buffer gnus-summary-buffer)
13800 (setq gnus-current-article article)
13801 (gnus-summary-mark-article article gnus-canceled-mark))
13802 (unless (memq article gnus-newsgroup-sparse)
13804 1 "No such article (may have expired or been canceled)")))
13805 (if (or (eq result 'pseudo) (eq result 'nneething))
13808 (set-buffer summary-buffer)
13809 (setq gnus-last-article gnus-current-article
13810 gnus-newsgroup-history (cons gnus-current-article
13811 gnus-newsgroup-history)
13812 gnus-current-article 0
13813 gnus-current-headers nil
13814 gnus-article-current nil)
13815 (if (eq result 'nneething)
13816 (gnus-configure-windows 'summary)
13817 (gnus-configure-windows 'article))
13818 (gnus-set-global-variables))
13819 (gnus-set-mode-line 'article))
13820 ;; The result from the `request' was an actual article -
13821 ;; or at least some text that is now displayed in the
13823 (if (and (numberp article)
13824 (not (eq article gnus-current-article)))
13825 ;; Seems like a new article has been selected.
13826 ;; `gnus-current-article' must be an article number.
13828 (set-buffer summary-buffer)
13829 (setq gnus-last-article gnus-current-article
13830 gnus-newsgroup-history (cons gnus-current-article
13831 gnus-newsgroup-history)
13832 gnus-current-article article
13833 gnus-current-headers
13834 (gnus-summary-article-header gnus-current-article)
13835 gnus-article-current
13836 (cons gnus-newsgroup-name gnus-current-article))
13837 (unless (vectorp gnus-current-headers)
13838 (setq gnus-current-headers nil))
13839 (gnus-summary-show-thread)
13840 (run-hooks 'gnus-mark-article-hook)
13841 (gnus-set-mode-line 'summary)
13842 (and (gnus-visual-p 'article-highlight 'highlight)
13843 (run-hooks 'gnus-visual-mark-article-hook))
13844 ;; Set the global newsgroup variables here.
13845 ;; Suggested by Jim Sisolak
13846 ;; <sisolak@trans4.neep.wisc.edu>.
13847 (gnus-set-global-variables)
13848 (setq gnus-have-all-headers
13849 (or all-headers gnus-show-all-headers))
13850 (and gnus-use-cache
13851 (vectorp (gnus-summary-article-header article))
13852 (gnus-cache-possibly-enter-article
13854 (gnus-summary-article-header article)
13855 (memq article gnus-newsgroup-marked)
13856 (memq article gnus-newsgroup-dormant)
13857 (memq article gnus-newsgroup-unreads)))))
13858 (when (or (numberp article)
13860 ;; Hooks for getting information from the article.
13861 ;; This hook must be called before being narrowed.
13862 (let (buffer-read-only)
13863 (run-hooks 'internal-hook)
13864 (run-hooks 'gnus-article-prepare-hook)
13865 ;; Decode MIME message.
13867 (if (or (not gnus-strict-mime)
13868 (gnus-fetch-field "Mime-Version"))
13869 (funcall gnus-show-mime-method)
13870 (funcall gnus-decode-encoded-word-method)))
13871 ;; Perform the article display hooks.
13872 (run-hooks 'gnus-article-display-hook))
13874 (goto-char (point-min))
13875 (and gnus-break-pages (gnus-narrow-to-page)))
13876 (gnus-set-mode-line 'article)
13877 (gnus-configure-windows 'article)
13878 (goto-char (point-min))
13881 (defun gnus-article-show-all-headers ()
13882 "Show all article headers in article mode buffer."
13884 (gnus-article-setup-buffer)
13885 (set-buffer gnus-article-buffer)
13886 (let ((buffer-read-only nil))
13887 (gnus-unhide-text (point-min) (point-max)))))
13889 (defun gnus-article-hide-headers-if-wanted ()
13890 "Hide unwanted headers if `gnus-have-all-headers' is nil.
13891 Provided for backwards compatibility."
13892 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers)
13893 gnus-inhibit-hiding
13894 (gnus-article-hide-headers)))
13896 (defsubst gnus-article-header-rank ()
13897 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
13898 (let ((list gnus-sorted-header-list)
13901 (when (looking-at (car list))
13903 (setq list (cdr list))
13907 (defun gnus-article-hide-headers (&optional arg delete)
13908 "Toggle whether to hide unwanted headers and possibly sort them as well.
13909 If given a negative prefix, always show; if given a positive prefix,
13911 (interactive (gnus-hidden-arg))
13912 (if (gnus-article-check-hidden-text 'headers arg)
13913 ;; Show boring headers as well.
13914 (gnus-article-show-hidden-text 'boring-headers)
13915 ;; This function might be inhibited.
13916 (unless gnus-inhibit-hiding
13918 (set-buffer gnus-article-buffer)
13920 (let ((buffer-read-only nil)
13921 (props (nconc (list 'gnus-type 'headers)
13922 gnus-hidden-properties))
13923 (max (1+ (length gnus-sorted-header-list)))
13924 (ignored (when (not (stringp gnus-visible-headers))
13925 (cond ((stringp gnus-ignored-headers)
13926 gnus-ignored-headers)
13927 ((listp gnus-ignored-headers)
13928 (mapconcat 'identity gnus-ignored-headers
13931 (cond ((stringp gnus-visible-headers)
13932 gnus-visible-headers)
13933 ((and gnus-visible-headers
13934 (listp gnus-visible-headers))
13935 (mapconcat 'identity gnus-visible-headers "\\|"))))
13936 (inhibit-point-motion-hooks t)
13938 ;; First we narrow to just the headers.
13940 (goto-char (point-min))
13941 ;; Hide any "From " lines at the beginning of (mail) articles.
13942 (while (looking-at "From ")
13946 (delete-region (point-min) (point))
13947 (gnus-hide-text (point-min) (point) props)))
13948 ;; Then treat the rest of the header lines.
13951 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
13952 ;; Then we use the two regular expressions
13953 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
13954 ;; select which header lines is to remain visible in the
13956 (goto-char (point-min))
13957 (while (re-search-forward "^[^ \t]*:" nil t)
13958 (beginning-of-line)
13959 ;; We add the headers we want to keep to a list and delete
13960 ;; them from the buffer.
13961 (gnus-put-text-property
13962 (point) (1+ (point)) 'message-rank
13963 (if (or (and visible (looking-at visible))
13965 (not (looking-at ignored))))
13966 (gnus-article-header-rank)
13969 (message-sort-headers-1)
13970 (when (setq beg (text-property-any
13971 (point-min) (point-max) 'message-rank (+ 2 max)))
13972 ;; We make the unwanted headers invisible.
13974 (delete-region beg (point-max))
13975 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
13976 (gnus-hide-text-type beg (point-max) 'headers))
13977 ;; Work around XEmacs lossage.
13978 (gnus-put-text-property (point-min) beg 'invisible nil))))))))
13980 (defun gnus-article-hide-boring-headers (&optional arg)
13981 "Toggle hiding of headers that aren't very interesting.
13982 If given a negative prefix, always show; if given a positive prefix,
13984 (interactive (gnus-hidden-arg))
13985 (unless (gnus-article-check-hidden-text 'boring-headers arg)
13987 (set-buffer gnus-article-buffer)
13989 (let ((buffer-read-only nil)
13990 (list gnus-boring-article-headers)
13991 (inhibit-point-motion-hooks t)
13993 (nnheader-narrow-to-headers)
13995 (setq elem (pop list))
13996 (goto-char (point-min))
13998 ;; Hide empty headers.
14000 (while (re-search-forward "^[^:]+:[ \t]\n[^ \t]" nil t)
14002 (gnus-hide-text-type
14003 (progn (beginning-of-line) (point))
14006 (if (re-search-forward "^[^ \t]" nil t)
14007 (match-beginning 0)
14010 ;; Hide boring Newsgroups header.
14011 ((eq elem 'newsgroups)
14012 (when (equal (message-fetch-field "newsgroups")
14013 (gnus-group-real-name gnus-newsgroup-name))
14014 (gnus-article-hide-header "newsgroups")))
14015 ((eq elem 'followup-to)
14016 (when (equal (message-fetch-field "followup-to")
14017 (message-fetch-field "newsgroups"))
14018 (gnus-article-hide-header "followup-to")))
14019 ((eq elem 'reply-to)
14020 (let ((from (message-fetch-field "from"))
14021 (reply-to (message-fetch-field "reply-to")))
14025 (nth 1 (funcall gnus-extract-address-components from))
14026 (nth 1 (funcall gnus-extract-address-components
14028 (gnus-article-hide-header "reply-to"))))
14030 (let ((date (message-fetch-field "date")))
14032 (< (gnus-days-between date (current-time-string))
14034 (gnus-article-hide-header "date")))))))))))
14036 (defun gnus-article-hide-header (header)
14038 (goto-char (point-min))
14039 (when (re-search-forward (concat "^" header ":") nil t)
14040 (gnus-hide-text-type
14041 (progn (beginning-of-line) (point))
14044 (if (re-search-forward "^[^ \t]" nil t)
14045 (match-beginning 0)
14047 'boring-headers))))
14049 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
14050 (defun gnus-article-treat-overstrike ()
14051 "Translate overstrikes into bold text."
14054 (set-buffer gnus-article-buffer)
14055 (let ((buffer-read-only nil))
14056 (while (search-forward "\b" nil t)
14057 (let ((next (following-char))
14058 (previous (char-after (- (point) 2))))
14060 ((eq next previous)
14061 (gnus-put-text-property (- (point) 2) (point) 'invisible t)
14062 (gnus-put-text-property (point) (1+ (point)) 'face 'bold))
14064 (gnus-put-text-property (1- (point)) (1+ (point)) 'invisible t)
14065 (gnus-put-text-property
14066 (- (point) 2) (1- (point)) 'face 'underline))
14068 (gnus-put-text-property (- (point) 2) (point) 'invisible t)
14069 (gnus-put-text-property
14070 (point) (1+ (point)) 'face 'underline))))))))
14072 (defun gnus-article-word-wrap ()
14073 "Format too long lines."
14076 (set-buffer gnus-article-buffer)
14077 (let ((buffer-read-only nil))
14079 (goto-char (point-min))
14080 (search-forward "\n\n" nil t)
14082 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
14083 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
14084 (adaptive-fill-mode t))
14085 (while (not (eobp))
14086 (and (>= (current-column) (min fill-column (window-width)))
14087 (/= (preceding-char) ?:)
14088 (fill-paragraph nil))
14089 (end-of-line 2))))))
14091 (defun gnus-article-remove-cr ()
14092 "Remove carriage returns from an article."
14095 (set-buffer gnus-article-buffer)
14096 (let ((buffer-read-only nil))
14097 (goto-char (point-min))
14098 (while (search-forward "\r" nil t)
14099 (replace-match "" t t)))))
14101 (defun gnus-article-remove-trailing-blank-lines ()
14102 "Remove all trailing blank lines from the article."
14105 (set-buffer gnus-article-buffer)
14106 (let ((buffer-read-only nil))
14107 (goto-char (point-max))
14111 (while (looking-at "^[ \t]*$")
14116 (defun gnus-article-display-x-face (&optional force)
14117 "Look for an X-Face header and display it if present."
14118 (interactive (list 'force))
14120 (set-buffer gnus-article-buffer)
14121 ;; Delete the old process, if any.
14122 (when (process-status "gnus-x-face")
14123 (delete-process "gnus-x-face"))
14124 (let ((inhibit-point-motion-hooks t)
14125 (case-fold-search nil)
14128 (nnheader-narrow-to-headers)
14129 (setq from (message-fetch-field "from"))
14130 (goto-char (point-min))
14131 (when (and gnus-article-x-face-command
14133 ;; Check whether this face is censored.
14134 (not gnus-article-x-face-too-ugly)
14135 (and gnus-article-x-face-too-ugly from
14136 (not (string-match gnus-article-x-face-too-ugly
14138 ;; Has to be present.
14139 (re-search-forward "^X-Face: " nil t))
14140 ;; We now have the area of the buffer where the X-Face is stored.
14141 (let ((beg (point))
14142 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
14143 ;; We display the face.
14144 (if (symbolp gnus-article-x-face-command)
14145 ;; The command is a lisp function, so we call it.
14146 (if (gnus-functionp gnus-article-x-face-command)
14147 (funcall gnus-article-x-face-command beg end)
14148 (error "%s is not a function" gnus-article-x-face-command))
14149 ;; The command is a string, so we interpret the command
14150 ;; as a, well, command, and fork it off.
14151 (let ((process-connection-type nil))
14152 (process-kill-without-query
14154 "gnus-x-face" nil "sh" "-c" gnus-article-x-face-command))
14155 (process-send-region "gnus-x-face" beg end)
14156 (process-send-eof "gnus-x-face")))))))))
14158 (defalias 'gnus-headers-decode-quoted-printable 'gnus-decode-rfc1522)
14159 (defun gnus-decode-rfc1522 ()
14160 "Hack to remove QP encoding from headers."
14161 (let ((case-fold-search t)
14162 (inhibit-point-motion-hooks t)
14163 (buffer-read-only nil)
14167 (goto-char (point-min))
14168 (or (search-forward "\n\n" nil t) (point-max)))
14170 (while (re-search-forward
14171 "=\\?iso-8859-1\\?q\\?\\([^?\t\n]*\\)\\?=" nil t)
14172 (setq string (match-string 1))
14173 (narrow-to-region (match-beginning 0) (match-end 0))
14174 (delete-region (point-min) (point-max))
14176 (gnus-mime-decode-quoted-printable (goto-char (point-min)) (point-max))
14177 (subst-char-in-region (point-min) (point-max) ?_ ? )
14179 (goto-char (point-min))))))
14181 (defun gnus-article-de-quoted-unreadable (&optional force)
14182 "Do a naive translation of a quoted-printable-encoded article.
14183 This is in no way, shape or form meant as a replacement for real MIME
14184 processing, but is simply a stop-gap measure until MIME support is
14186 If FORCE, decode the article whether it is marked as quoted-printable
14188 (interactive (list 'force))
14190 (set-buffer gnus-article-buffer)
14191 (let ((case-fold-search t)
14192 (buffer-read-only nil)
14193 (type (gnus-fetch-field "content-transfer-encoding")))
14194 (gnus-decode-rfc1522)
14196 (and type (string-match "quoted-printable" (downcase type))))
14197 (goto-char (point-min))
14198 (search-forward "\n\n" nil 'move)
14199 (gnus-mime-decode-quoted-printable (point) (point-max))))))
14201 (defun gnus-mime-decode-quoted-printable (from to)
14202 "Decode Quoted-Printable in the region between FROM and TO."
14205 (while (search-forward "=" to t)
14206 (cond ((eq (following-char) ?\n)
14209 ((looking-at "[0-9A-F][0-9A-F]")
14210 (subst-char-in-region
14211 (1- (point)) (point) ?=
14212 (hexl-hex-string-to-integer
14213 (buffer-substring (point) (+ 2 (point)))))
14217 ((gnus-message 3 "Malformed MIME quoted-printable message")))))
14219 (defun gnus-article-hide-pgp (&optional arg)
14220 "Toggle hiding of any PGP headers and signatures in the current article.
14221 If given a negative prefix, always show; if given a positive prefix,
14223 (interactive (gnus-hidden-arg))
14224 (unless (gnus-article-check-hidden-text 'pgp arg)
14226 (set-buffer gnus-article-buffer)
14227 (let ((props (nconc (list 'gnus-type 'pgp) gnus-hidden-properties))
14228 buffer-read-only beg end)
14230 (goto-char (point-min))
14231 ;; Hide the "header".
14232 (and (search-forward "\n-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
14233 (gnus-hide-text (match-beginning 0) (match-end 0) props))
14235 ;; Hide the actual signature.
14236 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
14237 (setq end (1+ (match-beginning 0)))
14240 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
14242 ;; Perhaps we shouldn't hide to the end of the buffer
14243 ;; if there is no end to the signature?
14246 ;; Hide "- " PGP quotation markers.
14247 (when (and beg end)
14248 (narrow-to-region beg end)
14249 (goto-char (point-min))
14250 (while (re-search-forward "^- " nil t)
14251 (gnus-hide-text (match-beginning 0) (match-end 0) props))
14254 (defun gnus-article-hide-signature (&optional arg)
14255 "Hide the signature in the current article.
14256 If given a negative prefix, always show; if given a positive prefix,
14258 (interactive (gnus-hidden-arg))
14259 (unless (gnus-article-check-hidden-text 'signature arg)
14261 (set-buffer gnus-article-buffer)
14263 (let ((buffer-read-only nil))
14264 (when (gnus-narrow-to-signature)
14265 (gnus-hide-text-type (point-min) (point-max) 'signature)))))))
14267 (defun gnus-article-strip-leading-blank-lines ()
14268 "Remove all blank lines from the beginning of the article."
14271 (set-buffer gnus-article-buffer)
14272 (let (buffer-read-only)
14273 (goto-char (point-min))
14274 (when (search-forward "\n\n" nil t)
14275 (while (looking-at "[ \t]$")
14276 (gnus-delete-line))))))
14278 (defvar mime::preview/content-list)
14279 (defvar mime::preview-content-info/point-min)
14280 (defun gnus-narrow-to-signature ()
14281 "Narrow to the signature."
14283 (if (and (boundp 'mime::preview/content-list)
14284 mime::preview/content-list)
14285 (let ((pcinfo (car (last mime::preview/content-list))))
14288 (funcall (intern "mime::preview-content-info/point-min") pcinfo)
14291 (goto-char (point-max))
14292 (when (re-search-backward gnus-signature-separator nil t)
14294 (when (or (null gnus-signature-limit)
14295 (and (numberp gnus-signature-limit)
14296 (< (- (point-max) (point)) gnus-signature-limit))
14297 (and (gnus-functionp gnus-signature-limit)
14298 (funcall gnus-signature-limit))
14299 (and (stringp gnus-signature-limit)
14300 (not (re-search-forward gnus-signature-limit nil t))))
14301 (narrow-to-region (point) (point-max))
14304 (defun gnus-hidden-arg ()
14305 "Return the current prefix arg as a number, or 0 if no prefix."
14306 (list (if current-prefix-arg
14307 (prefix-numeric-value current-prefix-arg)
14310 (defun gnus-article-check-hidden-text (type arg)
14311 "Return nil if hiding is necessary.
14312 Arg can be nil or a number. Nil and positive means hide, negative
14313 means show, 0 means toggle."
14315 (set-buffer gnus-article-buffer)
14316 (let ((hide (gnus-article-hidden-text-p type)))
14322 (gnus-article-show-hidden-text type))
14324 (if (eq hide 'hidden)
14325 (gnus-article-show-hidden-text type)
14328 (defun gnus-article-hidden-text-p (type)
14329 "Say whether the current buffer contains hidden text of type TYPE."
14330 (let ((pos (text-property-any (point-min) (point-max) 'gnus-type type)))
14332 (if (get-text-property pos 'invisible)
14336 (defun gnus-article-hide (&optional arg force)
14337 "Hide all the gruft in the current article.
14338 This means that PGP stuff, signatures, cited text and (some)
14339 headers will be hidden.
14340 If given a prefix, show the hidden text instead."
14341 (interactive (list current-prefix-arg 'force))
14342 (gnus-article-hide-headers arg)
14343 (gnus-article-hide-pgp arg)
14344 (gnus-article-hide-citation-maybe arg force)
14345 (gnus-article-hide-signature arg))
14347 (defun gnus-article-show-hidden-text (type &optional hide)
14348 "Show all hidden text of type TYPE.
14349 If HIDE, hide the text instead."
14351 (set-buffer gnus-article-buffer)
14352 (let ((buffer-read-only nil)
14353 (inhibit-point-motion-hooks t)
14355 (while (gnus-goto-char (text-property-any
14356 beg (point-max) 'gnus-type type))
14360 (gnus-hide-text beg (point) gnus-hidden-properties)
14361 (gnus-unhide-text beg (point)))
14362 (setq beg (point)))
14365 (defvar gnus-article-time-units
14366 `((year . ,(* 365.25 24 60 60))
14367 (week . ,(* 7 24 60 60))
14368 (day . ,(* 24 60 60))
14369 (hour . ,(* 60 60))
14372 "Mapping from time units to seconds.")
14374 (defun gnus-article-date-ut (&optional type highlight)
14375 "Convert DATE date to universal time in the current article.
14376 If TYPE is `local', convert to local time; if it is `lapsed', output
14377 how much time has lapsed since DATE."
14378 (interactive (list 'ut t))
14379 (let* ((header (or gnus-current-headers
14380 (gnus-summary-article-header) ""))
14381 (date (and (vectorp header) (mail-header-date header)))
14382 (date-regexp "^Date: \\|^X-Sent: ")
14383 (now (current-time))
14384 (inhibit-point-motion-hooks t)
14386 (when (and date (not (string= date "")))
14388 (set-buffer gnus-article-buffer)
14390 (nnheader-narrow-to-headers)
14391 (let ((buffer-read-only nil))
14392 ;; Delete any old Date headers.
14393 (if (re-search-forward date-regexp nil t)
14395 (setq bface (get-text-property (gnus-point-at-bol) 'face)
14396 eface (get-text-property (1- (gnus-point-at-eol))
14398 (message-remove-header date-regexp t)
14399 (beginning-of-line))
14400 (goto-char (point-max)))
14401 (insert (gnus-make-date-line date type))
14402 ;; Do highlighting.
14404 (when (and (gnus-visual-p 'article-highlight 'highlight)
14405 (looking-at "\\([^:]+\\): *\\(.*\\)$"))
14406 (gnus-put-text-property (match-beginning 1) (match-end 1)
14408 (gnus-put-text-property (match-beginning 2) (match-end 2)
14409 'face eface))))))))
14411 (defun gnus-make-date-line (date type)
14412 "Return a DATE line of TYPE."
14414 ;; Convert to the local timezone. We have to slap a
14415 ;; `condition-case' round the calls to the timezone
14416 ;; functions since they aren't particularly resistant to
14419 (concat "Date: " (condition-case ()
14420 (timezone-make-date-arpa-standard date)
14423 ;; Convert to Universal Time.
14427 (timezone-make-date-arpa-standard date nil "UT")
14430 ;; Get the original date from the article.
14431 ((eq type 'original)
14432 (concat "Date: " date "\n"))
14433 ;; Do an X-Sent lapsed format.
14435 ;; If the date is seriously mangled, the timezone
14436 ;; functions are liable to bug out, so we condition-case
14437 ;; the entire thing.
14438 (let* ((now (current-time))
14443 (timezone-make-date-arpa-standard
14444 (current-time-string now)
14445 (current-time-zone now) "UT"))
14447 (timezone-make-date-arpa-standard
14450 (real-sec (+ (* (float (car real-time)) 65536)
14452 (sec (abs real-sec))
14455 ((equal real-time '(0 0))
14456 "X-Sent: Unknown\n")
14462 ;; This is a bit convoluted, but basically we go
14463 ;; through the time units for years, weeks, etc,
14464 ;; and divide things to see whether that results
14465 ;; in positive answers.
14468 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
14469 ;; The (remaining) seconds are too few to
14470 ;; be divided into this time unit.
14472 ;; It's big enough, so we output it.
14473 (setq sec (- sec (* num (cdr unit))))
14475 (concat (if prev ", " "") (int-to-string
14477 " " (symbol-name (car unit))
14478 (if (> num 1) "s" ""))
14480 gnus-article-time-units "")
14481 ;; If dates are odd, then it might appear like the
14482 ;; article was sent in the future.
14485 " in the future\n"))))))
14487 (error "Unknown conversion type: %s" type))))
14489 (defun gnus-article-date-local (&optional highlight)
14490 "Convert the current article date to the local timezone."
14491 (interactive (list t))
14492 (gnus-article-date-ut 'local highlight))
14494 (defun gnus-article-date-original (&optional highlight)
14495 "Convert the current article date to what it was originally.
14496 This is only useful if you have used some other date conversion
14497 function and want to see what the date was before converting."
14498 (interactive (list t))
14499 (gnus-article-date-ut 'original highlight))
14501 (defun gnus-article-date-lapsed (&optional highlight)
14502 "Convert the current article date to time lapsed since it was sent."
14503 (interactive (list t))
14504 (gnus-article-date-ut 'lapsed highlight))
14506 (defun gnus-article-maybe-highlight ()
14507 "Do some article highlighting if `gnus-visual' is non-nil."
14508 (if (gnus-visual-p 'article-highlight 'highlight)
14509 (gnus-article-highlight-some)))
14511 ;;; Article savers.
14513 (defun gnus-output-to-rmail (file-name)
14514 "Append the current article to an Rmail file named FILE-NAME."
14516 ;; Most of these codes are borrowed from rmailout.el.
14517 (setq file-name (expand-file-name file-name))
14518 (setq rmail-default-rmail-file file-name)
14519 (let ((artbuf (current-buffer))
14520 (tmpbuf (get-buffer-create " *Gnus-output*")))
14522 (or (get-file-buffer file-name)
14523 (file-exists-p file-name)
14524 (if (gnus-yes-or-no-p
14525 (concat "\"" file-name "\" does not exist, create it? "))
14526 (let ((file-buffer (create-file-buffer file-name)))
14528 (set-buffer file-buffer)
14529 (rmail-insert-rmail-file-header)
14530 (let ((require-final-newline nil))
14531 (write-region (point-min) (point-max) file-name t 1)))
14532 (kill-buffer file-buffer))
14533 (error "Output file does not exist")))
14534 (set-buffer tmpbuf)
14535 (buffer-disable-undo (current-buffer))
14537 (insert-buffer-substring artbuf)
14538 (gnus-convert-article-to-rmail)
14539 ;; Decide whether to append to a file or to an Emacs buffer.
14540 (let ((outbuf (get-file-buffer file-name)))
14542 (append-to-file (point-min) (point-max) file-name)
14543 ;; File has been visited, in buffer OUTBUF.
14544 (set-buffer outbuf)
14545 (let ((buffer-read-only nil)
14546 (msg (and (boundp 'rmail-current-message)
14547 (symbol-value 'rmail-current-message))))
14548 ;; If MSG is non-nil, buffer is in RMAIL mode.
14551 (narrow-to-region (point-max) (point-max))))
14552 (insert-buffer-substring tmpbuf)
14555 (goto-char (point-min))
14557 (search-backward "\^_")
14558 (narrow-to-region (point) (point-max))
14559 (goto-char (1+ (point-min)))
14560 (rmail-count-new-messages t)
14561 (rmail-show-message msg)))))))
14562 (kill-buffer tmpbuf)))
14564 (defun gnus-output-to-file (file-name)
14565 "Append the current article to a file named FILE-NAME."
14566 (let ((artbuf (current-buffer)))
14567 (nnheader-temp-write nil
14568 (insert-buffer-substring artbuf)
14569 ;; Append newline at end of the buffer as separator, and then
14570 ;; save it to file.
14571 (goto-char (point-max))
14573 (append-to-file (point-min) (point-max) file-name))))
14575 (defun gnus-convert-article-to-rmail ()
14576 "Convert article in current buffer to Rmail message format."
14577 (let ((buffer-read-only nil))
14578 ;; Convert article directly into Babyl format.
14579 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
14580 (goto-char (point-min))
14581 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
14582 (while (search-forward "\n\^_" nil t) ;single char
14583 (replace-match "\n^_" t t)) ;2 chars: "^" and "_"
14584 (goto-char (point-max))
14587 (defun gnus-narrow-to-page (&optional arg)
14588 "Narrow the article buffer to a page.
14589 If given a numerical ARG, move forward ARG pages."
14591 (setq arg (if arg (prefix-numeric-value arg) 0))
14593 (set-buffer gnus-article-buffer)
14594 (goto-char (point-min))
14596 (when (gnus-visual-p 'page-marker)
14597 (let ((buffer-read-only nil))
14598 (gnus-remove-text-with-property 'gnus-prev)
14599 (gnus-remove-text-with-property 'gnus-next)))
14602 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
14604 (re-search-forward page-delimiter nil 'move arg)))
14605 (goto-char (match-end 0)))
14608 (if (re-search-forward page-delimiter nil 'move)
14609 (match-beginning 0)
14611 (when (and (gnus-visual-p 'page-marker)
14612 (not (= (point-min) 1)))
14614 (goto-char (point-min))
14615 (gnus-insert-prev-page-button)))
14616 (when (and (gnus-visual-p 'page-marker)
14617 (not (= (1- (point-max)) (buffer-size))))
14619 (goto-char (point-max))
14620 (gnus-insert-next-page-button)))))
14622 ;; Article mode commands
14624 (defun gnus-article-goto-next-page ()
14625 "Show the next page of the article."
14627 (when (gnus-article-next-page)
14628 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
14630 (defun gnus-article-goto-prev-page ()
14631 "Show the next page of the article."
14633 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))
14634 (gnus-article-prev-page nil)))
14636 (defun gnus-article-next-page (&optional lines)
14637 "Show the next page of the current article.
14638 If end of article, return non-nil. Otherwise return nil.
14639 Argument LINES specifies lines to be scrolled up."
14641 (move-to-window-line -1)
14642 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
14643 (if (save-excursion
14645 (and (pos-visible-in-window-p) ;Not continuation line.
14647 ;; Nothing in this page.
14648 (if (or (not gnus-break-pages)
14651 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
14653 (gnus-narrow-to-page 1) ;Go to next page.
14655 ;; More in this page.
14659 ;; Long lines may cause an end-of-buffer error.
14660 (goto-char (point-max))))
14661 (move-to-window-line 0)
14664 (defun gnus-article-prev-page (&optional lines)
14665 "Show previous page of current article.
14666 Argument LINES specifies lines to be scrolled down."
14668 (move-to-window-line 0)
14669 (if (and gnus-break-pages
14671 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
14673 (gnus-narrow-to-page -1) ;Go to previous page.
14674 (goto-char (point-max))
14678 (scroll-down lines)
14680 (move-to-window-line 0))))
14682 (defun gnus-article-refer-article ()
14683 "Read article specified by message-id around point."
14685 (let ((point (point)))
14686 (search-forward ">" nil t) ;Move point to end of "<....>".
14687 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
14688 (let ((message-id (match-string 1)))
14690 (set-buffer gnus-summary-buffer)
14691 (gnus-summary-refer-article message-id))
14692 (goto-char (point))
14693 (error "No references around point"))))
14695 (defun gnus-article-show-summary ()
14696 "Reconfigure windows to show summary buffer."
14698 (gnus-configure-windows 'article)
14699 (gnus-summary-goto-subject gnus-current-article))
14701 (defun gnus-article-describe-briefly ()
14702 "Describe article mode commands briefly."
14705 (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")))
14707 (defun gnus-article-summary-command ()
14708 "Execute the last keystroke in the summary buffer."
14710 (let ((obuf (current-buffer))
14711 (owin (current-window-configuration))
14713 (switch-to-buffer gnus-summary-buffer 'norecord)
14714 (setq func (lookup-key (current-local-map) (this-command-keys)))
14715 (call-interactively func)
14717 (set-window-configuration owin)
14718 (set-window-point (get-buffer-window (current-buffer)) (point))))
14720 (defun gnus-article-summary-command-nosave ()
14721 "Execute the last keystroke in the summary buffer."
14724 (pop-to-buffer gnus-summary-buffer 'norecord)
14725 (setq func (lookup-key (current-local-map) (this-command-keys)))
14726 (call-interactively func)))
14728 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
14729 "Read a summary buffer key sequence and execute it from the article buffer."
14732 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
14733 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
14734 "=" "^" "\M-^" "|"))
14737 (set-buffer gnus-summary-buffer)
14738 (push (or key last-command-event) unread-command-events)
14739 (setq keys (read-key-sequence nil)))
14742 (if (member keys nosaves)
14744 (pop-to-buffer gnus-summary-buffer 'norecord)
14745 (if (setq func (lookup-key (current-local-map) keys))
14746 (call-interactively func)
14748 (let ((obuf (current-buffer))
14749 (owin (current-window-configuration))
14752 (if not-restore-window
14753 (pop-to-buffer gnus-summary-buffer 'norecord)
14754 (switch-to-buffer gnus-summary-buffer 'norecord))
14755 (setq in-buffer (current-buffer))
14756 (if (setq func (lookup-key (current-local-map) keys))
14757 (call-interactively func)
14759 (when (eq in-buffer (current-buffer))
14761 (unless not-restore-window
14762 (set-window-configuration owin))
14763 (set-window-point (get-buffer-window (current-buffer)) opoint))))))
14767 ;;; Kill file handling.
14771 (defalias 'gnus-batch-kill 'gnus-batch-score)
14773 (defun gnus-batch-score ()
14774 "Run batched scoring.
14775 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
14776 Newsgroups is a list of strings in Bnews format. If you want to score
14777 the comp hierarchy, you'd say \"comp.all\". If you would not like to
14778 score the alt hierarchy, you'd say \"!alt.all\"."
14781 (gnus-newsrc-parse-options
14782 (apply (function concat)
14783 (mapcar (lambda (g) (concat g " "))
14784 command-line-args-left))))
14785 (gnus-expert-user t)
14786 (nnmail-spool-file nil)
14787 (gnus-use-dribble-file nil)
14788 (yes (car yes-and-no))
14789 (no (cdr yes-and-no))
14791 ;; Disable verbose message.
14792 gnus-novice-user gnus-large-newsgroup)
14793 ;; Eat all arguments.
14794 (setq command-line-args-left nil)
14797 ;; Apply kills to specified newsgroups in command line arguments.
14798 (setq newsrc (cdr gnus-newsrc-alist))
14800 (setq group (caar newsrc))
14801 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
14802 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed)
14804 (or (eq (car entry) t)
14805 (not (zerop (car entry)))))
14806 (if yes (string-match yes group) t)
14807 (or (null no) (not (string-match no group))))
14809 (gnus-summary-read-group group nil t nil t)
14810 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
14811 (gnus-summary-exit))))
14812 (setq newsrc (cdr newsrc)))
14814 (switch-to-buffer gnus-group-buffer)
14815 (gnus-group-save-newsrc)))
14817 (defun gnus-apply-kill-file ()
14818 "Apply a kill file to the current newsgroup.
14819 Returns the number of articles marked as read."
14820 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
14821 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14822 (gnus-apply-kill-file-internal)
14825 (defun gnus-kill-save-kill-buffer ()
14826 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14827 (when (get-file-buffer file)
14829 (set-buffer (get-file-buffer file))
14830 (and (buffer-modified-p) (save-buffer))
14831 (kill-buffer (current-buffer))))))
14833 (defvar gnus-kill-file-name "KILL"
14834 "Suffix of the kill files.")
14836 (defun gnus-newsgroup-kill-file (newsgroup)
14837 "Return the name of a kill file name for NEWSGROUP.
14838 If NEWSGROUP is nil, return the global kill file name instead."
14840 ;; The global KILL file is placed at top of the directory.
14841 ((or (null newsgroup)
14842 (string-equal newsgroup ""))
14843 (expand-file-name gnus-kill-file-name
14844 gnus-kill-files-directory))
14845 ;; Append ".KILL" to newsgroup name.
14846 ((gnus-use-long-file-name 'not-kill)
14847 (expand-file-name (concat (gnus-newsgroup-savable-name newsgroup)
14848 "." gnus-kill-file-name)
14849 gnus-kill-files-directory))
14850 ;; Place "KILL" under the hierarchical directory.
14852 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
14853 "/" gnus-kill-file-name)
14854 gnus-kill-files-directory))))
14861 (defvar gnus-dribble-ignore nil)
14862 (defvar gnus-dribble-eval-file nil)
14864 (defun gnus-dribble-file-name ()
14865 "Return the dribble file for the current .newsrc."
14867 (if gnus-dribble-directory
14868 (concat (file-name-as-directory gnus-dribble-directory)
14869 (file-name-nondirectory gnus-current-startup-file))
14870 gnus-current-startup-file)
14873 (defun gnus-dribble-enter (string)
14874 "Enter STRING into the dribble buffer."
14875 (if (and (not gnus-dribble-ignore)
14876 gnus-dribble-buffer
14877 (buffer-name gnus-dribble-buffer))
14878 (let ((obuf (current-buffer)))
14879 (set-buffer gnus-dribble-buffer)
14880 (insert string "\n")
14881 (set-window-point (get-buffer-window (current-buffer)) (point-max))
14882 (set-buffer obuf))))
14884 (defun gnus-dribble-read-file ()
14885 "Read the dribble file from disk."
14886 (let ((dribble-file (gnus-dribble-file-name)))
14888 (set-buffer (setq gnus-dribble-buffer
14890 (file-name-nondirectory dribble-file))))
14891 (gnus-add-current-to-buffer-list)
14893 (setq buffer-file-name dribble-file)
14895 (buffer-disable-undo (current-buffer))
14896 (bury-buffer (current-buffer))
14897 (set-buffer-modified-p nil)
14898 (let ((auto (make-auto-save-file-name))
14899 (gnus-dribble-ignore t)
14901 (when (or (file-exists-p auto) (file-exists-p dribble-file))
14902 ;; Load whichever file is newest -- the auto save file
14903 ;; or the "real" file.
14904 (if (file-newer-than-file-p auto dribble-file)
14905 (insert-file-contents auto)
14906 (insert-file-contents dribble-file))
14907 (unless (zerop (buffer-size))
14908 (set-buffer-modified-p t))
14909 ;; Set the file modes to reflect the .newsrc file modes.
14911 (when (and (file-exists-p gnus-current-startup-file)
14912 (setq modes (file-modes gnus-current-startup-file)))
14913 (set-file-modes dribble-file modes))
14914 ;; Possibly eval the file later.
14915 (when (gnus-y-or-n-p
14916 "Auto-save file exists. Do you want to read it? ")
14917 (setq gnus-dribble-eval-file t)))))))
14919 (defun gnus-dribble-eval-file ()
14920 (when gnus-dribble-eval-file
14921 (setq gnus-dribble-eval-file nil)
14923 (let ((gnus-dribble-ignore t))
14924 (set-buffer gnus-dribble-buffer)
14925 (eval-buffer (current-buffer))))))
14927 (defun gnus-dribble-delete-file ()
14928 (when (file-exists-p (gnus-dribble-file-name))
14929 (delete-file (gnus-dribble-file-name)))
14930 (when gnus-dribble-buffer
14932 (set-buffer gnus-dribble-buffer)
14933 (let ((auto (make-auto-save-file-name)))
14934 (if (file-exists-p auto)
14935 (delete-file auto))
14937 (set-buffer-modified-p nil)))))
14939 (defun gnus-dribble-save ()
14940 (when (and gnus-dribble-buffer
14941 (buffer-name gnus-dribble-buffer))
14943 (set-buffer gnus-dribble-buffer)
14946 (defun gnus-dribble-clear ()
14947 (when (gnus-buffer-exists-p gnus-dribble-buffer)
14949 (set-buffer gnus-dribble-buffer)
14951 (set-buffer-modified-p nil)
14952 (setq buffer-saved-size (buffer-size)))))
14956 ;;; Server Communication
14959 (defun gnus-start-news-server (&optional confirm)
14960 "Open a method for getting news.
14961 If CONFIRM is non-nil, the user will be asked for an NNTP server."
14963 (if gnus-current-select-method
14964 ;; Stream is already opened.
14966 ;; Open NNTP server.
14967 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
14970 ;; Read server name with completion.
14971 (setq gnus-nntp-server
14972 (completing-read "NNTP server: "
14973 (mapcar (lambda (server) (list server))
14974 (cons (list gnus-nntp-server)
14975 gnus-secondary-servers))
14976 nil nil gnus-nntp-server))))
14978 (if (and gnus-nntp-server
14979 (stringp gnus-nntp-server)
14980 (not (string= gnus-nntp-server "")))
14981 (setq gnus-select-method
14982 (cond ((or (string= gnus-nntp-server "")
14983 (string= gnus-nntp-server "::"))
14984 (list 'nnspool (system-name)))
14985 ((string-match "^:" gnus-nntp-server)
14986 (list 'nnmh gnus-nntp-server
14987 (list 'nnmh-directory
14988 (file-name-as-directory
14990 (concat "~/" (substring
14991 gnus-nntp-server 1)))))
14992 (list 'nnmh-get-new-mail nil)))
14994 (list 'nntp gnus-nntp-server)))))
14996 (setq how (car gnus-select-method))
14997 (cond ((eq how 'nnspool)
14999 (gnus-message 5 "Looking up local news spool..."))
15002 (gnus-message 5 "Looking up mh spool..."))
15005 (setq gnus-current-select-method gnus-select-method)
15006 (run-hooks 'gnus-open-server-hook)
15008 ;; gnus-open-server-hook might have opened it
15009 (gnus-server-opened gnus-select-method)
15010 (gnus-open-server gnus-select-method)
15013 "%s (%s) open error: '%s'. Continue? "
15014 (car gnus-select-method) (cadr gnus-select-method)
15015 (gnus-status-message gnus-select-method)))
15016 (gnus-error 1 "Couldn't open server on %s"
15017 (nth 1 gnus-select-method))))))
15019 (defun gnus-check-group (group)
15020 "Try to make sure that the server where GROUP exists is alive."
15021 (let ((method (gnus-find-method-for-group group)))
15022 (or (gnus-server-opened method)
15023 (gnus-open-server method))))
15025 (defun gnus-check-server (&optional method silent)
15026 "Check whether the connection to METHOD is down.
15027 If METHOD is nil, use `gnus-select-method'.
15028 If it is down, start it up (again)."
15029 (let ((method (or method gnus-select-method)))
15030 ;; Transform virtual server names into select methods.
15031 (when (stringp method)
15032 (setq method (gnus-server-to-method method)))
15033 (if (gnus-server-opened method)
15034 ;; The stream is already opened.
15036 ;; Open the server.
15038 (gnus-message 5 "Opening %s server%s..." (car method)
15039 (if (equal (nth 1 method) "") ""
15040 (format " on %s" (nth 1 method)))))
15041 (run-hooks 'gnus-open-server-hook)
15043 (gnus-open-server method)
15047 (defun gnus-get-function (method function)
15048 "Return a function symbol based on METHOD and FUNCTION."
15049 ;; Translate server names into methods.
15051 (error "Attempted use of a nil select method"))
15052 (when (stringp method)
15053 (setq method (gnus-server-to-method method)))
15054 (let ((func (intern (format "%s-%s" (car method) function))))
15055 ;; If the functions isn't bound, we require the backend in
15057 (unless (fboundp func)
15058 (require (car method))
15059 (unless (fboundp func)
15060 ;; This backend doesn't implement this function.
15061 (error "No such function: %s" func)))
15066 ;;; Interface functions to the backends.
15069 (defun gnus-open-server (method)
15070 "Open a connection to METHOD."
15071 (when (stringp method)
15072 (setq method (gnus-server-to-method method)))
15073 (let ((elem (assoc method gnus-opened-servers)))
15074 ;; If this method was previously denied, we just return nil.
15075 (if (eq (nth 1 elem) 'denied)
15077 (gnus-message 1 "Denied server")
15079 ;; Open the server.
15081 (funcall (gnus-get-function method 'open-server)
15082 (nth 1 method) (nthcdr 2 method))))
15083 ;; If this hasn't been opened before, we add it to the list.
15085 (setq elem (list method nil)
15086 gnus-opened-servers (cons elem gnus-opened-servers)))
15087 ;; Set the status of this server.
15088 (setcar (cdr elem) (if result 'ok 'denied))
15089 ;; Return the result from the "open" call.
15092 (defun gnus-close-server (method)
15093 "Close the connection to METHOD."
15094 (when (stringp method)
15095 (setq method (gnus-server-to-method method)))
15096 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
15098 (defun gnus-request-list (method)
15099 "Request the active file from METHOD."
15100 (when (stringp method)
15101 (setq method (gnus-server-to-method method)))
15102 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
15104 (defun gnus-request-list-newsgroups (method)
15105 "Request the newsgroups file from METHOD."
15106 (when (stringp method)
15107 (setq method (gnus-server-to-method method)))
15108 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
15110 (defun gnus-request-newgroups (date method)
15111 "Request all new groups since DATE from METHOD."
15112 (when (stringp method)
15113 (setq method (gnus-server-to-method method)))
15114 (funcall (gnus-get-function method 'request-newgroups)
15115 date (nth 1 method)))
15117 (defun gnus-server-opened (method)
15118 "Check whether a connection to METHOD has been opened."
15119 (when (stringp method)
15120 (setq method (gnus-server-to-method method)))
15121 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
15123 (defun gnus-status-message (method)
15124 "Return the status message from METHOD.
15125 If METHOD is a string, it is interpreted as a group name. The method
15126 this group uses will be queried."
15127 (let ((method (if (stringp method) (gnus-find-method-for-group method)
15129 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
15131 (defun gnus-request-group (group &optional dont-check method)
15132 "Request GROUP. If DONT-CHECK, no information is required."
15133 (let ((method (or method (gnus-find-method-for-group group))))
15134 (when (stringp method)
15135 (setq method (gnus-server-to-method method)))
15136 (funcall (gnus-get-function method 'request-group)
15137 (gnus-group-real-name group) (nth 1 method) dont-check)))
15139 (defun gnus-request-asynchronous (group &optional articles)
15140 "Request that GROUP behave asynchronously.
15141 ARTICLES is the `data' of the group."
15142 (let ((method (gnus-find-method-for-group group)))
15143 (funcall (gnus-get-function method 'request-asynchronous)
15144 (gnus-group-real-name group) (nth 1 method) articles)))
15146 (defun gnus-list-active-group (group)
15147 "Request active information on GROUP."
15148 (let ((method (gnus-find-method-for-group group))
15149 (func 'list-active-group))
15150 (when (gnus-check-backend-function func group)
15151 (funcall (gnus-get-function method func)
15152 (gnus-group-real-name group) (nth 1 method)))))
15154 (defun gnus-request-group-description (group)
15155 "Request a description of GROUP."
15156 (let ((method (gnus-find-method-for-group group))
15157 (func 'request-group-description))
15158 (when (gnus-check-backend-function func group)
15159 (funcall (gnus-get-function method func)
15160 (gnus-group-real-name group) (nth 1 method)))))
15162 (defun gnus-close-group (group)
15163 "Request the GROUP be closed."
15164 (let ((method (gnus-find-method-for-group group)))
15165 (funcall (gnus-get-function method 'close-group)
15166 (gnus-group-real-name group) (nth 1 method))))
15168 (defun gnus-retrieve-headers (articles group &optional fetch-old)
15169 "Request headers for ARTICLES in GROUP.
15170 If FETCH-OLD, retrieve all headers (or some subset thereof) in the group."
15171 (let ((method (gnus-find-method-for-group group)))
15172 (if (and gnus-use-cache (numberp (car articles)))
15173 (gnus-cache-retrieve-headers articles group fetch-old)
15174 (funcall (gnus-get-function method 'retrieve-headers)
15175 articles (gnus-group-real-name group) (nth 1 method)
15178 (defun gnus-retrieve-groups (groups method)
15179 "Request active information on GROUPS from METHOD."
15180 (when (stringp method)
15181 (setq method (gnus-server-to-method method)))
15182 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method)))
15184 (defun gnus-request-type (group &optional article)
15185 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
15186 (let ((method (gnus-find-method-for-group group)))
15187 (if (not (gnus-check-backend-function 'request-type (car method)))
15189 (funcall (gnus-get-function method 'request-type)
15190 (gnus-group-real-name group) article))))
15192 (defun gnus-request-update-mark (group article mark)
15193 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
15194 (let ((method (gnus-find-method-for-group group)))
15195 (if (not (gnus-check-backend-function 'request-update-mark (car method)))
15197 (funcall (gnus-get-function method 'request-update-mark)
15198 (gnus-group-real-name group) article mark))))
15200 (defun gnus-request-article (article group &optional buffer)
15201 "Request the ARTICLE in GROUP.
15202 ARTICLE can either be an article number or an article Message-ID.
15203 If BUFFER, insert the article in that group."
15204 (let ((method (gnus-find-method-for-group group)))
15205 (funcall (gnus-get-function method 'request-article)
15206 article (gnus-group-real-name group) (nth 1 method) buffer)))
15208 (defun gnus-request-head (article group)
15209 "Request the head of ARTICLE in GROUP."
15210 (let ((method (gnus-find-method-for-group group)))
15211 (funcall (gnus-get-function method 'request-head)
15212 article (gnus-group-real-name group) (nth 1 method))))
15214 (defun gnus-request-body (article group)
15215 "Request the body of ARTICLE in GROUP."
15216 (let ((method (gnus-find-method-for-group group)))
15217 (funcall (gnus-get-function method 'request-body)
15218 article (gnus-group-real-name group) (nth 1 method))))
15220 (defun gnus-request-post (method)
15221 "Post the current buffer using METHOD."
15222 (when (stringp method)
15223 (setq method (gnus-server-to-method method)))
15224 (funcall (gnus-get-function method 'request-post) (nth 1 method)))
15226 (defun gnus-request-scan (group method)
15227 "Request a SCAN being performed in GROUP from METHOD.
15228 If GROUP is nil, all groups on METHOD are scanned."
15229 (let ((method (if group (gnus-find-method-for-group group) method)))
15230 (funcall (gnus-get-function method 'request-scan)
15231 (and group (gnus-group-real-name group)) (nth 1 method))))
15233 (defsubst gnus-request-update-info (info method)
15234 "Request that METHOD update INFO."
15235 (when (stringp method)
15236 (setq method (gnus-server-to-method method)))
15237 (when (gnus-check-backend-function 'request-update-info (car method))
15238 (funcall (gnus-get-function method 'request-update-info)
15239 (gnus-group-real-name (gnus-info-group info))
15240 info (nth 1 method))))
15242 (defun gnus-request-expire-articles (articles group &optional force)
15243 (let ((method (gnus-find-method-for-group group)))
15244 (funcall (gnus-get-function method 'request-expire-articles)
15245 articles (gnus-group-real-name group) (nth 1 method)
15248 (defun gnus-request-move-article
15249 (article group server accept-function &optional last)
15250 (let ((method (gnus-find-method-for-group group)))
15251 (funcall (gnus-get-function method 'request-move-article)
15252 article (gnus-group-real-name group)
15253 (nth 1 method) accept-function last)))
15255 (defun gnus-request-accept-article (group method &optional last)
15256 ;; Make sure there's a newline at the end of the article.
15257 (when (stringp method)
15258 (setq method (gnus-server-to-method method)))
15259 (when (and (not method)
15261 (setq method (gnus-find-method-for-group group)))
15262 (goto-char (point-max))
15265 (let ((func (car (or method (gnus-find-method-for-group group)))))
15266 (funcall (intern (format "%s-request-accept-article" func))
15267 (if (stringp group) (gnus-group-real-name group) group)
15271 (defun gnus-request-replace-article (article group buffer)
15272 (let ((func (car (gnus-find-method-for-group group))))
15273 (funcall (intern (format "%s-request-replace-article" func))
15274 article (gnus-group-real-name group) buffer)))
15276 (defun gnus-request-associate-buffer (group)
15277 (let ((method (gnus-find-method-for-group group)))
15278 (funcall (gnus-get-function method 'request-associate-buffer)
15279 (gnus-group-real-name group))))
15281 (defun gnus-request-restore-buffer (article group)
15282 "Request a new buffer restored to the state of ARTICLE."
15283 (let ((method (gnus-find-method-for-group group)))
15284 (funcall (gnus-get-function method 'request-restore-buffer)
15285 article (gnus-group-real-name group) (nth 1 method))))
15287 (defun gnus-request-create-group (group &optional method)
15288 (when (stringp method)
15289 (setq method (gnus-server-to-method method)))
15290 (let ((method (or method (gnus-find-method-for-group group))))
15291 (funcall (gnus-get-function method 'request-create-group)
15292 (gnus-group-real-name group) (nth 1 method))))
15294 (defun gnus-request-delete-group (group &optional force)
15295 (let ((method (gnus-find-method-for-group group)))
15296 (funcall (gnus-get-function method 'request-delete-group)
15297 (gnus-group-real-name group) force (nth 1 method))))
15299 (defun gnus-request-rename-group (group new-name)
15300 (let ((method (gnus-find-method-for-group group)))
15301 (funcall (gnus-get-function method 'request-rename-group)
15302 (gnus-group-real-name group)
15303 (gnus-group-real-name new-name) (nth 1 method))))
15305 (defun gnus-member-of-valid (symbol group)
15306 "Find out if GROUP has SYMBOL as part of its \"valid\" spec."
15307 (memq symbol (assoc
15308 (symbol-name (car (gnus-find-method-for-group group)))
15309 gnus-valid-select-methods)))
15311 (defun gnus-method-option-p (method option)
15312 "Return non-nil if select METHOD has OPTION as a parameter."
15313 (when (stringp method)
15314 (setq method (gnus-server-to-method method)))
15315 (memq option (assoc (format "%s" (car method))
15316 gnus-valid-select-methods)))
15318 (defun gnus-server-extend-method (group method)
15319 ;; This function "extends" a virtual server. If the server is
15320 ;; "hello", and the select method is ("hello" (my-var "something"))
15321 ;; in the group "alt.alt", this will result in a new virtual server
15322 ;; called "hello+alt.alt".
15324 (gnus-copy-sequence
15325 (if (equal (car method) "native") gnus-select-method
15326 (cdr (assoc (car method) gnus-server-alist))))))
15327 (setcar (cdr entry) (concat (nth 1 entry) "+" group))
15328 (nconc entry (cdr method))))
15330 (defun gnus-find-method-for-group (group &optional info)
15331 "Find the select method that GROUP uses."
15332 (or gnus-override-method
15334 gnus-select-method)
15335 (let ((info (or info (gnus-get-info group)))
15338 (not (setq method (gnus-info-method info)))
15339 (equal method "native"))
15342 (cond ((stringp method)
15343 (gnus-server-to-method method))
15344 ((stringp (car method))
15345 (gnus-server-extend-method group method))
15348 (cond ((equal (cadr method) "")
15350 ((null (cadr method))
15351 (list (car method) ""))
15353 (gnus-server-add-address method)))))))
15355 (defun gnus-check-backend-function (func group)
15356 "Check whether GROUP supports function FUNC."
15357 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
15359 (fboundp (intern (format "%s-%s" method func)))))
15361 (defun gnus-methods-using (feature)
15362 "Find all methods that have FEATURE."
15363 (let ((valids gnus-valid-select-methods)
15366 (if (memq feature (car valids))
15367 (setq outs (cons (car valids) outs)))
15368 (setq valids (cdr valids)))
15373 ;;; Active & Newsrc File Handling
15376 (defun gnus-setup-news (&optional rawfile level dont-connect)
15377 "Setup news information.
15378 If RAWFILE is non-nil, the .newsrc file will also be read.
15379 If LEVEL is non-nil, the news will be set up at level LEVEL."
15380 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile)))))
15383 ;; Clear some variables to re-initialize news information.
15384 (setq gnus-newsrc-alist nil
15385 gnus-active-hashtb nil)
15386 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
15387 (gnus-read-newsrc-file rawfile))
15389 (when (and (not (assoc "archive" gnus-server-alist))
15390 gnus-message-archive-method)
15391 (push (cons "archive" gnus-message-archive-method)
15392 gnus-server-alist))
15394 ;; If we don't read the complete active file, we fill in the
15396 (if (or (null gnus-read-active-file)
15397 (eq gnus-read-active-file 'some))
15398 (gnus-update-active-hashtb-from-killed))
15400 ;; Read the active file and create `gnus-active-hashtb'.
15401 ;; If `gnus-read-active-file' is nil, then we just create an empty
15402 ;; hash table. The partial filling out of the hash table will be
15403 ;; done in `gnus-get-unread-articles'.
15404 (and gnus-read-active-file
15406 (gnus-read-active-file))
15408 (or gnus-active-hashtb
15409 (setq gnus-active-hashtb (make-vector 4095 0)))
15411 ;; Initialize the cache.
15412 (when gnus-use-cache
15415 ;; Possibly eval the dribble file.
15416 (and init (or gnus-use-dribble-file gnus-slave) (gnus-dribble-eval-file))
15418 ;; Slave Gnusii should then clear the dribble buffer.
15419 (when (and init gnus-slave)
15420 (gnus-dribble-clear))
15422 (gnus-update-format-specifications)
15424 ;; See whether we need to read the description file.
15425 (if (and (string-match "%[-,0-9]*D" gnus-group-line-format)
15426 (not gnus-description-hashtb)
15428 gnus-read-active-file)
15429 (gnus-read-all-descriptions-files))
15431 ;; Find new newsgroups and treat them.
15432 (if (and init gnus-check-new-newsgroups (not level)
15433 (gnus-check-server gnus-select-method))
15434 (gnus-find-new-newsgroups))
15436 ;; We might read in new NoCeM messages here.
15437 (when (and gnus-use-nocem
15439 (not dont-connect))
15440 (gnus-nocem-scan-groups))
15442 ;; Find the number of unread articles in each non-dead group.
15443 (let ((gnus-read-active-file (and (not level) gnus-read-active-file)))
15444 (gnus-get-unread-articles level))
15446 (if (and init gnus-check-bogus-newsgroups
15447 gnus-read-active-file (not level)
15448 (gnus-server-opened gnus-select-method))
15449 (gnus-check-bogus-newsgroups))))
15451 (defun gnus-find-new-newsgroups (&optional arg)
15452 "Search for new newsgroups and add them.
15453 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
15454 The `-n' option line from .newsrc is respected.
15455 If ARG (the prefix), use the `ask-server' method to query
15456 the server for new groups."
15458 (let ((check (if (or (and arg (not (listp gnus-check-new-newsgroups)))
15459 (null gnus-read-active-file)
15460 (eq gnus-read-active-file 'some))
15461 'ask-server gnus-check-new-newsgroups)))
15462 (unless (gnus-check-first-time-used)
15463 (if (or (consp check)
15464 (eq check 'ask-server))
15465 ;; Ask the server for new groups.
15466 (gnus-ask-server-for-new-groups)
15467 ;; Go through the active hashtb and look for new groups.
15469 group new-newsgroups)
15470 (gnus-message 5 "Looking for new newsgroups...")
15471 (unless gnus-have-read-active-file
15472 (gnus-read-active-file))
15473 (setq gnus-newsrc-last-checked-date (current-time-string))
15474 (unless gnus-killed-hashtb
15475 (gnus-make-hashtable-from-killed))
15476 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
15477 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
15480 (if (or (null (setq group (symbol-name sym)))
15482 (null (symbol-value sym))
15483 (gnus-gethash group gnus-killed-hashtb)
15484 (gnus-gethash group gnus-newsrc-hashtb))
15486 (let ((do-sub (gnus-matches-options-n group)))
15488 ((eq do-sub 'subscribe)
15489 (setq groups (1+ groups))
15490 (gnus-sethash group group gnus-killed-hashtb)
15491 (funcall gnus-subscribe-options-newsgroup-method group))
15492 ((eq do-sub 'ignore)
15495 (setq groups (1+ groups))
15496 (gnus-sethash group group gnus-killed-hashtb)
15497 (if gnus-subscribe-hierarchical-interactive
15498 (setq new-newsgroups (cons group new-newsgroups))
15499 (funcall gnus-subscribe-newsgroup-method group)))))))
15500 gnus-active-hashtb)
15501 (when new-newsgroups
15502 (gnus-subscribe-hierarchical-interactive new-newsgroups))
15503 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
15505 (gnus-message 6 "%d new newsgroup%s arrived."
15506 groups (if (> groups 1) "s have" " has"))
15507 (gnus-message 6 "No new newsgroups.")))))))
15509 (defun gnus-matches-options-n (group)
15510 ;; Returns `subscribe' if the group is to be unconditionally
15511 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
15512 ;; no match for the group.
15514 ;; First we check the two user variables.
15516 ((and gnus-options-subscribe
15517 (string-match gnus-options-subscribe group))
15519 ((and gnus-auto-subscribed-groups
15520 (string-match gnus-auto-subscribed-groups group))
15522 ((and gnus-options-not-subscribe
15523 (string-match gnus-options-not-subscribe group))
15525 ;; Then we go through the list that was retrieved from the .newsrc
15526 ;; file. This list has elements on the form
15527 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
15528 ;; is in the reverse order of the options line) is returned.
15530 (let ((regs gnus-newsrc-options-n))
15532 (not (string-match (caar regs) group)))
15533 (setq regs (cdr regs)))
15534 (and regs (cdar regs))))))
15536 (defun gnus-ask-server-for-new-groups ()
15537 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
15538 (methods (cons gnus-select-method
15540 (when gnus-message-archive-method
15543 (and (consp gnus-check-new-newsgroups)
15544 gnus-check-new-newsgroups)
15545 gnus-secondary-select-methods))))
15547 (new-date (current-time-string))
15548 group new-newsgroups got-new method hashtb
15549 gnus-override-subscribe-method)
15550 ;; Go through both primary and secondary select methods and
15551 ;; request new newsgroups.
15552 (while (setq method (gnus-server-get-method nil (pop methods)))
15553 (setq new-newsgroups nil)
15554 (setq gnus-override-subscribe-method method)
15555 (when (and (gnus-check-server method)
15556 (gnus-request-newgroups date method))
15559 (setq hashtb (gnus-make-hashtable 100))
15560 (set-buffer nntp-server-buffer)
15561 ;; Enter all the new groups into a hashtable.
15562 (gnus-active-to-gnus-format method hashtb 'ignore))
15563 ;; Now all new groups from `method' are in `hashtb'.
15565 (lambda (group-sym)
15566 (if (or (null (setq group (symbol-name group-sym)))
15567 (not (boundp group-sym))
15568 (null (symbol-value group-sym))
15569 (gnus-gethash group gnus-newsrc-hashtb)
15570 (member group gnus-zombie-list)
15571 (member group gnus-killed-list))
15572 ;; The group is already known.
15574 ;; Make this group active.
15575 (when (symbol-value group-sym)
15576 (gnus-set-active group (symbol-value group-sym)))
15577 ;; Check whether we want it or not.
15578 (let ((do-sub (gnus-matches-options-n group)))
15580 ((eq do-sub 'subscribe)
15582 (gnus-sethash group group gnus-killed-hashtb)
15583 (funcall gnus-subscribe-options-newsgroup-method group))
15584 ((eq do-sub 'ignore)
15588 (gnus-sethash group group gnus-killed-hashtb)
15589 (if gnus-subscribe-hierarchical-interactive
15590 (push group new-newsgroups)
15591 (funcall gnus-subscribe-newsgroup-method group)))))))
15593 (when new-newsgroups
15594 (gnus-subscribe-hierarchical-interactive new-newsgroups)))
15595 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
15597 (gnus-message 6 "%d new newsgroup%s arrived."
15598 groups (if (> groups 1) "s have" " has")))
15599 (and got-new (setq gnus-newsrc-last-checked-date new-date))
15602 (defun gnus-check-first-time-used ()
15603 (if (or (> (length gnus-newsrc-alist) 1)
15604 (file-exists-p gnus-startup-file)
15605 (file-exists-p (concat gnus-startup-file ".el"))
15606 (file-exists-p (concat gnus-startup-file ".eld")))
15608 (gnus-message 6 "First time user; subscribing you to default groups")
15609 (unless (gnus-read-active-file-p)
15610 (gnus-read-active-file))
15611 (setq gnus-newsrc-last-checked-date (current-time-string))
15612 (let ((groups gnus-default-subscribed-newsgroups)
15616 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
15619 (if (null (setq group (symbol-name sym)))
15621 (let ((do-sub (gnus-matches-options-n group)))
15623 ((eq do-sub 'subscribe)
15624 (gnus-sethash group group gnus-killed-hashtb)
15625 (funcall gnus-subscribe-options-newsgroup-method group))
15626 ((eq do-sub 'ignore)
15629 (setq gnus-killed-list (cons group gnus-killed-list)))))))
15630 gnus-active-hashtb)
15632 (if (gnus-active (car groups))
15633 (gnus-group-change-level
15634 (car groups) gnus-level-default-subscribed gnus-level-killed))
15635 (setq groups (cdr groups)))
15636 (gnus-group-make-help-group)
15637 (and gnus-novice-user
15638 (gnus-message 7 "`A k' to list killed groups"))))))
15640 (defun gnus-subscribe-group (group previous &optional method)
15641 (gnus-group-change-level
15643 (list t group gnus-level-default-subscribed nil nil method)
15645 gnus-level-default-subscribed gnus-level-killed previous t))
15647 ;; `gnus-group-change-level' is the fundamental function for changing
15648 ;; subscription levels of newsgroups. This might mean just changing
15649 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
15650 ;; again, which subscribes/unsubscribes a group, which is equally
15651 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
15652 ;; from 8-9 to 1-7 means that you remove the group from the list of
15653 ;; killed (or zombie) groups and add them to the (kinda) subscribed
15654 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
15655 ;; which is trivial.
15656 ;; ENTRY can either be a string (newsgroup name) or a list (if
15657 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
15658 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
15660 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
15661 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
15663 (defun gnus-group-change-level (entry level &optional oldlevel
15664 previous fromkilled)
15665 (let (group info active num)
15666 ;; Glean what info we can from the arguments
15668 (if fromkilled (setq group (nth 1 entry))
15669 (setq group (car (nth 2 entry))))
15670 (setq group entry))
15671 (if (and (stringp entry)
15673 (< oldlevel gnus-level-zombie))
15674 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
15675 (if (and (not oldlevel)
15677 (setq oldlevel (gnus-info-level (nth 2 entry)))
15678 (setq oldlevel (or oldlevel 9)))
15679 (if (stringp previous)
15680 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
15682 (if (and (>= oldlevel gnus-level-zombie)
15683 (gnus-gethash group gnus-newsrc-hashtb))
15684 ;; We are trying to subscribe a group that is already
15688 (or (gnus-ephemeral-group-p group)
15689 (gnus-dribble-enter
15690 (format "(gnus-group-change-level %S %S %S %S %S)"
15691 group level oldlevel (car (nth 2 previous)) fromkilled)))
15693 ;; Then we remove the newgroup from any old structures, if needed.
15694 ;; If the group was killed, we remove it from the killed or zombie
15695 ;; list. If not, and it is in fact going to be killed, we remove
15696 ;; it from the newsrc hash table and assoc.
15698 ((>= oldlevel gnus-level-zombie)
15699 (if (= oldlevel gnus-level-zombie)
15700 (setq gnus-zombie-list (delete group gnus-zombie-list))
15701 (setq gnus-killed-list (delete group gnus-killed-list))))
15703 (if (and (>= level gnus-level-zombie)
15706 (gnus-sethash (car (nth 2 entry)) nil gnus-newsrc-hashtb)
15708 (setcdr (gnus-gethash (car (nth 3 entry))
15709 gnus-newsrc-hashtb)
15711 (setcdr (cdr entry) (cdddr entry))))))
15713 ;; Finally we enter (if needed) the list where it is supposed to
15714 ;; go, and change the subscription level. If it is to be killed,
15715 ;; we enter it into the killed or zombie list.
15717 ((>= level gnus-level-zombie)
15718 ;; Remove from the hash table.
15719 (gnus-sethash group nil gnus-newsrc-hashtb)
15720 ;; We do not enter foreign groups into the list of dead
15722 (unless (gnus-group-foreign-p group)
15723 (if (= level gnus-level-zombie)
15724 (setq gnus-zombie-list (cons group gnus-zombie-list))
15725 (setq gnus-killed-list (cons group gnus-killed-list)))))
15727 ;; If the list is to be entered into the newsrc assoc, and
15728 ;; it was killed, we have to create an entry in the newsrc
15729 ;; hashtb format and fix the pointers in the newsrc assoc.
15730 (if (< oldlevel gnus-level-zombie)
15731 ;; It was alive, and it is going to stay alive, so we
15732 ;; just change the level and don't change any pointers or
15733 ;; hash table entries.
15734 (setcar (cdaddr entry) level)
15736 (setq info (cdr entry)
15738 (setq active (gnus-active group))
15740 (if active (- (1+ (cdr active)) (car active)) t))
15741 ;; Check whether the group is foreign. If so, the
15742 ;; foreign select method has to be entered into the
15744 (let ((method (or gnus-override-subscribe-method
15745 (gnus-group-method group))))
15746 (if (eq method gnus-select-method)
15747 (setq info (list group level nil))
15748 (setq info (list group level nil nil method)))))
15751 (let ((p gnus-newsrc-alist))
15755 (setq entry (cons info (cddr previous)))
15758 (setcdr (cdr previous) entry)
15759 (gnus-sethash group (cons num (cdr previous))
15760 gnus-newsrc-hashtb))
15761 (setcdr previous entry)
15762 (gnus-sethash group (cons num previous)
15763 gnus-newsrc-hashtb))
15765 (setcdr (gnus-gethash (caadr entry) gnus-newsrc-hashtb) entry)))))
15766 (when gnus-group-change-level-function
15767 (funcall gnus-group-change-level-function group level oldlevel)))))
15769 (defun gnus-kill-newsgroup (newsgroup)
15770 "Obsolete function. Kills a newsgroup."
15771 (gnus-group-change-level
15772 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed))
15774 (defun gnus-check-bogus-newsgroups (&optional confirm)
15775 "Remove bogus newsgroups.
15776 If CONFIRM is non-nil, the user has to confirm the deletion of every
15778 (let ((newsrc (cdr gnus-newsrc-alist))
15779 bogus group entry info)
15780 (gnus-message 5 "Checking bogus newsgroups...")
15781 (unless (gnus-read-active-file-p)
15782 (gnus-read-active-file))
15783 (when (gnus-read-active-file-p)
15784 ;; Find all bogus newsgroup that are subscribed.
15786 (setq info (pop newsrc)
15787 group (gnus-info-group info))
15788 (unless (or (gnus-active group) ; Active
15789 (gnus-info-method info) ; Foreign
15791 (not (gnus-y-or-n-p
15792 (format "Remove bogus newsgroup: %s " group)))))
15793 ;; Found a bogus newsgroup.
15794 (push group bogus)))
15795 ;; Remove all bogus subscribed groups by first killing them, and
15796 ;; then removing them from the list of killed groups.
15798 (when (setq entry (gnus-gethash (setq group (pop bogus))
15799 gnus-newsrc-hashtb))
15800 (gnus-group-change-level entry gnus-level-killed)
15801 (setq gnus-killed-list (delete group gnus-killed-list))))
15802 ;; Then we remove all bogus groups from the list of killed and
15803 ;; zombie groups. They are are removed without confirmation.
15804 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
15807 (setq killed (symbol-value (car dead-lists)))
15809 (unless (gnus-active (setq group (pop killed)))
15810 ;; The group is bogus.
15811 ;; !!!Slow as hell.
15812 (set (car dead-lists)
15813 (delete group (symbol-value (car dead-lists))))))
15814 (setq dead-lists (cdr dead-lists))))
15815 (gnus-message 5 "Checking bogus newsgroups...done"))))
15817 (defun gnus-check-duplicate-killed-groups ()
15818 "Remove duplicates from the list of killed groups."
15820 (let ((killed gnus-killed-list))
15822 (gnus-message 9 "%d" (length killed))
15823 (setcdr killed (delete (car killed) (cdr killed)))
15824 (setq killed (cdr killed)))))
15826 ;; We want to inline a function from gnus-cache, so we cheat here:
15829 (require 'gnus-cache))
15831 (defun gnus-get-unread-articles-in-group (info active &optional update)
15833 ;; Allow the backend to update the info in the group.
15835 (gnus-request-update-info
15836 info (gnus-find-method-for-group (gnus-info-group info))))
15837 (gnus-activate-group (gnus-info-group info) nil t))
15838 (let* ((range (gnus-info-read info))
15840 ;; If a cache is present, we may have to alter the active info.
15841 (when (and gnus-use-cache info)
15842 (inline (gnus-cache-possibly-alter-active
15843 (gnus-info-group info) active)))
15844 ;; Modify the list of read articles according to what articles
15845 ;; are available; then tally the unread articles and add the
15846 ;; number to the group hash table entry.
15848 ((zerop (cdr active))
15851 (setq num (- (1+ (cdr active)) (car active))))
15852 ((not (listp (cdr range)))
15853 ;; Fix a single (num . num) range according to the
15854 ;; active hash table.
15855 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
15856 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
15857 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
15858 ;; Compute number of unread articles.
15859 (setq num (max 0 (- (cdr active) (- (1+ (cdr range)) (car range))))))
15861 ;; The read list is a list of ranges. Fix them according to
15862 ;; the active hash table.
15863 ;; First peel off any elements that are below the lower
15865 (while (and (cdr range)
15867 (or (and (atom (cadr range)) (cadr range))
15869 (if (numberp (car range))
15872 (or (and (numberp (cadr range))
15875 (setcdr (car range)
15876 (or (and (numberp (nth 1 range)) (nth 1 range))
15878 (setcdr range (cddr range)))
15879 ;; Adjust the first element to be the same as the lower limit.
15880 (if (and (not (atom (car range)))
15881 (< (cdar range) (car active)))
15882 (setcdr (car range) (1- (car active))))
15883 ;; Then we want to peel off any elements that are higher
15884 ;; than the upper active limit.
15885 (let ((srange range))
15886 ;; Go past all legal elements.
15887 (while (and (cdr srange)
15888 (<= (or (and (atom (cadr srange))
15890 (caadr srange)) (cdr active)))
15891 (setq srange (cdr srange)))
15893 ;; Nuke all remaining illegal elements.
15894 (setcdr srange nil))
15896 ;; Adjust the final element.
15897 (if (and (not (atom (car srange)))
15898 (> (cdar srange) (cdr active)))
15899 (setcdr (car srange) (cdr active))))
15900 ;; Compute the number of unread articles.
15902 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
15904 (or (and (atom (car range)) (car range))
15906 (setq range (cdr range)))
15907 (setq num (max 0 (- (cdr active) num)))))
15908 ;; Set the number of unread articles.
15910 (setcar (gnus-gethash (gnus-info-group info) gnus-newsrc-hashtb) num))
15913 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
15914 ;; and compute how many unread articles there are in each group.
15915 (defun gnus-get-unread-articles (&optional level)
15916 (let* ((newsrc (cdr gnus-newsrc-alist))
15917 (level (or level gnus-activate-level (1+ gnus-level-subscribed)))
15920 (cond ((and gnus-activate-foreign-newsgroups
15921 (not (numberp gnus-activate-foreign-newsgroups)))
15922 (1+ gnus-level-subscribed))
15923 ((numberp gnus-activate-foreign-newsgroups)
15924 gnus-activate-foreign-newsgroups)
15927 info group active method)
15928 (gnus-message 5 "Checking new news...")
15931 (setq active (gnus-active (setq group (gnus-info-group
15932 (setq info (pop newsrc))))))
15934 ;; Check newsgroups. If the user doesn't want to check them, or
15935 ;; they can't be checked (for instance, if the news server can't
15936 ;; be reached) we just set the number of unread articles in this
15937 ;; newsgroup to t. This means that Gnus thinks that there are
15938 ;; unread articles, but it has no idea how many.
15939 (if (and (setq method (gnus-info-method info))
15940 (not (gnus-server-equal
15942 (setq method (gnus-server-get-method nil method))))
15943 (not (gnus-secondary-method-p method)))
15944 ;; These groups are foreign. Check the level.
15945 (when (<= (gnus-info-level info) foreign-level)
15946 (setq active (gnus-activate-group group 'scan))
15947 (unless (inline (gnus-virtual-group-p group))
15948 (inline (gnus-close-group group)))
15949 (when (fboundp (intern (concat (symbol-name (car method))
15950 "-request-update-info")))
15951 (inline (gnus-request-update-info info method))))
15952 ;; These groups are native or secondary.
15953 (when (and (<= (gnus-info-level info) level)
15954 (not gnus-read-active-file))
15955 (setq active (gnus-activate-group group 'scan))
15956 (inline (gnus-close-group group))))
15958 ;; Get the number of unread articles in the group.
15960 (inline (gnus-get-unread-articles-in-group info active))
15961 ;; The group couldn't be reached, so we nix out the number of
15962 ;; unread articles and stuff.
15963 (gnus-set-active group nil)
15964 (setcar (gnus-gethash group gnus-newsrc-hashtb) t)))
15966 (gnus-message 5 "Checking new news...done")))
15968 ;; Create a hash table out of the newsrc alist. The `car's of the
15969 ;; alist elements are used as keys.
15970 (defun gnus-make-hashtable-from-newsrc-alist ()
15971 (let ((alist gnus-newsrc-alist)
15972 (ohashtb gnus-newsrc-hashtb)
15974 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
15976 (setq prev (setq gnus-newsrc-alist
15977 (if (equal (caar gnus-newsrc-alist)
15980 (cons (list "dummy.group" 0 nil) alist)))))
15984 (cons (and ohashtb (car (gnus-gethash (caar alist) ohashtb)))
15986 gnus-newsrc-hashtb)
15988 alist (cdr alist)))))
15990 (defun gnus-make-hashtable-from-killed ()
15991 "Create a hash table from the killed and zombie lists."
15992 (let ((lists '(gnus-killed-list gnus-zombie-list))
15994 (setq gnus-killed-hashtb
15995 (gnus-make-hashtable
15996 (+ (length gnus-killed-list) (length gnus-zombie-list))))
15997 (while (setq list (pop lists))
15998 (setq list (symbol-value list))
16000 (gnus-sethash (car list) (pop list) gnus-killed-hashtb)))))
16002 (defun gnus-activate-group (group &optional scan dont-check)
16003 ;; Check whether a group has been activated or not.
16004 ;; If SCAN, request a scan of that group as well.
16005 (let ((method (gnus-find-method-for-group group))
16007 (and (gnus-check-server method)
16008 ;; We escape all bugs and quit here to make it possible to
16009 ;; continue if a group is so out-there that it reports bugs
16013 (gnus-check-backend-function 'request-scan (car method))
16014 (gnus-request-scan group method))
16017 (gnus-request-group group dont-check)
16021 (set-buffer nntp-server-buffer)
16022 (goto-char (point-min))
16023 ;; Parse the result we got from `gnus-request-group'.
16024 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
16026 (goto-char (match-beginning 1))
16028 group (setq active (cons (read (current-buffer))
16029 (read (current-buffer)))))
16030 ;; Return the new active info.
16033 (defun gnus-update-read-articles (group unread)
16034 "Update the list of read and ticked articles in GROUP using the
16035 UNREAD and TICKED lists.
16036 Note: UNSELECTED has to be sorted over `<'.
16037 Returns whether the updating was successful."
16038 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
16039 (entry (gnus-gethash group gnus-newsrc-hashtb))
16040 (info (nth 2 entry))
16042 (unread (sort (copy-sequence unread) '<))
16044 (if (or (not info) (not active))
16045 ;; There is no info on this group if it was, in fact,
16046 ;; killed. Gnus stores no information on killed groups, so
16047 ;; there's nothing to be done.
16048 ;; One could store the information somewhere temporarily,
16049 ;; perhaps... Hmmm...
16051 ;; Remove any negative articles numbers.
16052 (while (and unread (< (car unread) 0))
16053 (setq unread (cdr unread)))
16054 ;; Remove any expired article numbers
16055 (while (and unread (< (car unread) (car active)))
16056 (setq unread (cdr unread)))
16057 ;; Compute the ranges of read articles by looking at the list of
16058 ;; unread articles.
16060 (if (/= (car unread) prev)
16061 (setq read (cons (if (= prev (1- (car unread))) prev
16062 (cons prev (1- (car unread)))) read)))
16063 (setq prev (1+ (car unread)))
16064 (setq unread (cdr unread)))
16065 (when (<= prev (cdr active))
16066 (setq read (cons (cons prev (cdr active)) read)))
16067 ;; Enter this list into the group info.
16068 (gnus-info-set-read
16069 info (if (> (length read) 1) (nreverse read) read))
16070 ;; Set the number of unread articles in gnus-newsrc-hashtb.
16071 (gnus-get-unread-articles-in-group info (gnus-active group))
16074 (defun gnus-make-articles-unread (group articles)
16075 "Mark ARTICLES in GROUP as unread."
16076 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
16077 (gnus-gethash (gnus-group-real-name group)
16078 gnus-newsrc-hashtb))))
16079 (ranges (gnus-info-read info))
16082 (when (gnus-member-of-range
16083 (setq article (pop articles)) ranges)
16084 (setq news (cons article news))))
16086 (gnus-info-set-read
16087 info (gnus-remove-from-range (gnus-info-read info) (nreverse news)))
16088 (gnus-group-update-group group t))))
16090 ;; Enter all dead groups into the hashtb.
16091 (defun gnus-update-active-hashtb-from-killed ()
16092 (let ((hashtb (setq gnus-active-hashtb (make-vector 4095 0)))
16093 (lists (list gnus-killed-list gnus-zombie-list))
16096 (setq killed (car lists))
16098 (gnus-sethash (car killed) nil hashtb)
16099 (setq killed (cdr killed)))
16100 (setq lists (cdr lists)))))
16102 (defun gnus-get-killed-groups ()
16103 "Go through the active hashtb and all all unknown groups as killed."
16104 ;; First make sure active file has been read.
16105 (unless (gnus-read-active-file-p)
16106 (let ((gnus-read-active-file t))
16107 (gnus-read-active-file)))
16108 (or gnus-killed-hashtb (gnus-make-hashtable-from-killed))
16109 ;; Go through all newsgroups that are known to Gnus - enlarge kill list.
16113 (group (symbol-name sym)))
16114 (if (or (null group)
16115 (gnus-gethash group gnus-killed-hashtb)
16116 (gnus-gethash group gnus-newsrc-hashtb))
16118 (let ((do-sub (gnus-matches-options-n group)))
16119 (if (or (eq do-sub 'subscribe) (eq do-sub 'ignore))
16121 (setq groups (1+ groups))
16122 (setq gnus-killed-list
16123 (cons group gnus-killed-list))
16124 (gnus-sethash group group gnus-killed-hashtb))))))
16125 gnus-active-hashtb))
16127 ;; Get the active file(s) from the backend(s).
16128 (defun gnus-read-active-file ()
16129 (gnus-group-set-mode-line)
16132 (if (gnus-check-server gnus-select-method)
16133 ;; The native server is available.
16134 (cons gnus-select-method gnus-secondary-select-methods)
16135 ;; The native server is down, so we just do the
16137 gnus-secondary-select-methods)
16138 ;; Also read from the archive server.
16139 (when gnus-message-archive-method
16140 (list "archive"))))
16142 (setq gnus-have-read-active-file nil)
16144 (set-buffer nntp-server-buffer)
16146 (let* ((method (if (stringp (car methods))
16147 (gnus-server-get-method nil (car methods))
16149 (where (nth 1 method))
16150 (mesg (format "Reading active file%s via %s..."
16151 (if (and where (not (zerop (length where))))
16152 (concat " from " where) "")
16154 (gnus-message 5 mesg)
16155 (when (gnus-check-server method)
16156 ;; Request that the backend scan its incoming messages.
16157 (and (gnus-check-backend-function 'request-scan (car method))
16158 (gnus-request-scan nil method))
16160 ((and (eq gnus-read-active-file 'some)
16161 (gnus-check-backend-function 'retrieve-groups (car method)))
16162 (let ((newsrc (cdr gnus-newsrc-alist))
16163 (gmethod (gnus-server-get-method nil method))
16165 (while (setq info (pop newsrc))
16166 (when (gnus-server-equal
16167 (gnus-find-method-for-group
16168 (gnus-info-group info) info)
16170 (push (gnus-group-real-name (gnus-info-group info))
16173 (gnus-check-server method)
16174 (setq list-type (gnus-retrieve-groups groups method))
16178 1.2 "Cannot read partial active file from %s server."
16180 ((eq list-type 'active)
16181 (gnus-active-to-gnus-format method gnus-active-hashtb))
16183 (gnus-groups-to-gnus-format method gnus-active-hashtb))))))
16185 (if (not (gnus-request-list method))
16186 (unless (equal method gnus-message-archive-method)
16187 (gnus-error 1 "Cannot read active file from %s server."
16189 (gnus-message 5 mesg)
16190 (gnus-active-to-gnus-format method gnus-active-hashtb)
16191 ;; We mark this active file as read.
16192 (push method gnus-have-read-active-file)
16193 (gnus-message 5 "%sdone" mesg))))))
16194 (setq methods (cdr methods))))))
16196 ;; Read an active file and place the results in `gnus-active-hashtb'.
16197 (defun gnus-active-to-gnus-format (&optional method hashtb ignore-errors)
16199 (setq method gnus-select-method))
16200 (let ((cur (current-buffer))
16202 (if (and gnus-active-hashtb
16203 (not (equal method gnus-select-method)))
16205 (setq gnus-active-hashtb
16206 (if (equal method gnus-select-method)
16207 (gnus-make-hashtable
16208 (count-lines (point-min) (point-max)))
16209 (gnus-make-hashtable 4096)))))))
16210 ;; Delete unnecessary lines.
16211 (goto-char (point-min))
16212 (while (search-forward "\nto." nil t)
16213 (delete-region (1+ (match-beginning 0))
16214 (progn (forward-line 1) (point))))
16215 (or (string= gnus-ignored-newsgroups "")
16217 (goto-char (point-min))
16218 (delete-matching-lines gnus-ignored-newsgroups)))
16219 ;; Make the group names readable as a lisp expression even if they
16220 ;; contain special characters.
16221 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
16222 (goto-char (point-max))
16223 (while (re-search-backward "[][';?()#]" nil t)
16225 ;; If these are groups from a foreign select method, we insert the
16226 ;; group prefix in front of the group names.
16227 (and method (not (gnus-server-equal
16228 (gnus-server-get-method nil method)
16229 (gnus-server-get-method nil gnus-select-method)))
16230 (let ((prefix (gnus-group-prefixed-name "" method)))
16231 (goto-char (point-min))
16232 (while (and (not (eobp))
16233 (progn (insert prefix)
16234 (zerop (forward-line 1)))))))
16235 ;; Store the active file in a hash table.
16236 (goto-char (point-min))
16237 (if (string-match "%[oO]" gnus-group-line-format)
16238 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
16239 ;; If we want information on moderated groups, we use this
16241 (let* ((mod-hashtb (make-vector 7 0))
16242 (m (intern "m" mod-hashtb))
16244 (while (not (eobp))
16245 (condition-case nil
16247 (narrow-to-region (point) (gnus-point-at-eol))
16248 (setq group (let ((obarray hashtb)) (read cur)))
16249 (if (and (numberp (setq max (read cur)))
16250 (numberp (setq min (read cur)))
16252 (skip-chars-forward " \t")
16254 (or (= (following-char) ?=)
16255 (= (following-char) ?x)
16256 (= (following-char) ?j)))))
16257 (set group (cons min max))
16259 ;; Enter moderated groups into a list.
16260 (if (eq (let ((obarray mod-hashtb)) (read cur)) m)
16261 (setq gnus-moderated-list
16262 (cons (symbol-name group) gnus-moderated-list))))
16269 ;; And if we do not care about moderation, we use this loop,
16270 ;; which is faster.
16271 (let (group max min)
16272 (while (not (eobp))
16275 (narrow-to-region (point) (gnus-point-at-eol))
16276 ;; group gets set to a symbol interned in the hash table
16277 ;; (what a hack!!) - jwz
16278 (setq group (let ((obarray hashtb)) (read cur)))
16279 (if (and (numberp (setq max (read cur)))
16280 (numberp (setq min (read cur)))
16282 (skip-chars-forward " \t")
16284 (or (= (following-char) ?=)
16285 (= (following-char) ?x)
16286 (= (following-char) ?j)))))
16287 (set group (cons min max))
16295 (gnus-message 3 "Warning - illegal active: %s"
16297 (gnus-point-at-bol) (gnus-point-at-eol)))))))
16299 (forward-line 1))))))
16301 (defun gnus-groups-to-gnus-format (method &optional hashtb)
16302 ;; Parse a "groups" active file.
16303 (let ((cur (current-buffer))
16305 (if (and method gnus-active-hashtb)
16307 (setq gnus-active-hashtb
16308 (gnus-make-hashtable
16309 (count-lines (point-min) (point-max)))))))
16310 (prefix (and method
16311 (not (gnus-server-equal
16312 (gnus-server-get-method nil method)
16313 (gnus-server-get-method nil gnus-select-method)))
16314 (gnus-group-prefixed-name "" method))))
16316 (goto-char (point-min))
16317 ;; We split this into to separate loops, one with the prefix
16318 ;; and one without to speed the reading up somewhat.
16320 (let (min max opoint group)
16321 (while (not (eobp))
16324 (read cur) (read cur)
16325 (setq min (read cur)
16328 (skip-chars-forward " \t")
16331 (set (let ((obarray hashtb)) (read cur))
16333 (error (and group (symbolp group) (set group nil))))
16335 (let (min max group)
16336 (while (not (eobp))
16338 (if (= (following-char) ?2)
16340 (read cur) (read cur)
16341 (setq min (read cur)
16343 (set (setq group (let ((obarray hashtb)) (read cur)))
16345 (error (and group (symbolp group) (set group nil))))
16346 (forward-line 1))))))
16348 (defun gnus-read-newsrc-file (&optional force)
16349 "Read startup file.
16350 If FORCE is non-nil, the .newsrc file is read."
16351 ;; Reset variables that might be defined in the .newsrc.eld file.
16352 (let ((variables gnus-variable-list))
16354 (set (car variables) nil)
16355 (setq variables (cdr variables))))
16356 (let* ((newsrc-file gnus-current-startup-file)
16357 (quick-file (concat newsrc-file ".el")))
16359 ;; We always load the .newsrc.eld file. If always contains
16360 ;; much information that can not be gotten from the .newsrc
16361 ;; file (ticked articles, killed groups, foreign methods, etc.)
16362 (gnus-read-newsrc-el-file quick-file)
16364 (if (and (file-exists-p gnus-current-startup-file)
16366 (and (file-newer-than-file-p newsrc-file quick-file)
16367 (file-newer-than-file-p newsrc-file
16368 (concat quick-file "d")))
16369 (not gnus-newsrc-alist)))
16370 ;; We read the .newsrc file. Note that if there if a
16371 ;; .newsrc.eld file exists, it has already been read, and
16372 ;; the `gnus-newsrc-hashtb' has been created. While reading
16373 ;; the .newsrc file, Gnus will only use the information it
16374 ;; can find there for changing the data already read -
16375 ;; ie. reading the .newsrc file will not trash the data
16376 ;; already read (except for read articles).
16378 (gnus-message 5 "Reading %s..." newsrc-file)
16379 (set-buffer (find-file-noselect newsrc-file))
16380 (buffer-disable-undo (current-buffer))
16381 (gnus-newsrc-to-gnus-format)
16382 (kill-buffer (current-buffer))
16383 (gnus-message 5 "Reading %s...done" newsrc-file)))
16385 ;; Read any slave files.
16387 (gnus-master-read-slave-newsrc))
16389 ;; Convert old to new.
16390 (gnus-convert-old-newsrc))))
16392 (defun gnus-continuum-version (version)
16393 "Return VERSION as a floating point number."
16394 (when (or (string-match "^\\([^ ]+\\)? ?Gnus v?\\([0-9.]+\\)$" version)
16395 (string-match "^\\(.?\\)gnus-\\([0-9.]+\\)$" version))
16396 (let* ((alpha (and (match-beginning 1) (match-string 1 version)))
16397 (number (match-string 2 version))
16399 (string-match "\\([0-9]\\)\\.\\([0-9]+\\)\\.?\\([0-9]+\\)?" number)
16400 (setq major (string-to-number (match-string 1 number)))
16401 (setq minor (string-to-number (match-string 2 number)))
16402 (setq least (if (match-beginning 3)
16403 (string-to-number (match-string 3 number))
16407 (format "%s00%02d%02d"
16409 ((member alpha '("(ding)" "d")) "4.99")
16410 ((member alpha '("September" "s")) "5.01")
16411 ((member alpha '("Red" "r")) "5.03"))
16413 (format "%d.%02d%02d" major minor least))))))
16415 (defun gnus-convert-old-newsrc ()
16416 "Convert old newsrc into the new format, if needed."
16417 (let ((fcv (and gnus-newsrc-file-version
16418 (gnus-continuum-version gnus-newsrc-file-version))))
16420 ;; No .newsrc.eld file was loaded.
16422 ;; Gnus 5 .newsrc.eld was loaded.
16423 ((< fcv (gnus-continuum-version "September Gnus v0.1"))
16424 (gnus-convert-old-ticks)))))
16426 (defun gnus-convert-old-ticks ()
16427 (let ((newsrc (cdr gnus-newsrc-alist))
16428 marks info dormant ticked)
16429 (while (setq info (pop newsrc))
16430 (when (setq marks (gnus-info-marks info))
16431 (setq dormant (cdr (assq 'dormant marks))
16432 ticked (cdr (assq 'tick marks)))
16433 (when (or dormant ticked)
16434 (gnus-info-set-read
16437 (gnus-info-read info)
16438 (nconc (gnus-uncompress-range dormant)
16439 (gnus-uncompress-range ticked)))))))))
16441 (defun gnus-read-newsrc-el-file (file)
16442 (let ((ding-file (concat file "d")))
16443 ;; We always, always read the .eld file.
16444 (gnus-message 5 "Reading %s..." ding-file)
16445 (let (gnus-newsrc-assoc)
16446 (condition-case nil
16447 (load ding-file t t t)
16449 (gnus-error 1 "Error in %s" ding-file)))
16450 (when gnus-newsrc-assoc
16451 (setq gnus-newsrc-alist gnus-newsrc-assoc)))
16452 (gnus-make-hashtable-from-newsrc-alist)
16453 (when (file-newer-than-file-p file ding-file)
16454 ;; Old format quick file
16455 (gnus-message 5 "Reading %s..." file)
16456 ;; The .el file is newer than the .eld file, so we read that one
16458 (gnus-read-old-newsrc-el-file file))))
16460 ;; Parse the old-style quick startup file
16461 (defun gnus-read-old-newsrc-el-file (file)
16462 (let (newsrc killed marked group m info)
16464 (let ((gnus-killed-assoc nil)
16465 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc)
16467 (condition-case nil
16470 (setq newsrc gnus-newsrc-assoc
16471 killed gnus-killed-assoc
16472 marked gnus-marked-assoc)))
16473 (setq gnus-newsrc-alist nil)
16474 (while (setq group (pop newsrc))
16475 (if (setq info (gnus-get-info (car group)))
16477 (gnus-info-set-read info (cddr group))
16478 (gnus-info-set-level
16479 info (if (nth 1 group) gnus-level-default-subscribed
16480 gnus-level-default-unsubscribed))
16481 (setq gnus-newsrc-alist (cons info gnus-newsrc-alist)))
16484 (if (nth 1 group) gnus-level-default-subscribed
16485 gnus-level-default-unsubscribed)
16487 gnus-newsrc-alist))
16488 ;; Copy marks into info.
16489 (when (setq m (assoc (car group) marked))
16490 (unless (nthcdr 3 info)
16491 (nconc info (list nil)))
16492 (gnus-info-set-marks
16493 info (list (cons 'tick (gnus-compress-sequence
16494 (sort (cdr m) '<) t))))))
16495 (setq newsrc killed)
16497 (setcar newsrc (caar newsrc))
16498 (setq newsrc (cdr newsrc)))
16499 (setq gnus-killed-list killed))
16500 ;; The .el file version of this variable does not begin with
16501 ;; "options", while the .eld version does, so we just add it if it
16504 gnus-newsrc-options
16506 (and (not (string-match "^ *options" gnus-newsrc-options))
16507 (setq gnus-newsrc-options (concat "options " gnus-newsrc-options)))
16508 (and (not (string-match "\n$" gnus-newsrc-options))
16509 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n")))
16510 ;; Finally, if we read some options lines, we parse them.
16511 (or (string= gnus-newsrc-options "")
16512 (gnus-newsrc-parse-options gnus-newsrc-options))))
16514 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))
16515 (gnus-make-hashtable-from-newsrc-alist)))
16517 (defun gnus-make-newsrc-file (file)
16518 "Make server dependent file name by catenating FILE and server host name."
16519 (let* ((file (expand-file-name file nil))
16520 (real-file (concat file "-" (nth 1 gnus-select-method))))
16521 (if (or (file-exists-p real-file)
16522 (file-exists-p (concat real-file ".el"))
16523 (file-exists-p (concat real-file ".eld")))
16526 (defun gnus-newsrc-to-gnus-format ()
16527 (setq gnus-newsrc-options "")
16528 (setq gnus-newsrc-options-n nil)
16530 (or gnus-active-hashtb
16531 (setq gnus-active-hashtb (make-vector 4095 0)))
16532 (let ((buf (current-buffer))
16533 (already-read (> (length gnus-newsrc-alist) 1))
16534 group subscribed options-symbol newsrc Options-symbol
16536 (goto-char (point-min))
16537 ;; We intern the symbol `options' in the active hashtb so that we
16538 ;; can `eq' against it later.
16539 (set (setq options-symbol (intern "options" gnus-active-hashtb)) nil)
16540 (set (setq Options-symbol (intern "Options" gnus-active-hashtb)) nil)
16542 (while (not (eobp))
16543 ;; We first read the first word on the line by narrowing and
16544 ;; then reading into `gnus-active-hashtb'. Most groups will
16545 ;; already exist in that hashtb, so this will save some string
16549 (progn (skip-chars-forward "^ \t!:\n") (point)))
16550 (goto-char (point-min))
16552 (and (/= (point-min) (point-max))
16553 (let ((obarray gnus-active-hashtb)) (read buf))))
16555 ;; Now, the symbol we have read is either `options' or a group
16556 ;; name. If it is an options line, we just add it to a string.
16558 ((or (eq symbol options-symbol)
16559 (eq symbol Options-symbol))
16560 (setq gnus-newsrc-options
16561 ;; This concating is quite inefficient, but since our
16562 ;; thorough studies show that approx 99.37% of all
16563 ;; .newsrc files only contain a single options line, we
16564 ;; don't give a damn, frankly, my dear.
16565 (concat gnus-newsrc-options
16567 (gnus-point-at-bol)
16568 ;; Options may continue on the next line.
16569 (or (and (re-search-forward "^[^ \t]" nil 'move)
16570 (progn (beginning-of-line) (point)))
16574 ;; Group names can be just numbers.
16575 (when (numberp symbol)
16576 (setq symbol (intern (int-to-string symbol) gnus-active-hashtb)))
16577 (or (boundp symbol) (set symbol nil))
16578 ;; It was a group name.
16579 (setq subscribed (= (following-char) ?:)
16580 group (symbol-name symbol)
16583 ;; If the line ends here, this is clearly a buggy line, so
16584 ;; we put point a the beginning of line and let the cond
16585 ;; below do the error handling.
16586 (beginning-of-line)
16587 ;; We skip to the beginning of the ranges.
16588 (skip-chars-forward "!: \t"))
16589 ;; We are now at the beginning of the list of read articles.
16590 ;; We read them range by range.
16593 ((looking-at "[0-9]+")
16594 ;; We narrow and read a number instead of buffer-substring/
16595 ;; string-to-int because it's faster. narrow/widen is
16596 ;; faster than save-restriction/narrow, and save-restriction
16597 ;; produces a garbage object.
16599 (narrow-to-region (match-beginning 0) (match-end 0))
16602 ;; If the next character is a dash, then this is a range.
16603 (if (= (following-char) ?-)
16605 ;; We read the upper bound of the range.
16607 (if (not (looking-at "[0-9]+"))
16608 ;; This is a buggy line, by we pretend that
16609 ;; it's kinda OK. Perhaps the user should be
16611 (setq reads (cons num1 reads))
16616 (narrow-to-region (match-beginning 0)
16621 ;; It was just a simple number, so we add it to the
16623 (setq reads (cons num1 reads)))
16624 ;; If the next char in ?\n, then we have reached the end
16625 ;; of the line and return nil.
16626 (/= (following-char) ?\n))
16627 ((= (following-char) ?\n)
16628 ;; End of line, so we end.
16631 ;; Not numbers and not eol, so this might be a buggy
16634 ;; If it was eob instead of ?\n, we allow it.
16636 ;; The line was buggy.
16638 (gnus-error 3.1 "Mangled line: %s"
16639 (buffer-substring (gnus-point-at-bol)
16640 (gnus-point-at-eol)))))
16642 ;; Skip past ", ". Spaces are illegal in these ranges, but
16643 ;; we allow them, because it's a common mistake to put a
16644 ;; space after the comma.
16645 (skip-chars-forward ", "))
16647 ;; We have already read .newsrc.eld, so we gently update the
16648 ;; data in the hash table with the information we have just
16651 (let ((info (gnus-get-info group))
16654 ;; There is an entry for this file in the alist.
16656 (gnus-info-set-read info (nreverse reads))
16657 ;; We update the level very gently. In fact, we
16658 ;; only change it if there's been a status change
16659 ;; from subscribed to unsubscribed, or vice versa.
16660 (setq level (gnus-info-level info))
16661 (cond ((and (<= level gnus-level-subscribed)
16663 (setq level (if reads
16664 gnus-level-default-unsubscribed
16665 (1+ gnus-level-default-unsubscribed))))
16666 ((and (> level gnus-level-subscribed) subscribed)
16667 (setq level gnus-level-default-subscribed)))
16668 (gnus-info-set-level info level))
16669 ;; This is a new group.
16670 (setq info (list group
16672 gnus-level-default-subscribed
16674 (1+ gnus-level-subscribed)
16675 gnus-level-default-unsubscribed))
16676 (nreverse reads))))
16677 (setq newsrc (cons info newsrc))))))
16680 (setq newsrc (nreverse newsrc))
16682 (if (not already-read)
16684 ;; We now have two newsrc lists - `newsrc', which is what we
16685 ;; have read from .newsrc, and `gnus-newsrc-alist', which is
16686 ;; what we've read from .newsrc.eld. We have to merge these
16687 ;; lists. We do this by "attaching" any (foreign) groups in the
16688 ;; gnus-newsrc-alist to the (native) group that precedes them.
16689 (let ((rc (cdr gnus-newsrc-alist))
16690 (prev gnus-newsrc-alist)
16693 (or (null (nth 4 (car rc))) ; It's a native group.
16694 (assoc (caar rc) newsrc) ; It's already in the alist.
16695 (if (setq entry (assoc (caar prev) newsrc))
16696 (setcdr (setq mentry (memq entry newsrc))
16697 (cons (car rc) (cdr mentry)))
16698 (setq newsrc (cons (car rc) newsrc))))
16702 (setq gnus-newsrc-alist newsrc)
16703 ;; We make the newsrc hashtb.
16704 (gnus-make-hashtable-from-newsrc-alist)
16706 ;; Finally, if we read some options lines, we parse them.
16707 (or (string= gnus-newsrc-options "")
16708 (gnus-newsrc-parse-options gnus-newsrc-options))))
16710 ;; Parse options lines to find "options -n !all rec.all" and stuff.
16711 ;; The return value will be a list on the form
16712 ;; ((regexp1 . ignore)
16713 ;; (regexp2 . subscribe)...)
16714 ;; When handling new newsgroups, groups that match a `ignore' regexp
16715 ;; will be ignored, and groups that match a `subscribe' regexp will be
16716 ;; subscribed. A line like
16717 ;; options -n !all rec.all
16718 ;; will lead to a list that looks like
16719 ;; (("^rec\\..+" . subscribe)
16720 ;; ("^.+" . ignore))
16721 ;; So all "rec.*" groups will be subscribed, while all the other
16722 ;; groups will be ignored. Note that "options -n !all rec.all" is very
16723 ;; different from "options -n rec.all !all".
16724 (defun gnus-newsrc-parse-options (options)
16727 (gnus-set-work-buffer)
16728 (insert (regexp-quote options))
16729 ;; First we treat all continuation lines.
16730 (goto-char (point-min))
16731 (while (re-search-forward "\n[ \t]+" nil t)
16732 (replace-match " " t t))
16733 ;; Then we transform all "all"s into ".+"s.
16734 (goto-char (point-min))
16735 (while (re-search-forward "\\ball\\b" nil t)
16736 (replace-match ".+" t t))
16737 (goto-char (point-min))
16738 ;; We remove all other options than the "-n" ones.
16739 (while (re-search-forward "[ \t]-[^n][^-]*" nil t)
16740 (replace-match " ")
16742 (goto-char (point-min))
16744 ;; We are only interested in "options -n" lines - we
16745 ;; ignore the other option lines.
16746 (while (re-search-forward "[ \t]-n" nil t)
16748 (or (save-excursion
16749 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t)
16751 (gnus-point-at-eol)))
16752 ;; Search for all "words"...
16753 (while (re-search-forward "[^ \t,\n]+" eol t)
16754 (if (= (char-after (match-beginning 0)) ?!)
16755 ;; If the word begins with a bang (!), this is a "not"
16756 ;; spec. We put this spec (minus the bang) and the
16757 ;; symbol `ignore' into the list.
16758 (setq out (cons (cons (concat
16759 "^" (buffer-substring
16760 (1+ (match-beginning 0))
16763 ;; There was no bang, so this is a "yes" spec.
16764 (setq out (cons (cons (concat "^" (match-string 0))
16765 'subscribe) out)))))
16767 (setq gnus-newsrc-options-n out))))
16769 (defun gnus-save-newsrc-file (&optional force)
16770 "Save .newsrc file."
16771 ;; Note: We cannot save .newsrc file if all newsgroups are removed
16772 ;; from the variable gnus-newsrc-alist.
16773 (when (and (or gnus-newsrc-alist gnus-killed-list)
16774 gnus-current-startup-file)
16776 (if (and (or gnus-use-dribble-file gnus-slave)
16778 (or (not gnus-dribble-buffer)
16779 (not (buffer-name gnus-dribble-buffer))
16780 (zerop (save-excursion
16781 (set-buffer gnus-dribble-buffer)
16783 (gnus-message 4 "(No changes need to be saved)")
16784 (run-hooks 'gnus-save-newsrc-hook)
16786 (gnus-slave-save-newsrc)
16788 (when gnus-save-newsrc-file
16789 (gnus-message 5 "Saving %s..." gnus-current-startup-file)
16790 (gnus-gnus-to-newsrc-format)
16791 (gnus-message 5 "Saving %s...done" gnus-current-startup-file))
16792 ;; Save .newsrc.eld.
16793 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
16794 (make-local-variable 'version-control)
16795 (setq version-control 'never)
16796 (setq buffer-file-name
16797 (concat gnus-current-startup-file ".eld"))
16798 (setq default-directory (file-name-directory buffer-file-name))
16799 (gnus-add-current-to-buffer-list)
16800 (buffer-disable-undo (current-buffer))
16802 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file)
16803 (gnus-gnus-to-quick-newsrc-format)
16804 (run-hooks 'gnus-save-quick-newsrc-hook)
16806 (kill-buffer (current-buffer))
16808 5 "Saving %s.eld...done" gnus-current-startup-file))
16809 (gnus-dribble-delete-file)
16810 (gnus-group-set-mode-line)))))
16812 (defun gnus-gnus-to-quick-newsrc-format ()
16813 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
16814 (insert ";; Gnus startup file.\n")
16815 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
16816 (insert ";; to read .newsrc.\n")
16817 (insert "(setq gnus-newsrc-file-version "
16818 (prin1-to-string gnus-version) ")\n")
16820 (if gnus-save-killed-list gnus-variable-list
16821 ;; Remove the `gnus-killed-list' from the list of variables
16822 ;; to be saved, if required.
16823 (delq 'gnus-killed-list (copy-sequence gnus-variable-list))))
16824 ;; Peel off the "dummy" group.
16825 (gnus-newsrc-alist (cdr gnus-newsrc-alist))
16827 ;; Insert the variables into the file.
16829 (when (and (boundp (setq variable (pop variables)))
16830 (symbol-value variable))
16831 (insert "(setq " (symbol-name variable) " '")
16832 (prin1 (symbol-value variable) (current-buffer))
16835 (defun gnus-gnus-to-newsrc-format ()
16836 ;; Generate and save the .newsrc file.
16838 (set-buffer (create-file-buffer gnus-current-startup-file))
16839 (let ((newsrc (cdr gnus-newsrc-alist))
16840 (standard-output (current-buffer))
16841 info ranges range method)
16842 (setq buffer-file-name gnus-current-startup-file)
16843 (setq default-directory (file-name-directory buffer-file-name))
16844 (buffer-disable-undo (current-buffer))
16847 (if gnus-newsrc-options (insert gnus-newsrc-options))
16848 ;; Write subscribed and unsubscribed.
16849 (while (setq info (pop newsrc))
16850 ;; Don't write foreign groups to .newsrc.
16851 (when (or (null (setq method (gnus-info-method info)))
16852 (equal method "native")
16853 (gnus-server-equal method gnus-select-method))
16854 (insert (gnus-info-group info)
16855 (if (> (gnus-info-level info) gnus-level-subscribed)
16857 (when (setq ranges (gnus-info-read info))
16859 (if (not (listp (cdr ranges)))
16860 (if (= (car ranges) (cdr ranges))
16861 (princ (car ranges))
16862 (princ (car ranges))
16864 (princ (cdr ranges)))
16865 (while (setq range (pop ranges))
16866 (if (or (atom range) (= (car range) (cdr range)))
16867 (princ (or (and (atom range) range) (car range)))
16868 (princ (car range))
16870 (princ (cdr range)))
16871 (if ranges (insert ",")))))
16873 (make-local-variable 'version-control)
16874 (setq version-control 'never)
16875 ;; It has been reported that sometime the modtime on the .newsrc
16876 ;; file seems to be off. We really do want to overwrite it, so
16877 ;; we clear the modtime here before saving. It's a bit odd,
16879 ;; sometimes the modtime clear isn't sufficient. most brute force:
16880 ;; delete the silly thing entirely first. but this fails to provide
16881 ;; such niceties as .newsrc~ creation.
16882 (if gnus-modtime-botch
16883 (delete-file gnus-startup-file)
16884 (clear-visited-file-modtime))
16885 (run-hooks 'gnus-save-standard-newsrc-hook)
16887 (kill-buffer (current-buffer)))))
16891 ;;; Slave functions.
16894 (defun gnus-slave-save-newsrc ()
16896 (set-buffer gnus-dribble-buffer)
16898 (make-temp-name (concat gnus-current-startup-file "-slave-"))))
16899 (write-region (point-min) (point-max) slave-name nil 'nomesg))))
16901 (defun gnus-master-read-slave-newsrc ()
16904 (file-name-directory gnus-current-startup-file)
16908 (file-name-nondirectory gnus-current-startup-file)
16912 (if (not slave-files)
16913 () ; There are no slave files to read.
16914 (gnus-message 7 "Reading slave newsrcs...")
16916 (set-buffer (get-buffer-create " *gnus slave*"))
16917 (buffer-disable-undo (current-buffer))
16919 (sort (mapcar (lambda (file)
16920 (list (nth 5 (file-attributes file)) file))
16923 (or (< (caar f1) (caar f2))
16924 (< (nth 1 (car f1)) (nth 1 (car f2)))))))
16927 (setq file (nth 1 (car slave-files)))
16928 (insert-file-contents file)
16929 (if (condition-case ()
16931 (eval-buffer (current-buffer))
16934 (gnus-error 3.2 "Possible error in %s" file)
16936 (or gnus-slave ; Slaves shouldn't delete these files.
16940 (setq slave-files (cdr slave-files))))
16941 (gnus-message 7 "Reading slave newsrcs...done"))))
16945 ;;; Group description.
16948 (defun gnus-read-all-descriptions-files ()
16949 (let ((methods (cons gnus-select-method
16951 (when gnus-message-archive-method
16953 gnus-secondary-select-methods))))
16955 (gnus-read-descriptions-file (car methods))
16956 (setq methods (cdr methods)))
16959 (defun gnus-read-descriptions-file (&optional method)
16960 (let ((method (or method gnus-select-method)))
16961 (when (stringp method)
16962 (setq method (gnus-server-to-method method)))
16963 ;; We create the hashtable whether we manage to read the desc file
16964 ;; to avoid trying to re-read after a failed read.
16965 (or gnus-description-hashtb
16966 (setq gnus-description-hashtb
16967 (gnus-make-hashtable (length gnus-active-hashtb))))
16968 ;; Mark this method's desc file as read.
16969 (gnus-sethash (gnus-group-prefixed-name "" method) "Has read"
16970 gnus-description-hashtb)
16972 (gnus-message 5 "Reading descriptions file via %s..." (car method))
16974 ((not (gnus-check-server method))
16975 (gnus-message 1 "Couldn't open server")
16977 ((not (gnus-request-list-newsgroups method))
16978 (gnus-message 1 "Couldn't read newsgroups descriptions")
16984 (set-buffer nntp-server-buffer)
16985 (goto-char (point-min))
16986 (if (or (search-forward "\n.\n" nil t)
16987 (goto-char (point-max)))
16989 (beginning-of-line)
16990 (narrow-to-region (point-min) (point))))
16991 (goto-char (point-min))
16992 (while (not (eobp))
16993 ;; If we get an error, we set group to 0, which is not a
16997 (let ((obarray gnus-description-hashtb))
16998 ;; Group is set to a symbol interned in this
17000 (read nntp-server-buffer))
17002 (skip-chars-forward " \t")
17003 ;; ... which leads to this line being effectively ignored.
17004 (and (symbolp group)
17005 (set group (buffer-substring
17006 (point) (progn (end-of-line) (point)))))
17007 (forward-line 1))))
17008 (gnus-message 5 "Reading descriptions file...done")
17011 (defun gnus-group-get-description (group)
17012 "Get the description of a group by sending XGTITLE to the server."
17013 (when (gnus-request-group-description group)
17015 (set-buffer nntp-server-buffer)
17016 (goto-char (point-min))
17017 (when (looking-at "[^ \t]+[ \t]+\\(.*\\)")
17018 (match-string 1)))))
17022 ;;; Buffering of read articles.
17025 (defvar gnus-backlog-buffer " *Gnus Backlog*")
17026 (defvar gnus-backlog-articles nil)
17027 (defvar gnus-backlog-hashtb nil)
17029 (defun gnus-backlog-buffer ()
17030 "Return the backlog buffer."
17031 (or (get-buffer gnus-backlog-buffer)
17033 (set-buffer (get-buffer-create gnus-backlog-buffer))
17034 (buffer-disable-undo (current-buffer))
17035 (setq buffer-read-only t)
17036 (gnus-add-current-to-buffer-list)
17037 (get-buffer gnus-backlog-buffer))))
17039 (defun gnus-backlog-setup ()
17040 "Initialize backlog variables."
17041 (unless gnus-backlog-hashtb
17042 (setq gnus-backlog-hashtb (make-vector 1023 0))))
17044 (gnus-add-shutdown 'gnus-backlog-shutdown 'gnus)
17046 (defun gnus-backlog-shutdown ()
17047 "Clear all backlog variables and buffers."
17048 (when (get-buffer gnus-backlog-buffer)
17049 (kill-buffer gnus-backlog-buffer))
17050 (setq gnus-backlog-hashtb nil
17051 gnus-backlog-articles nil))
17053 (defun gnus-backlog-enter-article (group number buffer)
17054 (gnus-backlog-setup)
17055 (let ((ident (intern (concat group ":" (int-to-string number))
17056 gnus-backlog-hashtb))
17058 (if (memq ident gnus-backlog-articles)
17059 () ; It's already kept.
17060 ;; Remove the oldest article, if necessary.
17061 (and (numberp gnus-keep-backlog)
17062 (>= (length gnus-backlog-articles) gnus-keep-backlog)
17063 (gnus-backlog-remove-oldest-article))
17064 (setq gnus-backlog-articles (cons ident gnus-backlog-articles))
17065 ;; Insert the new article.
17067 (set-buffer (gnus-backlog-buffer))
17068 (let (buffer-read-only)
17069 (goto-char (point-max))
17070 (or (bolp) (insert "\n"))
17072 (insert-buffer-substring buffer)
17073 ;; Tag the beginning of the article with the ident.
17074 (gnus-put-text-property b (1+ b) 'gnus-backlog ident))))))
17076 (defun gnus-backlog-remove-oldest-article ()
17078 (set-buffer (gnus-backlog-buffer))
17079 (goto-char (point-min))
17080 (if (zerop (buffer-size))
17081 () ; The buffer is empty.
17082 (let ((ident (get-text-property (point) 'gnus-backlog))
17084 ;; Remove the ident from the list of articles.
17086 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
17087 ;; Delete the article itself.
17089 (point) (next-single-property-change
17090 (1+ (point)) 'gnus-backlog nil (point-max)))))))
17092 (defun gnus-backlog-remove-article (group number)
17093 "Remove article NUMBER in GROUP from the backlog."
17094 (when (numberp number)
17095 (gnus-backlog-setup)
17096 (let ((ident (intern (concat group ":" (int-to-string number))
17097 gnus-backlog-hashtb))
17099 (when (memq ident gnus-backlog-articles)
17100 ;; It was in the backlog.
17102 (set-buffer (gnus-backlog-buffer))
17103 (let (buffer-read-only)
17104 (when (setq beg (text-property-any
17105 (point-min) (point-max) 'gnus-backlog
17107 ;; Find the end (i. e., the beginning of the next article).
17109 (next-single-property-change
17110 (1+ beg) 'gnus-backlog (current-buffer) (point-max)))
17111 (delete-region beg end)
17115 (defun gnus-backlog-request-article (group number buffer)
17116 (when (numberp number)
17117 (gnus-backlog-setup)
17118 (let ((ident (intern (concat group ":" (int-to-string number))
17119 gnus-backlog-hashtb))
17121 (when (memq ident gnus-backlog-articles)
17122 ;; It was in the backlog.
17124 (set-buffer (gnus-backlog-buffer))
17125 (if (not (setq beg (text-property-any
17126 (point-min) (point-max) 'gnus-backlog
17128 ;; It wasn't in the backlog after all.
17130 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
17131 ;; Find the end (i. e., the beginning of the next article).
17133 (next-single-property-change
17134 (1+ beg) 'gnus-backlog (current-buffer) (point-max)))))
17135 (let ((buffer-read-only nil))
17137 (insert-buffer-substring gnus-backlog-buffer beg end)
17140 ;; Allow redefinition of Gnus functions.
17142 (gnus-ems-redefine)
17146 ;;; gnus.el ends here