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
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
28 (eval '(run-hooks 'gnus-load-hook))
34 (eval-when-compile (require 'cl))
36 ;; Site dependent variables. These variables should be defined in
39 (defvar gnus-default-nntp-server nil
40 "Specify a default NNTP server.
41 This variable should be defined in paths.el, and should never be set
43 If you want to change servers, you should use `gnus-select-method'.
44 See the documentation to that variable.")
46 (defvar gnus-backup-default-subscribed-newsgroups
47 '("news.announce.newusers" "news.groups.questions" "gnu.emacs.gnus")
48 "Default default new newsgroups the first time Gnus is run.
49 Should be set in paths.el, and shouldn't be touched by the user.")
51 (defvar gnus-local-domain nil
52 "Local domain name without a host name.
53 The DOMAINNAME environment variable is used instead if it is defined.
54 If the `system-name' function returns the full Internet name, there is
55 no need to set this variable.")
57 (defvar gnus-local-organization nil
58 "String with a description of what organization (if any) the user belongs to.
59 The ORGANIZATION environment variable is used instead if it is defined.
60 If this variable contains a function, this function will be called
61 with the current newsgroup name as the argument. The function should
64 In any case, if the string (either in the variable, in the environment
65 variable, or returned by the function) is a file name, the contents of
66 this file will be used as the organization.")
68 (defvar gnus-use-generic-from nil
69 "If nil, the full host name will be the system name prepended to the domain name.
70 If this is a string, the full host name will be this string.
71 If this is non-nil, non-string, the domain name will be used as the
74 (defvar gnus-use-generic-path nil
75 "If nil, use the NNTP server name in the Path header.
76 If stringp, use this; if non-nil, use no host name (user name only).")
78 ;; Customization variables
80 ;; Don't touch this variable.
81 (defvar gnus-nntp-service "nntp"
82 "*NNTP service name (\"nntp\" or 119).
83 This is an obsolete variable, which is scarcely used. If you use an
84 nntp server for your newsgroup and want to change the port number
85 used to 899, you would say something along these lines:
87 (setq gnus-select-method '(nntp \"my.nntp.server\" (nntp-port-number 899)))")
89 (defvar gnus-nntpserver-file "/etc/nntpserver"
90 "*A file with only the name of the nntp server in it.")
92 ;; This function is used to check both the environment variable
93 ;; NNTPSERVER and the /etc/nntpserver file to see whether one can find
94 ;; an nntp server name default.
95 (defun gnus-getenv-nntpserver ()
96 (or (getenv "NNTPSERVER")
97 (and (file-readable-p gnus-nntpserver-file)
99 (set-buffer (get-buffer-create " *gnus nntp*"))
100 (buffer-disable-undo (current-buffer))
101 (insert-file-contents gnus-nntpserver-file)
102 (let ((name (buffer-string)))
104 (if (string-match "^[ \t\n]*$" name)
107 (kill-buffer (current-buffer))))))))
109 (defvar gnus-select-method
111 (list 'nntp (or (condition-case ()
112 (gnus-getenv-nntpserver)
114 (if (and gnus-default-nntp-server
115 (not (string= gnus-default-nntp-server "")))
116 gnus-default-nntp-server)
118 (if (or (null gnus-nntp-service)
119 (equal gnus-nntp-service "nntp"))
121 (list gnus-nntp-service)))
122 "*Default method for selecting a newsgroup.
123 This variable should be a list, where the first element is how the
124 news is to be fetched, the second is the address.
126 For instance, if you want to get your news via NNTP from
127 \"flab.flab.edu\", you could say:
129 (setq gnus-select-method '(nntp \"flab.flab.edu\"))
131 If you want to use your local spool, say:
133 (setq gnus-select-method (list 'nnspool (system-name)))
135 If you use this variable, you must set `gnus-nntp-server' to nil.
137 There is a lot more to know about select methods and virtual servers -
138 see the manual for details.")
140 (defvar gnus-message-archive-method
141 '(nnfolder "archive" (nnfolder-directory "~/Mail/archive/")
142 (nnfolder-active-file "~/Mail/archive/active")
143 (nnfolder-get-new-mail nil)
144 (nnfolder-inhibit-expiry t))
145 "*Method used for archiving messages you've sent.
146 This should be a mail method.")
148 (defvar gnus-refer-article-method nil
149 "*Preferred method for fetching an article by Message-ID.
150 If you are reading news from the local spool (with nnspool), fetching
151 articles by Message-ID is painfully slow. By setting this method to an
152 nntp method, you might get acceptable results.
154 The value of this variable must be a valid select method as discussed
155 in the documentation of `gnus-select-method'.")
157 (defvar gnus-secondary-select-methods nil
158 "*A list of secondary methods that will be used for reading news.
159 This is a list where each element is a complete select method (see
160 `gnus-select-method').
162 If, for instance, you want to read your mail with the nnml backend,
163 you could set this variable:
165 (setq gnus-secondary-select-methods '((nnml \"\")))")
167 (defvar gnus-secondary-servers nil
168 "*List of NNTP servers that the user can choose between interactively.
169 To make Gnus query you for a server, you have to give `gnus' a
170 non-numeric prefix - `C-u M-x gnus', in short.")
172 (defvar gnus-nntp-server nil
173 "*The name of the host running the NNTP server.
174 This variable is semi-obsolete. Use the `gnus-select-method'
177 (defvar gnus-startup-file "~/.newsrc"
178 "*Your `.newsrc' file.
179 `.newsrc-SERVER' will be used instead if that exists.")
181 (defvar gnus-init-file "~/.gnus"
182 "*Your Gnus elisp startup file.
183 If a file with the .el or .elc suffixes exist, it will be read
186 (defvar gnus-group-faq-directory
187 '("/ftp@mirrors.aol.com:/pub/rtfm/usenet/"
188 "/ftp@src.doc.ic.ac.uk:/usenet/news-FAQS/"
189 "/ftp@ftp.seas.gwu.edu:/pub/rtfm/"
190 "/ftp@rtfm.mit.edu:/pub/usenet/news.answers/"
191 "/ftp@ftp.uni-paderborn.de:/pub/FAQ/"
192 "/ftp@ftp.sunet.se:/pub/usenet/"
193 "/ftp@nctuccca.edu.tw:/USENET/FAQ/"
194 "/ftp@hwarang.postech.ac.kr:/pub/usenet/news.answers/"
195 "/ftp@ftp.hk.super.net:/mirror/faqs/")
196 "*Directory where the group FAQs are stored.
197 This will most commonly be on a remote machine, and the file will be
200 This variable can also be a list of directories. In that case, the
201 first element in the list will be used by default, and the others will
202 be used as backup sites.
204 Note that Gnus uses an aol machine as the default directory. If this
205 feels fundamentally unclean, just think of it as a way to finally get
206 something of value back from them.
208 If the default site is too slow, try one of these:
210 North America: mirrors.aol.com /pub/rtfm/usenet
211 ftp.seas.gwu.edu /pub/rtfm
212 rtfm.mit.edu /pub/usenet/news.answers
213 Europe: ftp.uni-paderborn.de /pub/FAQ
214 src.doc.ic.ac.uk /usenet/news-FAQS
215 ftp.sunet.se /pub/usenet
216 Asia: nctuccca.edu.tw /USENET/FAQ
217 hwarang.postech.ac.kr /pub/usenet/news.answers
218 ftp.hk.super.net /mirror/faqs")
220 (defvar gnus-group-archive-directory
221 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
222 "*The address of the (ding) archives.")
224 (defvar gnus-group-recent-archive-directory
225 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
226 "*The address of the most recent (ding) articles.")
228 (defvar gnus-default-subscribed-newsgroups nil
229 "*This variable lists what newsgroups should be subscribed the first time Gnus is used.
230 It should be a list of strings.
231 If it is `t', Gnus will not do anything special the first time it is
232 started; it'll just use the normal newsgroups subscription methods.")
234 (defvar gnus-use-cross-reference t
235 "*Non-nil means that cross referenced articles will be marked as read.
236 If nil, ignore cross references. If t, mark articles as read in
237 subscribed newsgroups. If neither t nor nil, mark as read in all
240 (defvar gnus-single-article-buffer t
241 "*If non-nil, display all articles in the same buffer.
242 If nil, each group will get its own article buffer.")
244 (defvar gnus-use-dribble-file t
245 "*Non-nil means that Gnus will use a dribble file to store user updates.
246 If Emacs should crash without saving the .newsrc files, complete
247 information can be restored from the dribble file.")
249 (defvar gnus-dribble-directory nil
250 "*The directory where dribble files will be saved.
251 If this variable is nil, the directory where the .newsrc files are
252 saved will be used.")
254 (defvar gnus-asynchronous nil
255 "*If non-nil, Gnus will supply backends with data needed for async article fetching.")
257 (defvar gnus-kill-summary-on-exit t
258 "*If non-nil, kill the summary buffer when you exit from it.
259 If nil, the summary will become a \"*Dead Summary*\" buffer, and
260 it will be killed sometime later.")
262 (defvar gnus-large-newsgroup 200
263 "*The number of articles which indicates a large newsgroup.
264 If the number of articles in a newsgroup is greater than this value,
265 confirmation is required for selecting the newsgroup.")
267 ;; Suggested by Andrew Eskilsson <pi92ae@lelle.pt.hk-r.se>.
268 (defvar gnus-no-groups-message "No news is horrible news"
269 "*Message displayed by Gnus when no groups are available.")
271 (defvar gnus-use-long-file-name (not (memq system-type '(usg-unix-v xenix)))
272 "*Non-nil means that the default name of a file to save articles in is the group name.
273 If it's nil, the directory form of the group name is used instead.
275 If this variable is a list, and the list contains the element
276 `not-score', long file names will not be used for score files; if it
277 contains the element `not-save', long file names will not be used for
278 saving; and if it contains the element `not-kill', long file names
279 will not be used for kill files.")
281 (defvar gnus-article-save-directory (or (getenv "SAVEDIR") "~/News/")
282 "*Name of the directory articles will be saved in (default \"~/News\").
283 Initialized from the SAVEDIR environment variable.")
285 (defvar gnus-kill-files-directory (or (getenv "SAVEDIR") "~/News/")
286 "*Name of the directory where kill files will be stored (default \"~/News\").
287 Initialized from the SAVEDIR environment variable.")
289 (defvar gnus-default-article-saver 'gnus-summary-save-in-rmail
290 "*A function to save articles in your favorite format.
291 The function must be interactively callable (in other words, it must
292 be an Emacs command).
294 Gnus provides the following functions:
296 * gnus-summary-save-in-rmail (Rmail format)
297 * gnus-summary-save-in-mail (Unix mail format)
298 * gnus-summary-save-in-folder (MH folder)
299 * gnus-summary-save-in-file (article format).
300 * gnus-summary-save-in-vm (use VM's folder format).")
302 (defvar gnus-prompt-before-saving 'always
303 "*This variable says how much prompting is to be done when saving articles.
304 If it is nil, no prompting will be done, and the articles will be
305 saved to the default files. If this variable is `always', each and
306 every article that is saved will be preceded by a prompt, even when
307 saving large batches of articles. If this variable is neither nil not
308 `always', there the user will be prompted once for a file name for
309 each invocation of the saving commands.")
311 (defvar gnus-rmail-save-name (function gnus-plain-save-name)
312 "*A function generating a file name to save articles in Rmail format.
313 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
315 (defvar gnus-mail-save-name (function gnus-plain-save-name)
316 "*A function generating a file name to save articles in Unix mail format.
317 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
319 (defvar gnus-folder-save-name (function gnus-folder-save-name)
320 "*A function generating a file name to save articles in MH folder.
321 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER.")
323 (defvar gnus-file-save-name (function gnus-numeric-save-name)
324 "*A function generating a file name to save articles in article format.
325 The function is called with NEWSGROUP, HEADERS, and optional
328 (defvar gnus-split-methods
329 '((gnus-article-archive-name))
330 "*Variable used to suggest where articles are to be saved.
331 For instance, if you would like to save articles related to Gnus in
332 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
333 you could set this variable to something like:
335 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
336 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
338 This variable is an alist where the where the key is the match and the
339 value is a list of possible files to save in if the match is non-nil.
341 If the match is a string, it is used as a regexp match on the
342 article. If the match is a symbol, that symbol will be funcalled
343 from the buffer of the article to be saved with the newsgroup as the
344 parameter. If it is a list, it will be evaled in the same buffer.
346 If this form or function returns a string, this string will be used as
347 a possible file name; and if it returns a non-nil list, that list will
348 be used as possible file names.")
350 (defvar gnus-move-split-methods nil
351 "*Variable used to suggest where articles are to be moved to.
352 It uses the same syntax as the `gnus-split-methods' variable.")
354 (defvar gnus-save-score nil
355 "*If non-nil, save group scoring info.")
357 (defvar gnus-use-adaptive-scoring nil
358 "*If non-nil, use some adaptive scoring scheme.")
360 (defvar gnus-use-cache nil
361 "*If nil, Gnus will ignore the article cache.
362 If `passive', it will allow entering (and reading) articles
363 explicitly entered into the cache. If anything else, use the
364 cache to the full extent of the law.")
366 (defvar gnus-use-trees nil
367 "*If non-nil, display a thread tree buffer.")
369 (defvar gnus-keep-backlog nil
370 "*If non-nil, Gnus will keep read articles for later re-retrieval.
371 If it is a number N, then Gnus will only keep the last N articles
372 read. If it is neither nil nor a number, Gnus will keep all read
373 articles. This is not a good idea.")
375 (defvar gnus-use-nocem nil
376 "*If non-nil, Gnus will read NoCeM cancel messages.")
378 (defvar gnus-use-demon nil
379 "If non-nil, Gnus might use some demons.")
381 (defvar gnus-use-scoring t
382 "*If non-nil, enable scoring.")
384 (defvar gnus-use-picons nil
385 "*If non-nil, display picons.")
387 (defvar gnus-fetch-old-headers nil
388 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
389 If an unread article in the group refers to an older, already read (or
390 just marked as read) article, the old article will not normally be
391 displayed in the Summary buffer. If this variable is non-nil, Gnus
392 will attempt to grab the headers to the old articles, and thereby
393 build complete threads. If it has the value `some', only enough
394 headers to connect otherwise loose threads will be displayed.
395 This variable can also be a number. In that case, no more than that
396 number of old headers will be fetched.
398 The server has to support NOV for any of this to work.")
401 ;(defvar gnus-visual t
402 ; "*If non-nil, will do various highlighting.
403 ;If nil, no mouse highlights (or any other highlights) will be
404 ;performed. This might speed up Gnus some when generating large group
405 ;and summary buffers.")
407 (defvar gnus-novice-user t
408 "*Non-nil means that you are a usenet novice.
409 If non-nil, verbose messages may be displayed and confirmations may be
412 (defvar gnus-expert-user nil
413 "*Non-nil means that you will never be asked for confirmation about anything.
414 And that means *anything*.")
416 (defvar gnus-verbose 7
417 "*Integer that says how verbose Gnus should be.
418 The higher the number, the more messages Gnus will flash to say what
419 it's doing. At zero, Gnus will be totally mute; at five, Gnus will
420 display most important messages; and at ten, Gnus will keep on
421 jabbering all the time.")
423 (defvar gnus-keep-same-level nil
424 "*Non-nil means that the next newsgroup after the current will be on the same level.
425 When you type, for instance, `n' after reading the last article in the
426 current newsgroup, you will go to the next newsgroup. If this variable
427 is nil, the next newsgroup will be the next from the group
429 If this variable is non-nil, Gnus will either put you in the
430 next newsgroup with the same level, or, if no such newsgroup is
431 available, the next newsgroup with the lowest possible level higher
432 than the current level.
433 If this variable is `best', Gnus will make the next newsgroup the one
434 with the best level.")
436 (defvar gnus-summary-make-false-root 'adopt
437 "*nil means that Gnus won't gather loose threads.
438 If the root of a thread has expired or been read in a previous
439 session, the information necessary to build a complete thread has been
440 lost. Instead of having many small sub-threads from this original thread
441 scattered all over the summary buffer, Gnus can gather them.
443 If non-nil, Gnus will try to gather all loose sub-threads from an
444 original thread into one large thread.
446 If this variable is non-nil, it should be one of `none', `adopt',
449 If this variable is `none', Gnus will not make a false root, but just
450 present the sub-threads after another.
451 If this variable is `dummy', Gnus will create a dummy root that will
452 have all the sub-threads as children.
453 If this variable is `adopt', Gnus will make one of the \"children\"
454 the parent and mark all the step-children as such.
455 If this variable is `empty', the \"children\" are printed with empty
456 subject fields. (Or rather, they will be printed with a string
457 given by the `gnus-summary-same-subject' variable.)")
459 (defvar gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
460 "*A regexp to match subjects to be excluded from loose thread gathering.
461 As loose thread gathering is done on subjects only, that means that
462 there can be many false gatherings performed. By rooting out certain
463 common subjects, gathering might become saner.")
465 (defvar gnus-summary-gather-subject-limit nil
466 "*Maximum length of subject comparisons when gathering loose threads.
467 Use nil to compare full subjects. Setting this variable to a low
468 number will help gather threads that have been corrupted by
469 newsreaders chopping off subject lines, but it might also mean that
470 unrelated articles that have subject that happen to begin with the
471 same few characters will be incorrectly gathered.
473 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
474 comparing subjects.")
476 (defvar gnus-simplify-ignored-prefixes nil
477 "*Regexp, matches for which are removed from subject lines when simplifying.")
479 (defvar gnus-build-sparse-threads nil
480 "*If non-nil, fill in the gaps in threads.
481 If `some', only fill in the gaps that are needed to tie loose threads
482 together. If `more', fill in all leaf nodes that Gnus can find. If
483 non-nil and non-`some', fill in all gaps that Gnus manages to guess.")
485 (defvar gnus-summary-thread-gathering-function 'gnus-gather-threads-by-subject
486 "Function used for gathering loose threads.
487 There are two pre-defined functions: `gnus-gather-threads-by-subject',
488 which only takes Subjects into consideration; and
489 `gnus-gather-threads-by-references', which compared the References
490 headers of the articles to find matches.")
492 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
493 (defvar gnus-summary-same-subject ""
494 "*String indicating that the current article has the same subject as the previous.
495 This variable will only be used if the value of
496 `gnus-summary-make-false-root' is `empty'.")
498 (defvar gnus-summary-goto-unread t
499 "*If non-nil, marking commands will go to the next unread article.
500 If `never', \\<gnus-summary-mode-map>\\[gnus-summary-next-page] will go to the next article,
501 whether it is read or not.")
503 (defvar gnus-group-goto-unread t
504 "*If non-nil, movement commands will go to the next unread and subscribed group.")
506 (defvar gnus-goto-next-group-when-activating t
507 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group.")
509 (defvar gnus-check-new-newsgroups t
510 "*Non-nil means that Gnus will add new newsgroups at startup.
511 If this variable is `ask-server', Gnus will ask the server for new
512 groups since the last time it checked. This means that the killed list
513 is no longer necessary, so you could set `gnus-save-killed-list' to
516 A variant is to have this variable be a list of select methods. Gnus
517 will then use the `ask-server' method on all these select methods to
518 query for new groups from all those servers.
521 (setq gnus-check-new-newsgroups
522 '((nntp \"some.server\") (nntp \"other.server\")))
524 If this variable is nil, then you have to tell Gnus explicitly to
525 check for new newsgroups with \\<gnus-group-mode-map>\\[gnus-find-new-newsgroups].")
527 (defvar gnus-check-bogus-newsgroups nil
528 "*Non-nil means that Gnus will check and remove bogus newsgroup at startup.
529 If this variable is nil, then you have to tell Gnus explicitly to
530 check for bogus newsgroups with \\<gnus-group-mode-map>\\[gnus-group-check-bogus-groups].")
532 (defvar gnus-read-active-file t
533 "*Non-nil means that Gnus will read the entire active file at startup.
534 If this variable is nil, Gnus will only know about the groups in your
537 If this variable is `some', Gnus will try to only read the relevant
538 parts of the active file from the server. Not all servers support
539 this, and it might be quite slow with other servers, but this should
540 generally be faster than both the t and nil value.
542 If you set this variable to nil or `some', you probably still want to
543 be told about new newsgroups that arrive. To do that, set
544 `gnus-check-new-newsgroups' to `ask-server'. This may not work
545 properly with all servers.")
547 (defvar gnus-level-subscribed 5
548 "*Groups with levels less than or equal to this variable are subscribed.")
550 (defvar gnus-level-unsubscribed 7
551 "*Groups with levels less than or equal to this variable are unsubscribed.
552 Groups with levels less than `gnus-level-subscribed', which should be
553 less than this variable, are subscribed.")
555 (defvar gnus-level-zombie 8
556 "*Groups with this level are zombie groups.")
558 (defvar gnus-level-killed 9
559 "*Groups with this level are killed.")
561 (defvar gnus-level-default-subscribed 3
562 "*New subscribed groups will be subscribed at this level.")
564 (defvar gnus-level-default-unsubscribed 6
565 "*New unsubscribed groups will be unsubscribed at this level.")
567 (defvar gnus-activate-level (1+ gnus-level-subscribed)
568 "*Groups higher than this level won't be activated on startup.
569 Setting this variable to something log might save lots of time when
570 you have many groups that you aren't interested in.")
572 (defvar gnus-activate-foreign-newsgroups 4
573 "*If nil, Gnus will not check foreign newsgroups at startup.
574 If it is non-nil, it should be a number between one and nine. Foreign
575 newsgroups that have a level lower or equal to this number will be
576 activated on startup. For instance, if you want to active all
577 subscribed newsgroups, but not the rest, you'd set this variable to
578 `gnus-level-subscribed'.
580 If you subscribe to lots of newsgroups from different servers, startup
581 might take a while. By setting this variable to nil, you'll save time,
582 but you won't be told how many unread articles there are in the
585 (defvar gnus-save-newsrc-file t
586 "*Non-nil means that Gnus will save the `.newsrc' file.
587 Gnus always saves its own startup file, which is called
588 \".newsrc.eld\". The file called \".newsrc\" is in a format that can
589 be readily understood by other newsreaders. If you don't plan on
590 using other newsreaders, set this variable to nil to save some time on
593 (defvar gnus-save-killed-list t
594 "*If non-nil, save the list of killed groups to the startup file.
595 If you set this variable to nil, you'll save both time (when starting
596 and quitting) and space (both memory and disk), but it will also mean
597 that Gnus has no record of which groups are new and which are old, so
598 the automatic new newsgroups subscription methods become meaningless.
600 You should always set `gnus-check-new-newsgroups' to `ask-server' or
601 nil if you set this variable to nil.")
603 (defvar gnus-interactive-catchup t
604 "*If non-nil, require your confirmation when catching up a group.")
606 (defvar gnus-interactive-post t
607 "*If non-nil, group name will be asked for when posting.")
609 (defvar gnus-interactive-exit t
610 "*If non-nil, require your confirmation when exiting Gnus.")
612 (defvar gnus-kill-killed t
613 "*If non-nil, Gnus will apply kill files to already killed articles.
614 If it is nil, Gnus will never apply kill files to articles that have
615 already been through the scoring process, which might very well save lots
618 (defvar gnus-extract-address-components 'gnus-extract-address-components
619 "*Function for extracting address components from a From header.
620 Two pre-defined function exist: `gnus-extract-address-components',
621 which is the default, quite fast, and too simplistic solution, and
622 `mail-extract-address-components', which works much better, but is
625 (defvar gnus-summary-default-score 0
626 "*Default article score level.
627 If this variable is nil, scoring will be disabled.")
629 (defvar gnus-summary-zcore-fuzz 0
630 "*Fuzziness factor for the zcore in the summary buffer.
631 Articles with scores closer than this to `gnus-summary-default-score'
632 will not be marked.")
634 (defvar gnus-simplify-subject-fuzzy-regexp nil
635 "*Strings to be removed when doing fuzzy matches.
636 This can either be a regular expression or list of regular expressions
637 that will be removed from subject strings if fuzzy subject
638 simplification is selected.")
640 (defvar gnus-permanently-visible-groups nil
641 "*Regexp to match groups that should always be listed in the group buffer.
642 This means that they will still be listed when there are no unread
643 articles in the groups.")
645 (defvar gnus-list-groups-with-ticked-articles t
646 "*If non-nil, list groups that have only ticked articles.
647 If nil, only list groups that have unread articles.")
649 (defvar gnus-group-default-list-level gnus-level-subscribed
650 "*Default listing level.
651 Ignored if `gnus-group-use-permanent-levels' is non-nil.")
653 (defvar gnus-group-use-permanent-levels nil
654 "*If non-nil, once you set a level, Gnus will use this level.")
656 (defvar gnus-group-list-inactive-groups t
657 "*If non-nil, inactive groups will be listed.")
659 (defvar gnus-show-mime nil
660 "*If non-nil, do mime processing of articles.
661 The articles will simply be fed to the function given by
662 `gnus-show-mime-method'.")
664 (defvar gnus-strict-mime t
665 "*If nil, MIME-decode even if there is no Mime-Version header in the article.")
667 (defvar gnus-show-mime-method 'metamail-buffer
668 "*Function to process a MIME message.
669 The function is called from the article buffer.")
671 (defvar gnus-decode-encoded-word-method (lambda ())
672 "*Function to decode a MIME encoded-words.
673 The function is called from the article buffer.")
675 (defvar gnus-show-threads t
676 "*If non-nil, display threads in summary mode.")
678 (defvar gnus-thread-hide-subtree nil
679 "*If non-nil, hide all threads initially.
680 If threads are hidden, you have to run the command
681 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
682 to expose hidden threads.")
684 (defvar gnus-thread-hide-killed t
685 "*If non-nil, hide killed threads automatically.")
687 (defvar gnus-thread-ignore-subject nil
688 "*If non-nil, ignore subjects and do all threading based on the Reference header.
689 If nil, which is the default, articles that have different subjects
690 from their parents will start separate threads.")
692 (defvar gnus-thread-operation-ignore-subject t
693 "*If non-nil, subjects will be ignored when doing thread commands.
694 This affects commands like `gnus-summary-kill-thread' and
695 `gnus-summary-lower-thread'.
697 If this variable is nil, articles in the same thread with different
698 subjects will not be included in the operation in question. If this
699 variable is `fuzzy', only articles that have subjects that are fuzzily
700 equal will be included.")
702 (defvar gnus-thread-indent-level 4
703 "*Number that says how much each sub-thread should be indented.")
705 (defvar gnus-ignored-newsgroups
706 (purecopy (mapconcat 'identity
707 '("^to\\." ; not "real" groups
708 "^[0-9. \t]+ " ; all digits in name
709 "[][\"#'()]" ; bogus characters
712 "*A regexp to match uninteresting newsgroups in the active file.
713 Any lines in the active file matching this regular expression are
714 removed from the newsgroup list before anything else is done to it,
715 thus making them effectively non-existent.")
717 (defvar gnus-ignored-headers
718 "^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:"
719 "*All headers that match this regexp will be hidden.
720 This variable can also be a list of regexps of headers to be ignored.
721 If `gnus-visible-headers' is non-nil, this variable will be ignored.")
723 (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-"
724 "*All headers that do not match this regexp will be hidden.
725 This variable can also be a list of regexp of headers to remain visible.
726 If this variable is non-nil, `gnus-ignored-headers' will be ignored.")
728 (defvar gnus-sorted-header-list
729 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^To:"
730 "^Cc:" "^Date:" "^Organization:")
731 "*This variable is a list of regular expressions.
732 If it is non-nil, headers that match the regular expressions will
733 be placed first in the article buffer in the sequence specified by
736 (defvar gnus-boring-article-headers
737 '(empty followup-to reply-to)
738 "*Headers that are only to be displayed if they have interesting data.
739 Possible values in this list are `empty', `newsgroups', `followup-to',
740 `reply-to', and `date'.")
742 (defvar gnus-show-all-headers nil
743 "*If non-nil, don't hide any headers.")
745 (defvar gnus-save-all-headers t
746 "*If non-nil, don't remove any headers before saving.")
748 (defvar gnus-saved-headers gnus-visible-headers
749 "*Headers to keep if `gnus-save-all-headers' is nil.
750 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
751 If that variable is nil, however, all headers that match this regexp
752 will be kept while the rest will be deleted before saving.")
754 (defvar gnus-inhibit-startup-message nil
755 "*If non-nil, the startup message will not be displayed.")
757 (defvar gnus-signature-separator "^-- *$"
758 "Regexp matching signature separator.")
760 (defvar gnus-auto-extend-newsgroup t
761 "*If non-nil, extend newsgroup forward and backward when requested.")
763 (defvar gnus-auto-select-first t
764 "*If nil, don't select the first unread article when entering a group.
765 If this variable is `best', select the highest-scored unread article
766 in the group. If neither nil nor `best', select the first unread
769 If you want to prevent automatic selection of the first unread article
770 in some newsgroups, set the variable to nil in
771 `gnus-select-group-hook'.")
773 (defvar gnus-auto-select-next t
774 "*If non-nil, offer to go to the next group from the end of the previous.
775 If the value is t and the next newsgroup is empty, Gnus will exit
776 summary mode and go back to group mode. If the value is neither nil
777 nor t, Gnus will select the following unread newsgroup. In
778 particular, if the value is the symbol `quietly', the next unread
779 newsgroup will be selected without any confirmation, and if it is
780 `almost-quietly', the next group will be selected without any
781 confirmation if you are located on the last article in the group.
782 Finally, if this variable is `slightly-quietly', the `Z n' command
783 will go to the next group without confirmation.")
785 (defvar gnus-auto-select-same nil
786 "*If non-nil, select the next article with the same subject.")
788 (defvar gnus-summary-check-current nil
789 "*If non-nil, consider the current article when moving.
790 The \"unread\" movement commands will stay on the same line if the
791 current article is unread.")
793 (defvar gnus-auto-center-summary t
794 "*If non-nil, always center the current summary buffer.")
796 (defvar gnus-break-pages t
797 "*If non-nil, do page breaking on articles.
798 The page delimiter is specified by the `gnus-page-delimiter'
801 (defvar gnus-page-delimiter "^\^L"
802 "*Regexp describing what to use as article page delimiters.
803 The default value is \"^\^L\", which is a form linefeed at the
804 beginning of a line.")
806 (defvar gnus-use-full-window t
807 "*If non-nil, use the entire Emacs screen.")
809 (defvar gnus-window-configuration nil
810 "Obsolete variable. See `gnus-buffer-configuration'.")
812 (defvar gnus-window-min-width 2
813 "*Minimum width of Gnus buffers.")
815 (defvar gnus-window-min-height 1
816 "*Minimum height of Gnus buffers.")
818 (defvar gnus-buffer-configuration
822 (if gnus-carpal '(group-carpal 4))))
826 (if gnus-carpal '(summary-carpal 4))))
833 (if gnus-carpal '(summary-carpal 4))
835 (vertical ((height . 5) (width . 15)
837 (left . -1) (top . 1))
847 (if gnus-carpal '(summary-carpal 4))
848 (if gnus-use-trees '(tree 0.25))
853 (if gnus-carpal '(server-carpal 2))))
857 (if gnus-carpal '(browse-carpal 2))))
870 (article 1.0 point)))
881 (edit-group 1.0 point)))
885 (edit-server 1.0 point)))
889 (edit-score 1.0 point)))
916 (if gnus-carpal '(summary-carpal 4))
917 ("*Shell Command Output*" 1.0)))
925 "Window configuration for all possible Gnus buffers.
926 This variable is a list of lists. Each of these lists has a NAME and
927 a RULE. The NAMEs are commonsense names like `group', which names a
928 rule used when displaying the group buffer; `summary', which names a
929 rule for what happens when you enter a group and do not display an
930 article buffer; and so on. See the value of this variable for a
931 complete list of NAMEs.
933 Each RULE is a list of vectors. The first element in this vector is
934 the name of the buffer to be displayed; the second element is the
935 percentage of the screen this buffer is to occupy (a number in the
936 0.0-0.99 range); the optional third element is `point', which should
937 be present to denote which buffer point is to go to after making this
938 buffer configuration.")
940 (defvar gnus-window-to-buffer
941 '((group . gnus-group-buffer)
942 (summary . gnus-summary-buffer)
943 (article . gnus-article-buffer)
944 (server . gnus-server-buffer)
945 (browse . "*Gnus Browse Server*")
946 (edit-group . gnus-group-edit-buffer)
947 (edit-server . gnus-server-edit-buffer)
948 (group-carpal . gnus-carpal-group-buffer)
949 (summary-carpal . gnus-carpal-summary-buffer)
950 (server-carpal . gnus-carpal-server-buffer)
951 (browse-carpal . gnus-carpal-browse-buffer)
952 (edit-score . gnus-score-edit-buffer)
953 (mail . gnus-mail-buffer)
954 (post . gnus-post-news-buffer)
955 (faq . gnus-faq-buffer)
956 (picons . "*Picons*")
957 (tree . gnus-tree-buffer)
958 (info . gnus-info-buffer)
959 (draft . gnus-draft-buffer))
960 "Mapping from short symbols to buffer names or buffer variables.")
962 (defvar gnus-carpal nil
963 "*If non-nil, display clickable icons.")
965 (defvar gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies
966 "*Function called with a group name when new group is detected.
967 A few pre-made functions are supplied: `gnus-subscribe-randomly'
968 inserts new groups at the beginning of the list of groups;
969 `gnus-subscribe-alphabetically' inserts new groups in strict
970 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
971 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
972 for your decision; `gnus-subscribe-killed' kills all new groups.")
974 ;; Suggested by a bug report by Hallvard B Furuseth.
975 ;; <h.b.furuseth@usit.uio.no>.
976 (defvar gnus-subscribe-options-newsgroup-method
977 (function gnus-subscribe-alphabetically)
978 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines.
979 If, for instance, you want to subscribe to all newsgroups in the
980 \"no\" and \"alt\" hierarchies, you'd put the following in your
983 options -n no.all alt.all
985 Gnus will the subscribe all new newsgroups in these hierarchies with
986 the subscription method in this variable.")
988 (defvar gnus-subscribe-hierarchical-interactive nil
989 "*If non-nil, Gnus will offer to subscribe hierarchically.
990 When a new hierarchy appears, Gnus will ask the user:
992 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
994 If the user pressed `d', Gnus will descend the hierarchy, `y' will
995 subscribe to all newsgroups in the hierarchy and `s' will skip this
996 hierarchy in its entirety.")
998 (defvar gnus-group-sort-function 'gnus-group-sort-by-alphabet
999 "*Function used for sorting the group buffer.
1000 This function will be called with group info entries as the arguments
1001 for the groups to be sorted. Pre-made functions include
1002 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-unread',
1003 `gnus-group-sort-by-level', `gnus-group-sort-by-score', and
1004 `gnus-group-sort-by-rank'.
1006 This variable can also be a list of sorting functions. In that case,
1007 the most significant sort function should be the last function in the
1010 ;; Mark variables suggested by Thomas Michanek
1011 ;; <Thomas.Michanek@telelogic.se>.
1012 (defvar gnus-unread-mark ?
1013 "*Mark used for unread articles.")
1014 (defvar gnus-ticked-mark ?!
1015 "*Mark used for ticked articles.")
1016 (defvar gnus-dormant-mark ??
1017 "*Mark used for dormant articles.")
1018 (defvar gnus-del-mark ?r
1019 "*Mark used for del'd articles.")
1020 (defvar gnus-read-mark ?R
1021 "*Mark used for read articles.")
1022 (defvar gnus-expirable-mark ?E
1023 "*Mark used for expirable articles.")
1024 (defvar gnus-killed-mark ?K
1025 "*Mark used for killed articles.")
1026 (defvar gnus-souped-mark ?F
1027 "*Mark used for killed articles.")
1028 (defvar gnus-kill-file-mark ?X
1029 "*Mark used for articles killed by kill files.")
1030 (defvar gnus-low-score-mark ?Y
1031 "*Mark used for articles with a low score.")
1032 (defvar gnus-catchup-mark ?C
1033 "*Mark used for articles that are caught up.")
1034 (defvar gnus-replied-mark ?A
1035 "*Mark used for articles that have been replied to.")
1036 (defvar gnus-cached-mark ?*
1037 "*Mark used for articles that are in the cache.")
1038 (defvar gnus-saved-mark ?S
1039 "*Mark used for articles that have been saved to.")
1040 (defvar gnus-process-mark ?#
1042 (defvar gnus-ancient-mark ?O
1043 "*Mark used for ancient articles.")
1044 (defvar gnus-sparse-mark ?Q
1045 "*Mark used for sparsely reffed articles.")
1046 (defvar gnus-canceled-mark ?G
1047 "*Mark used for canceled articles.")
1048 (defvar gnus-score-over-mark ?+
1049 "*Score mark used for articles with high scores.")
1050 (defvar gnus-score-below-mark ?-
1051 "*Score mark used for articles with low scores.")
1052 (defvar gnus-empty-thread-mark ?
1053 "*There is no thread under the article.")
1054 (defvar gnus-not-empty-thread-mark ?=
1055 "*There is a thread under the article.")
1057 (defvar gnus-view-pseudo-asynchronously nil
1058 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
1060 (defvar gnus-view-pseudos nil
1061 "*If `automatic', pseudo-articles will be viewed automatically.
1062 If `not-confirm', pseudos will be viewed automatically, and the user
1063 will not be asked to confirm the command.")
1065 (defvar gnus-view-pseudos-separately t
1066 "*If non-nil, one pseudo-article will be created for each file to be viewed.
1067 If nil, all files that use the same viewing command will be given as a
1068 list of parameters to that command.")
1070 (defvar gnus-insert-pseudo-articles t
1071 "*If non-nil, insert pseudo-articles when decoding articles.")
1073 (defvar gnus-group-line-format "%M%S%p%P%5y: %(%g%)\n"
1074 "*Format of group lines.
1075 It works along the same lines as a normal formatting string,
1076 with some simple extensions.
1078 %M Only marked articles (character, \"*\" or \" \")
1079 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
1080 %L Level of subscribedness (integer)
1081 %N Number of unread articles (integer)
1082 %I Number of dormant articles (integer)
1083 %i Number of ticked and dormant (integer)
1084 %T Number of ticked articles (integer)
1085 %R Number of read articles (integer)
1086 %t Total number of articles (integer)
1087 %y Number of unread, unticked articles (integer)
1088 %G Group name (string)
1089 %g Qualified group name (string)
1090 %D Group description (string)
1091 %s Select method (string)
1092 %o Moderated group (char, \"m\")
1093 %p Process mark (char)
1094 %O Moderated group (string, \"(m)\" or \"\")
1095 %P Topic indentation (string)
1096 %n Select from where (string)
1097 %z A string that look like `<%s:%n>' if a foreign select method is used
1098 %u User defined specifier. The next character in the format string should
1099 be a letter. Gnus will call the function gnus-user-format-function-X,
1100 where X is the letter following %u. The function will be passed the
1101 current header as argument. The function should return a string, which
1102 will be inserted into the buffer just like information from any other
1105 Text between %( and %) will be highlighted with `gnus-mouse-face' when
1106 the mouse point move inside the area. There can only be one such area.
1108 Note that this format specification is not always respected. For
1109 reasons of efficiency, when listing killed groups, this specification
1110 is ignored altogether. If the spec is changed considerably, your
1111 output may end up looking strange when listing both alive and killed
1114 If you use %o or %O, reading the active file will be slower and quite
1115 a bit of extra memory will be used. %D will also worsen performance.
1116 Also note that if you change the format specification to include any
1117 of these specs, you must probably re-start Gnus to see them go into
1120 (defvar gnus-summary-line-format "%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n"
1121 "*The format specification of the lines in the summary buffer.
1123 It works along the same lines as a normal formatting string,
1124 with some simple extensions.
1126 %N Article number, left padded with spaces (string)
1128 %s Subject if it is at the root of a thread, and \"\" otherwise (string)
1129 %n Name of the poster (string)
1130 %a Extracted name of the poster (string)
1131 %A Extracted address of the poster (string)
1132 %F Contents of the From: header (string)
1133 %x Contents of the Xref: header (string)
1134 %D Date of the article (string)
1135 %d Date of the article (string) in DD-MMM format
1136 %M Message-id of the article (string)
1137 %r References of the article (string)
1138 %c Number of characters in the article (integer)
1139 %L Number of lines in the article (integer)
1140 %I Indentation based on thread level (a string of spaces)
1141 %T A string with two possible values: 80 spaces if the article
1142 is on thread level two or larger and 0 spaces on level one
1143 %R \"A\" if this article has been replied to, \" \" otherwise (character)
1144 %U Status of this article (character, \"R\", \"K\", \"-\" or \" \")
1145 %[ Opening bracket (character, \"[\" or \"<\")
1146 %] Closing bracket (character, \"]\" or \">\")
1147 %> Spaces of length thread-level (string)
1148 %< Spaces of length (- 20 thread-level) (string)
1149 %i Article score (number)
1150 %z Article zcore (character)
1151 %t Number of articles under the current thread (number).
1152 %e Whether the thread is empty or not (character).
1153 %u User defined specifier. The next character in the format string should
1154 be a letter. Gnus will call the function gnus-user-format-function-X,
1155 where X is the letter following %u. The function will be passed the
1156 current header as argument. The function should return a string, which
1157 will be inserted into the summary just like information from any other
1160 Text between %( and %) will be highlighted with `gnus-mouse-face'
1161 when the mouse point is placed inside the area. There can only be one
1164 The %U (status), %R (replied) and %z (zcore) specs have to be handled
1165 with care. For reasons of efficiency, Gnus will compute what column
1166 these characters will end up in, and \"hard-code\" that. This means that
1167 it is illegal to have these specs after a variable-length spec. Well,
1168 you might not be arrested, but your summary buffer will look strange,
1169 which is bad enough.
1171 The smart choice is to have these specs as for to the left as
1174 This restriction may disappear in later versions of Gnus.")
1176 (defvar gnus-summary-dummy-line-format
1178 "*The format specification for the dummy roots in the summary buffer.
1179 It works along the same lines as a normal formatting string,
1180 with some simple extensions.
1184 (defvar gnus-summary-mode-line-format "Gnus: %%b [%A] %Z"
1185 "*The format specification for the summary mode line.
1186 It works along the same lines as a normal formatting string,
1187 with some simple extensions:
1190 %p Unprefixed group name
1191 %A Current article number
1193 %U Number of unread articles in the group
1194 %e Number of unselected articles in the group
1195 %Z A string with unread/unselected article counts
1196 %g Shortish group name
1197 %S Subject of the current article
1198 %u User-defined spec
1199 %s Current score file name
1200 %d Number of dormant articles
1201 %r Number of articles that have been marked as read in this session
1202 %E Number of articles expunged by the score files")
1204 (defvar gnus-article-mode-line-format "Gnus: %%b %S"
1205 "*The format specification for the article mode line.
1206 See `gnus-summary-mode-line-format' for a closer description.")
1208 (defvar gnus-group-mode-line-format "Gnus: %%b {%M:%S}"
1209 "*The format specification for the group mode line.
1210 It works along the same lines as a normal formatting string,
1211 with some simple extensions:
1213 %S The native news server.
1214 %M The native select method.")
1216 (defvar gnus-valid-select-methods
1217 '(("nntp" post address prompt-address)
1218 ("nnspool" post address)
1219 ("nnvirtual" post-mail virtual prompt-address)
1220 ("nnmbox" mail respool address)
1221 ("nnml" mail respool address)
1222 ("nnmh" mail respool address)
1223 ("nndir" post-mail prompt-address address)
1224 ("nneething" none address prompt-address)
1225 ("nndoc" none address prompt-address)
1226 ("nnbabyl" mail address respool)
1227 ("nnkiboze" post address virtual)
1228 ("nnsoup" post-mail address)
1229 ("nnfolder" mail respool address))
1230 "An alist of valid select methods.
1231 The first element of each list lists should be a string with the name
1232 of the select method. The other elements may be be the category of
1233 this method (ie. `post', `mail', `none' or whatever) or other
1234 properties that this method has (like being respoolable).
1235 If you implement a new select method, all you should have to change is
1236 this variable. I think.")
1238 (defvar gnus-updated-mode-lines '(group article summary tree)
1239 "*List of buffers that should update their mode lines.
1240 The list may contain the symbols `group', `article' and `summary'. If
1241 the corresponding symbol is present, Gnus will keep that mode line
1242 updated with information that may be pertinent.
1243 If this variable is nil, screen refresh may be quicker.")
1245 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>.
1246 (defvar gnus-mode-non-string-length nil
1247 "*Max length of mode-line non-string contents.
1248 If this is nil, Gnus will take space as is needed, leaving the rest
1249 of the modeline intact.")
1252 ;(defvar gnus-mouse-face 'highlight
1253 ; "*Face used for mouse highlighting in Gnus.
1254 ;No mouse highlights will be done if `gnus-visual' is nil.")
1256 (defvar gnus-summary-mark-below nil
1257 "*Mark all articles with a score below this variable as read.
1258 This variable is local to each summary buffer and usually set by the
1261 (defvar gnus-article-sort-functions '(gnus-article-sort-by-number)
1262 "*List of functions used for sorting articles in the summary buffer.
1263 This variable is only used when not using a threaded display.")
1265 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number)
1266 "*List of functions used for sorting threads in the summary buffer.
1267 By default, threads are sorted by article number.
1269 Each function takes two threads and return non-nil if the first thread
1270 should be sorted before the other. If you use more than one function,
1271 the primary sort function should be the last. You should probably
1272 always include `gnus-thread-sort-by-number' in the list of sorting
1273 functions -- preferably first.
1275 Ready-mady functions include `gnus-thread-sort-by-number',
1276 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
1277 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
1278 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').")
1280 (defvar gnus-thread-score-function '+
1281 "*Function used for calculating the total score of a thread.
1283 The function is called with the scores of the article and each
1284 subthread and should then return the score of the thread.
1286 Some functions you can use are `+', `max', or `min'.")
1288 (defvar gnus-summary-expunge-below nil
1289 "All articles that have a score less than this variable will be expunged.")
1291 (defvar gnus-thread-expunge-below nil
1292 "All threads that have a total score less than this variable will be expunged.
1293 See `gnus-thread-score-function' for en explanation of what a
1294 \"thread score\" is.")
1296 (defvar gnus-auto-subscribed-groups
1297 "^nnml\\|^nnfolder\\|^nnmbox\\|^nnmh\\|^nnbabyl"
1298 "*All new groups that match this regexp will be subscribed automatically.
1299 Note that this variable only deals with new groups. It has no effect
1300 whatsoever on old groups.")
1302 (defvar gnus-options-subscribe nil
1303 "*All new groups matching this regexp will be subscribed unconditionally.
1304 Note that this variable deals only with new newsgroups. This variable
1305 does not affect old newsgroups.")
1307 (defvar gnus-options-not-subscribe nil
1308 "*All new groups matching this regexp will be ignored.
1309 Note that this variable deals only with new newsgroups. This variable
1310 does not affect old (already subscribed) newsgroups.")
1312 (defvar gnus-auto-expirable-newsgroups nil
1313 "*Groups in which to automatically mark read articles as expirable.
1314 If non-nil, this should be a regexp that should match all groups in
1315 which to perform auto-expiry. This only makes sense for mail groups.")
1317 (defvar gnus-total-expirable-newsgroups nil
1318 "*Groups in which to perform expiry of all read articles.
1319 Use with extreme caution. All groups that match this regexp will be
1320 expiring - which means that all read articles will be deleted after
1321 (say) one week. (This only goes for mail groups and the like, of
1324 (defvar gnus-group-uncollapsed-levels 1
1325 "Number of group name elements to leave alone when making a short group name.")
1327 (defvar gnus-hidden-properties '(invisible t intangible t)
1328 "Property list to use for hiding text.")
1330 (defvar gnus-modtime-botch nil
1331 "*Non-nil means .newsrc should be deleted prior to save. Its use is
1332 due to the bogus appearance that .newsrc was modified on disc.")
1336 (defvar gnus-group-mode-hook nil
1337 "*A hook for Gnus group mode.")
1339 (defvar gnus-summary-mode-hook nil
1340 "*A hook for Gnus summary mode.
1341 This hook is run before any variables are set in the summary buffer.")
1343 (defvar gnus-article-mode-hook nil
1344 "*A hook for Gnus article mode.")
1346 (defvar gnus-summary-prepare-exit-hook nil
1347 "*A hook called when preparing to exit from the summary buffer.
1348 It calls `gnus-summary-expire-articles' by default.")
1349 (add-hook 'gnus-summary-prepare-exit-hook 'gnus-summary-expire-articles)
1351 (defvar gnus-summary-exit-hook nil
1352 "*A hook called on exit from the summary buffer.")
1354 (defvar gnus-group-catchup-group-hook nil
1355 "*A hook run when catching up a group from the group buffer.")
1357 (defvar gnus-open-server-hook nil
1358 "*A hook called just before opening connection to the news server.")
1360 (defvar gnus-load-hook nil
1361 "*A hook run while Gnus is loaded.")
1363 (defvar gnus-startup-hook nil
1364 "*A hook called at startup.
1365 This hook is called after Gnus is connected to the NNTP server.")
1367 (defvar gnus-get-new-news-hook nil
1368 "*A hook run just before Gnus checks for new news.")
1370 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat
1371 "*A function that is called to generate the group buffer.
1372 The function is called with three arguments: The first is a number;
1373 all group with a level less or equal to that number should be listed,
1374 if the second is non-nil, empty groups should also be displayed. If
1375 the third is non-nil, it is a number. No groups with a level lower
1376 than this number should be displayed.
1378 The only current function implemented is `gnus-group-prepare-flat'.")
1380 (defvar gnus-group-prepare-hook nil
1381 "*A hook called after the group buffer has been generated.
1382 If you want to modify the group buffer, you can use this hook.")
1384 (defvar gnus-summary-prepare-hook nil
1385 "*A hook called after the summary buffer has been generated.
1386 If you want to modify the summary buffer, you can use this hook.")
1388 (defvar gnus-summary-generate-hook nil
1389 "*A hook run just before generating the summary buffer.
1390 This hook is commonly used to customize threading variables and the
1393 (defvar gnus-article-prepare-hook nil
1394 "*A hook called after an article has been prepared in the article buffer.
1395 If you want to run a special decoding program like nkf, use this hook.")
1397 ;(defvar gnus-article-display-hook nil
1398 ; "*A hook called after the article is displayed in the article buffer.
1399 ;The hook is designed to change the contents of the article
1400 ;buffer. Typical functions that this hook may contain are
1401 ;`gnus-article-hide-headers' (hide selected headers),
1402 ;`gnus-article-maybe-highlight' (perform fancy article highlighting),
1403 ;`gnus-article-hide-signature' (hide signature) and
1404 ;`gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).")
1405 ;(add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted)
1406 ;(add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike)
1407 ;(add-hook 'gnus-article-display-hook 'gnus-article-maybe-highlight)
1409 (defvar gnus-article-x-face-command
1410 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | xv -quit -"
1411 "String or function to be executed to display an X-Face header.
1412 If it is a string, the command will be executed in a sub-shell
1413 asynchronously. The compressed face will be piped to this command.")
1415 (defvar gnus-article-x-face-too-ugly nil
1416 "Regexp matching posters whose face shouldn't be shown automatically.")
1418 (defvar gnus-select-group-hook nil
1419 "*A hook called when a newsgroup is selected.
1421 If you'd like to simplify subjects like the
1422 `gnus-summary-next-same-subject' command does, you can use the
1425 (setq gnus-select-group-hook
1428 (mapcar (lambda (header)
1429 (mail-header-set-subject
1431 (gnus-simplify-subject
1432 (mail-header-subject header) 're-only)))
1433 gnus-newsgroup-headers))))")
1435 (defvar gnus-select-article-hook nil
1436 "*A hook called when an article is selected.")
1438 (defvar gnus-apply-kill-hook '(gnus-apply-kill-file)
1439 "*A hook called to apply kill files to a group.
1440 This hook is intended to apply a kill file to the selected newsgroup.
1441 The function `gnus-apply-kill-file' is called by default.
1443 Since a general kill file is too heavy to use only for a few
1444 newsgroups, I recommend you to use a lighter hook function. For
1445 example, if you'd like to apply a kill file to articles which contains
1446 a string `rmgroup' in subject in newsgroup `control', you can use the
1449 (setq gnus-apply-kill-hook
1452 (cond ((string-match \"control\" gnus-newsgroup-name)
1453 (gnus-kill \"Subject\" \"rmgroup\")
1454 (gnus-expunge \"X\"))))))")
1456 (defvar gnus-visual-mark-article-hook
1457 (list 'gnus-highlight-selected-summary)
1458 "*Hook run after selecting an article in the summary buffer.
1459 It is meant to be used for highlighting the article in some way. It
1460 is not run if `gnus-visual' is nil.")
1462 (defvar gnus-parse-headers-hook nil
1463 "*A hook called before parsing the headers.")
1465 (defvar gnus-exit-group-hook nil
1466 "*A hook called when exiting (not quitting) summary mode.")
1468 (defvar gnus-suspend-gnus-hook nil
1469 "*A hook called when suspending (not exiting) Gnus.")
1471 (defvar gnus-exit-gnus-hook nil
1472 "*A hook called when exiting Gnus.")
1474 (defvar gnus-after-exiting-gnus-hook nil
1475 "*A hook called after exiting Gnus.")
1477 (defvar gnus-save-newsrc-hook nil
1478 "*A hook called before saving any of the newsrc files.")
1480 (defvar gnus-save-quick-newsrc-hook nil
1481 "*A hook called just before saving the quick newsrc file.
1482 Can be used to turn version control on or off.")
1484 (defvar gnus-save-standard-newsrc-hook nil
1485 "*A hook called just before saving the standard newsrc file.
1486 Can be used to turn version control on or off.")
1488 (defvar gnus-summary-update-hook
1489 (list 'gnus-summary-highlight-line)
1490 "*A hook called when a summary line is changed.
1491 The hook will not be called if `gnus-visual' is nil.
1493 The default function `gnus-summary-highlight-line' will
1494 highlight the line according to the `gnus-summary-highlight'
1497 (defvar gnus-group-update-hook '(gnus-group-highlight-line)
1498 "*A hook called when a group line is changed.
1499 The hook will not be called if `gnus-visual' is nil.
1501 The default function `gnus-group-highlight-line' will
1502 highlight the line according to the `gnus-group-highlight'
1505 (defvar gnus-mark-article-hook (list 'gnus-summary-mark-unread-as-read)
1506 "*A hook called when an article is selected for the first time.
1507 The hook is intended to mark an article as read (or unread)
1508 automatically when it is selected.")
1510 (defvar gnus-group-change-level-function nil
1511 "Function run when a group level is changed.
1512 It is called with three parameters -- GROUP, LEVEL and OLDLEVEL.")
1514 ;; Remove any hilit infestation.
1515 (add-hook 'gnus-startup-hook
1517 (remove-hook 'gnus-summary-prepare-hook
1518 'hilit-rehighlight-buffer-quietly)
1519 (remove-hook 'gnus-summary-prepare-hook 'hilit-install-line-hooks)
1520 (setq gnus-mark-article-hook '(gnus-summary-mark-unread-as-read))
1521 (remove-hook 'gnus-article-prepare-hook
1522 'hilit-rehighlight-buffer-quietly)))
1525 ;; Internal variables
1527 (defvar gnus-server-alist nil
1528 "List of available servers.")
1530 (defvar gnus-topic-indentation "") ;; Obsolete variable.
1532 (defvar gnus-goto-missing-group-function nil)
1534 (defvar gnus-override-subscribe-method nil)
1536 (defvar gnus-group-goto-next-group-function nil
1537 "Function to override finding the next group after listing groups.")
1539 (defconst gnus-article-mark-lists
1540 '((marked . tick) (replied . reply)
1541 (expirable . expire) (killed . killed)
1542 (bookmarks . bookmark) (dormant . dormant)
1543 (scored . score) (saved . save)
1547 ;; Avoid highlighting in kill files.
1548 (defvar gnus-summary-inhibit-highlight nil)
1549 (defvar gnus-newsgroup-selected-overlay nil)
1551 (defvar gnus-inhibit-hiding nil)
1552 (defvar gnus-group-indentation "")
1553 (defvar gnus-inhibit-limiting nil)
1555 (defvar gnus-article-mode-map nil)
1556 (defvar gnus-dribble-buffer nil)
1557 (defvar gnus-headers-retrieved-by nil)
1558 (defvar gnus-article-reply nil)
1559 (defvar gnus-override-method nil)
1560 (defvar gnus-article-check-size nil)
1562 (defvar gnus-current-score-file nil)
1563 (defvar gnus-newsgroup-adaptive-score-file nil)
1564 (defvar gnus-scores-exclude-files nil)
1566 (defvar gnus-opened-servers nil)
1568 (defvar gnus-current-move-group nil)
1570 (defvar gnus-newsgroup-dependencies nil)
1571 (defvar gnus-newsgroup-async nil)
1572 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*")
1574 (defvar gnus-newsgroup-adaptive nil)
1576 (defvar gnus-summary-display-table nil)
1577 (defvar gnus-summary-display-article-function nil)
1579 (defvar gnus-summary-highlight-line-function nil
1580 "Function called after highlighting a summary line.")
1582 (defvar gnus-group-line-format-alist
1583 `((?M gnus-tmp-marked-mark ?c)
1584 (?S gnus-tmp-subscribed ?c)
1585 (?L gnus-tmp-level ?d)
1586 (?N (cond ((eq number t) "*" )
1590 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1591 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
1593 (?R gnus-tmp-number-of-read ?s)
1594 (?t gnus-tmp-number-total ?d)
1595 (?y gnus-tmp-number-of-unread ?s)
1596 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
1597 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
1598 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1599 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
1600 (?g gnus-tmp-group ?s)
1601 (?G gnus-tmp-qualified-group ?s)
1602 (?c (gnus-short-group-name gnus-tmp-group) ?s)
1603 (?D gnus-tmp-newsgroup-description ?s)
1604 (?o gnus-tmp-moderated ?c)
1605 (?O gnus-tmp-moderated-string ?s)
1606 (?p gnus-tmp-process-marked ?c)
1607 (?s gnus-tmp-news-server ?s)
1608 (?n gnus-tmp-news-method ?s)
1609 (?P gnus-group-indentation ?s)
1610 (?z gnus-tmp-news-method-string ?s)
1611 (?u gnus-tmp-user-defined ?s)))
1613 (defvar gnus-summary-line-format-alist
1614 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1615 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1616 (?s gnus-tmp-subject-or-nil ?s)
1617 (?n gnus-tmp-name ?s)
1618 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1620 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1622 (?F gnus-tmp-from ?s)
1623 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1624 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1625 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1626 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1627 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1628 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1629 (?L gnus-tmp-lines ?d)
1630 (?I gnus-tmp-indentation ?s)
1631 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1632 (?R gnus-tmp-replied ?c)
1633 (?\[ gnus-tmp-opening-bracket ?c)
1634 (?\] gnus-tmp-closing-bracket ?c)
1635 (?\> (make-string gnus-tmp-level ? ) ?s)
1636 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1637 (?i gnus-tmp-score ?d)
1638 (?z gnus-tmp-score-char ?c)
1639 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1640 (?U gnus-tmp-unread ?c)
1641 (?t (gnus-summary-number-of-articles-in-thread
1642 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1644 (?e (gnus-summary-number-of-articles-in-thread
1645 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1647 (?u gnus-tmp-user-defined ?s))
1648 "An alist of format specifications that can appear in summary lines,
1649 and what variables they correspond with, along with the type of the
1650 variable (string, integer, character, etc).")
1652 (defvar gnus-summary-dummy-line-format-alist
1653 `((?S gnus-tmp-subject ?s)
1654 (?N gnus-tmp-number ?d)
1655 (?u gnus-tmp-user-defined ?s)))
1657 (defvar gnus-summary-mode-line-format-alist
1658 `((?G gnus-tmp-group-name ?s)
1659 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1660 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1661 (?A gnus-tmp-article-number ?d)
1662 (?Z gnus-tmp-unread-and-unselected ?s)
1663 (?V gnus-version ?s)
1664 (?U gnus-tmp-unread ?d)
1665 (?S gnus-tmp-subject ?s)
1666 (?e gnus-tmp-unselected ?d)
1667 (?u gnus-tmp-user-defined ?s)
1668 (?d (length gnus-newsgroup-dormant) ?d)
1669 (?t (length gnus-newsgroup-marked) ?d)
1670 (?r (length gnus-newsgroup-reads) ?d)
1671 (?E gnus-newsgroup-expunged-tally ?d)
1672 (?s (gnus-current-score-file-nondirectory) ?s)))
1674 (defvar gnus-article-mode-line-format-alist
1675 gnus-summary-mode-line-format-alist)
1677 (defvar gnus-group-mode-line-format-alist
1678 `((?S gnus-tmp-news-server ?s)
1679 (?M gnus-tmp-news-method ?s)
1680 (?u gnus-tmp-user-defined ?s)))
1682 (defvar gnus-have-read-active-file nil)
1684 (defconst gnus-maintainer
1685 "gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls + Boys)"
1686 "The mail address of the Gnus maintainers.")
1688 (defconst gnus-version "September Gnus v0.40"
1689 "Version number for this version of Gnus.")
1691 (defvar gnus-info-nodes
1692 '((gnus-group-mode "(gnus)The Group Buffer")
1693 (gnus-summary-mode "(gnus)The Summary Buffer")
1694 (gnus-article-mode "(gnus)The Article Buffer"))
1695 "Assoc list of major modes and related Info nodes.")
1697 (defvar gnus-group-buffer "*Group*")
1698 (defvar gnus-summary-buffer "*Summary*")
1699 (defvar gnus-article-buffer "*Article*")
1700 (defvar gnus-server-buffer "*Server*")
1702 (defvar gnus-work-buffer " *gnus work*")
1704 (defvar gnus-original-article-buffer " *Original Article*")
1705 (defvar gnus-original-article nil)
1707 (defvar gnus-buffer-list nil
1708 "Gnus buffers that should be killed on exit.")
1710 (defvar gnus-slave nil
1711 "Whether this Gnus is a slave or not.")
1713 (defvar gnus-variable-list
1714 '(gnus-newsrc-options gnus-newsrc-options-n
1715 gnus-newsrc-last-checked-date
1716 gnus-newsrc-alist gnus-server-alist
1717 gnus-killed-list gnus-zombie-list
1718 gnus-topic-topology gnus-topic-alist
1720 "Gnus variables saved in the quick startup file.")
1722 (defvar gnus-newsrc-options nil
1723 "Options line in the .newsrc file.")
1725 (defvar gnus-newsrc-options-n nil
1726 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1728 (defvar gnus-newsrc-last-checked-date nil
1729 "Date Gnus last asked server for new newsgroups.")
1731 (defvar gnus-topic-topology nil
1732 "The complete topic hierarchy.")
1734 (defvar gnus-topic-alist nil
1735 "The complete topic-group alist.")
1737 (defvar gnus-newsrc-alist nil
1738 "Assoc list of read articles.
1739 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1741 (defvar gnus-newsrc-hashtb nil
1742 "Hashtable of gnus-newsrc-alist.")
1744 (defvar gnus-killed-list nil
1745 "List of killed newsgroups.")
1747 (defvar gnus-killed-hashtb nil
1748 "Hash table equivalent of gnus-killed-list.")
1750 (defvar gnus-zombie-list nil
1751 "List of almost dead newsgroups.")
1753 (defvar gnus-description-hashtb nil
1754 "Descriptions of newsgroups.")
1756 (defvar gnus-list-of-killed-groups nil
1757 "List of newsgroups that have recently been killed by the user.")
1759 (defvar gnus-active-hashtb nil
1760 "Hashtable of active articles.")
1762 (defvar gnus-moderated-list nil
1763 "List of moderated newsgroups.")
1765 (defvar gnus-group-marked nil)
1767 (defvar gnus-current-startup-file nil
1768 "Startup file for the current host.")
1770 (defvar gnus-last-search-regexp nil
1771 "Default regexp for article search command.")
1773 (defvar gnus-last-shell-command nil
1774 "Default shell command on article.")
1776 (defvar gnus-current-select-method nil
1777 "The current method for selecting a newsgroup.")
1779 (defvar gnus-group-list-mode nil)
1781 (defvar gnus-article-internal-prepare-hook nil)
1783 (defvar gnus-newsgroup-name nil)
1784 (defvar gnus-newsgroup-begin nil)
1785 (defvar gnus-newsgroup-end nil)
1786 (defvar gnus-newsgroup-last-rmail nil)
1787 (defvar gnus-newsgroup-last-mail nil)
1788 (defvar gnus-newsgroup-last-folder nil)
1789 (defvar gnus-newsgroup-last-file nil)
1790 (defvar gnus-newsgroup-auto-expire nil)
1791 (defvar gnus-newsgroup-active nil)
1793 (defvar gnus-newsgroup-data nil)
1794 (defvar gnus-newsgroup-data-reverse nil)
1795 (defvar gnus-newsgroup-limit nil)
1796 (defvar gnus-newsgroup-limits nil)
1798 (defvar gnus-newsgroup-unreads nil
1799 "List of unread articles in the current newsgroup.")
1801 (defvar gnus-newsgroup-unselected nil
1802 "List of unselected unread articles in the current newsgroup.")
1804 (defvar gnus-newsgroup-reads nil
1805 "Alist of read articles and article marks in the current newsgroup.")
1807 (defvar gnus-newsgroup-expunged-tally nil)
1809 (defvar gnus-newsgroup-marked nil
1810 "List of ticked articles in the current newsgroup (a subset of unread art).")
1812 (defvar gnus-newsgroup-killed nil
1813 "List of ranges of articles that have been through the scoring process.")
1815 (defvar gnus-newsgroup-cached nil
1816 "List of articles that come from the article cache.")
1818 (defvar gnus-newsgroup-saved nil
1819 "List of articles that have been saved.")
1821 (defvar gnus-newsgroup-kill-headers nil)
1823 (defvar gnus-newsgroup-replied nil
1824 "List of articles that have been replied to in the current newsgroup.")
1826 (defvar gnus-newsgroup-expirable nil
1827 "List of articles in the current newsgroup that can be expired.")
1829 (defvar gnus-newsgroup-processable nil
1830 "List of articles in the current newsgroup that can be processed.")
1832 (defvar gnus-newsgroup-bookmarks nil
1833 "List of articles in the current newsgroup that have bookmarks.")
1835 (defvar gnus-newsgroup-dormant nil
1836 "List of dormant articles in the current newsgroup.")
1838 (defvar gnus-newsgroup-scored nil
1839 "List of scored articles in the current newsgroup.")
1841 (defvar gnus-newsgroup-headers nil
1842 "List of article headers in the current newsgroup.")
1844 (defvar gnus-newsgroup-threads nil)
1846 (defvar gnus-newsgroup-prepared nil
1847 "Whether the current group has been prepared properly.")
1849 (defvar gnus-newsgroup-ancient nil
1850 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1852 (defvar gnus-newsgroup-sparse nil)
1854 (defvar gnus-current-article nil)
1855 (defvar gnus-article-current nil)
1856 (defvar gnus-current-headers nil)
1857 (defvar gnus-have-all-headers nil)
1858 (defvar gnus-last-article nil)
1859 (defvar gnus-newsgroup-history nil)
1860 (defvar gnus-current-kill-article nil)
1862 ;; Save window configuration.
1863 (defvar gnus-prev-winconf nil)
1865 (defvar gnus-summary-mark-positions nil)
1866 (defvar gnus-group-mark-positions nil)
1868 (defvar gnus-reffed-article-number nil)
1870 ;;; Let the byte-compiler know that we know about this variable.
1871 (defvar rmail-default-rmail-file)
1873 (defvar gnus-cache-removable-articles nil)
1875 (defvar gnus-dead-summary nil)
1877 (defconst gnus-summary-local-variables
1878 '(gnus-newsgroup-name
1879 gnus-newsgroup-begin gnus-newsgroup-end
1880 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1881 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1882 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1883 gnus-newsgroup-unselected gnus-newsgroup-marked
1884 gnus-newsgroup-reads gnus-newsgroup-saved
1885 gnus-newsgroup-replied gnus-newsgroup-expirable
1886 gnus-newsgroup-processable gnus-newsgroup-killed
1887 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1888 gnus-newsgroup-headers gnus-newsgroup-threads
1889 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1890 gnus-current-article gnus-current-headers gnus-have-all-headers
1891 gnus-last-article gnus-article-internal-prepare-hook
1892 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1893 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1894 gnus-newsgroup-async
1895 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1896 gnus-summary-mark-below gnus-newsgroup-active gnus-scores-exclude-files
1897 gnus-newsgroup-history gnus-newsgroup-ancient
1898 gnus-newsgroup-sparse
1899 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1900 gnus-newsgroup-adaptive-score-file
1901 (gnus-newsgroup-expunged-tally . 0)
1902 gnus-cache-removeable-articles gnus-newsgroup-cached
1903 gnus-newsgroup-data gnus-newsgroup-data-reverse
1904 gnus-newsgroup-limit gnus-newsgroup-limits)
1905 "Variables that are buffer-local to the summary buffers.")
1907 (defconst gnus-bug-message
1908 "Sending a bug report to the Gnus Towers.
1909 ========================================
1911 The buffer below is a mail buffer. When you press `C-c C-c', it will
1912 be sent to the Gnus Bug Exterminators.
1914 At the bottom of the buffer you'll see lots of variable settings.
1915 Please do not delete those. They will tell the Bug People what your
1916 environment is, so that it will be easier to locate the bugs.
1918 If you have found a bug that makes Emacs go \"beep\", set
1919 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
1920 and include the backtrace in your bug report.
1922 Please describe the bug in annoying, painstaking detail.
1924 Thank you for your help in stamping out bugs.
1927 ;;; End of variables.
1929 ;; Define some autoload functions Gnus might use.
1932 ;; This little mapcar goes through the list below and marks the
1933 ;; symbols in question as autoloaded functions.
1936 (let ((interactive (nth 1 (memq ':interactive package))))
1940 (when (consp function)
1941 (setq keymap (car (memq 'keymap function)))
1942 (setq function (car function)))
1943 (autoload function (car package) nil interactive keymap)))
1944 (if (eq (nth 1 package) ':interactive)
1947 '(("metamail" metamail-buffer)
1948 ("info" Info-goto-node)
1949 ("hexl" hexl-hex-string-to-integer)
1950 ("pp" pp pp-to-string pp-eval-expression)
1951 ("mail-extr" mail-extract-address-components)
1952 ("nnmail" nnmail-split-fancy nnmail-article-group)
1953 ("nnvirtual" nnvirtual-catchup-group)
1954 ("timezone" timezone-make-date-arpa-standard timezone-fix-time
1955 timezone-make-sortable-date timezone-make-time-string)
1956 ("sendmail" mail-position-on-field mail-setup)
1957 ("rmailout" rmail-output)
1958 ("rnewspost" news-mail-other-window news-reply-yank-original
1959 news-caesar-buffer-body)
1960 ("rmail" rmail-insert-rmail-file-header rmail-count-new-messages
1962 ("gnus-soup" :interactive t
1963 gnus-group-brew-soup gnus-brew-soup gnus-soup-add-article
1964 gnus-soup-send-replies gnus-soup-save-areas gnus-soup-pack-packet)
1965 ("nnsoup" nnsoup-pack-replies)
1966 ("gnus-mh" gnus-mh-mail-setup gnus-summary-save-article-folder
1967 gnus-Folder-save-name gnus-folder-save-name)
1968 ("gnus-mh" :interactive t gnus-summary-save-in-folder)
1969 ("gnus-vis" gnus-group-make-menu-bar gnus-summary-make-menu-bar
1970 gnus-server-make-menu-bar gnus-article-make-menu-bar
1971 gnus-browse-make-menu-bar gnus-highlight-selected-summary
1972 gnus-summary-highlight-line gnus-carpal-setup-buffer
1973 gnus-group-highlight-line
1974 gnus-article-add-button gnus-insert-next-page-button
1975 gnus-insert-prev-page-button gnus-visual-turn-off-edit-menu)
1976 ("gnus-vis" :interactive t
1977 gnus-article-push-button gnus-article-press-button
1978 gnus-article-highlight gnus-article-highlight-some
1979 gnus-article-highlight-headers gnus-article-highlight-signature
1980 gnus-article-add-buttons gnus-article-add-buttons-to-head
1981 gnus-article-next-button gnus-article-prev-button)
1982 ("gnus-demon" gnus-demon-add-nocem gnus-demon-add-scanmail
1983 gnus-demon-add-disconnection gnus-demon-add-handler
1984 gnus-demon-remove-handler)
1985 ("gnus-demon" :interactive t
1986 gnus-demon-init gnus-demon-cancel)
1987 ("gnus-salt" gnus-highlight-selected-tree gnus-possibly-generate-tree
1988 gnus-tree-open gnus-tree-close)
1989 ("gnus-nocem" gnus-nocem-scan-groups gnus-nocem-close
1990 gnus-nocem-unwanted-article-p)
1991 ("gnus-srvr" gnus-enter-server-buffer gnus-server-set-info)
1992 ("gnus-srvr" gnus-browse-foreign-server)
1993 ("gnus-cite" :interactive t
1994 gnus-article-highlight-citation gnus-article-hide-citation-maybe
1995 gnus-article-hide-citation gnus-article-fill-cited-article)
1996 ("gnus-kill" gnus-kill gnus-apply-kill-file-internal
1997 gnus-kill-file-edit-file gnus-kill-file-raise-followups-to-author
1998 gnus-execute gnus-expunge)
1999 ("gnus-cache" gnus-cache-possibly-enter-article gnus-cache-save-buffers
2000 gnus-cache-possibly-remove-articles gnus-cache-request-article
2001 gnus-cache-retrieve-headers gnus-cache-possibly-alter-active
2002 gnus-cache-enter-remove-article gnus-cached-article-p
2003 gnus-cache-open gnus-cache-close)
2004 ("gnus-cache" :interactive t gnus-jog-cache gnus-cache-enter-article
2005 gnus-cache-remove-article)
2006 ("gnus-score" :interactive t
2007 gnus-summary-increase-score gnus-summary-lower-score
2008 gnus-score-flush-cache gnus-score-close
2009 gnus-score-raise-same-subject-and-select
2010 gnus-score-raise-same-subject gnus-score-default
2011 gnus-score-raise-thread gnus-score-lower-same-subject-and-select
2012 gnus-score-lower-same-subject gnus-score-lower-thread
2013 gnus-possibly-score-headers)
2015 (gnus-summary-score-map keymap) gnus-score-save gnus-score-headers
2016 gnus-current-score-file-nondirectory gnus-score-adaptive
2017 gnus-score-find-trace gnus-score-file-name)
2018 ("gnus-edit" :interactive t gnus-score-customize)
2019 ("gnus-topic" :interactive t gnus-topic-mode)
2020 ("gnus-topic" gnus-topic-remove-group)
2021 ("gnus-salt" :interactive t gnus-pick-mode)
2022 ("gnus-uu" (gnus-uu-extract-map keymap) (gnus-uu-mark-map keymap))
2023 ("gnus-uu" :interactive t
2024 gnus-uu-digest-mail-forward gnus-uu-digest-post-forward
2025 gnus-uu-mark-series gnus-uu-mark-region gnus-uu-mark-buffer
2026 gnus-uu-mark-by-regexp gnus-uu-mark-all
2027 gnus-uu-mark-sparse gnus-uu-mark-thread gnus-uu-decode-uu
2028 gnus-uu-decode-uu-and-save gnus-uu-decode-unshar
2029 gnus-uu-decode-unshar-and-save gnus-uu-decode-save
2030 gnus-uu-decode-binhex gnus-uu-decode-uu-view
2031 gnus-uu-decode-uu-and-save-view gnus-uu-decode-unshar-view
2032 gnus-uu-decode-unshar-and-save-view gnus-uu-decode-save-view
2033 gnus-uu-decode-binhex-view)
2034 ("gnus-msg" (gnus-summary-send-map keymap)
2035 gnus-mail-yank-original gnus-mail-send-and-exit
2036 gnus-sendmail-setup-mail gnus-article-mail
2037 gnus-inews-message-id gnus-new-mail gnus-mail-reply)
2038 ("gnus-msg" :interactive t
2039 gnus-group-post-news gnus-group-mail gnus-summary-post-news
2040 gnus-summary-followup gnus-summary-followup-with-original
2041 gnus-summary-followup-and-reply
2042 gnus-summary-followup-and-reply-with-original
2043 gnus-summary-cancel-article gnus-summary-supersede-article
2044 gnus-post-news gnus-inews-news gnus-cancel-news
2045 gnus-summary-reply gnus-summary-reply-with-original
2046 gnus-summary-mail-forward gnus-summary-mail-other-window
2048 ("gnus-picon" :interactive t gnus-article-display-picons
2049 gnus-group-display-picons gnus-picons-article-display-x-face)
2050 ("gnus-vm" gnus-vm-mail-setup)
2051 ("gnus-vm" :interactive t gnus-summary-save-in-vm
2052 gnus-summary-save-article-vm gnus-yank-article))))
2056 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2057 ;; If you want the cursor to go somewhere else, set these two
2058 ;; functions in some startup hook to whatever you want.
2059 (defalias 'gnus-summary-position-point 'gnus-goto-colon)
2060 (defalias 'gnus-group-position-point 'gnus-goto-colon)
2062 ;;; Various macros and substs.
2064 (defun gnus-header-from (header)
2065 (mail-header-from header))
2067 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
2068 "Pop to BUFFER, evaluate FORMS, and then return to the original window."
2069 `(let ((GnusStartBufferWindow (selected-window)))
2072 (pop-to-buffer ,buffer)
2074 (select-window GnusStartBufferWindow))))
2076 (defmacro gnus-gethash (string hashtable)
2077 "Get hash value of STRING in HASHTABLE."
2078 `(symbol-value (intern-soft ,string ,hashtable)))
2080 (defmacro gnus-sethash (string value hashtable)
2081 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2082 `(set (intern ,string ,hashtable) ,value))
2084 (defmacro gnus-intern-safe (string hashtable)
2085 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2086 `(let ((symbol (intern ,string ,hashtable)))
2091 (defmacro gnus-group-unread (group)
2092 "Get the currently computed number of unread articles in GROUP."
2093 `(car (gnus-gethash ,group gnus-newsrc-hashtb)))
2095 (defmacro gnus-group-entry (group)
2096 "Get the newsrc entry for GROUP."
2097 `(gnus-gethash ,group gnus-newsrc-hashtb))
2099 (defmacro gnus-active (group)
2100 "Get active info on GROUP."
2101 `(gnus-gethash ,group gnus-active-hashtb))
2103 (defmacro gnus-set-active (group active)
2104 "Set GROUP's active info."
2105 `(gnus-sethash ,group ,active gnus-active-hashtb))
2107 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2108 ;; function `substring' might cut on a middle of multi-octet
2110 (defun gnus-truncate-string (str width)
2111 (substring str 0 width))
2113 ;; Added by Geoffrey T. Dairiki <dairiki@u.washington.edu>. A safe way
2114 ;; to limit the length of a string. This function is necessary since
2115 ;; `(substr "abc" 0 30)' pukes with "Args out of range".
2116 (defsubst gnus-limit-string (str width)
2117 (if (> (length str) width)
2118 (substring str 0 width)
2121 (defsubst gnus-simplify-subject-re (subject)
2122 "Remove \"Re:\" from subject lines."
2123 (if (string-match "^[Rr][Ee]: *" subject)
2124 (substring subject (match-end 0))
2127 (defsubst gnus-goto-char (point)
2128 (and point (goto-char point)))
2130 (defmacro gnus-buffer-exists-p (buffer)
2132 (funcall (if (stringp ,buffer) 'get-buffer 'buffer-name)
2135 (defmacro gnus-kill-buffer (buffer)
2136 `(let ((buf ,buffer))
2137 (if (gnus-buffer-exists-p buf)
2138 (kill-buffer buf))))
2140 (defsubst gnus-point-at-bol ()
2141 "Return point at the beginning of the line."
2148 (defsubst gnus-point-at-eol ()
2149 "Return point at the end of the line."
2156 ;; Delete the current line (and the next N lines.);
2157 (defmacro gnus-delete-line (&optional n)
2158 `(delete-region (progn (beginning-of-line) (point))
2159 (progn (forward-line ,(or n 1)) (point))))
2161 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
2162 (defvar gnus-init-inhibit nil)
2163 (defun gnus-read-init-file (&optional inhibit-next)
2164 (if gnus-init-inhibit
2165 (setq gnus-init-inhibit nil)
2166 (setq gnus-init-inhibit inhibit-next)
2168 (or (and (file-exists-p gnus-init-file)
2169 ;; Don't try to load a directory.
2170 (not (file-directory-p gnus-init-file)))
2171 (file-exists-p (concat gnus-init-file ".el"))
2172 (file-exists-p (concat gnus-init-file ".elc")))
2174 (load gnus-init-file nil t)
2176 (error "Error in %s: %s" gnus-init-file var))))))
2178 ;; Info access macros.
2180 (defmacro gnus-info-group (info)
2182 (defmacro gnus-info-rank (info)
2184 (defmacro gnus-info-read (info)
2186 (defmacro gnus-info-marks (info)
2188 (defmacro gnus-info-method (info)
2190 (defmacro gnus-info-params (info)
2193 (defmacro gnus-info-level (info)
2194 `(let ((rank (gnus-info-rank ,info)))
2198 (defmacro gnus-info-score (info)
2199 `(let ((rank (gnus-info-rank ,info)))
2200 (or (and (consp rank) (cdr rank)) 0)))
2202 (defmacro gnus-info-set-group (info group)
2203 `(setcar ,info ,group))
2204 (defmacro gnus-info-set-rank (info rank)
2205 `(setcar (nthcdr 1 ,info) ,rank))
2206 (defmacro gnus-info-set-read (info read)
2207 `(setcar (nthcdr 2 ,info) ,read))
2208 (defmacro gnus-info-set-marks (info marks)
2209 `(setcar (nthcdr 3 ,info) ,marks))
2210 (defmacro gnus-info-set-method (info method)
2211 `(setcar (nthcdr 4 ,info) ,method))
2212 (defmacro gnus-info-set-params (info params)
2213 `(setcar (nthcdr 5 ,info) ,params))
2215 (defmacro gnus-info-set-level (info level)
2216 `(let ((rank (cdr ,info)))
2217 (if (consp (car rank))
2218 (setcar (car rank) ,level)
2219 (setcar rank ,level))))
2220 (defmacro gnus-info-set-score (info score)
2221 `(let ((rank (cdr ,info)))
2222 (if (consp (car rank))
2223 (setcdr (car rank) ,score)
2224 (setcar rank (cons (car rank) ,score)))))
2226 (defmacro gnus-get-info (group)
2227 `(nth 2 (gnus-gethash ,group gnus-newsrc-hashtb)))
2229 (defun gnus-byte-code (func)
2230 "Return a form that can be `eval'ed based on FUNC."
2231 (let ((fval (symbol-function func)))
2232 (if (byte-code-function-p fval)
2233 (let ((flist (append fval nil)))
2234 (setcar flist 'byte-code)
2236 (cons 'progn (cddr fval)))))
2238 ;;; Load the compatability functions.
2245 ;; Format specs. The chunks below are the machine-generated forms
2246 ;; that are to be evaled as the result of the default format strings.
2247 ;; We write them in here to get them byte-compiled. That way the
2248 ;; default actions will be quite fast, while still retaining the full
2249 ;; flexibility of the user-defined format specs.
2251 ;; First we have lots of dummy defvars to let the compiler know these
2252 ;; are really dynamic variables.
2254 (defvar gnus-tmp-unread)
2255 (defvar gnus-tmp-replied)
2256 (defvar gnus-tmp-score-char)
2257 (defvar gnus-tmp-indentation)
2258 (defvar gnus-tmp-opening-bracket)
2259 (defvar gnus-tmp-lines)
2260 (defvar gnus-tmp-name)
2261 (defvar gnus-tmp-closing-bracket)
2262 (defvar gnus-tmp-subject-or-nil)
2263 (defvar gnus-tmp-subject)
2264 (defvar gnus-tmp-marked)
2265 (defvar gnus-tmp-marked-mark)
2266 (defvar gnus-tmp-subscribed)
2267 (defvar gnus-tmp-process-marked)
2268 (defvar gnus-tmp-number-of-unread)
2269 (defvar gnus-tmp-group-name)
2270 (defvar gnus-tmp-group)
2271 (defvar gnus-tmp-article-number)
2272 (defvar gnus-tmp-unread-and-unselected)
2273 (defvar gnus-tmp-news-method)
2274 (defvar gnus-tmp-news-server)
2275 (defvar gnus-tmp-article-number)
2276 (defvar gnus-mouse-face)
2277 (defvar gnus-mouse-face-prop)
2279 (defun gnus-summary-line-format-spec ()
2280 (insert gnus-tmp-unread gnus-tmp-replied
2281 gnus-tmp-score-char gnus-tmp-indentation)
2286 gnus-tmp-opening-bracket
2287 (format "%4d: %-20s"
2289 (if (> (length gnus-tmp-name) 20)
2290 (substring gnus-tmp-name 0 20)
2292 gnus-tmp-closing-bracket)
2294 gnus-mouse-face-prop gnus-mouse-face)
2295 (insert " " gnus-tmp-subject-or-nil "\n"))
2297 (defvar gnus-summary-line-format-spec
2298 (gnus-byte-code 'gnus-summary-line-format-spec))
2300 (defun gnus-summary-dummy-line-format-spec ()
2307 gnus-mouse-face-prop gnus-mouse-face)
2308 (insert " " gnus-tmp-subject "\n"))
2310 (defvar gnus-summary-dummy-line-format-spec
2311 (gnus-byte-code 'gnus-summary-dummy-line-format-spec))
2313 (defun gnus-group-line-format-spec ()
2314 (insert gnus-tmp-marked-mark gnus-tmp-subscribed
2315 gnus-tmp-process-marked
2316 gnus-group-indentation
2317 (format "%5s: " gnus-tmp-number-of-unread))
2321 (insert gnus-tmp-group "\n")
2323 gnus-mouse-face-prop gnus-mouse-face))
2324 (defvar gnus-group-line-format-spec
2325 (gnus-byte-code 'gnus-group-line-format-spec))
2327 (defvar gnus-format-specs
2328 `((version . ,emacs-version)
2329 (group ,gnus-group-line-format ,gnus-group-line-format-spec)
2330 (summary-dummy ,gnus-summary-dummy-line-format
2331 ,gnus-summary-dummy-line-format-spec)
2332 (summary ,gnus-summary-line-format ,gnus-summary-line-format-spec)))
2334 (defvar gnus-article-mode-line-format-spec nil)
2335 (defvar gnus-summary-mode-line-format-spec nil)
2336 (defvar gnus-group-mode-line-format-spec nil)
2338 ;;; Phew. All that gruft is over, fortunately.
2342 ;;; Gnus Utility Functions
2345 (defun gnus-extract-address-components (from)
2347 ;; First find the address - the thing with the @ in it. This may
2348 ;; not be accurate in mail addresses, but does the trick most of
2349 ;; the time in news messages.
2350 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
2351 (setq address (substring from (match-beginning 0) (match-end 0))))
2352 ;; Then we check whether the "name <address>" format is used.
2354 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2355 ;; Linear white space is not required.
2356 (string-match (concat "[ \t]*<" (regexp-quote address) ">") from)
2357 (and (setq name (substring from 0 (match-beginning 0)))
2358 ;; Strip any quotes from the name.
2359 (string-match "\".*\"" name)
2360 (setq name (substring name 1 (1- (match-end 0))))))
2361 ;; If not, then "address (name)" is used.
2363 (and (string-match "(.+)" from)
2364 (setq name (substring from (1+ (match-beginning 0))
2365 (1- (match-end 0)))))
2366 (and (string-match "()" from)
2367 (setq name address))
2368 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>.
2369 ;; XOVER might not support folded From headers.
2370 (and (string-match "(.*" from)
2371 (setq name (substring from (1+ (match-beginning 0))
2373 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2374 (list (or name from) (or address from))))
2376 (defun gnus-fetch-field (field)
2377 "Return the value of the header FIELD of current article."
2380 (let ((case-fold-search t))
2381 (nnheader-narrow-to-headers)
2382 (mail-fetch-field field)))))
2384 (defun gnus-goto-colon ()
2386 (search-forward ":" (gnus-point-at-eol) t))
2389 (defun gnus-update-format (var)
2390 "Update the format specification near point."
2395 ;; Find the end of the current word.
2396 (re-search-forward "[ \t\n]" nil t)
2398 (when (re-search-backward "\\(gnus-[-a-z]+-line-format\\)" nil t)
2399 (match-string 1)))))
2400 (let* ((type (intern (progn (string-match "gnus-\\([-a-z]+\\)-line" var)
2401 (match-string 1 var))))
2402 (entry (assq type gnus-format-specs))
2405 (setq gnus-format-specs (delq entry gnus-format-specs)))
2407 (intern (format "%s-spec" var))
2408 (gnus-parse-format (setq value (symbol-value (intern var)))
2409 (symbol-value (intern (format "%s-alist" var)))
2410 (not (string-match "mode" var))))
2411 (setq spec (symbol-value (intern (format "%s-spec" var))))
2412 (push (list type value spec) gnus-format-specs)
2414 (pop-to-buffer "*Gnus Format*")
2416 (lisp-interaction-mode)
2417 (insert (pp-to-string spec))))
2419 (defun gnus-update-format-specifications (&optional force)
2420 "Update all (necessary) format specifications."
2421 ;; Make the indentation array.
2422 (gnus-make-thread-indent-array)
2424 ;; See whether all the stored info needs to be flushed.
2426 (not (equal emacs-version
2427 (cdr (assq 'version gnus-format-specs)))))
2428 (setq gnus-format-specs nil))
2430 ;; Go through all the formats and see whether they need updating.
2431 (let ((types '(summary summary-dummy group
2432 summary-mode group-mode article-mode))
2433 new-format entry type val)
2434 (while (setq type (pop types))
2435 (setq new-format (symbol-value
2436 (intern (format "gnus-%s-line-format" type))))
2437 (setq entry (cdr (assq type gnus-format-specs)))
2439 (equal (car entry) new-format))
2440 ;; Use the old format.
2441 (set (intern (format "gnus-%s-line-format-spec" type))
2443 ;; This is a new format.
2445 (if (not (stringp new-format))
2446 ;; This is a function call or something.
2448 ;; This is a "real" format.
2452 (intern (format "gnus-%s-line-format-alist"
2453 (if (eq type 'article-mode)
2454 'summary-mode type))))
2455 (not (string-match "mode$" (symbol-name type))))))
2456 ;; Enter the new format spec into the list.
2459 (setcar (cdr entry) val)
2460 (setcar entry new-format))
2461 (push (list type new-format val) gnus-format-specs))
2462 (set (intern (format "gnus-%s-line-format-spec" type)) val))))
2464 (gnus-update-group-mark-positions)
2465 (gnus-update-summary-mark-positions)
2467 ;; See whether we need to read the description file.
2468 (if (and (string-match "%[-,0-9]*D" gnus-group-line-format)
2469 (not gnus-description-hashtb)
2470 gnus-read-active-file)
2471 (gnus-read-all-descriptions-files)))
2473 (defun gnus-update-summary-mark-positions ()
2474 "Compute where the summary marks are to go."
2476 (let ((gnus-replied-mark 129)
2477 (gnus-score-below-mark 130)
2478 (gnus-score-over-mark 130)
2482 (gnus-set-work-buffer)
2483 (gnus-summary-insert-line
2484 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2485 (goto-char (point-min))
2486 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2488 (goto-char (point-min))
2489 (push (cons 'replied (and (search-forward "\201" nil t) (- (point) 2)))
2491 (goto-char (point-min))
2492 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2494 (setq gnus-summary-mark-positions pos))))
2496 (defun gnus-update-group-mark-positions ()
2498 (let ((gnus-process-mark 128)
2499 (gnus-group-marked '("dummy.group")))
2500 (gnus-set-active "dummy.group" '(0 . 0))
2501 (gnus-set-work-buffer)
2502 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
2503 (goto-char (point-min))
2504 (setq gnus-group-mark-positions
2505 (list (cons 'process (and (search-forward "\200" nil t)
2506 (- (point) 2))))))))
2508 (defvar gnus-mouse-face-0 'highlight)
2509 (defvar gnus-mouse-face-1 'highlight)
2510 (defvar gnus-mouse-face-2 'highlight)
2511 (defvar gnus-mouse-face-3 'highlight)
2512 (defvar gnus-mouse-face-4 'highlight)
2514 (defun gnus-mouse-face-function (form type)
2516 (point) (progn ,@form (point))
2517 gnus-mouse-face-prop
2520 `(quote ,(symbol-value (intern (format "gnus-mouse-face-%d" type)))))))
2522 (defvar gnus-face-0 'bold)
2523 (defvar gnus-face-1 'italic)
2524 (defvar gnus-face-2 'bold-italic)
2525 (defvar gnus-face-3 'bold)
2526 (defvar gnus-face-4 'bold)
2528 (defun gnus-face-face-function (form type)
2530 (point) (progn ,@form (point))
2531 'face ',(symbol-value (intern (format "gnus-face-%d" type)))))
2533 (defun gnus-max-width-function (el max-width)
2534 (or (numberp max-width) (signal 'wrong-type-argument '(numberp max-width)))
2536 `(if (> (length ,el) ,max-width)
2537 (substring ,el 0 ,max-width)
2539 `(let ((val (eval ,el)))
2541 (setq val (int-to-string val)))
2542 (if (> (length val) ,max-width)
2543 (substring val 0 ,max-width)
2546 (defun gnus-parse-format (format spec-alist &optional insert)
2547 ;; This function parses the FORMAT string with the help of the
2548 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
2549 ;; string. If the FORMAT string contains the specifiers %( and %)
2550 ;; the text between them will have the mouse-face text property.
2552 "\\`\\(.*\\)%[0-9]?[{(]\\(.*\\)%[0-9]?[})]\\(.*\n?\\)\\'"
2554 (gnus-parse-complex-format format spec-alist)
2555 ;; This is a simple format.
2556 (gnus-parse-simple-format format spec-alist insert)))
2558 (defun gnus-parse-complex-format (format spec-alist)
2560 (gnus-set-work-buffer)
2562 (goto-char (point-min))
2563 (while (re-search-forward "\"" nil t)
2564 (replace-match "\\\"" nil t))
2565 (goto-char (point-min))
2567 (while (re-search-forward "%\\([0-9]+\\)?\\([{}()]\\)" nil t)
2568 (let ((number (if (match-beginning 1)
2569 (match-string 1) "0"))
2570 (delim (aref (match-string 2) 0)))
2571 (if (or (= delim ?\() (= delim ?\{))
2572 (replace-match (concat "\"(" (if (= delim ?\() "mouse" "face")
2574 (replace-match "\")\""))))
2575 (goto-char (point-max))
2577 (goto-char (point-min))
2578 (let ((form (read (current-buffer))))
2579 (cons 'progn (gnus-complex-form-to-spec form spec-alist)))))
2581 (defun gnus-complex-form-to-spec (form spec-alist)
2586 (gnus-parse-simple-format sform spec-alist t)
2587 (funcall (intern (format "gnus-%s-face-function" (car sform)))
2588 (gnus-complex-form-to-spec (cddr sform) spec-alist)
2592 (defun gnus-parse-simple-format (format spec-alist &optional insert)
2593 ;; This function parses the FORMAT string with the help of the
2594 ;; SPEC-ALIST and returns a list that can be eval'ed to return a
2597 spec flist fstring newspec elem beg result dontinsert)
2599 (gnus-set-work-buffer)
2601 (goto-char (point-min))
2602 (while (re-search-forward "%[-0-9]*\\(,[0-9]+\\)?\\([^0-9]\\)\\(.\\)?"
2604 (if (= (setq spec (string-to-char (match-string 2))) ?%)
2606 beg (1+ (match-beginning 0)))
2607 ;; First check if there are any specs that look anything like
2608 ;; "%12,12A", ie. with a "max width specification". These have
2609 ;; to be treated specially.
2610 (if (setq beg (match-beginning 1))
2614 (1+ (match-beginning 1)) (match-end 1))))
2616 (setq beg (match-beginning 2)))
2617 ;; Find the specification from `spec-alist'.
2618 (unless (setq elem (cdr (assq spec spec-alist)))
2619 (setq elem '("*" ?s)))
2620 ;; Treat user defined format specifiers specially.
2621 (when (eq (car elem) 'gnus-tmp-user-defined)
2624 (list (intern (concat "gnus-user-format-function-"
2626 'gnus-tmp-header) ?s))
2627 (delete-region (match-beginning 3) (match-end 3)))
2628 (if (not (zerop max-width))
2629 (let ((el (car elem)))
2630 (cond ((= (cadr elem) ?c)
2631 (setq el (list 'char-to-string el)))
2633 (setq el (list 'int-to-string el))))
2634 (setq flist (cons (gnus-max-width-function el max-width)
2638 (setq flist (cons (car elem) flist))
2639 (setq newspec (cadr elem)))))
2640 ;; Remove the old specification (and possibly a ",12" string).
2641 (delete-region beg (match-end 2))
2642 ;; Insert the new specification.
2645 (setq fstring (buffer-substring 1 (point-max))))
2646 ;; Do some postprocessing to increase efficiency.
2651 ((string= fstring "")
2653 ;; Not a format string.
2654 ((not (string-match "%" fstring))
2656 ;; A format string with just a single string spec.
2657 ((string= fstring "%s")
2659 ;; A single character.
2660 ((string= fstring "%c")
2663 ((string= fstring "%d")
2666 (list `(princ ,(car flist)))
2667 (list `(int-to-string ,(car flist)))))
2668 ;; Just lots of chars and strings.
2669 ((string-match "\\`\\(%[cs]\\)+\\'" fstring)
2671 ;; A single string spec at the beginning of the spec.
2672 ((string-match "\\`%[sc][^%]+\\'" fstring)
2673 (list (car flist) (substring fstring 2)))
2674 ;; A single string spec in the middle of the spec.
2675 ((string-match "\\`\\([^%]+\\)%[sc]\\([^%]+\\)\\'" fstring)
2676 (list (match-string 1 fstring) (car flist) (match-string 2 fstring)))
2677 ;; A single string spec in the end of the spec.
2678 ((string-match "\\`\\([^%]+\\)%[sc]\\'" fstring)
2679 (list (match-string 1 fstring) (car flist)))
2680 ;; A more complex spec.
2682 (list (cons 'format (cons fstring (nreverse flist)))))))
2688 (cons 'insert result)))
2689 (cond ((stringp result)
2692 (cons 'concat result))
2695 (defun gnus-eval-format (format &optional alist props)
2696 "Eval the format variable FORMAT, using ALIST.
2697 If PROPS, insert the result."
2698 (let ((form (gnus-parse-format format alist props)))
2700 (add-text-properties (point) (progn (eval form) (point)) props)
2703 (defun gnus-remove-text-with-property (prop)
2704 "Delete all text in the current buffer with text property PROP."
2706 (goto-char (point-min))
2708 (while (get-text-property (point) prop)
2710 (goto-char (next-single-property-change (point) prop nil (point-max))))))
2712 (defun gnus-set-work-buffer ()
2713 (if (get-buffer gnus-work-buffer)
2715 (set-buffer gnus-work-buffer)
2717 (set-buffer (get-buffer-create gnus-work-buffer))
2718 (kill-all-local-variables)
2719 (buffer-disable-undo (current-buffer))
2720 (gnus-add-current-to-buffer-list)))
2722 ;; Article file names when saving.
2724 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2725 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2726 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
2727 Otherwise, it is like ~/News/news/group/num."
2730 (concat (if (gnus-use-long-file-name 'not-save)
2731 (gnus-capitalize-newsgroup newsgroup)
2732 (gnus-newsgroup-directory-form newsgroup))
2733 "/" (int-to-string (mail-header-number headers)))
2734 (or gnus-article-save-directory "~/News"))))
2736 (string-equal (file-name-directory default)
2737 (file-name-directory last-file))
2738 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2740 (or last-file default))))
2742 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2743 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2744 If variable `gnus-use-long-file-name' is non-nil, it is
2745 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2748 (concat (if (gnus-use-long-file-name 'not-save)
2750 (gnus-newsgroup-directory-form newsgroup))
2751 "/" (int-to-string (mail-header-number headers)))
2752 (or gnus-article-save-directory "~/News"))))
2754 (string-equal (file-name-directory default)
2755 (file-name-directory last-file))
2756 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2758 (or last-file default))))
2760 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2761 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2762 If variable `gnus-use-long-file-name' is non-nil, it is
2763 ~/News/News.group. Otherwise, it is like ~/News/news/group/news."
2766 (if (gnus-use-long-file-name 'not-save)
2767 (gnus-capitalize-newsgroup newsgroup)
2768 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2769 (or gnus-article-save-directory "~/News"))))
2771 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2772 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2773 If variable `gnus-use-long-file-name' is non-nil, it is
2774 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2777 (if (gnus-use-long-file-name 'not-save)
2779 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2780 (or gnus-article-save-directory "~/News"))))
2782 ;; For subscribing new newsgroup
2784 (defun gnus-subscribe-hierarchical-interactive (groups)
2785 (let ((groups (sort groups 'string<))
2786 prefixes prefix start ans group starts)
2788 (setq prefixes (list "^"))
2789 (while (and groups prefixes)
2790 (while (not (string-match (car prefixes) (car groups)))
2791 (setq prefixes (cdr prefixes)))
2792 (setq prefix (car prefixes))
2793 (setq start (1- (length prefix)))
2794 (if (and (string-match "[^\\.]\\." (car groups) start)
2797 (concat "^" (substring (car groups) 0 (match-end 0))))
2798 (string-match prefix (cadr groups)))
2800 (setq prefixes (cons prefix prefixes))
2801 (message "Descend hierarchy %s? ([y]nsq): "
2802 (substring prefix 1 (1- (length prefix))))
2803 (setq ans (read-char))
2806 (string-match prefix
2807 (setq group (car groups))))
2808 (setq gnus-killed-list
2809 (cons group gnus-killed-list))
2810 (gnus-sethash group group gnus-killed-hashtb)
2811 (setq groups (cdr groups)))
2812 (setq starts (cdr starts)))
2815 (string-match prefix
2816 (setq group (car groups))))
2817 (gnus-sethash group group gnus-killed-hashtb)
2818 (gnus-subscribe-alphabetically (car groups))
2819 (setq groups (cdr groups)))
2820 (setq starts (cdr starts)))
2823 (setq group (car groups))
2824 (setq gnus-killed-list (cons group gnus-killed-list))
2825 (gnus-sethash group group gnus-killed-hashtb)
2826 (setq groups (cdr groups))))
2828 (message "Subscribe %s? ([n]yq)" (car groups))
2829 (setq ans (read-char))
2830 (setq group (car groups))
2832 (gnus-subscribe-alphabetically (car groups))
2833 (gnus-sethash group group gnus-killed-hashtb))
2836 (setq group (car groups))
2837 (setq gnus-killed-list (cons group gnus-killed-list))
2838 (gnus-sethash group group gnus-killed-hashtb)
2839 (setq groups (cdr groups))))
2841 (setq gnus-killed-list (cons group gnus-killed-list))
2842 (gnus-sethash group group gnus-killed-hashtb)))
2843 (setq groups (cdr groups)))))))
2845 (defun gnus-subscribe-randomly (newsgroup)
2846 "Subscribe new NEWSGROUP by making it the first newsgroup."
2847 (gnus-subscribe-newsgroup newsgroup))
2849 (defun gnus-subscribe-alphabetically (newgroup)
2850 "Subscribe new NEWSGROUP and insert it in alphabetical order."
2851 (let ((groups (cdr gnus-newsrc-alist))
2853 (while (and (not before) groups)
2854 (if (string< newgroup (caar groups))
2855 (setq before (caar groups))
2856 (setq groups (cdr groups))))
2857 (gnus-subscribe-newsgroup newgroup before)))
2859 (defun gnus-subscribe-hierarchically (newgroup)
2860 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
2861 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2863 (set-buffer (find-file-noselect gnus-current-startup-file))
2864 (let ((groupkey newgroup)
2866 (while (and (not before) groupkey)
2867 (goto-char (point-min))
2869 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
2870 (while (and (re-search-forward groupkey-re nil t)
2872 (setq before (match-string 1))
2873 (string< before newgroup)))))
2874 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
2876 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
2877 (substring groupkey (match-beginning 1) (match-end 1)))))
2878 (gnus-subscribe-newsgroup newgroup before))))
2880 (defun gnus-subscribe-interactively (group)
2881 "Subscribe the new GROUP interactively.
2882 It is inserted in hierarchical newsgroup order if subscribed. If not,
2884 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " group))
2885 (gnus-subscribe-hierarchically group)
2886 (push group gnus-killed-list)))
2888 (defun gnus-subscribe-zombies (group)
2889 "Make the new GROUP into a zombie group."
2890 (push group gnus-zombie-list))
2892 (defun gnus-subscribe-killed (group)
2893 "Make the new GROUP a killed group."
2894 (push group gnus-killed-list))
2896 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
2897 "Subscribe new NEWSGROUP.
2898 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
2899 the first newsgroup."
2900 ;; We subscribe the group by changing its level to `subscribed'.
2901 (gnus-group-change-level
2902 newsgroup gnus-level-default-subscribed
2903 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
2904 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))
2908 (defun gnus-newsgroup-directory-form (newsgroup)
2909 "Make hierarchical directory name from NEWSGROUP name."
2910 (let ((newsgroup (gnus-newsgroup-savable-name newsgroup))
2911 (len (length newsgroup))
2913 ;; If this is a foreign group, we don't want to translate the
2915 (if (setq idx (string-match ":" newsgroup))
2916 (aset newsgroup idx ?/)
2918 ;; Replace all occurrences of `.' with `/'.
2920 (if (= (aref newsgroup idx) ?.)
2921 (aset newsgroup idx ?/))
2922 (setq idx (1+ idx)))
2925 (defun gnus-newsgroup-savable-name (group)
2926 ;; Replace any slashes in a group name (eg. an ange-ftp nndoc group)
2928 (nnheader-replace-chars-in-string group ?/ ?.))
2930 (defun gnus-make-directory (dir)
2931 "Make DIRECTORY recursively."
2932 ;; Why don't we use `(make-directory dir 'parents)'? That's just one
2933 ;; of the many mysteries of the universe.
2934 (let* ((dir (expand-file-name dir default-directory))
2936 (if (string-match "/$" dir)
2937 (setq dir (substring dir 0 (match-beginning 0))))
2938 ;; First go down the path until we find a directory that exists.
2939 (while (not (file-exists-p dir))
2940 (setq dirs (cons dir dirs))
2941 (string-match "/[^/]+$" dir)
2942 (setq dir (substring dir 0 (match-beginning 0))))
2943 ;; Then create all the subdirs.
2944 (while (and dirs (not err))
2946 (make-directory (car dirs))
2947 (error (setq err t)))
2948 (setq dirs (cdr dirs)))
2949 ;; We return whether we were successful or not.
2952 (defun gnus-capitalize-newsgroup (newsgroup)
2953 "Capitalize NEWSGROUP name."
2954 (and (not (zerop (length newsgroup)))
2955 (concat (char-to-string (upcase (aref newsgroup 0)))
2956 (substring newsgroup 1))))
2958 ;; Various... things.
2960 (defun gnus-simplify-subject (subject &optional re-only)
2961 "Remove `Re:' and words in parentheses.
2962 If RE-ONLY is non-nil, strip leading `Re:'s only."
2963 (let ((case-fold-search t)) ;Ignore case.
2964 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
2965 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
2966 (setq subject (substring subject (match-end 0))))
2967 ;; Remove uninteresting prefixes.
2968 (if (and (not re-only)
2969 gnus-simplify-ignored-prefixes
2970 (string-match gnus-simplify-ignored-prefixes subject))
2971 (setq subject (substring subject (match-end 0))))
2972 ;; Remove words in parentheses from end.
2974 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
2975 (setq subject (substring subject 0 (match-beginning 0)))))
2976 ;; Return subject string.
2979 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
2981 ;; Written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
2982 (defun gnus-simplify-buffer-fuzzy ()
2983 (goto-char (point-min))
2984 (re-search-forward "^[ \t]*\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;][ \t]*" nil t)
2985 (goto-char (match-beginning 0))
2987 (looking-at "^[ \t]*\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;][ \t]*")
2988 (looking-at "^[[].*:[ \t].*[]]$"))
2989 (goto-char (point-min))
2990 (while (re-search-forward "^[ \t]*\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;][ \t]*"
2992 (replace-match "" t t))
2993 (goto-char (point-min))
2994 (while (re-search-forward "^[[].*:[ \t].*[]]$" nil t)
2995 (goto-char (match-end 0))
2998 (progn (goto-char (match-beginning 0)))
2999 (re-search-forward ":"))))
3000 (goto-char (point-min))
3001 (while (re-search-forward "[ \t\n]*[[{(][^()]*[]})][ \t]*$" nil t)
3002 (replace-match "" t t))
3003 (goto-char (point-min))
3004 (while (re-search-forward "[ \t]+" nil t)
3005 (replace-match " " t t))
3006 (goto-char (point-min))
3007 (while (re-search-forward "[ \t]+$" nil t)
3008 (replace-match "" t t))
3009 (goto-char (point-min))
3010 (while (re-search-forward "^[ \t]+" nil t)
3011 (replace-match "" t t))
3012 (goto-char (point-min))
3013 (if gnus-simplify-subject-fuzzy-regexp
3014 (if (listp gnus-simplify-subject-fuzzy-regexp)
3015 (let ((list gnus-simplify-subject-fuzzy-regexp))
3017 (goto-char (point-min))
3018 (while (re-search-forward (car list) nil t)
3019 (replace-match "" t t))
3020 (setq list (cdr list))))
3021 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
3022 (replace-match "" t t)))))
3024 (defun gnus-simplify-subject-fuzzy (subject)
3025 "Siplify a subject string fuzzily."
3027 (gnus-set-work-buffer)
3028 (let ((case-fold-search t))
3030 (inline (gnus-simplify-buffer-fuzzy))
3033 ;; Add the current buffer to the list of buffers to be killed on exit.
3034 (defun gnus-add-current-to-buffer-list ()
3035 (or (memq (current-buffer) gnus-buffer-list)
3036 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list))))
3038 (defun gnus-string> (s1 s2)
3039 (not (or (string< s1 s2)
3042 ;;; General various misc type functions.
3044 (defun gnus-clear-system ()
3045 "Clear all variables and buffers."
3046 ;; Clear Gnus variables.
3047 (let ((variables gnus-variable-list))
3049 (set (car variables) nil)
3050 (setq variables (cdr variables))))
3051 ;; Clear other internal variables.
3052 (setq gnus-list-of-killed-groups nil
3053 gnus-have-read-active-file nil
3054 gnus-newsrc-alist nil
3055 gnus-newsrc-hashtb nil
3056 gnus-killed-list nil
3057 gnus-zombie-list nil
3058 gnus-killed-hashtb nil
3059 gnus-active-hashtb nil
3060 gnus-moderated-list nil
3061 gnus-description-hashtb nil
3062 gnus-newsgroup-headers nil
3063 gnus-newsgroup-name nil
3064 gnus-server-alist nil
3065 gnus-opened-servers nil
3066 gnus-current-select-method nil)
3067 ;; Reset any score variables.
3068 (and gnus-use-scoring (gnus-score-close))
3069 ;; Kill the startup file.
3070 (and gnus-current-startup-file
3071 (get-file-buffer gnus-current-startup-file)
3072 (kill-buffer (get-file-buffer gnus-current-startup-file)))
3073 ;; Save any cache buffers.
3074 (and gnus-use-cache (gnus-cache-save-buffers))
3075 ;; Clear the dribble buffer.
3076 (gnus-dribble-clear)
3077 ;; Close down NoCeM.
3078 (when gnus-use-nocem
3080 ;; Shut down the demons.
3081 (when gnus-use-demon
3082 (gnus-demon-cancel))
3083 ;; Kill global KILL file buffer.
3084 (if (get-file-buffer (gnus-newsgroup-kill-file nil))
3085 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
3086 (gnus-kill-buffer nntp-server-buffer)
3088 (and gnus-keep-backlog (gnus-backlog-shutdown))
3089 ;; Kill Gnus buffers.
3090 (while gnus-buffer-list
3091 (gnus-kill-buffer (car gnus-buffer-list))
3092 (setq gnus-buffer-list (cdr gnus-buffer-list))))
3094 (defun gnus-windows-old-to-new (setting)
3095 ;; First we take care of the really, really old Gnus 3 actions.
3096 (if (symbolp setting)
3098 (cond ((memq setting '(SelectArticle))
3100 ((memq setting '(SelectSubject ExpandSubject))
3102 ((memq setting '(SelectNewsgroup ExitNewsgroup))
3105 (if (or (listp setting)
3106 (not (and gnus-window-configuration
3107 (memq setting '(group summary article)))))
3109 (let* ((setting (if (eq setting 'group)
3110 (if (assq 'newsgroup gnus-window-configuration)
3112 'newsgroups) setting))
3113 (elem (cadr (assq setting gnus-window-configuration)))
3114 (total (apply '+ elem))
3115 (types '(group summary article))
3116 (pbuf (if (eq setting 'newsgroups) 'group 'summary))
3121 (or (not (numberp (nth i elem)))
3122 (zerop (nth i elem))
3124 (setq perc (/ (float (nth 0 elem)) total))
3125 (setq out (cons (if (eq pbuf (nth i types))
3126 (vector (nth i types) perc 'point)
3127 (vector (nth i types) perc))
3130 (list (nreverse out)))))
3133 (defun gnus-add-configuration (conf)
3134 "Add the window configuration CONF to `gnus-buffer-configuration'."
3135 (setq gnus-buffer-configuration
3136 (cons conf (delq (assq (car conf) gnus-buffer-configuration)
3137 gnus-buffer-configuration))))
3139 (defvar gnus-frame-list nil)
3141 (defun gnus-configure-frame (split &optional window)
3142 "Split WINDOW according to SPLIT."
3144 (setq window (get-buffer-window (current-buffer))))
3145 (select-window window)
3146 ;; This might be an old-stylee buffer config.
3147 (when (vectorp split)
3148 (setq split (append split nil)))
3149 (when (or (consp (car split))
3150 (vectorp (car split)))
3152 (push 'vertical split))
3153 ;; The SPLIT might be something that is to be evaled to
3154 ;; return a new SPLIT.
3155 (while (and (not (assq (car split) gnus-window-to-buffer))
3156 (gnus-functionp (car split)))
3157 (setq split (eval split)))
3158 (let* ((type (car split))
3160 (len (if (eq type 'horizontal) (window-width) (window-height)))
3162 (window-min-width (or gnus-window-min-width window-min-width))
3163 (window-min-height (or gnus-window-min-height window-min-height))
3164 s result new-win rest comp-subs size sub)
3166 ;; Nothing to do here.
3168 ;; Don't switch buffers.
3170 (and (memq 'point split) window))
3171 ;; This is a buffer to be selected.
3172 ((not (memq type '(frame horizontal vertical)))
3173 (let ((buffer (cond ((stringp type) type)
3174 (t (cdr (assq type gnus-window-to-buffer)))))
3177 (error "Illegal buffer type: %s" type))
3178 (unless (setq buf (get-buffer (if (symbolp buffer)
3179 (symbol-value buffer) buffer)))
3180 (setq buf (get-buffer-create (if (symbolp buffer)
3181 (symbol-value buffer) buffer))))
3182 (switch-to-buffer buf)
3183 ;; We return the window if it has the `point' spec.
3184 (and (memq 'point split) window)))
3185 ;; This is a frame split.
3187 (unless gnus-frame-list
3188 (setq gnus-frame-list (list (window-frame
3189 (get-buffer-window (current-buffer))))))
3191 params frame fresult)
3192 (while (< i (length subs))
3193 ;; Frame parameter is gotten from the sub-split.
3194 (setq params (cadr (elt subs i)))
3195 ;; It should be a list.
3196 (unless (listp params)
3198 ;; Create a new frame?
3199 (unless (setq frame (elt gnus-frame-list i))
3200 (nconc gnus-frame-list (list (setq frame (make-frame params)))))
3201 ;; Is the old frame still alive?
3202 (unless (frame-live-p frame)
3203 (setcar (nthcdr i gnus-frame-list)
3204 (setq frame (make-frame params))))
3205 ;; Select the frame in question and do more splits there.
3206 (select-frame frame)
3207 (setq fresult (or (gnus-configure-frame (elt subs i)) fresult))
3209 ;; Select the frame that has the selected buffer.
3211 (select-frame (window-frame fresult)))))
3212 ;; This is a normal split.
3214 (when (> (length subs) 0)
3215 ;; First we have to compute the sizes of all new windows.
3217 (setq sub (append (pop subs) nil))
3218 (while (and (not (assq (car sub) gnus-window-to-buffer))
3219 (gnus-functionp (car sub)))
3220 (setq sub (eval sub)))
3222 (push sub comp-subs)
3223 (setq size (cadar comp-subs))
3224 (cond ((equal size 1.0)
3225 (setq rest (car comp-subs))
3228 (setq s (floor (* size len))))
3232 (error "Illegal size: %s" size)))
3233 ;; Try to make sure that we are inside the safe limits.
3235 ((eq type 'horizontal)
3236 (setq s (max s window-min-width)))
3237 ((eq type 'vertical)
3238 (setq s (max s window-min-height))))
3239 (setcar (cdar comp-subs) s)
3241 ;; Take care of the "1.0" spec.
3243 (setcar (cdr rest) (- len total))
3244 (error "No 1.0 specs in %s" split))
3245 ;; The we do the actual splitting in a nice recursive
3247 (setq comp-subs (nreverse comp-subs))
3249 (if (null (cdr comp-subs))
3250 (setq new-win window)
3252 (split-window window (cadar comp-subs)
3253 (eq type 'horizontal))))
3254 (setq result (or (gnus-configure-frame
3255 (car comp-subs) window) result))
3256 (select-window new-win)
3257 (setq window new-win)
3258 (setq comp-subs (cdr comp-subs))))
3259 ;; Return the proper window, if any.
3261 (select-window result))))))
3263 (defvar gnus-frame-split-p nil)
3265 (defun gnus-configure-windows (setting &optional force)
3266 (setq setting (gnus-windows-old-to-new setting))
3267 (let ((split (if (symbolp setting)
3268 (cadr (assq setting gnus-buffer-configuration))
3270 (in-buf (current-buffer))
3271 rule val w height hor ohor heights sub jump-buffer
3272 rel total to-buf all-visible)
3274 (setq gnus-frame-split-p nil)
3277 (error "No such setting: %s" setting))
3279 (if (and (not force)
3280 (setq all-visible (gnus-all-windows-visible-p split)))
3281 ;; All the windows mentioned are already visible, so we just
3282 ;; put point in the assigned buffer, and do not touch the
3284 (select-window all-visible)
3286 ;; Either remove all windows or just remove all Gnus windows.
3287 (let ((frame (selected-frame)))
3289 (if gnus-use-full-window
3290 ;; We want to remove all other windows.
3291 (if (not gnus-frame-split-p)
3292 ;; This is not a `frame' split, so we ignore the
3294 (delete-other-windows)
3295 ;; This is a `frame' split, so we delete all windows
3299 (unless (eq (cdr (assq 'minibuffer
3300 (frame-parameters frame)))
3302 (select-frame frame)
3303 (delete-other-windows)))
3305 ;; Just remove some windows.
3306 (gnus-remove-some-windows)
3307 (switch-to-buffer nntp-server-buffer))
3308 (select-frame frame)))
3310 (switch-to-buffer nntp-server-buffer)
3311 (gnus-configure-frame split (get-buffer-window (current-buffer))))))
3313 (defun gnus-all-windows-visible-p (split)
3314 (when (vectorp split)
3315 (setq split (append split nil)))
3316 (when (or (consp (car split))
3317 (vectorp (car split)))
3319 (push 'vertical split))
3320 ;; The SPLIT might be something that is to be evaled to
3321 ;; return a new SPLIT.
3322 (while (and (not (assq (car split) gnus-window-to-buffer))
3323 (gnus-functionp (car split)))
3324 (setq split (eval split)))
3325 (let* ((type (elt split 0)))
3329 ((not (or (eq type 'horizontal) (eq type 'vertical) (eq type 'frame)))
3330 (let ((buffer (cond ((stringp type) type)
3331 (t (cdr (assq type gnus-window-to-buffer)))))
3334 (error "Illegal buffer type: %s" type))
3335 (when (setq buf (get-buffer (if (symbolp buffer) (symbol-value buffer)
3337 (setq win (get-buffer-window buf t)))
3339 (if (memq 'point split)
3343 (when (eq type 'frame)
3344 (setq gnus-frame-split-p t))
3345 (let ((n (mapcar 'gnus-all-windows-visible-p
3349 (cond ((windowp (car n))
3356 (defun gnus-window-top-edge (&optional window)
3357 (nth 1 (window-edges window)))
3359 (defun gnus-remove-some-windows ()
3360 (let ((buffers gnus-window-to-buffer)
3361 buf bufs lowest-buf lowest)
3363 ;; Remove windows on all known Gnus buffers.
3365 (setq buf (cdar buffers))
3367 (setq buf (and (boundp buf) (symbol-value buf))))
3369 (get-buffer-window buf)
3371 (setq bufs (cons buf bufs))
3373 (if (or (not lowest)
3374 (< (gnus-window-top-edge) lowest))
3376 (setq lowest (gnus-window-top-edge))
3377 (setq lowest-buf buf)))))
3378 (setq buffers (cdr buffers)))
3379 ;; Remove windows on *all* summary buffers.
3383 (let ((buf (window-buffer win)))
3384 (if (string-match "^\\*Summary" (buffer-name buf))
3386 (setq bufs (cons buf bufs))
3388 (if (or (not lowest)
3389 (< (gnus-window-top-edge) lowest))
3391 (setq lowest-buf buf)
3392 (setq lowest (gnus-window-top-edge))))))))))
3395 (pop-to-buffer lowest-buf)
3396 (switch-to-buffer nntp-server-buffer)))
3398 (and (not (eq (car bufs) lowest-buf))
3399 (delete-windows-on (car bufs)))
3400 (setq bufs (cdr bufs))))))
3402 (defun gnus-version ()
3403 "Version numbers of this version of Gnus."
3405 (let ((methods gnus-valid-select-methods)
3408 ;; Go through all the legal select methods and add their version
3409 ;; numbers to the total version string. Only the backends that are
3410 ;; currently in use will have their message numbers taken into
3413 (setq meth (intern (concat (caar methods) "-version")))
3415 (stringp (symbol-value meth))
3416 (setq mess (concat mess "; " (symbol-value meth))))
3417 (setq methods (cdr methods)))
3418 (gnus-message 2 mess)))
3420 (defun gnus-info-find-node ()
3421 "Find Info documentation of Gnus."
3423 ;; Enlarge info window if needed.
3424 (let ((mode major-mode)
3426 (Info-goto-node (cadr (assq mode gnus-info-nodes)))
3427 (setq gnus-info-buffer (current-buffer))
3428 (gnus-configure-windows 'info)))
3430 (defun gnus-days-between (date1 date2)
3431 ;; Return the number of days between date1 and date2.
3432 (- (gnus-day-number date1) (gnus-day-number date2)))
3434 (defun gnus-day-number (date)
3435 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
3436 (timezone-parse-date date))))
3437 (timezone-absolute-from-gregorian
3438 (nth 1 dat) (nth 2 dat) (car dat))))
3440 (defun gnus-encode-date (date)
3441 "Convert DATE to internal time."
3442 (let* ((parse (timezone-parse-date date))
3443 (date (mapcar (lambda (d) (and d (string-to-int d))) parse))
3444 (time (mapcar 'string-to-int (timezone-parse-time (aref parse 3)))))
3445 (encode-time (caddr time) (cadr time) (car time)
3446 (caddr date) (cadr date) (car date) (nth 4 date))))
3448 (defun gnus-time-minus (t1 t2)
3449 "Subtract two internal times."
3450 (let ((borrow (< (cadr t1) (cadr t2))))
3451 (list (- (car t1) (car t2) (if borrow 1 0))
3452 (- (+ (if borrow 65536 0) (cadr t1)) (cadr t2)))))
3454 (defun gnus-file-newer-than (file date)
3455 (let ((fdate (nth 5 (file-attributes file))))
3456 (or (> (car fdate) (car date))
3457 (and (= (car fdate) (car date))
3458 (> (nth 1 fdate) (nth 1 date))))))
3460 (defmacro gnus-define-keys (keymap &rest plist)
3461 "Define all keys in PLIST in KEYMAP."
3462 `(gnus-define-keys-1 (quote ,keymap) (quote ,plist)))
3464 (defmacro gnus-define-keymap (keymap &rest plist)
3465 "Define all keys in PLIST in KEYMAP."
3466 `(gnus-define-keys-1 ,keymap (quote ,plist)))
3468 (defun gnus-define-keys-1 (keymap plist)
3470 (error "Can't set keys in a null keymap"))
3471 (cond ((symbolp keymap)
3472 (setq keymap (symbol-value keymap)))
3475 (set (car keymap) nil)
3476 (define-prefix-command (car keymap))
3477 (define-key (symbol-value (caddr keymap)) (cadr keymap) (car keymap))
3478 (setq keymap (symbol-value (car keymap)))))
3481 (when (symbolp (setq key (pop plist)))
3482 (setq key (symbol-value key)))
3483 (define-key keymap key (pop plist)))))
3485 (defun gnus-group-read-only-p (&optional group)
3486 "Check whether GROUP supports editing or not.
3487 If GROUP is nil, `gnus-newsgroup-name' will be checked instead. Note
3488 that that variable is buffer-local to the summary buffers."
3489 (let ((group (or group gnus-newsgroup-name)))
3490 (not (gnus-check-backend-function 'request-replace-article group))))
3492 (defun gnus-group-total-expirable-p (group)
3493 "Check whether GROUP is total-expirable or not."
3494 (let ((params (gnus-info-params (gnus-get-info group))))
3495 (or (memq 'total-expire params)
3496 (cdr (assq 'total-expire params)) ; (total-expire . t)
3497 (and gnus-total-expirable-newsgroups ; Check var.
3498 (string-match gnus-total-expirable-newsgroups group)))))
3500 (defun gnus-group-auto-expirable-p (group)
3501 "Check whether GROUP is total-expirable or not."
3502 (let ((params (gnus-info-params (gnus-get-info group))))
3503 (or (memq 'auto-expire params)
3504 (cdr (assq 'auto-expire params)) ; (auto-expire . t)
3505 (and gnus-auto-expirable-newsgroups ; Check var.
3506 (string-match gnus-auto-expirable-newsgroups group)))))
3508 (defun gnus-virtual-group-p (group)
3509 "Say whether GROUP is virtual or not."
3510 (memq 'virtual (assoc (symbol-name (car (gnus-find-method-for-group group)))
3511 gnus-valid-select-methods)))
3513 (defsubst gnus-simplify-subject-fully (subject)
3514 "Simplify a subject string according to the user's wishes."
3516 ((null gnus-summary-gather-subject-limit)
3517 (gnus-simplify-subject-re subject))
3518 ((eq gnus-summary-gather-subject-limit 'fuzzy)
3519 (gnus-simplify-subject-fuzzy subject))
3520 ((numberp gnus-summary-gather-subject-limit)
3521 (gnus-limit-string (gnus-simplify-subject-re subject)
3522 gnus-summary-gather-subject-limit))
3526 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
3527 "Check whether two subjects are equal. If optional argument
3528 simple-first is t, first argument is already simplified."
3530 ((null simple-first)
3531 (equal (gnus-simplify-subject-fully s1)
3532 (gnus-simplify-subject-fully s2)))
3535 (gnus-simplify-subject-fully s2)))))
3537 ;; Returns a list of writable groups.
3538 (defun gnus-writable-groups ()
3539 (let ((alist gnus-newsrc-alist)
3541 (while (setq group (car (pop alist)))
3542 (unless (gnus-group-read-only-p group)
3543 (push group groups)))
3546 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
3548 (defun gnus-y-or-n-p (prompt)
3553 (defun gnus-yes-or-no-p (prompt)
3555 (yes-or-no-p prompt)
3558 ;; Check whether to use long file names.
3559 (defun gnus-use-long-file-name (symbol)
3560 ;; The variable has to be set...
3561 (and gnus-use-long-file-name
3562 ;; If it isn't a list, then we return t.
3563 (or (not (listp gnus-use-long-file-name))
3564 ;; If it is a list, and the list contains `symbol', we
3566 (not (memq symbol gnus-use-long-file-name)))))
3568 ;; I suspect there's a better way, but I haven't taken the time to do
3569 ;; it yet. -erik selberg@cs.washington.edu
3570 (defun gnus-dd-mmm (messy-date)
3571 "Return a string like DD-MMM from a big messy string"
3572 (let ((datevec (timezone-parse-date messy-date)))
3574 (or (aref datevec 2) "??")
3577 (nth (1- (string-to-number (aref datevec 1)))
3578 timezone-months-assoc))
3581 ;; Make a hash table (default and minimum size is 255).
3582 ;; Optional argument HASHSIZE specifies the table size.
3583 (defun gnus-make-hashtable (&optional hashsize)
3584 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0))
3586 ;; Make a number that is suitable for hashing; bigger than MIN and one
3588 (defun gnus-create-hash-size (min)
3594 ;; Show message if message has a lower level than `gnus-verbose'.
3595 ;; Guideline for numbers:
3596 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages
3597 ;; for things that take a long time, 7 - not very important messages
3598 ;; on stuff, 9 - messages inside loops.
3599 (defun gnus-message (level &rest args)
3600 (if (<= level gnus-verbose)
3601 (apply 'message args)
3602 ;; We have to do this format thingy here even if the result isn't
3603 ;; shown - the return value has to be the same as the return value
3605 (apply 'format args)))
3607 (defun gnus-functionp (form)
3608 "Return non-nil if FORM is funcallable."
3609 (or (and (symbolp form) (fboundp form))
3610 (and (listp form) (eq (car form) 'lambda))))
3612 ;; Generate a unique new group name.
3613 (defun gnus-generate-new-group-name (leaf)
3616 (while (gnus-gethash name gnus-newsrc-hashtb)
3617 (setq name (concat leaf "<" (int-to-string (setq num (1+ num))) ">")))
3620 ;; Find out whether the gnus-visual TYPE is wanted.
3621 (defun gnus-visual-p (&optional type class)
3622 (and gnus-visual ; Has to be non-nil, at least.
3623 (if (not type) ; We don't care about type.
3625 (if (listp gnus-visual) ; It's a list, so we check it.
3626 (or (memq type gnus-visual)
3627 (memq class gnus-visual))
3630 (defun gnus-parent-id (references)
3631 "Return the last Message-ID in REFERENCES."
3632 (when (and references
3633 (string-match "\\(<[^<>]+>\\)[ \t\n]*\\'" references))
3634 (substring references (match-beginning 1) (match-end 1))))
3636 (defun gnus-split-references (references)
3637 "Return a list of Message-IDs in REFERENCES."
3640 (while (string-match "<[^>]+>" references beg)
3641 (push (substring references (match-beginning 0) (setq beg (match-end 0)))
3645 (defun gnus-ephemeral-group-p (group)
3646 "Say whether GROUP is ephemeral or not."
3647 (gnus-group-get-parameter group 'quit-config))
3649 (defun gnus-group-quit-config (group)
3650 "Return the quit-config of GROUP."
3651 (gnus-group-get-parameter group 'quit-config))
3653 (defun gnus-simplify-mode-line ()
3654 "Make mode lines a bit simpler."
3655 (setq mode-line-modified "-- ")
3656 (when (listp mode-line-format)
3657 (make-local-variable 'mode-line-format)
3658 (setq mode-line-format (copy-sequence mode-line-format))
3659 (when (equal (nth 3 mode-line-format) " ")
3660 (setcar (nthcdr 3 mode-line-format) " "))))
3662 ;;; List and range functions
3664 (defun gnus-last-element (list)
3665 "Return last element of LIST."
3667 (setq list (cdr list)))
3670 (defun gnus-copy-sequence (list)
3671 "Do a complete, total copy of a list."
3672 (if (and (consp list) (not (consp (cdr list))))
3673 (cons (car list) (cdr list))
3674 (mapcar (lambda (elem) (if (consp elem)
3675 (if (consp (cdr elem))
3676 (gnus-copy-sequence elem)
3677 (cons (car elem) (cdr elem)))
3681 (defun gnus-set-difference (list1 list2)
3682 "Return a list of elements of LIST1 that do not appear in LIST2."
3683 (let ((list1 (copy-sequence list1)))
3685 (setq list1 (delq (car list2) list1))
3686 (setq list2 (cdr list2)))
3689 (defun gnus-sorted-complement (list1 list2)
3690 "Return a list of elements of LIST1 that do not appear in LIST2.
3691 Both lists have to be sorted over <."
3693 (if (or (null list1) (null list2))
3695 (while (and list1 list2)
3696 (cond ((= (car list1) (car list2))
3697 (setq list1 (cdr list1)
3699 ((< (car list1) (car list2))
3700 (setq out (cons (car list1) out))
3701 (setq list1 (cdr list1)))
3703 (setq out (cons (car list2) out))
3704 (setq list2 (cdr list2)))))
3705 (nconc (nreverse out) (or list1 list2)))))
3707 (defun gnus-intersection (list1 list2)
3710 (if (memq (car list2) list1)
3711 (setq result (cons (car list2) result)))
3712 (setq list2 (cdr list2)))
3715 (defun gnus-sorted-intersection (list1 list2)
3716 ;; LIST1 and LIST2 have to be sorted over <.
3718 (while (and list1 list2)
3719 (cond ((= (car list1) (car list2))
3720 (setq out (cons (car list1) out)
3723 ((< (car list1) (car list2))
3724 (setq list1 (cdr list1)))
3726 (setq list2 (cdr list2)))))
3729 (defun gnus-set-sorted-intersection (list1 list2)
3730 ;; LIST1 and LIST2 have to be sorted over <.
3731 ;; This function modifies LIST1.
3732 (let* ((top (cons nil list1))
3734 (while (and list1 list2)
3735 (cond ((= (car list1) (car list2))
3739 ((< (car list1) (car list2))
3740 (setcdr prev (cdr list1))
3741 (setq list1 (cdr list1)))
3743 (setq list2 (cdr list2)))))
3747 (defun gnus-compress-sequence (numbers &optional always-list)
3748 "Convert list of numbers to a list of ranges or a single range.
3749 If ALWAYS-LIST is non-nil, this function will always release a list of
3751 (let* ((first (car numbers))
3752 (last (car numbers))
3756 (if (not (listp (cdr numbers)))
3759 (cond ((= last (car numbers)) nil) ;Omit duplicated number
3760 ((= (1+ last) (car numbers)) ;Still in sequence
3761 (setq last (car numbers)))
3762 (t ;End of one sequence
3764 (cons (if (= first last) first
3765 (cons first last)) result))
3766 (setq first (car numbers))
3767 (setq last (car numbers))))
3768 (setq numbers (cdr numbers)))
3769 (if (and (not always-list) (null result))
3770 (if (= first last) (list first) (cons first last))
3771 (nreverse (cons (if (= first last) first (cons first last))
3774 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
3775 (defun gnus-uncompress-range (ranges)
3776 "Expand a list of ranges into a list of numbers.
3777 RANGES is either a single range on the form `(num . num)' or a list of
3779 (let (first last result)
3783 ((not (listp (cdr ranges)))
3784 (setq first (car ranges))
3785 (setq last (cdr ranges))
3786 (while (<= first last)
3787 (setq result (cons first result))
3788 (setq first (1+ first)))
3792 (if (atom (car ranges))
3793 (if (numberp (car ranges))
3794 (setq result (cons (car ranges) result)))
3795 (setq first (caar ranges))
3796 (setq last (cdar ranges))
3797 (while (<= first last)
3798 (setq result (cons first result))
3799 (setq first (1+ first))))
3800 (setq ranges (cdr ranges)))
3801 (nreverse result)))))
3803 (defun gnus-add-to-range (ranges list)
3804 "Return a list of ranges that has all articles from both RANGES and LIST.
3805 Note: LIST has to be sorted over `<'."
3807 (gnus-compress-sequence list t)
3808 (setq list (copy-sequence list))
3809 (or (listp (cdr ranges))
3810 (setq ranges (list ranges)))
3812 ilist lowest highest temp)
3813 (while (and ranges list)
3815 (setq lowest (or (and (atom (car ranges)) (car ranges))
3817 (while (and list (cdr list) (< (cadr list) lowest))
3818 (setq list (cdr list)))
3819 (if (< (car ilist) lowest)
3822 (setq list (cdr list))
3824 (setq out (nconc (gnus-compress-sequence ilist t) out))))
3825 (setq highest (or (and (atom (car ranges)) (car ranges))
3827 (while (and list (<= (car list) highest))
3828 (setq list (cdr list)))
3829 (setq ranges (cdr ranges)))
3831 (setq out (nconc (gnus-compress-sequence list t) out)))
3832 (setq out (sort out (lambda (r1 r2)
3833 (< (or (and (atom r1) r1) (car r1))
3834 (or (and (atom r2) r2) (car r2))))))
3837 (if (atom (car ranges))
3839 (if (atom (cadr ranges))
3840 (if (= (1+ (car ranges)) (cadr ranges))
3842 (setcar ranges (cons (car ranges)
3844 (setcdr ranges (cddr ranges))))
3845 (if (= (1+ (car ranges)) (caadr ranges))
3847 (setcar (cadr ranges) (car ranges))
3848 (setcar ranges (cadr ranges))
3849 (setcdr ranges (cddr ranges))))))
3851 (if (atom (cadr ranges))
3852 (if (= (1+ (cdar ranges)) (cadr ranges))
3854 (setcdr (car ranges) (cadr ranges))
3855 (setcdr ranges (cddr ranges))))
3856 (if (= (1+ (cdar ranges)) (caadr ranges))
3858 (setcdr (car ranges) (cdadr ranges))
3859 (setcdr ranges (cddr ranges)))))))
3860 (setq ranges (cdr ranges)))
3863 (defun gnus-remove-from-range (ranges list)
3864 "Return a list of ranges that has all articles from LIST removed from RANGES.
3865 Note: LIST has to be sorted over `<'."
3866 ;; !!! This function shouldn't look like this, but I've got a headache.
3867 (gnus-compress-sequence
3868 (gnus-sorted-complement
3869 (gnus-uncompress-range ranges) list)))
3871 (defun gnus-member-of-range (number ranges)
3872 (if (not (listp (cdr ranges)))
3873 (and (>= number (car ranges))
3874 (<= number (cdr ranges)))
3877 (if (numberp (car ranges))
3878 (>= number (car ranges))
3879 (>= number (caar ranges)))
3881 (if (if (numberp (car ranges))
3882 (= number (car ranges))
3883 (and (>= number (caar ranges))
3884 (<= number (cdar ranges))))
3885 (setq not-stop nil))
3886 (setq ranges (cdr ranges)))
3889 (defun gnus-range-length (range)
3890 "Return the length RANGE would have if uncompressed."
3891 (length (gnus-uncompress-range range)))
3893 (defun gnus-sublist-p (list sublist)
3894 "Test whether all elements in SUBLIST are members of LIST."
3897 (unless (memq (pop sublist) list)
3907 (defvar gnus-group-mode-map nil)
3908 (put 'gnus-group-mode 'mode-class 'special)
3910 (unless gnus-group-mode-map
3911 (setq gnus-group-mode-map (make-keymap))
3912 (suppress-keymap gnus-group-mode-map)
3916 " " gnus-group-read-group
3917 "=" gnus-group-select-group
3918 "\M- " gnus-group-unhidden-select-group
3919 "\r" gnus-group-select-group
3920 "\M-\r" gnus-group-quick-select-group
3921 "j" gnus-group-jump-to-group
3922 "n" gnus-group-next-unread-group
3923 "p" gnus-group-prev-unread-group
3924 "\177" gnus-group-prev-unread-group
3925 [delete] gnus-group-prev-unread-group
3926 "N" gnus-group-next-group
3927 "P" gnus-group-prev-group
3928 "\M-n" gnus-group-next-unread-group-same-level
3929 "\M-p" gnus-group-prev-unread-group-same-level
3930 "," gnus-group-best-unread-group
3931 "." gnus-group-first-unread-group
3932 "u" gnus-group-unsubscribe-current-group
3933 "U" gnus-group-unsubscribe-group
3934 "c" gnus-group-catchup-current
3935 "C" gnus-group-catchup-current-all
3936 "l" gnus-group-list-groups
3937 "L" gnus-group-list-all-groups
3939 "g" gnus-group-get-new-news
3940 "\M-g" gnus-group-get-new-news-this-group
3941 "R" gnus-group-restart
3942 "r" gnus-group-read-init-file
3943 "B" gnus-group-browse-foreign-server
3944 "b" gnus-group-check-bogus-groups
3945 "F" gnus-find-new-newsgroups
3946 "\C-c\C-d" gnus-group-describe-group
3947 "\M-d" gnus-group-describe-all-groups
3948 "\C-c\C-a" gnus-group-apropos
3949 "\C-c\M-\C-a" gnus-group-description-apropos
3950 "a" gnus-group-post-news
3951 "\ek" gnus-group-edit-local-kill
3952 "\eK" gnus-group-edit-global-kill
3953 "\C-k" gnus-group-kill-group
3954 "\C-y" gnus-group-yank-group
3955 "\C-w" gnus-group-kill-region
3956 "\C-x\C-t" gnus-group-transpose-groups
3957 "\C-c\C-l" gnus-group-list-killed
3958 "\C-c\C-x" gnus-group-expire-articles
3959 "\C-c\M-\C-x" gnus-group-expire-all-groups
3961 "s" gnus-group-save-newsrc
3962 "z" gnus-group-suspend
3963 "Z" gnus-group-clear-dribble
3966 "?" gnus-group-describe-briefly
3967 "\C-c\C-i" gnus-info-find-node
3968 "\M-e" gnus-group-edit-group-method
3969 "^" gnus-group-enter-server-mode
3970 gnus-mouse-2 gnus-mouse-pick-group
3971 "<" beginning-of-buffer
3974 "\C-c\C-s" gnus-group-sort-groups
3976 "\C-c\M-g" gnus-activate-all-groups
3977 "\M-&" gnus-group-universal-argument
3978 "#" gnus-group-mark-group
3979 "\M-#" gnus-group-unmark-group)
3982 (gnus-group-mark-map "M" gnus-group-mode-map)
3983 "m" gnus-group-mark-group
3984 "u" gnus-group-unmark-group
3985 "w" gnus-group-mark-region
3986 "m" gnus-group-mark-buffer
3987 "r" gnus-group-mark-regexp
3988 "U" gnus-group-unmark-all-groups)
3991 (gnus-group-group-map "G" gnus-group-mode-map)
3992 "d" gnus-group-make-directory-group
3993 "h" gnus-group-make-help-group
3994 "a" gnus-group-make-archive-group
3995 "k" gnus-group-make-kiboze-group
3996 "m" gnus-group-make-group
3997 "E" gnus-group-edit-group
3998 "e" gnus-group-edit-group-method
3999 "p" gnus-group-edit-group-parameters
4000 "v" gnus-group-add-to-virtual
4001 "V" gnus-group-make-empty-virtual
4002 "D" gnus-group-enter-directory
4003 "f" gnus-group-make-doc-group
4004 "r" gnus-group-rename-group
4005 "\177" gnus-group-delete-group
4006 [delete] gnus-group-delete-group)
4009 (gnus-group-soup-map "s" gnus-group-group-map)
4010 "b" gnus-group-brew-soup
4011 "w" gnus-soup-save-areas
4012 "s" gnus-soup-send-replies
4013 "p" gnus-soup-pack-packet
4014 "r" nnsoup-pack-replies)
4017 (gnus-group-sort-map "S" gnus-group-group-map)
4018 "s" gnus-group-sort-groups
4019 "a" gnus-group-sort-groups-by-alphabet
4020 "u" gnus-group-sort-groups-by-unread
4021 "l" gnus-group-sort-groups-by-level
4022 "v" gnus-group-sort-groups-by-score
4023 "r" gnus-group-sort-groups-by-rank
4024 "m" gnus-group-sort-groups-by-method)
4027 (gnus-group-list-map "A" gnus-group-mode-map)
4028 "k" gnus-group-list-killed
4029 "z" gnus-group-list-zombies
4030 "s" gnus-group-list-groups
4031 "u" gnus-group-list-all-groups
4032 "A" gnus-group-list-active
4033 "a" gnus-group-apropos
4034 "d" gnus-group-description-apropos
4035 "m" gnus-group-list-matching
4036 "M" gnus-group-list-all-matching
4037 "l" gnus-group-list-level)
4040 (gnus-group-score-map "W" gnus-group-mode-map)
4041 "f" gnus-score-flush-cache)
4044 (gnus-group-help-map "H" gnus-group-mode-map)
4045 "f" gnus-group-fetch-faq)
4048 (gnus-group-sub-map "S" gnus-group-mode-map)
4049 "l" gnus-group-set-current-level
4050 "t" gnus-group-unsubscribe-current-group
4051 "s" gnus-group-unsubscribe-group
4052 "k" gnus-group-kill-group
4053 "y" gnus-group-yank-group
4054 "w" gnus-group-kill-region
4055 "\C-k" gnus-group-kill-level
4056 "z" gnus-group-kill-all-zombies))
4058 (defun gnus-group-mode ()
4059 "Major mode for reading news.
4061 All normal editing commands are switched off.
4062 \\<gnus-group-mode-map>
4063 The group buffer lists (some of) the groups available. For instance,
4064 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
4065 lists all zombie groups.
4067 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
4068 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
4070 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
4072 The following commands are available:
4074 \\{gnus-group-mode-map}"
4076 (when (and menu-bar-mode
4077 (gnus-visual-p 'group-menu 'menu))
4078 (gnus-group-make-menu-bar))
4079 (kill-all-local-variables)
4080 (gnus-simplify-mode-line)
4081 (setq major-mode 'gnus-group-mode)
4082 (setq mode-name "Group")
4083 (gnus-group-set-mode-line)
4084 (setq mode-line-process nil)
4085 (use-local-map gnus-group-mode-map)
4086 (buffer-disable-undo (current-buffer))
4087 (setq truncate-lines t)
4088 (setq buffer-read-only t)
4089 (run-hooks 'gnus-group-mode-hook))
4091 (defun gnus-mouse-pick-group (e)
4092 "Enter the group under the mouse pointer."
4095 (gnus-group-read-group nil))
4097 ;; Look at LEVEL and find out what the level is really supposed to be.
4098 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
4099 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
4100 (defun gnus-group-default-level (&optional level number-or-nil)
4102 (gnus-group-use-permanent-levels
4103 (setq gnus-group-default-list-level
4104 (or level gnus-group-default-list-level))
4105 (or gnus-group-default-list-level gnus-level-subscribed))
4109 (or level gnus-group-default-list-level gnus-level-subscribed))))
4112 (defun gnus-slave-no-server (&optional arg)
4113 "Read network news as a slave, without connecting to local server"
4115 (gnus-no-server arg t))
4118 (defun gnus-no-server (&optional arg slave)
4120 If ARG is a positive number, Gnus will use that as the
4121 startup level. If ARG is nil, Gnus will be started at level 2.
4122 If ARG is non-nil and not a positive number, Gnus will
4123 prompt the user for the name of an NNTP server to use.
4124 As opposed to `gnus', this command will not connect to the local server."
4126 (make-local-variable 'gnus-group-use-permanent-levels)
4127 (setq gnus-group-use-permanent-levels t)
4128 (gnus (or arg (1- gnus-level-default-subscribed)) t slave))
4131 (defun gnus-slave (&optional arg)
4132 "Read news as a slave."
4134 (gnus arg nil 'slave))
4137 (defun gnus-other-frame (&optional arg)
4138 "Pop up a frame to read news."
4140 (if (get-buffer gnus-group-buffer)
4141 (let ((pop-up-frames t))
4143 (select-frame (make-frame))
4147 (defun gnus (&optional arg dont-connect slave)
4149 If ARG is non-nil and a positive number, Gnus will use that as the
4150 startup level. If ARG is non-nil and not a positive number, Gnus will
4151 prompt the user for the name of an NNTP server to use."
4154 (if (get-buffer gnus-group-buffer)
4156 (switch-to-buffer gnus-group-buffer)
4157 (gnus-group-get-new-news))
4160 (nnheader-init-server-buffer)
4161 (gnus-read-init-file)
4162 (setq gnus-slave slave)
4164 (gnus-group-setup-buffer)
4165 (let ((buffer-read-only nil))
4167 (if (not gnus-inhibit-startup-message)
4169 (gnus-group-startup-message)
4172 (let ((level (and (numberp arg) (> arg 0) arg))
4178 (gnus-start-news-server (and arg (not level))))))
4179 (if (and (not dont-connect)
4182 (run-hooks 'gnus-startup-hook)
4183 ;; NNTP server is successfully open.
4185 ;; Find the current startup file name.
4186 (setq gnus-current-startup-file
4187 (gnus-make-newsrc-file gnus-startup-file))
4189 ;; Read the dribble file.
4190 (and (or gnus-slave gnus-use-dribble-file) (gnus-dribble-read-file))
4192 (gnus-summary-make-display-table)
4193 ;; Do the actual startup.
4194 (gnus-setup-news nil level)
4195 ;; Generate the group buffer.
4196 (gnus-group-list-groups level)
4197 (gnus-group-first-unread-group)
4198 (gnus-configure-windows 'group)
4199 (gnus-group-set-mode-line))))))
4201 (defun gnus-unload ()
4202 "Unload all Gnus features."
4204 (or (boundp 'load-history)
4205 (error "Sorry, `gnus-unload' is not implemented in this Emacs version."))
4206 (let ((history load-history)
4209 (and (string-match "^\\(gnus\\|nn\\)" (caar history))
4210 (setq feature (cdr (assq 'provide (car history))))
4211 (unload-feature feature 'force))
4212 (setq history (cdr history)))))
4214 (defun gnus-compile ()
4215 "Byte-compile the user-defined format specs."
4217 (let ((entries gnus-format-specs)
4218 entry gnus-tmp-func)
4220 (gnus-message 7 "Compiling format specs...")
4223 (setq entry (pop entries))
4224 (if (eq (car entry) 'version)
4225 (setq gnus-format-specs (delq entry gnus-format-specs))
4226 (when (and (listp (caddr entry))
4227 (not (eq 'byte-code (caaddr entry))))
4228 (fset 'gnus-tmp-func
4229 `(lambda () ,(caddr entry)))
4230 (byte-compile 'gnus-tmp-func)
4231 (setcar (cddr entry) (gnus-byte-code 'gnus-tmp-func)))))
4233 (push (cons 'version emacs-version) gnus-format-specs)
4235 (gnus-message 7 "Compiling user specs...done"))))
4237 (defun gnus-indent-rigidly (start end arg)
4238 "Indent rigidly using only spaces and no tabs."
4241 (narrow-to-region start end)
4242 (indent-rigidly start end arg)
4243 (goto-char (point-min))
4244 (while (search-forward "\t" nil t)
4245 (replace-match " " t t)))))
4247 (defun gnus-group-startup-message (&optional x y)
4248 "Insert startup message in current buffer."
4249 ;; Insert the message.
4254 _ ___ __ ___ __ _ ___
4273 ;; And then hack it.
4274 (gnus-indent-rigidly (point-min) (point-max)
4275 (/ (max (- (window-width) (or x 46)) 0) 2))
4276 (goto-char (point-min))
4278 (let* ((pheight (count-lines (point-min) (point-max)))
4279 (wheight (window-height))
4280 (rest (- wheight pheight)))
4281 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
4283 (goto-char (point-min))
4284 (and (search-forward "Praxis" nil t)
4285 (put-text-property (match-beginning 0) (match-end 0) 'face 'bold))
4286 (goto-char (point-min))
4287 (let* ((mode-string (gnus-group-set-mode-line)))
4288 (setq mode-line-buffer-identification
4289 (list (concat gnus-version (substring (car mode-string) 4))))
4290 (set-buffer-modified-p t)))
4292 (defun gnus-group-setup-buffer ()
4293 (or (get-buffer gnus-group-buffer)
4295 (switch-to-buffer gnus-group-buffer)
4296 (gnus-add-current-to-buffer-list)
4298 (and gnus-carpal (gnus-carpal-setup-buffer 'group)))))
4300 (defun gnus-group-list-groups (&optional level unread lowest)
4301 "List newsgroups with level LEVEL or lower that have unread articles.
4302 Default is all subscribed groups.
4303 If argument UNREAD is non-nil, groups with no unread articles are also
4305 (interactive (list (if current-prefix-arg
4306 (prefix-numeric-value current-prefix-arg)
4308 (gnus-group-default-level nil t)
4309 gnus-group-default-list-level
4310 gnus-level-subscribed))))
4312 (setq level (car gnus-group-list-mode)
4313 unread (cdr gnus-group-list-mode)))
4314 (setq level (gnus-group-default-level level))
4315 (gnus-group-setup-buffer) ;May call from out of group buffer
4316 (gnus-update-format-specifications)
4317 (let ((case-fold-search nil)
4318 (props (text-properties-at (gnus-point-at-bol)))
4319 (group (gnus-group-group-name)))
4320 (funcall gnus-group-prepare-function level unread lowest)
4321 (if (zerop (buffer-size))
4322 (gnus-message 5 gnus-no-groups-message)
4323 (goto-char (point-max))
4324 (when (or (not gnus-group-goto-next-group-function)
4325 (not (funcall gnus-group-goto-next-group-function
4328 ;; Go to the first group with unread articles.
4329 (gnus-group-search-forward t)
4330 ;; Find the right group to put point on. If the current group
4331 ;; has disappeared in the new listing, try to find the next
4332 ;; one. If no next one can be found, just leave point at the
4333 ;; first newsgroup in the buffer.
4334 (if (not (gnus-goto-char
4336 (point-min) (point-max)
4337 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
4338 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
4340 (not (gnus-goto-char
4342 (point-min) (point-max) 'gnus-group
4344 (caar newsrc) gnus-active-hashtb)))))
4345 (setq newsrc (cdr newsrc)))
4346 (or newsrc (progn (goto-char (point-max))
4347 (forward-line -1)))))))
4348 ;; Adjust cursor point.
4349 (gnus-group-position-point))))
4351 (defun gnus-group-list-level (level &optional all)
4352 "List groups on LEVEL.
4353 If ALL (the prefix), also list groups that have no unread articles."
4354 (interactive "nList groups on level: \nP")
4355 (gnus-group-list-groups level all level))
4357 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
4358 "List all newsgroups with unread articles of level LEVEL or lower.
4359 If ALL is non-nil, list groups that have no unread articles.
4360 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
4361 If REGEXP, only list groups matching REGEXP."
4362 (set-buffer gnus-group-buffer)
4363 (let ((buffer-read-only nil)
4364 (newsrc (cdr gnus-newsrc-alist))
4365 (lowest (or lowest 1))
4366 info clevel unread group params)
4368 (if (< lowest gnus-level-zombie)
4369 ;; List living groups.
4371 (setq info (car newsrc)
4372 group (gnus-info-group info)
4373 params (gnus-info-params info)
4375 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
4376 (and unread ; This group might be bogus
4378 (string-match regexp group))
4379 (<= (setq clevel (gnus-info-level info)) level)
4381 (or all ; We list all groups?
4382 (and gnus-group-list-inactive-groups
4383 (eq unread t)) ; We list unactivated groups
4384 (> unread 0) ; We list groups with unread articles
4385 (and gnus-list-groups-with-ticked-articles
4386 (cdr (assq 'tick (gnus-info-marks info))))
4387 ; And groups with tickeds
4388 ;; Check for permanent visibility.
4389 (and gnus-permanently-visible-groups
4390 (string-match gnus-permanently-visible-groups
4392 (memq 'visible params)
4393 (cdr (assq 'visible params)))
4394 (gnus-group-insert-group-line
4395 group (gnus-info-level info)
4396 (gnus-info-marks info) unread (gnus-info-method info)))))
4398 ;; List dead groups.
4399 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
4400 (gnus-group-prepare-flat-list-dead
4401 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
4402 gnus-level-zombie ?Z
4404 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
4405 (gnus-group-prepare-flat-list-dead
4406 (setq gnus-killed-list (sort gnus-killed-list 'string<))
4407 gnus-level-killed ?K regexp))
4409 (gnus-group-set-mode-line)
4410 (setq gnus-group-list-mode (cons level all))
4411 (run-hooks 'gnus-group-prepare-hook)))
4413 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
4414 ;; List zombies and killed lists somewhat faster, which was
4415 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
4416 ;; this by ignoring the group format specification altogether.
4419 ;; This loop is used when listing groups that match some
4422 (setq group (pop groups))
4423 (when (string-match regexp group)
4424 (add-text-properties
4425 (point) (prog1 (1+ (point))
4426 (insert " " mark " *: " group "\n"))
4427 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4429 'gnus-level level))))
4430 ;; This loop is used when listing all groups.
4432 (add-text-properties
4433 (point) (prog1 (1+ (point))
4434 (insert " " mark " *: "
4435 (setq group (pop groups)) "\n"))
4436 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4438 'gnus-level level))))))
4440 (defmacro gnus-group-real-name (group)
4441 "Find the real name of a foreign newsgroup."
4442 `(let ((gname ,group))
4443 (if (string-match ":[^:]+$" gname)
4444 (substring gname (1+ (match-beginning 0)))
4447 (defsubst gnus-server-add-address (method)
4448 (let ((method-name (symbol-name (car method))))
4449 (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
4450 (not (assq (intern (concat method-name "-address")) method)))
4451 (append method (list (list (intern (concat method-name "-address"))
4455 (defsubst gnus-server-get-method (group method)
4456 ;; Input either a server name, and extended server name, or a
4457 ;; select method, and return a select method.
4458 (cond ((stringp method)
4459 (gnus-server-to-method method))
4460 ((and (stringp (car method)) group)
4461 (gnus-server-extend-method group method))
4463 (gnus-server-add-address method))))
4465 (defun gnus-server-to-method (server)
4466 "Map virtual server names to select methods."
4468 ;; Perhaps this is the native server?
4469 (and (equal server "native") gnus-select-method)
4470 ;; It should be in the server alist.
4471 (cdr (assoc server gnus-server-alist))
4472 ;; If not, we look through all the opened server
4473 ;; to see whether we can find it there.
4474 (let ((opened gnus-opened-servers))
4476 (not (equal server (format "%s:%s" (caaar opened)
4481 (defmacro gnus-server-equal (ss1 ss2)
4482 "Say whether two servers are equal."
4486 (and (= (length s1) (length s2))
4488 (while (and s1 (member (car s1) s2))
4492 (defun gnus-group-prefixed-name (group method)
4493 "Return the whole name from GROUP and METHOD."
4494 (and (stringp method) (setq method (gnus-server-to-method method)))
4495 (concat (format "%s" (car method))
4497 (or (assoc (format "%s" (car method))
4498 (gnus-methods-using 'address))
4499 (equal method gnus-message-archive-method))
4500 (not (string= (nth 1 method) "")))
4501 (concat "+" (nth 1 method)))
4504 (defun gnus-group-real-prefix (group)
4505 "Return the prefix of the current group name."
4506 (if (string-match "^[^:]+:" group)
4507 (substring group 0 (match-end 0))
4510 (defun gnus-group-method (group)
4511 "Return the server or method used for selecting GROUP."
4512 (let ((prefix (gnus-group-real-prefix group)))
4513 (if (equal prefix "")
4515 (let ((servers gnus-opened-servers)
4517 backend possible found)
4518 (if (string-match "^[^\\+]+\\+" prefix)
4519 (setq backend (intern (substring prefix 0 (1- (match-end 0))))
4520 server (substring prefix (match-end 0) (1- (length prefix))))
4521 (setq backend (intern (substring prefix 0 (1- (length prefix))))))
4523 (when (eq (caaar servers) backend)
4524 (setq possible (caar servers))
4525 (when (equal (cadaar servers) server)
4526 (setq found (caar servers))))
4528 (or (car (rassoc found gnus-server-alist))
4530 (car (rassoc possible gnus-server-alist))
4532 (list backend server))))))
4534 (defsubst gnus-secondary-method-p (method)
4535 "Return whether METHOD is a secondary select method."
4536 (let ((methods gnus-secondary-select-methods)
4537 (gmethod (gnus-server-get-method nil method)))
4539 (not (equal (gnus-server-get-method nil (car methods))
4541 (setq methods (cdr methods)))
4544 (defun gnus-group-foreign-p (group)
4545 "Say whether a group is foreign or not."
4546 (and (not (gnus-group-native-p group))
4547 (not (gnus-group-secondary-p group))))
4549 (defun gnus-group-native-p (group)
4550 "Say whether the group is native or not."
4551 (not (string-match ":" group)))
4553 (defun gnus-group-secondary-p (group)
4554 "Say whether the group is secondary or not."
4555 (gnus-secondary-method-p (gnus-find-method-for-group group)))
4557 (defun gnus-group-get-parameter (group &optional symbol)
4558 "Returns the group parameters for GROUP.
4559 If SYMBOL, return the value of that symbol in the group parameters."
4560 (let ((params (gnus-info-params (gnus-get-info group))))
4562 (gnus-group-parameter-value params symbol)
4565 (defun gnus-group-parameter-value (params symbol)
4566 "Return the value of SYMBOL in group PARAMS."
4567 (or (car (memq symbol params)) ; It's either a simple symbol
4568 (cdr (assq symbol params)))) ; or a cons.
4570 (defun gnus-group-add-parameter (group param)
4571 "Add parameter PARAM to GROUP."
4572 (let ((info (gnus-get-info group)))
4574 () ; This is a dead group. We just ignore it.
4575 ;; Cons the new param to the old one and update.
4576 (gnus-group-set-info (cons param (gnus-info-params info))
4579 (defun gnus-group-set-parameter (group name value)
4580 "Set parameter NAME to VALUE in GROUP."
4581 (let ((info (gnus-get-info group)))
4583 () ; This is a dead group. We just ignore it.
4584 (let ((old-params (gnus-info-params info))
4585 (new-params (list (cons name value))))
4587 (if (or (not (listp (car old-params)))
4588 (not (eq (caar old-params) name)))
4589 (setq new-params (append new-params (list (car old-params)))))
4590 (setq old-params (cdr old-params)))
4591 (gnus-group-set-info new-params group 'params)))))
4593 (defun gnus-group-add-score (group &optional score)
4594 "Add SCORE to the GROUP score.
4595 If SCORE is nil, add 1 to the score of GROUP."
4596 (let ((info (gnus-get-info group)))
4597 (gnus-info-set-score info (+ (gnus-info-score info) (or score 1)))))
4599 (defun gnus-summary-bubble-group ()
4600 "Increase the score of the current group.
4601 This is a handy function to add to `gnus-summary-exit-hook' to
4602 increase the score of each group you read."
4603 (gnus-group-add-score gnus-newsgroup-name))
4605 (defun gnus-group-set-info (info &optional method-only-group part)
4606 (let* ((entry (gnus-gethash
4607 (or method-only-group (gnus-info-group info))
4608 gnus-newsrc-hashtb))
4610 (info (if method-only-group (nth 2 entry) info)))
4611 (when method-only-group
4613 (error "Trying to change non-existent group %s" method-only-group))
4614 ;; We have received parts of the actual group info - either the
4615 ;; select method or the group parameters. We first check
4616 ;; whether we have to extend the info, and if so, do that.
4617 (let ((len (length info))
4618 (total (if (eq part 'method) 5 6)))
4620 (setcdr (nthcdr (1- len) info)
4621 (make-list (- total len) nil)))
4622 ;; Then we enter the new info.
4623 (setcar (nthcdr (1- total) info) part-info)))
4625 ;; This is a new group, so we just create it.
4627 (set-buffer gnus-group-buffer)
4628 (if (gnus-info-method info)
4629 ;; It's a foreign group...
4630 (gnus-group-make-group
4631 (gnus-group-real-name (gnus-info-group info))
4632 (prin1-to-string (car (gnus-info-method info)))
4633 (nth 1 (gnus-info-method info)))
4634 ;; It's a native group.
4635 (gnus-group-make-group (gnus-info-group info)))
4636 (gnus-message 6 "Note: New group created")
4638 (gnus-gethash (gnus-group-prefixed-name
4639 (gnus-group-real-name (gnus-info-group info))
4640 (or (gnus-info-method info) gnus-select-method))
4641 gnus-newsrc-hashtb))))
4642 ;; Whether it was a new group or not, we now have the entry, so we
4643 ;; can do the update.
4646 (setcar (nthcdr 2 entry) info)
4647 (when (and (not (eq (car entry) t))
4648 (gnus-active (gnus-info-group info)))
4649 (let ((marked (gnus-info-marks info)))
4650 (setcar entry (length (gnus-list-of-unread-articles
4652 (error "No such group: %s" (gnus-info-group info)))))
4654 (defun gnus-group-set-method-info (group select-method)
4655 (gnus-group-set-info select-method group 'method))
4657 (defun gnus-group-set-params-info (group params)
4658 (gnus-group-set-info params group 'params))
4660 (defun gnus-group-update-group-line ()
4661 "Update the current line in the group buffer."
4662 (let* ((buffer-read-only nil)
4663 (group (gnus-group-group-name))
4664 (gnus-group-indentation (gnus-group-group-indentation))
4665 (entry (and group (gnus-gethash group gnus-newsrc-hashtb))))
4667 (not (gnus-ephemeral-group-p group))
4669 (concat "(gnus-group-set-info '"
4670 (prin1-to-string (nth 2 entry)) ")")))
4672 (gnus-group-insert-group-line-info group)
4674 (gnus-group-position-point)))
4676 (defun gnus-group-insert-group-line-info (group)
4677 "Insert GROUP on the current line."
4678 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
4682 ;; (Un)subscribed group.
4683 (setq info (nth 2 entry))
4684 (gnus-group-insert-group-line
4685 group (gnus-info-level info) (gnus-info-marks info)
4686 (or (car entry) t) (gnus-info-method info)))
4687 ;; This group is dead.
4688 (gnus-group-insert-group-line
4690 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
4692 (if (setq active (gnus-active group))
4693 (- (1+ (cdr active)) (car active)) 0)
4696 (defun gnus-group-insert-group-line
4697 (gnus-tmp-group gnus-tmp-level gnus-tmp-marked number
4699 "Insert a group line in the group buffer."
4700 (let* ((gnus-tmp-active (gnus-active gnus-tmp-group))
4701 (gnus-tmp-number-total
4703 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
4705 (gnus-tmp-number-of-unread
4706 (if (numberp number) (int-to-string (max 0 number))
4708 (gnus-tmp-number-of-read
4709 (if (numberp number)
4710 (int-to-string (max 0 (- gnus-tmp-number-total number)))
4712 (gnus-tmp-subscribed
4713 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
4714 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
4715 ((= gnus-tmp-level gnus-level-zombie) ?Z)
4717 (gnus-tmp-qualified-group (gnus-group-real-name gnus-tmp-group))
4718 (gnus-tmp-newsgroup-description
4719 (if gnus-description-hashtb
4720 (or (gnus-gethash gnus-tmp-group gnus-description-hashtb) "")
4723 (if (member gnus-tmp-group gnus-moderated-list) ?m ? ))
4724 (gnus-tmp-moderated-string
4725 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
4727 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
4728 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
4729 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
4730 (gnus-tmp-news-method-string
4732 (format "(%s:%s)" (car gnus-tmp-method)
4733 (cadr gnus-tmp-method)) ""))
4734 (gnus-tmp-marked-mark
4735 (if (and (numberp number)
4737 (cdr (assq 'tick gnus-tmp-marked)))
4739 (gnus-tmp-process-marked
4740 (if (member gnus-tmp-group gnus-group-marked)
4741 gnus-process-mark ? ))
4742 (buffer-read-only nil)
4743 header gnus-tmp-header) ; passed as parameter to user-funcs.
4745 (add-text-properties
4749 (eval gnus-group-line-format-spec))
4750 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
4751 gnus-unread ,(if (numberp number)
4752 (string-to-int gnus-tmp-number-of-unread)
4754 gnus-marked ,gnus-tmp-marked-mark
4755 gnus-indentation ,gnus-group-indentation
4756 gnus-level ,gnus-tmp-level))
4757 (when (gnus-visual-p 'group-highlight 'highlight)
4759 (run-hooks 'gnus-group-update-hook)
4761 ;; Allow XEmacs to remove front-sticky text properties.
4762 (gnus-group-remove-excess-properties)))
4764 (defun gnus-group-update-group (group &optional visible-only)
4765 "Update all lines where GROUP appear.
4766 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
4769 (set-buffer gnus-group-buffer)
4770 ;; The buffer may be narrowed.
4773 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
4775 found buffer-read-only visible)
4776 ;; Enter the current status into the dribble buffer.
4777 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
4778 (if (and entry (not (gnus-ephemeral-group-p group)))
4780 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
4782 ;; Find all group instances. If topics are in use, each group
4783 ;; may be listed in more than once.
4784 (while (setq loc (text-property-any
4785 loc (point-max) 'gnus-group ident))
4788 (let ((gnus-group-indentation (gnus-group-group-indentation)))
4790 (gnus-group-insert-group-line-info group))
4791 (setq loc (1+ loc)))
4792 (unless (or found visible-only)
4793 ;; No such line in the buffer, find out where it's supposed to
4794 ;; go, and insert it there (or at the end of the buffer).
4795 (if gnus-goto-missing-group-function
4796 (funcall gnus-goto-missing-group-function group)
4797 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
4798 (while (and entry (car entry)
4802 (point-min) (point-max)
4803 'gnus-group (gnus-intern-safe
4804 (caar entry) gnus-active-hashtb)))))
4805 (setq entry (cdr entry)))
4806 (or entry (goto-char (point-max)))))
4807 ;; Finally insert the line.
4808 (let ((gnus-group-indentation (gnus-group-group-indentation)))
4809 (gnus-group-insert-group-line-info group)))
4810 (gnus-group-set-mode-line)))))
4812 (defun gnus-group-set-mode-line ()
4813 (when (memq 'group gnus-updated-mode-lines)
4814 (let* ((gformat (or gnus-group-mode-line-format-spec
4815 (setq gnus-group-mode-line-format-spec
4817 gnus-group-mode-line-format
4818 gnus-group-mode-line-format-alist))))
4819 (gnus-tmp-news-server (car (cdr gnus-select-method)))
4820 (gnus-tmp-news-method (car gnus-select-method))
4822 gnus-tmp-header ;Dummy binding for user-defined formats
4823 ;; Get the resulting string.
4824 (mode-string (eval gformat)))
4825 ;; If the line is too long, we chop it off.
4826 (when (> (length mode-string) max-len)
4827 (setq mode-string (substring mode-string 0 (- max-len 4))))
4829 (setq mode-line-buffer-identification (list mode-string))
4830 (set-buffer-modified-p t)))))
4832 (defun gnus-group-group-name ()
4833 "Get the name of the newsgroup on the current line."
4834 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
4835 (and group (symbol-name group))))
4837 (defun gnus-group-group-level ()
4838 "Get the level of the newsgroup on the current line."
4839 (get-text-property (gnus-point-at-bol) 'gnus-level))
4841 (defun gnus-group-group-indentation ()
4842 "Get the indentation of the newsgroup on the current line."
4843 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation) ""))
4845 (defun gnus-group-group-unread ()
4846 "Get the number of unread articles of the newsgroup on the current line."
4847 (get-text-property (gnus-point-at-bol) 'gnus-unread))
4849 (defun gnus-group-search-forward (&optional backward all level first-too)
4850 "Find the next newsgroup with unread articles.
4851 If BACKWARD is non-nil, find the previous newsgroup instead.
4852 If ALL is non-nil, just find any newsgroup.
4853 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
4855 If FIRST-TOO, the current line is also eligible as a target."
4856 (let ((way (if backward -1 1))
4857 (low gnus-level-killed)
4860 (if (and backward (progn (beginning-of-line)) (bobp))
4862 (or first-too (forward-line way))
4870 (get-text-property (point) 'gnus-unread)))
4871 (and (numberp unread) (> unread 0)))
4872 (setq lev (get-text-property (point)
4874 (<= lev gnus-level-subscribed)))
4876 (and (setq lev (get-text-property (point)
4885 (zerop (forward-line way)))))
4887 (progn (gnus-group-position-point) t)
4888 (goto-char (or pos beg))
4891 ;;; Gnus group mode commands
4895 (defun gnus-group-mark-group (n &optional unmark no-advance)
4896 "Mark the current group."
4898 (let ((buffer-read-only nil)
4902 (setq group (gnus-group-group-name))
4906 (or (cdr (assq 'process gnus-group-mark-positions)) 2))
4911 (setq gnus-group-marked (delete group gnus-group-marked)))
4913 (setq gnus-group-marked
4914 (cons group (delete group gnus-group-marked))))
4916 (or no-advance (zerop (gnus-group-next-group 1))))
4918 (gnus-summary-position-point)
4921 (defun gnus-group-unmark-group (n)
4922 "Remove the mark from the current group."
4924 (gnus-group-mark-group n 'unmark)
4925 (gnus-group-position-point))
4927 (defun gnus-group-unmark-all-groups ()
4928 "Unmark all groups."
4929 (let ((groups gnus-group-marked))
4932 (gnus-group-remove-mark (pop groups)))))
4933 (gnus-group-position-point))
4935 (defun gnus-group-mark-region (unmark beg end)
4936 "Mark all groups between point and mark.
4937 If UNMARK, remove the mark instead."
4938 (interactive "P\nr")
4939 (let ((num (count-lines beg end)))
4942 (- num (gnus-group-mark-group num unmark)))))
4944 (defun gnus-group-mark-buffer (&optional unmark)
4945 "Mark all groups in the buffer.
4946 If UNMARK, remove the mark instead."
4948 (gnus-group-mark-region unmark (point-min) (point-max)))
4950 (defun gnus-group-mark-regexp (regexp)
4951 "Mark all groups that match some regexp."
4952 (interactive "sMark (regexp): ")
4953 (let ((alist (cdr gnus-newsrc-alist))
4956 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
4957 (gnus-group-set-mark group))))
4958 (gnus-group-position-point))
4960 (defun gnus-group-remove-mark (group)
4961 "Remove the process mark from GROUP and move point there.
4962 Return nil if the group isn't displayed."
4963 (if (gnus-group-goto-group group)
4965 (gnus-group-mark-group 1 'unmark t)
4967 (setq gnus-group-marked
4968 (delete group gnus-group-marked))
4971 (defun gnus-group-set-mark (group)
4972 "Set the process mark on GROUP."
4973 (if (gnus-group-goto-group group)
4975 (gnus-group-mark-group 1 nil t))
4976 (setq gnus-group-marked
4977 (cons group (delete group gnus-group-marked)))))
4979 (defun gnus-group-universal-argument (arg &optional groups func)
4980 "Perform any command on all groups accoring to the process/prefix convention."
4982 (let ((groups (or groups (gnus-group-process-prefix arg)))
4984 (if (eq (setq func (or func
4987 (substitute-command-keys
4988 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
4991 (message "Undefined key")
4994 (gnus-group-remove-mark (setq group (pop groups)))
4995 (command-execute func))))
4996 (gnus-group-position-point))
4998 (defun gnus-group-process-prefix (n)
4999 "Return a list of groups to work on.
5000 Take into consideration N (the prefix) and the list of marked groups."
5003 (setq n (prefix-numeric-value n))
5004 ;; There is a prefix, so we return a list of the N next
5006 (let ((way (if (< n 0) -1 1))
5011 (setq group (gnus-group-group-name)))
5012 (setq groups (cons group groups))
5014 (gnus-group-next-group way)))
5016 ((and (boundp 'transient-mark-mode)
5019 ;; Work on the region between point and mark.
5020 (let ((max (max (point) (mark)))
5023 (goto-char (min (point) (mark)))
5026 (push (gnus-group-group-name) groups)
5027 (zerop (gnus-group-next-group 1))
5029 (nreverse groups))))
5031 ;; No prefix, but a list of marked articles.
5032 (reverse gnus-group-marked))
5034 ;; Neither marked articles or a prefix, so we return the
5036 (let ((group (gnus-group-group-name)))
5037 (and group (list group))))))
5039 ;; Selecting groups.
5041 (defun gnus-group-read-group (&optional all no-article group)
5042 "Read news in this newsgroup.
5043 If the prefix argument ALL is non-nil, already read articles become
5044 readable. IF ALL is a number, fetch this number of articles. If the
5045 optional argument NO-ARTICLE is non-nil, no article will be
5046 auto-selected upon group entry. If GROUP is non-nil, fetch that
5049 (let ((group (or group (gnus-group-group-name)))
5050 number active marked entry)
5051 (or group (error "No group on current line"))
5052 (setq marked (nth 3 (nth 2 (setq entry (gnus-gethash
5053 group gnus-newsrc-hashtb)))))
5054 ;; This group might be a dead group. In that case we have to get
5055 ;; the number of unread articles from `gnus-active-hashtb'.
5057 (cond ((numberp all) all)
5059 ((setq active (gnus-active group))
5060 (- (1+ (cdr active)) (car active)))))
5061 (gnus-summary-read-group
5062 group (or all (and (numberp number)
5063 (zerop (+ number (length (cdr (assq 'tick marked)))
5064 (length (cdr (assq 'dormant marked)))))))
5067 (defun gnus-group-select-group (&optional all)
5068 "Select this newsgroup.
5069 No article is selected automatically.
5070 If ALL is non-nil, already read articles become readable.
5071 If ALL is a number, fetch this number of articles."
5073 (gnus-group-read-group all t))
5075 (defun gnus-group-quick-select-group (&optional all)
5076 "Select the current group \"quickly\".
5077 This means that no highlighting or scoring will be performed."
5080 gnus-score-find-score-files-function
5081 gnus-apply-kill-hook
5082 gnus-summary-expunge-below)
5083 (gnus-group-read-group all t)))
5085 (defun gnus-group-visible-select-group (&optional all)
5086 "Select the current group without hiding any articles."
5088 (let ((gnus-inhibit-limiting t))
5089 (gnus-group-read-group all t)))
5092 (defun gnus-fetch-group (group)
5093 "Start Gnus if necessary and enter GROUP.
5094 Returns whether the fetching was successful or not."
5095 (interactive "sGroup name: ")
5096 (or (get-buffer gnus-group-buffer)
5098 (gnus-group-select-group))
5100 ;; Enter a group that is not in the group buffer. Non-nil is returned
5101 ;; if selection was successful.
5102 (defun gnus-group-read-ephemeral-group
5103 (group method &optional activate quit-config)
5104 (let ((group (if (gnus-group-foreign-p group) group
5105 (gnus-group-prefixed-name group method))))
5108 `(t nil (,group ,gnus-level-default-subscribed nil nil ,method
5109 ((quit-config . ,(if quit-config quit-config
5110 (cons (current-buffer) 'summary))))))
5112 (set-buffer gnus-group-buffer)
5113 (or (gnus-check-server method)
5114 (error "Unable to contact server: %s" (gnus-status-message method)))
5115 (if activate (or (gnus-request-group group)
5116 (error "Couldn't request group")))
5118 (gnus-group-read-group t t group)
5122 (defun gnus-group-jump-to-group (group)
5123 "Jump to newsgroup GROUP."
5125 (list (completing-read
5126 "Group: " gnus-active-hashtb nil
5127 (memq gnus-select-method gnus-have-read-active-file))))
5129 (if (equal group "")
5130 (error "Empty group name"))
5132 (let ((b (text-property-any
5133 (point-min) (point-max)
5134 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
5135 (unless (gnus-ephemeral-group-p group)
5137 ;; Either go to the line in the group buffer...
5139 ;; ... or insert the line.
5142 (gnus-activate-group group)
5143 (error "%s error: %s" group (gnus-status-message group)))
5145 (gnus-group-update-group group)
5146 (goto-char (text-property-any
5147 (point-min) (point-max)
5148 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))
5149 ;; Adjust cursor point.
5150 (gnus-group-position-point)))
5152 (defun gnus-group-goto-group (group)
5153 "Goto to newsgroup GROUP."
5155 (let ((b (text-property-any (point-min) (point-max)
5156 'gnus-group (gnus-intern-safe
5157 group gnus-active-hashtb))))
5158 (and b (goto-char b)))))
5160 (defun gnus-group-next-group (n)
5161 "Go to next N'th newsgroup.
5162 If N is negative, search backward instead.
5163 Returns the difference between N and the number of skips actually
5166 (gnus-group-next-unread-group n t))
5168 (defun gnus-group-next-unread-group (n &optional all level)
5169 "Go to next N'th unread newsgroup.
5170 If N is negative, search backward instead.
5171 If ALL is non-nil, choose any newsgroup, unread or not.
5172 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
5173 such group can be found, the next group with a level higher than
5175 Returns the difference between N and the number of skips actually
5178 (let ((backward (< n 0))
5181 (gnus-group-search-forward
5182 backward (or (not gnus-group-goto-unread) all) level))
5184 (if (/= 0 n) (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
5185 (if level " on this level or higher" "")))
5188 (defun gnus-group-prev-group (n)
5189 "Go to previous N'th newsgroup.
5190 Returns the difference between N and the number of skips actually
5193 (gnus-group-next-unread-group (- n) t))
5195 (defun gnus-group-prev-unread-group (n)
5196 "Go to previous N'th unread newsgroup.
5197 Returns the difference between N and the number of skips actually
5200 (gnus-group-next-unread-group (- n)))
5202 (defun gnus-group-next-unread-group-same-level (n)
5203 "Go to next N'th unread newsgroup on the same level.
5204 If N is negative, search backward instead.
5205 Returns the difference between N and the number of skips actually
5208 (gnus-group-next-unread-group n t (gnus-group-group-level))
5209 (gnus-group-position-point))
5211 (defun gnus-group-prev-unread-group-same-level (n)
5212 "Go to next N'th unread newsgroup on the same level.
5213 Returns the difference between N and the number of skips actually
5216 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
5217 (gnus-group-position-point))
5219 (defun gnus-group-best-unread-group (&optional exclude-group)
5220 "Go to the group with the highest level.
5221 If EXCLUDE-GROUP, do not go to that group."
5223 (goto-char (point-min))
5226 (while (setq unread (get-text-property (point) 'gnus-unread))
5227 (if (and (numberp unread) (> unread 0))
5229 (if (and (< (get-text-property (point) 'gnus-level) best)
5230 (or (not exclude-group)
5231 (not (equal exclude-group (gnus-group-group-name)))))
5233 (setq best (get-text-property (point) 'gnus-level))
5234 (setq best-point (point))))))
5236 (if best-point (goto-char best-point))
5237 (gnus-summary-position-point)
5238 (and best-point (gnus-group-group-name))))
5240 (defun gnus-group-first-unread-group ()
5241 "Go to the first group with unread articles."
5244 (let ((opoint (point))
5246 (goto-char (point-min))
5247 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
5248 (and (numberp unread) ; Not a topic.
5249 (not (zerop unread))) ; Has unread articles.
5250 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
5253 nil)) ; Not success.
5254 (gnus-group-position-point)))
5256 (defun gnus-group-enter-server-mode ()
5257 "Jump to the server buffer."
5259 (gnus-enter-server-buffer))
5261 (defun gnus-group-make-group (name &optional method address)
5262 "Add a new newsgroup.
5263 The user will be prompted for a NAME, for a select METHOD, and an
5267 (read-string "Group name: ")
5270 "Method: " (append gnus-valid-select-methods gnus-server-alist)
5272 (if (assoc method gnus-valid-select-methods)
5274 (if (memq 'prompt-address
5275 (assoc method gnus-valid-select-methods))
5276 (read-string "Address: ")
5278 (list method "")))))
5281 (set-buffer gnus-group-buffer)
5282 (let* ((meth (and method (if address (list (intern method) address)
5284 (nname (if method (gnus-group-prefixed-name name meth) name))
5286 (and (gnus-gethash nname gnus-newsrc-hashtb)
5287 (error "Group %s already exists" nname))
5288 (gnus-group-change-level
5289 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
5290 gnus-level-default-subscribed gnus-level-killed
5291 (and (gnus-group-group-name)
5292 (gnus-gethash (gnus-group-group-name)
5293 gnus-newsrc-hashtb))
5295 (gnus-set-active nname (cons 1 0))
5296 (or (gnus-ephemeral-group-p name)
5298 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")")))
5299 (gnus-group-insert-group-line-info nname)
5301 (when (assoc (symbol-name (car method)) gnus-valid-select-methods)
5302 (require (car method)))
5303 (gnus-check-server method)
5304 (and (gnus-check-backend-function 'request-create-group nname)
5305 (gnus-request-create-group nname))
5308 (defun gnus-group-delete-group (group &optional force)
5309 "Delete the current group.
5310 If FORCE (the prefix) is non-nil, all the articles in the group will
5311 be deleted. This is \"deleted\" as in \"removed forever from the face
5312 of the Earth\". There is no undo."
5314 (list (gnus-group-group-name)
5315 current-prefix-arg))
5316 (or group (error "No group to rename"))
5317 (or (gnus-check-backend-function 'request-delete-group group)
5318 (error "This backend does not support group deletion"))
5320 (if (not (gnus-yes-or-no-p
5322 "Do you really want to delete %s%s? "
5323 group (if force " and all its contents" ""))))
5325 (gnus-message 6 "Deleting group %s..." group)
5326 (if (not (gnus-request-delete-group group force))
5328 (gnus-message 3 "Couldn't delete group %s" group)
5330 (gnus-message 6 "Deleting group %s...done" group)
5331 (gnus-group-goto-group group)
5332 (gnus-group-kill-group 1 t)
5334 (gnus-group-position-point)))
5336 (defun gnus-group-rename-group (group new-name)
5339 (gnus-group-group-name)
5341 (or (gnus-check-backend-function
5342 'request-rename-group (gnus-group-group-name))
5343 (error "This backend does not support renaming groups"))
5344 (read-string "New group name: "))))
5346 (or (gnus-check-backend-function 'request-rename-group group)
5347 (error "This backend does not support renaming groups"))
5349 (or group (error "No group to rename"))
5350 (and (string-match "^[ \t]*$" new-name)
5351 (error "Not a valid group name"))
5353 ;; We find the proper prefixed name.
5355 (gnus-group-prefixed-name
5356 (gnus-group-real-name new-name)
5357 (gnus-info-method (gnus-get-info group))))
5359 (gnus-message 6 "Renaming group %s to %s..." group new-name)
5361 (if (not (gnus-request-rename-group group new-name))
5363 (gnus-message 3 "Couldn't rename group %s to %s" group new-name)
5365 ;; We rename the group internally by killing it...
5366 (gnus-group-goto-group group)
5367 (gnus-group-kill-group)
5368 ;; ... changing its name ...
5369 (setcar (cdr (car gnus-list-of-killed-groups))
5371 ;; ... and then yanking it. Magic!
5372 (gnus-group-yank-group)
5373 (gnus-set-active new-name (gnus-active group))
5374 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
5376 (gnus-group-position-point)))
5378 (defun gnus-group-edit-group (group &optional part)
5379 "Edit the group on the current line."
5380 (interactive (list (gnus-group-group-name)))
5381 (let ((done-func '(lambda ()
5382 "Exit editing mode and update the information."
5384 (gnus-group-edit-group-done 'part 'group)))
5385 (part (or part 'info))
5386 (winconf (current-window-configuration))
5388 (or group (error "No group on current line"))
5389 (or (setq info (gnus-get-info group))
5390 (error "Killed group; can't be edited"))
5391 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5392 (gnus-configure-windows 'edit-group)
5393 (gnus-add-current-to-buffer-list)
5395 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
5396 (use-local-map (copy-keymap emacs-lisp-mode-map))
5397 (local-set-key "\C-c\C-c" done-func)
5398 (make-local-variable 'gnus-prev-winconf)
5399 (setq gnus-prev-winconf winconf)
5400 ;; We modify the func to let it know what part it is editing.
5401 (setcar (cdr (nth 4 done-func)) (list 'quote part))
5402 (setcar (cdr (cdr (nth 4 done-func))) group)
5407 ";; Type `C-c C-c' after editing the select method.\n\n")
5409 ";; Type `C-c C-c' after editing the group parameters.\n\n")
5411 ";; Type `C-c C-c' after editing the group info.\n\n")))
5414 (cond ((eq part 'method)
5415 (or (gnus-info-method info) "native"))
5417 (gnus-info-params info))
5421 (defun gnus-group-edit-group-method (group)
5422 "Edit the select method of GROUP."
5423 (interactive (list (gnus-group-group-name)))
5424 (gnus-group-edit-group group 'method))
5426 (defun gnus-group-edit-group-parameters (group)
5427 "Edit the group parameters of GROUP."
5428 (interactive (list (gnus-group-group-name)))
5429 (gnus-group-edit-group group 'params))
5431 (defun gnus-group-edit-group-done (part group)
5432 "Get info from buffer, update variables and jump to the group buffer."
5433 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5434 (goto-char (point-min))
5435 (let* ((form (read (current-buffer)))
5436 (winconf gnus-prev-winconf)
5437 (new-group (when (eq part 'info)
5438 (if (or (not (nth 4 form))
5440 gnus-select-method (nth 4 form)))
5441 (gnus-group-real-name (car form))
5442 (gnus-group-prefixed-name
5443 (gnus-group-real-name (car form)) (nth 4 form))))))
5447 (when new-group (setcar form new-group))
5448 (gnus-group-set-info form))
5449 (gnus-group-set-info form group part))
5450 (kill-buffer (current-buffer))
5451 (and winconf (set-window-configuration winconf))
5452 (set-buffer gnus-group-buffer)
5453 (when (and new-group
5454 (not (equal new-group group)))
5455 (when (gnus-group-goto-group group)
5456 (gnus-group-kill-group 1))
5457 (gnus-activate-group new-group))
5458 (gnus-group-update-group (or new-group group))
5459 (gnus-group-position-point)))
5461 (defun gnus-group-make-help-group ()
5462 "Create the Gnus documentation group."
5464 (let ((path load-path)
5465 (name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
5467 (and (gnus-gethash name gnus-newsrc-hashtb)
5468 (error "Documentation group already exists"))
5470 (setq dir (file-name-as-directory (expand-file-name (pop path)))
5472 (when (or (file-exists-p (setq file (concat dir "gnus-tut.txt")))
5474 (setq file (concat (file-name-directory
5475 (directory-file-name dir))
5476 "etc/gnus-tut.txt"))))
5479 (message "Couldn't find doc group")
5480 (gnus-group-make-group
5481 (gnus-group-real-name name)
5483 (list 'nndoc-address file)
5484 (list 'nndoc-article-type 'mbox)))))
5485 (gnus-group-position-point))
5487 (defun gnus-group-make-doc-group (file type)
5488 "Create a group that uses a single file as the source."
5490 (list (read-file-name "File name: ")
5491 (and current-prefix-arg 'ask)))
5492 (when (eq type 'ask)
5497 "%sFile type (mbox, babyl, digest, forward, mmfd, guess) [mbdfag]: "
5499 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
5500 ((= char ?b) 'babyl)
5501 ((= char ?d) 'digest)
5502 ((= char ?f) 'forward)
5504 (t (setq err (format "%c unknown. " char))
5507 (let* ((file (expand-file-name file))
5508 (name (gnus-generate-new-group-name
5509 (gnus-group-prefixed-name
5510 (file-name-nondirectory file) '(nndoc "")))))
5511 (gnus-group-make-group
5512 (gnus-group-real-name name)
5514 (list 'nndoc-address file)
5515 (list 'nndoc-article-type (or type 'guess))))
5517 (gnus-group-position-point)))
5519 (defun gnus-group-make-archive-group (&optional all)
5520 "Create the (ding) Gnus archive group of the most recent articles.
5521 Given a prefix, create a full group."
5523 (let ((group (gnus-group-prefixed-name
5524 (if all "ding.archives" "ding.recent") '(nndir ""))))
5525 (and (gnus-gethash group gnus-newsrc-hashtb)
5526 (error "Archive group already exists"))
5527 (gnus-group-make-group
5528 (gnus-group-real-name group)
5529 (list 'nndir (if all "hpc" "edu")
5530 (list 'nndir-directory
5531 (if all gnus-group-archive-directory
5532 gnus-group-recent-archive-directory)))))
5534 (gnus-group-position-point))
5536 (defun gnus-group-make-directory-group (dir)
5537 "Create an nndir group.
5538 The user will be prompted for a directory. The contents of this
5539 directory will be used as a newsgroup. The directory should contain
5540 mail messages or news articles in files that have numeric names."
5542 (list (read-file-name "Create group from directory: ")))
5543 (or (file-exists-p dir) (error "No such directory"))
5544 (or (file-directory-p dir) (error "Not a directory"))
5548 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
5550 (gnus-group-prefixed-name
5551 (concat (file-name-as-directory (directory-file-name dir))
5554 (setq ext (format "<%d>" (setq i (1+ i)))))
5555 (gnus-group-make-group
5556 (gnus-group-real-name group)
5557 (list 'nndir group (list 'nndir-directory dir))))
5559 (gnus-group-position-point))
5561 (defun gnus-group-make-kiboze-group (group address scores)
5562 "Create an nnkiboze group.
5563 The user will be prompted for a name, a regexp to match groups, and
5564 score file entries for articles to include in the group."
5567 (read-string "nnkiboze group name: ")
5568 (read-string "Source groups (regexp): ")
5569 (let ((headers (mapcar (lambda (group) (list group))
5570 '("subject" "from" "number" "date" "message-id"
5571 "references" "chars" "lines" "xref"
5572 "followup" "all" "body" "head")))
5573 scores header regexp regexps)
5574 (while (not (equal "" (setq header (completing-read
5575 "Match on header: " headers nil t))))
5577 (while (not (equal "" (setq regexp (read-string
5578 (format "Match on %s (string): "
5580 (setq regexps (cons (list regexp nil nil 'r) regexps)))
5581 (setq scores (cons (cons header regexps) scores)))
5583 (gnus-group-make-group group "nnkiboze" address)
5585 (gnus-set-work-buffer)
5586 (let (emacs-lisp-mode-hook)
5587 (pp scores (current-buffer)))
5588 (write-region (point-min) (point-max)
5589 (gnus-score-file-name (concat "nnkiboze:" group))))
5591 (gnus-group-position-point))
5593 (defun gnus-group-add-to-virtual (n vgroup)
5594 "Add the current group to a virtual group."
5596 (list current-prefix-arg
5597 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
5599 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
5600 (error "%s is not an nnvirtual group" vgroup))
5601 (let* ((groups (gnus-group-process-prefix n))
5602 (method (gnus-info-method (gnus-get-info vgroup))))
5603 (setcar (cdr method)
5605 (nth 1 method) "\\|"
5608 (gnus-group-remove-mark s)
5609 (concat "\\(^" (regexp-quote s) "$\\)"))
5611 (gnus-group-position-point))
5613 (defun gnus-group-make-empty-virtual (group)
5614 "Create a new, fresh, empty virtual group."
5615 (interactive "sCreate new, empty virtual group: ")
5616 (let* ((method (list 'nnvirtual "^$"))
5617 (pgroup (gnus-group-prefixed-name group method)))
5618 ;; Check whether it exists already.
5619 (and (gnus-gethash pgroup gnus-newsrc-hashtb)
5620 (error "Group %s already exists." pgroup))
5621 ;; Subscribe the new group after the group on the current line.
5622 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
5623 (gnus-group-update-group pgroup)
5625 (gnus-group-position-point)))
5627 (defun gnus-group-enter-directory (dir)
5628 "Enter an ephemeral nneething group."
5629 (interactive "DDirectory to read: ")
5630 (let* ((method (list 'nneething dir))
5631 (leaf (gnus-group-prefixed-name
5632 (file-name-nondirectory (directory-file-name dir))
5634 (name (gnus-generate-new-group-name leaf)))
5635 (let ((nneething-read-only t))
5636 (or (gnus-group-read-ephemeral-group
5638 (cons (current-buffer) (if (eq major-mode 'gnus-summary-mode)
5640 (error "Couldn't enter %s" dir)))))
5642 ;; Group sorting commands
5643 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
5645 (defun gnus-group-sort-groups (func &optional reverse)
5646 "Sort the group buffer according to FUNC.
5647 If REVERSE, reverse the sorting order."
5648 (interactive (list gnus-group-sort-function
5649 current-prefix-arg))
5651 ((not (listp func)) func)
5653 ((= 1 (length func)) (car func))
5655 ,(gnus-make-sort-function
5656 (reverse func)))))))
5657 ;; We peel off the dummy group from the alist.
5659 (when (equal (car (gnus-info-group gnus-newsrc-alist)) "dummy.group")
5660 (pop gnus-newsrc-alist))
5662 (setq gnus-newsrc-alist
5663 (sort gnus-newsrc-alist func))
5665 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
5666 ;; Regenerate the hash table.
5667 (gnus-make-hashtable-from-newsrc-alist)
5668 (gnus-group-list-groups))))
5670 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
5671 "Sort the group buffer alphabetically by group name.
5672 If REVERSE, sort in reverse order."
5674 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
5676 (defun gnus-group-sort-groups-by-unread (&optional reverse)
5677 "Sort the group buffer by number of unread articles.
5678 If REVERSE, sort in reverse order."
5680 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
5682 (defun gnus-group-sort-groups-by-level (&optional reverse)
5683 "Sort the group buffer by group level.
5684 If REVERSE, sort in reverse order."
5686 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
5688 (defun gnus-group-sort-groups-by-score (&optional reverse)
5689 "Sort the group buffer by group score.
5690 If REVERSE, sort in reverse order."
5692 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
5694 (defun gnus-group-sort-groups-by-rank (&optional reverse)
5695 "Sort the group buffer by group rank.
5696 If REVERSE, sort in reverse order."
5698 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
5700 (defun gnus-group-sort-groups-by-method (&optional reverse)
5701 "Sort the group buffer alphabetically by backend name.
5702 If REVERSE, sort in reverse order."
5704 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
5706 (defun gnus-group-sort-by-alphabet (info1 info2)
5707 "Sort alphabetically."
5708 (string< (gnus-info-group info1) (gnus-info-group info2)))
5710 (defun gnus-group-sort-by-unread (info1 info2)
5711 "Sort by number of unread articles."
5712 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
5713 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
5714 (< (or (and (numberp n1) n1) 0)
5715 (or (and (numberp n2) n2) 0))))
5717 (defun gnus-group-sort-by-level (info1 info2)
5719 (< (gnus-info-level info1) (gnus-info-level info2)))
5721 (defun gnus-group-sort-by-method (info1 info2)
5722 "Sort alphabetically by backend name."
5723 (string< (symbol-name (car (gnus-find-method-for-group
5724 (gnus-info-group info1) info1)))
5725 (symbol-name (car (gnus-find-method-for-group
5726 (gnus-info-group info2) info2)))))
5728 (defun gnus-group-sort-by-score (info1 info2)
5729 "Sort by group score."
5730 (< (gnus-info-score info1) (gnus-info-score info2)))
5732 (defun gnus-group-sort-by-rank (info1 info2)
5733 "Sort by level and score."
5734 (let ((level1 (gnus-info-level info1))
5735 (level2 (gnus-info-level info2)))
5736 (or (< level1 level2)
5737 (and (= level1 level2)
5738 (< (gnus-info-score info1) (gnus-info-score info2))))))
5740 ;; Group catching up.
5742 (defun gnus-group-catchup-current (&optional n all)
5743 "Mark all articles not marked as unread in current newsgroup as read.
5744 If prefix argument N is numeric, the ARG next newsgroups will be
5745 caught up. If ALL is non-nil, marked articles will also be marked as
5746 read. Cross references (Xref: header) of articles are ignored.
5747 The difference between N and actual number of newsgroups that were
5748 caught up is returned."
5750 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
5754 "Do you really want to mark all articles as read? "
5755 "Mark all unread articles as read? "))))
5757 (let ((groups (gnus-group-process-prefix n))
5760 ;; Virtual groups have to be given special treatment.
5761 (let ((method (gnus-find-method-for-group (car groups))))
5762 (if (eq 'nnvirtual (car method))
5763 (nnvirtual-catchup-group
5764 (gnus-group-real-name (car groups)) (nth 1 method) all)))
5765 (gnus-group-remove-mark (car groups))
5767 (gnus-group-goto-group (car groups))
5768 (gnus-group-catchup (car groups) all))
5769 (gnus-group-update-group-line)
5770 (setq ret (1+ ret)))
5771 (setq groups (cdr groups)))
5772 (gnus-group-next-unread-group 1)
5775 (defun gnus-group-catchup-current-all (&optional n)
5776 "Mark all articles in current newsgroup as read.
5777 Cross references (Xref: header) of articles are ignored."
5779 (gnus-group-catchup-current n 'all))
5781 (defun gnus-group-catchup (group &optional all)
5782 "Mark all articles in GROUP as read.
5783 If ALL is non-nil, all articles are marked as read.
5784 The return value is the number of articles that were marked as read,
5785 or nil if no action could be taken."
5786 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5788 ;; Do the updating only if the newsgroup isn't killed.
5789 (if (not (numberp (car entry)))
5790 (gnus-message 1 "Can't catch up; non-active group")
5791 ;; Do auto-expirable marks if that's required.
5792 (when (gnus-group-auto-expirable-p group)
5793 (gnus-add-marked-articles
5794 group 'expire (gnus-list-of-unread-articles group))
5796 (let ((marks (nth 3 (nth 2 entry))))
5797 (gnus-add-marked-articles
5798 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))
5799 (gnus-add-marked-articles
5800 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))))))
5802 (gnus-update-read-articles group nil)
5803 ;; Also nix out the lists of marks and dormants.
5805 (gnus-add-marked-articles group 'tick nil nil 'force)
5806 (gnus-add-marked-articles group 'dormant nil nil 'force))
5807 (run-hooks 'gnus-group-catchup-group-hook)
5810 (defun gnus-group-expire-articles (&optional n)
5811 "Expire all expirable articles in the current newsgroup."
5813 (let ((groups (gnus-group-process-prefix n))
5816 (error "No groups to expire"))
5817 (while (setq group (pop groups))
5818 (gnus-group-remove-mark group)
5819 (when (gnus-check-backend-function 'request-expire-articles group)
5820 (gnus-message 6 "Expiring articles in %s..." group)
5821 (let* ((info (gnus-get-info group))
5822 (expirable (if (gnus-group-total-expirable-p group)
5823 (cons nil (gnus-list-of-read-articles group))
5824 (assq 'expire (gnus-info-marks info))))
5825 (expiry-wait (gnus-group-get-parameter group 'expiry-wait)))
5829 (gnus-compress-sequence
5831 ;; We set the expiry variables to the groupp
5833 (let ((nnmail-expiry-wait-function nil)
5834 (nnmail-expiry-wait expiry-wait))
5835 (gnus-request-expire-articles
5836 (gnus-uncompress-sequence (cdr expirable)) group))
5837 ;; Just expire using the normal expiry values.
5838 (gnus-request-expire-articles
5839 (gnus-uncompress-sequence (cdr expirable)) group)))))
5840 (gnus-message 6 "Expiring articles in %s...done" group)))
5841 (gnus-group-position-point))))
5843 (defun gnus-group-expire-all-groups ()
5844 "Expire all expirable articles in all newsgroups."
5847 (gnus-message 5 "Expiring...")
5848 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
5849 (cdr gnus-newsrc-alist))))
5850 (gnus-group-expire-articles nil)))
5851 (gnus-group-position-point)
5852 (gnus-message 5 "Expiring...done"))
5854 (defun gnus-group-set-current-level (n level)
5855 "Set the level of the next N groups to LEVEL."
5859 (if (not (gnus-group-group-name))
5860 (error "No group on the current line")
5862 (let ((s (read-string
5863 (format "Level (default %s): " (gnus-group-group-level)))))
5864 (if (string-match "^\\s-*$" s)
5865 (int-to-string (gnus-group-group-level))
5867 (or (and (>= level 1) (<= level gnus-level-killed))
5868 (error "Illegal level: %d" level))
5869 (let ((groups (gnus-group-process-prefix n))
5871 (while (setq group (pop groups))
5872 (gnus-group-remove-mark group)
5873 (gnus-message 6 "Changed level of %s from %d to %d"
5874 group (or (gnus-group-group-level) gnus-level-killed)
5876 (gnus-group-change-level
5877 group level (or (gnus-group-group-level) gnus-level-killed))
5878 (gnus-group-update-group-line)))
5879 (gnus-group-position-point))
5881 (defun gnus-group-unsubscribe-current-group (&optional n)
5882 "Toggle subscription of the current group.
5883 If given numerical prefix, toggle the N next groups."
5885 (let ((groups (gnus-group-process-prefix n))
5888 (setq group (car groups)
5889 groups (cdr groups))
5890 (gnus-group-remove-mark group)
5891 (gnus-group-unsubscribe-group
5892 group (if (<= (gnus-group-group-level) gnus-level-subscribed)
5893 gnus-level-default-unsubscribed
5894 gnus-level-default-subscribed) t)
5895 (gnus-group-update-group-line))
5896 (gnus-group-next-group 1)))
5898 (defun gnus-group-unsubscribe-group (group &optional level silent)
5899 "Toggle subscription to GROUP.
5900 Killed newsgroups are subscribed. If SILENT, don't try to update the
5903 (list (completing-read
5904 "Group: " gnus-active-hashtb nil
5905 (memq gnus-select-method gnus-have-read-active-file))))
5906 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
5908 ((string-match "^[ \t]$" group)
5909 (error "Empty group name"))
5911 ;; Toggle subscription flag.
5912 (gnus-group-change-level
5913 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
5914 gnus-level-subscribed)
5915 (1+ gnus-level-subscribed)
5916 gnus-level-default-subscribed)))
5918 (gnus-group-update-group group)))
5919 ((and (stringp group)
5920 (or (not (memq gnus-select-method gnus-have-read-active-file))
5921 (gnus-active group)))
5922 ;; Add new newsgroup.
5923 (gnus-group-change-level
5925 (if level level gnus-level-default-subscribed)
5926 (or (and (member group gnus-zombie-list)
5929 (and (gnus-group-group-name)
5930 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
5932 (gnus-group-update-group group)))
5933 (t (error "No such newsgroup: %s" group)))
5934 (gnus-group-position-point)))
5936 (defun gnus-group-transpose-groups (n)
5937 "Move the current newsgroup up N places.
5938 If given a negative prefix, move down instead. The difference between
5939 N and the number of steps taken is returned."
5941 (or (gnus-group-group-name)
5942 (error "No group on current line"))
5943 (gnus-group-kill-group 1)
5945 (forward-line (- n))
5946 (gnus-group-yank-group)
5947 (gnus-group-position-point)))
5949 (defun gnus-group-kill-all-zombies ()
5950 "Kill all zombie newsgroups."
5952 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
5953 (setq gnus-zombie-list nil)
5954 (gnus-group-list-groups))
5956 (defun gnus-group-kill-region (begin end)
5957 "Kill newsgroups in current region (excluding current point).
5958 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
5973 (beginning-of-line) ;Important when LINES < 1
5974 (gnus-group-kill-group lines)))
5976 (defun gnus-group-kill-group (&optional n discard)
5977 "Kill the next N groups.
5978 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
5979 However, only groups that were alive can be yanked; already killed
5980 groups or zombie groups can't be yanked.
5981 The return value is the name of the group that was killed, or a list
5984 (let ((buffer-read-only nil)
5985 (groups (gnus-group-process-prefix n))
5986 group entry level out)
5987 (if (< (length groups) 10)
5988 ;; This is faster when there are few groups.
5990 (push (setq group (pop groups)) out)
5991 (gnus-group-remove-mark group)
5992 (setq level (gnus-group-group-level))
5994 (if (and (not discard)
5995 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
5996 (setq gnus-list-of-killed-groups
5997 (cons (cons (car entry) (nth 2 entry))
5998 gnus-list-of-killed-groups)))
5999 (gnus-group-change-level
6000 (if entry entry group) gnus-level-killed (if entry nil level)))
6001 ;; If there are lots and lots of groups to be killed, we use
6002 ;; this thing instead.
6004 (setq groups (nreverse groups))
6006 (gnus-group-remove-mark (setq group (pop groups)))
6009 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
6010 (push (cons (car entry) (nth 2 entry))
6011 gnus-list-of-killed-groups)
6012 (setcdr (cdr entry) (cdr (cdr (cdr entry)))))
6013 ((member group gnus-zombie-list)
6014 (setq gnus-zombie-list (delete group gnus-zombie-list)))))
6015 (gnus-make-hashtable-from-newsrc-alist)))
6017 (gnus-group-position-point)
6018 (if (< (length out) 2) (car out) (nreverse out))))
6020 (defun gnus-group-yank-group (&optional arg)
6021 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
6022 inserting it before the current newsgroup. The numeric ARG specifies
6023 how many newsgroups are to be yanked. The name of the newsgroup yanked
6024 is returned, or (if several groups are yanked) a list of yanked groups
6027 (setq arg (or arg 1))
6028 (let (info group prev out)
6029 (while (>= (decf arg) 0)
6030 (if (not (setq info (pop gnus-list-of-killed-groups)))
6031 (error "No more newsgroups to yank"))
6032 (push (setq group (nth 1 info)) out)
6033 ;; Find which newsgroup to insert this one before - search
6034 ;; backward until something suitable is found. If there are no
6035 ;; other newsgroups in this buffer, just make this newsgroup the
6037 (setq prev (gnus-group-group-name))
6038 (gnus-group-change-level
6039 info (nth 2 info) gnus-level-killed
6040 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
6042 (gnus-group-insert-group-line-info group))
6044 (gnus-group-position-point)
6045 (if (< (length out) 2) (car out) (nreverse out))))
6047 (defun gnus-group-kill-level (level)
6048 "Kill all groups that is on a certain LEVEL."
6049 (interactive "nKill all groups on level: ")
6051 ((= level gnus-level-zombie)
6052 (setq gnus-killed-list
6053 (nconc gnus-zombie-list gnus-killed-list))
6054 (setq gnus-zombie-list nil))
6055 ((and (< level gnus-level-zombie)
6057 (or gnus-expert-user
6060 "Do you really want to kill all groups on level %d? "
6062 (let* ((prev gnus-newsrc-alist)
6065 (if (= (gnus-info-level level) level)
6066 (setcdr prev (cdr alist))
6068 (setq alist (cdr alist)))
6069 (gnus-make-hashtable-from-newsrc-alist)
6070 (gnus-group-list-groups)))
6072 (error "Can't kill; illegal level: %d" level))))
6074 (defun gnus-group-list-all-groups (&optional arg)
6075 "List all newsgroups with level ARG or lower.
6076 Default is gnus-level-unsubscribed, which lists all subscribed and most
6077 unsubscribed groups."
6079 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
6081 ;; Redefine this to list ALL killed groups if prefix arg used.
6082 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
6083 (defun gnus-group-list-killed (&optional arg)
6084 "List all killed newsgroups in the group buffer.
6085 If ARG is non-nil, list ALL killed groups known to Gnus. This may
6086 entail asking the server for the groups."
6088 ;; Find all possible killed newsgroups if arg.
6090 ;; First make sure active file has been read.
6091 (unless gnus-have-read-active-file
6092 (let ((gnus-read-active-file t))
6093 (gnus-read-active-file)))
6094 (or gnus-killed-hashtb (gnus-make-hashtable-from-killed))
6095 ;; Go through all newsgroups that are known to Gnus - enlarge kill list
6099 (group (symbol-name sym)))
6100 (if (or (null group)
6101 (gnus-gethash group gnus-killed-hashtb)
6102 (gnus-gethash group gnus-newsrc-hashtb))
6104 (let ((do-sub (gnus-matches-options-n group)))
6105 (if (or (eq do-sub 'subscribe) (eq do-sub 'ignore))
6107 (setq groups (1+ groups))
6108 (setq gnus-killed-list
6109 (cons group gnus-killed-list))
6110 (gnus-sethash group group gnus-killed-hashtb))))))
6111 gnus-active-hashtb))
6112 (if (not gnus-killed-list)
6113 (gnus-message 6 "No killed groups")
6114 (let (gnus-group-list-mode)
6115 (funcall gnus-group-prepare-function
6116 gnus-level-killed t gnus-level-killed))
6117 (goto-char (point-min)))
6118 (gnus-group-position-point))
6120 (defun gnus-group-list-zombies ()
6121 "List all zombie newsgroups in the group buffer."
6123 (if (not gnus-zombie-list)
6124 (gnus-message 6 "No zombie groups")
6125 (let (gnus-group-list-mode)
6126 (funcall gnus-group-prepare-function
6127 gnus-level-zombie t gnus-level-zombie))
6128 (goto-char (point-min)))
6129 (gnus-group-position-point))
6131 (defun gnus-group-list-active ()
6132 "List all groups that are available from the server(s)."
6134 ;; First we make sure that we have really read the active file.
6135 (unless gnus-have-read-active-file
6136 (let ((gnus-read-active-file t))
6137 (gnus-read-active-file)))
6138 ;; Find all groups and sort them.
6144 (and (symbol-value sym)
6145 (setq list (cons (symbol-name sym) list))))
6149 (buffer-read-only nil))
6152 (gnus-group-insert-group-line-info (car groups))
6153 (setq groups (cdr groups)))
6154 (goto-char (point-min))))
6156 (defun gnus-activate-all-groups (level)
6157 "Activate absolutely all groups."
6158 (interactive (list 7))
6159 (let ((gnus-activate-level level)
6160 (gnus-activate-foreign-newsgroups level))
6161 (gnus-group-get-new-news)))
6163 (defun gnus-group-get-new-news (&optional arg)
6164 "Get newly arrived articles.
6165 If ARG is a number, it specifies which levels you are interested in
6166 re-scanning. If ARG is non-nil and not a number, this will force
6167 \"hard\" re-reading of the active files from all servers."
6169 (run-hooks 'gnus-get-new-news-hook)
6170 ;; We might read in new NoCeM messages here.
6171 (when gnus-use-nocem
6172 (gnus-nocem-scan-groups))
6173 ;; If ARG is not a number, then we read the active file.
6174 (when (and arg (not (numberp arg)))
6175 (let ((gnus-read-active-file t))
6176 (gnus-read-active-file))
6179 (setq arg (gnus-group-default-level arg t))
6180 (if (and gnus-read-active-file (not arg))
6182 (gnus-read-active-file)
6183 (gnus-get-unread-articles arg))
6184 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
6185 (gnus-get-unread-articles arg)))
6186 (gnus-group-list-groups))
6188 (defun gnus-group-get-new-news-this-group (&optional n)
6189 "Check for newly arrived news in the current group (and the N-1 next groups).
6190 The difference between N and the number of newsgroup checked is returned.
6191 If N is negative, this group and the N-1 previous groups will be checked."
6193 (let* ((groups (gnus-group-process-prefix n))
6194 (ret (if (numberp n) (- n (length groups)) 0))
6197 (setq group (car groups)
6198 groups (cdr groups))
6199 (gnus-group-remove-mark group)
6200 (unless (gnus-get-new-news-in-group group)
6202 (gnus-message 3 "%s error: %s" group (gnus-status-message group))))
6203 (when gnus-goto-next-group-when-activating
6204 (gnus-group-next-unread-group 1 t))
6205 (gnus-summary-position-point)
6208 (defun gnus-get-new-news-in-group (group)
6209 (when (and group (gnus-activate-group group 'scan))
6210 (gnus-get-unread-articles-in-group
6211 (gnus-get-info group) (gnus-active group) t)
6212 (when (gnus-group-goto-group group)
6213 (gnus-group-update-group-line))
6216 (defun gnus-group-fetch-faq (group &optional faq-dir)
6217 "Fetch the FAQ for the current group."
6220 (gnus-group-real-name (gnus-group-group-name))
6221 (cond (current-prefix-arg
6223 "Faq dir: " (and (listp gnus-group-faq-directory)
6224 gnus-group-faq-directory))))))
6226 (setq faq-dir (if (listp gnus-group-faq-directory)
6227 (car gnus-group-faq-directory)
6228 gnus-group-faq-directory)))
6229 (or group (error "No group name given"))
6230 (let ((file (concat (file-name-as-directory faq-dir)
6231 (gnus-group-real-name group))))
6232 (if (not (file-exists-p file))
6233 (error "No such file: %s" file)
6236 (defun gnus-group-describe-group (force &optional group)
6237 "Display a description of the current newsgroup."
6238 (interactive (list current-prefix-arg (gnus-group-group-name)))
6239 (and force (setq gnus-description-hashtb nil))
6240 (let ((method (gnus-find-method-for-group group))
6242 (or group (error "No group name given"))
6243 (and (or (and gnus-description-hashtb
6244 ;; We check whether this group's method has been
6245 ;; queried for a description file.
6247 (gnus-group-prefixed-name "" method)
6248 gnus-description-hashtb))
6249 (setq desc (gnus-group-get-description group))
6250 (gnus-read-descriptions-file method))
6252 (or desc (gnus-gethash group gnus-description-hashtb)
6253 "No description available")))))
6255 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6256 (defun gnus-group-describe-all-groups (&optional force)
6257 "Pop up a buffer with descriptions of all newsgroups."
6259 (and force (setq gnus-description-hashtb nil))
6260 (if (not (or gnus-description-hashtb
6261 (gnus-read-all-descriptions-files)))
6262 (error "Couldn't request descriptions file"))
6263 (let ((buffer-read-only nil)
6269 (insert (format " *: %-20s %s\n" (symbol-name group)
6270 (symbol-value group)))
6271 (add-text-properties
6272 b (1+ b) (list 'gnus-group group
6273 'gnus-unread t 'gnus-marked nil
6274 'gnus-level (1+ gnus-level-subscribed))))
6275 gnus-description-hashtb)
6276 (goto-char (point-min))
6277 (gnus-group-position-point)))
6279 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
6280 (defun gnus-group-apropos (regexp &optional search-description)
6281 "List all newsgroups that have names that match a regexp."
6282 (interactive "sGnus apropos (regexp): ")
6284 (obuf (current-buffer))
6286 ;; Go through all newsgroups that are known to Gnus.
6289 (and (symbol-name group)
6290 (string-match regexp (symbol-name group))
6291 (setq groups (cons (symbol-name group) groups))))
6293 ;; Go through all descriptions that are known to Gnus.
6294 (if search-description
6297 (and (string-match regexp (symbol-value group))
6298 (gnus-active (symbol-name group))
6299 (setq groups (cons (symbol-name group) groups))))
6300 gnus-description-hashtb))
6302 (gnus-message 3 "No groups matched \"%s\"." regexp)
6303 ;; Print out all the groups.
6305 (pop-to-buffer "*Gnus Help*")
6306 (buffer-disable-undo (current-buffer))
6308 (setq groups (sort groups 'string<))
6310 ;; Groups may be entered twice into the list of groups.
6311 (if (not (string= (car groups) prev))
6313 (insert (setq prev (car groups)) "\n")
6314 (if (and gnus-description-hashtb
6315 (setq des (gnus-gethash (car groups)
6316 gnus-description-hashtb)))
6317 (insert " " des "\n"))))
6318 (setq groups (cdr groups)))
6319 (goto-char (point-min))))
6320 (pop-to-buffer obuf)))
6322 (defun gnus-group-description-apropos (regexp)
6323 "List all newsgroups that have names or descriptions that match a regexp."
6324 (interactive "sGnus description apropos (regexp): ")
6325 (if (not (or gnus-description-hashtb
6326 (gnus-read-all-descriptions-files)))
6327 (error "Couldn't request descriptions file"))
6328 (gnus-group-apropos regexp t))
6330 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6331 (defun gnus-group-list-matching (level regexp &optional all lowest)
6332 "List all groups with unread articles that match REGEXP.
6333 If the prefix LEVEL is non-nil, it should be a number that says which
6334 level to cut off listing groups.
6335 If ALL, also list groups with no unread articles.
6336 If LOWEST, don't list groups with level lower than LOWEST."
6337 (interactive "P\nsList newsgroups matching: ")
6338 (gnus-group-prepare-flat (or level gnus-level-subscribed)
6339 all (or lowest 1) regexp)
6340 (goto-char (point-min))
6341 (gnus-group-position-point))
6343 (defun gnus-group-list-all-matching (level regexp &optional lowest)
6344 "List all groups that match REGEXP.
6345 If the prefix LEVEL is non-nil, it should be a number that says which
6346 level to cut off listing groups.
6347 If LOWEST, don't list groups with level lower than LOWEST."
6348 (interactive "P\nsList newsgroups matching: ")
6349 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
6351 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
6352 (defun gnus-group-save-newsrc (&optional force)
6353 "Save the Gnus startup files.
6354 If FORCE, force saving whether it is necessary or not."
6356 (gnus-save-newsrc-file force))
6358 (defun gnus-group-restart (&optional arg)
6359 "Force Gnus to read the .newsrc file."
6361 (gnus-save-newsrc-file)
6362 (gnus-setup-news 'force)
6363 (gnus-group-list-groups arg))
6365 (defun gnus-group-read-init-file ()
6366 "Read the Gnus elisp init file."
6368 (gnus-read-init-file))
6370 (defun gnus-group-check-bogus-groups (&optional silent)
6371 "Check bogus newsgroups.
6372 If given a prefix, don't ask for confirmation before removing a bogus
6375 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
6376 (gnus-group-list-groups))
6378 (defun gnus-group-edit-global-kill (&optional article group)
6379 "Edit the global kill file.
6380 If GROUP, edit that local kill file instead."
6382 (setq gnus-current-kill-article article)
6383 (gnus-kill-file-edit-file group)
6386 (substitute-command-keys
6387 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
6388 (if group "local" "global")))))
6390 (defun gnus-group-edit-local-kill (article group)
6391 "Edit a local kill file."
6392 (interactive (list nil (gnus-group-group-name)))
6393 (gnus-group-edit-global-kill article group))
6395 (defun gnus-group-force-update ()
6396 "Update `.newsrc' file."
6398 (gnus-save-newsrc-file))
6400 (defun gnus-group-suspend ()
6401 "Suspend the current Gnus session.
6402 In fact, cleanup buffers except for group mode buffer.
6403 The hook gnus-suspend-gnus-hook is called before actually suspending."
6405 (run-hooks 'gnus-suspend-gnus-hook)
6406 ;; Kill Gnus buffers except for group mode buffer.
6407 (let ((group-buf (get-buffer gnus-group-buffer)))
6408 ;; Do this on a separate list in case the user does a ^G before we finish
6409 (let ((gnus-buffer-list
6410 (delq group-buf (delq gnus-dribble-buffer
6411 (append gnus-buffer-list nil)))))
6412 (while gnus-buffer-list
6413 (gnus-kill-buffer (car gnus-buffer-list))
6414 (setq gnus-buffer-list (cdr gnus-buffer-list))))
6417 (setq gnus-buffer-list (list group-buf))
6418 (bury-buffer group-buf)
6419 (delete-windows-on group-buf t)))))
6421 (defun gnus-group-clear-dribble ()
6422 "Clear all information from the dribble buffer."
6424 (gnus-dribble-clear)
6425 (gnus-message 7 "Cleared dribble buffer"))
6427 (defun gnus-group-exit ()
6428 "Quit reading news after updating .newsrc.eld and .newsrc.
6429 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6432 (or noninteractive ;For gnus-batch-kill
6433 (not (gnus-server-opened gnus-select-method)) ;NNTP connection closed
6434 (not gnus-interactive-exit) ;Without confirmation
6436 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
6437 (run-hooks 'gnus-exit-gnus-hook)
6438 ;; Offer to save data from non-quitted summary buffers.
6439 (gnus-offer-save-summaries)
6440 ;; Save the newsrc file(s).
6441 (gnus-save-newsrc-file)
6443 (gnus-close-backends)
6444 ;; Shut down the cache.
6445 (when gnus-use-cache
6447 ;; Reset everything.
6449 ;; Allow the user to do things after cleaning up.
6450 (run-hooks 'gnus-after-exiting-gnus-hook)))
6452 (defun gnus-close-backends ()
6453 ;; Send a close request to all backends that support such a request.
6454 (let ((methods gnus-valid-select-methods)
6457 (if (fboundp (setq func (intern (concat (car (car methods))
6458 "-request-close"))))
6460 (setq methods (cdr methods)))))
6462 (defun gnus-group-quit ()
6463 "Quit reading news without updating .newsrc.eld or .newsrc.
6464 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6466 (when (or noninteractive ;For gnus-batch-kill
6467 (zerop (buffer-size))
6468 (not (gnus-server-opened gnus-select-method))
6470 (not gnus-current-startup-file)
6472 (format "Quit reading news without saving %s? "
6473 (file-name-nondirectory gnus-current-startup-file))))
6474 (run-hooks 'gnus-exit-gnus-hook)
6475 (if gnus-use-full-window
6476 (delete-other-windows)
6477 (gnus-remove-some-windows))
6479 (gnus-close-backends)
6480 ;; Shut down the cache.
6481 (when gnus-use-cache
6484 ;; Allow the user to do things after cleaning up.
6485 (run-hooks 'gnus-after-exiting-gnus-hook)))
6487 (defun gnus-offer-save-summaries ()
6488 "Offer to save all active summary buffers."
6490 (let ((buflist (buffer-list))
6492 ;; Go through all buffers and find all summaries.
6494 (and (setq bufname (buffer-name (car buflist)))
6495 (string-match "Summary" bufname)
6497 (set-buffer bufname)
6498 ;; We check that this is, indeed, a summary buffer.
6499 (and (eq major-mode 'gnus-summary-mode)
6500 ;; Also make sure this isn't bogus.
6501 gnus-newsgroup-prepared))
6502 (push bufname buffers))
6503 (setq buflist (cdr buflist)))
6504 ;; Go through all these summary buffers and offer to save them.
6507 "Update summary buffer %s? "
6508 (lambda (buf) (set-buffer buf) (gnus-summary-exit))
6511 (defun gnus-group-describe-briefly ()
6512 "Give a one line description of the group mode commands."
6514 (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")))
6516 (defun gnus-group-browse-foreign-server (method)
6517 "Browse a foreign news server.
6518 If called interactively, this function will ask for a select method
6519 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
6520 If not, METHOD should be a list where the first element is the method
6521 and the second element is the address."
6523 (list (let ((how (completing-read
6525 (append gnus-valid-select-methods gnus-server-alist)
6526 nil t (cons "nntp" 0))))
6527 ;; We either got a backend name or a virtual server name.
6528 ;; If the first, we also need an address.
6529 (if (assoc how gnus-valid-select-methods)
6531 ;; Suggested by mapjph@bath.ac.uk.
6534 (mapcar (lambda (server) (list server))
6535 gnus-secondary-servers)))
6536 ;; We got a server name, so we find the method.
6537 (gnus-server-to-method how)))))
6538 (gnus-browse-foreign-server method))
6542 ;;; Gnus summary mode
6545 (defvar gnus-summary-mode-map nil)
6547 (put 'gnus-summary-mode 'mode-class 'special)
6549 (unless gnus-summary-mode-map
6550 (setq gnus-summary-mode-map (make-keymap))
6551 (suppress-keymap gnus-summary-mode-map)
6553 ;; Non-orthogonal keys
6556 gnus-summary-mode-map
6557 " " gnus-summary-next-page
6558 "\177" gnus-summary-prev-page
6559 [delete] gnus-summary-prev-page
6560 "\r" gnus-summary-scroll-up
6561 "n" gnus-summary-next-unread-article
6562 "p" gnus-summary-prev-unread-article
6563 "N" gnus-summary-next-article
6564 "P" gnus-summary-prev-article
6565 "\M-\C-n" gnus-summary-next-same-subject
6566 "\M-\C-p" gnus-summary-prev-same-subject
6567 "\M-n" gnus-summary-next-unread-subject
6568 "\M-p" gnus-summary-prev-unread-subject
6569 "." gnus-summary-first-unread-article
6570 "," gnus-summary-best-unread-article
6571 "\M-s" gnus-summary-search-article-forward
6572 "\M-r" gnus-summary-search-article-backward
6573 "<" gnus-summary-beginning-of-article
6574 ">" gnus-summary-end-of-article
6575 "j" gnus-summary-goto-article
6576 "^" gnus-summary-refer-parent-article
6577 "\M-^" gnus-summary-refer-article
6578 "u" gnus-summary-tick-article-forward
6579 "!" gnus-summary-tick-article-forward
6580 "U" gnus-summary-tick-article-backward
6581 "d" gnus-summary-mark-as-read-forward
6582 "D" gnus-summary-mark-as-read-backward
6583 "E" gnus-summary-mark-as-expirable
6584 "\M-u" gnus-summary-clear-mark-forward
6585 "\M-U" gnus-summary-clear-mark-backward
6586 "k" gnus-summary-kill-same-subject-and-select
6587 "\C-k" gnus-summary-kill-same-subject
6588 "\M-\C-k" gnus-summary-kill-thread
6589 "\M-\C-l" gnus-summary-lower-thread
6590 "e" gnus-summary-edit-article
6591 "#" gnus-summary-mark-as-processable
6592 "\M-#" gnus-summary-unmark-as-processable
6593 "\M-\C-t" gnus-summary-toggle-threads
6594 "\M-\C-s" gnus-summary-show-thread
6595 "\M-\C-h" gnus-summary-hide-thread
6596 "\M-\C-f" gnus-summary-next-thread
6597 "\M-\C-b" gnus-summary-prev-thread
6598 "\M-\C-u" gnus-summary-up-thread
6599 "\M-\C-d" gnus-summary-down-thread
6600 "&" gnus-summary-execute-command
6601 "c" gnus-summary-catchup-and-exit
6602 "\C-w" gnus-summary-mark-region-as-read
6603 "\C-t" gnus-summary-toggle-truncation
6604 "?" gnus-summary-mark-as-dormant
6605 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
6606 "\C-c\C-s\C-n" gnus-summary-sort-by-number
6607 "\C-c\C-s\C-a" gnus-summary-sort-by-author
6608 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
6609 "\C-c\C-s\C-d" gnus-summary-sort-by-date
6610 "\C-c\C-s\C-i" gnus-summary-sort-by-score
6611 "=" gnus-summary-expand-window
6612 "\C-x\C-s" gnus-summary-reselect-current-group
6613 "\M-g" gnus-summary-rescan-group
6614 "w" gnus-summary-stop-page-breaking
6615 "\C-c\C-r" gnus-summary-caesar-message
6616 "\M-t" gnus-summary-toggle-mime
6617 "f" gnus-summary-followup
6618 "F" gnus-summary-followup-with-original
6619 "C" gnus-summary-cancel-article
6620 "r" gnus-summary-reply
6621 "R" gnus-summary-reply-with-original
6622 "\C-c\C-f" gnus-summary-mail-forward
6623 "o" gnus-summary-save-article
6624 "\C-o" gnus-summary-save-article-mail
6625 "|" gnus-summary-pipe-output
6626 "\M-k" gnus-summary-edit-local-kill
6627 "\M-K" gnus-summary-edit-global-kill
6629 "\C-c\C-d" gnus-summary-describe-group
6630 "q" gnus-summary-exit
6631 "Q" gnus-summary-exit-no-update
6632 "\C-c\C-i" gnus-info-find-node
6633 gnus-mouse-2 gnus-mouse-pick-article
6634 "m" gnus-summary-mail-other-window
6635 "a" gnus-summary-post-news
6636 "x" gnus-summary-limit-to-unread
6637 "s" gnus-summary-isearch-article
6638 "t" gnus-article-hide-headers
6639 "g" gnus-summary-show-article
6640 "l" gnus-summary-goto-last-article
6641 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
6642 "\C-d" gnus-summary-enter-digest-group
6644 "*" gnus-cache-enter-article
6645 "\M-*" gnus-cache-remove-article
6646 "\M-&" gnus-summary-universal-argument
6647 "\C-l" gnus-recenter
6648 "I" gnus-summary-increase-score
6649 "L" gnus-summary-lower-score
6651 "V" gnus-summary-score-map
6652 "X" gnus-uu-extract-map
6653 "S" gnus-summary-send-map)
6655 ;; Sort of orthogonal keymap
6657 (gnus-summary-mark-map "M" gnus-summary-mode-map)
6658 "t" gnus-summary-tick-article-forward
6659 "!" gnus-summary-tick-article-forward
6660 "d" gnus-summary-mark-as-read-forward
6661 "r" gnus-summary-mark-as-read-forward
6662 "c" gnus-summary-clear-mark-forward
6663 " " gnus-summary-clear-mark-forward
6664 "e" gnus-summary-mark-as-expirable
6665 "x" gnus-summary-mark-as-expirable
6666 "?" gnus-summary-mark-as-dormant
6667 "b" gnus-summary-set-bookmark
6668 "B" gnus-summary-remove-bookmark
6669 "#" gnus-summary-mark-as-processable
6670 "\M-#" gnus-summary-unmark-as-processable
6671 "S" gnus-summary-limit-include-expunged
6672 "C" gnus-summary-catchup
6673 "H" gnus-summary-catchup-to-here
6674 "\C-c" gnus-summary-catchup-all
6675 "k" gnus-summary-kill-same-subject-and-select
6676 "K" gnus-summary-kill-same-subject
6677 "P" gnus-uu-mark-map)
6680 (gnus-summary-mscore-map "V" gnus-summary-mode-map)
6681 "c" gnus-summary-clear-above
6682 "u" gnus-summary-tick-above
6683 "m" gnus-summary-mark-above
6684 "k" gnus-summary-kill-below)
6687 (gnus-summary-limit-map "/" gnus-summary-mode-map)
6688 "/" gnus-summary-limit-to-subject
6689 "n" gnus-summary-limit-to-articles
6690 "w" gnus-summary-pop-limit
6691 "s" gnus-summary-limit-to-subject
6692 "a" gnus-summary-limit-to-author
6693 "u" gnus-summary-limit-to-unread
6694 "m" gnus-summary-limit-to-marks
6695 "v" gnus-summary-limit-to-score
6696 "D" gnus-summary-limit-include-dormant
6697 "d" gnus-summary-limit-exclude-dormant
6698 ;; "t" gnus-summary-limit-exclude-thread
6699 "E" gnus-summary-limit-include-expunged
6700 "c" gnus-summary-limit-exclude-childless-dormant
6701 "C" gnus-summary-limit-mark-excluded-as-read)
6704 (gnus-summary-goto-map "G" gnus-summary-mode-map)
6705 "n" gnus-summary-next-unread-article
6706 "p" gnus-summary-prev-unread-article
6707 "N" gnus-summary-next-article
6708 "P" gnus-summary-prev-article
6709 "\C-n" gnus-summary-next-same-subject
6710 "\C-p" gnus-summary-prev-same-subject
6711 "\M-n" gnus-summary-next-unread-subject
6712 "\M-p" gnus-summary-prev-unread-subject
6713 "f" gnus-summary-first-unread-article
6714 "b" gnus-summary-best-unread-article
6715 "g" gnus-summary-goto-subject
6716 "l" gnus-summary-goto-last-article
6717 "p" gnus-summary-pop-article)
6720 (gnus-summary-thread-map "T" gnus-summary-mode-map)
6721 "k" gnus-summary-kill-thread
6722 "l" gnus-summary-lower-thread
6723 "i" gnus-summary-raise-thread
6724 "T" gnus-summary-toggle-threads
6725 "t" gnus-summary-rethread-current
6726 "^" gnus-summary-reparent-thread
6727 "s" gnus-summary-show-thread
6728 "S" gnus-summary-show-all-threads
6729 "h" gnus-summary-hide-thread
6730 "H" gnus-summary-hide-all-threads
6731 "n" gnus-summary-next-thread
6732 "p" gnus-summary-prev-thread
6733 "u" gnus-summary-up-thread
6734 "o" gnus-summary-top-thread
6735 "d" gnus-summary-down-thread
6736 "#" gnus-uu-mark-thread
6737 "\M-#" gnus-uu-unmark-thread)
6740 (gnus-summary-exit-map "Z" gnus-summary-mode-map)
6741 "c" gnus-summary-catchup-and-exit
6742 "C" gnus-summary-catchup-all-and-exit
6743 "E" gnus-summary-exit-no-update
6744 "Q" gnus-summary-exit
6745 "Z" gnus-summary-exit
6746 "n" gnus-summary-catchup-and-goto-next-group
6747 "R" gnus-summary-reselect-current-group
6748 "G" gnus-summary-rescan-group
6749 "N" gnus-summary-next-group
6750 "P" gnus-summary-prev-group)
6753 (gnus-summary-article-map "A" gnus-summary-mode-map)
6754 " " gnus-summary-next-page
6755 "n" gnus-summary-next-page
6756 "\177" gnus-summary-prev-page
6757 [delete] gnus-summary-prev-page
6758 "p" gnus-summary-prev-page
6759 "\r" gnus-summary-scroll-up
6760 "<" gnus-summary-beginning-of-article
6761 ">" gnus-summary-end-of-article
6762 "b" gnus-summary-beginning-of-article
6763 "e" gnus-summary-end-of-article
6764 "^" gnus-summary-refer-parent-article
6765 "r" gnus-summary-refer-parent-article
6766 "R" gnus-summary-refer-references
6767 "g" gnus-summary-show-article
6768 "s" gnus-summary-isearch-article)
6771 (gnus-summary-wash-map "W" gnus-summary-mode-map)
6772 "b" gnus-article-add-buttons
6773 "B" gnus-article-add-buttons-to-head
6774 "o" gnus-article-treat-overstrike
6775 ;; "w" gnus-article-word-wrap
6776 "w" gnus-article-fill-cited-article
6777 "c" gnus-article-remove-cr
6778 "L" gnus-article-remove-trailing-blank-lines
6779 "q" gnus-article-de-quoted-unreadable
6780 "f" gnus-article-display-x-face
6781 "l" gnus-summary-stop-page-breaking
6782 "r" gnus-summary-caesar-message
6783 "t" gnus-article-hide-headers
6784 "v" gnus-summary-verbose-headers
6785 "m" gnus-summary-toggle-mime)
6788 (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
6789 "a" gnus-article-hide
6790 "h" gnus-article-hide-headers
6791 "b" gnus-article-hide-boring-headers
6792 "s" gnus-article-hide-signature
6793 "c" gnus-article-hide-citation
6794 "p" gnus-article-hide-pgp
6795 "\C-c" gnus-article-hide-citation-maybe)
6798 (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
6799 "a" gnus-article-highlight
6800 "h" gnus-article-highlight-headers
6801 "c" gnus-article-highlight-citation
6802 "s" gnus-article-highlight-signature)
6805 (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
6806 "z" gnus-article-date-ut
6807 "u" gnus-article-date-ut
6808 "l" gnus-article-date-local
6809 "e" gnus-article-date-lapsed
6810 "o" gnus-article-date-original)
6813 (gnus-summary-help-map "H" gnus-summary-mode-map)
6815 "f" gnus-summary-fetch-faq
6816 "d" gnus-summary-describe-group
6817 "h" gnus-summary-describe-briefly
6818 "i" gnus-info-find-node)
6821 (gnus-summary-backend-map "B" gnus-summary-mode-map)
6822 "e" gnus-summary-expire-articles
6823 "\M-\C-e" gnus-summary-expire-articles-now
6824 "\177" gnus-summary-delete-article
6825 [delete] gnus-summary-delete-article
6826 "m" gnus-summary-move-article
6827 "r" gnus-summary-respool-article
6828 "w" gnus-summary-edit-article
6829 "c" gnus-summary-copy-article
6830 "B" gnus-summary-crosspost-article
6831 "q" gnus-summary-respool-query
6832 "i" gnus-summary-import-article)
6835 (gnus-summary-save-map "O" gnus-summary-mode-map)
6836 "o" gnus-summary-save-article
6837 "m" gnus-summary-save-article-mail
6838 "r" gnus-summary-save-article-rmail
6839 "f" gnus-summary-save-article-file
6840 "b" gnus-summary-save-article-body-file
6841 "h" gnus-summary-save-article-folder
6842 "v" gnus-summary-save-article-vm
6843 "p" gnus-summary-pipe-output
6844 "s" gnus-soup-add-article)
6849 (defun gnus-summary-mode (&optional group)
6850 "Major mode for reading articles.
6852 All normal editing commands are switched off.
6853 \\<gnus-summary-mode-map>
6854 Each line in this buffer represents one article. To read an
6855 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
6856 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
6859 You can also post articles and send mail from this buffer. To
6860 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
6861 of an article, type `\\[gnus-summary-reply]'.
6863 There are approx. one gazillion commands you can execute in this
6864 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
6866 The following commands are available:
6868 \\{gnus-summary-mode-map}"
6870 (when (and menu-bar-mode
6871 (gnus-visual-p 'summary-menu 'menu))
6872 (gnus-summary-make-menu-bar))
6873 (kill-all-local-variables)
6874 (let ((locals gnus-summary-local-variables))
6876 (if (consp (car locals))
6878 (make-local-variable (car (car locals)))
6879 (set (car (car locals)) (eval (cdr (car locals)))))
6880 (make-local-variable (car locals))
6881 (set (car locals) nil))
6882 (setq locals (cdr locals))))
6883 (gnus-make-thread-indent-array)
6884 (gnus-simplify-mode-line)
6885 (setq major-mode 'gnus-summary-mode)
6886 (setq mode-name "Summary")
6887 (make-local-variable 'minor-mode-alist)
6888 (use-local-map gnus-summary-mode-map)
6889 (buffer-disable-undo (current-buffer))
6890 (setq buffer-read-only t) ;Disable modification
6891 (setq truncate-lines t)
6892 (setq selective-display t)
6893 (setq selective-display-ellipses t) ;Display `...'
6894 (setq buffer-display-table gnus-summary-display-table)
6895 (setq gnus-newsgroup-name group)
6896 (run-hooks 'gnus-summary-mode-hook))
6898 (defun gnus-summary-make-display-table ()
6899 ;; Change the display table. Odd characters have a tendency to mess
6900 ;; up nicely formatted displays - we make all possible glyphs
6901 ;; display only a single character.
6903 ;; We start from the standard display table, if any.
6904 (setq gnus-summary-display-table
6905 (or (copy-sequence standard-display-table)
6906 (make-display-table)))
6907 ;; Nix out all the control chars...
6909 (while (>= (setq i (1- i)) 0)
6910 (aset gnus-summary-display-table i [??])))
6911 ;; ... but not newline and cr, of course. (cr is necessary for the
6912 ;; selective display).
6913 (aset gnus-summary-display-table ?\n nil)
6914 (aset gnus-summary-display-table ?\r nil)
6915 ;; We nix out any glyphs over 126 that are not set already.
6917 (while (>= (setq i (1- i)) 127)
6918 ;; Only modify if the entry is nil.
6919 (or (aref gnus-summary-display-table i)
6920 (aset gnus-summary-display-table i [??])))))
6922 (defun gnus-summary-clear-local-variables ()
6923 (let ((locals gnus-summary-local-variables))
6925 (if (consp (car locals))
6926 (and (vectorp (car (car locals)))
6927 (set (car (car locals)) nil))
6928 (and (vectorp (car locals))
6929 (set (car locals) nil)))
6930 (setq locals (cdr locals)))))
6932 ;; Summary data functions.
6934 (defmacro gnus-data-number (data)
6937 (defmacro gnus-data-set-number (data number)
6938 `(setcar ,data ,number))
6940 (defmacro gnus-data-mark (data)
6943 (defmacro gnus-data-set-mark (data mark)
6944 `(setcar (nthcdr 1 ,data) ,mark))
6946 (defmacro gnus-data-pos (data)
6949 (defmacro gnus-data-set-pos (data pos)
6950 `(setcar (nthcdr 2 ,data) ,pos))
6952 (defmacro gnus-data-header (data)
6955 (defmacro gnus-data-level (data)
6958 (defmacro gnus-data-unread-p (data)
6959 `(= (nth 1 ,data) gnus-unread-mark))
6961 (defmacro gnus-data-pseudo-p (data)
6962 `(consp (nth 3 ,data)))
6964 (defmacro gnus-data-find (number)
6965 `(assq ,number gnus-newsgroup-data))
6967 (defmacro gnus-data-find-list (number &optional data)
6968 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
6969 (memq (assq ,number bdata)
6972 (defmacro gnus-data-make (number mark pos header level)
6973 `(list ,number ,mark ,pos ,header ,level))
6975 (defun gnus-data-enter (after-article number mark pos header level offset)
6976 (let ((data (gnus-data-find-list after-article)))
6977 (or data (error "No such article: %d" after-article))
6978 (setcdr data (cons (gnus-data-make number mark pos header level)
6980 (setq gnus-newsgroup-data-reverse nil)
6981 (gnus-data-update-list (cdr (cdr data)) offset)))
6983 (defun gnus-data-enter-list (after-article list &optional offset)
6985 (let ((data (and after-article (gnus-data-find-list after-article)))
6987 (or data (not after-article) (error "No such article: %d" after-article))
6988 ;; Find the last element in the list to be spliced into the main
6991 (setq list (cdr list)))
6994 (setcdr list gnus-newsgroup-data)
6995 (setq gnus-newsgroup-data ilist)
6996 (and offset (gnus-data-update-list (cdr list) offset)))
6997 (setcdr list (cdr data))
6999 (and offset (gnus-data-update-list (cdr data) offset)))
7000 (setq gnus-newsgroup-data-reverse nil))))
7002 (defun gnus-data-remove (article &optional offset)
7003 (let ((data gnus-newsgroup-data))
7004 (if (= (gnus-data-number (car data)) article)
7005 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
7006 gnus-newsgroup-data-reverse nil)
7008 (and (= (gnus-data-number (car (cdr data))) article)
7010 (setcdr data (cdr (cdr data)))
7011 (and offset (gnus-data-update-list (cdr data) offset))
7013 gnus-newsgroup-data-reverse nil)))
7014 (setq data (cdr data))))))
7016 (defmacro gnus-data-list (backward)
7018 (or gnus-newsgroup-data-reverse
7019 (setq gnus-newsgroup-data-reverse
7020 (reverse gnus-newsgroup-data)))
7021 gnus-newsgroup-data))
7023 (defun gnus-data-update-list (data offset)
7024 "Add OFFSET to the POS of all data entries in DATA."
7026 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
7027 (setq data (cdr data))))
7029 (defun gnus-data-compute-positions ()
7030 "Compute the positions of all articles."
7031 (let ((data gnus-newsgroup-data)
7034 (when (setq pos (text-property-any
7035 (point-min) (point-max)
7036 'gnus-number (gnus-data-number (car data))))
7037 (gnus-data-set-pos (car data) (+ pos 3)))
7038 (setq data (cdr data)))))
7040 (defun gnus-summary-article-pseudo-p (article)
7041 "Say whether this article is a pseudo article or not."
7042 (not (vectorp (gnus-data-header (gnus-data-find article)))))
7044 (defun gnus-article-parent-p (number)
7045 "Say whether this article is a parent or not."
7046 (let* ((data (gnus-data-find-list number)))
7047 (and (cdr data) ; There has to be an article after...
7048 (< (gnus-data-level (car data)) ; And it has to have a higher level.
7049 (gnus-data-level (nth 1 data))))))
7051 (defmacro gnus-summary-skip-intangible ()
7052 "If the current article is intangible, then jump to a different article."
7053 '(let ((to (get-text-property (point) 'gnus-intangible)))
7054 (and to (gnus-summary-goto-subject to))))
7056 (defmacro gnus-summary-article-intangible-p ()
7057 "Say whether this article is intangible or not."
7058 '(get-text-property (point) 'gnus-intangible))
7060 ;; Some summary mode macros.
7062 (defmacro gnus-summary-article-number ()
7063 "The article number of the article on the current line.
7064 If there isn's an article number here, then we return the current
7067 (gnus-summary-skip-intangible)
7068 (or (get-text-property (point) 'gnus-number)
7069 (gnus-summary-last-subject))))
7071 (defmacro gnus-summary-article-header (&optional number)
7072 `(gnus-data-header (gnus-data-find
7073 ,(or number '(gnus-summary-article-number)))))
7075 (defmacro gnus-summary-thread-level (&optional number)
7076 `(if (and (eq gnus-summary-make-false-root 'dummy)
7077 (get-text-property (point) 'gnus-intangible))
7079 (gnus-data-level (gnus-data-find
7080 ,(or number '(gnus-summary-article-number))))))
7082 (defmacro gnus-summary-article-mark (&optional number)
7083 `(gnus-data-mark (gnus-data-find
7084 ,(or number '(gnus-summary-article-number)))))
7086 (defmacro gnus-summary-article-pos (&optional number)
7087 `(gnus-data-pos (gnus-data-find
7088 ,(or number '(gnus-summary-article-number)))))
7090 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
7091 (defmacro gnus-summary-article-subject (&optional number)
7092 "Return current subject string or nil if nothing."
7095 `(gnus-data-header (assq ,number gnus-newsgroup-data))
7096 '(gnus-data-header (assq (gnus-summary-article-number)
7097 gnus-newsgroup-data)))))
7100 (mail-header-subject headers))))
7102 (defmacro gnus-summary-article-score (&optional number)
7103 "Return current article score."
7104 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
7105 gnus-newsgroup-scored))
7106 gnus-summary-default-score 0))
7108 (defun gnus-summary-article-children (&optional number)
7109 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
7110 (level (gnus-data-level (car data)))
7112 (while (and (setq data (cdr data))
7113 (> (setq l (gnus-data-level (car data))) level))
7114 (and (= (1+ level) l)
7115 (setq children (cons (gnus-data-number (car data))
7117 (nreverse children)))
7119 (defun gnus-summary-article-parent (&optional number)
7120 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
7121 (gnus-data-list t)))
7122 (level (gnus-data-level (car data)))
7125 () ; This is a root.
7126 ;; We search until we find an article with a level less than
7127 ;; this one. That function has to be the parent.
7128 (while (and (setq data (cdr data))
7129 (not (< (gnus-data-level (car data)) level))))
7130 (and data (gnus-data-number (car data))))))
7132 ;; Various summary mode internalish functions.
7134 (defun gnus-mouse-pick-article (e)
7137 (gnus-summary-next-page nil t))
7139 (defun gnus-summary-setup-buffer (group)
7140 "Initialize summary buffer."
7141 (let ((buffer (concat "*Summary " group "*")))
7142 (if (get-buffer buffer)
7145 (setq gnus-summary-buffer (current-buffer))
7146 (not gnus-newsgroup-prepared))
7147 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
7148 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
7149 (gnus-add-current-to-buffer-list)
7150 (gnus-summary-mode group)
7152 (gnus-carpal-setup-buffer 'summary))
7153 (unless gnus-single-article-buffer
7154 (make-local-variable 'gnus-article-buffer)
7155 (make-local-variable 'gnus-original-article-buffer))
7156 (setq gnus-newsgroup-name group)
7159 (defun gnus-set-global-variables ()
7160 ;; Set the global equivalents of the summary buffer-local variables
7161 ;; to the latest values they had. These reflect the summary buffer
7162 ;; that was in action when the last article was fetched.
7163 (when (eq major-mode 'gnus-summary-mode)
7164 (setq gnus-summary-buffer (current-buffer))
7165 (let ((name gnus-newsgroup-name)
7166 (marked gnus-newsgroup-marked)
7167 (unread gnus-newsgroup-unreads)
7168 (headers gnus-current-headers)
7169 (data gnus-newsgroup-data)
7170 (article-buffer gnus-article-buffer)
7171 (original gnus-original-article-buffer)
7172 (score-file gnus-current-score-file))
7174 (set-buffer gnus-group-buffer)
7175 (setq gnus-newsgroup-name name)
7176 (setq gnus-newsgroup-marked marked)
7177 (setq gnus-newsgroup-unreads unread)
7178 (setq gnus-current-headers headers)
7179 (setq gnus-newsgroup-data data)
7180 (setq gnus-article-buffer article-buffer)
7181 (setq gnus-original-article-buffer original)
7182 (setq gnus-current-score-file score-file)))))
7184 (defun gnus-summary-last-article-p (&optional article)
7185 "Return whether ARTICLE is the last article in the buffer."
7186 (if (not (setq article (or article (gnus-summary-article-number))))
7187 t ; All non-existant numbers are the last article. :-)
7188 (cdr (gnus-data-find-list article))))
7190 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
7191 "Insert a dummy root in the summary buffer."
7193 (add-text-properties
7194 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
7195 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
7197 (defvar gnus-thread-indent-array nil)
7198 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
7199 (defun gnus-make-thread-indent-array ()
7201 (if (and gnus-thread-indent-array
7202 (= gnus-thread-indent-level gnus-thread-indent-array-level))
7204 (setq gnus-thread-indent-array (make-vector 201 "")
7205 gnus-thread-indent-array-level gnus-thread-indent-level)
7207 (aset gnus-thread-indent-array n
7208 (make-string (* n gnus-thread-indent-level) ? ))
7211 (defun gnus-summary-insert-line
7212 (gnus-tmp-header gnus-tmp-level gnus-tmp-current gnus-tmp-unread
7213 gnus-tmp-replied gnus-tmp-expirable gnus-tmp-subject-or-nil
7214 &optional gnus-tmp-dummy gnus-tmp-score gnus-tmp-process)
7215 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
7216 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
7217 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
7218 (gnus-tmp-score-char
7219 (if (or (null gnus-summary-default-score)
7220 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
7221 gnus-summary-zcore-fuzz)) ?
7222 (if (< gnus-tmp-score gnus-summary-default-score)
7223 gnus-score-below-mark gnus-score-over-mark)))
7224 (gnus-tmp-replied (cond (gnus-tmp-process gnus-process-mark)
7225 ((memq gnus-tmp-current gnus-newsgroup-cached)
7227 (gnus-tmp-replied gnus-replied-mark)
7228 ((memq gnus-tmp-current gnus-newsgroup-saved)
7230 (t gnus-unread-mark)))
7231 (gnus-tmp-from (mail-header-from gnus-tmp-header))
7234 ((string-match "(.+)" gnus-tmp-from)
7235 (substring gnus-tmp-from
7236 (1+ (match-beginning 0)) (1- (match-end 0))))
7237 ((string-match "<[^>]+> *$" gnus-tmp-from)
7238 (let ((beg (match-beginning 0)))
7239 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
7240 (substring gnus-tmp-from (1+ (match-beginning 0))
7241 (1- (match-end 0))))
7242 (substring gnus-tmp-from 0 beg))))
7244 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
7245 (gnus-tmp-number (mail-header-number gnus-tmp-header))
7246 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
7247 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
7248 (buffer-read-only nil))
7249 (when (string= gnus-tmp-name "")
7250 (setq gnus-tmp-name gnus-tmp-from))
7251 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
7254 (progn (eval gnus-summary-line-format-spec) (point))
7255 'gnus-number gnus-tmp-number)
7256 (when (gnus-visual-p 'summary-highlight 'highlight)
7258 (run-hooks 'gnus-summary-update-hook)
7261 (defun gnus-summary-update-line (&optional dont-update)
7262 ;; Update summary line after change.
7263 (when (and gnus-summary-default-score
7264 (not gnus-summary-inhibit-highlight))
7265 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
7266 (article (gnus-summary-article-number))
7267 (score (gnus-summary-article-score article)))
7269 (if (and gnus-summary-mark-below
7270 (< (gnus-summary-article-score)
7271 gnus-summary-mark-below))
7272 ;; This article has a low score, so we mark it as read.
7273 (when (memq article gnus-newsgroup-unreads)
7274 (gnus-summary-mark-article-as-read gnus-low-score-mark))
7275 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
7276 ;; This article was previously marked as read on account
7277 ;; of a low score, but now it has risen, so we mark it as
7279 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
7280 (gnus-summary-update-mark
7281 (if (or (null gnus-summary-default-score)
7282 (<= (abs (- score gnus-summary-default-score))
7283 gnus-summary-zcore-fuzz)) ?
7284 (if (< score gnus-summary-default-score)
7285 gnus-score-below-mark gnus-score-over-mark)) 'score))
7286 ;; Do visual highlighting.
7287 (when (gnus-visual-p 'summary-highlight 'highlight)
7288 (run-hooks 'gnus-summary-update-hook)))))
7290 (defvar gnus-tmp-new-adopts nil)
7292 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
7293 ;; Sum up all elements (and sub-elements) in a list.
7295 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
7297 ((and (consp thread) (cdr thread))
7300 'gnus-summary-number-of-articles-in-thread (cdr thread))))
7303 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
7306 (when (and level (zerop level) gnus-tmp-new-adopts)
7309 'gnus-summary-number-of-articles-in-thread
7310 gnus-tmp-new-adopts))))
7312 (if (> number 1) gnus-not-empty-thread-mark
7313 gnus-empty-thread-mark)
7316 (defun gnus-summary-set-local-parameters (group)
7317 "Go through the local params of GROUP and set all variable specs in that list."
7318 (let ((params (gnus-info-params (gnus-get-info group)))
7321 (setq elem (car params)
7322 params (cdr params))
7323 (and (consp elem) ; Has to be a cons.
7324 (consp (cdr elem)) ; The cdr has to be a list.
7325 (symbolp (car elem)) ; Has to be a symbol in there.
7326 (progn ; So we set it.
7327 (make-local-variable (car elem))
7328 (set (car elem) (eval (nth 1 elem))))))))
7330 (defun gnus-summary-read-group
7331 (group &optional show-all no-article kill-buffer no-display)
7332 "Start reading news in newsgroup GROUP.
7333 If SHOW-ALL is non-nil, already read articles are also listed.
7334 If NO-ARTICLE is non-nil, no article is selected initially.
7335 If NO-DISPLAY, don't generate a summary buffer."
7336 (gnus-message 5 "Retrieving newsgroup: %s..." group)
7337 (let* ((new-group (gnus-summary-setup-buffer group))
7338 (quit-config (gnus-group-quit-config group))
7339 (did-select (and new-group (gnus-select-newsgroup group show-all))))
7341 ;; This summary buffer exists already, so we just select it.
7343 (gnus-set-global-variables)
7345 (gnus-kill-or-deaden-summary kill-buffer))
7346 (gnus-configure-windows 'summary 'force)
7347 (gnus-set-mode-line 'summary)
7348 (gnus-summary-position-point)
7351 ;; We couldn't select this group.
7353 (when (and (eq major-mode 'gnus-summary-mode)
7354 (not (equal (current-buffer) kill-buffer)))
7355 (kill-buffer (current-buffer))
7356 (if (not quit-config)
7358 (set-buffer gnus-group-buffer)
7359 (gnus-group-jump-to-group group)
7360 (gnus-group-next-unread-group 1))
7361 (if (not (buffer-name (car quit-config)))
7362 (gnus-configure-windows 'group 'force)
7363 (set-buffer (car quit-config))
7364 (and (eq major-mode 'gnus-summary-mode)
7365 (gnus-set-global-variables))
7366 (gnus-configure-windows (cdr quit-config)))))
7367 (gnus-message 3 "Can't select group")
7369 ;; The user did a `C-g' while prompting for number of articles,
7370 ;; so we exit this group.
7371 ((eq did-select 'quit)
7372 (and (eq major-mode 'gnus-summary-mode)
7373 (not (equal (current-buffer) kill-buffer))
7374 (kill-buffer (current-buffer)))
7376 (gnus-kill-or-deaden-summary kill-buffer))
7377 (if (not quit-config)
7379 (set-buffer gnus-group-buffer)
7380 (gnus-group-jump-to-group group)
7381 (gnus-group-next-unread-group 1)
7382 (gnus-configure-windows 'group 'force))
7383 (if (not (buffer-name (car quit-config)))
7384 (gnus-configure-windows 'group 'force)
7385 (set-buffer (car quit-config))
7386 (and (eq major-mode 'gnus-summary-mode)
7387 (gnus-set-global-variables))
7388 (gnus-configure-windows (cdr quit-config))))
7389 ;; Finally signal the quit.
7391 ;; The group was successfully selected.
7393 (gnus-set-global-variables)
7394 ;; Save the active value in effect when the group was entered.
7395 (setq gnus-newsgroup-active
7397 (gnus-active gnus-newsgroup-name)))
7398 ;; You can change the summary buffer in some way with this hook.
7399 (run-hooks 'gnus-select-group-hook)
7400 ;; Set any local variables in the group parameters.
7401 (gnus-summary-set-local-parameters gnus-newsgroup-name)
7402 (gnus-update-format-specifications)
7403 ;; Do score processing.
7404 (when gnus-use-scoring
7405 (gnus-possibly-score-headers))
7406 ;; Check whether to fill in the gaps in the threads.
7407 (when gnus-build-sparse-threads
7408 (gnus-build-sparse-threads))
7409 ;; Find the initial limit.
7411 (let ((gnus-newsgroup-dormant nil))
7412 (gnus-summary-initial-limit show-all))
7413 (gnus-summary-initial-limit show-all))
7414 ;; Generate the summary buffer.
7416 (gnus-summary-prepare))
7417 (when gnus-use-trees
7418 (gnus-tree-open group)
7419 (setq gnus-summary-highlight-line-function
7420 'gnus-tree-highlight-article))
7421 ;; If the summary buffer is empty, but there are some low-scored
7422 ;; articles or some excluded dormants, we include these in the
7424 (when (and (zerop (buffer-size))
7426 (cond (gnus-newsgroup-dormant
7427 (gnus-summary-limit-include-dormant))
7428 ((and gnus-newsgroup-scored show-all)
7429 (gnus-summary-limit-include-expunged))))
7430 ;; Function `gnus-apply-kill-file' must be called in this hook.
7431 (run-hooks 'gnus-apply-kill-hook)
7432 (if (and (zerop (buffer-size))
7435 ;; This newsgroup is empty.
7436 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
7437 (gnus-message 6 "No unread news")
7439 (gnus-kill-or-deaden-summary kill-buffer))
7440 ;; Return nil from this function.
7442 ;; Hide conversation thread subtrees. We cannot do this in
7443 ;; gnus-summary-prepare-hook since kill processing may not
7444 ;; work with hidden articles.
7445 (and gnus-show-threads
7446 gnus-thread-hide-subtree
7447 (gnus-summary-hide-all-threads))
7448 ;; Show first unread article if requested.
7449 (if (and (not no-article)
7451 gnus-newsgroup-unreads
7452 gnus-auto-select-first)
7453 (if (eq gnus-auto-select-first 'best)
7454 (gnus-summary-best-unread-article)
7455 (gnus-summary-first-unread-article))
7456 ;; Don't select any articles, just move point to the first
7457 ;; article in the group.
7458 (goto-char (point-min))
7459 (gnus-summary-position-point)
7460 (gnus-set-mode-line 'summary)
7461 (gnus-configure-windows 'summary 'force))
7462 ;; If we are in async mode, we send some info to the backend.
7463 (when gnus-newsgroup-async
7464 (gnus-request-asynchronous gnus-newsgroup-name gnus-newsgroup-data))
7466 (gnus-kill-or-deaden-summary kill-buffer))
7467 (when (get-buffer-window gnus-group-buffer t)
7468 ;; Gotta use windows, because recenter does wierd stuff if
7469 ;; the current buffer ain't the displayed window.
7470 (let ((owin (selected-window)))
7471 (select-window (get-buffer-window gnus-group-buffer t))
7472 (when (gnus-group-goto-group group)
7474 (select-window owin))))
7475 ;; Mark this buffer as "prepared".
7476 (setq gnus-newsgroup-prepared t)
7479 (defun gnus-summary-prepare ()
7480 "Generate the summary buffer."
7481 (let ((buffer-read-only nil))
7483 (setq gnus-newsgroup-data nil
7484 gnus-newsgroup-data-reverse nil)
7485 (run-hooks 'gnus-summary-generate-hook)
7486 ;; Generate the buffer, either with threads or without.
7487 (when gnus-newsgroup-headers
7488 (gnus-summary-prepare-threads
7489 (if gnus-show-threads
7490 (gnus-sort-gathered-threads
7491 (funcall gnus-summary-thread-gathering-function
7493 (gnus-cut-threads (gnus-make-threads)))))
7494 ;; Unthreaded display.
7495 (gnus-sort-articles gnus-newsgroup-headers))))
7496 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
7497 ;; Call hooks for modifying summary buffer.
7498 (goto-char (point-min))
7499 (run-hooks 'gnus-summary-prepare-hook)))
7501 (defun gnus-gather-threads-by-subject (threads)
7502 "Gather threads by looking at Subject headers."
7503 (if (not gnus-summary-make-false-root)
7505 (let ((hashtb (gnus-make-hashtable 1023))
7508 subject hthread whole-subject)
7510 (setq whole-subject (mail-header-subject (car (car threads))))
7511 (if (and gnus-summary-gather-exclude-subject
7512 (string-match gnus-summary-gather-exclude-subject
7514 () ; We don't want to do anything with this article.
7515 ;; We simplify the subject before looking it up in the
7519 ;; Truncate the subject.
7520 ((numberp gnus-summary-gather-subject-limit)
7521 (setq subject (gnus-simplify-subject-re whole-subject))
7522 (if (> (length subject) gnus-summary-gather-subject-limit)
7523 (substring subject 0 gnus-summary-gather-subject-limit)
7525 ;; Fuzzily simplify it.
7526 ((eq 'fuzzy gnus-summary-gather-subject-limit)
7527 (gnus-simplify-subject-fuzzy whole-subject))
7528 ;; Just remove the leading "Re:".
7530 (gnus-simplify-subject-re whole-subject))))
7532 (if (setq hthread (gnus-gethash subject hashtb))
7534 ;; We enter a dummy root into the thread, if we
7535 ;; haven't done that already.
7536 (unless (stringp (car (car hthread)))
7537 (setcar hthread (list whole-subject (car hthread))))
7538 ;; We add this new gathered thread to this gathered
7540 (setcdr (car hthread)
7541 (nconc (cdr (car hthread)) (list (car threads))))
7542 ;; Remove it from the list of threads.
7543 (setcdr prev (cdr threads))
7544 (setq threads prev))
7545 ;; Enter this thread into the hash table.
7546 (gnus-sethash subject threads hashtb)))
7548 (setq threads (cdr threads)))
7551 (defun gnus-summary-gather-threads-by-references (threads)
7552 "Gather threads by looking at References headers."
7553 (let ((idhashtb (gnus-make-hashtable 1023))
7554 (thhashtb (gnus-make-hashtable 1023))
7557 ids references id gthread gid entered)
7559 (when (setq references (mail-header-references (caar threads)))
7560 (setq id (mail-header-id (caar threads)))
7561 (setq ids (gnus-split-references references))
7564 (if (not (setq gid (gnus-gethash (car ids) idhashtb)))
7566 (gnus-sethash (car ids) id idhashtb)
7567 (gnus-sethash id threads thhashtb))
7568 (setq gthread (gnus-gethash gid thhashtb))
7570 ;; We enter a dummy root into the thread, if we
7571 ;; haven't done that already.
7572 (unless (stringp (caar gthread))
7573 (setcar gthread (list (mail-header-subject (caar gthread))
7575 ;; We add this new gathered thread to this gathered
7577 (setcdr (car gthread)
7578 (nconc (cdar gthread) (list (car threads)))))
7579 ;; Add it into the thread hash table.
7580 (gnus-sethash id gthread thhashtb)
7582 ;; Remove it from the list of threads.
7583 (setcdr prev (cdr threads))
7584 (setq threads prev))
7585 (setq ids (cdr ids))))
7587 (setq threads (cdr threads)))
7590 (defun gnus-sort-gathered-threads (threads)
7591 "Sort subtreads inside each gathered thread by article number."
7592 (let ((result threads))
7594 (when (stringp (car (car threads)))
7595 (setcdr (car threads)
7596 (sort (cdr (car threads)) 'gnus-thread-sort-by-number)))
7597 (setq threads (cdr threads)))
7600 (defun gnus-make-threads ()
7601 "Go through the dependency hashtb and find the roots. Return all threads."
7605 (unless (car (symbol-value refs))
7606 ;; These threads do not refer back to any other articles,
7607 ;; so they're roots.
7608 (setq threads (append (cdr (symbol-value refs)) threads))))
7609 gnus-newsgroup-dependencies)
7612 (defun gnus-build-sparse-threads ()
7613 (let ((headers gnus-newsgroup-headers)
7614 (deps gnus-newsgroup-dependencies)
7615 header references generation relations
7616 cthread subject child end pthread relation)
7617 ;; First we create an alist of generations/relations, where
7618 ;; generations is how much we trust the ralation, and the relation
7620 (gnus-message 7 "Making sparse threads...")
7622 (nnheader-set-temp-buffer " *gnus sparse threads*")
7623 (while (setq header (pop headers))
7624 (when (and (setq references (mail-header-references header))
7625 (not (string= references "")))
7627 (setq child (downcase (mail-header-id header))
7628 subject (mail-header-subject header))
7630 (while (search-backward ">" nil t)
7631 (setq end (1+ (point)))
7632 (when (search-backward "<" nil t)
7633 (push (list (incf generation)
7634 child (setq child (downcase
7635 (buffer-substring (point) end)))
7638 (push (list (1+ generation) child nil subject) relations)
7640 (kill-buffer (current-buffer)))
7641 ;; Sort over trustworthiness.
7642 (setq relations (sort relations (lambda (r1 r2) (< (car r1) (car r2)))))
7643 (while (setq relation (pop relations))
7644 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
7645 (unless (car (symbol-value cthread))
7646 ;; Make this article the parent of these threads.
7647 (setcar (symbol-value cthread)
7648 (vector gnus-reffed-article-number
7652 (or (caddr relation) "") 0 0 "")))
7653 (set cthread (list (vector gnus-reffed-article-number
7655 "" "" (cadr relation)
7656 (or (caddr relation) "") 0 0 ""))))
7657 (push gnus-reffed-article-number gnus-newsgroup-limit)
7658 (push gnus-reffed-article-number gnus-newsgroup-sparse)
7659 (push (cons gnus-reffed-article-number gnus-sparse-mark)
7660 gnus-newsgroup-reads)
7661 (decf gnus-reffed-article-number)
7662 ;; Make this new thread the child of its parent.
7663 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
7664 (setcdr (symbol-value pthread)
7665 (nconc (cdr (symbol-value pthread))
7666 (list (symbol-value cthread))))
7667 (set pthread (list nil (symbol-value cthread))))))
7668 (gnus-message 7 "Making sparse threads...done")))
7670 (defun gnus-build-old-threads ()
7671 ;; Look at all the articles that refer back to old articles, and
7672 ;; fetch the headers for the articles that aren't there. This will
7673 ;; build complete threads - if the roots haven't been expired by the
7678 (when (not (car (symbol-value refs)))
7679 (setq heads (cdr (symbol-value refs)))
7681 (if (memq (mail-header-number (car (car heads)))
7682 gnus-newsgroup-dormant)
7683 (setq heads (cdr heads))
7684 (setq id (symbol-name refs))
7685 (while (and (setq id (gnus-build-get-header id))
7686 (not (car (gnus-gethash
7687 id gnus-newsgroup-dependencies)))))
7688 (setq heads nil)))))
7689 gnus-newsgroup-dependencies)))
7691 (defun gnus-build-get-header (id)
7692 ;; Look through the buffer of NOV lines and find the header to
7693 ;; ID. Enter this line into the dependencies hash table, and return
7694 ;; the id of the parent article (if any).
7695 (let ((deps gnus-newsgroup-dependencies)
7699 (set-buffer nntp-server-buffer)
7700 (goto-char (point-min))
7701 (while (and (not found) (search-forward id nil t))
7703 (setq found (looking-at
7704 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
7705 (regexp-quote id))))
7706 (or found (beginning-of-line 2)))
7711 (setq header (gnus-nov-parse-line
7712 (read (current-buffer)) deps))
7713 (gnus-parent-id (mail-header-references header))))))
7715 (let ((number (mail-header-number header)))
7716 (push number gnus-newsgroup-limit)
7717 (push header gnus-newsgroup-headers)
7718 (if (memq number gnus-newsgroup-unselected)
7720 (push number gnus-newsgroup-unreads)
7721 (setq gnus-newsgroup-unselected
7722 (delq number gnus-newsgroup-unselected)))
7723 (push number gnus-newsgroup-ancient)))))))
7725 (defun gnus-summary-update-article (article &optional header)
7726 "Update ARTICLE in the summary buffer."
7727 (let ((id (mail-header-id (gnus-summary-article-header article)))
7728 (data (gnus-data-find article)))
7729 (setcar (gnus-id-to-thread id) nil)
7730 (gnus-summary-insert-subject id)
7731 ;; Set the (possibly) new article number in the data structure.
7732 (gnus-data-set-number data (gnus-id-to-article id))))
7734 (defun gnus-rebuild-thread (id)
7735 "Rebuild the thread containing ID."
7736 (let ((dep gnus-newsgroup-dependencies)
7737 (buffer-read-only nil)
7738 current headers refs thread art data)
7739 (if (not gnus-show-threads)
7740 (setq thread (list (car (gnus-id-to-thread id))))
7741 ;; Get the thread this article is part of.
7742 (setq thread (gnus-remove-thread id)))
7743 (setq current (save-excursion
7744 (and (zerop (forward-line -1))
7745 (gnus-summary-article-number))))
7746 ;; If this is a gathered thread, we have to go some re-gathering.
7747 (when (stringp (car thread))
7748 (let ((subject (car thread))
7750 (setq thread (cdr thread))
7752 (unless (memq (setq thr (gnus-id-to-thread
7754 (mail-header-id (car (car thread))))))
7757 (setq thread (cdr thread)))
7758 ;; We now have all (unique) roots.
7759 (if (= (length roots) 1)
7760 ;; All the loose roots are now one solid root.
7761 (setq thread (car roots))
7762 (setq thread (cons subject (gnus-sort-threads roots))))))
7765 ;; We then insert this thread into the summary buffer.
7766 (let (gnus-newsgroup-data gnus-newsgroup-threads)
7767 (gnus-summary-prepare-threads (list thread))
7768 (setq data (nreverse gnus-newsgroup-data))
7769 (setq threads gnus-newsgroup-threads))
7770 ;; We splice the new data into the data structure.
7771 (gnus-data-enter-list current data)
7772 (gnus-data-compute-positions)
7773 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
7775 (defun gnus-id-to-thread (id)
7776 "Return the (sub-)thread where ID appears."
7777 (gnus-gethash (downcase id) gnus-newsgroup-dependencies))
7779 (defun gnus-id-to-article (id)
7780 "Return the article number of ID."
7781 (let ((thread (gnus-id-to-thread id)))
7783 (mail-header-number (car thread)))))
7785 (defun gnus-id-to-header (id)
7786 "Return the article headers of ID."
7787 (car (gnus-id-to-thread id)))
7789 (defun gnus-article-displayed-root-p (article)
7790 "Say whether ARTICLE is a root(ish) article."
7791 (let ((level (gnus-summary-thread-level article))
7797 (null (setq particle (gnus-id-to-article
7799 (mail-header-references
7800 (gnus-summary-article-header article))))))
7801 (null (gnus-summary-thread-level particle)))))))
7803 (defun gnus-root-id (id)
7804 "Return the id of the root of the thread where ID appears."
7806 (while (and id (setq prev (car (gnus-gethash
7808 gnus-newsgroup-dependencies))))
7810 id (gnus-parent-id (mail-header-references prev))))
7813 (defun gnus-remove-thread (id &optional dont-remove)
7814 "Remove the thread that has ID in it."
7815 (let ((dep gnus-newsgroup-dependencies)
7816 headers thread prev last-id)
7817 ;; First go up in this thread until we find the root.
7818 (setq last-id (gnus-root-id id))
7819 (setq headers (list (car (gnus-id-to-thread last-id))
7820 (car (car (cdr (gnus-id-to-thread last-id))))))
7821 ;; We have now found the real root of this thread. It might have
7822 ;; been gathered into some loose thread, so we have to search
7823 ;; through the threads to find the thread we wanted.
7824 (let ((threads gnus-newsgroup-threads)
7827 (setq sub (car threads))
7828 (if (stringp (car sub))
7829 ;; This is a gathered threads, so we look at the roots
7830 ;; below it to find whether this article in in this
7833 (setq sub (cdr sub))
7835 (when (member (car (car sub)) headers)
7836 (setq thread (car threads)
7839 (setq sub (cdr sub))))
7840 ;; It's an ordinary thread, so we check it.
7841 (when (eq (car sub) (car headers))
7844 (setq threads (cdr threads)))
7845 ;; If this article is in no thread, then it's a root.
7848 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
7849 (setq thread (gnus-gethash (downcase last-id) dep)))
7852 thread ; We return this thread.
7854 (if (stringp (car thread))
7856 ;; If we use dummy roots, then we have to remove the
7857 ;; dummy root as well.
7858 (when (eq gnus-summary-make-false-root 'dummy)
7861 (setq thread (cdr thread))
7863 (gnus-remove-thread-1 (car thread))
7864 (setq thread (cdr thread))))
7865 (gnus-remove-thread-1 thread))))))))
7867 (defun gnus-remove-thread-1 (thread)
7868 "Remove the thread THREAD recursively."
7869 (let ((number (mail-header-number (car thread)))
7871 (when (setq pos (text-property-any
7872 (point-min) (point-max) 'gnus-number number))
7875 (gnus-data-remove number))
7876 (setq thread (cdr thread))
7878 (gnus-remove-thread-1 (car thread))
7879 (setq thread (cdr thread)))))
7881 (defun gnus-sort-threads (threads)
7883 (if (not gnus-thread-sort-functions)
7885 (let ((func (if (= 1 (length gnus-thread-sort-functions))
7886 (car gnus-thread-sort-functions)
7888 ,(gnus-make-sort-function
7889 (reverse gnus-thread-sort-functions))))))
7890 (gnus-message 7 "Sorting threads...")
7893 (gnus-message 7 "Sorting threads...done")))))
7895 (defun gnus-sort-articles (articles)
7897 (when gnus-article-sort-functions
7898 (let ((func (if (= 1 (length gnus-article-sort-functions))
7899 (car gnus-article-sort-functions)
7901 ,(gnus-make-sort-function
7902 (reverse gnus-article-sort-functions))))))
7903 (gnus-message 7 "Sorting articles...")
7905 (setq gnus-newsgroup-headers (sort articles func))
7906 (gnus-message 7 "Sorting articles...done")))))
7908 (defun gnus-make-sort-function (funs)
7909 "Return a composite sort condition based on the functions in FUNC."
7911 `(or (,(car funs) t1 t2)
7912 (and (not (,(car funs) t2 t1))
7913 ,(gnus-make-sort-function (cdr funs))))
7914 `(,(car funs) t1 t2)))
7916 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
7917 (defmacro gnus-thread-header (thread)
7918 ;; Return header of first article in THREAD.
7919 ;; Note that THREAD must never, ever be anything else than a variable -
7920 ;; using some other form will lead to serious barfage.
7921 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
7922 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
7923 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
7926 (defsubst gnus-article-sort-by-number (h1 h2)
7927 "Sort articles by article number."
7928 (< (mail-header-number h1)
7929 (mail-header-number h2)))
7931 (defun gnus-thread-sort-by-number (h1 h2)
7932 "Sort threads by root article number."
7933 (gnus-article-sort-by-number
7934 (gnus-thread-header h1) (gnus-thread-header h2)))
7936 (defsubst gnus-article-sort-by-author (h1 h2)
7937 "Sort articles by root author."
7939 (let ((extract (funcall
7940 gnus-extract-address-components
7941 (mail-header-from h1))))
7942 (or (car extract) (cdr extract)))
7943 (let ((extract (funcall
7944 gnus-extract-address-components
7945 (mail-header-from h2))))
7946 (or (car extract) (cdr extract)))))
7948 (defun gnus-thread-sort-by-author (h1 h2)
7949 "Sort threads by root author."
7950 (gnus-article-sort-by-author
7951 (gnus-thread-header h1) (gnus-thread-header h2)))
7953 (defsubst gnus-article-sort-by-subject (h1 h2)
7954 "Sort articles by root subject."
7956 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
7957 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
7959 (defun gnus-thread-sort-by-subject (h1 h2)
7960 "Sort threads by root subject."
7961 (gnus-article-sort-by-subject
7962 (gnus-thread-header h1) (gnus-thread-header h2)))
7964 (defsubst gnus-article-sort-by-date (h1 h2)
7965 "Sort articles by root article date."
7967 (gnus-sortable-date (mail-header-date h1))
7968 (gnus-sortable-date (mail-header-date h2))))
7970 (defun gnus-thread-sort-by-date (h1 h2)
7971 "Sort threads by root article date."
7972 (gnus-article-sort-by-date
7973 (gnus-thread-header h1) (gnus-thread-header h2)))
7975 (defsubst gnus-article-sort-by-score (h1 h2)
7976 "Sort articles by root article score.
7977 Unscored articles will be counted as having a score of zero."
7978 (> (or (cdr (assq (mail-header-number h1)
7979 gnus-newsgroup-scored))
7980 gnus-summary-default-score 0)
7981 (or (cdr (assq (mail-header-number h2)
7982 gnus-newsgroup-scored))
7983 gnus-summary-default-score 0)))
7985 (defun gnus-thread-sort-by-score (h1 h2)
7986 "Sort threads by root article score."
7987 (gnus-article-sort-by-score
7988 (gnus-thread-header h1) (gnus-thread-header h2)))
7990 (defun gnus-thread-sort-by-total-score (h1 h2)
7991 "Sort threads by the sum of all scores in the thread.
7992 Unscored articles will be counted as having a score of zero."
7993 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
7995 (defun gnus-thread-total-score (thread)
7996 ;; This function find the total score of THREAD.
7998 (if (stringp (car thread))
7999 (apply gnus-thread-score-function 0
8000 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
8001 (gnus-thread-total-score-1 thread))
8002 (gnus-thread-total-score-1 (list thread))))
8004 (defun gnus-thread-total-score-1 (root)
8005 ;; This function find the total score of the thread below ROOT.
8006 (setq root (car root))
8007 (apply gnus-thread-score-function
8008 (or (cdr (assq (mail-header-number root) gnus-newsgroup-scored))
8009 gnus-summary-default-score 0)
8010 (mapcar 'gnus-thread-total-score
8011 (cdr (gnus-gethash (downcase (mail-header-id root))
8012 gnus-newsgroup-dependencies)))))
8014 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8015 (defvar gnus-tmp-prev-subject nil)
8016 (defvar gnus-tmp-false-parent nil)
8017 (defvar gnus-tmp-root-expunged nil)
8018 (defvar gnus-tmp-dummy-line nil)
8020 (defun gnus-summary-prepare-threads (threads)
8021 "Prepare summary buffer from THREADS and indentation LEVEL.
8022 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
8023 or a straight list of headers."
8024 (gnus-message 7 "Generating summary...")
8026 (setq gnus-newsgroup-threads threads)
8029 (let ((gnus-tmp-level 0)
8030 (default-score (or gnus-summary-default-score 0))
8031 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
8032 thread number subject stack state gnus-tmp-gathered beg-match
8033 new-roots gnus-tmp-new-adopts thread-end
8034 gnus-tmp-header gnus-tmp-unread
8035 gnus-tmp-replied gnus-tmp-subject-or-nil
8036 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
8037 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
8038 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
8040 (setq gnus-tmp-prev-subject nil)
8042 (if (vectorp (car threads))
8043 ;; If this is a straight (sic) list of headers, then a
8044 ;; threaded summary display isn't required, so we just create
8045 ;; an unthreaded one.
8046 (gnus-summary-prepare-unthreaded threads)
8048 ;; Do the threaded display.
8050 (while (or threads stack gnus-tmp-new-adopts new-roots)
8052 (if (and (= gnus-tmp-level 0)
8053 (not (setq gnus-tmp-dummy-line nil))
8055 (= (car (car stack)) 0))
8056 (not gnus-tmp-false-parent)
8057 (or gnus-tmp-new-adopts new-roots))
8058 (if gnus-tmp-new-adopts
8059 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
8060 thread (list (car gnus-tmp-new-adopts))
8061 gnus-tmp-header (car (car thread))
8062 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
8064 (setq thread (list (car new-roots))
8065 gnus-tmp-header (car (car thread))
8066 new-roots (cdr new-roots))))
8069 ;; If there are some threads, we do them before the
8070 ;; threads on the stack.
8071 (setq thread threads
8072 gnus-tmp-header (car (car thread)))
8073 ;; There were no current threads, so we pop something off
8075 (setq state (car stack)
8076 gnus-tmp-level (car state)
8079 gnus-tmp-header (car (car thread)))))
8081 (setq gnus-tmp-false-parent nil)
8082 (setq gnus-tmp-root-expunged nil)
8083 (setq thread-end nil)
8085 (if (stringp gnus-tmp-header)
8086 ;; The header is a dummy root.
8088 ((eq gnus-summary-make-false-root 'adopt)
8089 ;; We let the first article adopt the rest.
8090 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
8091 (cdr (cdr (car thread)))))
8092 (setq gnus-tmp-gathered
8094 (lambda (h) (mail-header-number (car h)))
8095 (cdr (cdr (car thread))))
8097 (setq thread (cons (list (car (car thread))
8098 (car (cdr (car thread))))
8100 (setq gnus-tmp-level -1
8101 gnus-tmp-false-parent t))
8102 ((eq gnus-summary-make-false-root 'empty)
8103 ;; We print adopted articles with empty subject fields.
8104 (setq gnus-tmp-gathered
8106 (lambda (h) (mail-header-number (car h)))
8107 (cdr (cdr (car thread))))
8109 (setq gnus-tmp-level -1))
8110 ((eq gnus-summary-make-false-root 'dummy)
8111 ;; We remember that we probably want to output a dummy
8113 (setq gnus-tmp-dummy-line gnus-tmp-header)
8114 (setq gnus-tmp-prev-subject gnus-tmp-header))
8116 ;; We do not make a root for the gathered
8117 ;; sub-threads at all.
8118 (setq gnus-tmp-level -1)))
8120 (setq number (mail-header-number gnus-tmp-header)
8121 subject (mail-header-subject gnus-tmp-header))
8124 ;; If the thread has changed subject, we might want to make
8125 ;; this subthread into a root.
8126 ((and (null gnus-thread-ignore-subject)
8127 (not (zerop gnus-tmp-level))
8128 gnus-tmp-prev-subject
8130 (gnus-subject-equal gnus-tmp-prev-subject subject))))
8131 (setq new-roots (nconc new-roots (list (car thread)))
8133 gnus-tmp-header nil))
8134 ;; If the article lies outside the current limit,
8135 ;; then we do not display it.
8136 ((and (not (memq number gnus-newsgroup-limit))
8137 (not gnus-tmp-dummy-line))
8138 (setq gnus-tmp-gathered
8140 (lambda (h) (mail-header-number (car h)))
8143 (setq gnus-tmp-new-adopts (if (cdr (car thread))
8144 (append gnus-tmp-new-adopts
8146 gnus-tmp-new-adopts)
8148 gnus-tmp-header nil)
8149 (when (zerop gnus-tmp-level)
8150 (setq gnus-tmp-root-expunged t)))
8151 ;; Perhaps this article is to be marked as read?
8152 ((and gnus-summary-mark-below
8153 (< (or (cdr (assq number gnus-newsgroup-scored))
8155 gnus-summary-mark-below))
8156 (setq gnus-newsgroup-unreads
8157 (delq number gnus-newsgroup-unreads))
8158 (if gnus-newsgroup-auto-expire
8159 (push number gnus-newsgroup-expirable)
8160 (push (cons number gnus-low-score-mark)
8161 gnus-newsgroup-reads))))
8163 (when gnus-tmp-header
8164 ;; We may have an old dummy line to output before this
8166 (when gnus-tmp-dummy-line
8167 (gnus-summary-insert-dummy-line
8168 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
8169 (setq gnus-tmp-dummy-line nil))
8171 ;; Compute the mark.
8175 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8176 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8177 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8178 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8179 (t (or (cdr (assq number gnus-newsgroup-reads))
8180 gnus-ancient-mark))))
8182 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
8183 gnus-tmp-header gnus-tmp-level)
8184 gnus-newsgroup-data)
8186 ;; Actually insert the line.
8188 gnus-tmp-subject-or-nil
8190 ((and gnus-thread-ignore-subject
8191 gnus-tmp-prev-subject
8192 (not (inline (gnus-subject-equal
8193 gnus-tmp-prev-subject subject))))
8195 ((zerop gnus-tmp-level)
8196 (if (and (eq gnus-summary-make-false-root 'empty)
8197 (memq number gnus-tmp-gathered)
8198 gnus-tmp-prev-subject
8199 (inline (gnus-subject-equal
8200 gnus-tmp-prev-subject subject)))
8201 gnus-summary-same-subject
8203 (t gnus-summary-same-subject)))
8204 (if (and (eq gnus-summary-make-false-root 'adopt)
8205 (= gnus-tmp-level 1)
8206 (memq number gnus-tmp-gathered))
8207 (setq gnus-tmp-opening-bracket ?\<
8208 gnus-tmp-closing-bracket ?\>)
8209 (setq gnus-tmp-opening-bracket ?\[
8210 gnus-tmp-closing-bracket ?\]))
8212 gnus-tmp-indentation
8213 (aref gnus-thread-indent-array gnus-tmp-level)
8214 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
8215 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
8216 gnus-summary-default-score 0)
8218 (if (or (null gnus-summary-default-score)
8219 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
8220 gnus-summary-zcore-fuzz)) ?
8221 (if (< gnus-tmp-score gnus-summary-default-score)
8222 gnus-score-below-mark gnus-score-over-mark))
8224 (cond ((memq number gnus-newsgroup-processable)
8226 ((memq number gnus-newsgroup-cached)
8228 ((memq number gnus-newsgroup-replied)
8230 (t gnus-unread-mark))
8231 gnus-tmp-from (mail-header-from gnus-tmp-header)
8234 ((string-match "(.+)" gnus-tmp-from)
8235 (substring gnus-tmp-from
8236 (1+ (match-beginning 0)) (1- (match-end 0))))
8237 ((string-match "<[^>]+> *$" gnus-tmp-from)
8238 (setq beg-match (match-beginning 0))
8239 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
8240 (substring gnus-tmp-from (1+ (match-beginning 0))
8241 (1- (match-end 0))))
8242 (substring gnus-tmp-from 0 beg-match)))
8244 (when (string= gnus-tmp-name "")
8245 (setq gnus-tmp-name gnus-tmp-from))
8246 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
8249 (progn (eval gnus-summary-line-format-spec) (point))
8250 'gnus-number number)
8253 (run-hooks 'gnus-summary-update-hook)
8256 (setq gnus-tmp-prev-subject subject)))
8258 (when (nth 1 thread)
8259 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
8260 (incf gnus-tmp-level)
8261 (setq threads (if thread-end nil (cdr (car thread))))
8263 (setq gnus-tmp-level 0)))))
8264 (gnus-message 7 "Generating summary...done"))
8266 (defun gnus-summary-prepare-unthreaded (headers)
8267 "Generate an unthreaded summary buffer based on HEADERS."
8268 (let (header number mark)
8271 (setq header (car headers)
8272 headers (cdr headers)
8273 number (mail-header-number header))
8275 ;; We may have to root out some bad articles...
8276 (when (memq number gnus-newsgroup-limit)
8277 (when (and gnus-summary-mark-below
8278 (< (or (cdr (assq number gnus-newsgroup-scored))
8279 gnus-summary-default-score 0)
8280 gnus-summary-mark-below))
8281 (setq gnus-newsgroup-unreads
8282 (delq number gnus-newsgroup-unreads))
8283 (if gnus-newsgroup-auto-expire
8284 (push number gnus-newsgroup-expirable)
8285 (push (cons number gnus-low-score-mark)
8286 gnus-newsgroup-reads)))
8290 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8291 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8292 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8293 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8294 (t (or (cdr (assq number gnus-newsgroup-reads))
8295 gnus-ancient-mark))))
8296 (setq gnus-newsgroup-data
8297 (cons (gnus-data-make number mark (1+ (point)) header 0)
8298 gnus-newsgroup-data))
8299 (gnus-summary-insert-line
8300 header 0 nil mark (memq number gnus-newsgroup-replied)
8301 (memq number gnus-newsgroup-expirable)
8302 (mail-header-subject header) nil
8303 (cdr (assq number gnus-newsgroup-scored))
8304 (memq number gnus-newsgroup-processable))))))
8306 (defun gnus-select-newsgroup (group &optional read-all)
8307 "Select newsgroup GROUP.
8308 If READ-ALL is non-nil, all articles in the group are selected."
8309 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
8310 (info (nth 2 entry))
8311 articles fetched-articles cached)
8313 (or (gnus-check-server
8314 (setq gnus-current-select-method (gnus-find-method-for-group group)))
8315 (error "Couldn't open server"))
8317 (or (and entry (not (eq (car entry) t))) ; Either it's active...
8318 (gnus-activate-group group) ; Or we can activate it...
8319 (progn ; Or we bug out.
8320 (kill-buffer (current-buffer))
8321 (error "Couldn't request group %s: %s"
8322 group (gnus-status-message group))))
8324 (setq gnus-newsgroup-name group)
8325 (setq gnus-newsgroup-unselected nil)
8326 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
8328 (and gnus-asynchronous
8329 (gnus-check-backend-function
8330 'request-asynchronous gnus-newsgroup-name)
8331 (setq gnus-newsgroup-async
8332 (gnus-request-asynchronous gnus-newsgroup-name)))
8334 ;; Adjust and set lists of article marks.
8336 (gnus-adjust-marked-articles info))
8338 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8339 (when (gnus-virtual-group-p group)
8340 (setq cached gnus-newsgroup-cached))
8342 (setq gnus-newsgroup-unreads
8343 (gnus-set-difference
8344 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
8345 gnus-newsgroup-dormant))
8347 (setq gnus-newsgroup-processable nil)
8349 (setq articles (gnus-articles-to-read group read-all))
8353 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
8355 ((eq articles 0) nil)
8357 ;; Init the dependencies hash table.
8358 (setq gnus-newsgroup-dependencies
8359 (gnus-make-hashtable (length articles)))
8360 ;; Retrieve the headers and read them in.
8361 (gnus-message 5 "Fetching headers...")
8362 (setq gnus-newsgroup-headers
8364 (setq gnus-headers-retrieved-by
8365 (gnus-retrieve-headers
8366 articles gnus-newsgroup-name
8367 ;; We might want to fetch old headers, but
8368 ;; not if there is only 1 article.
8369 (and gnus-fetch-old-headers
8371 (not (eq gnus-fetch-old-headers 'some))
8372 (not (numberp gnus-fetch-old-headers)))
8373 (> (length articles) 1))))))
8374 (gnus-get-newsgroup-headers-xover articles)
8375 (gnus-get-newsgroup-headers)))
8376 (gnus-message 5 "Fetching headers...done")
8378 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8380 (setq gnus-newsgroup-cached cached))
8382 ;; Set the initial limit.
8383 (setq gnus-newsgroup-limit (copy-sequence articles))
8384 ;; Remove canceled articles from the list of unread articles.
8385 (setq gnus-newsgroup-unreads
8386 (gnus-set-sorted-intersection
8387 gnus-newsgroup-unreads
8388 (setq fetched-articles
8389 (mapcar (lambda (headers) (mail-header-number headers))
8390 gnus-newsgroup-headers))))
8391 ;; Removed marked articles that do not exist.
8392 (gnus-update-missing-marks
8393 (gnus-sorted-complement fetched-articles articles))
8394 ;; We might want to build some more threads first.
8395 (and gnus-fetch-old-headers
8396 (eq gnus-headers-retrieved-by 'nov)
8397 (gnus-build-old-threads))
8398 ;; Check whether auto-expire is to be done in this group.
8399 (setq gnus-newsgroup-auto-expire
8400 (gnus-group-auto-expirable-p group))
8401 ;; First and last article in this newsgroup.
8402 (and gnus-newsgroup-headers
8403 (setq gnus-newsgroup-begin
8404 (mail-header-number (car gnus-newsgroup-headers)))
8405 (setq gnus-newsgroup-end
8407 (gnus-last-element gnus-newsgroup-headers))))
8408 (setq gnus-reffed-article-number -1)
8409 ;; GROUP is successfully selected.
8410 (or gnus-newsgroup-headers t)))))
8412 (defun gnus-articles-to-read (group read-all)
8413 ;; Find out what articles the user wants to read.
8415 ;; Select all articles if `read-all' is non-nil, or if there
8416 ;; are no unread articles.
8418 (and (zerop (length gnus-newsgroup-marked))
8419 (zerop (length gnus-newsgroup-unreads))))
8420 (gnus-uncompress-range (gnus-active group))
8421 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
8422 (copy-sequence gnus-newsgroup-unreads))
8424 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
8425 (scored (length scored-list))
8426 (number (length articles))
8427 (marked (+ (length gnus-newsgroup-marked)
8428 (length gnus-newsgroup-dormant)))
8436 ((and (or (<= scored marked) (= scored number))
8437 (numberp gnus-large-newsgroup)
8438 (> number gnus-large-newsgroup))
8442 "How many articles from %s (default %d): "
8443 gnus-newsgroup-name number))))
8444 (if (string-match "^[ \t]*$" input) number input)))
8445 ((and (> scored marked) (< scored number))
8448 (format "%s %s (%d scored, %d total): "
8449 "How many articles from"
8450 group scored number))))
8451 (if (string-match "^[ \t]*$" input)
8455 (setq select (if (stringp select) (string-to-number select) select))
8456 (if (or (null select) (zerop select))
8458 (if (and (not (zerop scored)) (<= (abs select) scored))
8460 (setq articles (sort scored-list '<))
8461 (setq number (length articles)))
8462 (setq articles (copy-sequence articles)))
8464 (if (< (abs select) number)
8466 ;; Select the N oldest articles.
8467 (setcdr (nthcdr (1- (abs select)) articles) nil)
8468 ;; Select the N most recent articles.
8469 (setq articles (nthcdr (- number select) articles))))
8470 (setq gnus-newsgroup-unselected
8471 (gnus-sorted-intersection
8472 gnus-newsgroup-unreads
8473 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
8476 (defun gnus-killed-articles (killed articles)
8479 (if (inline (gnus-member-of-range (car articles) killed))
8480 (setq out (cons (car articles) out)))
8481 (setq articles (cdr articles)))
8484 (defun gnus-uncompress-marks (marks)
8485 "Uncompress the mark ranges in MARKS."
8486 (let ((uncompressed '(score bookmark))
8489 (if (memq (caar marks) uncompressed)
8490 (push (car marks) out)
8491 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
8492 (setq marks (cdr marks)))
8495 (defun gnus-adjust-marked-articles (info)
8496 "Set all article lists and remove all marks that are no longer legal."
8497 (let* ((marked-lists (gnus-info-marks info))
8498 (active (gnus-active (gnus-info-group info)))
8501 (types gnus-article-mark-lists)
8502 (uncompressed '(score bookmark))
8503 marks var articles article mark)
8506 (setq marks (pop marked-lists))
8507 (set (setq var (intern (format "gnus-newsgroup-%s"
8508 (car (rassq (setq mark (car marks))
8510 (if (memq (car marks) uncompressed) (cdr marks)
8511 (gnus-uncompress-range (cdr marks))))
8513 (setq articles (symbol-value var))
8515 ;; All articles have to be subsets of the active articles.
8517 ;; Adjust "simple" lists.
8518 ((memq mark '(tick dormant expirable reply killed save))
8520 (when (or (< (setq article (pop articles)) min) (> article max))
8521 (set var (delq article (symbol-value var))))))
8523 ((memq mark '(score bookmark))
8525 (when (or (< (car (setq article (pop articles))) min)
8526 (> (car article) max))
8527 (set var (delq article (symbol-value var))))))))))
8529 (defun gnus-update-missing-marks (missing)
8530 "Go through the list of MISSING articles and remove them mark lists."
8532 (let ((types gnus-article-mark-lists)
8534 ;; Go through all types.
8536 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
8537 (when (symbol-value var)
8538 ;; This list has articles. So we delete all missing articles
8542 (set var (delq (pop m) (symbol-value var)))))))))
8544 (defun gnus-update-marks ()
8545 "Enter the various lists of marked articles into the newsgroup info list."
8546 (let ((types gnus-article-mark-lists)
8547 (info (gnus-get-info gnus-newsgroup-name))
8548 (uncompressed '(score bookmark killed))
8549 var type list newmarked symbol)
8551 ;; Add all marks lists that are non-nil to the list of marks lists.
8553 (setq type (pop types))
8554 (when (setq list (symbol-value
8556 (intern (format "gnus-newsgroup-%s"
8558 (push (cons (cdr type)
8559 (if (memq (cdr type) uncompressed) list
8560 (gnus-compress-sequence (set symbol (sort list '<)) t)))
8563 ;; Enter these new marks into the info of the group.
8565 (setcar (nthcdr 3 info) newmarked)
8566 ;; Add the marks lists to the end of the info.
8568 (setcdr (nthcdr 2 info) (list newmarked))))
8570 ;; Cut off the end of the info if there's nothing else there.
8574 (when (nthcdr (decf i) info)
8575 (setcdr (nthcdr i info) nil)))))))
8577 (defun gnus-add-marked-articles (group type articles &optional info force)
8578 ;; Add ARTICLES of TYPE to the info of GROUP.
8579 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
8580 ;; add, but replace marked articles of TYPE with ARTICLES.
8581 (let ((info (or info (gnus-get-info group)))
8582 (uncompressed '(score bookmark killed))
8585 (and (not (setq marked (nthcdr 3 info)))
8586 (setcdr (nthcdr 2 info)
8587 (list (list (cons type (gnus-compress-sequence
8589 (and (not (setq m (assq type (car marked))))
8591 (cons (cons type (gnus-compress-sequence articles t) )
8594 (setcdr m (gnus-compress-sequence articles t))
8595 (setcdr m (gnus-compress-sequence
8596 (sort (nconc (gnus-uncompress-range m)
8597 (copy-sequence articles)) '<) t))))))
8599 (defun gnus-set-mode-line (where)
8600 "This function sets the mode line of the article or summary buffers.
8601 If WHERE is `summary', the summary mode line format will be used."
8602 ;; Is this mode line one we keep updated?
8603 (when (memq where gnus-updated-mode-lines)
8606 ;; We evaluate this in the summary buffer since these
8607 ;; variables are buffer-local to that buffer.
8608 (set-buffer gnus-summary-buffer)
8609 ;; We bind all these variables that are used in the `eval' form
8611 (let* ((mformat (symbol-value
8613 (format "gnus-%s-mode-line-format-spec" where))))
8614 (gnus-tmp-group-name gnus-newsgroup-name)
8615 (gnus-tmp-article-number (or gnus-current-article 0))
8616 (gnus-tmp-unread gnus-newsgroup-unreads)
8617 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
8618 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
8619 (gnus-tmp-unread-and-unselected
8620 (cond ((and (zerop gnus-tmp-unread-and-unticked)
8621 (zerop gnus-tmp-unselected)) "")
8622 ((zerop gnus-tmp-unselected)
8623 (format "{%d more}" gnus-tmp-unread-and-unticked))
8624 (t (format "{%d(+%d) more}"
8625 gnus-tmp-unread-and-unticked
8626 gnus-tmp-unselected))))
8628 (if (and gnus-current-headers
8629 (vectorp gnus-current-headers))
8630 (mail-header-subject gnus-current-headers) ""))
8632 gnus-tmp-header);; passed as argument to any user-format-funcs
8633 (setq mode-string (eval mformat))
8634 (setq max-len (max 4 (if gnus-mode-non-string-length
8636 gnus-mode-non-string-length)
8637 (length mode-string))))
8638 ;; We might have to chop a bit of the string off...
8639 (when (> (length mode-string) max-len)
8641 (concat (gnus-truncate-string mode-string (- max-len 3))
8643 ;; Pad the mode string a bit.
8644 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
8645 ;; Update the mode line.
8646 (setq mode-line-buffer-identification (list mode-string))
8647 (set-buffer-modified-p t))))
8649 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
8650 "Go through the HEADERS list and add all Xrefs to a hash table.
8651 The resulting hash table is returned, or nil if no Xrefs were found."
8652 (let* ((from-method (gnus-find-method-for-group from-newsgroup))
8653 (virtual (gnus-virtual-group-p from-newsgroup))
8654 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
8655 (xref-hashtb (make-vector 63 0))
8656 start group entry number xrefs header)
8658 (setq header (pop headers))
8659 (when (and (setq xrefs (mail-header-xref header))
8660 (not (memq (setq number (mail-header-number header))
8663 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
8664 (setq start (match-end 0))
8665 (setq group (concat prefix (substring xrefs (match-beginning 1)
8668 (string-to-int (substring xrefs (match-beginning 2)
8670 (if (setq entry (gnus-gethash group xref-hashtb))
8671 (setcdr entry (cons number (cdr entry)))
8672 (gnus-sethash group (cons number nil) xref-hashtb)))))
8673 (and start xref-hashtb)))
8675 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
8676 "Look through all the headers and mark the Xrefs as read."
8677 (let ((virtual (gnus-virtual-group-p from-newsgroup))
8678 name entry info xref-hashtb idlist method nth4)
8680 (set-buffer gnus-group-buffer)
8681 (when (setq xref-hashtb
8682 (gnus-create-xref-hashtb from-newsgroup headers unreads))
8685 (unless (string= from-newsgroup (setq name (symbol-name group)))
8686 (setq idlist (symbol-value group))
8687 ;; Dead groups are not updated.
8689 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
8691 (if (stringp (setq nth4 (gnus-info-method info)))
8692 (setq nth4 (gnus-server-to-method nth4))))
8693 ;; Only do the xrefs if the group has the same
8694 ;; select method as the group we have just read.
8695 (or (gnus-methods-equal-p
8696 nth4 (gnus-find-method-for-group from-newsgroup))
8698 (equal nth4 (setq method (gnus-find-method-for-group
8700 (and (equal (car nth4) (car method))
8701 (equal (nth 1 nth4) (nth 1 method))))
8702 gnus-use-cross-reference
8703 (or (not (eq gnus-use-cross-reference t))
8705 ;; Only do cross-references on subscribed
8706 ;; groups, if that is what is wanted.
8707 (<= (gnus-info-level info) gnus-level-subscribed))
8708 (gnus-group-make-articles-read name idlist))))
8711 (defun gnus-group-make-articles-read (group articles)
8713 (entry (gnus-gethash group gnus-newsrc-hashtb))
8714 (info (nth 2 entry))
8715 (active (gnus-active group))
8717 ;; First peel off all illegal article numbers.
8719 (let ((ids articles)
8723 (if (and first (> id (cdr active)))
8725 ;; We'll end up in this situation in one particular
8726 ;; obscure situation. If you re-scan a group and get
8727 ;; a new article that is cross-posted to a different
8728 ;; group that has not been re-scanned, you might get
8729 ;; crossposted article that has a higher number than
8730 ;; Gnus believes possible. So we re-activate this
8731 ;; group as well. This might mean doing the
8732 ;; crossposting thingy will *increase* the number
8733 ;; of articles in some groups. Tsk, tsk.
8734 (setq active (or (gnus-activate-group group) active))))
8735 (if (or (> id (cdr active))
8736 (< id (car active)))
8737 (setq articles (delq id articles)))
8738 (setq ids (cdr ids)))))
8739 ;; If the read list is nil, we init it.
8741 (null (gnus-info-read info))
8743 (gnus-info-set-read info (cons 1 (1- (car active)))))
8744 ;; Then we add the read articles to the range.
8749 (gnus-info-read info) (setq articles (sort articles '<)))))
8750 ;; Then we have to re-compute how many unread
8751 ;; articles there are in this group.
8756 (setq num (- (1+ (cdr active)) (car active))))
8757 ((not (listp (cdr range)))
8758 (setq num (- (cdr active) (- (1+ (cdr range))
8762 (if (numberp (car range))
8764 (setq num (+ num (- (1+ (cdr (car range)))
8765 (car (car range))))))
8766 (setq range (cdr range)))
8767 (setq num (- (cdr active) num))))
8768 ;; Update the number of unread articles.
8770 ;; Update the group buffer.
8771 (gnus-group-update-group group t)))))
8773 (defun gnus-methods-equal-p (m1 m2)
8774 (let ((m1 (or m1 gnus-select-method))
8775 (m2 (or m2 gnus-select-method)))
8777 (and (eq (car m1) (car m2))
8778 (or (not (memq 'address (assoc (symbol-name (car m1))
8779 gnus-valid-select-methods)))
8780 (equal (nth 1 m1) (nth 1 m2)))))))
8782 (defsubst gnus-header-value ()
8783 (buffer-substring (match-end 0) (gnus-point-at-eol)))
8785 (defvar gnus-newsgroup-none-id 0)
8787 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
8788 (let ((cur nntp-server-buffer)
8791 (save-excursion (set-buffer gnus-summary-buffer)
8792 gnus-newsgroup-dependencies)))
8793 headers id id-dep ref-dep end ref)
8795 (set-buffer nntp-server-buffer)
8796 (let ((case-fold-search t)
8797 in-reply-to header number p lines)
8798 (goto-char (point-min))
8799 ;; Search to the beginning of the next header. Error messages
8800 ;; do not begin with 2 or 3.
8801 (while (re-search-forward "^[23][0-9]+ " nil t)
8804 ;; This implementation of this function, with nine
8805 ;; search-forwards instead of the one re-search-forward and
8806 ;; a case (which basically was the old function) is actually
8807 ;; about twice as fast, even though it looks messier. You
8808 ;; can't have everything, I guess. Speed and elegance
8809 ;; doesn't always go hand in hand.
8818 (narrow-to-region (point)
8819 (or (and (search-forward "\n.\n" nil t)
8825 (if (search-forward "\nsubject: " nil t)
8826 (gnus-header-value) "(none)"))
8830 (if (search-forward "\nfrom: " nil t)
8831 (gnus-header-value) "(nobody)"))
8835 (if (search-forward "\ndate: " nil t)
8836 (gnus-header-value) ""))
8840 (if (search-forward "\nmessage-id: " nil t)
8841 (setq id (gnus-header-value))
8842 ;; If there was no message-id, we just fake one to make
8843 ;; subsequent routines simpler.
8844 (setq id (concat "none+"
8846 (setq gnus-newsgroup-none-id
8847 (1+ gnus-newsgroup-none-id)))))))
8851 (if (search-forward "\nreferences: " nil t)
8854 (setq end (match-end 0))
8861 (search-backward ">" end t)
8864 (search-backward "<" end t)
8866 ;; Get the references from the in-reply-to header if there
8867 ;; were no references and the in-reply-to header looks
8869 (if (and (search-forward "\nin-reply-to: " nil t)
8870 (setq in-reply-to (gnus-header-value))
8871 (string-match "<[^>]+>" in-reply-to))
8873 (setq ref (substring in-reply-to (match-beginning 0)
8875 (setq ref (downcase ref))))
8882 (if (search-forward "\nlines: " nil t)
8883 (if (numberp (setq lines (read cur)))
8889 (and (search-forward "\nxref: " nil t)
8890 (gnus-header-value)))))
8891 ;; We do the threading while we read the headers. The
8892 ;; message-id and the last reference are both entered into
8893 ;; the same hash table. Some tippy-toeing around has to be
8894 ;; done in case an article has arrived before the article
8895 ;; which it refers to.
8896 (if (boundp (setq id-dep (intern (downcase id) dependencies)))
8897 (if (and (car (symbol-value id-dep))
8899 ;; An article with this Message-ID has already
8900 ;; been seen, so we ignore this one, except we add
8901 ;; any additional Xrefs (in case the two articles
8902 ;; came from different servers).
8904 (mail-header-set-xref
8905 (car (symbol-value id-dep))
8906 (concat (or (mail-header-xref
8907 (car (symbol-value id-dep))) "")
8908 (or (mail-header-xref header) "")))
8910 (setcar (symbol-value id-dep) header))
8911 (set id-dep (list header)))
8913 (if (boundp (setq ref-dep (intern ref dependencies)))
8914 (setcdr (symbol-value ref-dep)
8915 (nconc (cdr (symbol-value ref-dep))
8916 (list (symbol-value id-dep))))
8917 (set ref-dep (list nil (symbol-value id-dep))))
8918 (setq headers (cons header headers)))
8919 (goto-char (point-max))
8921 (nreverse headers)))))
8923 ;; The following macros and functions were written by Felix Lee
8924 ;; <flee@cse.psu.edu>.
8926 (defmacro gnus-nov-read-integer ()
8928 (if (= (following-char) ?\t)
8930 (let ((num (condition-case nil (read buffer) (error nil))))
8931 (if (numberp num) num 0)))
8932 (or (eobp) (forward-char 1))))
8934 (defmacro gnus-nov-skip-field ()
8935 '(search-forward "\t" eol 'move))
8937 (defmacro gnus-nov-field ()
8938 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
8940 ;; Goes through the xover lines and returns a list of vectors
8941 (defun gnus-get-newsgroup-headers-xover (sequence &optional force-new)
8942 "Parse the news overview data in the server buffer, and return a
8943 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
8944 ;; Get the Xref when the users reads the articles since most/some
8945 ;; NNTP servers do not include Xrefs when using XOVER.
8946 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
8947 (let ((cur nntp-server-buffer)
8948 (dependencies gnus-newsgroup-dependencies)
8949 number headers header)
8951 (set-buffer nntp-server-buffer)
8952 ;; Allow the user to mangle the headers before parsing them.
8953 (run-hooks 'gnus-parse-headers-hook)
8954 ;; Allow the user to mangle the headers before parsing them.
8955 (run-hooks 'gnus-parse-headers-hook)
8956 (goto-char (point-min))
8957 (while (and sequence (not (eobp)))
8958 (setq number (read cur))
8959 (while (and sequence (< (car sequence) number))
8960 (setq sequence (cdr sequence)))
8962 (eq number (car sequence))
8964 (setq sequence (cdr sequence))
8966 (inline (gnus-nov-parse-line
8967 number dependencies force-new)))
8968 (setq headers (cons header headers)))))
8970 (setq headers (nreverse headers)))
8973 ;; This function has to be called with point after the article number
8974 ;; on the beginning of the line.
8975 (defun gnus-nov-parse-line (number dependencies &optional force-new)
8977 (eol (gnus-point-at-eol))
8978 (buffer (current-buffer))
8979 header ref id id-dep ref-dep)
8981 ;; overview: [num subject from date id refs chars lines misc]
8982 (narrow-to-region (point) eol)
8983 (or (eobp) (forward-char))
8989 (gnus-nov-field) ; subject
8990 (gnus-nov-field) ; from
8991 (gnus-nov-field) ; date
8992 (setq id (or (gnus-nov-field)
8995 (setq none (1+ none)))))) ; id
8998 (let ((beg (point)))
8999 (search-forward "\t" eol)
9000 (if (search-backward ">" beg t)
9006 (search-backward "<" beg t)
9009 (gnus-nov-field)) ; refs
9010 (gnus-nov-read-integer) ; chars
9011 (gnus-nov-read-integer) ; lines
9012 (if (= (following-char) ?\n)
9014 (gnus-nov-field)) ; misc
9018 (gnus-message 4 "Strange nov line")
9024 ;; We build the thread tree.
9026 (if (boundp (setq id-dep (intern (downcase id) dependencies)))
9027 (if (and (car (symbol-value id-dep))
9029 ;; An article with this Message-ID has already been seen,
9030 ;; so we ignore this one, except we add any additional
9031 ;; Xrefs (in case the two articles came from different
9034 (mail-header-set-xref
9035 (car (symbol-value id-dep))
9036 (concat (or (mail-header-xref
9037 (car (symbol-value id-dep))) "")
9038 (or (mail-header-xref header) "")))
9040 (setcar (symbol-value id-dep) header))
9041 (set id-dep (list header))))
9044 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
9045 (setcdr (symbol-value ref-dep)
9046 (nconc (cdr (symbol-value ref-dep))
9047 (list (symbol-value id-dep))))
9048 (set ref-dep (list nil (symbol-value id-dep))))))
9051 (defun gnus-article-get-xrefs ()
9052 "Fill in the Xref value in `gnus-current-headers', if necessary.
9053 This is meant to be called in `gnus-article-internal-prepare-hook'."
9054 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
9055 gnus-current-headers)))
9056 (or (not gnus-use-cross-reference)
9058 (and (mail-header-xref headers)
9059 (not (string= (mail-header-xref headers) "")))
9060 (let ((case-fold-search t)
9063 (nnheader-narrow-to-headers)
9064 (goto-char (point-min))
9065 (if (or (and (eq (downcase (following-char)) ?x)
9066 (looking-at "Xref:"))
9067 (search-forward "\nXref:" nil t))
9069 (goto-char (1+ (match-end 0)))
9070 (setq xref (buffer-substring (point)
9071 (progn (end-of-line) (point))))
9072 (mail-header-set-xref headers xref))))))))
9074 (defun gnus-summary-insert-subject (id)
9075 "Find article ID and insert the summary line for that article."
9076 (let ((header (gnus-read-header id))
9077 (number (and (numberp id) id)))
9079 ;; Rebuild the thread that this article is part of and go to the
9080 ;; article we have fetched.
9081 (gnus-rebuild-thread (mail-header-id header))
9082 (gnus-summary-goto-subject (setq number (mail-header-number header))))
9083 (when (and (numberp number)
9085 ;; We have to update the boundaries even if we can't fetch the
9086 ;; article if ID is a number -- so that the next `P' or `N'
9087 ;; command will fetch the previous (or next) article even
9088 ;; if the one we tried to fetch this time has been canceled.
9089 (and (> number gnus-newsgroup-end)
9090 (setq gnus-newsgroup-end number))
9091 (and (< number gnus-newsgroup-begin)
9092 (setq gnus-newsgroup-begin number))
9093 (setq gnus-newsgroup-unselected
9094 (delq number gnus-newsgroup-unselected)))
9095 ;; Report back a success?
9096 (and header number)))
9098 (defun gnus-summary-work-articles (n)
9099 "Return a list of articles to be worked upon. The prefix argument,
9100 the list of process marked articles, and the current article will be
9101 taken into consideration."
9103 ((and n (numberp n))
9104 ;; A numerical prefix has been given.
9105 (let ((backward (< n 0))
9111 (push (setq article (gnus-summary-article-number))
9114 (gnus-summary-find-prev nil article)
9115 (gnus-summary-find-next nil article)))
9117 (nreverse articles)))
9118 ((and (boundp 'transient-mark-mode)
9121 ;; Work on the region between point and mark.
9122 (let ((max (max (point) (mark)))
9125 (goto-char (min (point) (mark)))
9128 (push (setq article (gnus-summary-article-number)) articles)
9129 (gnus-summary-find-next nil article)
9131 (nreverse articles))))
9132 (gnus-newsgroup-processable
9133 ;; There are process-marked articles present.
9134 (reverse gnus-newsgroup-processable))
9136 ;; Just return the current article.
9137 (list (gnus-summary-article-number)))))
9139 (defun gnus-summary-search-group (&optional backward use-level)
9140 "Search for next unread newsgroup.
9141 If optional argument BACKWARD is non-nil, search backward instead."
9143 (set-buffer gnus-group-buffer)
9144 (if (gnus-group-search-forward
9145 backward nil (if use-level (gnus-group-group-level) nil))
9146 (gnus-group-group-name))))
9148 (defun gnus-summary-best-group (&optional exclude-group)
9149 "Find the name of the best unread group.
9150 If EXCLUDE-GROUP, do not go to this group."
9152 (set-buffer gnus-group-buffer)
9154 (gnus-group-best-unread-group exclude-group))))
9156 (defun gnus-summary-find-next (&optional unread article backward)
9157 (if backward (gnus-summary-find-prev)
9158 (let* ((article (or article (gnus-summary-article-number)))
9159 (arts (gnus-data-find-list article))
9161 (when (or (not gnus-summary-check-current)
9163 (not (gnus-data-unread-p (car arts))))
9164 (setq arts (cdr arts)))
9169 (when (gnus-data-unread-p (car arts))
9170 (setq result (car arts)
9172 (setq arts (cdr arts)))
9175 (goto-char (gnus-data-pos result))
9176 (gnus-data-number result)))))
9178 (defun gnus-summary-find-prev (&optional unread article)
9179 (let* ((article (or article (gnus-summary-article-number)))
9180 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
9182 (when (or (not gnus-summary-check-current)
9184 (not (gnus-data-unread-p (car arts))))
9185 (setq arts (cdr arts)))
9190 (and (gnus-data-unread-p (car arts))
9191 (setq result (car arts)
9193 (setq arts (cdr arts)))
9197 (goto-char (gnus-data-pos result))
9198 (gnus-data-number result)))))
9200 (defun gnus-summary-find-subject (subject &optional unread backward article)
9201 (let* ((simp-subject (gnus-simplify-subject-fully subject))
9202 (article (or article (gnus-summary-article-number)))
9203 (articles (gnus-data-list backward))
9204 (arts (gnus-data-find-list article articles))
9206 (when (or (not gnus-summary-check-current)
9208 (not (gnus-data-unread-p (car arts))))
9209 (setq arts (cdr arts)))
9211 (and (or (not unread)
9212 (gnus-data-unread-p (car arts)))
9213 (vectorp (gnus-data-header (car arts)))
9215 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
9216 (setq result (car arts)
9218 (setq arts (cdr arts)))
9220 (goto-char (gnus-data-pos result))
9221 (gnus-data-number result))))
9223 (defun gnus-summary-search-forward (&optional unread subject backward)
9224 "Search forward for an article.
9225 If UNREAD, look for unread articles. If SUBJECT, look for
9226 articles with that subject. If BACKWARD, search backward instead."
9227 (cond (subject (gnus-summary-find-subject subject unread backward))
9228 (backward (gnus-summary-find-prev unread))
9229 (t (gnus-summary-find-next unread))))
9231 (defun gnus-recenter (&optional n)
9232 "Center point in window and redisplay frame.
9233 Also do horizontal recentering."
9235 (gnus-horizontal-recenter)
9238 (defun gnus-summary-recenter ()
9239 "Center point in the summary window.
9240 If `gnus-auto-center-summary' is nil, or the article buffer isn't
9241 displayed, no centering will be performed."
9242 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
9243 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
9244 (let* ((top (cond ((< (window-height) 4) 0)
9245 ((< (window-height) 7) 1)
9247 (height (1- (window-height)))
9248 (bottom (save-excursion (goto-char (point-max))
9249 (forward-line (- height))
9251 (window (get-buffer-window (current-buffer))))
9252 ;; The user has to want it.
9253 (when gnus-auto-center-summary
9254 (when (get-buffer-window gnus-article-buffer)
9255 ;; Only do recentering when the article buffer is displayed,
9256 ;; Set the window start to either `bottom', which is the biggest
9257 ;; possible valid number, or the second line from the top,
9258 ;; whichever is the least.
9260 window (min bottom (save-excursion
9261 (forward-line (- top)) (point)))))
9262 ;; Do horizontal recentering while we're at it.
9263 (when (get-buffer-window (current-buffer) t)
9264 (let ((selected (selected-window)))
9265 (select-window (get-buffer-window (current-buffer) t))
9266 (gnus-summary-position-point)
9267 (gnus-horizontal-recenter)
9268 (select-window selected))))))
9270 (defun gnus-horizontal-recenter ()
9271 "Recenter the current buffer horizontally."
9272 (if (< (current-column) (/ (window-width) 2))
9273 (set-window-hscroll (get-buffer-window (current-buffer) t) 0)
9274 (let* ((orig (point))
9275 (end (window-end (get-buffer-window (current-buffer) t)))
9277 ;; Find the longest line currently displayed in the window.
9278 (goto-char (window-start))
9279 (while (and (not (eobp))
9282 (setq max (max max (current-column)))
9285 ;; Scroll horizontally to center (sort of) the point.
9286 (if (> max (window-width))
9288 (get-buffer-window (current-buffer) t)
9289 (min (- (current-column) (/ (window-width) 3))
9290 (+ 2 (- max (window-width)))))
9291 (set-window-hscroll (get-buffer-window (current-buffer) t) 0))
9294 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
9295 (defun gnus-short-group-name (group &optional levels)
9296 "Collapse GROUP name LEVELS."
9303 (while (string-match "\\." group skip)
9304 (setq skip (match-end 0)
9307 (if (string-match ":" group)
9308 (setq foreign (substring group 0 (match-end 0))
9309 group (substring group (match-end 0))))
9311 (if (and (string-match "\\." group)
9312 (> levels (- gnus-group-uncollapsed-levels 1)))
9313 (setq name (concat name (substring group 0 1))
9314 group (substring group (match-end 0))
9316 name (concat name "."))
9317 (setq name (concat foreign name group)
9321 (defun gnus-summary-jump-to-group (newsgroup)
9322 "Move point to NEWSGROUP in group mode buffer."
9323 ;; Keep update point of group mode buffer if visible.
9324 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
9325 (save-window-excursion
9326 ;; Take care of tree window mode.
9327 (if (get-buffer-window gnus-group-buffer)
9328 (pop-to-buffer gnus-group-buffer))
9329 (gnus-group-jump-to-group newsgroup))
9331 ;; Take care of tree window mode.
9332 (if (get-buffer-window gnus-group-buffer)
9333 (pop-to-buffer gnus-group-buffer)
9334 (set-buffer gnus-group-buffer))
9335 (gnus-group-jump-to-group newsgroup))))
9337 ;; This function returns a list of article numbers based on the
9338 ;; difference between the ranges of read articles in this group and
9339 ;; the range of active articles.
9340 (defun gnus-list-of-unread-articles (group)
9341 (let* ((read (gnus-info-read (gnus-get-info group)))
9342 (active (gnus-active group))
9345 ;; If none are read, then all are unread.
9347 (setq first (car active))
9348 ;; If the range of read articles is a single range, then the
9349 ;; first unread article is the article after the last read
9350 ;; article. Sounds logical, doesn't it?
9351 (if (not (listp (cdr read)))
9352 (setq first (1+ (cdr read)))
9353 ;; `read' is a list of ranges.
9354 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
9355 (car (car read)))) 1)
9359 (while (< first nlast)
9360 (setq unread (cons first unread))
9361 (setq first (1+ first))))
9362 (setq first (1+ (if (atom (car read)) (car read) (cdr (car read)))))
9363 (setq nlast (if (atom (car (cdr read)))
9365 (car (car (cdr read)))))
9366 (setq read (cdr read)))))
9367 ;; And add the last unread articles.
9368 (while (<= first last)
9369 (setq unread (cons first unread))
9370 (setq first (1+ first)))
9371 ;; Return the list of unread articles.
9374 (defun gnus-list-of-read-articles (group)
9375 "Return a list of unread, unticked and non-dormant articles."
9376 (let* ((info (gnus-get-info group))
9377 (marked (gnus-info-marks info))
9378 (active (gnus-active group)))
9380 (gnus-set-difference
9381 (gnus-sorted-complement
9382 (gnus-uncompress-range active)
9383 (gnus-list-of-unread-articles group))
9385 (gnus-uncompress-range (cdr (assq 'dormant marked)))
9386 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
9388 ;; Various summary commands
9390 (defun gnus-summary-universal-argument (arg)
9391 "Perform any operation on all articles that are process/prefixed."
9393 (gnus-set-global-variables)
9394 (let ((articles (gnus-summary-work-articles arg))
9401 (substitute-command-keys
9402 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
9406 (message "Undefined key")
9410 (gnus-summary-goto-subject (setq article (pop articles)))
9411 (command-execute func)
9412 (gnus-summary-remove-process-mark article)))))
9413 (gnus-summary-position-point))
9415 (defun gnus-summary-toggle-truncation (&optional arg)
9416 "Toggle truncation of summary lines.
9417 With arg, turn line truncation on iff arg is positive."
9419 (setq truncate-lines
9420 (if (null arg) (not truncate-lines)
9421 (> (prefix-numeric-value arg) 0)))
9424 (defun gnus-summary-reselect-current-group (&optional all rescan)
9425 "Exit and then reselect the current newsgroup.
9426 The prefix argument ALL means to select all articles."
9428 (gnus-set-global-variables)
9429 (let ((current-subject (gnus-summary-article-number))
9430 (group gnus-newsgroup-name))
9431 (setq gnus-newsgroup-begin nil)
9433 ;; We have to adjust the point of group mode buffer because the
9434 ;; current point was moved to the next unread newsgroup by
9436 (gnus-summary-jump-to-group group)
9439 (gnus-group-get-new-news-this-group 1)))
9440 (gnus-group-read-group all t)
9441 (gnus-summary-goto-subject current-subject)))
9443 (defun gnus-summary-rescan-group (&optional all)
9444 "Exit the newsgroup, ask for new articles, and select the newsgroup."
9446 (gnus-summary-reselect-current-group all t))
9448 (defun gnus-summary-update-info ()
9449 (let* ((group gnus-newsgroup-name))
9450 (when gnus-newsgroup-kill-headers
9451 (setq gnus-newsgroup-killed
9452 (gnus-compress-sequence
9454 (gnus-set-sorted-intersection
9455 (gnus-uncompress-range gnus-newsgroup-killed)
9456 (setq gnus-newsgroup-unselected
9457 (sort gnus-newsgroup-unselected '<)))
9458 (setq gnus-newsgroup-unreads
9459 (sort gnus-newsgroup-unreads '<))) t)))
9460 (unless (listp (cdr gnus-newsgroup-killed))
9461 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
9462 (let ((headers gnus-newsgroup-headers))
9463 (gnus-close-group group)
9464 (run-hooks 'gnus-exit-group-hook)
9465 (unless gnus-save-score
9466 (setq gnus-newsgroup-scored nil))
9467 ;; Set the new ranges of read articles.
9468 (gnus-update-read-articles
9469 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
9470 ;; Set the current article marks.
9472 ;; Do the cross-ref thing.
9473 (when gnus-use-cross-reference
9474 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
9475 ;; Do adaptive scoring, and possibly save score files.
9476 (when gnus-newsgroup-adaptive
9477 (gnus-score-adaptive))
9478 (when gnus-use-scoring
9480 ;; Do not switch windows but change the buffer to work.
9481 (set-buffer gnus-group-buffer)
9482 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
9483 (gnus-group-update-group group)))))
9485 (defun gnus-summary-exit (&optional temporary)
9486 "Exit reading current newsgroup, and then return to group selection mode.
9487 gnus-exit-group-hook is called with no arguments if that value is non-nil."
9489 (gnus-set-global-variables)
9490 (gnus-kill-save-kill-buffer)
9491 (let* ((group gnus-newsgroup-name)
9492 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
9494 (buf (current-buffer)))
9495 (run-hooks 'gnus-summary-prepare-exit-hook)
9496 ;; If we have several article buffers, we kill them at exit.
9497 (unless gnus-single-article-buffer
9498 (gnus-kill-buffer gnus-article-buffer)
9499 (gnus-kill-buffer gnus-original-article-buffer))
9500 (when gnus-use-cache
9501 (gnus-cache-possibly-remove-articles)
9502 (gnus-cache-save-buffers))
9503 (when gnus-use-trees
9504 (gnus-tree-close group))
9505 ;; Make all changes in this group permanent.
9506 (gnus-summary-update-info)
9507 ;; Make sure where I was, and go to next newsgroup.
9508 (set-buffer gnus-group-buffer)
9510 (gnus-group-jump-to-group group)
9511 (gnus-group-next-unread-group 1))
9512 (run-hooks 'gnus-summary-exit-hook)
9515 ;; If we have several article buffers, we kill them at exit.
9516 (unless gnus-single-article-buffer
9517 (gnus-kill-buffer gnus-article-buffer)
9518 (gnus-kill-buffer gnus-original-article-buffer))
9520 (if (not gnus-kill-summary-on-exit)
9521 (gnus-deaden-summary)
9522 ;; We set all buffer-local variables to nil. It is unclear why
9523 ;; this is needed, but if we don't, buffer-local variables are
9524 ;; not garbage-collected, it seems. This would the lead to en
9525 ;; ever-growing Emacs.
9526 (gnus-summary-clear-local-variables)
9527 (when (get-buffer gnus-article-buffer)
9528 (bury-buffer gnus-article-buffer))
9529 ;; We clear the global counterparts of the buffer-local
9530 ;; variables as well, just to be on the safe side.
9531 (gnus-configure-windows 'group 'force)
9532 (gnus-summary-clear-local-variables)
9533 ;; Return to group mode buffer.
9534 (if (eq mode 'gnus-summary-mode)
9535 (gnus-kill-buffer buf)))
9536 (setq gnus-current-select-method gnus-select-method)
9537 (pop-to-buffer gnus-group-buffer)
9538 ;; Clear the current group name.
9539 (if (not quit-config)
9541 (gnus-group-jump-to-group group)
9542 (gnus-group-next-unread-group 1)
9543 (gnus-configure-windows 'group 'force))
9544 (if (not (buffer-name (car quit-config)))
9545 (gnus-configure-windows 'group 'force)
9546 (set-buffer (car quit-config))
9547 (and (eq major-mode 'gnus-summary-mode)
9548 (gnus-set-global-variables))
9549 (gnus-configure-windows (cdr quit-config))))
9551 (setq gnus-newsgroup-name nil)))))
9553 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
9554 (defun gnus-summary-exit-no-update (&optional no-questions)
9555 "Quit reading current newsgroup without updating read article info."
9557 (gnus-set-global-variables)
9558 (let* ((group gnus-newsgroup-name)
9559 (quit-config (gnus-group-quit-config group)))
9560 (when (or no-questions
9562 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
9563 ;; If we have several article buffers, we kill them at exit.
9564 (unless gnus-single-article-buffer
9565 (gnus-kill-buffer gnus-article-buffer)
9566 (gnus-kill-buffer gnus-original-article-buffer))
9567 (if (not gnus-kill-summary-on-exit)
9568 (gnus-deaden-summary)
9569 (gnus-close-group group)
9570 (gnus-summary-clear-local-variables)
9571 (set-buffer gnus-group-buffer)
9572 (gnus-summary-clear-local-variables)
9573 (when (get-buffer gnus-summary-buffer)
9574 (kill-buffer gnus-summary-buffer)))
9575 (when gnus-use-trees
9576 (gnus-tree-close group))
9577 (when (get-buffer gnus-article-buffer)
9578 (bury-buffer gnus-article-buffer))
9579 ;; Return to the group buffer.
9580 (gnus-configure-windows 'group 'force)
9581 ;; Clear the current group name.
9582 (setq gnus-newsgroup-name nil)
9583 (when (equal (gnus-group-group-name) group)
9584 (gnus-group-next-unread-group 1))
9586 (if (not (buffer-name (car quit-config)))
9587 (gnus-configure-windows 'group 'force)
9588 (set-buffer (car quit-config))
9589 (when (eq major-mode 'gnus-summary-mode)
9590 (gnus-set-global-variables))
9591 (gnus-configure-windows (cdr quit-config)))))))
9595 (defvar gnus-dead-summary-mode-map nil)
9597 (if gnus-dead-summary-mode-map
9599 (setq gnus-dead-summary-mode-map (make-keymap))
9600 (suppress-keymap gnus-dead-summary-mode-map)
9601 (substitute-key-definition
9602 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
9603 (let ((keys '("\C-d" "\r" "\177")))
9605 (define-key gnus-dead-summary-mode-map
9606 (pop keys) 'gnus-summary-wake-up-the-dead))))
9608 (defvar gnus-dead-summary-mode nil
9609 "Minor mode for Gnus summary buffers.")
9611 (defun gnus-dead-summary-mode (&optional arg)
9612 "Minor mode for Gnus summary buffers."
9614 (when (eq major-mode 'gnus-summary-mode)
9615 (make-local-variable 'gnus-dead-summary-mode)
9616 (setq gnus-dead-summary-mode
9617 (if (null arg) (not gnus-dead-summary-mode)
9618 (> (prefix-numeric-value arg) 0)))
9619 (when gnus-dead-summary-mode
9620 (unless (assq 'gnus-dead-summary-mode minor-mode-alist)
9621 (push '(gnus-dead-summary-mode " Dead") minor-mode-alist))
9622 (unless (assq 'gnus-dead-summary-mode minor-mode-map-alist)
9623 (push (cons 'gnus-dead-summary-mode gnus-dead-summary-mode-map)
9624 minor-mode-map-alist)))))
9626 (defun gnus-deaden-summary ()
9627 "Make the current summary buffer into a dead summary buffer."
9628 ;; Kill any previous dead summary buffer.
9629 (when (and gnus-dead-summary
9630 (buffer-name gnus-dead-summary))
9632 (set-buffer gnus-dead-summary)
9633 (when gnus-dead-summary-mode
9634 (kill-buffer (current-buffer)))))
9635 ;; Make this the current dead summary.
9636 (setq gnus-dead-summary (current-buffer))
9637 (gnus-dead-summary-mode 1)
9638 (let ((name (buffer-name)))
9639 (when (string-match "Summary" name)
9641 (concat (substring name 0 (match-beginning 0)) "Dead "
9642 (substring name (match-beginning 0))) t))))
9644 (defun gnus-kill-or-deaden-summary (buffer)
9645 "Kill or deaden the summary BUFFER."
9646 (cond (gnus-kill-summary-on-exit
9647 (when (and gnus-use-trees
9648 (and (get-buffer buffer)
9649 (buffer-name (get-buffer buffer))))
9651 (set-buffer (get-buffer buffer))
9652 (gnus-tree-close gnus-newsgroup-name)))
9653 (gnus-kill-buffer buffer))
9654 ((and (get-buffer buffer)
9655 (buffer-name (get-buffer buffer)))
9658 (gnus-deaden-summary)))))
9660 (defun gnus-summary-wake-up-the-dead (&rest args)
9661 "Wake up the dead summary buffer."
9663 (gnus-dead-summary-mode -1)
9664 (let ((name (buffer-name)))
9665 (when (string-match "Dead " name)
9667 (concat (substring name 0 (match-beginning 0))
9668 (substring name (match-end 0))) t)))
9669 (gnus-message 3 "This dead summary is now alive again"))
9671 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
9672 (defun gnus-summary-fetch-faq (&optional faq-dir)
9673 "Fetch the FAQ for the current group.
9674 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
9678 (if current-prefix-arg
9680 "Faq dir: " (and (listp gnus-group-faq-directory)
9681 gnus-group-faq-directory)))))
9682 (let (gnus-faq-buffer)
9683 (and (setq gnus-faq-buffer
9684 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
9685 (gnus-configure-windows 'summary-faq))))
9687 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
9688 (defun gnus-summary-describe-group (&optional force)
9689 "Describe the current newsgroup."
9691 (gnus-group-describe-group force gnus-newsgroup-name))
9693 (defun gnus-summary-describe-briefly ()
9694 "Describe summary mode commands briefly."
9697 (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")))
9699 ;; Walking around group mode buffer from summary mode.
9701 (defun gnus-summary-next-group (&optional no-article target-group backward)
9702 "Exit current newsgroup and then select next unread newsgroup.
9703 If prefix argument NO-ARTICLE is non-nil, no article is selected
9704 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
9705 previous group instead."
9707 (gnus-set-global-variables)
9708 (let ((current-group gnus-newsgroup-name)
9709 (current-buffer (current-buffer))
9711 ;; First we semi-exit this group to update Xrefs and all variables.
9712 ;; We can't do a real exit, because the window conf must remain
9713 ;; the same in case the user is prompted for info, and we don't
9714 ;; want the window conf to change before that...
9715 (gnus-summary-exit t)
9716 (while (not entered)
9717 ;; Then we find what group we are supposed to enter.
9718 (set-buffer gnus-group-buffer)
9719 (gnus-group-jump-to-group current-group)
9722 (if (eq gnus-keep-same-level 'best)
9723 (gnus-summary-best-group gnus-newsgroup-name)
9724 (gnus-summary-search-group backward gnus-keep-same-level))))
9725 (if (not target-group)
9726 ;; There are no further groups, so we return to the group
9729 (gnus-message 5 "Returning to the group buffer")
9731 (set-buffer current-buffer)
9732 (gnus-summary-exit))
9733 ;; We try to enter the target group.
9734 (gnus-group-jump-to-group target-group)
9735 (let ((unreads (gnus-group-group-unread)))
9736 (if (and (or (eq t unreads)
9737 (and unreads (not (zerop unreads))))
9738 (gnus-summary-read-group
9739 target-group nil no-article current-buffer))
9741 (setq current-group target-group
9742 target-group nil)))))))
9744 (defun gnus-summary-prev-group (&optional no-article)
9745 "Exit current newsgroup and then select previous unread newsgroup.
9746 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
9748 (gnus-summary-next-group no-article nil t))
9750 ;; Walking around summary lines.
9752 (defun gnus-summary-first-subject (&optional unread)
9753 "Go to the first unread subject.
9754 If UNREAD is non-nil, go to the first unread article.
9755 Returns the article selected or nil if there are no unread articles."
9760 ((null gnus-newsgroup-data)
9761 (gnus-message 3 "No articles in the group")
9763 ;; Pick the first article.
9765 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
9766 (gnus-data-number (car gnus-newsgroup-data)))
9767 ;; No unread articles.
9768 ((null gnus-newsgroup-unreads)
9769 (gnus-message 3 "No more unread articles")
9771 ;; Find the first unread article.
9773 (let ((data gnus-newsgroup-data))
9775 (not (gnus-data-unread-p (car data))))
9776 (setq data (cdr data)))
9779 (goto-char (gnus-data-pos (car data)))
9780 (gnus-data-number (car data)))))))
9781 (gnus-summary-position-point)))
9783 (defun gnus-summary-next-subject (n &optional unread dont-display)
9784 "Go to next N'th summary line.
9785 If N is negative, go to the previous N'th subject line.
9786 If UNREAD is non-nil, only unread articles are selected.
9787 The difference between N and the actual number of steps taken is
9790 (let ((backward (< n 0))
9794 (gnus-summary-find-prev unread)
9795 (gnus-summary-find-next unread)))
9797 (if (/= 0 n) (gnus-message 7 "No more%s articles"
9798 (if unread " unread" "")))
9801 (gnus-summary-recenter)
9802 (gnus-summary-position-point)))
9805 (defun gnus-summary-next-unread-subject (n)
9806 "Go to next N'th unread summary line."
9808 (gnus-summary-next-subject n t))
9810 (defun gnus-summary-prev-subject (n &optional unread)
9811 "Go to previous N'th summary line.
9812 If optional argument UNREAD is non-nil, only unread article is selected."
9814 (gnus-summary-next-subject (- n) unread))
9816 (defun gnus-summary-prev-unread-subject (n)
9817 "Go to previous N'th unread summary line."
9819 (gnus-summary-next-subject (- n) t))
9821 (defun gnus-summary-goto-subject (article &optional force silent)
9822 "Go the subject line of ARTICLE.
9823 If FORCE, also allow jumping to articles not currently shown."
9825 (data (gnus-data-find article)))
9826 ;; We read in the article if we have to.
9829 (gnus-summary-insert-subject article)
9830 (setq data (gnus-data-find article)))
9835 (gnus-message 3 "Can't find article %d" article))
9837 (goto-char (gnus-data-pos data))
9840 ;; Walking around summary lines with displaying articles.
9842 (defun gnus-summary-expand-window (&optional arg)
9843 "Make the summary buffer take up the entire Emacs frame.
9844 Given a prefix, will force an `article' buffer configuration."
9846 (gnus-set-global-variables)
9848 (gnus-configure-windows 'article 'force)
9849 (gnus-configure-windows 'summary 'force)))
9851 (defun gnus-summary-display-article (article &optional all-header)
9852 "Display ARTICLE in article buffer."
9853 (gnus-set-global-variables)
9857 (if gnus-summary-display-article-function
9858 (funcall gnus-summary-display-article-function article all-header)
9859 (gnus-article-prepare article all-header))
9860 (run-hooks 'gnus-select-article-hook)
9861 (gnus-summary-recenter)
9862 (gnus-summary-goto-subject article)
9863 (when gnus-use-trees
9864 (gnus-possibly-generate-tree article)
9865 (gnus-highlight-selected-tree article))
9866 ;; Successfully display article.
9867 (gnus-article-set-window-start
9868 (cdr (assq article gnus-newsgroup-bookmarks)))
9871 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
9872 "Select the current article.
9873 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
9874 non-nil, the article will be re-fetched even if it already present in
9875 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
9877 (let ((article (or article (gnus-summary-article-number)))
9878 (all-headers (not (not all-headers))) ;Must be T or NIL.
9879 gnus-summary-display-article-function
9882 (gnus-summary-article-pseudo-p article)
9883 (error "This is a pseudo-article."))
9886 (set-buffer gnus-summary-buffer)
9887 (if (or (and gnus-single-article-buffer
9888 (or (null gnus-current-article)
9889 (null gnus-article-current)
9890 (null (get-buffer gnus-article-buffer))
9891 (not (eq article (cdr gnus-article-current)))
9892 (not (equal (car gnus-article-current)
9893 gnus-newsgroup-name))))
9894 (and (not gnus-single-article-buffer)
9895 (null gnus-current-article))
9897 ;; The requested article is different from the current article.
9899 (gnus-summary-display-article article all-headers)
9901 (if (or all-headers gnus-show-all-headers)
9902 (gnus-article-show-all-headers))
9905 (gnus-article-set-window-start
9906 (cdr (assq article gnus-newsgroup-bookmarks)))))))
9908 (defun gnus-summary-set-current-mark (&optional current-mark)
9909 "Obsolete function."
9912 (defun gnus-summary-next-article (&optional unread subject backward push)
9913 "Select the next article.
9914 If UNREAD, only unread articles are selected.
9915 If SUBJECT, only articles with SUBJECT are selected.
9916 If BACKWARD, the previous article is selected instead of the next."
9918 (gnus-set-global-variables)
9921 ;; Is there such an article?
9922 ((and (gnus-summary-search-forward unread subject backward)
9923 (or (gnus-summary-display-article (gnus-summary-article-number))
9924 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
9925 (gnus-summary-position-point))
9926 ;; If not, we try the first unread, if that is wanted.
9928 gnus-auto-select-same
9929 (or (gnus-summary-first-unread-article)
9930 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
9931 (gnus-summary-position-point)
9932 (gnus-message 6 "Wrapped"))
9933 ;; Try to get next/previous article not displayed in this group.
9934 ((and gnus-auto-extend-newsgroup
9935 (not unread) (not subject))
9936 (gnus-summary-goto-article
9937 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
9939 ;; Go to next/previous group.
9941 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
9942 (gnus-summary-jump-to-group gnus-newsgroup-name))
9943 (let ((cmd last-command-char)
9945 (if (eq gnus-keep-same-level 'best)
9946 (gnus-summary-best-group gnus-newsgroup-name)
9947 (gnus-summary-search-group backward gnus-keep-same-level))))
9948 ;; For some reason, the group window gets selected. We change
9950 (select-window (get-buffer-window (current-buffer)))
9951 ;; Select next unread newsgroup automagically.
9953 ((not gnus-auto-select-next)
9954 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
9955 ((or (eq gnus-auto-select-next 'quietly)
9956 (and (eq gnus-auto-select-next 'slightly-quietly)
9958 (and (eq gnus-auto-select-next 'almost-quietly)
9959 (gnus-summary-last-article-p)))
9961 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
9963 (gnus-message 7 "No more%s articles (%s)..."
9964 (if unread " unread" "")
9965 (if group (concat "selecting " group)
9967 (gnus-summary-next-group nil group backward)))
9969 (gnus-summary-walk-group-buffer
9970 gnus-newsgroup-name cmd unread backward))))))))
9972 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward)
9973 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
9974 (?\C-p (gnus-group-prev-unread-group 1))))
9975 keve key group ended)
9977 (set-buffer gnus-group-buffer)
9978 (gnus-summary-jump-to-group from-group)
9980 (if (eq gnus-keep-same-level 'best)
9981 (gnus-summary-best-group gnus-newsgroup-name)
9982 (gnus-summary-search-group backward gnus-keep-same-level))))
9985 5 "No more%s articles%s" (if unread " unread" "")
9987 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
9988 (format " (Type %s for %s [%s])"
9989 (single-key-description cmd) group
9990 (car (gnus-gethash group gnus-newsrc-hashtb)))
9991 (format " (Type %s to exit %s)"
9992 (single-key-description cmd)
9993 gnus-newsgroup-name)))
9994 ;; Confirm auto selection.
9995 (setq key (car (setq keve (gnus-read-event-char))))
9998 ((assq key keystrokes)
9999 (let ((obuf (current-buffer)))
10000 (switch-to-buffer gnus-group-buffer)
10002 (gnus-group-jump-to-group group))
10003 (eval (car (cdr (assq key keystrokes))))
10004 (setq group (gnus-group-group-name))
10005 (switch-to-buffer obuf))
10008 (if (or (not group)
10009 (gnus-ephemeral-group-p gnus-newsgroup-name))
10010 (gnus-summary-exit)
10011 (gnus-summary-next-group nil group backward)))
10013 (push (cdr keve) unread-command-events))))))
10015 (defun gnus-read-event-char ()
10016 "Get the next event."
10017 (let ((event (read-event)))
10018 (cons (and (numberp event) event) event)))
10020 (defun gnus-summary-next-unread-article ()
10021 "Select unread article after current one."
10023 (gnus-summary-next-article t (and gnus-auto-select-same
10024 (gnus-summary-article-subject))))
10026 (defun gnus-summary-prev-article (&optional unread subject)
10027 "Select the article after the current one.
10028 If UNREAD is non-nil, only unread articles are selected."
10030 (gnus-summary-next-article unread subject t))
10032 (defun gnus-summary-prev-unread-article ()
10033 "Select unred article before current one."
10035 (gnus-summary-prev-article t (and gnus-auto-select-same
10036 (gnus-summary-article-subject))))
10038 (defun gnus-summary-next-page (&optional lines circular)
10039 "Show next page of the selected article.
10040 If at the end of the current article, select the next article.
10041 LINES says how many lines should be scrolled up.
10043 If CIRCULAR is non-nil, go to the start of the article instead of
10044 selecting the next article when reaching the end of the current
10047 (setq gnus-summary-buffer (current-buffer))
10048 (gnus-set-global-variables)
10049 (let ((article (gnus-summary-article-number))
10051 (gnus-configure-windows 'article)
10052 (if (or (null gnus-current-article)
10053 (null gnus-article-current)
10054 (/= article (cdr gnus-article-current))
10055 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10056 ;; Selected subject is different from current article's.
10057 (gnus-summary-display-article article)
10058 (gnus-eval-in-buffer-window
10059 gnus-article-buffer
10060 (setq endp (gnus-article-next-page lines)))
10063 (gnus-summary-beginning-of-article))
10065 (gnus-message 3 "End of message"))
10067 (if (and (eq gnus-summary-goto-unread 'never)
10068 (not (eq article gnus-newsgroup-end)))
10069 (gnus-summary-next-article)
10070 (gnus-summary-next-unread-article))))))
10071 (gnus-summary-recenter)
10072 (gnus-summary-position-point)))
10074 (defun gnus-summary-prev-page (&optional lines)
10075 "Show previous page of selected article.
10076 Argument LINES specifies lines to be scrolled down."
10078 (gnus-set-global-variables)
10079 (let ((article (gnus-summary-article-number)))
10080 (gnus-configure-windows 'article)
10081 (if (or (null gnus-current-article)
10082 (null gnus-article-current)
10083 (/= article (cdr gnus-article-current))
10084 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10085 ;; Selected subject is different from current article's.
10086 (gnus-summary-display-article article)
10087 (gnus-summary-recenter)
10088 (gnus-eval-in-buffer-window gnus-article-buffer
10089 (gnus-article-prev-page lines))))
10090 (gnus-summary-position-point))
10092 (defun gnus-summary-scroll-up (lines)
10093 "Scroll up (or down) one line current article.
10094 Argument LINES specifies lines to be scrolled up (or down if negative)."
10096 (gnus-set-global-variables)
10097 (gnus-configure-windows 'article)
10098 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
10099 (gnus-eval-in-buffer-window
10100 gnus-article-buffer
10102 (if (gnus-article-next-page lines)
10103 (gnus-message 3 "End of message")))
10105 (gnus-article-prev-page (- lines))))))
10106 (gnus-summary-recenter)
10107 (gnus-summary-position-point))
10109 (defun gnus-summary-next-same-subject ()
10110 "Select next article which has the same subject as current one."
10112 (gnus-set-global-variables)
10113 (gnus-summary-next-article nil (gnus-summary-article-subject)))
10115 (defun gnus-summary-prev-same-subject ()
10116 "Select previous article which has the same subject as current one."
10118 (gnus-set-global-variables)
10119 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
10121 (defun gnus-summary-next-unread-same-subject ()
10122 "Select next unread article which has the same subject as current one."
10124 (gnus-set-global-variables)
10125 (gnus-summary-next-article t (gnus-summary-article-subject)))
10127 (defun gnus-summary-prev-unread-same-subject ()
10128 "Select previous unread article which has the same subject as current one."
10130 (gnus-set-global-variables)
10131 (gnus-summary-prev-article t (gnus-summary-article-subject)))
10133 (defun gnus-summary-first-unread-article ()
10134 "Select the first unread article.
10135 Return nil if there are no unread articles."
10137 (gnus-set-global-variables)
10139 (if (gnus-summary-first-subject t)
10141 (gnus-summary-show-thread)
10142 (gnus-summary-first-subject t)
10143 (gnus-summary-display-article (gnus-summary-article-number))))
10144 (gnus-summary-position-point)))
10146 (defun gnus-summary-best-unread-article ()
10147 "Select the unread article with the highest score."
10149 (gnus-set-global-variables)
10150 (let ((best -1000000)
10151 (data gnus-newsgroup-data)
10154 (and (gnus-data-unread-p (car data))
10156 (gnus-summary-article-score (gnus-data-number (car data))))
10159 article (gnus-data-number (car data))))
10160 (setq data (cdr data)))
10162 (gnus-summary-goto-article article)
10163 (error "No unread articles"))
10164 (gnus-summary-position-point)))
10166 (defun gnus-summary-last-subject ()
10167 "Go to the last displayed subject line in the group."
10168 (let ((article (gnus-data-number (car (gnus-data-list t)))))
10170 (gnus-summary-goto-subject article))))
10172 (defun gnus-summary-goto-article (article &optional all-headers force)
10173 "Fetch ARTICLE and display it if it exists.
10174 If ALL-HEADERS is non-nil, no header lines are hidden."
10180 (mapcar (lambda (number) (list (int-to-string number)))
10181 gnus-newsgroup-limit)))
10185 (if (gnus-summary-goto-subject article force)
10186 (gnus-summary-display-article article all-headers)
10187 (gnus-message 4 "Couldn't go to article %s" article) nil)
10188 (gnus-summary-position-point)))
10190 (defun gnus-summary-goto-last-article ()
10191 "Go to the previously read article."
10194 (and gnus-last-article
10195 (gnus-summary-goto-article gnus-last-article))
10196 (gnus-summary-position-point)))
10198 (defun gnus-summary-pop-article (number)
10199 "Pop one article off the history and go to the previous.
10200 NUMBER articles will be popped off."
10203 (setq gnus-newsgroup-history
10204 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
10206 (gnus-summary-goto-article (car to))
10207 (error "Article history empty")))
10208 (gnus-summary-position-point))
10210 ;; Summary commands and functions for limiting the summary buffer.
10212 (defun gnus-summary-limit-to-articles (n)
10213 "Limit the summary buffer to the next N articles.
10214 If not given a prefix, use the process marked articles instead."
10216 (gnus-set-global-variables)
10218 (let ((articles (gnus-summary-work-articles n)))
10219 (setq gnus-newsgroup-processable nil)
10220 (gnus-summary-limit articles))
10221 (gnus-summary-position-point)))
10223 (defun gnus-summary-pop-limit (&optional total)
10224 "Restore the previous limit.
10225 If given a prefix, remove all limits."
10227 (gnus-set-global-variables)
10229 (setq gnus-newsgroup-limits
10230 (list (mapcar (lambda (h) (mail-header-number h))
10231 gnus-newsgroup-headers))))
10232 (unless gnus-newsgroup-limits
10233 (error "No limit to pop"))
10235 (gnus-summary-limit nil 'pop)
10236 (gnus-summary-position-point)))
10238 (defun gnus-summary-limit-to-subject (subject &optional header)
10239 "Limit the summary buffer to articles that have subjects that match a regexp."
10240 (interactive "sRegexp: ")
10242 (setq header "subject"))
10243 (when (not (equal "" subject))
10245 (let ((articles (gnus-summary-find-matching
10246 (or header "subject") subject 'all)))
10247 (or articles (error "Found no matches for \"%s\"" subject))
10248 (gnus-summary-limit articles))
10249 (gnus-summary-position-point))))
10251 (defun gnus-summary-limit-to-author (from)
10252 "Limit the summary buffer to articles that have authors that match a regexp."
10253 (interactive "sRegexp: ")
10254 (gnus-summary-limit-to-subject from "from"))
10256 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10258 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10260 (defun gnus-summary-limit-to-unread (&optional all)
10261 "Limit the summary buffer to articles that are not marked as read.
10262 If ALL is non-nil, limit strictly to unread articles."
10265 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
10266 (gnus-summary-limit-to-marks
10267 ;; Concat all the marks that say that an article is read and have
10269 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
10270 gnus-killed-mark gnus-kill-file-mark
10271 gnus-low-score-mark gnus-expirable-mark
10272 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark)
10275 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10276 (make-obsolete 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10278 (defun gnus-summary-limit-to-marks (marks &optional reverse)
10279 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
10280 If REVERSE, limit the summary buffer to articles that are not marked
10281 with MARKS. MARKS can either be a string of marks or a list of marks.
10282 Returns how many articles were removed."
10283 (interactive "sMarks: ")
10284 (gnus-set-global-variables)
10286 (let ((data gnus-newsgroup-data)
10287 (marks (if (listp marks) marks
10288 (append marks nil))) ; Transform to list.
10291 (and (if reverse (not (memq (gnus-data-mark (car data)) marks))
10292 (memq (gnus-data-mark (car data)) marks))
10293 (setq articles (cons (gnus-data-number (car data)) articles)))
10294 (setq data (cdr data)))
10295 (gnus-summary-limit articles))
10296 (gnus-summary-position-point)))
10298 (defun gnus-summary-limit-to-score (&optional score)
10299 "Limit to articles with score at or above SCORE."
10301 (gnus-set-global-variables)
10302 (setq score (if score
10303 (prefix-numeric-value score)
10304 (or gnus-summary-default-score 0)))
10305 (let ((data gnus-newsgroup-data)
10308 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
10310 (push (gnus-data-number (car data)) articles))
10311 (setq data (cdr data)))
10313 (gnus-summary-limit articles)
10314 (gnus-summary-position-point))))
10316 (defun gnus-summary-limit-include-dormant ()
10317 "Display all the hidden articles that are marked as dormant."
10319 (gnus-set-global-variables)
10320 (or gnus-newsgroup-dormant
10321 (error "There are no dormant articles in this group"))
10323 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
10324 (gnus-summary-position-point)))
10326 (defun gnus-summary-limit-exclude-dormant ()
10327 "Hide all dormant articles."
10329 (gnus-set-global-variables)
10331 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
10332 (gnus-summary-position-point)))
10334 (defun gnus-summary-limit-exclude-childless-dormant ()
10335 "Hide all dormant articles that have no children."
10337 (gnus-set-global-variables)
10338 (let ((data gnus-newsgroup-data)
10340 ;; Find all articles that are either not dormant or have
10343 (and (or (not (= (gnus-data-mark (car data)) gnus-dormant-mark))
10344 (gnus-article-parent-p (gnus-data-number (car data))))
10345 (setq articles (cons (gnus-data-number (car data))
10347 (setq data (cdr data)))
10348 ;; Do the limiting.
10350 (gnus-summary-limit articles)
10351 (gnus-summary-position-point))))
10353 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
10354 "Mark all unread excluded articles as read.
10355 If ALL, mark even excluded ticked and dormants as read."
10357 (let ((articles (gnus-sorted-complement
10359 (mapcar (lambda (h) (mail-header-number h))
10360 gnus-newsgroup-headers)
10362 (sort gnus-newsgroup-limit '<)))
10364 (setq gnus-newsgroup-unreads nil)
10366 (setq gnus-newsgroup-dormant nil
10367 gnus-newsgroup-marked nil
10368 gnus-newsgroup-reads
10370 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
10371 gnus-newsgroup-reads))
10372 (while (setq article (pop articles))
10373 (unless (or (memq article gnus-newsgroup-dormant)
10374 (memq article gnus-newsgroup-marked))
10375 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
10377 (defun gnus-summary-limit (articles &optional pop)
10379 ;; We pop the previous limit off the stack and use that.
10380 (setq articles (car gnus-newsgroup-limits)
10381 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
10382 ;; We use the new limit, so we push the old limit on the stack.
10383 (setq gnus-newsgroup-limits
10384 (cons gnus-newsgroup-limit gnus-newsgroup-limits)))
10386 (setq gnus-newsgroup-limit articles)
10387 (let ((total (length gnus-newsgroup-data))
10388 (data (gnus-data-find-list (gnus-summary-article-number)))
10390 ;; This will do all the work of generating the new summary buffer
10391 ;; according to the new limit.
10392 (gnus-summary-prepare)
10393 ;; Hide any threads, possibly.
10394 (and gnus-show-threads
10395 gnus-thread-hide-subtree
10396 (gnus-summary-hide-all-threads))
10397 ;; Try to return to the article you were at, or one in the
10400 ;; We try to find some article after the current one.
10402 (and (gnus-summary-goto-subject
10403 (gnus-data-number (car data)) nil t)
10406 (setq data (cdr data))))
10408 ;; If there is no data, that means that we were after the last
10409 ;; article. The same goes when we can't find any articles
10410 ;; after the current one.
10412 (goto-char (point-max))
10413 (gnus-summary-find-prev)))
10414 ;; We return how many articles were removed from the summary
10415 ;; buffer as a result of the new limit.
10416 (- total (length gnus-newsgroup-data))))
10418 (defsubst gnus-cut-thread (thread)
10419 "Go forwards in the thread until we find an article that we want to display."
10420 (if (eq gnus-fetch-old-headers 'some)
10422 (memq (mail-header-number (car thread))
10423 gnus-newsgroup-ancient)
10424 (<= (length (cdr thread)) 1))
10425 (setq thread (cadr thread)))
10427 (memq (mail-header-number (car thread)) gnus-newsgroup-sparse)
10428 (= (length (cdr thread)) 1))
10429 (setq thread (cadr thread))))
10432 (defun gnus-cut-threads (threads)
10433 "Cut off all uninteresting articles from the beginning of threads."
10434 (when (or (eq gnus-fetch-old-headers 'some)
10435 (eq gnus-build-sparse-threads 'some)
10436 (eq gnus-build-sparse-threads 'more))
10437 (let ((th threads))
10439 (setcar th (gnus-cut-thread (car th)))
10440 (setq th (cdr th)))))
10443 (defun gnus-summary-initial-limit (&optional show-if-empty)
10444 "Figure out what the initial limit is supposed to be on group entry.
10445 This entails weeding out unwanted dormants, low-scored articles,
10446 fetch-old-headers verbiage, and so on."
10447 ;; Most groups have nothing to remove.
10448 (if (or gnus-inhibit-limiting
10449 (and (null gnus-newsgroup-dormant)
10450 (not (eq gnus-fetch-old-headers 'some))
10451 (null gnus-summary-expunge-below)
10452 (not (eq gnus-build-sparse-threads 'some))
10453 (not (eq gnus-build-sparse-threads 'more))
10454 (null gnus-thread-expunge-below)
10455 (not gnus-use-nocem)))
10457 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10458 (setq gnus-newsgroup-limit nil)
10461 (unless (car (symbol-value node))
10462 ;; These threads have no parents -- they are roots.
10463 (let ((nodes (cdr (symbol-value node)))
10466 (if (and gnus-thread-expunge-below
10467 (< (gnus-thread-total-score (car nodes))
10468 gnus-thread-expunge-below))
10469 (gnus-expunge-thread (pop nodes))
10470 (setq thread (pop nodes))
10471 (gnus-summary-limit-children thread))))))
10472 gnus-newsgroup-dependencies)
10473 ;; If this limitation resulted in an empty group, we might
10474 ;; pop the previous limit and use it instead.
10475 (when (and (not gnus-newsgroup-limit)
10477 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
10478 gnus-newsgroup-limit))
10480 (defun gnus-summary-limit-children (thread)
10481 "Return 1 if this subthread is visible and 0 if it is not."
10482 ;; First we get the number of visible children to this thread. This
10483 ;; is done by recursing down the thread using this function, so this
10484 ;; will really go down to a leaf article first, before slowly
10485 ;; working its way up towards the root.
10489 (apply '+ (mapcar 'gnus-summary-limit-children
10492 (number (mail-header-number (car thread)))
10495 ;; If this article is dormant and has absolutely no visible
10496 ;; children, then this article isn't visible.
10497 (and (memq number gnus-newsgroup-dormant)
10499 ;; If this is a "fetch-old-headered" and there is only one
10500 ;; visible child (or less), then we don't want this article.
10501 (and (eq gnus-fetch-old-headers 'some)
10502 (memq number gnus-newsgroup-ancient)
10504 ;; If this is a sparsely inserted article with no children,
10505 ;; we don't want it.
10506 (and (eq gnus-build-sparse-threads 'some)
10507 (memq number gnus-newsgroup-sparse)
10509 ;; If we use expunging, and this article is really
10510 ;; low-scored, then we don't want this article.
10511 (when (and gnus-summary-expunge-below
10513 (or (cdr (assq number gnus-newsgroup-scored))
10514 gnus-summary-default-score))
10515 gnus-summary-expunge-below))
10516 ;; We increase the expunge-tally here, but that has
10517 ;; nothing to do with the limits, really.
10518 (incf gnus-newsgroup-expunged-tally)
10519 ;; We also mark as read here, if that's wanted.
10520 (when (and gnus-summary-mark-below
10521 (< score gnus-summary-mark-below))
10522 (setq gnus-newsgroup-unreads
10523 (delq number gnus-newsgroup-unreads))
10524 (if gnus-newsgroup-auto-expire
10525 (push number gnus-newsgroup-expirable)
10526 (push (cons number gnus-low-score-mark)
10527 gnus-newsgroup-reads)))
10529 (and gnus-use-nocem
10530 (gnus-nocem-unwanted-article-p (mail-header-id (car thread)))))
10531 ;; Nope, invisible article.
10533 ;; Ok, this article is to be visible, so we add it to the limit
10535 (setq gnus-newsgroup-limit (cons number gnus-newsgroup-limit))
10538 (defun gnus-expunge-thread (thread)
10539 "Mark all articles in THREAD as read."
10540 (let* ((number (mail-header-number (car thread))))
10541 (incf gnus-newsgroup-expunged-tally)
10542 ;; We also mark as read here, if that's wanted.
10543 (setq gnus-newsgroup-unreads
10544 (delq number gnus-newsgroup-unreads))
10545 (if gnus-newsgroup-auto-expire
10546 (push number gnus-newsgroup-expirable)
10547 (push (cons number gnus-low-score-mark)
10548 gnus-newsgroup-reads)))
10549 ;; Go recursively through all subthreads.
10550 (mapcar 'gnus-expunge-thread (cdr thread)))
10552 ;; Summary article oriented commands
10554 (defun gnus-summary-refer-parent-article (n)
10555 "Refer parent article N times.
10556 The difference between N and the number of articles fetched is returned."
10558 (gnus-set-global-variables)
10562 (let* ((header (gnus-summary-article-header))
10564 ;; If we try to find the parent of the currently
10565 ;; displayed article, then we take a look at the actual
10566 ;; References header, since this is slightly more
10567 ;; reliable than the References field we got from the
10569 (if (and (eq (mail-header-number header)
10570 (cdr gnus-article-current))
10571 (equal gnus-newsgroup-name
10572 (car gnus-article-current)))
10574 (set-buffer gnus-original-article-buffer)
10575 (nnheader-narrow-to-headers)
10577 (mail-fetch-field "references")
10579 ;; It's not the current article, so we take a bet on
10580 ;; the value we got from the server.
10581 (mail-header-references header))))
10582 (if (setq ref (or ref (mail-header-references header)))
10583 (or (gnus-summary-refer-article (gnus-parent-id ref))
10584 (gnus-message 1 "Couldn't find parent"))
10585 (gnus-message 1 "No references in article %d"
10586 (gnus-summary-article-number))
10589 (gnus-summary-position-point)
10592 (defun gnus-summary-refer-references ()
10593 "Fetch all articles mentioned in the References header.
10594 Return how many articles were fetched."
10596 (gnus-set-global-variables)
10597 (let ((ref (mail-header-references (gnus-summary-article-header)))
10598 (current (gnus-summary-article-number))
10600 ;; For each Message-ID in the References header...
10601 (while (string-match "<[^>]*>" ref)
10603 ;; ... fetch that article.
10604 (gnus-summary-refer-article
10605 (prog1 (match-string 0 ref)
10606 (setq ref (substring ref (match-end 0))))))
10607 (gnus-summary-goto-subject current)
10608 (gnus-summary-position-point)
10611 (defun gnus-summary-refer-article (message-id)
10612 "Fetch an article specified by MESSAGE-ID."
10613 (interactive "sMessage-ID: ")
10614 (when (and (stringp message-id)
10615 (not (zerop (length message-id))))
10616 ;; Construct the correct Message-ID if necessary.
10617 ;; Suggested by tale@pawl.rpi.edu.
10618 (unless (string-match "^<" message-id)
10619 (setq message-id (concat "<" message-id)))
10620 (unless (string-match ">$" message-id)
10621 (setq message-id (concat message-id ">")))
10622 (let ((header (car (gnus-gethash (downcase message-id)
10623 gnus-newsgroup-dependencies))))
10625 ;; The article is present in the buffer, to we just go to it.
10626 (gnus-summary-goto-article (mail-header-number header) nil t)
10627 ;; We fetch the article
10628 (let ((gnus-override-method gnus-refer-article-method)
10630 ;; Start the special refer-article method, if necessary.
10631 (when gnus-refer-article-method
10632 (gnus-check-server gnus-refer-article-method))
10633 ;; Fetch the header, and display the article.
10634 (if (setq number (gnus-summary-insert-subject message-id))
10635 (gnus-summary-select-article nil nil nil number)
10636 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
10638 (defun gnus-summary-enter-digest-group (&optional force)
10639 "Enter a digest group based on the current article."
10641 (gnus-set-global-variables)
10642 (gnus-summary-select-article)
10643 (let ((name (format "%s-%d"
10644 (gnus-group-prefixed-name
10645 gnus-newsgroup-name (list 'nndoc ""))
10646 gnus-current-article))
10647 (ogroup gnus-newsgroup-name)
10648 (case-fold-search t)
10649 (buf (current-buffer))
10652 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
10653 (insert-buffer-substring gnus-original-article-buffer)
10655 (goto-char (point-min))
10656 (or (search-forward "\n\n" nil t) (point)))
10657 (goto-char (point-min))
10658 (delete-matching-lines "^\\(Path\\):\\|^From ")
10661 (if (gnus-group-read-ephemeral-group
10662 name `(nndoc ,name (nndoc-address
10664 (nndoc-article-type ,(if force 'digest 'guess))) t)
10665 ;; Make all postings to this group go to the parent group.
10666 (setcdr (nthcdr 4 (gnus-get-info name))
10667 (list (list (cons 'to-group ogroup))))
10668 ;; Couldn't select this doc group.
10669 (switch-to-buffer buf)
10670 (gnus-set-global-variables)
10671 (gnus-configure-windows 'summary)
10672 (gnus-message 3 "Article couldn't be entered?"))
10673 (kill-buffer dig))))
10675 (defun gnus-summary-isearch-article (&optional regexp-p)
10676 "Do incremental search forward on the current article.
10677 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
10679 (gnus-set-global-variables)
10680 (gnus-summary-select-article)
10681 (gnus-configure-windows 'article)
10682 (gnus-eval-in-buffer-window
10683 gnus-article-buffer
10684 (goto-char (point-min))
10685 (isearch-forward regexp-p)))
10687 (defun gnus-summary-search-article-forward (regexp &optional backward)
10688 "Search for an article containing REGEXP forward.
10689 If BACKWARD, search backward instead."
10692 (format "Search article %s (regexp%s): "
10693 (if current-prefix-arg "backward" "forward")
10694 (if gnus-last-search-regexp
10695 (concat ", default " gnus-last-search-regexp)
10697 current-prefix-arg))
10698 (gnus-set-global-variables)
10699 (if (string-equal regexp "")
10700 (setq regexp (or gnus-last-search-regexp ""))
10701 (setq gnus-last-search-regexp regexp))
10702 (if (gnus-summary-search-article regexp backward)
10703 (gnus-article-set-window-start
10704 (cdr (assq (gnus-summary-article-number) gnus-newsgroup-bookmarks)))
10705 (error "Search failed: \"%s\"" regexp)))
10707 (defun gnus-summary-search-article-backward (regexp)
10708 "Search for an article containing REGEXP backward."
10711 (format "Search article backward (regexp%s): "
10712 (if gnus-last-search-regexp
10713 (concat ", default " gnus-last-search-regexp)
10715 (gnus-summary-search-article-forward regexp 'backward))
10717 (defun gnus-summary-search-article (regexp &optional backward)
10718 "Search for an article containing REGEXP.
10719 Optional argument BACKWARD means do search for backward.
10720 gnus-select-article-hook is not called during the search."
10721 (let ((gnus-select-article-hook nil) ;Disable hook.
10722 (gnus-mark-article-hook nil) ;Inhibit marking as read.
10725 (function re-search-backward) (function re-search-forward)))
10728 ;; Hidden thread subtrees must be searched for ,too.
10729 (gnus-summary-show-all-threads)
10730 ;; First of all, search current article.
10731 ;; We don't want to read article again from NNTP server nor reset
10733 (gnus-summary-select-article)
10734 (gnus-message 9 "Searching article: %d..." gnus-current-article)
10735 (setq last gnus-current-article)
10736 (gnus-eval-in-buffer-window
10737 gnus-article-buffer
10740 ;; Begin search from current point.
10741 (setq found (funcall re-search regexp nil t))))
10742 ;; Then search next articles.
10743 (while (and (not found)
10744 (gnus-summary-display-article
10745 (if backward (gnus-summary-find-prev)
10746 (gnus-summary-find-next))))
10747 (gnus-message 9 "Searching article: %d..." gnus-current-article)
10748 (gnus-eval-in-buffer-window
10749 gnus-article-buffer
10752 (goto-char (if backward (point-max) (point-min)))
10753 (setq found (funcall re-search regexp nil t)))))
10755 ;; Adjust article pointer.
10756 (or (eq last gnus-current-article)
10757 (setq gnus-last-article last))
10758 ;; Return T if found such article.
10761 (defun gnus-summary-find-matching (header regexp &optional backward unread
10763 "Return a list of all articles that match REGEXP on HEADER.
10764 The search stars on the current article and goes forwards unless
10765 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
10766 If UNREAD is non-nil, only unread articles will
10767 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
10768 in the comparisons."
10769 (let ((data (if (eq backward 'all) gnus-newsgroup-data
10770 (gnus-data-find-list
10771 (gnus-summary-article-number) (gnus-data-list backward))))
10772 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
10773 (case-fold-search (not not-case-fold))
10775 (or (fboundp (intern (concat "mail-header-" header)))
10776 (error "%s is not a valid header" header))
10778 (setq d (car data))
10779 (and (or (not unread) ; We want all articles...
10780 (gnus-data-unread-p d)) ; Or just unreads.
10781 (vectorp (gnus-data-header d)) ; It's not a pseudo.
10782 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
10783 (setq articles (cons (gnus-data-number d) articles))) ; Success!
10784 (setq data (cdr data)))
10785 (nreverse articles)))
10787 (defun gnus-summary-execute-command (header regexp command &optional backward)
10788 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
10789 If HEADER is an empty string (or nil), the match is done on the entire
10790 article. If BACKWARD (the prefix) is non-nil, search backward instead."
10792 (list (let ((completion-ignore-case t))
10795 (mapcar (lambda (string) (list string))
10796 '("Number" "Subject" "From" "Lines" "Date"
10797 "Message-ID" "Xref" "References" "Body"))
10798 nil 'require-match))
10799 (read-string "Regexp: ")
10800 (read-key-sequence "Command: ")
10801 current-prefix-arg))
10802 (when (equal header "Body")
10804 (gnus-set-global-variables)
10805 ;; Hidden thread subtrees must be searched as well.
10806 (gnus-summary-show-all-threads)
10807 ;; We don't want to change current point nor window configuration.
10809 (save-window-excursion
10810 (gnus-message 6 "Executing %s..." (key-description command))
10811 ;; We'd like to execute COMMAND interactively so as to give arguments.
10812 (gnus-execute header regexp
10813 `(lambda () (call-interactively ',(key-binding command)))
10815 (gnus-message 6 "Executing %s...done" (key-description command)))))
10817 (defun gnus-summary-beginning-of-article ()
10818 "Scroll the article back to the beginning."
10820 (gnus-set-global-variables)
10821 (gnus-summary-select-article)
10822 (gnus-configure-windows 'article)
10823 (gnus-eval-in-buffer-window
10824 gnus-article-buffer
10826 (goto-char (point-min))
10827 (and gnus-break-pages (gnus-narrow-to-page))))
10829 (defun gnus-summary-end-of-article ()
10830 "Scroll to the end of the article."
10832 (gnus-set-global-variables)
10833 (gnus-summary-select-article)
10834 (gnus-configure-windows 'article)
10835 (gnus-eval-in-buffer-window
10836 gnus-article-buffer
10838 (goto-char (point-max))
10840 (and gnus-break-pages (gnus-narrow-to-page))))
10842 (defun gnus-summary-show-article (&optional arg)
10843 "Force re-fetching of the current article.
10844 If ARG (the prefix) is non-nil, show the raw article without any
10845 article massaging functions being run."
10847 (gnus-set-global-variables)
10849 ;; Select the article the normal way.
10850 (gnus-summary-select-article nil 'force)
10851 ;; Bind the article treatment functions to nil.
10852 (let ((gnus-have-all-headers t)
10853 gnus-article-display-hook
10854 gnus-article-prepare-hook
10856 (gnus-summary-select-article nil 'force)))
10857 ; (gnus-configure-windows 'article)
10858 (gnus-summary-position-point))
10860 (defun gnus-summary-verbose-headers (&optional arg)
10861 "Toggle permanent full header display.
10862 If ARG is a positive number, turn header display on.
10863 If ARG is a negative number, turn header display off."
10865 (gnus-set-global-variables)
10866 (gnus-summary-toggle-header arg)
10867 (setq gnus-show-all-headers
10868 (cond ((or (not (numberp arg))
10870 (not gnus-show-all-headers))
10874 (defun gnus-summary-toggle-header (&optional arg)
10875 "Show the headers if they are hidden, or hide them if they are shown.
10876 If ARG is a positive number, show the entire header.
10877 If ARG is a negative number, hide the unwanted header lines."
10879 (gnus-set-global-variables)
10881 (set-buffer gnus-article-buffer)
10882 (let* ((buffer-read-only nil)
10883 (inhibit-point-motion-hooks t)
10884 (hidden (text-property-any
10885 (goto-char (point-min)) (search-forward "\n\n")
10888 (goto-char (point-min))
10889 (when (search-forward "\n\n" nil t)
10890 (delete-region (point-min) (1- (point))))
10891 (goto-char (point-min))
10893 (set-buffer gnus-original-article-buffer)
10894 (goto-char (point-min))
10895 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
10896 (insert-buffer-substring gnus-original-article-buffer 1 e)
10897 (let ((gnus-inhibit-hiding t))
10898 (run-hooks 'gnus-article-display-hook))
10899 (if (or (not hidden) (and (numberp arg) (< arg 0)))
10900 (gnus-article-hide-headers)))))
10902 (defun gnus-summary-show-all-headers ()
10903 "Make all header lines visible."
10905 (gnus-set-global-variables)
10906 (gnus-article-show-all-headers))
10908 (defun gnus-summary-toggle-mime (&optional arg)
10909 "Toggle MIME processing.
10910 If ARG is a positive number, turn MIME processing on."
10912 (gnus-set-global-variables)
10913 (setq gnus-show-mime
10914 (if (null arg) (not gnus-show-mime)
10915 (> (prefix-numeric-value arg) 0)))
10916 (gnus-summary-select-article t 'force))
10918 (defun gnus-summary-caesar-message (&optional arg)
10919 "Caesar rotate the current article by 13.
10920 The numerical prefix specifies how manu places to rotate each letter
10923 (gnus-set-global-variables)
10924 (gnus-summary-select-article)
10925 (let ((mail-header-separator ""))
10926 (gnus-eval-in-buffer-window
10927 gnus-article-buffer
10930 (let ((start (window-start)))
10931 (news-caesar-buffer-body arg)
10932 (set-window-start (get-buffer-window (current-buffer)) start))))))
10934 (defun gnus-summary-stop-page-breaking ()
10935 "Stop page breaking in the current article."
10937 (gnus-set-global-variables)
10938 (gnus-summary-select-article)
10939 (gnus-eval-in-buffer-window gnus-article-buffer (widen)))
10941 (defun gnus-summary-move-article (&optional n to-newsgroup select-method action)
10942 "Move the current article to a different newsgroup.
10943 If N is a positive number, move the N next articles.
10944 If N is a negative number, move the N previous articles.
10945 If N is nil and any articles have been marked with the process mark,
10946 move those articles instead.
10947 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
10948 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
10949 re-spool using this method.
10951 For this function to work, both the current newsgroup and the
10952 newsgroup that you want to move to have to support the `request-move'
10953 and `request-accept' functions."
10955 (unless action (setq action 'move))
10956 (gnus-set-global-variables)
10957 ;; Check whether the source group supports the required functions.
10958 (cond ((and (eq action 'move)
10959 (not (gnus-check-backend-function
10960 'request-move-article gnus-newsgroup-name)))
10961 (error "The current group does not support article moving"))
10962 ((and (eq action 'crosspost)
10963 (not (gnus-check-backend-function
10964 'request-replace-article gnus-newsgroup-name)))
10965 (error "The current group does not support article editing")))
10966 (let ((articles (gnus-summary-work-articles n))
10967 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
10968 (names '((move "move" "Moving")
10969 (copy "copy" "Copying")
10970 (crosspost "crosspost" "Crossposting")))
10971 (copy-buf (save-excursion
10972 (nnheader-set-temp-buffer " *copy article*")))
10973 art-group to-method new-xref article)
10974 (unless (assq action names)
10975 (error "Unknown action %s" action))
10976 ;; Read the newsgroup name.
10977 (when (and (not to-newsgroup)
10978 (not select-method))
10980 (gnus-read-move-group-name
10981 (cadr (assq action names))
10982 gnus-current-move-group articles prefix))
10983 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
10984 (setq to-method (if select-method (list select-method "")
10985 (gnus-find-method-for-group to-newsgroup)))
10986 ;;(when (equal to-newsgroup gnus-newsgroup-name)
10987 ;;(error "Can't %s to the same group you're already in" action))
10988 ;; Check the method we are to move this article to...
10989 (or (gnus-check-backend-function 'request-accept-article (car to-method))
10990 (error "%s does not support article copying" (car to-method)))
10991 (or (gnus-check-server to-method)
10992 (error "Can't open server %s" (car to-method)))
10993 (gnus-message 6 "%s to %s: %s..."
10994 (caddr (assq action names))
10995 (or select-method to-newsgroup) articles)
10997 (setq article (pop articles))
11001 ;; Move the article.
11003 (gnus-request-move-article
11004 article ; Article to move
11005 gnus-newsgroup-name ; From newsgrouo
11006 (nth 1 (gnus-find-method-for-group
11007 gnus-newsgroup-name)) ; Server
11008 (list 'gnus-request-accept-article
11010 (list 'quote select-method)
11012 (not articles)) ; Accept form
11013 (not articles))) ; Only save nov last time
11014 ;; Copy the article.
11017 (set-buffer copy-buf)
11018 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11019 (gnus-request-accept-article
11020 (if select-method select-method to-newsgroup)
11022 ;; Crosspost the article.
11023 ((eq action 'crosspost)
11024 (let ((xref (mail-header-xref (gnus-summary-article-header article))))
11025 (setq new-xref (concat gnus-newsgroup-name ":" article))
11026 (if (and xref (not (string= xref "")))
11028 (when (string-match "^Xref: " xref)
11029 (setq xref (substring xref (match-end 0))))
11030 (setq new-xref (concat xref " " new-xref)))
11031 (setq new-xref (concat (system-name) " " new-xref)))
11033 (set-buffer copy-buf)
11034 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11035 (nnheader-replace-header "xref" new-xref)
11036 (gnus-request-accept-article
11037 (if select-method select-method to-newsgroup)
11038 (not articles)))))))
11039 (if (not art-group)
11040 (gnus-message 1 "Couldn't %s article %s"
11041 (cadr (assq action names)) article)
11044 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
11046 (gnus-group-prefixed-name
11048 (if select-method (list select-method "")
11049 (gnus-find-method-for-group to-newsgroup)))
11050 gnus-newsrc-hashtb)))
11051 (info (nth 2 entry)))
11052 ;; Update the group that has been moved to.
11054 (memq action '(move copy)))
11055 (unless (memq article gnus-newsgroup-unreads)
11056 (gnus-info-set-read
11057 info (gnus-add-to-range (gnus-info-read info)
11058 (list (cdr art-group)))))
11060 ;; Copy any marks over to the new group.
11061 (let ((marks gnus-article-mark-lists)
11062 (to-article (cdr art-group)))
11064 ;; See whether the article is to be put in the cache.
11065 (when gnus-use-cache
11066 (gnus-cache-possibly-enter-article
11067 (gnus-info-group info) to-article
11068 (let ((header (copy-sequence
11069 (gnus-summary-article-header article))))
11070 (mail-header-set-number header to-article)
11072 (memq article gnus-newsgroup-marked)
11073 (memq article gnus-newsgroup-dormant)
11074 (memq article gnus-newsgroup-unreads)))
11077 (when (memq article (symbol-value
11078 (intern (format "gnus-newsgroup-%s"
11080 (gnus-add-marked-articles
11081 (gnus-info-group info) (cdar marks)
11082 (list to-article) info))
11083 (setq marks (cdr marks)))))
11085 ;; Update the Xref header in this article to point to
11086 ;; the new crossposted article we have just created.
11087 (when (eq action 'crosspost)
11089 (set-buffer copy-buf)
11090 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11091 (nnheader-replace-header
11092 "xref" (concat new-xref " " (gnus-group-prefixed-name
11093 (car art-group) to-method)
11094 ":" (cdr art-group)))
11095 (gnus-request-replace-article
11096 article gnus-newsgroup-name (current-buffer)))))
11098 (gnus-summary-goto-subject article)
11099 (when (eq action 'move)
11100 (gnus-summary-mark-article article gnus-canceled-mark)))
11101 (gnus-summary-remove-process-mark article))
11102 (gnus-kill-buffer copy-buf)
11103 (gnus-summary-position-point)
11104 (gnus-set-mode-line 'summary)))
11106 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
11107 "Move the current article to a different newsgroup.
11108 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11109 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
11110 re-spool using this method."
11112 (gnus-summary-move-article n nil nil 'copy))
11114 (defun gnus-summary-crosspost-article (&optional n)
11115 "Crosspost the current article to some other group."
11117 (gnus-summary-move-article n nil nil 'crosspost))
11119 (defun gnus-summary-respool-article (&optional n respool-method)
11120 "Respool the current article.
11121 The article will be squeezed through the mail spooling process again,
11122 which means that it will be put in some mail newsgroup or other
11123 depending on `nnmail-split-methods'.
11124 If N is a positive number, respool the N next articles.
11125 If N is a negative number, respool the N previous articles.
11126 If N is nil and any articles have been marked with the process mark,
11127 respool those articles instead.
11129 Respooling can be done both from mail groups and \"real\" newsgroups.
11130 In the former case, the articles in question will be moved from the
11131 current group into whatever groups they are destined to. In the
11132 latter case, they will be copied into the relevant groups."
11134 (gnus-set-global-variables)
11135 (let ((respool-methods (gnus-methods-using 'respool))
11137 (symbol-name (car (gnus-find-method-for-group gnus-newsgroup-name)))))
11139 (setq respool-method
11141 "What method do you want to use when respooling? "
11142 respool-methods nil t methname)))
11143 (or (string= respool-method "")
11144 (if (assoc (symbol-name
11145 (car (gnus-find-method-for-group gnus-newsgroup-name)))
11147 (gnus-summary-move-article n nil (intern respool-method))
11148 (gnus-summary-copy-article n nil (intern respool-method))))))
11150 (defun gnus-summary-import-article (file)
11151 "Import a random file into a mail newsgroup."
11152 (interactive "fImport file: ")
11153 (gnus-set-global-variables)
11154 (let ((group gnus-newsgroup-name)
11155 (now (current-time))
11157 (or (gnus-check-backend-function 'request-accept-article group)
11158 (error "%s does not support article importing" group))
11159 (or (file-readable-p file)
11160 (not (file-regular-p file))
11161 (error "Can't read %s" file))
11163 (set-buffer (get-buffer-create " *import file*"))
11164 (buffer-disable-undo (current-buffer))
11166 (insert-file-contents file)
11167 (goto-char (point-min))
11168 (unless (nnheader-article-p)
11169 ;; This doesn't look like an article, so we fudge some headers.
11170 (setq atts (file-attributes file)
11171 lines (count-lines (point-min) (point-max)))
11172 (insert "From: " (read-string "From: ") "\n"
11173 "Subject: " (read-string "Subject: ") "\n"
11174 "Date: " (timezone-make-date-arpa-standard
11175 (current-time-string (nth 5 atts))
11176 (current-time-zone now)
11177 (current-time-zone now)) "\n"
11178 "Message-ID: " (gnus-inews-message-id) "\n"
11179 "Lines: " (int-to-string lines) "\n"
11180 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
11181 (gnus-request-accept-article group t)
11182 (kill-buffer (current-buffer)))))
11184 (defun gnus-summary-expire-articles ()
11185 "Expire all articles that are marked as expirable in the current group."
11187 (gnus-set-global-variables)
11188 (when (gnus-check-backend-function
11189 'request-expire-articles gnus-newsgroup-name)
11190 ;; This backend supports expiry.
11191 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
11192 (expirable (if total
11193 (gnus-list-of-read-articles gnus-newsgroup-name)
11194 (setq gnus-newsgroup-expirable
11195 (sort gnus-newsgroup-expirable '<))))
11196 (expiry-wait (gnus-group-get-parameter
11197 gnus-newsgroup-name 'expiry-wait))
11200 ;; There are expirable articles in this group, so we run them
11201 ;; through the expiry process.
11202 (gnus-message 6 "Expiring articles...")
11203 ;; The list of articles that weren't expired is returned.
11205 (let ((nnmail-expiry-wait-function nil)
11206 (nnmail-expiry-wait expiry-wait))
11207 (setq es (gnus-request-expire-articles
11208 expirable gnus-newsgroup-name)))
11209 (setq es (gnus-request-expire-articles
11210 expirable gnus-newsgroup-name)))
11211 (or total (setq gnus-newsgroup-expirable es))
11212 ;; We go through the old list of expirable, and mark all
11213 ;; really expired articles as nonexistent.
11214 (unless (eq es expirable) ;If nothing was expired, we don't mark.
11215 (let ((gnus-use-cache nil))
11217 (unless (memq (car expirable) es)
11218 (when (gnus-data-find (car expirable))
11219 (gnus-summary-mark-article
11220 (car expirable) gnus-canceled-mark)))
11221 (setq expirable (cdr expirable)))))
11222 (gnus-message 6 "Expiring articles...done")))))
11224 (defun gnus-summary-expire-articles-now ()
11225 "Expunge all expirable articles in the current group.
11226 This means that *all* articles that are marked as expirable will be
11227 deleted forever, right now."
11229 (gnus-set-global-variables)
11230 (or gnus-expert-user
11232 "Are you really, really, really sure you want to expunge? ")
11234 (let ((nnmail-expiry-wait 'immediate)
11235 (nnmail-expiry-wait-function nil))
11236 (gnus-summary-expire-articles)))
11238 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
11239 (defun gnus-summary-delete-article (&optional n)
11240 "Delete the N next (mail) articles.
11241 This command actually deletes articles. This is not a marking
11242 command. The article will disappear forever from your life, never to
11244 If N is negative, delete backwards.
11245 If N is nil and articles have been marked with the process mark,
11246 delete these instead."
11248 (gnus-set-global-variables)
11249 (or (gnus-check-backend-function 'request-expire-articles
11250 gnus-newsgroup-name)
11251 (error "The current newsgroup does not support article deletion."))
11252 ;; Compute the list of articles to delete.
11253 (let ((articles (gnus-summary-work-articles n))
11255 (if (and gnus-novice-user
11256 (not (gnus-y-or-n-p
11257 (format "Do you really want to delete %s forever? "
11258 (if (> (length articles) 1) "these articles"
11259 "this article")))))
11261 ;; Delete the articles.
11262 (setq not-deleted (gnus-request-expire-articles
11263 articles gnus-newsgroup-name 'force))
11265 (gnus-summary-remove-process-mark (car articles))
11266 ;; The backend might not have been able to delete the article
11268 (or (memq (car articles) not-deleted)
11269 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
11270 (setq articles (cdr articles))))
11271 (gnus-summary-position-point)
11272 (gnus-set-mode-line 'summary)
11275 (defun gnus-summary-edit-article (&optional force)
11276 "Enter into a buffer and edit the current article.
11277 This will have permanent effect only in mail groups.
11278 If FORCE is non-nil, allow editing of articles even in read-only
11282 (set-buffer gnus-summary-buffer)
11283 (gnus-set-global-variables)
11284 (when (and (not force)
11285 (gnus-group-read-only-p))
11286 (error "The current newsgroup does not support article editing."))
11287 (gnus-summary-select-article t nil t)
11288 (gnus-configure-windows 'article)
11289 (select-window (get-buffer-window gnus-article-buffer))
11290 (gnus-message 6 "C-c C-c to end edits")
11291 (setq buffer-read-only nil)
11293 (use-local-map (copy-keymap (current-local-map)))
11294 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
11295 (buffer-enable-undo)
11297 (goto-char (point-min))
11298 (search-forward "\n\n" nil t)))
11300 (defun gnus-summary-edit-article-done ()
11301 "Make edits to the current article permanent."
11303 (if (gnus-group-read-only-p)
11305 (gnus-summary-edit-article-postpone)
11307 1 "The current newsgroup does not support article editing.")
11309 (let ((buf (buffer-substring-no-properties (point-min) (point-max))))
11312 (if (not (gnus-request-replace-article
11313 (cdr gnus-article-current) (car gnus-article-current)
11315 (error "Couldn't replace article.")
11316 (gnus-article-mode)
11317 (use-local-map gnus-article-mode-map)
11318 (setq buffer-read-only t)
11319 (buffer-disable-undo (current-buffer))
11320 (gnus-configure-windows 'summary)
11321 (gnus-summary-update-article (cdr gnus-article-current)))
11322 (run-hooks 'gnus-article-display-hook)
11323 (and (gnus-visual-p 'summary-highlight 'highlight)
11324 (run-hooks 'gnus-visual-mark-article-hook)))))
11326 (defun gnus-summary-edit-article-postpone ()
11327 "Postpone changes to the current article."
11329 (gnus-article-mode)
11330 (use-local-map gnus-article-mode-map)
11331 (setq buffer-read-only t)
11332 (buffer-disable-undo (current-buffer))
11333 (gnus-configure-windows 'summary)
11334 (and (gnus-visual-p 'summary-highlight 'highlight)
11335 (run-hooks 'gnus-visual-mark-article-hook)))
11337 (defun gnus-summary-respool-query ()
11338 "Query where the respool algorithm would put this article."
11340 (gnus-set-global-variables)
11341 (gnus-summary-select-article)
11343 (set-buffer gnus-article-buffer)
11345 (goto-char (point-min))
11346 (search-forward "\n\n")
11347 (narrow-to-region (point-min) (point))
11348 (pp-eval-expression
11349 (list 'quote (mapcar 'car (nnmail-article-group 'identity)))))))
11351 ;; Summary score commands.
11353 ;; Suggested by boubaker@cenatls.cena.dgac.fr.
11355 (defun gnus-summary-raise-score (n)
11356 "Raise the score of the current article by N."
11358 (gnus-set-global-variables)
11359 (gnus-summary-set-score (+ (gnus-summary-article-score) n)))
11361 (defun gnus-summary-set-score (n)
11362 "Set the score of the current article to N."
11364 (gnus-set-global-variables)
11366 (gnus-summary-show-thread)
11367 (let ((buffer-read-only nil))
11369 (gnus-summary-update-mark
11370 (if (= n (or gnus-summary-default-score 0)) ?
11371 (if (< n (or gnus-summary-default-score 0))
11372 gnus-score-below-mark gnus-score-over-mark)) 'score))
11373 (let* ((article (gnus-summary-article-number))
11374 (score (assq article gnus-newsgroup-scored)))
11375 (if score (setcdr score n)
11376 (setq gnus-newsgroup-scored
11377 (cons (cons article n) gnus-newsgroup-scored))))
11378 (gnus-summary-update-line)))
11380 (defun gnus-summary-current-score ()
11381 "Return the score of the current article."
11383 (gnus-set-global-variables)
11384 (message "%s" (gnus-summary-article-score)))
11386 ;; Summary marking commands.
11388 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
11389 "Mark articles which has the same subject as read, and then select the next.
11390 If UNMARK is positive, remove any kind of mark.
11391 If UNMARK is negative, tick articles."
11393 (gnus-set-global-variables)
11395 (setq unmark (prefix-numeric-value unmark)))
11397 (gnus-summary-mark-same-subject
11398 (gnus-summary-article-subject) unmark)))
11399 ;; Select next unread article. If auto-select-same mode, should
11400 ;; select the first unread article.
11401 (gnus-summary-next-article t (and gnus-auto-select-same
11402 (gnus-summary-article-subject)))
11403 (gnus-message 7 "%d article%s marked as %s"
11404 count (if (= count 1) " is" "s are")
11405 (if unmark "unread" "read"))))
11407 (defun gnus-summary-kill-same-subject (&optional unmark)
11408 "Mark articles which has the same subject as read.
11409 If UNMARK is positive, remove any kind of mark.
11410 If UNMARK is negative, tick articles."
11412 (gnus-set-global-variables)
11414 (setq unmark (prefix-numeric-value unmark)))
11416 (gnus-summary-mark-same-subject
11417 (gnus-summary-article-subject) unmark)))
11418 ;; If marked as read, go to next unread subject.
11420 ;; Go to next unread subject.
11421 (gnus-summary-next-subject 1 t))
11422 (gnus-message 7 "%d articles are marked as %s"
11423 count (if unmark "unread" "read"))))
11425 (defun gnus-summary-mark-same-subject (subject &optional unmark)
11426 "Mark articles with same SUBJECT as read, and return marked number.
11427 If optional argument UNMARK is positive, remove any kinds of marks.
11428 If optional argument UNMARK is negative, mark articles as unread instead."
11432 ((null unmark) ; Mark as read.
11435 (gnus-summary-mark-article-as-read gnus-killed-mark)
11436 (gnus-summary-show-thread) t)
11437 (gnus-summary-find-subject subject))
11438 (setq count (1+ count))))
11439 ((> unmark 0) ; Tick.
11442 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
11443 (gnus-summary-show-thread) t)
11444 (gnus-summary-find-subject subject))
11445 (setq count (1+ count))))
11446 (t ; Mark as unread.
11449 (gnus-summary-mark-article-as-unread gnus-unread-mark)
11450 (gnus-summary-show-thread) t)
11451 (gnus-summary-find-subject subject))
11452 (setq count (1+ count)))))
11453 (gnus-set-mode-line 'summary)
11454 ;; Return the number of marked articles.
11457 (defun gnus-summary-mark-as-processable (n &optional unmark)
11458 "Set the process mark on the next N articles.
11459 If N is negative, mark backward instead. If UNMARK is non-nil, remove
11460 the process mark instead. The difference between N and the actual
11461 number of articles marked is returned."
11463 (gnus-set-global-variables)
11464 (let ((backward (< n 0))
11469 (gnus-summary-remove-process-mark
11470 (gnus-summary-article-number))
11471 (gnus-summary-set-process-mark (gnus-summary-article-number)))
11472 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
11474 (if (/= 0 n) (gnus-message 7 "No more articles"))
11475 (gnus-summary-recenter)
11476 (gnus-summary-position-point)
11479 (defun gnus-summary-unmark-as-processable (n)
11480 "Remove the process mark from the next N articles.
11481 If N is negative, mark backward instead. The difference between N and
11482 the actual number of articles marked is returned."
11484 (gnus-set-global-variables)
11485 (gnus-summary-mark-as-processable n t))
11487 (defun gnus-summary-unmark-all-processable ()
11488 "Remove the process mark from all articles."
11490 (gnus-set-global-variables)
11492 (while gnus-newsgroup-processable
11493 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
11494 (gnus-summary-position-point))
11496 (defun gnus-summary-mark-as-expirable (n)
11497 "Mark N articles forward as expirable.
11498 If N is negative, mark backward instead. The difference between N and
11499 the actual number of articles marked is returned."
11501 (gnus-set-global-variables)
11502 (gnus-summary-mark-forward n gnus-expirable-mark))
11504 (defun gnus-summary-mark-article-as-replied (article)
11505 "Mark ARTICLE replied and update the summary line."
11506 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
11507 (let ((buffer-read-only nil))
11508 (when (gnus-summary-goto-subject article)
11509 (gnus-summary-update-secondary-mark article))))
11511 (defun gnus-summary-set-bookmark (article)
11512 "Set a bookmark in current article."
11513 (interactive (list (gnus-summary-article-number)))
11514 (gnus-set-global-variables)
11515 (if (or (not (get-buffer gnus-article-buffer))
11516 (not gnus-current-article)
11517 (not gnus-article-current)
11518 (not (equal gnus-newsgroup-name (car gnus-article-current))))
11519 (error "No current article selected"))
11520 ;; Remove old bookmark, if one exists.
11521 (let ((old (assq article gnus-newsgroup-bookmarks)))
11522 (if old (setq gnus-newsgroup-bookmarks
11523 (delq old gnus-newsgroup-bookmarks))))
11524 ;; Set the new bookmark, which is on the form
11525 ;; (article-number . line-number-in-body).
11526 (setq gnus-newsgroup-bookmarks
11530 (set-buffer gnus-article-buffer)
11534 (goto-char (point-min))
11535 (search-forward "\n\n" nil t)
11538 gnus-newsgroup-bookmarks))
11539 (gnus-message 6 "A bookmark has been added to the current article."))
11541 (defun gnus-summary-remove-bookmark (article)
11542 "Remove the bookmark from the current article."
11543 (interactive (list (gnus-summary-article-number)))
11544 (gnus-set-global-variables)
11545 ;; Remove old bookmark, if one exists.
11546 (let ((old (assq article gnus-newsgroup-bookmarks)))
11549 (setq gnus-newsgroup-bookmarks
11550 (delq old gnus-newsgroup-bookmarks))
11551 (gnus-message 6 "Removed bookmark."))
11552 (gnus-message 6 "No bookmark in current article."))))
11554 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11555 (defun gnus-summary-mark-as-dormant (n)
11556 "Mark N articles forward as dormant.
11557 If N is negative, mark backward instead. The difference between N and
11558 the actual number of articles marked is returned."
11560 (gnus-set-global-variables)
11561 (gnus-summary-mark-forward n gnus-dormant-mark))
11563 (defun gnus-summary-set-process-mark (article)
11564 "Set the process mark on ARTICLE and update the summary line."
11565 (setq gnus-newsgroup-processable
11567 (delq article gnus-newsgroup-processable)))
11568 (when (gnus-summary-goto-subject article)
11569 (gnus-summary-show-thread)
11570 (gnus-summary-update-secondary-mark article)))
11572 (defun gnus-summary-remove-process-mark (article)
11573 "Remove the process mark from ARTICLE and update the summary line."
11574 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
11575 (when (gnus-summary-goto-subject article)
11576 (gnus-summary-show-thread)
11577 (gnus-summary-update-secondary-mark article)))
11579 (defun gnus-summary-set-saved-mark (article)
11580 "Set the process mark on ARTICLE and update the summary line."
11581 (push article gnus-newsgroup-saved)
11582 (when (gnus-summary-goto-subject article)
11583 (gnus-summary-update-secondary-mark article)))
11585 (defun gnus-summary-mark-forward (n &optional mark no-expire)
11586 "Mark N articles as read forwards.
11587 If N is negative, mark backwards instead.
11588 Mark with MARK. If MARK is ? , ?! or ??, articles will be
11590 The difference between N and the actual number of articles marked is
11593 (gnus-set-global-variables)
11594 (let ((backward (< n 0))
11595 (gnus-summary-goto-unread
11596 (and gnus-summary-goto-unread
11597 (not (eq gnus-summary-goto-unread 'never))
11598 (not (memq mark (list gnus-unread-mark
11599 gnus-ticked-mark gnus-dormant-mark)))))
11601 (mark (or mark gnus-del-mark)))
11602 (while (and (> n 0)
11603 (gnus-summary-mark-article nil mark no-expire)
11604 (zerop (gnus-summary-next-subject
11606 (and gnus-summary-goto-unread
11607 (not (eq gnus-summary-goto-unread 'never)))
11610 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11611 (gnus-summary-recenter)
11612 (gnus-summary-position-point)
11613 (gnus-set-mode-line 'summary)
11616 (defun gnus-summary-mark-article-as-read (mark)
11617 "Mark the current article quickly as read with MARK."
11618 (let ((article (gnus-summary-article-number)))
11619 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11620 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11621 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11622 (setq gnus-newsgroup-reads
11623 (cons (cons article mark) gnus-newsgroup-reads))
11624 ;; Possibly remove from cache, if that is used.
11625 (and gnus-use-cache (gnus-cache-enter-remove-article article))
11626 ;; Allow the backend to change the mark.
11627 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
11628 ;; Check for auto-expiry.
11629 (when (and gnus-newsgroup-auto-expire
11630 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
11631 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
11632 (= mark gnus-ancient-mark)
11633 (= mark gnus-read-mark) (= mark gnus-souped-mark)))
11634 (setq mark gnus-expirable-mark)
11635 (push article gnus-newsgroup-expirable))
11636 ;; Set the mark in the buffer.
11637 (gnus-summary-update-mark mark 'unread)
11640 (defun gnus-summary-mark-article-as-unread (mark)
11641 "Mark the current article quickly as unread with MARK."
11642 (let ((article (gnus-summary-article-number)))
11643 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11644 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11645 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
11646 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
11647 (cond ((= mark gnus-ticked-mark)
11648 (push article gnus-newsgroup-marked))
11649 ((= mark gnus-dormant-mark)
11650 (push article gnus-newsgroup-dormant))
11652 (push article gnus-newsgroup-unreads)))
11653 (setq gnus-newsgroup-reads
11654 (delq (assq article gnus-newsgroup-reads)
11655 gnus-newsgroup-reads))
11657 ;; See whether the article is to be put in the cache.
11658 (and gnus-use-cache
11659 (vectorp (gnus-summary-article-header article))
11661 (gnus-cache-possibly-enter-article
11662 gnus-newsgroup-name article
11663 (gnus-summary-article-header article)
11664 (= mark gnus-ticked-mark)
11665 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11668 (gnus-summary-update-mark mark 'unread)
11671 (defun gnus-summary-mark-article (&optional article mark no-expire)
11672 "Mark ARTICLE with MARK. MARK can be any character.
11673 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
11674 `??' (dormant) and `?E' (expirable).
11675 If MARK is nil, then the default character `?D' is used.
11676 If ARTICLE is nil, then the article on the current line will be
11678 ;; The mark might be a string.
11679 (and (stringp mark)
11680 (setq mark (aref mark 0)))
11681 ;; If no mark is given, then we check auto-expiring.
11682 (and (not no-expire)
11683 gnus-newsgroup-auto-expire
11685 (and (numberp mark)
11686 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
11687 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
11688 (= mark gnus-read-mark) (= mark gnus-souped-mark))))
11689 (setq mark gnus-expirable-mark))
11690 (let* ((mark (or mark gnus-del-mark))
11691 (article (or article (gnus-summary-article-number))))
11692 (or article (error "No article on current line"))
11693 (if (or (= mark gnus-unread-mark)
11694 (= mark gnus-ticked-mark)
11695 (= mark gnus-dormant-mark))
11696 (gnus-mark-article-as-unread article mark)
11697 (gnus-mark-article-as-read article mark))
11699 ;; See whether the article is to be put in the cache.
11700 (and gnus-use-cache
11701 (not (= mark gnus-canceled-mark))
11702 (vectorp (gnus-summary-article-header article))
11704 (gnus-cache-possibly-enter-article
11705 gnus-newsgroup-name article
11706 (gnus-summary-article-header article)
11707 (= mark gnus-ticked-mark)
11708 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11710 (if (gnus-summary-goto-subject article nil t)
11711 (let ((buffer-read-only nil))
11712 (gnus-summary-show-thread)
11714 (gnus-summary-update-mark mark 'unread)
11717 (defun gnus-summary-update-secondary-mark (article)
11718 "Update the secondary (read, process, cache) mark."
11719 (gnus-summary-update-mark
11720 (cond ((memq article gnus-newsgroup-processable)
11722 ((memq article gnus-newsgroup-cached)
11724 ((memq article gnus-newsgroup-replied)
11726 ((memq article gnus-newsgroup-saved)
11728 (t gnus-unread-mark))
11730 (when (gnus-visual-p 'summary-highlight 'highlight)
11731 (run-hooks 'gnus-summary-update-hook))
11734 (defun gnus-summary-update-mark (mark type)
11735 (beginning-of-line)
11736 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
11737 (buffer-read-only nil))
11739 ;; Go to the right position on the line.
11740 (forward-char forward)
11741 ;; Replace the old mark with the new mark.
11742 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
11743 ;; Optionally update the marks by some user rule.
11744 (when (eq type 'unread)
11745 (gnus-data-set-mark
11746 (gnus-data-find (gnus-summary-article-number)) mark)
11747 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
11749 (defun gnus-mark-article-as-read (article &optional mark)
11750 "Enter ARTICLE in the pertinent lists and remove it from others."
11751 ;; Make the article expirable.
11752 (let ((mark (or mark gnus-del-mark)))
11753 (if (= mark gnus-expirable-mark)
11754 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
11755 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
11756 ;; Remove from unread and marked lists.
11757 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11758 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11759 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11760 (push (cons article mark) gnus-newsgroup-reads)
11761 ;; Possibly remove from cache, if that is used.
11762 (when gnus-use-cache
11763 (gnus-cache-enter-remove-article article))))
11765 (defun gnus-mark-article-as-unread (article &optional mark)
11766 "Enter ARTICLE in the pertinent lists and remove it from others."
11767 (let ((mark (or mark gnus-ticked-mark)))
11768 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11769 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11770 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
11771 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11772 (cond ((= mark gnus-ticked-mark)
11773 (push article gnus-newsgroup-marked))
11774 ((= mark gnus-dormant-mark)
11775 (push article gnus-newsgroup-dormant))
11777 (push article gnus-newsgroup-unreads)))
11778 (setq gnus-newsgroup-reads
11779 (delq (assq article gnus-newsgroup-reads)
11780 gnus-newsgroup-reads))))
11782 (defalias 'gnus-summary-mark-as-unread-forward
11783 'gnus-summary-tick-article-forward)
11784 (make-obsolete 'gnus-summary-mark-as-unread-forward
11785 'gnus-summary-tick-article-forward)
11786 (defun gnus-summary-tick-article-forward (n)
11787 "Tick N articles forwards.
11788 If N is negative, tick backwards instead.
11789 The difference between N and the number of articles ticked is returned."
11791 (gnus-summary-mark-forward n gnus-ticked-mark))
11793 (defalias 'gnus-summary-mark-as-unread-backward
11794 'gnus-summary-tick-article-backward)
11795 (make-obsolete 'gnus-summary-mark-as-unread-backward
11796 'gnus-summary-tick-article-backward)
11797 (defun gnus-summary-tick-article-backward (n)
11798 "Tick N articles backwards.
11799 The difference between N and the number of articles ticked is returned."
11801 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
11803 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
11804 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
11805 (defun gnus-summary-tick-article (&optional article clear-mark)
11806 "Mark current article as unread.
11807 Optional 1st argument ARTICLE specifies article number to be marked as unread.
11808 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
11810 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
11811 gnus-ticked-mark)))
11813 (defun gnus-summary-mark-as-read-forward (n)
11814 "Mark N articles as read forwards.
11815 If N is negative, mark backwards instead.
11816 The difference between N and the actual number of articles marked is
11819 (gnus-summary-mark-forward n gnus-del-mark t))
11821 (defun gnus-summary-mark-as-read-backward (n)
11822 "Mark the N articles as read backwards.
11823 The difference between N and the actual number of articles marked is
11826 (gnus-summary-mark-forward (- n) gnus-del-mark t))
11828 (defun gnus-summary-mark-as-read (&optional article mark)
11829 "Mark current article as read.
11830 ARTICLE specifies the article to be marked as read.
11831 MARK specifies a string to be inserted at the beginning of the line."
11832 (gnus-summary-mark-article article mark))
11834 (defun gnus-summary-clear-mark-forward (n)
11835 "Clear marks from N articles forward.
11836 If N is negative, clear backward instead.
11837 The difference between N and the number of marks cleared is returned."
11839 (gnus-summary-mark-forward n gnus-unread-mark))
11841 (defun gnus-summary-clear-mark-backward (n)
11842 "Clear marks from N articles backward.
11843 The difference between N and the number of marks cleared is returned."
11845 (gnus-summary-mark-forward (- n) gnus-unread-mark))
11847 (defun gnus-summary-mark-unread-as-read ()
11848 "Intended to be used by `gnus-summary-mark-article-hook'."
11849 (when (memq gnus-current-article gnus-newsgroup-unreads)
11850 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
11852 (defun gnus-summary-mark-region-as-read (point mark all)
11853 "Mark all unread articles between point and mark as read.
11854 If given a prefix, mark all articles between point and mark as read,
11855 even ticked and dormant ones."
11856 (interactive "r\nP")
11860 (beginning-of-line)
11865 (memq (setq article (gnus-summary-article-number))
11866 gnus-newsgroup-unreads))
11867 (gnus-summary-mark-article article gnus-del-mark))
11869 (gnus-summary-find-next))))))
11871 (defun gnus-summary-mark-below (score mark)
11872 "Mark articles with score less than SCORE with MARK."
11873 (interactive "P\ncMark: ")
11874 (gnus-set-global-variables)
11875 (setq score (if score
11876 (prefix-numeric-value score)
11877 (or gnus-summary-default-score 0)))
11879 (set-buffer gnus-summary-buffer)
11880 (goto-char (point-min))
11883 (and (< (gnus-summary-article-score) score)
11884 (gnus-summary-mark-article nil mark))
11885 (gnus-summary-find-next)))))
11887 (defun gnus-summary-kill-below (&optional score)
11888 "Mark articles with score below SCORE as read."
11890 (gnus-set-global-variables)
11891 (gnus-summary-mark-below score gnus-killed-mark))
11893 (defun gnus-summary-clear-above (&optional score)
11894 "Clear all marks from articles with score above SCORE."
11896 (gnus-set-global-variables)
11897 (gnus-summary-mark-above score gnus-unread-mark))
11899 (defun gnus-summary-tick-above (&optional score)
11900 "Tick all articles with score above SCORE."
11902 (gnus-set-global-variables)
11903 (gnus-summary-mark-above score gnus-ticked-mark))
11905 (defun gnus-summary-mark-above (score mark)
11906 "Mark articles with score over SCORE with MARK."
11907 (interactive "P\ncMark: ")
11908 (gnus-set-global-variables)
11909 (setq score (if score
11910 (prefix-numeric-value score)
11911 (or gnus-summary-default-score 0)))
11913 (set-buffer gnus-summary-buffer)
11914 (goto-char (point-min))
11916 (if (> (gnus-summary-article-score) score)
11917 (gnus-summary-mark-article nil mark))
11919 (gnus-summary-find-next)))))
11921 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11922 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
11923 (defun gnus-summary-limit-include-expunged ()
11924 "Display all the hidden articles that were expunged for low scores."
11926 (gnus-set-global-variables)
11927 (let ((buffer-read-only nil))
11928 (let ((scored gnus-newsgroup-scored)
11931 (or (gnus-summary-goto-subject (car (car scored)))
11932 (and (setq h (gnus-summary-article-header (car (car scored))))
11933 (< (cdr (car scored)) gnus-summary-expunge-below)
11934 (setq headers (cons h headers))))
11935 (setq scored (cdr scored)))
11936 (or headers (error "No expunged articles hidden."))
11937 (goto-char (point-min))
11938 (gnus-summary-prepare-unthreaded (nreverse headers)))
11939 (goto-char (point-min))
11940 (gnus-summary-position-point)))
11942 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
11943 "Mark all articles not marked as unread in this newsgroup as read.
11944 If prefix argument ALL is non-nil, all articles are marked as read.
11945 If QUIETLY is non-nil, no questions will be asked.
11946 If TO-HERE is non-nil, it should be a point in the buffer. All
11947 articles before this point will be marked as read.
11948 The number of articles marked as read is returned."
11950 (gnus-set-global-variables)
11953 (not gnus-interactive-catchup) ;Without confirmation?
11957 "Mark absolutely all articles as read? "
11958 "Mark all unread articles as read? ")))
11960 (not gnus-newsgroup-adaptive)
11961 (not gnus-newsgroup-auto-expire))
11964 (setq gnus-newsgroup-marked nil
11965 gnus-newsgroup-dormant nil))
11966 (setq gnus-newsgroup-unreads nil))
11967 ;; We actually mark all articles as canceled, which we
11968 ;; have to do when using auto-expiry or adaptive scoring.
11969 (gnus-summary-show-all-threads)
11970 (if (gnus-summary-first-subject (not all))
11972 (if to-here (< (point) to-here) t)
11973 (gnus-summary-mark-article-as-read gnus-catchup-mark)
11974 (gnus-summary-find-next (not all)))))
11976 (setq gnus-newsgroup-unreads nil))
11977 (gnus-set-mode-line 'summary)))
11978 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
11979 (if (and (not to-here) (eq 'nnvirtual (car method)))
11980 (nnvirtual-catchup-group
11981 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
11982 (gnus-summary-position-point)))
11984 (defun gnus-summary-catchup-to-here (&optional all)
11985 "Mark all unticked articles before the current one as read.
11986 If ALL is non-nil, also mark ticked and dormant articles as read."
11988 (gnus-set-global-variables)
11990 (let ((beg (point)))
11991 ;; We check that there are unread articles.
11992 (when (or all (gnus-summary-find-prev))
11993 (gnus-summary-catchup all t beg))))
11994 (gnus-summary-position-point))
11996 (defun gnus-summary-catchup-all (&optional quietly)
11997 "Mark all articles in this newsgroup as read."
11999 (gnus-set-global-variables)
12000 (gnus-summary-catchup t quietly))
12002 (defun gnus-summary-catchup-and-exit (&optional all quietly)
12003 "Mark all articles not marked as unread in this newsgroup as read, then exit.
12004 If prefix argument ALL is non-nil, all articles are marked as read."
12006 (gnus-set-global-variables)
12007 (gnus-summary-catchup all quietly nil 'fast)
12008 ;; Select next newsgroup or exit.
12009 (if (eq gnus-auto-select-next 'quietly)
12010 (gnus-summary-next-group nil)
12011 (gnus-summary-exit)))
12013 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
12014 "Mark all articles in this newsgroup as read, and then exit."
12016 (gnus-set-global-variables)
12017 (gnus-summary-catchup-and-exit t quietly))
12019 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
12020 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
12021 "Mark all articles in this group as read and select the next group.
12022 If given a prefix, mark all articles, unread as well as ticked, as
12025 (gnus-set-global-variables)
12027 (gnus-summary-catchup all))
12028 (gnus-summary-next-article t nil nil t))
12030 ;; Thread-based commands.
12032 (defun gnus-summary-articles-in-thread (&optional article)
12033 "Return a list of all articles in the current thread.
12034 If ARTICLE is non-nil, return all articles in the thread that starts
12035 with that article."
12036 (let* ((article (or article (gnus-summary-article-number)))
12037 (data (gnus-data-find-list article))
12038 (top-level (gnus-data-level (car data)))
12040 (cond ((null gnus-thread-operation-ignore-subject)
12041 (gnus-simplify-subject-re
12042 (mail-header-subject (gnus-data-header (car data)))))
12043 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
12044 (gnus-simplify-subject-fuzzy
12045 (mail-header-subject (gnus-data-header (car data)))))
12049 () ; This article doesn't exist.
12051 (and (or (not top-subject)
12052 (string= top-subject
12053 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
12054 (gnus-simplify-subject-fuzzy
12055 (mail-header-subject
12056 (gnus-data-header (car data))))
12057 (gnus-simplify-subject-re
12058 (mail-header-subject
12059 (gnus-data-header (car data)))))))
12060 (setq articles (cons (gnus-data-number (car data)) articles)))
12061 (if (and (setq data (cdr data))
12062 (> (gnus-data-level (car data)) top-level))
12065 ;; Return the list of articles.
12066 (nreverse articles))))
12068 (defun gnus-summary-rethread-current ()
12069 "Rethread the thread the current article is part of."
12071 (gnus-set-global-variables)
12072 (let* ((gnus-show-threads t)
12073 (article (gnus-summary-article-number))
12074 (id (mail-header-id (gnus-summary-article-header)))
12075 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
12077 (error "No article on the current line"))
12078 (gnus-rebuild-thread id)
12079 (gnus-summary-goto-subject article)))
12081 (defun gnus-summary-reparent-thread ()
12082 "Make current article child of the marked (or previous) article.
12084 Note that the re-threading will only work if `gnus-thread-ignore-subject'
12085 is non-nil or the Subject: of both articles are the same."
12087 (or (not (gnus-group-read-only-p))
12088 (error "The current newsgroup does not support article editing."))
12089 (or (<= (length gnus-newsgroup-processable) 1)
12090 (error "No more than one article may be marked."))
12091 (save-window-excursion
12092 (let ((gnus-article-buffer " *reparent*")
12093 (current-article (gnus-summary-article-number))
12094 ; first grab the marked article, otherwise one line up.
12095 (parent-article (if (not (null gnus-newsgroup-processable))
12096 (car gnus-newsgroup-processable)
12098 (if (eq (forward-line -1) 0)
12099 (gnus-summary-article-number)
12100 (error "Beginning of summary buffer."))))))
12101 (or (not (eq current-article parent-article))
12102 (error "An article may not be self-referential."))
12103 (let ((message-id (mail-header-id
12104 (gnus-summary-article-header parent-article))))
12105 (or (and message-id (not (equal message-id "")))
12106 (error "No message-id in desired parent."))
12107 (gnus-summary-select-article t t nil current-article)
12108 (set-buffer gnus-article-buffer)
12109 (setq buffer-read-only nil)
12110 (let ((buf (buffer-substring-no-properties (point-min) (point-max))))
12113 (goto-char (point-min))
12114 (if (search-forward-regexp "^References: " nil t)
12115 (insert message-id " " )
12116 (insert "References: " message-id "\n"))
12117 (or (gnus-request-replace-article current-article
12118 (car gnus-article-current)
12119 gnus-article-buffer)
12120 (error "Couldn't replace article."))
12121 (set-buffer gnus-summary-buffer)
12122 (gnus-summary-unmark-all-processable)
12123 (gnus-summary-rethread-current)
12124 (message "Article %d is now the child of article %d."
12125 current-article parent-article)))))
12127 (defun gnus-summary-toggle-threads (&optional arg)
12128 "Toggle showing conversation threads.
12129 If ARG is positive number, turn showing conversation threads on."
12131 (gnus-set-global-variables)
12132 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
12133 (setq gnus-show-threads
12134 (if (null arg) (not gnus-show-threads)
12135 (> (prefix-numeric-value arg) 0)))
12136 (gnus-summary-prepare)
12137 (gnus-summary-goto-subject current)
12138 (gnus-summary-position-point)))
12140 (defun gnus-summary-show-all-threads ()
12141 "Show all threads."
12143 (gnus-set-global-variables)
12145 (let ((buffer-read-only nil))
12146 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
12147 (gnus-summary-position-point))
12149 (defun gnus-summary-show-thread ()
12150 "Show thread subtrees.
12151 Returns nil if no thread was there to be shown."
12153 (gnus-set-global-variables)
12154 (let ((buffer-read-only nil)
12156 ;; first goto end then to beg, to have point at beg after let
12157 (end (progn (end-of-line) (point)))
12158 (beg (progn (beginning-of-line) (point))))
12160 ;; Any hidden lines here?
12161 (search-forward "\r" end t)
12162 (subst-char-in-region beg end ?\^M ?\n t)
12164 (gnus-summary-position-point))))
12166 (defun gnus-summary-hide-all-threads ()
12167 "Hide all thread subtrees."
12169 (gnus-set-global-variables)
12171 (goto-char (point-min))
12172 (gnus-summary-hide-thread)
12173 (while (zerop (gnus-summary-next-thread 1 t))
12174 (gnus-summary-hide-thread)))
12175 (gnus-summary-position-point))
12177 (defun gnus-summary-hide-thread ()
12178 "Hide thread subtrees.
12179 Returns nil if no threads were there to be hidden."
12181 (gnus-set-global-variables)
12182 (let ((buffer-read-only nil)
12184 (article (gnus-summary-article-number))
12187 ;; Go forward until either the buffer ends or the subthread
12189 (when (and (not (eobp))
12190 (or (zerop (gnus-summary-next-thread 1 t))
12191 (goto-char (point-max))))
12194 (if (and (> (point) start)
12195 (search-backward "\n" start t))
12197 (subst-char-in-region start (point) ?\n ?\^M)
12198 (gnus-summary-goto-subject article))
12201 (gnus-summary-position-point)))))
12203 (defun gnus-summary-go-to-next-thread (&optional previous)
12204 "Go to the same level (or less) next thread.
12205 If PREVIOUS is non-nil, go to previous thread instead.
12206 Return the article number moved to, or nil if moving was impossible."
12207 (let* ((level (gnus-summary-thread-level))
12208 (article (gnus-summary-article-number))
12209 (data (cdr (gnus-data-find-list article (gnus-data-list previous))))
12212 (if (<= (gnus-data-level (car data)) level)
12213 (setq oart (gnus-data-number (car data))
12215 (setq data (cdr data))))
12217 (gnus-summary-goto-subject oart))))
12219 (defun gnus-summary-next-thread (n &optional silent)
12220 "Go to the same level next N'th thread.
12221 If N is negative, search backward instead.
12222 Returns the difference between N and the number of skips actually
12225 If SILENT, don't output messages."
12227 (gnus-set-global-variables)
12228 (let ((backward (< n 0))
12231 (while (and (> n 0)
12232 (setq old (save-excursion (forward-line 1) (point)))
12233 (gnus-summary-go-to-next-thread backward))
12234 (when (and (eq gnus-summary-make-false-root 'dummy)
12235 (setq dum (text-property-not-all
12236 old (point) 'gnus-intangible nil)))
12239 (gnus-summary-position-point)
12240 (when (and (not silent) (/= 0 n))
12241 (gnus-message 7 "No more threads"))
12244 (defun gnus-summary-prev-thread (n)
12245 "Go to the same level previous N'th thread.
12246 Returns the difference between N and the number of skips actually
12249 (gnus-set-global-variables)
12250 (gnus-summary-next-thread (- n)))
12252 (defun gnus-summary-go-down-thread ()
12253 "Go down one level in the current thread."
12254 (let ((children (gnus-summary-article-children)))
12256 (gnus-summary-goto-subject (car children)))))
12258 (defun gnus-summary-go-up-thread ()
12259 "Go up one level in the current thread."
12260 (let ((parent (gnus-summary-article-parent)))
12262 (gnus-summary-goto-subject parent))))
12264 (defun gnus-summary-down-thread (n)
12265 "Go down thread N steps.
12266 If N is negative, go up instead.
12267 Returns the difference between N and how many steps down that were
12270 (gnus-set-global-variables)
12273 (while (and (> n 0)
12274 (if up (gnus-summary-go-up-thread)
12275 (gnus-summary-go-down-thread)))
12277 (gnus-summary-position-point)
12278 (if (/= 0 n) (gnus-message 7 "Can't go further"))
12281 (defun gnus-summary-up-thread (n)
12282 "Go up thread N steps.
12283 If N is negative, go up instead.
12284 Returns the difference between N and how many steps down that were
12287 (gnus-set-global-variables)
12288 (gnus-summary-down-thread (- n)))
12290 (defun gnus-summary-top-thread ()
12291 "Go to the top of the thread."
12293 (gnus-set-global-variables)
12294 (while (gnus-summary-go-up-thread))
12295 (gnus-summary-article-number))
12297 (defun gnus-summary-kill-thread (&optional unmark)
12298 "Mark articles under current thread as read.
12299 If the prefix argument is positive, remove any kinds of marks.
12300 If the prefix argument is negative, tick articles instead."
12302 (gnus-set-global-variables)
12304 (setq unmark (prefix-numeric-value unmark)))
12305 (let ((articles (gnus-summary-articles-in-thread)))
12307 ;; Expand the thread.
12308 (gnus-summary-show-thread)
12309 ;; Mark all the articles.
12311 (gnus-summary-goto-subject (car articles))
12312 (cond ((null unmark)
12313 (gnus-summary-mark-article-as-read gnus-killed-mark))
12315 (gnus-summary-mark-article-as-unread gnus-unread-mark))
12317 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
12318 (setq articles (cdr articles))))
12319 ;; Hide killed subtrees.
12321 gnus-thread-hide-killed
12322 (gnus-summary-hide-thread))
12323 ;; If marked as read, go to next unread subject.
12325 ;; Go to next unread subject.
12326 (gnus-summary-next-subject 1 t)))
12327 (gnus-set-mode-line 'summary))
12329 ;; Summary sorting commands
12331 (defun gnus-summary-sort-by-number (&optional reverse)
12332 "Sort summary buffer by article number.
12333 Argument REVERSE means reverse order."
12335 (gnus-summary-sort 'number reverse))
12337 (defun gnus-summary-sort-by-author (&optional reverse)
12338 "Sort summary buffer by author name alphabetically.
12339 If case-fold-search is non-nil, case of letters is ignored.
12340 Argument REVERSE means reverse order."
12342 (gnus-summary-sort 'author reverse))
12344 (defun gnus-summary-sort-by-subject (&optional reverse)
12345 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
12346 If case-fold-search is non-nil, case of letters is ignored.
12347 Argument REVERSE means reverse order."
12349 (gnus-summary-sort 'subject reverse))
12351 (defun gnus-summary-sort-by-date (&optional reverse)
12352 "Sort summary buffer by date.
12353 Argument REVERSE means reverse order."
12355 (gnus-summary-sort 'date reverse))
12357 (defun gnus-summary-sort-by-score (&optional reverse)
12358 "Sort summary buffer by score.
12359 Argument REVERSE means reverse order."
12361 (gnus-summary-sort 'score reverse))
12363 (defun gnus-summary-sort (predicate reverse)
12364 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
12365 (gnus-set-global-variables)
12366 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
12367 (article (intern (format "gnus-article-sort-by-%s" predicate)))
12368 (gnus-thread-sort-functions
12373 (,thread t2 t1)))))
12374 (gnus-article-sort-functions
12379 (,article t2 t1)))))
12381 (gnus-summary-prepare-hook nil))
12382 ;; We do the sorting by regenerating the threads.
12383 (gnus-summary-prepare)
12384 ;; Hide subthreads if needed.
12385 (when (and gnus-show-threads gnus-thread-hide-subtree)
12386 (gnus-summary-hide-all-threads)))
12387 ;; If in async mode, we send some info to the backend.
12388 (when gnus-newsgroup-async
12389 (gnus-request-asynchronous
12390 gnus-newsgroup-name gnus-newsgroup-data)))
12392 (defun gnus-sortable-date (date)
12393 "Make sortable string by string-lessp from DATE.
12394 Timezone package is used."
12395 (let* ((date (timezone-fix-time date nil nil)) ;[Y M D H M S]
12396 (year (aref date 0))
12397 (month (aref date 1))
12398 (day (aref date 2)))
12399 (timezone-make-sortable-date
12401 (timezone-make-time-string
12402 (aref date 3) (aref date 4) (aref date 5)))))
12404 ;; Summary saving commands.
12406 (defun gnus-summary-save-article (&optional n not-saved)
12407 "Save the current article using the default saver function.
12408 If N is a positive number, save the N next articles.
12409 If N is a negative number, save the N previous articles.
12410 If N is nil and any articles have been marked with the process mark,
12411 save those articles instead.
12412 The variable `gnus-default-article-saver' specifies the saver function."
12414 (gnus-set-global-variables)
12415 (let ((articles (gnus-summary-work-articles n))
12416 file header article)
12418 (setq header (gnus-summary-article-header
12419 (setq article (pop articles))))
12420 (if (not (vectorp header))
12421 ;; This is a pseudo-article.
12422 (if (assq 'name header)
12423 (gnus-copy-file (cdr (assq 'name header)))
12424 (gnus-message 1 "Article %d is unsaveable" article))
12425 ;; This is a real article.
12426 (save-window-excursion
12427 (gnus-summary-select-article t nil nil article))
12428 (unless gnus-save-all-headers
12429 ;; Remove headers accoring to `gnus-saved-headers'.
12430 (let ((gnus-visible-headers
12431 (or gnus-saved-headers gnus-visible-headers)))
12432 (gnus-article-hide-headers nil t)))
12433 ;; Remove any X-Gnus lines.
12435 (set-buffer gnus-article-buffer)
12437 (let ((buffer-read-only nil))
12438 (nnheader-narrow-to-headers)
12439 (while (re-search-forward "^X-Gnus" nil t)
12440 (gnus-delete-line)))))
12441 (save-window-excursion
12442 (if (not gnus-default-article-saver)
12443 (error "No default saver is defined.")
12444 (setq file (funcall
12445 gnus-default-article-saver
12447 ((not gnus-prompt-before-saving)
12449 ((eq gnus-prompt-before-saving 'always)
12452 (gnus-summary-remove-process-mark article)
12454 (gnus-summary-set-saved-mark article))))
12455 (gnus-summary-position-point)
12458 (defun gnus-summary-pipe-output (&optional arg)
12459 "Pipe the current article to a subprocess.
12460 If N is a positive number, pipe the N next articles.
12461 If N is a negative number, pipe the N previous articles.
12462 If N is nil and any articles have been marked with the process mark,
12463 pipe those articles instead."
12465 (gnus-set-global-variables)
12466 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
12467 (gnus-summary-save-article arg t))
12468 (gnus-configure-windows 'pipe))
12470 (defun gnus-summary-save-article-mail (&optional arg)
12471 "Append the current article to an mail file.
12472 If N is a positive number, save the N next articles.
12473 If N is a negative number, save the N previous articles.
12474 If N is nil and any articles have been marked with the process mark,
12475 save those articles instead."
12477 (gnus-set-global-variables)
12478 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
12479 (gnus-summary-save-article arg)))
12481 (defun gnus-summary-save-article-rmail (&optional arg)
12482 "Append the current article to an rmail file.
12483 If N is a positive number, save the N next articles.
12484 If N is a negative number, save the N previous articles.
12485 If N is nil and any articles have been marked with the process mark,
12486 save those articles instead."
12488 (gnus-set-global-variables)
12489 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
12490 (gnus-summary-save-article arg)))
12492 (defun gnus-summary-save-article-file (&optional arg)
12493 "Append the current article to a file.
12494 If N is a positive number, save the N next articles.
12495 If N is a negative number, save the N previous articles.
12496 If N is nil and any articles have been marked with the process mark,
12497 save those articles instead."
12499 (gnus-set-global-variables)
12500 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
12501 (gnus-summary-save-article arg)))
12503 (defun gnus-summary-save-article-body-file (&optional arg)
12504 "Append the current article body to a file.
12505 If N is a positive number, save the N next articles.
12506 If N is a negative number, save the N previous articles.
12507 If N is nil and any articles have been marked with the process mark,
12508 save those articles instead."
12510 (gnus-set-global-variables)
12511 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
12512 (gnus-summary-save-article arg)))
12514 (defun gnus-get-split-value (methods)
12515 "Return a value based on the split METHODS."
12516 (let (split-name method result match)
12519 (set-buffer gnus-original-article-buffer)
12521 (nnheader-narrow-to-headers)
12523 (goto-char (point-min))
12524 (setq method (pop methods))
12525 (setq match (pop method))
12528 ;; Regular expression.
12530 (re-search-forward match nil t)
12532 ((gnus-functionp match)
12536 (setq result (funcall match gnus-newsgroup-name))))
12541 (setq result (eval match)))))
12542 (setq split-name (append (cdr methods) split-name))
12543 (cond ((stringp result)
12544 (push result split-name))
12546 (setq split-name (append result split-name)))))))))
12549 (defun gnus-read-move-group-name (prompt default articles prefix)
12550 "Read a group name."
12551 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
12553 (format "Where do you want to %s %s? "
12555 (if (> (length articles) 1)
12556 (format "these %d articles" (length articles))
12564 (format "(default %s) " default)
12566 gnus-active-hashtb nil nil prefix))
12567 ((= 1 (length split-name))
12568 (completing-read prom gnus-active-hashtb
12569 nil nil (cons (car split-name) 0)))
12572 prom (mapcar (lambda (el) (list el)) (nreverse split-name)))))))
12575 (if (or (string= to-newsgroup "")
12576 (string= to-newsgroup prefix))
12577 (setq to-newsgroup (or default "")))
12578 (or (gnus-active to-newsgroup)
12579 (gnus-activate-group to-newsgroup)
12580 (error "No such group: %s" to-newsgroup)))
12583 (defun gnus-read-save-file-name (prompt default-name)
12584 (let* ((split-name (gnus-get-split-value gnus-split-methods))
12586 ;; Let the split methods have their say.
12588 ;; No split name was found.
12591 (concat prompt " (default "
12592 (file-name-nondirectory default-name) ") ")
12593 (file-name-directory default-name)
12595 ;; A single split name was found
12596 ((= 1 (length split-name))
12598 (concat prompt " (default " (car split-name) ") ")
12599 gnus-article-save-directory
12600 (concat gnus-article-save-directory (car split-name))))
12601 ;; A list of splits was found.
12603 (setq split-name (mapcar (lambda (el) (list el))
12604 (nreverse split-name)))
12605 (let ((result (completing-read
12606 (concat prompt " ") split-name nil nil)))
12607 (concat gnus-article-save-directory
12608 (if (string= result "")
12609 (car (car split-name))
12611 ;; If we have read a directory, we append the default file name.
12612 (when (file-directory-p file)
12613 (setq file (concat (file-name-as-directory file)
12614 (file-name-nondirectory default-name))))
12615 ;; Possibly translate some charaters.
12616 (nnheader-translate-file-chars file)))
12618 (defun gnus-article-archive-name (group)
12619 "Return the first instance of an \"Archive-name\" in the current buffer."
12620 (let ((case-fold-search t))
12621 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
12622 (match-string 1))))
12624 (defun gnus-summary-save-in-rmail (&optional filename)
12625 "Append this article to Rmail file.
12626 Optional argument FILENAME specifies file name.
12627 Directory to save to is default to `gnus-article-save-directory' which
12628 is initialized from the SAVEDIR environment variable."
12630 (gnus-set-global-variables)
12631 (let ((default-name
12632 (funcall gnus-rmail-save-name gnus-newsgroup-name
12633 gnus-current-headers gnus-newsgroup-last-rmail)))
12635 (cond ((eq filename 'default)
12637 (filename filename)
12638 (t (gnus-read-save-file-name
12639 "Save in rmail file:" default-name))))
12640 (gnus-make-directory (file-name-directory filename))
12641 (gnus-eval-in-buffer-window
12642 gnus-original-article-buffer
12646 (gnus-output-to-rmail filename))))
12647 ;; Remember the directory name to save articles
12648 (setq gnus-newsgroup-last-rmail filename)))
12650 (defun gnus-summary-save-in-mail (&optional filename)
12651 "Append this article to Unix mail file.
12652 Optional argument FILENAME specifies file name.
12653 Directory to save to is default to `gnus-article-save-directory' which
12654 is initialized from the SAVEDIR environment variable."
12656 (gnus-set-global-variables)
12657 (let ((default-name
12658 (funcall gnus-mail-save-name gnus-newsgroup-name
12659 gnus-current-headers gnus-newsgroup-last-mail)))
12661 (cond ((eq filename 'default)
12663 (filename filename)
12664 (t (gnus-read-save-file-name
12665 "Save in Unix mail file:" default-name))))
12667 (expand-file-name filename
12669 (file-name-directory default-name))))
12670 (gnus-make-directory (file-name-directory filename))
12671 (gnus-eval-in-buffer-window
12672 gnus-original-article-buffer
12676 (if (and (file-readable-p filename) (mail-file-babyl-p filename))
12677 (gnus-output-to-rmail filename)
12678 (let ((mail-use-rfc822 t))
12679 (rmail-output filename 1 t t))))))
12680 ;; Remember the directory name to save articles.
12681 (setq gnus-newsgroup-last-mail filename)))
12683 (defun gnus-summary-save-in-file (&optional filename)
12684 "Append this article to file.
12685 Optional argument FILENAME specifies file name.
12686 Directory to save to is default to `gnus-article-save-directory' which
12687 is initialized from the SAVEDIR environment variable."
12689 (gnus-set-global-variables)
12690 (let ((default-name
12691 (funcall gnus-file-save-name gnus-newsgroup-name
12692 gnus-current-headers gnus-newsgroup-last-file)))
12694 (cond ((eq filename 'default)
12696 (filename filename)
12697 (t (gnus-read-save-file-name
12698 "Save in file:" default-name))))
12699 (gnus-make-directory (file-name-directory filename))
12700 (gnus-eval-in-buffer-window
12701 gnus-original-article-buffer
12705 (gnus-output-to-file filename))))
12706 ;; Remember the directory name to save articles.
12707 (setq gnus-newsgroup-last-file filename)))
12709 (defun gnus-summary-save-body-in-file (&optional filename)
12710 "Append this article body to a file.
12711 Optional argument FILENAME specifies file name.
12712 The directory to save in defaults to `gnus-article-save-directory' which
12713 is initialized from the SAVEDIR environment variable."
12715 (gnus-set-global-variables)
12716 (let ((default-name
12717 (funcall gnus-file-save-name gnus-newsgroup-name
12718 gnus-current-headers gnus-newsgroup-last-file)))
12720 (cond ((eq filename 'default)
12722 (filename filename)
12723 (t (gnus-read-save-file-name
12724 "Save body in file:" default-name))))
12725 (gnus-make-directory (file-name-directory filename))
12726 (gnus-eval-in-buffer-window
12727 gnus-article-buffer
12731 (goto-char (point-min))
12732 (and (search-forward "\n\n" nil t)
12733 (narrow-to-region (point) (point-max)))
12734 (gnus-output-to-file filename))))
12735 ;; Remember the directory name to save articles.
12736 (setq gnus-newsgroup-last-file filename)))
12738 (defun gnus-summary-save-in-pipe (&optional command)
12739 "Pipe this article to subprocess."
12741 (gnus-set-global-variables)
12743 (cond ((eq command 'default)
12744 gnus-last-shell-command)
12746 (t (read-string "Shell command on article: "
12747 gnus-last-shell-command))))
12748 (if (string-equal command "")
12749 (setq command gnus-last-shell-command))
12750 (gnus-eval-in-buffer-window
12751 gnus-article-buffer
12754 (shell-command-on-region (point-min) (point-max) command nil)))
12755 (setq gnus-last-shell-command command))
12757 ;; Summary extract commands
12759 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
12760 (let ((buffer-read-only nil)
12761 (article (gnus-summary-article-number))
12763 (or (gnus-summary-goto-subject article)
12764 (error (format "No such article: %d" article)))
12765 (gnus-summary-position-point)
12766 ;; If all commands are to be bunched up on one line, we collect
12768 (if gnus-view-pseudos-separately
12770 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
12773 (setq action (cdr (assq 'action (car ps))))
12774 (setq files (list (cdr (assq 'name (car ps)))))
12775 (while (and ps (cdr ps)
12776 (string= (or action "1")
12777 (or (cdr (assq 'action (car (cdr ps)))) "2")))
12778 (setq files (cons (cdr (assq 'name (car (cdr ps)))) files))
12779 (setcdr ps (cdr (cdr ps))))
12782 (if (not (string-match "%s" action))
12783 (setq files (cons " " files)))
12784 (setq files (cons " " files))
12785 (and (assq 'execute (car ps))
12786 (setcdr (assq 'execute (car ps))
12787 (funcall (if (string-match "%s" action)
12790 (mapconcat (lambda (f) f) files " ")))))
12791 (setq ps (cdr ps)))))
12792 (if (and gnus-view-pseudos (not not-view))
12794 (and (assq 'execute (car pslist))
12795 (gnus-execute-command (cdr (assq 'execute (car pslist)))
12796 (eq gnus-view-pseudos 'not-confirm)))
12797 (setq pslist (cdr pslist)))
12800 (setq after-article (or (cdr (assq 'article (car pslist)))
12801 (gnus-summary-article-number)))
12802 (gnus-summary-goto-subject after-article)
12805 (insert " " (file-name-nondirectory
12806 (cdr (assq 'name (car pslist))))
12807 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
12809 (forward-line -1) ; back to `b'
12810 (add-text-properties
12811 b e (list 'gnus-number gnus-reffed-article-number
12812 gnus-mouse-face-prop gnus-mouse-face))
12814 after-article gnus-reffed-article-number
12815 gnus-unread-mark b (car pslist) 0 (- e b))
12816 (push gnus-reffed-article-number gnus-newsgroup-unreads)
12817 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
12818 (setq pslist (cdr pslist)))))))
12820 (defun gnus-pseudos< (p1 p2)
12821 (let ((c1 (cdr (assq 'action p1)))
12822 (c2 (cdr (assq 'action p2))))
12823 (and c1 c2 (string< c1 c2))))
12825 (defun gnus-request-pseudo-article (props)
12826 (cond ((assq 'execute props)
12827 (gnus-execute-command (cdr (assq 'execute props)))))
12828 (let ((gnus-current-article (gnus-summary-article-number)))
12829 (run-hooks 'gnus-mark-article-hook)))
12831 (defun gnus-execute-command (command &optional automatic)
12833 (gnus-article-setup-buffer)
12834 (set-buffer gnus-article-buffer)
12835 (let ((command (if automatic command (read-string "Command: " command)))
12836 (buffer-read-only nil))
12838 (insert "$ " command "\n\n")
12839 (if gnus-view-pseudo-asynchronously
12840 (start-process "gnus-execute" nil "sh" "-c" command)
12841 (call-process "sh" nil t nil "-c" command)))))
12843 (defun gnus-copy-file (file &optional to)
12846 (list (read-file-name "Copy file: " default-directory)
12847 (read-file-name "Copy file to: " default-directory)))
12848 (gnus-set-global-variables)
12849 (or to (setq to (read-file-name "Copy file to: " default-directory)))
12850 (and (file-directory-p to)
12851 (setq to (concat (file-name-as-directory to)
12852 (file-name-nondirectory file))))
12853 (copy-file file to))
12855 ;; Summary kill commands.
12857 (defun gnus-summary-edit-global-kill (article)
12858 "Edit the \"global\" kill file."
12859 (interactive (list (gnus-summary-article-number)))
12860 (gnus-set-global-variables)
12861 (gnus-group-edit-global-kill article))
12863 (defun gnus-summary-edit-local-kill ()
12864 "Edit a local kill file applied to the current newsgroup."
12866 (gnus-set-global-variables)
12867 (setq gnus-current-headers (gnus-summary-article-header))
12868 (gnus-set-global-variables)
12869 (gnus-group-edit-local-kill
12870 (gnus-summary-article-number) gnus-newsgroup-name))
12874 ;;; Gnus article mode
12877 (put 'gnus-article-mode 'mode-class 'special)
12879 (if gnus-article-mode-map
12881 (setq gnus-article-mode-map (make-keymap))
12882 (suppress-keymap gnus-article-mode-map)
12885 gnus-article-mode-map
12886 " " gnus-article-goto-next-page
12887 "\177" gnus-article-goto-prev-page
12888 [delete] gnus-article-goto-prev-page
12889 "\C-c^" gnus-article-refer-article
12890 "h" gnus-article-show-summary
12891 "s" gnus-article-show-summary
12892 "\C-c\C-m" gnus-article-mail
12893 "?" gnus-article-describe-briefly
12894 gnus-mouse-2 gnus-article-push-button
12895 "\r" gnus-article-press-button
12896 "\t" gnus-article-next-button
12897 "\M-\t" gnus-article-prev-button
12898 "\C-c\C-b" gnus-bug)
12900 (substitute-key-definition
12901 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map))
12903 (defun gnus-article-mode ()
12904 "Major mode for displaying an article.
12906 All normal editing commands are switched off.
12908 The following commands are available:
12910 \\<gnus-article-mode-map>
12911 \\[gnus-article-next-page]\t Scroll the article one page forwards
12912 \\[gnus-article-prev-page]\t Scroll the article one page backwards
12913 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
12914 \\[gnus-article-show-summary]\t Display the summary buffer
12915 \\[gnus-article-mail]\t Send a reply to the address near point
12916 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
12917 \\[gnus-info-find-node]\t Go to the Gnus info node"
12919 (when (and menu-bar-mode
12920 (gnus-visual-p 'article-menu 'menu))
12921 (gnus-article-make-menu-bar))
12922 (kill-all-local-variables)
12923 (gnus-simplify-mode-line)
12924 (setq mode-name "Article")
12925 (setq major-mode 'gnus-article-mode)
12926 (make-local-variable 'minor-mode-alist)
12927 (or (assq 'gnus-show-mime minor-mode-alist)
12928 (setq minor-mode-alist
12929 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
12930 (use-local-map gnus-article-mode-map)
12931 (make-local-variable 'page-delimiter)
12932 (setq page-delimiter gnus-page-delimiter)
12933 (buffer-disable-undo (current-buffer))
12934 (setq buffer-read-only t) ;Disable modification
12935 (run-hooks 'gnus-article-mode-hook))
12937 (defun gnus-article-setup-buffer ()
12938 "Initialize the article buffer."
12939 (let* ((name (if gnus-single-article-buffer "*Article*"
12940 (concat "*Article " gnus-newsgroup-name "*")))
12942 (progn (string-match "\\*Article" name)
12943 (concat " *Original Article"
12944 (substring name (match-end 0))))))
12945 (setq gnus-article-buffer name)
12946 (setq gnus-original-article-buffer original)
12947 ;; This might be a variable local to the summary buffer.
12948 (unless gnus-single-article-buffer
12950 (set-buffer gnus-summary-buffer)
12951 (setq gnus-article-buffer name)
12952 (setq gnus-original-article-buffer original)
12953 (gnus-set-global-variables))
12954 (make-local-variable 'gnus-summary-buffer))
12955 (if (get-buffer name)
12958 (buffer-disable-undo (current-buffer))
12959 (setq buffer-read-only t)
12960 (gnus-add-current-to-buffer-list)
12961 (or (eq major-mode 'gnus-article-mode)
12962 (gnus-article-mode))
12965 (set-buffer (get-buffer-create name))
12966 (gnus-add-current-to-buffer-list)
12967 (gnus-article-mode)
12968 (current-buffer)))))
12970 ;; Set article window start at LINE, where LINE is the number of lines
12971 ;; from the head of the article.
12972 (defun gnus-article-set-window-start (&optional line)
12974 (get-buffer-window gnus-article-buffer)
12976 (set-buffer gnus-article-buffer)
12977 (goto-char (point-min))
12980 (gnus-message 6 "Moved to bookmark")
12981 (search-forward "\n\n" nil t)
12982 (forward-line line)
12985 (defun gnus-kill-all-overlays ()
12986 "Delete all overlays in the current buffer."
12987 (when (fboundp 'overlay-lists)
12988 (let* ((overlayss (overlay-lists))
12989 (buffer-read-only nil)
12990 (overlays (nconc (car overlayss) (cdr overlayss))))
12992 (delete-overlay (pop overlays))))))
12994 (defun gnus-request-article-this-buffer (article group)
12995 "Get an article and insert it into this buffer."
12999 (gnus-kill-all-overlays)
13000 (setq group (or group gnus-newsgroup-name))
13002 ;; Open server if it has closed.
13003 (gnus-check-server (gnus-find-method-for-group group))
13005 ;; Using `gnus-request-article' directly will insert the article into
13006 ;; `nntp-server-buffer' - so we'll save some time by not having to
13007 ;; copy it from the server buffer into the article buffer.
13009 ;; We only request an article by message-id when we do not have the
13010 ;; headers for it, so we'll have to get those.
13011 (when (stringp article)
13012 (let ((gnus-override-method gnus-refer-article-method))
13013 (gnus-read-header article)))
13015 ;; If the article number is negative, that means that this article
13016 ;; doesn't belong in this newsgroup (possibly), so we find its
13017 ;; message-id and request it by id instead of number.
13018 (when (numberp article)
13020 (set-buffer gnus-summary-buffer)
13021 (let ((header (gnus-summary-article-header article)))
13024 ((memq article gnus-newsgroup-sparse)
13025 ;; This is a sparse gap article.
13026 (setq article (mail-header-id header)))
13028 ;; It's a real article.
13029 (setq article (mail-header-id header)))
13031 ;; It is an extracted pseudo-article.
13032 (setq article 'pseudo)
13033 (gnus-request-pseudo-article header))))
13035 (let ((method (gnus-find-method-for-group
13036 gnus-newsgroup-name)))
13037 (if (not (eq (car method) 'nneething))
13039 (let ((dir (concat (file-name-as-directory (nth 1 method))
13040 (mail-header-subject header))))
13041 (if (file-directory-p dir)
13043 (setq article 'nneething)
13044 (gnus-group-enter-directory dir)))))))))
13047 ;; We first check `gnus-original-article-buffer'.
13048 ((and (equal (car gnus-original-article) group)
13049 (eq (cdr gnus-original-article) article)
13050 (get-buffer gnus-original-article-buffer))
13051 (insert-buffer-substring gnus-original-article-buffer)
13053 ;; Check the backlog.
13054 ((and gnus-keep-backlog
13055 (gnus-backlog-request-article group article (current-buffer)))
13057 ;; Check the cache.
13058 ((and gnus-use-cache
13060 (gnus-cache-request-article article group))
13062 ;; Get the article and put into the article buffer.
13063 ((or (stringp article) (numberp article))
13064 (let ((gnus-override-method
13065 (and (stringp article) gnus-refer-article-method))
13066 (buffer-read-only nil))
13068 (gnus-kill-all-overlays)
13069 (if (gnus-request-article article group (current-buffer))
13071 (and gnus-keep-backlog
13072 (gnus-backlog-enter-article
13073 group article (current-buffer)))
13075 ;; It was a pseudo.
13078 ;; Take the article from the original article buffer
13079 ;; and place it in the buffer it's supposed to be in.
13080 (setq gnus-original-article (cons group article))
13081 (when (and (get-buffer gnus-article-buffer)
13082 (equal (buffer-name (current-buffer))
13083 (buffer-name (get-buffer gnus-article-buffer))))
13085 (if (get-buffer gnus-original-article-buffer)
13086 (set-buffer (get-buffer gnus-original-article-buffer))
13087 (set-buffer (get-buffer-create gnus-original-article-buffer))
13088 (buffer-disable-undo (current-buffer))
13089 (setq major-mode 'gnus-original-article-mode)
13090 (setq buffer-read-only t)
13091 (gnus-add-current-to-buffer-list))
13092 (let (buffer-read-only)
13094 (insert-buffer-substring gnus-article-buffer))))
13096 ;; Update sparse articles.
13097 (when (memq article gnus-newsgroup-sparse)
13098 (gnus-summary-update-article article))))
13100 (defun gnus-read-header (id)
13101 "Read the headers of article ID and enter them into the Gnus system."
13102 (let ((group gnus-newsgroup-name)
13103 (headers gnus-newsgroup-headers)
13105 ;; First we check to see whether the header in question is already
13108 ;; This is a Message-ID.
13109 (setq header (gnus-id-to-header id))
13110 ;; This is an article number.
13111 (setq header (gnus-summary-article-header id)))
13113 ;; We have found the header.
13115 ;; We have to really fetch the header to this article.
13117 (if (gnus-check-backend-function 'request-head group)
13118 (gnus-request-head id group)
13119 (gnus-request-article id group)))
13121 (set-buffer nntp-server-buffer)
13122 (and (search-forward "\n\n" nil t)
13123 (delete-region (1- (point)) (point-max)))
13124 (goto-char (point-max))
13126 (goto-char (point-min))
13135 gnus-reffed-article-number)))
13136 " Article retrieved.\n"))
13137 (if (not (setq header (car (gnus-get-newsgroup-headers))))
13138 () ; Malformed head.
13139 (if (and (stringp id)
13140 (not (string= (gnus-group-real-name group)
13142 ;; If we fetched by Message-ID and the article came
13143 ;; from a different group, we fudge some bogus article
13144 ;; numbers for this article.
13145 (mail-header-set-number header gnus-reffed-article-number))
13146 (decf gnus-reffed-article-number)
13147 (push header gnus-newsgroup-headers)
13148 (setq gnus-current-headers header)
13149 (push (mail-header-number header) gnus-newsgroup-limit)
13152 (defun gnus-article-prepare (article &optional all-headers header)
13153 "Prepare ARTICLE in article mode buffer.
13154 ARTICLE should either be an article number or a Message-ID.
13155 If ARTICLE is an id, HEADER should be the article headers.
13156 If ALL-HEADERS is non-nil, no headers are hidden."
13158 ;; Make sure we start in a summary buffer.
13159 (unless (eq major-mode 'gnus-summary-mode)
13160 (set-buffer gnus-summary-buffer))
13161 (setq gnus-summary-buffer (current-buffer))
13162 ;; Make sure the connection to the server is alive.
13163 (unless (gnus-server-opened
13164 (gnus-find-method-for-group gnus-newsgroup-name))
13165 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
13166 (gnus-request-group gnus-newsgroup-name t))
13167 (let* ((article (if header (mail-header-number header) article))
13168 (summary-buffer (current-buffer))
13169 (internal-hook gnus-article-internal-prepare-hook)
13170 (group gnus-newsgroup-name)
13173 (gnus-article-setup-buffer)
13174 (set-buffer gnus-article-buffer)
13175 ;; Deactivate active regions.
13176 (when (and (boundp 'transient-mark-mode)
13177 transient-mark-mode)
13178 (setq mark-active nil))
13179 (if (not (setq result (let ((buffer-read-only nil))
13180 (gnus-request-article-this-buffer
13182 ;; There is no such article.
13184 (when (and (numberp article)
13185 (not (memq article gnus-newsgroup-sparse)))
13186 (setq gnus-article-current
13187 (cons gnus-newsgroup-name article))
13188 (set-buffer gnus-summary-buffer)
13189 (setq gnus-current-article article)
13190 (gnus-summary-mark-article article gnus-canceled-mark))
13191 (unless (memq article gnus-newsgroup-sparse)
13193 1 "No such article (may have expired or been canceled)")
13196 (if (or (eq result 'pseudo) (eq result 'nneething))
13199 (set-buffer summary-buffer)
13200 (setq gnus-last-article gnus-current-article
13201 gnus-newsgroup-history (cons gnus-current-article
13202 gnus-newsgroup-history)
13203 gnus-current-article 0
13204 gnus-current-headers nil
13205 gnus-article-current nil)
13206 (if (eq result 'nneething)
13207 (gnus-configure-windows 'summary)
13208 (gnus-configure-windows 'article))
13209 (gnus-set-global-variables))
13210 (gnus-set-mode-line 'article))
13211 ;; The result from the `request' was an actual article -
13212 ;; or at least some text that is now displayed in the
13214 (if (and (numberp article)
13215 (not (eq article gnus-current-article)))
13216 ;; Seems like a new article has been selected.
13217 ;; `gnus-current-article' must be an article number.
13219 (set-buffer summary-buffer)
13220 (setq gnus-last-article gnus-current-article
13221 gnus-newsgroup-history (cons gnus-current-article
13222 gnus-newsgroup-history)
13223 gnus-current-article article
13224 gnus-current-headers
13225 (gnus-summary-article-header gnus-current-article)
13226 gnus-article-current
13227 (cons gnus-newsgroup-name gnus-current-article))
13228 (unless (vectorp gnus-current-headers)
13229 (setq gnus-current-headers nil))
13230 (gnus-summary-show-thread)
13231 (run-hooks 'gnus-mark-article-hook)
13232 (gnus-set-mode-line 'summary)
13233 (and (gnus-visual-p 'article-highlight 'highlight)
13234 (run-hooks 'gnus-visual-mark-article-hook))
13235 ;; Set the global newsgroup variables here.
13236 ;; Suggested by Jim Sisolak
13237 ;; <sisolak@trans4.neep.wisc.edu>.
13238 (gnus-set-global-variables)
13239 (setq gnus-have-all-headers
13240 (or all-headers gnus-show-all-headers))
13241 (and gnus-use-cache
13242 (vectorp (gnus-summary-article-header article))
13243 (gnus-cache-possibly-enter-article
13245 (gnus-summary-article-header article)
13246 (memq article gnus-newsgroup-marked)
13247 (memq article gnus-newsgroup-dormant)
13248 (memq article gnus-newsgroup-unreads)))))
13249 ;; Hooks for getting information from the article.
13250 ;; This hook must be called before being narrowed.
13251 (let (buffer-read-only)
13252 (run-hooks 'internal-hook)
13253 (run-hooks 'gnus-article-prepare-hook)
13254 ;; Decode MIME message.
13256 (if (or (not gnus-strict-mime)
13257 (gnus-fetch-field "Mime-Version"))
13258 (funcall gnus-show-mime-method)
13259 (funcall gnus-decode-encoded-word-method)))
13260 ;; Perform the article display hooks.
13261 (run-hooks 'gnus-article-display-hook))
13263 (goto-char (point-min))
13264 (and gnus-break-pages (gnus-narrow-to-page))
13265 (gnus-set-mode-line 'article)
13266 (gnus-configure-windows 'article)
13267 (goto-char (point-min))
13270 (defun gnus-article-show-all-headers ()
13271 "Show all article headers in article mode buffer."
13273 (gnus-article-setup-buffer)
13274 (set-buffer gnus-article-buffer)
13275 (let ((buffer-read-only nil))
13276 (remove-text-properties (point-min) (point-max)
13277 gnus-hidden-properties))))
13279 (defun gnus-article-hide-headers-if-wanted ()
13280 "Hide unwanted headers if `gnus-have-all-headers' is nil.
13281 Provided for backwards compatibility."
13282 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers)
13283 gnus-inhibit-hiding
13284 (gnus-article-hide-headers)))
13286 (defun gnus-article-hide-headers (&optional arg delete)
13287 "Toggle whether to hide unwanted headers and possibly sort them as well.
13288 If given a negative prefix, always show; if given a positive prefix,
13291 (unless (gnus-article-check-hidden-text 'headers arg)
13292 ;; This function might be inhibited.
13293 (unless gnus-inhibit-hiding
13295 (set-buffer gnus-article-buffer)
13297 (let ((buffer-read-only nil)
13298 (ignored (when (not (stringp gnus-visible-headers))
13299 (cond ((stringp gnus-ignored-headers)
13300 gnus-ignored-headers)
13301 ((listp gnus-ignored-headers)
13302 (mapconcat 'identity gnus-ignored-headers
13305 (cond ((stringp gnus-visible-headers)
13306 gnus-visible-headers)
13307 ((and gnus-visible-headers
13308 (listp gnus-visible-headers))
13309 (mapconcat 'identity gnus-visible-headers "\\|"))))
13310 want-list beg want-l)
13311 ;; First we narrow to just the headers.
13313 (goto-char (point-min))
13314 ;; Hide any "From " lines at the beginning of (mail) articles.
13315 (while (looking-at "From ")
13318 (add-text-properties
13319 (point-min) (point)
13320 (nconc (list 'gnus-type 'headers) gnus-hidden-properties)))
13321 ;; Then treat the rest of the header lines.
13324 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
13325 ;; Then we use the two regular expressions
13326 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
13327 ;; select which header lines is to remain visible in the
13329 (goto-char (point-min))
13330 (while (re-search-forward "^[^ \t]*:" nil t)
13331 (beginning-of-line)
13332 ;; We add the headers we want to keep to a list and delete
13333 ;; them from the buffer.
13334 (if (or (and visible (looking-at visible))
13335 (and ignored (not (looking-at ignored))))
13337 (push (buffer-substring
13341 ;; Be sure to get multi-line headers...
13342 (re-search-forward "^[^ \t]*:" nil t)
13343 (beginning-of-line)
13346 (delete-region beg (point)))
13348 ;; Sort the headers that we want to display.
13349 (setq want-list (sort want-list 'gnus-article-header-less))
13350 (goto-char (point-min))
13352 (insert (pop want-list)))
13353 ;; We make the unwanted headers invisible.
13355 (delete-region (point-min) (point-max))
13356 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
13357 (add-text-properties
13358 (point) (point-max)
13359 (nconc (list 'gnus-type 'headers)
13360 gnus-hidden-properties)))))))))
13362 (defsubst gnus-article-header-rank (header)
13363 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
13364 (let ((list gnus-sorted-header-list)
13367 (when (string-match (car list) header)
13369 (setq list (cdr list))
13373 (defun gnus-article-header-less (h1 h2)
13374 "Say whether string H1 is \"less\" than string H2."
13375 (< (gnus-article-header-rank h1)
13376 (gnus-article-header-rank h2)))
13378 (defun gnus-article-hide-boring-headers (&optional arg)
13379 "Toggle hiding of headers that aren't very interesting.
13380 If given a negative prefix, always show; if given a positive prefix,
13383 (unless (gnus-article-check-hidden-text 'boring-headers arg)
13385 (set-buffer gnus-article-buffer)
13387 (let ((buffer-read-only nil)
13388 (list gnus-boring-article-headers)
13389 (inhibit-point-motion-hooks t)
13391 (nnheader-narrow-to-headers)
13393 (setq elem (pop list))
13394 (goto-char (point-min))
13396 ;; Hide empty headers.
13398 (while (re-search-forward "^[^:]+:[ \t]\n[^ \t]" nil t)
13400 (add-text-properties
13401 (progn (beginning-of-line) (point))
13404 (if (re-search-forward "^[^ \t]" nil t)
13405 (match-beginning 0)
13407 (nconc (list 'gnus-type 'boring-headers)
13408 gnus-hidden-properties))))
13409 ;; Hide boring Newsgroups header.
13410 ((eq elem 'newsgroups)
13411 (when (equal (mail-fetch-field "newsgroups")
13412 (gnus-group-real-name gnus-newsgroup-name))
13413 (gnus-article-hide-header "newsgroups")))
13414 ((eq elem 'followup-to)
13415 (when (equal (mail-fetch-field "followup-to")
13416 (mail-fetch-field "newsgroups"))
13417 (gnus-article-hide-header "followup-to")))
13418 ((eq elem 'reply-to)
13419 (let ((from (mail-fetch-field "from"))
13420 (reply-to (mail-fetch-field "reply-to")))
13424 (nth 1 (mail-extract-address-components from))
13425 (nth 1 (mail-extract-address-components reply-to))))
13426 (gnus-article-hide-header "reply-to"))))
13428 (let ((date (mail-fetch-field "date")))
13430 (< (gnus-days-between date (current-time-string))
13432 (gnus-article-hide-header "date")))))))))))
13434 (defun gnus-article-hide-header (header)
13436 (goto-char (point-min))
13437 (when (re-search-forward (concat "^" header ":") nil t)
13438 (add-text-properties
13439 (progn (beginning-of-line) (point))
13442 (if (re-search-forward "^[^ \t]" nil t)
13443 (match-beginning 0)
13445 (nconc (list 'gnus-type 'boring-headers)
13446 gnus-hidden-properties)))))
13448 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
13449 (defun gnus-article-treat-overstrike ()
13450 "Translate overstrikes into bold text."
13453 (set-buffer gnus-article-buffer)
13454 (let ((buffer-read-only nil))
13455 (while (search-forward "\b" nil t)
13456 (let ((next (following-char))
13457 (previous (char-after (- (point) 2))))
13458 (cond ((eq next previous)
13459 (put-text-property (- (point) 2) (point) 'invisible t)
13460 (put-text-property (point) (1+ (point)) 'face 'bold))
13462 (put-text-property (1- (point)) (1+ (point)) 'invisible t)
13464 (- (point) 2) (1- (point)) 'face 'underline))
13466 (put-text-property (- (point) 2) (point) 'invisible t)
13468 (point) (1+ (point)) 'face 'underline))))))))
13470 (defun gnus-article-word-wrap ()
13471 "Format too long lines."
13474 (set-buffer gnus-article-buffer)
13475 (let ((buffer-read-only nil)
13478 (goto-char (point-min))
13479 (search-forward "\n\n" nil t)
13481 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
13482 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
13483 (adaptive-fill-mode t))
13484 (while (not (eobp))
13485 (and (>= (current-column) (min fill-column (window-width)))
13486 (/= (preceding-char) ?:)
13487 (fill-paragraph nil))
13488 (end-of-line 2))))))
13490 (defun gnus-article-remove-cr ()
13491 "Remove carriage returns from an article."
13494 (set-buffer gnus-article-buffer)
13495 (let ((buffer-read-only nil))
13496 (goto-char (point-min))
13497 (while (search-forward "\r" nil t)
13498 (replace-match "" t t)))))
13500 (defun gnus-article-remove-trailing-blank-lines ()
13501 "Remove all trailing blank lines from the article."
13504 (set-buffer gnus-article-buffer)
13505 (let ((buffer-read-only nil))
13506 (goto-char (point-max))
13510 (while (looking-at "^[ \t]*$")
13515 (defun gnus-article-display-x-face (&optional force)
13516 "Look for an X-Face header and display it if present."
13517 (interactive (list 'force))
13519 (set-buffer gnus-article-buffer)
13520 ;; Delete the old process, if any.
13521 (when (process-status "gnus-x-face")
13522 (delete-process "gnus-x-face"))
13523 (let ((inhibit-point-motion-hooks t)
13524 (case-fold-search nil)
13527 (nnheader-narrow-to-headers)
13528 (setq from (mail-fetch-field "from"))
13529 (goto-char (point-min))
13530 (when (and gnus-article-x-face-command
13532 ;; Check whether this face is censored.
13533 (not gnus-article-x-face-too-ugly)
13534 (and gnus-article-x-face-too-ugly from
13535 (not (string-match gnus-article-x-face-too-ugly
13537 ;; Has to be present.
13538 (re-search-forward "^X-Face: " nil t))
13539 ;; We now have the area of the buffer where the X-Face is stored.
13540 (let ((beg (point))
13541 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
13542 ;; We display the face.
13543 (if (symbolp gnus-article-x-face-command)
13544 ;; The command is a lisp function, so we call it.
13545 (if (gnus-functionp gnus-article-x-face-command)
13546 (funcall gnus-article-x-face-command beg end)
13547 (error "%s is not a function" gnus-article-x-face-command))
13548 ;; The command is a string, so we interpret the command
13549 ;; as a, well, command, and fork it off.
13550 (let ((process-connection-type nil))
13551 (process-kill-without-query
13553 "gnus-x-face" nil "sh" "-c" gnus-article-x-face-command))
13554 (process-send-region "gnus-x-face" beg end)
13555 (process-send-eof "gnus-x-face")))))))))
13557 (defun gnus-headers-decode-quoted-printable ()
13558 "Hack to remove QP encoding from headers."
13559 (let ((case-fold-search t)
13560 (inhibit-point-motion-hooks t)
13562 (goto-char (point-min))
13563 (while (re-search-forward "=\\?iso-8859-1\\?q\\?\\([^?\t\n]*\\)\\?=" nil t)
13564 (setq string (match-string 1))
13565 (narrow-to-region (match-beginning 0) (match-end 0))
13566 (delete-region (point-min) (point-max))
13568 (gnus-mime-decode-quoted-printable (goto-char (point-min)) (point-max))
13569 (subst-char-in-region (point-min) (point-max) ?_ ? )
13571 (goto-char (point-min)))))
13573 (defun gnus-article-de-quoted-unreadable (&optional force)
13574 "Do a naive translation of a quoted-printable-encoded article.
13575 This is in no way, shape or form meant as a replacement for real MIME
13576 processing, but is simply a stop-gap measure until MIME support is
13578 If FORCE, decode the article whether it is marked as quoted-printable
13580 (interactive (list 'force))
13582 (set-buffer gnus-article-buffer)
13583 (let ((case-fold-search t)
13584 (buffer-read-only nil)
13585 (type (gnus-fetch-field "content-transfer-encoding")))
13587 (and type (string-match "quoted-printable" type)))
13588 (gnus-headers-decode-quoted-printable)
13589 (goto-char (point-min))
13590 (search-forward "\n\n" nil 'move)
13591 (gnus-mime-decode-quoted-printable (point) (point-max))))))
13593 (defun gnus-mime-decode-quoted-printable (from to)
13594 "Decode Quoted-Printable in the region between FROM and TO."
13596 (while (search-forward "=" to t)
13597 (cond ((eq (following-char) ?\n)
13600 ((looking-at "[0-9A-F][0-9A-F]")
13602 (insert (hexl-hex-string-to-integer
13603 (buffer-substring (point) (+ 2 (point)))))
13607 ((gnus-message 3 "Malformed MIME quoted-printable message")))))
13609 (defun gnus-article-hide-pgp (&optional arg)
13610 "Toggle hiding of any PGP headers and signatures in the current article.
13611 If given a negative prefix, always show; if given a positive prefix,
13614 (unless (gnus-article-check-hidden-text 'pgp arg)
13616 (set-buffer gnus-article-buffer)
13617 (let ((props (nconc (list 'gnus-type 'pgp) gnus-hidden-properties))
13618 buffer-read-only beg end)
13620 (goto-char (point-min))
13621 ;; Hide the "header".
13622 (and (search-forward "\n-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
13623 (add-text-properties (match-beginning 0) (match-end 0) props))
13625 ;; Hide the actual signature.
13626 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
13627 (setq end (match-beginning 0))
13628 (add-text-properties
13629 (match-beginning 0)
13630 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
13632 ;; Perhaps we shouldn't hide to the end of the buffer
13633 ;; if there is no end to the signature?
13636 ;; Hide "- " PGP quotation markers.
13637 (when (and beg end)
13638 (narrow-to-region beg end)
13639 (goto-char (point-min))
13640 (while (re-search-forward "^- " nil t)
13641 (add-text-properties (match-beginning 0) (match-end 0) props))
13644 (defun gnus-article-hide-signature (&optional arg)
13645 "Hide the signature in the current article.
13646 If given a negative prefix, always show; if given a positive prefix,
13649 (unless (gnus-article-check-hidden-text 'signature arg)
13651 (set-buffer gnus-article-buffer)
13653 (let ((buffer-read-only nil))
13654 (when (gnus-narrow-to-signature)
13655 (add-text-properties
13656 (point-min) (point-max)
13657 (nconc (list 'gnus-type 'signature)
13658 gnus-hidden-properties))))))))
13660 (defvar gnus-signature-limit nil
13661 "Provide a limit to what is considered a signature.
13662 If it is a number, no signature may not be longer (in characters) than
13663 that number. If it is a function, the function will be called without
13664 any parameters, and if it returns nil, there is no signature in the
13665 buffer. If it is a string, it will be used as a regexp. If it
13666 matches, the text in question is not a signature.")
13668 (defun gnus-narrow-to-signature ()
13669 "Narrow to the signature."
13671 (goto-char (point-max))
13672 (when (re-search-backward gnus-signature-separator nil t)
13674 (when (or (null gnus-signature-limit)
13675 (and (numberp gnus-signature-limit)
13676 (< (- (point-max) (point)) gnus-signature-limit))
13677 (and (gnus-functionp gnus-signature-limit)
13678 (funcall gnus-signature-limit))
13679 (and (stringp gnus-signature-limit)
13680 (not (re-search-forward gnus-signature-limit nil t))))
13681 (narrow-to-region (point) (point-max))
13684 (defun gnus-article-check-hidden-text (type arg)
13685 "Return nil if hiding is necessary."
13687 (set-buffer gnus-article-buffer)
13688 (let ((hide (gnus-article-hidden-text-p type)))
13689 (cond ((or (and (null arg) (eq hide 'hidden))
13690 (and arg (< 0 (prefix-numeric-value arg))))
13691 (gnus-article-show-hidden-text type))
13693 (gnus-article-show-hidden-text type t))
13696 (defun gnus-article-hidden-text-p (type)
13697 "Say whether the current buffer contains hidden text of type TYPE."
13698 (let ((pos (text-property-any (point-min) (point-max) 'gnus-type type))
13701 (if (get-text-property pos 'invisible)
13705 (defun gnus-article-hide (&optional arg force)
13706 "Hide all the gruft in the current article.
13707 This means that PGP stuff, signatures, cited text and (some)
13708 headers will be hidden.
13709 If given a prefix, show the hidden text instead."
13710 (interactive (list current-prefix-arg 'force))
13711 (gnus-article-hide-headers arg)
13712 (gnus-article-hide-pgp arg)
13713 (gnus-article-hide-citation-maybe arg force)
13714 (gnus-article-hide-signature arg))
13716 (defun gnus-article-show-hidden-text (type &optional hide)
13717 "Show all hidden text of type TYPE.
13718 If HIDE, hide the text instead."
13720 (set-buffer gnus-article-buffer)
13721 (let ((buffer-read-only nil)
13722 (inhibit-point-motion-hooks t)
13724 (while (gnus-goto-char (text-property-any
13725 beg (point-max) 'gnus-type type))
13729 (add-text-properties beg (point) gnus-hidden-properties)
13730 (remove-text-properties beg (point) gnus-hidden-properties))
13731 (setq beg (point)))
13734 (defvar gnus-article-time-units
13735 `((year . ,(* 365.25 24 60 60))
13736 (week . ,(* 7 24 60 60))
13737 (day . ,(* 24 60 60))
13738 (hour . ,(* 60 60))
13741 "Mapping from time units to seconds.")
13743 (defun gnus-article-date-ut (&optional type highlight)
13744 "Convert DATE date to universal time in the current article.
13745 If TYPE is `local', convert to local time; if it is `lapsed', output
13746 how much time has lapsed since DATE."
13747 (interactive (list 'ut t))
13748 (let* ((header (or gnus-current-headers
13749 (gnus-summary-article-header) ""))
13750 (date (and (vectorp header) (mail-header-date header)))
13751 (date-regexp "^Date: \\|^X-Sent: ")
13752 (now (current-time))
13753 (inhibit-point-motion-hooks t))
13754 (when (and date (not (string= date "")))
13756 (set-buffer gnus-article-buffer)
13758 (nnheader-narrow-to-headers)
13759 (let ((buffer-read-only nil))
13760 ;; Delete any old Date headers.
13761 (if (zerop (nnheader-remove-header date-regexp t))
13762 (beginning-of-line)
13763 (goto-char (point-max)))
13766 ;; Convert to the local timezone. We have to slap a
13767 ;; `condition-case' round the calls to the timezone
13768 ;; functions since they aren't particularly resistant to
13771 (concat "Date: " (condition-case ()
13772 (timezone-make-date-arpa-standard date)
13775 ;; Convert to Universal Time.
13779 (timezone-make-date-arpa-standard date nil "UT")
13782 ;; Get the original date from the article.
13783 ((eq type 'original)
13784 (concat "Date: " date "\n"))
13785 ;; Do an X-Sent lapsed format.
13787 ;; If the date is seriously mangled, the timezone
13788 ;; functions are liable to bug out, so we condition-case
13789 ;; the entire thing.
13794 (timezone-make-date-arpa-standard
13795 (current-time-string now)
13796 (current-time-zone now) "UT"))
13798 (timezone-make-date-arpa-standard
13801 (real-sec (+ (* (float (car real-time)) 65536)
13803 (sec (abs real-sec))
13809 ;; This is a bit convoluted, but basically we go
13810 ;; through the time units for years, weeks, etc,
13811 ;; and divide things to see whether that results
13812 ;; in positive answers.
13815 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
13816 ;; The (remaining) seconds are too few to
13817 ;; be divided into this time unit.
13819 ;; It's big enough, so we output it.
13820 (setq sec (- sec (* num (cdr unit))))
13822 (concat (if prev ", " "") (int-to-string
13824 " " (symbol-name (car unit))
13825 (if (> num 1) "s" ""))
13827 gnus-article-time-units "")
13828 ;; If dates are odd, then it might appear like the
13829 ;; article was sent in the future.
13832 " in the future\n")))))
13834 (error "Unknown conversion type: %s" type)))))
13835 ;; Do highlighting.
13836 (when (and highlight (gnus-visual-p 'article-highlight 'highlight))
13837 (gnus-article-highlight-headers)))))))
13839 (defun gnus-article-date-local (&optional highlight)
13840 "Convert the current article date to the local timezone."
13841 (interactive (list t))
13842 (gnus-article-date-ut 'local highlight))
13844 (defun gnus-article-date-original (&optional highlight)
13845 "Convert the current article date to what it was originally.
13846 This is only useful if you have used some other date conversion
13847 function and want to see what the date was before converting."
13848 (interactive (list t))
13849 (gnus-article-date-ut 'original highlight))
13851 (defun gnus-article-date-lapsed (&optional highlight)
13852 "Convert the current article date to time lapsed since it was sent."
13853 (interactive (list t))
13854 (gnus-article-date-ut 'lapsed highlight))
13856 (defun gnus-article-maybe-highlight ()
13857 "Do some article highlighting if `gnus-visual' is non-nil."
13858 (if (gnus-visual-p 'article-highlight 'highlight)
13859 (gnus-article-highlight-some)))
13863 (defun gnus-output-to-rmail (file-name)
13864 "Append the current article to an Rmail file named FILE-NAME."
13866 ;; Most of these codes are borrowed from rmailout.el.
13867 (setq file-name (expand-file-name file-name))
13868 (setq rmail-default-rmail-file file-name)
13869 (let ((artbuf (current-buffer))
13870 (tmpbuf (get-buffer-create " *Gnus-output*")))
13872 (or (get-file-buffer file-name)
13873 (file-exists-p file-name)
13874 (if (gnus-yes-or-no-p
13875 (concat "\"" file-name "\" does not exist, create it? "))
13876 (let ((file-buffer (create-file-buffer file-name)))
13878 (set-buffer file-buffer)
13879 (rmail-insert-rmail-file-header)
13880 (let ((require-final-newline nil))
13881 (write-region (point-min) (point-max) file-name t 1)))
13882 (kill-buffer file-buffer))
13883 (error "Output file does not exist")))
13884 (set-buffer tmpbuf)
13885 (buffer-disable-undo (current-buffer))
13887 (insert-buffer-substring artbuf)
13888 (gnus-convert-article-to-rmail)
13889 ;; Decide whether to append to a file or to an Emacs buffer.
13890 (let ((outbuf (get-file-buffer file-name)))
13892 (append-to-file (point-min) (point-max) file-name)
13893 ;; File has been visited, in buffer OUTBUF.
13894 (set-buffer outbuf)
13895 (let ((buffer-read-only nil)
13896 (msg (and (boundp 'rmail-current-message)
13897 (symbol-value 'rmail-current-message))))
13898 ;; If MSG is non-nil, buffer is in RMAIL mode.
13901 (narrow-to-region (point-max) (point-max))))
13902 (insert-buffer-substring tmpbuf)
13905 (goto-char (point-min))
13907 (search-backward "\^_")
13908 (narrow-to-region (point) (point-max))
13909 (goto-char (1+ (point-min)))
13910 (rmail-count-new-messages t)
13911 (rmail-show-message msg)))))))
13912 (kill-buffer tmpbuf)))
13914 (defun gnus-output-to-file (file-name)
13915 "Append the current article to a file named FILE-NAME."
13916 (setq file-name (expand-file-name file-name))
13917 (let ((artbuf (current-buffer))
13918 (tmpbuf (get-buffer-create " *Gnus-output*")))
13920 (set-buffer tmpbuf)
13921 (buffer-disable-undo (current-buffer))
13923 (insert-buffer-substring artbuf)
13924 ;; Append newline at end of the buffer as separator, and then
13925 ;; save it to file.
13926 (goto-char (point-max))
13928 (append-to-file (point-min) (point-max) file-name))
13929 (kill-buffer tmpbuf)))
13931 (defun gnus-convert-article-to-rmail ()
13932 "Convert article in current buffer to Rmail message format."
13933 (let ((buffer-read-only nil))
13934 ;; Convert article directly into Babyl format.
13935 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
13936 (goto-char (point-min))
13937 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
13938 (while (search-forward "\n\^_" nil t) ;single char
13939 (replace-match "\n^_" t t)) ;2 chars: "^" and "_"
13940 (goto-char (point-max))
13943 (defun gnus-narrow-to-page (&optional arg)
13944 "Narrow the article buffer to a page.
13945 If given a numerical ARG, move forward ARG pages."
13947 (setq arg (if arg (prefix-numeric-value arg) 0))
13949 (set-buffer gnus-article-buffer)
13950 (goto-char (point-min))
13952 (when (gnus-visual-p 'page-marker)
13953 (let ((buffer-read-only nil))
13954 (gnus-remove-text-with-property 'gnus-prev)
13955 (gnus-remove-text-with-property 'gnus-next)))
13958 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
13960 (re-search-forward page-delimiter nil 'move arg)))
13961 (goto-char (match-end 0)))
13964 (if (re-search-forward page-delimiter nil 'move)
13965 (match-beginning 0)
13967 (when (and (gnus-visual-p 'page-marker)
13968 (not (= (point-min) 1)))
13970 (goto-char (point-min))
13971 (gnus-insert-prev-page-button)))
13972 (when (and (gnus-visual-p 'page-marker)
13973 (not (= (1- (point-max)) (buffer-size))))
13975 (goto-char (point-max))
13976 (gnus-insert-next-page-button)))))
13978 ;; Article mode commands
13980 (defun gnus-article-goto-next-page ()
13981 "Show the next page of the article."
13983 (when (gnus-article-next-page)
13984 (gnus-article-read-summary-keys nil ?n)))
13986 (defun gnus-article-goto-prev-page ()
13987 "Show the next page of the article."
13989 (if (bobp) (gnus-article-read-summary-keys nil ?n)
13990 (gnus-article-prev-page nil)))
13992 (defun gnus-article-next-page (&optional lines)
13993 "Show the next page of the current article.
13994 If end of article, return non-nil. Otherwise return nil.
13995 Argument LINES specifies lines to be scrolled up."
13997 (move-to-window-line -1)
13998 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
13999 (if (save-excursion
14001 (and (pos-visible-in-window-p) ;Not continuation line.
14003 ;; Nothing in this page.
14004 (if (or (not gnus-break-pages)
14007 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
14009 (gnus-narrow-to-page 1) ;Go to next page.
14011 ;; More in this page.
14015 ;; Long lines may cause an end-of-buffer error.
14016 (goto-char (point-max))))
14019 (defun gnus-article-prev-page (&optional lines)
14020 "Show previous page of current article.
14021 Argument LINES specifies lines to be scrolled down."
14023 (move-to-window-line 0)
14024 (if (and gnus-break-pages
14026 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
14028 (gnus-narrow-to-page -1) ;Go to previous page.
14029 (goto-char (point-max))
14032 (scroll-down lines)
14035 (defun gnus-article-refer-article ()
14036 "Read article specified by message-id around point."
14038 (let ((point (point)))
14039 (search-forward ">" nil t) ;Move point to end of "<....>".
14040 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
14041 (let ((message-id (match-string 1)))
14043 (set-buffer gnus-summary-buffer)
14044 (gnus-summary-refer-article message-id))
14045 (goto-char (point))
14046 (error "No references around point"))))
14048 (defun gnus-article-show-summary ()
14049 "Reconfigure windows to show summary buffer."
14051 (gnus-configure-windows 'article)
14052 (gnus-summary-goto-subject gnus-current-article))
14054 (defun gnus-article-describe-briefly ()
14055 "Describe article mode commands briefly."
14058 (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")))
14060 (defun gnus-article-summary-command ()
14061 "Execute the last keystroke in the summary buffer."
14063 (let ((obuf (current-buffer))
14064 (owin (current-window-configuration))
14066 (switch-to-buffer gnus-summary-buffer 'norecord)
14067 (setq func (lookup-key (current-local-map) (this-command-keys)))
14068 (call-interactively func)
14070 (set-window-configuration owin)
14071 (set-window-point (get-buffer-window (current-buffer)) (point))))
14073 (defun gnus-article-summary-command-nosave ()
14074 "Execute the last keystroke in the summary buffer."
14077 (pop-to-buffer gnus-summary-buffer 'norecord)
14078 (setq func (lookup-key (current-local-map) (this-command-keys)))
14079 (call-interactively func)))
14081 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
14082 "Read a summary buffer key sequence and execute it from the article buffer."
14085 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
14086 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
14090 (set-buffer gnus-summary-buffer)
14091 (push (or key last-command-event) unread-command-events)
14092 (setq keys (read-key-sequence nil)))
14095 (if (member keys nosaves)
14097 (pop-to-buffer gnus-summary-buffer 'norecord)
14098 (if (setq func (lookup-key (current-local-map) keys))
14099 (call-interactively func)
14101 (let ((obuf (current-buffer))
14102 (owin (current-window-configuration))
14105 (if not-restore-window
14106 (pop-to-buffer gnus-summary-buffer 'norecord)
14107 (switch-to-buffer gnus-summary-buffer 'norecord))
14108 (setq in-buffer (current-buffer))
14109 (if (setq func (lookup-key (current-local-map) keys))
14110 (call-interactively func)
14112 (when (eq in-buffer (current-buffer))
14114 (unless not-restore-window
14115 (set-window-configuration owin))
14116 (set-window-point (get-buffer-window (current-buffer)) opoint))))))
14120 ;;; Kill file handling.
14124 (defalias 'gnus-batch-kill 'gnus-batch-score)
14126 (defun gnus-batch-score ()
14127 "Run batched scoring.
14128 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
14129 Newsgroups is a list of strings in Bnews format. If you want to score
14130 the comp hierarchy, you'd say \"comp.all\". If you would not like to
14131 score the alt hierarchy, you'd say \"!alt.all\"."
14134 (gnus-newsrc-parse-options
14135 (apply (function concat)
14136 (mapcar (lambda (g) (concat g " "))
14137 command-line-args-left))))
14138 (gnus-expert-user t)
14139 (nnmail-spool-file nil)
14140 (gnus-use-dribble-file nil)
14141 (yes (car yes-and-no))
14142 (no (cdr yes-and-no))
14144 ;; Disable verbose message.
14145 gnus-novice-user gnus-large-newsgroup)
14146 ;; Eat all arguments.
14147 (setq command-line-args-left nil)
14150 ;; Apply kills to specified newsgroups in command line arguments.
14151 (setq newsrc (cdr gnus-newsrc-alist))
14153 (setq group (car (car newsrc)))
14154 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
14155 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed)
14157 (or (eq (car entry) t)
14158 (not (zerop (car entry)))))
14159 (if yes (string-match yes group) t)
14160 (or (null no) (not (string-match no group))))
14162 (gnus-summary-read-group group nil t nil t)
14163 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
14164 (gnus-summary-exit))))
14165 (setq newsrc (cdr newsrc)))
14167 (switch-to-buffer gnus-group-buffer)
14168 (gnus-group-save-newsrc)))
14170 (defun gnus-apply-kill-file ()
14171 "Apply a kill file to the current newsgroup.
14172 Returns the number of articles marked as read."
14173 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
14174 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14175 (gnus-apply-kill-file-internal)
14178 (defun gnus-kill-save-kill-buffer ()
14179 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14180 (when (get-file-buffer file)
14182 (set-buffer (get-file-buffer file))
14183 (and (buffer-modified-p) (save-buffer))
14184 (kill-buffer (current-buffer))))))
14186 (defvar gnus-kill-file-name "KILL"
14187 "Suffix of the kill files.")
14189 (defun gnus-newsgroup-kill-file (newsgroup)
14190 "Return the name of a kill file name for NEWSGROUP.
14191 If NEWSGROUP is nil, return the global kill file name instead."
14193 ;; The global KILL file is placed at top of the directory.
14194 ((or (null newsgroup)
14195 (string-equal newsgroup ""))
14196 (expand-file-name gnus-kill-file-name
14197 (or gnus-kill-files-directory "~/News")))
14198 ;; Append ".KILL" to newsgroup name.
14199 ((gnus-use-long-file-name 'not-kill)
14200 (expand-file-name (concat (gnus-newsgroup-savable-name newsgroup)
14201 "." gnus-kill-file-name)
14202 (or gnus-kill-files-directory "~/News")))
14203 ;; Place "KILL" under the hierarchical directory.
14205 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
14206 "/" gnus-kill-file-name)
14207 (or gnus-kill-files-directory "~/News")))))
14214 (defvar gnus-dribble-ignore nil)
14215 (defvar gnus-dribble-eval-file nil)
14217 (defun gnus-dribble-file-name ()
14218 "Return the dribble file for the current .newsrc."
14220 (if gnus-dribble-directory
14221 (concat (file-name-as-directory gnus-dribble-directory)
14222 (file-name-nondirectory gnus-current-startup-file))
14223 gnus-current-startup-file)
14226 (defun gnus-dribble-enter (string)
14227 "Enter STRING into the dribble buffer."
14228 (if (and (not gnus-dribble-ignore)
14229 gnus-dribble-buffer
14230 (buffer-name gnus-dribble-buffer))
14231 (let ((obuf (current-buffer)))
14232 (set-buffer gnus-dribble-buffer)
14233 (insert string "\n")
14234 (set-window-point (get-buffer-window (current-buffer)) (point-max))
14235 (set-buffer obuf))))
14237 (defun gnus-dribble-read-file ()
14238 "Read the dribble file from disk."
14239 (let ((dribble-file (gnus-dribble-file-name)))
14241 (set-buffer (setq gnus-dribble-buffer
14243 (file-name-nondirectory dribble-file))))
14244 (gnus-add-current-to-buffer-list)
14246 (setq buffer-file-name dribble-file)
14248 (buffer-disable-undo (current-buffer))
14249 (bury-buffer (current-buffer))
14250 (set-buffer-modified-p nil)
14251 (let ((auto (make-auto-save-file-name))
14252 (gnus-dribble-ignore t))
14253 (when (or (file-exists-p auto) (file-exists-p dribble-file))
14254 ;; Load whichever file is newest -- the auto save file
14255 ;; or the "real" file.
14256 (if (file-newer-than-file-p auto dribble-file)
14257 (insert-file-contents auto)
14258 (insert-file-contents dribble-file))
14259 (unless (zerop (buffer-size))
14260 (set-buffer-modified-p t))
14261 ;; Set the file modes to reflect the .newsrc file modes.
14263 (when (file-exists-p gnus-current-startup-file)
14264 (set-file-modes dribble-file
14265 (file-modes gnus-current-startup-file)))
14266 ;; Possibly eval the file later.
14267 (when (gnus-y-or-n-p
14268 "Auto-save file exists. Do you want to read it? ")
14269 (setq gnus-dribble-eval-file t)))))))
14271 (defun gnus-dribble-eval-file ()
14272 (if (not gnus-dribble-eval-file)
14274 (setq gnus-dribble-eval-file nil)
14276 (let ((gnus-dribble-ignore t))
14277 (set-buffer gnus-dribble-buffer)
14278 (eval-buffer (current-buffer))))))
14280 (defun gnus-dribble-delete-file ()
14281 (if (file-exists-p (gnus-dribble-file-name))
14282 (delete-file (gnus-dribble-file-name)))
14283 (if gnus-dribble-buffer
14285 (set-buffer gnus-dribble-buffer)
14286 (let ((auto (make-auto-save-file-name)))
14287 (if (file-exists-p auto)
14288 (delete-file auto))
14290 (set-buffer-modified-p nil)))))
14292 (defun gnus-dribble-save ()
14293 (if (and gnus-dribble-buffer
14294 (buffer-name gnus-dribble-buffer))
14296 (set-buffer gnus-dribble-buffer)
14299 (defun gnus-dribble-clear ()
14301 (if (gnus-buffer-exists-p gnus-dribble-buffer)
14303 (set-buffer gnus-dribble-buffer)
14305 (set-buffer-modified-p nil)
14306 (setq buffer-saved-size (buffer-size))))))
14310 ;;; Server Communication
14313 (defun gnus-start-news-server (&optional confirm)
14314 "Open a method for getting news.
14315 If CONFIRM is non-nil, the user will be asked for an NNTP server."
14317 (if gnus-current-select-method
14318 ;; Stream is already opened.
14320 ;; Open NNTP server.
14321 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
14324 ;; Read server name with completion.
14325 (setq gnus-nntp-server
14326 (completing-read "NNTP server: "
14327 (mapcar (lambda (server) (list server))
14328 (cons (list gnus-nntp-server)
14329 gnus-secondary-servers))
14330 nil nil gnus-nntp-server))))
14332 (if (and gnus-nntp-server
14333 (stringp gnus-nntp-server)
14334 (not (string= gnus-nntp-server "")))
14335 (setq gnus-select-method
14336 (cond ((or (string= gnus-nntp-server "")
14337 (string= gnus-nntp-server "::"))
14338 (list 'nnspool (system-name)))
14339 ((string-match "^:" gnus-nntp-server)
14340 (list 'nnmh gnus-nntp-server
14341 (list 'nnmh-directory
14342 (file-name-as-directory
14344 (concat "~/" (substring
14345 gnus-nntp-server 1)))))
14346 (list 'nnmh-get-new-mail nil)))
14348 (list 'nntp gnus-nntp-server)))))
14350 (setq how (car gnus-select-method))
14351 (cond ((eq how 'nnspool)
14353 (gnus-message 5 "Looking up local news spool..."))
14356 (gnus-message 5 "Looking up mh spool..."))
14359 (setq gnus-current-select-method gnus-select-method)
14360 (run-hooks 'gnus-open-server-hook)
14362 ;; gnus-open-server-hook might have opened it
14363 (gnus-server-opened gnus-select-method)
14364 (gnus-open-server gnus-select-method)
14367 "%s (%s) open error: '%s'. Continue? "
14368 (car gnus-select-method) (cadr gnus-select-method)
14369 (gnus-status-message gnus-select-method)))
14371 (gnus-message 1 "Couldn't open server on %s"
14372 (nth 1 gnus-select-method))
14376 (defun gnus-check-group (group)
14377 "Try to make sure that the server where GROUP exists is alive."
14378 (let ((method (gnus-find-method-for-group group)))
14379 (or (gnus-server-opened method)
14380 (gnus-open-server method))))
14382 (defun gnus-check-server (&optional method)
14383 "Check whether the connection to METHOD is down.
14384 If METHOD is nil, use `gnus-select-method'.
14385 If it is down, start it up (again)."
14386 (let ((method (or method gnus-select-method)))
14387 ;; Transform virtual server names into select methods.
14388 (when (stringp method)
14389 (setq method (gnus-server-to-method method)))
14390 (if (gnus-server-opened method)
14391 ;; The stream is already opened.
14393 ;; Open the server.
14394 (gnus-message 5 "Opening %s server%s..." (car method)
14395 (if (equal (nth 1 method) "") ""
14396 (format " on %s" (nth 1 method))))
14397 (run-hooks 'gnus-open-server-hook)
14399 (gnus-open-server method)
14402 (defun gnus-get-function (method function)
14403 "Return a function symbol based on METHOD and FUNCTION."
14404 ;; Translate server names into methods.
14406 (error "Attempted use of a nil select method"))
14407 (when (stringp method)
14408 (setq method (gnus-server-to-method method)))
14409 (let ((func (intern (format "%s-%s" (car method) function))))
14410 ;; If the functions isn't bound, we require the backend in
14412 (unless (fboundp func)
14413 (require (car method))
14414 (unless (fboundp func)
14415 ;; This backend doesn't implement this function.
14416 (error "No such function: %s" func)))
14421 ;;; Interface functions to the backends.
14424 (defun gnus-open-server (method)
14425 "Open a connection to METHOD."
14426 (let ((elem (assoc method gnus-opened-servers)))
14427 ;; If this method was previously denied, we just return nil.
14428 (if (eq (nth 1 elem) 'denied)
14430 (gnus-message 1 "Denied server")
14432 ;; Open the server.
14434 (funcall (gnus-get-function method 'open-server)
14435 (nth 1 method) (nthcdr 2 method))))
14436 ;; If this hasn't been opened before, we add it to the list.
14438 (setq elem (list method nil)
14439 gnus-opened-servers (cons elem gnus-opened-servers)))
14440 ;; Set the status of this server.
14441 (setcar (cdr elem) (if result 'ok 'denied))
14442 ;; Return the result from the "open" call.
14445 (defun gnus-close-server (method)
14446 "Close the connection to METHOD."
14447 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
14449 (defun gnus-request-list (method)
14450 "Request the active file from METHOD."
14451 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
14453 (defun gnus-request-list-newsgroups (method)
14454 "Request the newsgroups file from METHOD."
14455 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
14457 (defun gnus-request-newgroups (date method)
14458 "Request all new groups since DATE from METHOD."
14459 (funcall (gnus-get-function method 'request-newgroups)
14460 date (nth 1 method)))
14462 (defun gnus-server-opened (method)
14463 "Check whether a connection to METHOD has been opened."
14464 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
14466 (defun gnus-status-message (method)
14467 "Return the status message from METHOD.
14468 If METHOD is a string, it is interpreted as a group name. The method
14469 this group uses will be queried."
14470 (let ((method (if (stringp method) (gnus-find-method-for-group method)
14472 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
14474 (defun gnus-request-group (group &optional dont-check method)
14475 "Request GROUP. If DONT-CHECK, no information is required."
14476 (let ((method (or method (gnus-find-method-for-group group))))
14477 (funcall (gnus-get-function method 'request-group)
14478 (gnus-group-real-name group) (nth 1 method) dont-check)))
14480 (defun gnus-request-asynchronous (group &optional articles)
14481 "Request that GROUP behave asynchronously.
14482 ARTICLES is the `data' of the group."
14483 (let ((method (gnus-find-method-for-group group)))
14484 (funcall (gnus-get-function method 'request-asynchronous)
14485 (gnus-group-real-name group) (nth 1 method) articles)))
14487 (defun gnus-list-active-group (group)
14488 "Request active information on GROUP."
14489 (let ((method (gnus-find-method-for-group group))
14490 (func 'list-active-group))
14491 (when (gnus-check-backend-function func group)
14492 (funcall (gnus-get-function method func)
14493 (gnus-group-real-name group) (nth 1 method)))))
14495 (defun gnus-request-group-description (group)
14496 "Request a description of GROUP."
14497 (let ((method (gnus-find-method-for-group group))
14498 (func 'request-group-description))
14499 (when (gnus-check-backend-function func group)
14500 (funcall (gnus-get-function method func)
14501 (gnus-group-real-name group) (nth 1 method)))))
14503 (defun gnus-close-group (group)
14504 "Request the GROUP be closed."
14505 (let ((method (gnus-find-method-for-group group)))
14506 (funcall (gnus-get-function method 'close-group)
14507 (gnus-group-real-name group) (nth 1 method))))
14509 (defun gnus-retrieve-headers (articles group &optional fetch-old)
14510 "Request headers for ARTICLES in GROUP.
14511 If FETCH-OLD, retrieve all headers (or some subset thereof) in the group."
14512 (let ((method (gnus-find-method-for-group group)))
14513 (if (and gnus-use-cache (numberp (car articles)))
14514 (gnus-cache-retrieve-headers articles group fetch-old)
14515 (funcall (gnus-get-function method 'retrieve-headers)
14516 articles (gnus-group-real-name group) (nth 1 method)
14519 (defun gnus-retrieve-groups (groups method)
14520 "Request active information on GROUPS from METHOD."
14521 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method)))
14523 (defun gnus-request-type (group &optional article)
14524 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
14525 (let ((method (gnus-find-method-for-group group)))
14526 (if (not (gnus-check-backend-function 'request-type (car method)))
14528 (funcall (gnus-get-function method 'request-type)
14529 (gnus-group-real-name group) article))))
14531 (defun gnus-request-update-mark (group article mark)
14532 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
14533 (let ((method (gnus-find-method-for-group group)))
14534 (if (not (gnus-check-backend-function 'request-update-mark (car method)))
14536 (funcall (gnus-get-function method 'request-update-mark)
14537 (gnus-group-real-name group) article mark))))
14539 (defun gnus-request-article (article group &optional buffer)
14540 "Request the ARTICLE in GROUP.
14541 ARTICLE can either be an article number or an article Message-ID.
14542 If BUFFER, insert the article in that group."
14543 (let ((method (gnus-find-method-for-group group)))
14544 (funcall (gnus-get-function method 'request-article)
14545 article (gnus-group-real-name group) (nth 1 method) buffer)))
14547 (defun gnus-request-head (article group)
14548 "Request the head of ARTICLE in GROUP."
14549 (let ((method (gnus-find-method-for-group group)))
14550 (funcall (gnus-get-function method 'request-head)
14551 article (gnus-group-real-name group) (nth 1 method))))
14553 (defun gnus-request-body (article group)
14554 "Request the body of ARTICLE in GROUP."
14555 (let ((method (gnus-find-method-for-group group)))
14556 (funcall (gnus-get-function method 'request-body)
14557 article (gnus-group-real-name group) (nth 1 method))))
14559 (defun gnus-request-post (method)
14560 "Post the current buffer using METHOD."
14561 (funcall (gnus-get-function method 'request-post) (nth 1 method)))
14563 (defun gnus-request-scan (group method)
14564 "Request a SCAN being performed in GROUP from METHOD.
14565 If GROUP is nil, all groups on METHOD are scanned."
14566 (let ((method (if group (gnus-find-method-for-group group) method)))
14567 (funcall (gnus-get-function method 'request-scan)
14568 (and group (gnus-group-real-name group)) (nth 1 method))))
14570 (defsubst gnus-request-update-info (info method)
14571 "Request that METHOD update INFO."
14572 (when (gnus-check-backend-function 'request-update-info (car method))
14573 (funcall (gnus-get-function method 'request-update-info)
14574 (gnus-group-real-name (gnus-info-group info))
14575 info (nth 1 method))))
14577 (defun gnus-request-expire-articles (articles group &optional force)
14578 (let ((method (gnus-find-method-for-group group)))
14579 (funcall (gnus-get-function method 'request-expire-articles)
14580 articles (gnus-group-real-name group) (nth 1 method)
14583 (defun gnus-request-move-article
14584 (article group server accept-function &optional last)
14585 (let ((method (gnus-find-method-for-group group)))
14586 (funcall (gnus-get-function method 'request-move-article)
14587 article (gnus-group-real-name group)
14588 (nth 1 method) accept-function last)))
14590 (defun gnus-request-accept-article (group &optional last method)
14591 ;; Make sure there's a newline at the end of the article.
14592 (goto-char (point-max))
14595 (let ((func (if (symbolp group) group
14596 (car (or method (gnus-find-method-for-group group))))))
14597 (funcall (intern (format "%s-request-accept-article" func))
14598 (if (stringp group) (gnus-group-real-name group) group)
14601 (defun gnus-request-replace-article (article group buffer)
14602 (let ((func (car (gnus-find-method-for-group group))))
14603 (funcall (intern (format "%s-request-replace-article" func))
14604 article (gnus-group-real-name group) buffer)))
14606 (defun gnus-request-associate-buffer (group)
14607 (let ((method (gnus-find-method-for-group group)))
14608 (funcall (gnus-get-function method 'request-associate-buffer)
14609 (gnus-group-real-name group))))
14611 (defun gnus-request-restore-buffer (article group)
14612 "Request a new buffer restored to the state of ARTICLE."
14613 (let ((method (gnus-find-method-for-group group)))
14614 (funcall (gnus-get-function method 'request-restore-buffer)
14615 article (gnus-group-real-name group) (nth 1 method))))
14617 (defun gnus-request-create-group (group &optional method)
14618 (let ((method (or method (gnus-find-method-for-group group))))
14619 (funcall (gnus-get-function method 'request-create-group)
14620 (gnus-group-real-name group) (nth 1 method))))
14622 (defun gnus-request-delete-group (group &optional force)
14623 (let ((method (gnus-find-method-for-group group)))
14624 (funcall (gnus-get-function method 'request-delete-group)
14625 (gnus-group-real-name group) force (nth 1 method))))
14627 (defun gnus-request-rename-group (group new-name)
14628 (let ((method (gnus-find-method-for-group group)))
14629 (funcall (gnus-get-function method 'request-rename-group)
14630 (gnus-group-real-name group)
14631 (gnus-group-real-name new-name) (nth 1 method))))
14633 (defun gnus-member-of-valid (symbol group)
14634 "Find out if GROUP has SYMBOL as part of its \"valid\" spec."
14635 (memq symbol (assoc
14636 (symbol-name (car (gnus-find-method-for-group group)))
14637 gnus-valid-select-methods)))
14639 (defun gnus-method-option-p (method option)
14640 "Return non-nil if select METHOD has OPTION as a parameter."
14641 (memq option (assoc (format "%s" (car method))
14642 gnus-valid-select-methods)))
14644 (defun gnus-server-extend-method (group method)
14645 ;; This function "extends" a virtual server. If the server is
14646 ;; "hello", and the select method is ("hello" (my-var "something"))
14647 ;; in the group "alt.alt", this will result in a new virtual server
14648 ;; called "hello+alt.alt".
14650 (gnus-copy-sequence
14651 (if (equal (car method) "native") gnus-select-method
14652 (cdr (assoc (car method) gnus-server-alist))))))
14653 (setcar (cdr entry) (concat (nth 1 entry) "+" group))
14654 (nconc entry (cdr method))))
14656 (defun gnus-find-method-for-group (group &optional info)
14657 "Find the select method that GROUP uses."
14658 (or gnus-override-method
14660 gnus-select-method)
14661 (let ((info (or info (gnus-get-info group)))
14664 (not (setq method (gnus-info-method info))))
14665 (setq method gnus-select-method)
14667 (cond ((stringp method)
14668 (gnus-server-to-method method))
14669 ((stringp (car method))
14670 (gnus-server-extend-method group method))
14673 (gnus-server-add-address method))))
14675 (defun gnus-check-backend-function (func group)
14676 "Check whether GROUP supports function FUNC."
14677 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
14679 (fboundp (intern (format "%s-%s" method func)))))
14681 (defun gnus-methods-using (feature)
14682 "Find all methods that have FEATURE."
14683 (let ((valids gnus-valid-select-methods)
14686 (if (memq feature (car valids))
14687 (setq outs (cons (car valids) outs)))
14688 (setq valids (cdr valids)))
14693 ;;; Active & Newsrc File Handling
14696 (defun gnus-setup-news (&optional rawfile level)
14697 "Setup news information.
14698 If RAWFILE is non-nil, the .newsrc file will also be read.
14699 If LEVEL is non-nil, the news will be set up at level LEVEL."
14700 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile)))))
14701 ;; Clear some variables to re-initialize news information.
14702 (if init (setq gnus-newsrc-alist nil
14703 gnus-active-hashtb nil))
14705 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
14706 (if init (gnus-read-newsrc-file rawfile))
14708 (unless (assoc "archive" gnus-server-alist)
14709 (push (cons "archive" gnus-message-archive-method)
14710 gnus-server-alist))
14712 ;; If we don't read the complete active file, we fill in the
14714 (if (or (null gnus-read-active-file)
14715 (eq gnus-read-active-file 'some))
14716 (gnus-update-active-hashtb-from-killed))
14718 ;; Read the active file and create `gnus-active-hashtb'.
14719 ;; If `gnus-read-active-file' is nil, then we just create an empty
14720 ;; hash table. The partial filling out of the hash table will be
14721 ;; done in `gnus-get-unread-articles'.
14722 (and gnus-read-active-file
14724 (gnus-read-active-file))
14726 (or gnus-active-hashtb
14727 (setq gnus-active-hashtb (make-vector 4095 0)))
14729 ;; Initialize the cache.
14730 (when gnus-use-cache
14733 ;; Possibly eval the dribble file.
14734 (and init (or gnus-use-dribble-file gnus-slave) (gnus-dribble-eval-file))
14736 (gnus-update-format-specifications)
14738 ;; Find new newsgroups and treat them.
14739 (if (and init gnus-check-new-newsgroups (not level)
14740 (gnus-check-server gnus-select-method))
14741 (gnus-find-new-newsgroups))
14743 ;; Find the number of unread articles in each non-dead group.
14744 (let ((gnus-read-active-file (and (not level) gnus-read-active-file)))
14745 (gnus-get-unread-articles level))
14747 (if (and init gnus-check-bogus-newsgroups
14748 gnus-read-active-file (not level)
14749 (gnus-server-opened gnus-select-method))
14750 (gnus-check-bogus-newsgroups))))
14752 (defun gnus-find-new-newsgroups (&optional arg)
14753 "Search for new newsgroups and add them.
14754 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
14755 The `-n' option line from .newsrc is respected.
14756 If ARG (the prefix), use the `ask-server' method to query
14757 the server for new groups."
14759 (let ((check (if (or (and arg (not (listp gnus-check-new-newsgroups)))
14760 (null gnus-read-active-file)
14761 (eq gnus-read-active-file 'some))
14762 'ask-server gnus-check-new-newsgroups)))
14763 (unless (gnus-check-first-time-used)
14764 (if (or (consp check)
14765 (eq check 'ask-server))
14766 ;; Ask the server for new groups.
14767 (gnus-ask-server-for-new-groups)
14768 ;; Go through the active hashtb and look for new groups.
14770 group new-newsgroups)
14771 (gnus-message 5 "Looking for new newsgroups...")
14772 (unless gnus-have-read-active-file
14773 (gnus-read-active-file))
14774 (setq gnus-newsrc-last-checked-date (current-time-string))
14775 (unless gnus-killed-hashtb
14776 (gnus-make-hashtable-from-killed))
14777 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
14778 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
14781 (if (or (null (setq group (symbol-name sym)))
14783 (null (symbol-value sym))
14784 (gnus-gethash group gnus-killed-hashtb)
14785 (gnus-gethash group gnus-newsrc-hashtb))
14787 (let ((do-sub (gnus-matches-options-n group)))
14789 ((eq do-sub 'subscribe)
14790 (setq groups (1+ groups))
14791 (gnus-sethash group group gnus-killed-hashtb)
14792 (funcall gnus-subscribe-options-newsgroup-method group))
14793 ((eq do-sub 'ignore)
14796 (setq groups (1+ groups))
14797 (gnus-sethash group group gnus-killed-hashtb)
14798 (if gnus-subscribe-hierarchical-interactive
14799 (setq new-newsgroups (cons group new-newsgroups))
14800 (funcall gnus-subscribe-newsgroup-method group)))))))
14801 gnus-active-hashtb)
14802 (when new-newsgroups
14803 (gnus-subscribe-hierarchical-interactive new-newsgroups))
14804 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
14806 (gnus-message 6 "%d new newsgroup%s arrived."
14807 groups (if (> groups 1) "s have" " has"))
14808 (gnus-message 6 "No new newsgroups.")))))))
14810 (defun gnus-matches-options-n (group)
14811 ;; Returns `subscribe' if the group is to be unconditionally
14812 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
14813 ;; no match for the group.
14815 ;; First we check the two user variables.
14817 ((and gnus-options-subscribe
14818 (string-match gnus-options-subscribe group))
14820 ((and gnus-auto-subscribed-groups
14821 (string-match gnus-auto-subscribed-groups group))
14823 ((and gnus-options-not-subscribe
14824 (string-match gnus-options-not-subscribe group))
14826 ;; Then we go through the list that was retrieved from the .newsrc
14827 ;; file. This list has elements on the form
14828 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
14829 ;; is in the reverse order of the options line) is returned.
14831 (let ((regs gnus-newsrc-options-n))
14833 (not (string-match (car (car regs)) group)))
14834 (setq regs (cdr regs)))
14835 (and regs (cdr (car regs)))))))
14837 (defun gnus-ask-server-for-new-groups ()
14838 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
14839 (methods (cons gnus-select-method
14843 (and (consp gnus-check-new-newsgroups)
14844 gnus-check-new-newsgroups)
14845 gnus-secondary-select-methods))))
14847 (new-date (current-time-string))
14848 group new-newsgroups got-new method hashtb
14849 gnus-override-subscribe-method)
14850 ;; Go through both primary and secondary select methods and
14851 ;; request new newsgroups.
14852 (while (setq method (gnus-server-get-method nil (pop methods)))
14853 (setq gnus-override-subscribe-method method)
14854 (when (and (gnus-check-server method)
14855 (gnus-request-newgroups date method))
14858 (setq hashtb (gnus-make-hashtable 100))
14859 (set-buffer nntp-server-buffer)
14860 ;; Enter all the new groups into a hashtable.
14861 (gnus-active-to-gnus-format method hashtb 'ignore)))
14862 ;; Now all new groups from `method' are in `hashtb'.
14864 (lambda (group-sym)
14865 (if (or (null (setq group (symbol-name group-sym)))
14866 (null (symbol-value group-sym))
14867 (gnus-gethash group gnus-newsrc-hashtb)
14868 (member group gnus-zombie-list)
14869 (member group gnus-killed-list))
14870 ;; The group is already known.
14872 ;; Make this group active.
14873 (when (symbol-value group-sym)
14874 (gnus-set-active group (symbol-value group-sym)))
14875 ;; Check whether we want it or not.
14876 (let ((do-sub (gnus-matches-options-n group)))
14878 ((eq do-sub 'subscribe)
14880 (gnus-sethash group group gnus-killed-hashtb)
14881 (funcall gnus-subscribe-options-newsgroup-method group))
14882 ((eq do-sub 'ignore)
14886 (gnus-sethash group group gnus-killed-hashtb)
14887 (if gnus-subscribe-hierarchical-interactive
14888 (push group new-newsgroups)
14889 (funcall gnus-subscribe-newsgroup-method group)))))))
14891 (when new-newsgroups
14892 (gnus-subscribe-hierarchical-interactive new-newsgroups)))
14893 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
14895 (gnus-message 6 "%d new newsgroup%s arrived."
14896 groups (if (> groups 1) "s have" " has")))
14897 (and got-new (setq gnus-newsrc-last-checked-date new-date))
14900 (defun gnus-check-first-time-used ()
14901 (if (or (> (length gnus-newsrc-alist) 1)
14902 (file-exists-p gnus-startup-file)
14903 (file-exists-p (concat gnus-startup-file ".el"))
14904 (file-exists-p (concat gnus-startup-file ".eld")))
14906 (gnus-message 6 "First time user; subscribing you to default groups")
14907 (unless gnus-have-read-active-file
14908 (gnus-read-active-file))
14909 (setq gnus-newsrc-last-checked-date (current-time-string))
14910 (let ((groups gnus-default-subscribed-newsgroups)
14914 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
14917 (if (null (setq group (symbol-name sym)))
14919 (let ((do-sub (gnus-matches-options-n group)))
14921 ((eq do-sub 'subscribe)
14922 (gnus-sethash group group gnus-killed-hashtb)
14923 (funcall gnus-subscribe-options-newsgroup-method group))
14924 ((eq do-sub 'ignore)
14927 (setq gnus-killed-list (cons group gnus-killed-list)))))))
14928 gnus-active-hashtb)
14930 (if (gnus-active (car groups))
14931 (gnus-group-change-level
14932 (car groups) gnus-level-default-subscribed gnus-level-killed))
14933 (setq groups (cdr groups)))
14934 (gnus-group-make-help-group)
14935 (and gnus-novice-user
14936 (gnus-message 7 "`A k' to list killed groups"))))))
14938 (defun gnus-subscribe-group (group previous &optional method)
14939 (gnus-group-change-level
14941 (list t group gnus-level-default-subscribed nil nil method)
14943 gnus-level-default-subscribed gnus-level-killed previous t))
14945 ;; `gnus-group-change-level' is the fundamental function for changing
14946 ;; subscription levels of newsgroups. This might mean just changing
14947 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
14948 ;; again, which subscribes/unsubscribes a group, which is equally
14949 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
14950 ;; from 8-9 to 1-7 means that you remove the group from the list of
14951 ;; killed (or zombie) groups and add them to the (kinda) subscribed
14952 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
14953 ;; which is trivial.
14954 ;; ENTRY can either be a string (newsgroup name) or a list (if
14955 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
14956 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
14958 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
14959 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
14961 (defun gnus-group-change-level (entry level &optional oldlevel
14962 previous fromkilled)
14963 (let (group info active num)
14964 ;; Glean what info we can from the arguments
14966 (if fromkilled (setq group (nth 1 entry))
14967 (setq group (car (nth 2 entry))))
14968 (setq group entry))
14969 (if (and (stringp entry)
14971 (< oldlevel gnus-level-zombie))
14972 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
14973 (if (and (not oldlevel)
14975 (setq oldlevel (car (cdr (nth 2 entry)))))
14976 (if (stringp previous)
14977 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
14979 (if (and (>= oldlevel gnus-level-zombie)
14980 (gnus-gethash group gnus-newsrc-hashtb))
14981 ;; We are trying to subscribe a group that is already
14985 (or (gnus-ephemeral-group-p group)
14986 (gnus-dribble-enter
14987 (format "(gnus-group-change-level %S %S %S %S %S)"
14988 group level oldlevel (car (nth 2 previous)) fromkilled)))
14990 ;; Then we remove the newgroup from any old structures, if needed.
14991 ;; If the group was killed, we remove it from the killed or zombie
14992 ;; list. If not, and it is in fact going to be killed, we remove
14993 ;; it from the newsrc hash table and assoc.
14995 ((>= oldlevel gnus-level-zombie)
14996 (if (= oldlevel gnus-level-zombie)
14997 (setq gnus-zombie-list (delete group gnus-zombie-list))
14998 (setq gnus-killed-list (delete group gnus-killed-list))))
15000 (if (and (>= level gnus-level-zombie)
15003 (gnus-sethash (car (nth 2 entry)) nil gnus-newsrc-hashtb)
15005 (setcdr (gnus-gethash (car (nth 3 entry))
15006 gnus-newsrc-hashtb)
15008 (setcdr (cdr entry) (cdr (cdr (cdr entry))))))))
15010 ;; Finally we enter (if needed) the list where it is supposed to
15011 ;; go, and change the subscription level. If it is to be killed,
15012 ;; we enter it into the killed or zombie list.
15014 ((>= level gnus-level-zombie)
15015 ;; Remove from the hash table.
15016 (gnus-sethash group nil gnus-newsrc-hashtb)
15017 ;; We do not enter foreign groups into the list of dead
15019 (unless (gnus-group-foreign-p group)
15020 (if (= level gnus-level-zombie)
15021 (setq gnus-zombie-list (cons group gnus-zombie-list))
15022 (setq gnus-killed-list (cons group gnus-killed-list)))))
15024 ;; If the list is to be entered into the newsrc assoc, and
15025 ;; it was killed, we have to create an entry in the newsrc
15026 ;; hashtb format and fix the pointers in the newsrc assoc.
15027 (if (< oldlevel gnus-level-zombie)
15028 ;; It was alive, and it is going to stay alive, so we
15029 ;; just change the level and don't change any pointers or
15030 ;; hash table entries.
15031 (setcar (cdr (car (cdr (cdr entry)))) level)
15033 (setq info (cdr entry)
15035 (setq active (gnus-active group))
15037 (if active (- (1+ (cdr active)) (car active)) t))
15038 ;; Check whether the group is foreign. If so, the
15039 ;; foreign select method has to be entered into the
15041 (let ((method (or gnus-override-subscribe-method
15042 (gnus-group-method group))))
15043 (if (eq method gnus-select-method)
15044 (setq info (list group level nil))
15045 (setq info (list group level nil nil method)))))
15048 (let ((p gnus-newsrc-alist))
15049 (while (cdr (cdr p))
15052 (setq entry (cons info (cdr (cdr previous))))
15055 (setcdr (cdr previous) entry)
15056 (gnus-sethash group (cons num (cdr previous))
15057 gnus-newsrc-hashtb))
15058 (setcdr previous entry)
15059 (gnus-sethash group (cons num previous)
15060 gnus-newsrc-hashtb))
15062 (setcdr (gnus-gethash (car (car (cdr entry))) gnus-newsrc-hashtb)
15064 (when gnus-group-change-level-function
15065 (funcall gnus-group-change-level-function group level oldlevel)))))
15067 (defun gnus-kill-newsgroup (newsgroup)
15068 "Obsolete function. Kills a newsgroup."
15069 (gnus-group-change-level
15070 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed))
15072 (defun gnus-check-bogus-newsgroups (&optional confirm)
15073 "Remove bogus newsgroups.
15074 If CONFIRM is non-nil, the user has to confirm the deletion of every
15076 (let ((newsrc (cdr gnus-newsrc-alist))
15077 bogus group entry info)
15078 (gnus-message 5 "Checking bogus newsgroups...")
15079 (unless gnus-have-read-active-file
15080 (gnus-read-active-file))
15081 (when (member gnus-select-method gnus-have-read-active-file)
15082 ;; Find all bogus newsgroup that are subscribed.
15084 (setq info (pop newsrc)
15085 group (gnus-info-group info))
15086 (unless (or (gnus-active group) ; Active
15087 (gnus-info-method info) ; Foreign
15089 (not (gnus-y-or-n-p
15090 (format "Remove bogus newsgroup: %s " group)))))
15091 ;; Found a bogus newsgroup.
15092 (push group bogus)))
15093 ;; Remove all bogus subscribed groups by first killing them, and
15094 ;; then removing them from the list of killed groups.
15096 (when (setq entry (gnus-gethash (setq group (pop bogus))
15097 gnus-newsrc-hashtb))
15098 (gnus-group-change-level entry gnus-level-killed)
15099 (setq gnus-killed-list (delete group gnus-killed-list))))
15100 ;; Then we remove all bogus groups from the list of killed and
15101 ;; zombie groups. They are are removed without confirmation.
15102 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
15105 (setq killed (symbol-value (car dead-lists)))
15107 (unless (gnus-active (setq group (pop killed)))
15108 ;; The group is bogus.
15109 ;; !!!Slow as hell.
15110 (set (car dead-lists)
15111 (delete group (symbol-value (car dead-lists))))))
15112 (setq dead-lists (cdr dead-lists))))
15113 (gnus-message 5 "Checking bogus newsgroups...done"))))
15115 (defun gnus-check-duplicate-killed-groups ()
15116 "Remove duplicates from the list of killed groups."
15118 (let ((killed gnus-killed-list))
15120 (gnus-message 9 "%d" (length killed))
15121 (setcdr killed (delete (car killed) (cdr killed)))
15122 (setq killed (cdr killed)))))
15124 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
15125 ;; and compute how many unread articles there are in each group.
15126 (defun gnus-get-unread-articles (&optional level)
15127 (let* ((newsrc (cdr gnus-newsrc-alist))
15128 (level (or level gnus-activate-level (1+ gnus-level-subscribed)))
15131 (cond ((and gnus-activate-foreign-newsgroups
15132 (not (numberp gnus-activate-foreign-newsgroups)))
15133 (1+ gnus-level-subscribed))
15134 ((numberp gnus-activate-foreign-newsgroups)
15135 gnus-activate-foreign-newsgroups)
15138 info group active virtuals method)
15139 (gnus-message 5 "Checking new news...")
15142 (setq info (car newsrc)
15143 group (gnus-info-group info)
15144 active (gnus-active group))
15146 ;; Check newsgroups. If the user doesn't want to check them, or
15147 ;; they can't be checked (for instance, if the news server can't
15148 ;; be reached) we just set the number of unread articles in this
15149 ;; newsgroup to t. This means that Gnus thinks that there are
15150 ;; unread articles, but it has no idea how many.
15151 (if (and (setq method (gnus-info-method info))
15152 (not (gnus-server-equal
15154 (gnus-server-get-method nil method)))
15155 (not (gnus-secondary-method-p method)))
15156 ;; These groups are foreign. Check the level.
15157 (when (<= (gnus-info-level info) foreign-level)
15158 (setq active (gnus-activate-group group 'scan))
15159 (gnus-close-group group))
15161 ;; These groups are native or secondary.
15162 (when (and (<= (gnus-info-level info) level)
15163 (not gnus-read-active-file))
15164 (setq active (gnus-activate-group group 'scan))
15165 (gnus-close-group group)))
15168 (gnus-get-unread-articles-in-group info active t)
15169 ;; The group couldn't be reached, so we nix out the number of
15170 ;; unread articles and stuff.
15171 (gnus-set-active group nil)
15172 (setcar (gnus-gethash group gnus-newsrc-hashtb) t))
15174 (setq newsrc (cdr newsrc)))
15176 (gnus-message 5 "Checking new news...done")))
15178 ;; Create a hash table out of the newsrc alist. The `car's of the
15179 ;; alist elements are used as keys.
15180 (defun gnus-make-hashtable-from-newsrc-alist ()
15181 (let ((alist gnus-newsrc-alist)
15182 (ohashtb gnus-newsrc-hashtb)
15184 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
15186 (setq prev (setq gnus-newsrc-alist
15187 (if (equal (car (car gnus-newsrc-alist))
15190 (cons (list "dummy.group" 0 nil) alist)))))
15194 (cons (and ohashtb (car (gnus-gethash (car (car alist)) ohashtb)))
15196 gnus-newsrc-hashtb)
15198 alist (cdr alist)))))
15200 (defun gnus-make-hashtable-from-killed ()
15201 "Create a hash table from the killed and zombie lists."
15202 (let ((lists '(gnus-killed-list gnus-zombie-list))
15204 (setq gnus-killed-hashtb
15205 (gnus-make-hashtable
15206 (+ (length gnus-killed-list) (length gnus-zombie-list))))
15208 (setq list (symbol-value (car lists)))
15209 (setq lists (cdr lists))
15211 (gnus-sethash (car list) (car list) gnus-killed-hashtb)
15212 (setq list (cdr list))))))
15214 (defun gnus-get-unread-articles-in-group (info active &optional update)
15216 ;; Allow the backend to update the info in the group.
15218 (gnus-request-update-info
15219 info (gnus-find-method-for-group (gnus-info-group info))))
15220 (let* ((range (gnus-info-read info))
15222 (marked (gnus-info-marks info)))
15223 ;; If a cache is present, we may have to alter the active info.
15224 (and gnus-use-cache
15225 (gnus-cache-possibly-alter-active (gnus-info-group info) active))
15226 ;; Modify the list of read articles according to what articles
15227 ;; are available; then tally the unread articles and add the
15228 ;; number to the group hash table entry.
15230 ((zerop (cdr active))
15233 (setq num (- (1+ (cdr active)) (car active))))
15234 ((not (listp (cdr range)))
15235 ;; Fix a single (num . num) range according to the
15236 ;; active hash table.
15237 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
15238 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
15239 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
15240 ;; Compute number of unread articles.
15241 (setq num (max 0 (- (cdr active) (- (1+ (cdr range)) (car range))))))
15243 ;; The read list is a list of ranges. Fix them according to
15244 ;; the active hash table.
15245 ;; First peel off any elements that are below the lower
15247 (while (and (cdr range)
15249 (or (and (atom (car (cdr range))) (car (cdr range)))
15250 (car (car (cdr range))))))
15251 (if (numberp (car range))
15254 (or (and (numberp (car (cdr range)))
15256 (cdr (car (cdr range))))))
15257 (setcdr (car range)
15258 (or (and (numberp (nth 1 range)) (nth 1 range))
15259 (cdr (car (cdr range))))))
15260 (setcdr range (cdr (cdr range))))
15261 ;; Adjust the first element to be the same as the lower limit.
15262 (if (and (not (atom (car range)))
15263 (< (cdr (car range)) (car active)))
15264 (setcdr (car range) (1- (car active))))
15265 ;; Then we want to peel off any elements that are higher
15266 ;; than the upper active limit.
15267 (let ((srange range))
15268 ;; Go past all legal elements.
15269 (while (and (cdr srange)
15270 (<= (or (and (atom (car (cdr srange)))
15271 (car (cdr srange)))
15272 (car (car (cdr srange)))) (cdr active)))
15273 (setq srange (cdr srange)))
15275 ;; Nuke all remaining illegal elements.
15276 (setcdr srange nil))
15278 ;; Adjust the final element.
15279 (if (and (not (atom (car srange)))
15280 (> (cdr (car srange)) (cdr active)))
15281 (setcdr (car srange) (cdr active))))
15282 ;; Compute the number of unread articles.
15284 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
15285 (cdr (car range))))
15286 (or (and (atom (car range)) (car range))
15287 (car (car range))))))
15288 (setq range (cdr range)))
15289 (setq num (max 0 (- (cdr active) num)))))
15290 ;; Set the number of unread articles.
15291 (setcar (gnus-gethash (gnus-info-group info) gnus-newsrc-hashtb) num)
15294 (defun gnus-activate-group (group &optional scan)
15295 ;; Check whether a group has been activated or not.
15296 ;; If SCAN, request a scan of that group as well.
15297 (let ((method (gnus-find-method-for-group group))
15299 (and (gnus-check-server method)
15300 ;; We escape all bugs and quit here to make it possible to
15301 ;; continue if a group is so out-there that it reports bugs
15305 (gnus-check-backend-function 'request-scan (car method))
15306 (gnus-request-scan group method))
15309 (gnus-request-group group)
15313 (set-buffer nntp-server-buffer)
15314 (goto-char (point-min))
15315 ;; Parse the result we got from `gnus-request-group'.
15316 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
15318 (goto-char (match-beginning 1))
15320 group (setq active (cons (read (current-buffer))
15321 (read (current-buffer)))))
15322 ;; Return the new active info.
15325 (defun gnus-update-read-articles (group unread)
15326 "Update the list of read and ticked articles in GROUP using the
15327 UNREAD and TICKED lists.
15328 Note: UNSELECTED has to be sorted over `<'.
15329 Returns whether the updating was successful."
15330 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
15331 (entry (gnus-gethash group gnus-newsrc-hashtb))
15332 (info (nth 2 entry))
15333 (marked (gnus-info-marks info))
15335 (unread (sort (copy-sequence unread) '<))
15337 (if (or (not info) (not active))
15338 ;; There is no info on this group if it was, in fact,
15339 ;; killed. Gnus stores no information on killed groups, so
15340 ;; there's nothing to be done.
15341 ;; One could store the information somewhere temporarily,
15342 ;; perhaps... Hmmm...
15344 ;; Remove any negative articles numbers.
15345 (while (and unread (< (car unread) 0))
15346 (setq unread (cdr unread)))
15347 ;; Remove any expired article numbers
15348 (while (and unread (< (car unread) (car active)))
15349 (setq unread (cdr unread)))
15350 ;; Compute the ranges of read articles by looking at the list of
15351 ;; unread articles.
15353 (if (/= (car unread) prev)
15354 (setq read (cons (if (= prev (1- (car unread))) prev
15355 (cons prev (1- (car unread)))) read)))
15356 (setq prev (1+ (car unread)))
15357 (setq unread (cdr unread)))
15358 (when (<= prev (cdr active))
15359 (setq read (cons (cons prev (cdr active)) read)))
15360 ;; Enter this list into the group info.
15361 (gnus-info-set-read
15362 info (if (> (length read) 1) (nreverse read) read))
15363 ;; Set the number of unread articles in gnus-newsrc-hashtb.
15364 (gnus-get-unread-articles-in-group info (gnus-active group))
15367 (defun gnus-make-articles-unread (group articles)
15368 "Mark ARTICLES in GROUP as unread."
15369 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
15370 (gnus-gethash (gnus-group-real-name group)
15371 gnus-newsrc-hashtb))))
15372 (ranges (gnus-info-read info))
15375 (when (gnus-member-of-range
15376 (setq article (pop articles)) ranges)
15377 (setq news (cons article news))))
15379 (gnus-info-set-read
15380 info (gnus-remove-from-range (gnus-info-read info) (nreverse news)))
15381 (gnus-group-update-group group t))))
15383 ;; Enter all dead groups into the hashtb.
15384 (defun gnus-update-active-hashtb-from-killed ()
15385 (let ((hashtb (setq gnus-active-hashtb (make-vector 4095 0)))
15386 (lists (list gnus-killed-list gnus-zombie-list))
15389 (setq killed (car lists))
15391 (gnus-sethash (car killed) nil hashtb)
15392 (setq killed (cdr killed)))
15393 (setq lists (cdr lists)))))
15395 ;; Get the active file(s) from the backend(s).
15396 (defun gnus-read-active-file ()
15397 (gnus-group-set-mode-line)
15400 (if (gnus-check-server gnus-select-method)
15401 ;; The native server is available.
15402 (cons gnus-select-method gnus-secondary-select-methods)
15403 ;; The native server is down, so we just do the
15405 gnus-secondary-select-methods)
15406 ;; Also read from the archive server.
15409 (setq gnus-have-read-active-file nil)
15411 (set-buffer nntp-server-buffer)
15413 (let* ((method (gnus-server-get-method nil (car methods)))
15414 (where (nth 1 method))
15415 (mesg (format "Reading active file%s via %s..."
15416 (if (and where (not (zerop (length where))))
15417 (concat " from " where) "")
15419 (gnus-message 5 mesg)
15420 (if (not (gnus-check-server method))
15422 ;; Request that the backend scan its incoming messages.
15423 (and (gnus-check-backend-function 'request-scan (car method))
15424 (gnus-request-scan nil method))
15426 ((and (eq gnus-read-active-file 'some)
15427 (gnus-check-backend-function 'retrieve-groups (car method)))
15428 (let ((newsrc (cdr gnus-newsrc-alist))
15429 (gmethod (gnus-server-get-method nil method))
15432 (and (gnus-server-equal
15433 (gnus-find-method-for-group
15434 (car (car newsrc)) (car newsrc))
15436 (setq groups (cons (gnus-group-real-name
15437 (car (car newsrc))) groups)))
15438 (setq newsrc (cdr newsrc)))
15439 (gnus-check-server method)
15440 (setq list-type (gnus-retrieve-groups groups method))
15444 1 "Cannot read partial active file from %s server."
15448 ((eq list-type 'active)
15449 (gnus-active-to-gnus-format method gnus-active-hashtb))
15451 (gnus-groups-to-gnus-format method gnus-active-hashtb)))))
15453 (if (not (gnus-request-list method))
15455 (unless (equal method gnus-message-archive-method)
15456 (gnus-message 1 "Cannot read active file from %s server."
15459 (gnus-active-to-gnus-format method)
15460 ;; We mark this active file as read.
15461 (push method gnus-have-read-active-file)
15462 (gnus-message 5 "%sdone" mesg))))))
15463 (setq methods (cdr methods))))))
15465 ;; Read an active file and place the results in `gnus-active-hashtb'.
15466 (defun gnus-active-to-gnus-format (&optional method hashtb ignore-errors)
15468 (setq method gnus-select-method))
15469 (let ((cur (current-buffer))
15471 (if (and gnus-active-hashtb
15472 (not (equal method gnus-select-method)))
15474 (setq gnus-active-hashtb
15475 (if (equal method gnus-select-method)
15476 (gnus-make-hashtable
15477 (count-lines (point-min) (point-max)))
15478 (gnus-make-hashtable 4096))))))
15479 (flag-hashtb (gnus-make-hashtable 60)))
15480 ;; Delete unnecessary lines.
15481 (goto-char (point-min))
15482 (while (search-forward "\nto." nil t)
15483 (delete-region (1+ (match-beginning 0))
15484 (progn (forward-line 1) (point))))
15485 (or (string= gnus-ignored-newsgroups "")
15487 (goto-char (point-min))
15488 (delete-matching-lines gnus-ignored-newsgroups)))
15489 ;; Make the group names readable as a lisp expression even if they
15490 ;; contain special characters.
15491 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
15492 (goto-char (point-max))
15493 (while (re-search-backward "[][';?()#]" nil t)
15495 ;; If these are groups from a foreign select method, we insert the
15496 ;; group prefix in front of the group names.
15497 (and method (not (gnus-server-equal
15498 (gnus-server-get-method nil method)
15499 (gnus-server-get-method nil gnus-select-method)))
15500 (let ((prefix (gnus-group-prefixed-name "" method)))
15501 (goto-char (point-min))
15502 (while (and (not (eobp))
15503 (progn (insert prefix)
15504 (zerop (forward-line 1)))))))
15505 ;; Store the active file in a hash table.
15506 (goto-char (point-min))
15507 (if (string-match "%[oO]" gnus-group-line-format)
15508 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
15509 ;; If we want information on moderated groups, we use this
15511 (let* ((mod-hashtb (make-vector 7 0))
15512 (m (intern "m" mod-hashtb))
15514 (while (not (eobp))
15515 (condition-case nil
15517 (narrow-to-region (point) (gnus-point-at-eol))
15518 (setq group (let ((obarray hashtb)) (read cur)))
15519 (if (and (numberp (setq max (read cur)))
15520 (numberp (setq min (read cur)))
15522 (skip-chars-forward " \t")
15524 (or (= (following-char) ?=)
15525 (= (following-char) ?x)
15526 (= (following-char) ?j)))))
15527 (set group (cons min max))
15529 ;; Enter moderated groups into a list.
15530 (if (eq (let ((obarray mod-hashtb)) (read cur)) m)
15531 (setq gnus-moderated-list
15532 (cons (symbol-name group) gnus-moderated-list))))
15539 ;; And if we do not care about moderation, we use this loop,
15540 ;; which is faster.
15541 (let (group max min)
15542 (while (not (eobp))
15545 (narrow-to-region (point) (gnus-point-at-eol))
15546 ;; group gets set to a symbol interned in the hash table
15547 ;; (what a hack!!) - jwz
15548 (setq group (let ((obarray hashtb)) (read cur)))
15549 (if (and (numberp (setq max (read cur)))
15550 (numberp (setq min (read cur)))
15552 (skip-chars-forward " \t")
15554 (or (= (following-char) ?=)
15555 (= (following-char) ?x)
15556 (= (following-char) ?j)))))
15557 (set group (cons min max))
15565 (gnus-message 3 "Warning - illegal active: %s"
15567 (gnus-point-at-bol) (gnus-point-at-eol)))))))
15569 (forward-line 1))))))
15571 (defun gnus-groups-to-gnus-format (method &optional hashtb)
15572 ;; Parse a "groups" active file.
15573 (let ((cur (current-buffer))
15575 (if (and method gnus-active-hashtb)
15577 (setq gnus-active-hashtb
15578 (gnus-make-hashtable
15579 (count-lines (point-min) (point-max)))))))
15580 (prefix (and method
15581 (not (gnus-server-equal
15582 (gnus-server-get-method nil method)
15583 (gnus-server-get-method nil gnus-select-method)))
15584 (gnus-group-prefixed-name "" method))))
15586 (goto-char (point-min))
15587 ;; We split this into to separate loops, one with the prefix
15588 ;; and one without to speed the reading up somewhat.
15590 (let (min max opoint group)
15591 (while (not (eobp))
15594 (read cur) (read cur)
15595 (setq min (read cur)
15598 (skip-chars-forward " \t")
15601 (set (let ((obarray hashtb)) (read cur))
15603 (error (and group (symbolp group) (set group nil))))
15605 (let (min max group)
15606 (while (not (eobp))
15608 (if (= (following-char) ?2)
15610 (read cur) (read cur)
15611 (setq min (read cur)
15613 (set (setq group (let ((obarray hashtb)) (read cur)))
15615 (error (and group (symbolp group) (set group nil))))
15616 (forward-line 1))))))
15618 (defun gnus-read-newsrc-file (&optional force)
15619 "Read startup file.
15620 If FORCE is non-nil, the .newsrc file is read."
15621 ;; Reset variables that might be defined in the .newsrc.eld file.
15622 (let ((variables gnus-variable-list))
15624 (set (car variables) nil)
15625 (setq variables (cdr variables))))
15626 (let* ((newsrc-file gnus-current-startup-file)
15627 (quick-file (concat newsrc-file ".el")))
15629 ;; We always load the .newsrc.eld file. If always contains
15630 ;; much information that can not be gotten from the .newsrc
15631 ;; file (ticked articles, killed groups, foreign methods, etc.)
15632 (gnus-read-newsrc-el-file quick-file)
15635 (and (file-newer-than-file-p newsrc-file quick-file)
15636 (file-newer-than-file-p newsrc-file
15637 (concat quick-file "d")))
15638 (not gnus-newsrc-alist))
15639 ;; We read the .newsrc file. Note that if there if a
15640 ;; .newsrc.eld file exists, it has already been read, and
15641 ;; the `gnus-newsrc-hashtb' has been created. While reading
15642 ;; the .newsrc file, Gnus will only use the information it
15643 ;; can find there for changing the data already read -
15644 ;; ie. reading the .newsrc file will not trash the data
15645 ;; already read (except for read articles).
15647 (gnus-message 5 "Reading %s..." newsrc-file)
15648 (set-buffer (find-file-noselect newsrc-file))
15649 (buffer-disable-undo (current-buffer))
15650 (gnus-newsrc-to-gnus-format)
15651 (kill-buffer (current-buffer))
15652 (gnus-message 5 "Reading %s...done" newsrc-file)))
15654 ;; Read any slave files.
15656 (gnus-master-read-slave-newsrc)))))
15658 (defun gnus-read-newsrc-el-file (file)
15659 (let ((ding-file (concat file "d")))
15660 ;; We always, always read the .eld file.
15661 (gnus-message 5 "Reading %s..." ding-file)
15662 (let (gnus-newsrc-assoc)
15663 (condition-case nil
15664 (load ding-file t t t)
15666 (gnus-message 1 "Error in %s" ding-file)
15668 (when gnus-newsrc-assoc
15669 (setq gnus-newsrc-alist gnus-newsrc-assoc)))
15670 (gnus-make-hashtable-from-newsrc-alist)
15671 (when (file-newer-than-file-p file ding-file)
15672 ;; Old format quick file
15673 (gnus-message 5 "Reading %s..." file)
15674 ;; The .el file is newer than the .eld file, so we read that one
15676 (gnus-read-old-newsrc-el-file file))))
15678 ;; Parse the old-style quick startup file
15679 (defun gnus-read-old-newsrc-el-file (file)
15680 (let (newsrc killed marked group m)
15682 (let ((gnus-killed-assoc nil)
15683 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc)
15685 (condition-case nil
15688 (setq newsrc gnus-newsrc-assoc
15689 killed gnus-killed-assoc
15690 marked gnus-marked-assoc)))
15691 (setq gnus-newsrc-alist nil)
15693 (setq group (car newsrc))
15694 (let ((info (gnus-get-info (car group))))
15697 (gnus-info-set-read info (cdr (cdr group)))
15698 (gnus-info-set-level
15699 info (if (nth 1 group) gnus-level-default-subscribed
15700 gnus-level-default-unsubscribed))
15701 (setq gnus-newsrc-alist (cons info gnus-newsrc-alist)))
15702 (setq gnus-newsrc-alist
15706 (if (nth 1 group) gnus-level-default-subscribed
15707 gnus-level-default-unsubscribed)
15708 (cdr (cdr group))))
15709 gnus-newsrc-alist)))
15710 (if (setq m (assoc (car group) marked))
15711 (gnus-info-set-marks
15712 info (cons (list (cons 'tick (gnus-compress-sequence
15713 (sort (cdr m) '<) t)))
15715 (setq newsrc (cdr newsrc)))
15716 (setq newsrc killed)
15718 (setcar newsrc (car (car newsrc)))
15719 (setq newsrc (cdr newsrc)))
15720 (setq gnus-killed-list killed))
15721 ;; The .el file version of this variable does not begin with
15722 ;; "options", while the .eld version does, so we just add it if it
15725 gnus-newsrc-options
15727 (and (not (string-match "^ *options" gnus-newsrc-options))
15728 (setq gnus-newsrc-options (concat "options " gnus-newsrc-options)))
15729 (and (not (string-match "\n$" gnus-newsrc-options))
15730 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n")))
15731 ;; Finally, if we read some options lines, we parse them.
15732 (or (string= gnus-newsrc-options "")
15733 (gnus-newsrc-parse-options gnus-newsrc-options))))
15735 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))
15736 (gnus-make-hashtable-from-newsrc-alist)))
15738 (defun gnus-make-newsrc-file (file)
15739 "Make server dependent file name by catenating FILE and server host name."
15740 (let* ((file (expand-file-name file nil))
15741 (real-file (concat file "-" (nth 1 gnus-select-method))))
15742 (if (or (file-exists-p real-file)
15743 (file-exists-p (concat real-file ".el"))
15744 (file-exists-p (concat real-file ".eld")))
15747 (defun gnus-newsrc-to-gnus-format ()
15748 (setq gnus-newsrc-options "")
15749 (setq gnus-newsrc-options-n nil)
15751 (or gnus-active-hashtb
15752 (setq gnus-active-hashtb (make-vector 4095 0)))
15753 (let ((buf (current-buffer))
15754 (already-read (> (length gnus-newsrc-alist) 1))
15755 group subscribed options-symbol newsrc Options-symbol
15757 (goto-char (point-min))
15758 ;; We intern the symbol `options' in the active hashtb so that we
15759 ;; can `eq' against it later.
15760 (set (setq options-symbol (intern "options" gnus-active-hashtb)) nil)
15761 (set (setq Options-symbol (intern "Options" gnus-active-hashtb)) nil)
15763 (while (not (eobp))
15764 ;; We first read the first word on the line by narrowing and
15765 ;; then reading into `gnus-active-hashtb'. Most groups will
15766 ;; already exist in that hashtb, so this will save some string
15770 (progn (skip-chars-forward "^ \t!:\n") (point)))
15771 (goto-char (point-min))
15773 (and (/= (point-min) (point-max))
15774 (let ((obarray gnus-active-hashtb)) (read buf))))
15776 ;; Now, the symbol we have read is either `options' or a group
15777 ;; name. If it is an options line, we just add it to a string.
15779 ((or (eq symbol options-symbol)
15780 (eq symbol Options-symbol))
15781 (setq gnus-newsrc-options
15782 ;; This concating is quite inefficient, but since our
15783 ;; thorough studies show that approx 99.37% of all
15784 ;; .newsrc files only contain a single options line, we
15785 ;; don't give a damn, frankly, my dear.
15786 (concat gnus-newsrc-options
15788 (gnus-point-at-bol)
15789 ;; Options may continue on the next line.
15790 (or (and (re-search-forward "^[^ \t]" nil 'move)
15791 (progn (beginning-of-line) (point)))
15795 ;; Group names can be just numbers.
15796 (when (numberp symbol)
15797 (setq symbol (intern (int-to-string symbol) gnus-active-hashtb)))
15798 (or (boundp symbol) (set symbol nil))
15799 ;; It was a group name.
15800 (setq subscribed (= (following-char) ?:)
15801 group (symbol-name symbol)
15804 ;; If the line ends here, this is clearly a buggy line, so
15805 ;; we put point a the beginning of line and let the cond
15806 ;; below do the error handling.
15807 (beginning-of-line)
15808 ;; We skip to the beginning of the ranges.
15809 (skip-chars-forward "!: \t"))
15810 ;; We are now at the beginning of the list of read articles.
15811 ;; We read them range by range.
15814 ((looking-at "[0-9]+")
15815 ;; We narrow and read a number instead of buffer-substring/
15816 ;; string-to-int because it's faster. narrow/widen is
15817 ;; faster than save-restriction/narrow, and save-restriction
15818 ;; produces a garbage object.
15820 (narrow-to-region (match-beginning 0) (match-end 0))
15823 ;; If the next character is a dash, then this is a range.
15824 (if (= (following-char) ?-)
15826 ;; We read the upper bound of the range.
15828 (if (not (looking-at "[0-9]+"))
15829 ;; This is a buggy line, by we pretend that
15830 ;; it's kinda OK. Perhaps the user should be
15832 (setq reads (cons num1 reads))
15837 (narrow-to-region (match-beginning 0)
15842 ;; It was just a simple number, so we add it to the
15844 (setq reads (cons num1 reads)))
15845 ;; If the next char in ?\n, then we have reached the end
15846 ;; of the line and return nil.
15847 (/= (following-char) ?\n))
15848 ((= (following-char) ?\n)
15849 ;; End of line, so we end.
15852 ;; Not numbers and not eol, so this might be a buggy
15855 ;; If it was eob instead of ?\n, we allow it.
15857 ;; The line was buggy.
15859 (gnus-message 3 "Mangled line: %s"
15860 (buffer-substring (gnus-point-at-bol)
15861 (gnus-point-at-eol)))
15865 ;; Skip past ", ". Spaces are illegal in these ranges, but
15866 ;; we allow them, because it's a common mistake to put a
15867 ;; space after the comma.
15868 (skip-chars-forward ", "))
15870 ;; We have already read .newsrc.eld, so we gently update the
15871 ;; data in the hash table with the information we have just
15874 (let ((info (gnus-get-info group))
15877 ;; There is an entry for this file in the alist.
15879 (gnus-info-set-read info (nreverse reads))
15880 ;; We update the level very gently. In fact, we
15881 ;; only change it if there's been a status change
15882 ;; from subscribed to unsubscribed, or vice versa.
15883 (setq level (gnus-info-level info))
15884 (cond ((and (<= level gnus-level-subscribed)
15886 (setq level (if reads
15887 gnus-level-default-unsubscribed
15888 (1+ gnus-level-default-unsubscribed))))
15889 ((and (> level gnus-level-subscribed) subscribed)
15890 (setq level gnus-level-default-subscribed)))
15891 (gnus-info-set-level info level))
15892 ;; This is a new group.
15893 (setq info (list group
15895 gnus-level-default-subscribed
15897 (1+ gnus-level-subscribed)
15898 gnus-level-default-unsubscribed))
15899 (nreverse reads))))
15900 (setq newsrc (cons info newsrc))))))
15903 (setq newsrc (nreverse newsrc))
15905 (if (not already-read)
15907 ;; We now have two newsrc lists - `newsrc', which is what we
15908 ;; have read from .newsrc, and `gnus-newsrc-alist', which is
15909 ;; what we've read from .newsrc.eld. We have to merge these
15910 ;; lists. We do this by "attaching" any (foreign) groups in the
15911 ;; gnus-newsrc-alist to the (native) group that precedes them.
15912 (let ((rc (cdr gnus-newsrc-alist))
15913 (prev gnus-newsrc-alist)
15916 (or (null (nth 4 (car rc))) ; It's a native group.
15917 (assoc (car (car rc)) newsrc) ; It's already in the alist.
15918 (if (setq entry (assoc (car (car prev)) newsrc))
15919 (setcdr (setq mentry (memq entry newsrc))
15920 (cons (car rc) (cdr mentry)))
15921 (setq newsrc (cons (car rc) newsrc))))
15925 (setq gnus-newsrc-alist newsrc)
15926 ;; We make the newsrc hashtb.
15927 (gnus-make-hashtable-from-newsrc-alist)
15929 ;; Finally, if we read some options lines, we parse them.
15930 (or (string= gnus-newsrc-options "")
15931 (gnus-newsrc-parse-options gnus-newsrc-options))))
15933 ;; Parse options lines to find "options -n !all rec.all" and stuff.
15934 ;; The return value will be a list on the form
15935 ;; ((regexp1 . ignore)
15936 ;; (regexp2 . subscribe)...)
15937 ;; When handling new newsgroups, groups that match a `ignore' regexp
15938 ;; will be ignored, and groups that match a `subscribe' regexp will be
15939 ;; subscribed. A line like
15940 ;; options -n !all rec.all
15941 ;; will lead to a list that looks like
15942 ;; (("^rec\\..+" . subscribe)
15943 ;; ("^.+" . ignore))
15944 ;; So all "rec.*" groups will be subscribed, while all the other
15945 ;; groups will be ignored. Note that "options -n !all rec.all" is very
15946 ;; different from "options -n rec.all !all".
15947 (defun gnus-newsrc-parse-options (options)
15950 (gnus-set-work-buffer)
15951 (insert (regexp-quote options))
15952 ;; First we treat all continuation lines.
15953 (goto-char (point-min))
15954 (while (re-search-forward "\n[ \t]+" nil t)
15955 (replace-match " " t t))
15956 ;; Then we transform all "all"s into ".+"s.
15957 (goto-char (point-min))
15958 (while (re-search-forward "\\ball\\b" nil t)
15959 (replace-match ".+" t t))
15960 (goto-char (point-min))
15961 ;; We remove all other options than the "-n" ones.
15962 (while (re-search-forward "[ \t]-[^n][^-]*" nil t)
15963 (replace-match " ")
15965 (goto-char (point-min))
15967 ;; We are only interested in "options -n" lines - we
15968 ;; ignore the other option lines.
15969 (while (re-search-forward "[ \t]-n" nil t)
15971 (or (save-excursion
15972 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t)
15974 (gnus-point-at-eol)))
15975 ;; Search for all "words"...
15976 (while (re-search-forward "[^ \t,\n]+" eol t)
15977 (if (= (char-after (match-beginning 0)) ?!)
15978 ;; If the word begins with a bang (!), this is a "not"
15979 ;; spec. We put this spec (minus the bang) and the
15980 ;; symbol `ignore' into the list.
15981 (setq out (cons (cons (concat
15982 "^" (buffer-substring
15983 (1+ (match-beginning 0))
15986 ;; There was no bang, so this is a "yes" spec.
15987 (setq out (cons (cons (concat "^" (match-string 0))
15988 'subscribe) out)))))
15990 (setq gnus-newsrc-options-n out))))
15992 (defun gnus-save-newsrc-file (&optional force)
15993 "Save .newsrc file."
15994 ;; Note: We cannot save .newsrc file if all newsgroups are removed
15995 ;; from the variable gnus-newsrc-alist.
15996 (when (and (or gnus-newsrc-alist gnus-killed-list)
15997 gnus-current-startup-file)
15999 (if (and (or gnus-use-dribble-file gnus-slave)
16001 (or (not gnus-dribble-buffer)
16002 (not (buffer-name gnus-dribble-buffer))
16003 (zerop (save-excursion
16004 (set-buffer gnus-dribble-buffer)
16006 (gnus-message 4 "(No changes need to be saved)")
16007 (run-hooks 'gnus-save-newsrc-hook)
16009 (gnus-slave-save-newsrc)
16011 (when gnus-save-newsrc-file
16012 (gnus-message 5 "Saving %s..." gnus-current-startup-file)
16013 (gnus-gnus-to-newsrc-format)
16014 (gnus-message 5 "Saving %s...done" gnus-current-startup-file))
16015 ;; Save .newsrc.eld.
16016 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
16017 (make-local-variable 'version-control)
16018 (setq version-control 'never)
16019 (setq buffer-file-name
16020 (concat gnus-current-startup-file ".eld"))
16021 (gnus-add-current-to-buffer-list)
16022 (buffer-disable-undo (current-buffer))
16024 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file)
16025 (gnus-gnus-to-quick-newsrc-format)
16026 (run-hooks 'gnus-save-quick-newsrc-hook)
16028 (kill-buffer (current-buffer))
16030 5 "Saving %s.eld...done" gnus-current-startup-file))
16031 (gnus-dribble-delete-file)))))
16033 (defun gnus-gnus-to-quick-newsrc-format ()
16034 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
16035 (insert ";; Gnus startup file.\n")
16036 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
16037 (insert ";; to read .newsrc.\n")
16038 (insert "(setq gnus-newsrc-file-version "
16039 (prin1-to-string gnus-version) ")\n")
16041 (if gnus-save-killed-list gnus-variable-list
16042 ;; Remove the `gnus-killed-list' from the list of variables
16043 ;; to be saved, if required.
16044 (delq 'gnus-killed-list (copy-sequence gnus-variable-list))))
16045 ;; Peel off the "dummy" group.
16046 (gnus-newsrc-alist (cdr gnus-newsrc-alist))
16048 ;; Insert the variables into the file.
16050 (when (and (boundp (setq variable (pop variables)))
16051 (symbol-value variable))
16052 (insert "(setq " (symbol-name variable) " '"
16053 (prin1-to-string (symbol-value variable)) ")\n")))))
16055 (defun gnus-gnus-to-newsrc-format ()
16056 ;; Generate and save the .newsrc file.
16057 (let ((newsrc (cdr gnus-newsrc-alist))
16060 (set-buffer (create-file-buffer gnus-current-startup-file))
16061 (setq buffer-file-name gnus-current-startup-file)
16062 (buffer-disable-undo (current-buffer))
16065 (if gnus-newsrc-options (insert gnus-newsrc-options))
16066 ;; Write subscribed and unsubscribed.
16068 (setq info (car newsrc))
16069 (if (not (gnus-info-method info))
16070 ;; Don't write foreign groups to .newsrc.
16072 (insert (gnus-info-group info)
16073 (if (> (gnus-info-level info) gnus-level-subscribed)
16075 (if (setq ranges (gnus-info-read info))
16078 (if (not (listp (cdr ranges)))
16079 (if (= (car ranges) (cdr ranges))
16080 (insert (int-to-string (car ranges)))
16081 (insert (int-to-string (car ranges)) "-"
16082 (int-to-string (cdr ranges))))
16084 (setq range (car ranges)
16085 ranges (cdr ranges))
16086 (if (or (atom range) (= (car range) (cdr range)))
16087 (insert (int-to-string
16088 (or (and (atom range) range)
16090 (insert (int-to-string (car range)) "-"
16091 (int-to-string (cdr range))))
16092 (if ranges (insert ","))))))
16094 (setq newsrc (cdr newsrc)))
16095 (make-local-variable 'version-control)
16096 (setq version-control 'never)
16097 ;; It has been reported that sometime the modtime on the .newsrc
16098 ;; file seems to be off. We really do want to overwrite it, so
16099 ;; we clear the modtime here before saving. It's a bit odd,
16101 ;; sometimes the modtime clear isn't sufficient. most brute force:
16102 ;; delete the silly thing entirely first. but this fails to provide
16103 ;; such niceties as .newsrc~ creation.
16104 (if gnus-modtime-botch
16105 (delete-file gnus-startup-file)
16106 (clear-visited-file-modtime))
16107 (run-hooks 'gnus-save-standard-newsrc-hook)
16109 (kill-buffer (current-buffer)))))
16113 ;;; Slave functions.
16116 (defun gnus-slave-save-newsrc ()
16118 (set-buffer gnus-dribble-buffer)
16120 (make-temp-name (concat gnus-current-startup-file "-slave-"))))
16121 (write-region (point-min) (point-max) slave-name nil 'nomesg))))
16123 (defun gnus-master-read-slave-newsrc ()
16126 (file-name-directory gnus-current-startup-file)
16130 (file-name-nondirectory gnus-current-startup-file)
16134 (if (not slave-files)
16135 () ; There are no slave files to read.
16136 (gnus-message 7 "Reading slave newsrcs...")
16138 (set-buffer (get-buffer-create " *gnus slave*"))
16139 (buffer-disable-undo (current-buffer))
16141 (sort (mapcar (lambda (file)
16142 (list (nth 5 (file-attributes file)) file))
16145 (or (< (car (car f1)) (car (car f2)))
16146 (< (nth 1 (car f1)) (nth 1 (car f2)))))))
16149 (setq file (nth 1 (car slave-files)))
16150 (insert-file-contents file)
16151 (if (condition-case ()
16153 (eval-buffer (current-buffer))
16156 (gnus-message 3 "Possible error in %s" file)
16160 (or gnus-slave ; Slaves shouldn't delete these files.
16164 (setq slave-files (cdr slave-files))))
16165 (gnus-message 7 "Reading slave newsrcs...done"))))
16169 ;;; Group description.
16172 (defun gnus-read-all-descriptions-files ()
16173 (let ((methods (cons gnus-select-method
16175 gnus-secondary-select-methods))))
16177 (gnus-read-descriptions-file (car methods))
16178 (setq methods (cdr methods)))
16181 (defun gnus-read-descriptions-file (&optional method)
16182 (let ((method (or method gnus-select-method)))
16183 (when (stringp method)
16184 (setq method (gnus-server-to-method method)))
16185 ;; We create the hashtable whether we manage to read the desc file
16186 ;; to avoid trying to re-read after a failed read.
16187 (or gnus-description-hashtb
16188 (setq gnus-description-hashtb
16189 (gnus-make-hashtable (length gnus-active-hashtb))))
16190 ;; Mark this method's desc file as read.
16191 (gnus-sethash (gnus-group-prefixed-name "" method) "Has read"
16192 gnus-description-hashtb)
16194 (gnus-message 5 "Reading descriptions file via %s..." (car method))
16196 ((not (gnus-check-server method))
16197 (gnus-message 1 "Couldn't open server")
16199 ((not (gnus-request-list-newsgroups method))
16200 (gnus-message 1 "Couldn't read newsgroups descriptions")
16206 (set-buffer nntp-server-buffer)
16207 (goto-char (point-min))
16208 (if (or (search-forward "\n.\n" nil t)
16209 (goto-char (point-max)))
16211 (beginning-of-line)
16212 (narrow-to-region (point-min) (point))))
16213 (goto-char (point-min))
16214 (while (not (eobp))
16215 ;; If we get an error, we set group to 0, which is not a
16219 (let ((obarray gnus-description-hashtb))
16220 ;; Group is set to a symbol interned in this
16222 (read nntp-server-buffer))
16224 (skip-chars-forward " \t")
16225 ;; ... which leads to this line being effectively ignored.
16226 (and (symbolp group)
16227 (set group (buffer-substring
16228 (point) (progn (end-of-line) (point)))))
16229 (forward-line 1))))
16230 (gnus-message 5 "Reading descriptions file...done")
16233 (defun gnus-group-get-description (group)
16234 "Get the description of a group by sending XGTITLE to the server."
16235 (when (gnus-request-group-description group)
16237 (set-buffer nntp-server-buffer)
16238 (goto-char (point-min))
16239 (when (looking-at "[^ \t]+[ \t]+\\(.*\\)")
16240 (match-string 1)))))
16244 ;;; Buffering of read articles.
16247 (defvar gnus-backlog-buffer " *Gnus Backlog*")
16248 (defvar gnus-backlog-articles nil)
16249 (defvar gnus-backlog-hashtb nil)
16251 (defun gnus-backlog-buffer ()
16252 "Return the backlog buffer."
16253 (or (get-buffer gnus-backlog-buffer)
16255 (set-buffer (get-buffer-create gnus-backlog-buffer))
16256 (buffer-disable-undo (current-buffer))
16257 (setq buffer-read-only t)
16258 (gnus-add-current-to-buffer-list)
16259 (get-buffer gnus-backlog-buffer))))
16261 (defun gnus-backlog-setup ()
16262 "Initialize backlog variables."
16263 (unless gnus-backlog-hashtb
16264 (setq gnus-backlog-hashtb (make-vector 1023 0))))
16266 (defun gnus-backlog-shutdown ()
16267 "Clear all backlog variables and buffers."
16268 (when (get-buffer gnus-backlog-buffer)
16269 (kill-buffer gnus-backlog-buffer))
16270 (setq gnus-backlog-hashtb nil
16271 gnus-backlog-articles nil))
16273 (defun gnus-backlog-enter-article (group number buffer)
16274 (gnus-backlog-setup)
16275 (let ((ident (intern (concat group ":" (int-to-string number))
16276 gnus-backlog-hashtb))
16278 (if (memq ident gnus-backlog-articles)
16279 () ; It's already kept.
16280 ;; Remove the oldest article, if necessary.
16281 (and (numberp gnus-keep-backlog)
16282 (>= (length gnus-backlog-articles) gnus-keep-backlog)
16283 (gnus-backlog-remove-oldest-article))
16284 (setq gnus-backlog-articles (cons ident gnus-backlog-articles))
16285 ;; Insert the new article.
16287 (set-buffer (gnus-backlog-buffer))
16288 (let (buffer-read-only)
16289 (goto-char (point-max))
16290 (or (bolp) (insert "\n"))
16292 (insert-buffer-substring buffer)
16293 ;; Tag the beginning of the article with the ident.
16294 (put-text-property b (1+ b) 'gnus-backlog ident))))))
16296 (defun gnus-backlog-remove-oldest-article ()
16298 (set-buffer (gnus-backlog-buffer))
16299 (goto-char (point-min))
16300 (if (zerop (buffer-size))
16301 () ; The buffer is empty.
16302 (let ((ident (get-text-property (point) 'gnus-backlog))
16304 ;; Remove the ident from the list of articles.
16306 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
16307 ;; Delete the article itself.
16309 (point) (next-single-property-change
16310 (1+ (point)) 'gnus-backlog nil (point-max)))))))
16312 (defun gnus-backlog-request-article (group number buffer)
16313 (gnus-backlog-setup)
16314 (let ((ident (intern (concat group ":" (int-to-string number))
16315 gnus-backlog-hashtb))
16317 (when (memq ident gnus-backlog-articles)
16318 ;; It was in the backlog.
16320 (set-buffer (gnus-backlog-buffer))
16321 (if (not (setq beg (text-property-any
16322 (point-min) (point-max) 'gnus-backlog
16324 ;; It wasn't in the backlog after all.
16326 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
16327 ;; Find the end (i. e., the beginning of the next article).
16329 (next-single-property-change
16330 (1+ beg) 'gnus-backlog (current-buffer) (point-max)))))
16331 (let ((buffer-read-only nil))
16333 (insert-buffer-substring gnus-backlog-buffer beg end)
16336 ;; Allow redefinition of Gnus functions.
16338 (gnus-ems-redefine)
16342 ;;; gnus.el ends here