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).")
79 ;; Customization variables
81 ;; Don't touch this variable.
82 (defvar gnus-nntp-service "nntp"
83 "*NNTP service name (\"nntp\" or 119).
84 This is an obsolete variable, which is scarcely used. If you use an
85 nntp server for your newsgroup and want to change the port number
86 used to 899, you would say something along these lines:
88 (setq gnus-select-method '(nntp \"my.nntp.server\" (nntp-port-number 899)))")
90 (defvar gnus-nntpserver-file "/etc/nntpserver"
91 "*A file with only the name of the nntp server in it.")
93 ;; This function is used to check both the environment variable
94 ;; NNTPSERVER and the /etc/nntpserver file to see whether one can find
95 ;; an nntp server name default.
96 (defun gnus-getenv-nntpserver ()
97 (or (getenv "NNTPSERVER")
98 (and (file-readable-p gnus-nntpserver-file)
100 (set-buffer (get-buffer-create " *gnus nntp*"))
101 (buffer-disable-undo (current-buffer))
102 (insert-file-contents gnus-nntpserver-file)
103 (let ((name (buffer-string)))
105 (if (string-match "^[ \t\n]*$" name)
108 (kill-buffer (current-buffer))))))))
110 (defvar gnus-select-method
112 (list 'nntp (or (condition-case ()
113 (gnus-getenv-nntpserver)
115 (if (and gnus-default-nntp-server
116 (not (string= gnus-default-nntp-server "")))
117 gnus-default-nntp-server)
119 (if (or (null gnus-nntp-service)
120 (equal gnus-nntp-service "nntp"))
122 (list gnus-nntp-service)))
123 "*Default method for selecting a newsgroup.
124 This variable should be a list, where the first element is how the
125 news is to be fetched, the second is the address.
127 For instance, if you want to get your news via NNTP from
128 \"flab.flab.edu\", you could say:
130 (setq gnus-select-method '(nntp \"flab.flab.edu\"))
132 If you want to use your local spool, say:
134 (setq gnus-select-method (list 'nnspool (system-name)))
136 If you use this variable, you must set `gnus-nntp-server' to nil.
138 There is a lot more to know about select methods and virtual servers -
139 see the manual for details.")
141 (defvar gnus-message-archive-method
142 '(nnfolder "archive" (nnfolder-directory "~/Mail/archive/")
143 (nnfolder-active-file "~/Mail/archive/active")
144 (nnfolder-get-new-mail nil)
145 (nnfolder-inhibit-expiry t))
146 "*Method used for archiving messages you've sent.
147 This should be a mail method.")
149 (defvar gnus-refer-article-method nil
150 "*Preferred method for fetching an article by Message-ID.
151 If you are reading news from the local spool (with nnspool), fetching
152 articles by Message-ID is painfully slow. By setting this method to an
153 nntp method, you might get acceptable results.
155 The value of this variable must be a valid select method as discussed
156 in the documentation of `gnus-select-method'")
158 (defvar gnus-secondary-select-methods nil
159 "*A list of secondary methods that will be used for reading news.
160 This is a list where each element is a complete select method (see
161 `gnus-select-method').
163 If, for instance, you want to read your mail with the nnml backend,
164 you could set this variable:
166 (setq gnus-secondary-select-methods '((nnml \"\")))")
168 (defvar gnus-secondary-servers nil
169 "*List of NNTP servers that the user can choose between interactively.
170 To make Gnus query you for a server, you have to give `gnus' a
171 non-numeric prefix - `C-u M-x gnus', in short.")
173 (defvar gnus-nntp-server nil
174 "*The name of the host running the NNTP server.
175 This variable is semi-obsolete. Use the `gnus-select-method'
178 (defvar gnus-startup-file "~/.newsrc"
179 "*Your `.newsrc' file.
180 `.newsrc-SERVER' will be used instead if that exists.")
182 (defvar gnus-init-file "~/.gnus"
183 "*Your Gnus elisp startup file.
184 If a file with the .el or .elc suffixes exist, it will be read
187 (defvar gnus-group-faq-directory
188 '("/ftp@mirrors.aol.com:/pub/rtfm/usenet/"
189 ; "/ftp@ftp.uu.net:/usenet/news.answers/"
190 "/ftp@src.doc.ic.ac.uk:/usenet/news-FAQS/"
191 "/ftp@ftp.seas.gwu.edu:/pub/rtfm/"
192 "/ftp@rtfm.mit.edu:/pub/usenet/news.answers/"
193 "/ftp@ftp.uni-paderborn.de:/pub/FAQ/"
194 ; "/ftp@ftp.Germany.EU.net:/pub/newsarchive/news.answers/"
195 "/ftp@ftp.sunet.se:/pub/usenet/"
196 "/ftp@nctuccca.edu.tw:/USENET/FAQ/"
197 "/ftp@hwarang.postech.ac.kr:/pub/usenet/news.answers/"
198 "/ftp@ftp.hk.super.net:/mirror/faqs/")
199 "*Directory where the group FAQs are stored.
200 This will most commonly be on a remote machine, and the file will be
203 This variable can also be a list of directories. In that case, the
204 first element in the list will be used by default, and the others will
205 be used as backup sites.
207 Note that Gnus uses an aol machine as the default directory. If this
208 feels fundamentally unclean, just think of it as a way to finally get
209 something of value back from them.
211 If the default site is too slow, try one of these:
213 North America: mirrors.aol.com /pub/rtfm/usenet
214 ftp.seas.gwu.edu /pub/rtfm
215 rtfm.mit.edu /pub/usenet/news.answers
216 Europe: ftp.uni-paderborn.de /pub/FAQ
217 src.doc.ic.ac.uk /usenet/news-FAQS
218 ftp.sunet.se /pub/usenet
219 Asia: nctuccca.edu.tw /USENET/FAQ
220 hwarang.postech.ac.kr /pub/usenet/news.answers
221 ftp.hk.super.net /mirror/faqs")
223 (defvar gnus-group-archive-directory
224 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
225 "*The address of the (ding) archives.")
227 (defvar gnus-group-recent-archive-directory
228 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
229 "*The address of the most recent (ding) articles.")
231 (defvar gnus-default-subscribed-newsgroups nil
232 "*This variable lists what newsgroups should be subscribed the first time Gnus is used.
233 It should be a list of strings.
234 If it is `t', Gnus will not do anything special the first time it is
235 started; it'll just use the normal newsgroups subscription methods.")
237 (defvar gnus-use-cross-reference t
238 "*Non-nil means that cross referenced articles will be marked as read.
239 If nil, ignore cross references. If t, mark articles as read in
240 subscribed newsgroups. If neither t nor nil, mark as read in all
243 (defvar gnus-single-article-buffer t
244 "*If non-nil, display all articles in the same buffer.
245 If nil, each group will get its own article buffer.")
247 (defvar gnus-use-dribble-file t
248 "*Non-nil means that Gnus will use a dribble file to store user updates.
249 If Emacs should crash without saving the .newsrc files, complete
250 information can be restored from the dribble file.")
252 (defvar gnus-dribble-directory nil
253 "*The directory where dribble files will be saved.
254 If this variable is nil, the directory where the .newsrc files are
255 saved will be used.")
257 (defvar gnus-asynchronous nil
258 "*If non-nil, Gnus will supply backends with data needed for async article fetching.")
260 (defvar gnus-kill-summary-on-exit t
261 "*If non-nil, kill the summary buffer when you exit from it.
262 If nil, the summary will become a \"*Dead Summary*\" buffer, and
263 it will be killed sometime later.")
265 (defvar gnus-large-newsgroup 200
266 "*The number of articles which indicates a large newsgroup.
267 If the number of articles in a newsgroup is greater than this value,
268 confirmation is required for selecting the newsgroup.")
270 ;; Suggested by Andrew Eskilsson <pi92ae@lelle.pt.hk-r.se>.
271 (defvar gnus-no-groups-message "No news is horrible news"
272 "*Message displayed by Gnus when no groups are available.")
274 (defvar gnus-use-long-file-name (not (memq system-type '(usg-unix-v xenix)))
275 "*Non-nil means that the default name of a file to save articles in is the group name.
276 If it's nil, the directory form of the group name is used instead.
278 If this variable is a list, and the list contains the element
279 `not-score', long file names will not be used for score files; if it
280 contains the element `not-save', long file names will not be used for
281 saving; and if it contains the element `not-kill', long file names
282 will not be used for kill files.")
284 (defvar gnus-article-save-directory (or (getenv "SAVEDIR") "~/News/")
285 "*Name of the directory articles will be saved in (default \"~/News\").
286 Initialized from the SAVEDIR environment variable.")
288 (defvar gnus-kill-files-directory (or (getenv "SAVEDIR") "~/News/")
289 "*Name of the directory where kill files will be stored (default \"~/News\").
290 Initialized from the SAVEDIR environment variable.")
292 (defvar gnus-default-article-saver 'gnus-summary-save-in-rmail
293 "*A function to save articles in your favorite format.
294 The function must be interactively callable (in other words, it must
295 be an Emacs command).
297 Gnus provides the following functions:
299 * gnus-summary-save-in-rmail (Rmail format)
300 * gnus-summary-save-in-mail (Unix mail format)
301 * gnus-summary-save-in-folder (MH folder)
302 * gnus-summary-save-in-file (article format).
303 * gnus-summary-save-in-vm (use VM's folder format).")
305 (defvar gnus-prompt-before-saving 'always
306 "*This variable says how much prompting is to be done when saving articles.
307 If it is nil, no prompting will be done, and the articles will be
308 saved to the default files. If this variable is `always', each and
309 every article that is saved will be preceded by a prompt, even when
310 saving large batches of articles. If this variable is neither nil not
311 `always', there the user will be prompted once for a file name for
312 each invocation of the saving commands.")
314 (defvar gnus-rmail-save-name (function gnus-plain-save-name)
315 "*A function generating a file name to save articles in Rmail format.
316 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
318 (defvar gnus-mail-save-name (function gnus-plain-save-name)
319 "*A function generating a file name to save articles in Unix mail format.
320 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
322 (defvar gnus-folder-save-name (function gnus-folder-save-name)
323 "*A function generating a file name to save articles in MH folder.
324 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER.")
326 (defvar gnus-file-save-name (function gnus-numeric-save-name)
327 "*A function generating a file name to save articles in article format.
328 The function is called with NEWSGROUP, HEADERS, and optional
331 (defvar gnus-split-methods
332 '((gnus-article-archive-name))
333 "*Variable used to suggest where articles are to be saved.
334 For instance, if you would like to save articles related to Gnus in
335 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
336 you could set this variable to something like:
338 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
339 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
341 This variable is an alist where the where the key is the match and the
342 value is a list of possible files to save in if the match is non-nil.
344 If the match is a string, it is used as a regexp match on the
345 article. If the match is a symbol, that symbol will be funcalled
346 from the buffer of the article to be saved with the newsgroup as the
347 parameter. If it is a list, it will be evaled in the same buffer.
349 If this form or function returns a string, this string will be used as
350 a possible file name; and if it returns a non-nil list, that list will
351 be used as possible file names.")
353 (defvar gnus-move-split-methods nil
354 "*Variable used to suggest where articles are to be moved to.
355 It uses the same syntax as the `gnus-split-methods' variable.")
357 (defvar gnus-save-score nil
358 "*If non-nil, save group scoring info.")
360 (defvar gnus-use-adaptive-scoring nil
361 "*If non-nil, use some adaptive scoring scheme.")
363 (defvar gnus-use-cache nil
364 "*If nil, Gnus will ignore the article cache.
365 If `passive', it will allow entering (and reading) articles
366 explicitly entered into the cache. If anything else, use the
367 cache to the full extent of the law.")
369 (defvar gnus-use-trees nil
370 "*If non-nil, display a thread tree buffer.")
372 (defvar gnus-keep-backlog nil
373 "*If non-nil, Gnus will keep read articles for later re-retrieval.
374 If it is a number N, then Gnus will only keep the last N articles
375 read. If it is neither nil nor a number, Gnus will keep all read
376 articles. This is not a good idea.")
378 (defvar gnus-use-nocem nil
379 "*If non-nil, Gnus will read NoCeM cancel messages.")
381 (defvar gnus-use-demon nil
382 "If non-nil, Gnus might use some demons.")
384 (defvar gnus-use-scoring t
385 "*If non-nil, enable scoring.")
387 (defvar gnus-use-picons nil
388 "*If non-nil, display picons.")
390 (defvar gnus-fetch-old-headers nil
391 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
392 If an unread article in the group refers to an older, already read (or
393 just marked as read) article, the old article will not normally be
394 displayed in the Summary buffer. If this variable is non-nil, Gnus
395 will attempt to grab the headers to the old articles, and thereby
396 build complete threads. If it has the value `some', only enough
397 headers to connect otherwise loose threads will be displayed.
398 This variable can also be a number. In that case, no more than that
399 number of old headers will be fetched.
401 The server has to support NOV for any of this to work.")
404 ;(defvar gnus-visual t
405 ; "*If non-nil, will do various highlighting.
406 ;If nil, no mouse highlights (or any other highlights) will be
407 ;performed. This might speed up Gnus some when generating large group
408 ;and summary buffers.")
410 (defvar gnus-novice-user t
411 "*Non-nil means that you are a usenet novice.
412 If non-nil, verbose messages may be displayed and confirmations may be
415 (defvar gnus-expert-user nil
416 "*Non-nil means that you will never be asked for confirmation about anything.
417 And that means *anything*.")
419 (defvar gnus-verbose 7
420 "*Integer that says how verbose Gnus should be.
421 The higher the number, the more messages Gnus will flash to say what
422 it's doing. At zero, Gnus will be totally mute; at five, Gnus will
423 display most important messages; and at ten, Gnus will keep on
424 jabbering all the time.")
426 (defvar gnus-keep-same-level nil
427 "*Non-nil means that the next newsgroup after the current will be on the same level.
428 When you type, for instance, `n' after reading the last article in the
429 current newsgroup, you will go to the next newsgroup. If this variable
430 is nil, the next newsgroup will be the next from the group
432 If this variable is non-nil, Gnus will either put you in the
433 next newsgroup with the same level, or, if no such newsgroup is
434 available, the next newsgroup with the lowest possible level higher
435 than the current level.
436 If this variable is `best', Gnus will make the next newsgroup the one
437 with the best level.")
439 (defvar gnus-summary-make-false-root 'adopt
440 "*nil means that Gnus won't gather loose threads.
441 If the root of a thread has expired or been read in a previous
442 session, the information necessary to build a complete thread has been
443 lost. Instead of having many small sub-threads from this original thread
444 scattered all over the summary buffer, Gnus can gather them.
446 If non-nil, Gnus will try to gather all loose sub-threads from an
447 original thread into one large thread.
449 If this variable is non-nil, it should be one of `none', `adopt',
452 If this variable is `none', Gnus will not make a false root, but just
453 present the sub-threads after another.
454 If this variable is `dummy', Gnus will create a dummy root that will
455 have all the sub-threads as children.
456 If this variable is `adopt', Gnus will make one of the \"children\"
457 the parent and mark all the step-children as such.
458 If this variable is `empty', the \"children\" are printed with empty
459 subject fields. (Or rather, they will be printed with a string
460 given by the `gnus-summary-same-subject' variable.)")
462 (defvar gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
463 "*A regexp to match subjects to be excluded from loose thread gathering.
464 As loose thread gathering is done on subjects only, that means that
465 there can be many false gatherings performed. By rooting out certain
466 common subjects, gathering might become saner.")
468 (defvar gnus-summary-gather-subject-limit nil
469 "*Maximum length of subject comparisons when gathering loose threads.
470 Use nil to compare full subjects. Setting this variable to a low
471 number will help gather threads that have been corrupted by
472 newsreaders chopping off subject lines, but it might also mean that
473 unrelated articles that have subject that happen to begin with the
474 same few characters will be incorrectly gathered.
476 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
477 comparing subjects.")
479 (defvar gnus-simplify-ignored-prefixes nil
480 "*Regexp, matches for which are removed from subject lines when simplifying.")
482 (defvar gnus-build-sparse-threads nil
483 "*If non-nil, fill in the gaps in threads.
484 If `some', only fill in the gaps that are needed to tie loose threads
485 together. If `more', fill in all leaf nodes that Gnus can find. If
486 non-nil and non-`some', fill in all gaps that Gnus manages to guess.")
488 (defvar gnus-summary-thread-gathering-function 'gnus-gather-threads-by-subject
489 "Function used for gathering loose threads.
490 There are two pre-defined functions: `gnus-gather-threads-by-subject',
491 which only takes Subjects into consideration; and
492 `gnus-gather-threads-by-references', which compared the References
493 headers of the articles to find matches.")
495 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
496 (defvar gnus-summary-same-subject ""
497 "*String indicating that the current article has the same subject as the previous.
498 This variable will only be used if the value of
499 `gnus-summary-make-false-root' is `empty'.")
501 (defvar gnus-summary-goto-unread t
502 "*If non-nil, marking commands will go to the next unread article.
503 If `never', \\<gnus-summary-mode-map>\\[gnus-summary-next-page] will go to the next article,
504 whether it is read or not.")
506 (defvar gnus-group-goto-unread t
507 "*If non-nil, movement commands will go to the next unread and subscribed group.")
509 (defvar gnus-goto-next-group-when-activating t
510 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group.")
512 (defvar gnus-check-new-newsgroups t
513 "*Non-nil means that Gnus will add new newsgroups at startup.
514 If this variable is `ask-server', Gnus will ask the server for new
515 groups since the last time it checked. This means that the killed list
516 is no longer necessary, so you could set `gnus-save-killed-list' to
519 A variant is to have this variable be a list of select methods. Gnus
520 will then use the `ask-server' method on all these select methods to
521 query for new groups from all those servers.
524 (setq gnus-check-new-newsgroups
525 '((nntp \"some.server\") (nntp \"other.server\")))
527 If this variable is nil, then you have to tell Gnus explicitly to
528 check for new newsgroups with \\<gnus-group-mode-map>\\[gnus-find-new-newsgroups].")
530 (defvar gnus-check-bogus-newsgroups nil
531 "*Non-nil means that Gnus will check and remove bogus newsgroup at startup.
532 If this variable is nil, then you have to tell Gnus explicitly to
533 check for bogus newsgroups with \\<gnus-group-mode-map>\\[gnus-group-check-bogus-groups].")
535 (defvar gnus-read-active-file t
536 "*Non-nil means that Gnus will read the entire active file at startup.
537 If this variable is nil, Gnus will only know about the groups in your
540 If this variable is `some', Gnus will try to only read the relevant
541 parts of the active file from the server. Not all servers support
542 this, and it might be quite slow with other servers, but this should
543 generally be faster than both the t and nil value.
545 If you set this variable to nil or `some', you probably still want to
546 be told about new newsgroups that arrive. To do that, set
547 `gnus-check-new-newsgroups' to `ask-server'. This may not work
548 properly with all servers.")
550 (defvar gnus-level-subscribed 5
551 "*Groups with levels less than or equal to this variable are subscribed.")
553 (defvar gnus-level-unsubscribed 7
554 "*Groups with levels less than or equal to this variable are unsubscribed.
555 Groups with levels less than `gnus-level-subscribed', which should be
556 less than this variable, are subscribed.")
558 (defvar gnus-level-zombie 8
559 "*Groups with this level are zombie groups.")
561 (defvar gnus-level-killed 9
562 "*Groups with this level are killed.")
564 (defvar gnus-level-default-subscribed 3
565 "*New subscribed groups will be subscribed at this level.")
567 (defvar gnus-level-default-unsubscribed 6
568 "*New unsubscribed groups will be unsubscribed at this level.")
570 (defvar gnus-activate-level (1+ gnus-level-subscribed)
571 "*Groups higher than this level won't be activated on startup.
572 Setting this variable to something log might save lots of time when
573 you have many groups that you aren't interested in.")
575 (defvar gnus-activate-foreign-newsgroups 4
576 "*If nil, Gnus will not check foreign newsgroups at startup.
577 If it is non-nil, it should be a number between one and nine. Foreign
578 newsgroups that have a level lower or equal to this number will be
579 activated on startup. For instance, if you want to active all
580 subscribed newsgroups, but not the rest, you'd set this variable to
581 `gnus-level-subscribed'.
583 If you subscribe to lots of newsgroups from different servers, startup
584 might take a while. By setting this variable to nil, you'll save time,
585 but you won't be told how many unread articles there are in the
588 (defvar gnus-save-newsrc-file t
589 "*Non-nil means that Gnus will save the `.newsrc' file.
590 Gnus always saves its own startup file, which is called
591 \".newsrc.eld\". The file called \".newsrc\" is in a format that can
592 be readily understood by other newsreaders. If you don't plan on
593 using other newsreaders, set this variable to nil to save some time on
596 (defvar gnus-save-killed-list t
597 "*If non-nil, save the list of killed groups to the startup file.
598 If you set this variable to nil, you'll save both time (when starting
599 and quitting) and space (both memory and disk), but it will also mean
600 that Gnus has no record of which groups are new and which are old, so
601 the automatic new newsgroups subscription methods become meaningless.
603 You should always set `gnus-check-new-newsgroups' to `ask-server' or
604 nil if you set this variable to nil.")
606 (defvar gnus-interactive-catchup t
607 "*If non-nil, require your confirmation when catching up a group.")
609 (defvar gnus-interactive-post t
610 "*If non-nil, group name will be asked for when posting.")
612 (defvar gnus-interactive-exit t
613 "*If non-nil, require your confirmation when exiting Gnus.")
615 (defvar gnus-kill-killed t
616 "*If non-nil, Gnus will apply kill files to already killed articles.
617 If it is nil, Gnus will never apply kill files to articles that have
618 already been through the scoring process, which might very well save lots
621 (defvar gnus-extract-address-components 'gnus-extract-address-components
622 "*Function for extracting address components from a From header.
623 Two pre-defined function exist: `gnus-extract-address-components',
624 which is the default, quite fast, and too simplistic solution, and
625 `mail-extract-address-components', which works much better, but is
628 (defvar gnus-summary-default-score 0
629 "*Default article score level.
630 If this variable is nil, scoring will be disabled.")
632 (defvar gnus-summary-zcore-fuzz 0
633 "*Fuzziness factor for the zcore in the summary buffer.
634 Articles with scores closer than this to `gnus-summary-default-score'
635 will not be marked.")
637 (defvar gnus-simplify-subject-fuzzy-regexp nil
638 "*Strings to be removed when doing fuzzy matches.
639 This can either be a regular expression or list of regular expressions
640 that will be removed from subject strings if fuzzy subject
641 simplification is selected.")
643 (defvar gnus-permanently-visible-groups nil
644 "*Regexp to match groups that should always be listed in the group buffer.
645 This means that they will still be listed when there are no unread
646 articles in the groups.")
648 (defvar gnus-list-groups-with-ticked-articles t
649 "*If non-nil, list groups that have only ticked articles.
650 If nil, only list groups that have unread articles.")
652 (defvar gnus-group-default-list-level gnus-level-subscribed
653 "*Default listing level.
654 Ignored if `gnus-group-use-permanent-levels' is non-nil.")
656 (defvar gnus-group-use-permanent-levels nil
657 "*If non-nil, once you set a level, Gnus will use this level.")
659 (defvar gnus-group-list-inactive-groups t
660 "*If non-nil, inactive groups will be listed.")
662 (defvar gnus-show-mime nil
663 "*If non-nil, do mime processing of articles.
664 The articles will simply be fed to the function given by
665 `gnus-show-mime-method'.")
667 (defvar gnus-strict-mime t
668 "*If nil, MIME-decode even if there is no Mime-Version header in the article.")
670 (defvar gnus-show-mime-method 'metamail-buffer
671 "*Function to process a MIME message.
672 The function is called from the article buffer.")
674 (defvar gnus-decode-encoded-word-method (lambda ())
675 "*Function to decode a MIME encoded-words.
676 The function is called from the article buffer.")
678 (defvar gnus-show-threads t
679 "*If non-nil, display threads in summary mode.")
681 (defvar gnus-thread-hide-subtree nil
682 "*If non-nil, hide all threads initially.
683 If threads are hidden, you have to run the command
684 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
685 to expose hidden threads.")
687 (defvar gnus-thread-hide-killed t
688 "*If non-nil, hide killed threads automatically.")
690 (defvar gnus-thread-ignore-subject nil
691 "*If non-nil, ignore subjects and do all threading based on the Reference header.
692 If nil, which is the default, articles that have different subjects
693 from their parents will start separate threads.")
695 (defvar gnus-thread-operation-ignore-subject t
696 "*If non-nil, subjects will be ignored when doing thread commands.
697 This affects commands like `gnus-summary-kill-thread' and
698 `gnus-summary-lower-thread'.
700 If this variable is nil, articles in the same thread with different
701 subjects will not be included in the operation in question. If this
702 variable is `fuzzy', only articles that have subjects that are fuzzily
703 equal will be included.")
705 (defvar gnus-thread-indent-level 4
706 "*Number that says how much each sub-thread should be indented.")
708 (defvar gnus-ignored-newsgroups
709 (purecopy (mapconcat 'identity
710 '("^to\\." ; not "real" groups
711 "^[0-9. \t]+ " ; all digits in name
712 "[][\"#'()]" ; bogus characters
715 "*A regexp to match uninteresting newsgroups in the active file.
716 Any lines in the active file matching this regular expression are
717 removed from the newsgroup list before anything else is done to it,
718 thus making them effectively non-existent.")
720 (defvar gnus-ignored-headers
721 "^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:"
722 "*All headers that match this regexp will be hidden.
723 This variable can also be a list of regexps of headers to be ignored.
724 If `gnus-visible-headers' is non-nil, this variable will be ignored.")
726 (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-"
727 "*All headers that do not match this regexp will be hidden.
728 This variable can also be a list of regexp of headers to remain visible.
729 If this variable is non-nil, `gnus-ignored-headers' will be ignored.")
731 (defvar gnus-sorted-header-list
732 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^To:"
733 "^Cc:" "^Date:" "^Organization:")
734 "*This variable is a list of regular expressions.
735 If it is non-nil, headers that match the regular expressions will
736 be placed first in the article buffer in the sequence specified by
739 (defvar gnus-boring-article-headers
740 '(empty followup-to reply-to)
741 "*Headers that are only to be displayed if they have interesting data.
742 Possible values in this list are `empty', `newsgroups', `followup-to',
743 `reply-to', and `date'.")
745 (defvar gnus-show-all-headers nil
746 "*If non-nil, don't hide any headers.")
748 (defvar gnus-save-all-headers t
749 "*If non-nil, don't remove any headers before saving.")
751 (defvar gnus-saved-headers gnus-visible-headers
752 "*Headers to keep if `gnus-save-all-headers' is nil.
753 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
754 If that variable is nil, however, all headers that match this regexp
755 will be kept while the rest will be deleted before saving.")
757 (defvar gnus-inhibit-startup-message nil
758 "*If non-nil, the startup message will not be displayed.")
760 (defvar gnus-signature-separator "^-- *$"
761 "Regexp matching signature separator.")
763 (defvar gnus-auto-extend-newsgroup t
764 "*If non-nil, extend newsgroup forward and backward when requested.")
766 (defvar gnus-auto-select-first t
767 "*If nil, don't select the first unread article when entering a group.
768 If this variable is `best', select the highest-scored unread article
769 in the group. If neither nil nor `best', select the first unread
772 If you want to prevent automatic selection of the first unread article
773 in some newsgroups, set the variable to nil in
774 `gnus-select-group-hook'.")
776 (defvar gnus-auto-select-next t
777 "*If non-nil, offer to go to the next group from the end of the previous.
778 If the value is t and the next newsgroup is empty, Gnus will exit
779 summary mode and go back to group mode. If the value is neither nil
780 nor t, Gnus will select the following unread newsgroup. In
781 particular, if the value is the symbol `quietly', the next unread
782 newsgroup will be selected without any confirmation, and if it is
783 `almost-quietly', the next group will be selected without any
784 confirmation if you are located on the last article in the group.
785 Finally, if this variable is `slightly-quietly', the `Z n' command
786 will go to the next group without confirmation.")
788 (defvar gnus-auto-select-same nil
789 "*If non-nil, select the next article with the same subject.")
791 (defvar gnus-summary-check-current nil
792 "*If non-nil, consider the current article when moving.
793 The \"unread\" movement commands will stay on the same line if the
794 current article is unread.")
796 (defvar gnus-auto-center-summary t
797 "*If non-nil, always center the current summary buffer.")
799 (defvar gnus-break-pages t
800 "*If non-nil, do page breaking on articles.
801 The page delimiter is specified by the `gnus-page-delimiter'
804 (defvar gnus-page-delimiter "^\^L"
805 "*Regexp describing what to use as article page delimiters.
806 The default value is \"^\^L\", which is a form linefeed at the
807 beginning of a line.")
809 (defvar gnus-use-full-window t
810 "*If non-nil, use the entire Emacs screen.")
812 (defvar gnus-window-configuration nil
813 "Obsolete variable. See `gnus-buffer-configuration'.")
815 (defvar gnus-window-min-width 2
816 "*Minimum width of Gnus buffers.")
818 (defvar gnus-window-min-height 1
819 "*Minimum height of Gnus buffers.")
821 (defvar gnus-buffer-configuration
825 (if gnus-carpal '(group-carpal 4))))
829 (if gnus-carpal '(summary-carpal 4))))
836 (if gnus-carpal '(summary-carpal 4))
838 (vertical ((height . 5) (width . 15)
840 (left . -1) (top . 1))
850 (if gnus-carpal '(summary-carpal 4))
851 (if gnus-use-trees '(tree 0.25))
856 (if gnus-carpal '(server-carpal 2))))
860 (if gnus-carpal '(browse-carpal 2))))
873 (article 1.0 point)))
884 (edit-group 1.0 point)))
888 (edit-server 1.0 point)))
892 (edit-score 1.0 point)))
919 (if gnus-carpal '(summary-carpal 4))
920 ("*Shell Command Output*" 1.0)))
928 "Window configuration for all possible Gnus buffers.
929 This variable is a list of lists. Each of these lists has a NAME and
930 a RULE. The NAMEs are commonsense names like `group', which names a
931 rule used when displaying the group buffer; `summary', which names a
932 rule for what happens when you enter a group and do not display an
933 article buffer; and so on. See the value of this variable for a
934 complete list of NAMEs.
936 Each RULE is a list of vectors. The first element in this vector is
937 the name of the buffer to be displayed; the second element is the
938 percentage of the screen this buffer is to occupy (a number in the
939 0.0-0.99 range); the optional third element is `point', which should
940 be present to denote which buffer point is to go to after making this
941 buffer configuration.")
943 (defvar gnus-window-to-buffer
944 '((group . gnus-group-buffer)
945 (summary . gnus-summary-buffer)
946 (article . gnus-article-buffer)
947 (server . gnus-server-buffer)
948 (browse . "*Gnus Browse Server*")
949 (edit-group . gnus-group-edit-buffer)
950 (edit-server . gnus-server-edit-buffer)
951 (group-carpal . gnus-carpal-group-buffer)
952 (summary-carpal . gnus-carpal-summary-buffer)
953 (server-carpal . gnus-carpal-server-buffer)
954 (browse-carpal . gnus-carpal-browse-buffer)
955 (edit-score . gnus-score-edit-buffer)
956 (mail . gnus-mail-buffer)
957 (post . gnus-post-news-buffer)
958 (faq . gnus-faq-buffer)
959 (picons . "*Picons*")
960 (tree . gnus-tree-buffer)
961 (info . gnus-info-buffer)
962 (draft . gnus-draft-buffer))
963 "Mapping from short symbols to buffer names or buffer variables.")
965 (defvar gnus-carpal nil
966 "*If non-nil, display clickable icons.")
968 (defvar gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies
969 "*Function called with a group name when new group is detected.
970 A few pre-made functions are supplied: `gnus-subscribe-randomly'
971 inserts new groups at the beginning of the list of groups;
972 `gnus-subscribe-alphabetically' inserts new groups in strict
973 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
974 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
975 for your decision; `gnus-subscribe-killed' kills all new groups.")
977 ;; Suggested by a bug report by Hallvard B Furuseth.
978 ;; <h.b.furuseth@usit.uio.no>.
979 (defvar gnus-subscribe-options-newsgroup-method
980 (function gnus-subscribe-alphabetically)
981 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines.
982 If, for instance, you want to subscribe to all newsgroups in the
983 \"no\" and \"alt\" hierarchies, you'd put the following in your
986 options -n no.all alt.all
988 Gnus will the subscribe all new newsgroups in these hierarchies with
989 the subscription method in this variable.")
991 (defvar gnus-subscribe-hierarchical-interactive nil
992 "*If non-nil, Gnus will offer to subscribe hierarchically.
993 When a new hierarchy appears, Gnus will ask the user:
995 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
997 If the user pressed `d', Gnus will descend the hierarchy, `y' will
998 subscribe to all newsgroups in the hierarchy and `s' will skip this
999 hierarchy in its entirety.")
1001 (defvar gnus-group-sort-function 'gnus-group-sort-by-alphabet
1002 "*Function used for sorting the group buffer.
1003 This function will be called with group info entries as the arguments
1004 for the groups to be sorted. Pre-made functions include
1005 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-unread',
1006 `gnus-group-sort-by-level', `gnus-group-sort-by-score', and
1007 `gnus-group-sort-by-rank'.
1009 This variable can also be a list of sorting functions. In that case,
1010 the most significant sort function should be the last function in the
1013 ;; Mark variables suggested by Thomas Michanek
1014 ;; <Thomas.Michanek@telelogic.se>.
1015 (defvar gnus-unread-mark ?
1016 "*Mark used for unread articles.")
1017 (defvar gnus-ticked-mark ?!
1018 "*Mark used for ticked articles.")
1019 (defvar gnus-dormant-mark ??
1020 "*Mark used for dormant articles.")
1021 (defvar gnus-del-mark ?r
1022 "*Mark used for del'd articles.")
1023 (defvar gnus-read-mark ?R
1024 "*Mark used for read articles.")
1025 (defvar gnus-expirable-mark ?E
1026 "*Mark used for expirable articles.")
1027 (defvar gnus-killed-mark ?K
1028 "*Mark used for killed articles.")
1029 (defvar gnus-souped-mark ?F
1030 "*Mark used for killed articles.")
1031 (defvar gnus-kill-file-mark ?X
1032 "*Mark used for articles killed by kill files.")
1033 (defvar gnus-low-score-mark ?Y
1034 "*Mark used for articles with a low score.")
1035 (defvar gnus-catchup-mark ?C
1036 "*Mark used for articles that are caught up.")
1037 (defvar gnus-replied-mark ?A
1038 "*Mark used for articles that have been replied to.")
1039 (defvar gnus-cached-mark ?*
1040 "*Mark used for articles that are in the cache.")
1041 (defvar gnus-saved-mark ?S
1042 "*Mark used for articles that have been saved to.")
1043 (defvar gnus-process-mark ?#
1045 (defvar gnus-ancient-mark ?O
1046 "*Mark used for ancient articles.")
1047 (defvar gnus-sparse-mark ?Q
1048 "*Mark used for sparsely reffed articles.")
1049 (defvar gnus-canceled-mark ?G
1050 "*Mark used for canceled articles.")
1051 (defvar gnus-score-over-mark ?+
1052 "*Score mark used for articles with high scores.")
1053 (defvar gnus-score-below-mark ?-
1054 "*Score mark used for articles with low scores.")
1055 (defvar gnus-empty-thread-mark ?
1056 "*There is no thread under the article.")
1057 (defvar gnus-not-empty-thread-mark ?=
1058 "*There is a thread under the article.")
1060 (defvar gnus-view-pseudo-asynchronously nil
1061 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
1063 (defvar gnus-view-pseudos nil
1064 "*If `automatic', pseudo-articles will be viewed automatically.
1065 If `not-confirm', pseudos will be viewed automatically, and the user
1066 will not be asked to confirm the command.")
1068 (defvar gnus-view-pseudos-separately t
1069 "*If non-nil, one pseudo-article will be created for each file to be viewed.
1070 If nil, all files that use the same viewing command will be given as a
1071 list of parameters to that command.")
1073 (defvar gnus-insert-pseudo-articles t
1074 "*If non-nil, insert pseudo-articles when decoding articles.")
1076 (defvar gnus-group-line-format "%M%S%p%P%5y: %(%g%)\n"
1077 "*Format of group lines.
1078 It works along the same lines as a normal formatting string,
1079 with some simple extensions.
1081 %M Only marked articles (character, \"*\" or \" \")
1082 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
1083 %L Level of subscribedness (integer)
1084 %N Number of unread articles (integer)
1085 %I Number of dormant articles (integer)
1086 %i Number of ticked and dormant (integer)
1087 %T Number of ticked articles (integer)
1088 %R Number of read articles (integer)
1089 %t Total number of articles (integer)
1090 %y Number of unread, unticked articles (integer)
1091 %G Group name (string)
1092 %g Qualified group name (string)
1093 %D Group description (string)
1094 %s Select method (string)
1095 %o Moderated group (char, \"m\")
1096 %p Process mark (char)
1097 %O Moderated group (string, \"(m)\" or \"\")
1098 %P Topic indentation (string)
1099 %n Select from where (string)
1100 %z A string that look like `<%s:%n>' if a foreign select method is used
1101 %u User defined specifier. The next character in the format string should
1102 be a letter. Gnus will call the function gnus-user-format-function-X,
1103 where X is the letter following %u. The function will be passed the
1104 current header as argument. The function should return a string, which
1105 will be inserted into the buffer just like information from any other
1108 Text between %( and %) will be highlighted with `gnus-mouse-face' when
1109 the mouse point move inside the area. There can only be one such area.
1111 Note that this format specification is not always respected. For
1112 reasons of efficiency, when listing killed groups, this specification
1113 is ignored altogether. If the spec is changed considerably, your
1114 output may end up looking strange when listing both alive and killed
1117 If you use %o or %O, reading the active file will be slower and quite
1118 a bit of extra memory will be used. %D will also worsen performance.
1119 Also note that if you change the format specification to include any
1120 of these specs, you must probably re-start Gnus to see them go into
1123 (defvar gnus-summary-line-format "%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n"
1124 "*The format specification of the lines in the summary buffer.
1126 It works along the same lines as a normal formatting string,
1127 with some simple extensions.
1129 %N Article number, left padded with spaces (string)
1131 %s Subject if it is at the root of a thread, and \"\" otherwise (string)
1132 %n Name of the poster (string)
1133 %a Extracted name of the poster (string)
1134 %A Extracted address of the poster (string)
1135 %F Contents of the From: header (string)
1136 %x Contents of the Xref: header (string)
1137 %D Date of the article (string)
1138 %d Date of the article (string) in DD-MMM format
1139 %M Message-id of the article (string)
1140 %r References of the article (string)
1141 %c Number of characters in the article (integer)
1142 %L Number of lines in the article (integer)
1143 %I Indentation based on thread level (a string of spaces)
1144 %T A string with two possible values: 80 spaces if the article
1145 is on thread level two or larger and 0 spaces on level one
1146 %R \"A\" if this article has been replied to, \" \" otherwise (character)
1147 %U Status of this article (character, \"R\", \"K\", \"-\" or \" \")
1148 %[ Opening bracket (character, \"[\" or \"<\")
1149 %] Closing bracket (character, \"]\" or \">\")
1150 %> Spaces of length thread-level (string)
1151 %< Spaces of length (- 20 thread-level) (string)
1152 %i Article score (number)
1153 %z Article zcore (character)
1154 %t Number of articles under the current thread (number).
1155 %e Whether the thread is empty or not (character).
1156 %u User defined specifier. The next character in the format string should
1157 be a letter. Gnus will call the function gnus-user-format-function-X,
1158 where X is the letter following %u. The function will be passed the
1159 current header as argument. The function should return a string, which
1160 will be inserted into the summary just like information from any other
1163 Text between %( and %) will be highlighted with `gnus-mouse-face'
1164 when the mouse point is placed inside the area. There can only be one
1167 The %U (status), %R (replied) and %z (zcore) specs have to be handled
1168 with care. For reasons of efficiency, Gnus will compute what column
1169 these characters will end up in, and \"hard-code\" that. This means that
1170 it is illegal to have these specs after a variable-length spec. Well,
1171 you might not be arrested, but your summary buffer will look strange,
1172 which is bad enough.
1174 The smart choice is to have these specs as for to the left as
1177 This restriction may disappear in later versions of Gnus.")
1179 (defvar gnus-summary-dummy-line-format
1181 "*The format specification for the dummy roots in the summary buffer.
1182 It works along the same lines as a normal formatting string,
1183 with some simple extensions.
1187 (defvar gnus-summary-mode-line-format "Gnus: %%b [%A] %Z"
1188 "*The format specification for the summary mode line.
1189 It works along the same lines as a normal formatting string,
1190 with some simple extensions:
1193 %p Unprefixed group name
1194 %A Current article number
1196 %U Number of unread articles in the group
1197 %e Number of unselected articles in the group
1198 %Z A string with unread/unselected article counts
1199 %g Shortish group name
1200 %S Subject of the current article
1201 %u User-defined spec
1202 %s Current score file name
1203 %d Number of dormant articles
1204 %r Number of articles that have been marked as read in this session
1205 %E Number of articles expunged by the score files")
1207 (defvar gnus-article-mode-line-format "Gnus: %%b %S"
1208 "*The format specification for the article mode line.
1209 See `gnus-summary-mode-line-format' for a closer description.")
1211 (defvar gnus-group-mode-line-format "Gnus: %%b {%M:%S}"
1212 "*The format specification for the group mode line.
1213 It works along the same lines as a normal formatting string,
1214 with some simple extensions:
1216 %S The native news server.
1217 %M The native select method.")
1219 (defvar gnus-valid-select-methods
1220 '(("nntp" post address prompt-address)
1222 ("nnvirtual" post-mail virtual prompt-address)
1223 ("nnmbox" mail respool)
1224 ("nnml" mail respool)
1225 ("nnmh" mail respool)
1226 ("nndir" post-mail prompt-address address)
1227 ("nneething" none prompt-address)
1228 ("nndoc" none prompt-address)
1229 ("nnbabyl" mail respool)
1230 ("nnkiboze" post virtual)
1231 ("nnsoup" post-mail)
1232 ("nnfolder" mail respool))
1233 "An alist of valid select methods.
1234 The first element of each list lists should be a string with the name
1235 of the select method. The other elements may be be the category of
1236 this method (ie. `post', `mail', `none' or whatever) or other
1237 properties that this method has (like being respoolable).
1238 If you implement a new select method, all you should have to change is
1239 this variable. I think.")
1241 (defvar gnus-updated-mode-lines '(group article summary tree)
1242 "*List of buffers that should update their mode lines.
1243 The list may contain the symbols `group', `article' and `summary'. If
1244 the corresponding symbol is present, Gnus will keep that mode line
1245 updated with information that may be pertinent.
1246 If this variable is nil, screen refresh may be quicker.")
1248 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>.
1249 (defvar gnus-mode-non-string-length nil
1250 "*Max length of mode-line non-string contents.
1251 If this is nil, Gnus will take space as is needed, leaving the rest
1252 of the modeline intact.")
1255 ;(defvar gnus-mouse-face 'highlight
1256 ; "*Face used for mouse highlighting in Gnus.
1257 ;No mouse highlights will be done if `gnus-visual' is nil.")
1259 (defvar gnus-summary-mark-below nil
1260 "*Mark all articles with a score below this variable as read.
1261 This variable is local to each summary buffer and usually set by the
1264 (defvar gnus-article-sort-functions '(gnus-article-sort-by-number)
1265 "*List of functions used for sorting articles in the summary buffer.
1266 This variable is only used when not using a threaded display.")
1268 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number)
1269 "*List of functions used for sorting threads in the summary buffer.
1270 By default, threads are sorted by article number.
1272 Each function takes two threads and return non-nil if the first thread
1273 should be sorted before the other. If you use more than one function,
1274 the primary sort function should be the last. You should probably
1275 always include `gnus-thread-sort-by-number' in the list of sorting
1276 functions -- preferably first.
1278 Ready-mady functions include `gnus-thread-sort-by-number',
1279 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
1280 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
1281 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').")
1283 (defvar gnus-thread-score-function '+
1284 "*Function used for calculating the total score of a thread.
1286 The function is called with the scores of the article and each
1287 subthread and should then return the score of the thread.
1289 Some functions you can use are `+', `max', or `min'.")
1291 (defvar gnus-summary-expunge-below nil
1292 "All articles that have a score less than this variable will be expunged.")
1294 (defvar gnus-thread-expunge-below nil
1295 "All threads that have a total score less than this variable will be expunged.
1296 See `gnus-thread-score-function' for en explanation of what a
1297 \"thread score\" is.")
1299 (defvar gnus-auto-subscribed-groups
1300 "^nnml\\|^nnfolder\\|^nnmbox\\|^nnmh\\|^nnbabyl"
1301 "*All new groups that match this regexp will be subscribed automatically.
1302 Note that this variable only deals with new groups. It has no effect
1303 whatsoever on old groups.")
1305 (defvar gnus-options-subscribe nil
1306 "*All new groups matching this regexp will be subscribed unconditionally.
1307 Note that this variable deals only with new newsgroups. This variable
1308 does not affect old newsgroups.")
1310 (defvar gnus-options-not-subscribe nil
1311 "*All new groups matching this regexp will be ignored.
1312 Note that this variable deals only with new newsgroups. This variable
1313 does not affect old (already subscribed) newsgroups.")
1315 (defvar gnus-auto-expirable-newsgroups nil
1316 "*Groups in which to automatically mark read articles as expirable.
1317 If non-nil, this should be a regexp that should match all groups in
1318 which to perform auto-expiry. This only makes sense for mail groups.")
1320 (defvar gnus-total-expirable-newsgroups nil
1321 "*Groups in which to perform expiry of all read articles.
1322 Use with extreme caution. All groups that match this regexp will be
1323 expiring - which means that all read articles will be deleted after
1324 (say) one week. (This only goes for mail groups and the like, of
1327 (defvar gnus-group-uncollapsed-levels 1
1328 "Number of group name elements to leave alone when making a short group name.")
1330 (defvar gnus-hidden-properties '(invisible t intangible t)
1331 "Property list to use for hiding text.")
1333 (defvar gnus-modtime-botch nil
1334 "*Non-nil means .newsrc should be deleted prior to save. Its use is
1335 due to the bogus appearance that .newsrc was modified on disc.")
1339 (defvar gnus-group-mode-hook nil
1340 "*A hook for Gnus group mode.")
1342 (defvar gnus-summary-mode-hook nil
1343 "*A hook for Gnus summary mode.
1344 This hook is run before any variables are set in the summary buffer.")
1346 (defvar gnus-article-mode-hook nil
1347 "*A hook for Gnus article mode.")
1349 (defvar gnus-summary-prepare-exit-hook nil
1350 "*A hook called when preparing to exit from the summary buffer.
1351 It calls `gnus-summary-expire-articles' by default.")
1352 (add-hook 'gnus-summary-prepare-exit-hook 'gnus-summary-expire-articles)
1354 (defvar gnus-summary-exit-hook nil
1355 "*A hook called on exit from the summary buffer.")
1357 (defvar gnus-group-catchup-group-hook nil
1358 "*A hook run when catching up a group from the group buffer.")
1360 (defvar gnus-open-server-hook nil
1361 "*A hook called just before opening connection to the news server.")
1363 (defvar gnus-load-hook nil
1364 "*A hook run while Gnus is loaded.")
1366 (defvar gnus-startup-hook nil
1367 "*A hook called at startup.
1368 This hook is called after Gnus is connected to the NNTP server.")
1370 (defvar gnus-get-new-news-hook nil
1371 "*A hook run just before Gnus checks for new news.")
1373 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat
1374 "*A function that is called to generate the group buffer.
1375 The function is called with three arguments: The first is a number;
1376 all group with a level less or equal to that number should be listed,
1377 if the second is non-nil, empty groups should also be displayed. If
1378 the third is non-nil, it is a number. No groups with a level lower
1379 than this number should be displayed.
1381 The only current function implemented is `gnus-group-prepare-flat'.")
1383 (defvar gnus-group-prepare-hook nil
1384 "*A hook called after the group buffer has been generated.
1385 If you want to modify the group buffer, you can use this hook.")
1387 (defvar gnus-summary-prepare-hook nil
1388 "*A hook called after the summary buffer has been generated.
1389 If you want to modify the summary buffer, you can use this hook.")
1391 (defvar gnus-summary-generate-hook nil
1392 "*A hook run just before generating the summary buffer.
1393 This hook is commonly used to customize threading variables and the
1396 (defvar gnus-article-prepare-hook nil
1397 "*A hook called after an article has been prepared in the article buffer.
1398 If you want to run a special decoding program like nkf, use this hook.")
1400 ;(defvar gnus-article-display-hook nil
1401 ; "*A hook called after the article is displayed in the article buffer.
1402 ;The hook is designed to change the contents of the article
1403 ;buffer. Typical functions that this hook may contain are
1404 ;`gnus-article-hide-headers' (hide selected headers),
1405 ;`gnus-article-maybe-highlight' (perform fancy article highlighting),
1406 ;`gnus-article-hide-signature' (hide signature) and
1407 ;`gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).")
1408 ;(add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted)
1409 ;(add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike)
1410 ;(add-hook 'gnus-article-display-hook 'gnus-article-maybe-highlight)
1412 (defvar gnus-article-x-face-command
1413 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | xv -quit -"
1414 "String or function to be executed to display an X-Face header.
1415 If it is a string, the command will be executed in a sub-shell
1416 asynchronously. The compressed face will be piped to this command.")
1418 (defvar gnus-article-x-face-too-ugly nil
1419 "Regexp matching posters whose face shouldn't be shown automatically.")
1421 (defvar gnus-select-group-hook nil
1422 "*A hook called when a newsgroup is selected.
1424 If you'd like to simplify subjects like the
1425 `gnus-summary-next-same-subject' command does, you can use the
1428 (setq gnus-select-group-hook
1431 (mapcar (lambda (header)
1432 (mail-header-set-subject
1434 (gnus-simplify-subject
1435 (mail-header-subject header) 're-only)))
1436 gnus-newsgroup-headers))))")
1438 (defvar gnus-select-article-hook nil
1439 "*A hook called when an article is selected.")
1441 (defvar gnus-apply-kill-hook '(gnus-apply-kill-file)
1442 "*A hook called to apply kill files to a group.
1443 This hook is intended to apply a kill file to the selected newsgroup.
1444 The function `gnus-apply-kill-file' is called by default.
1446 Since a general kill file is too heavy to use only for a few
1447 newsgroups, I recommend you to use a lighter hook function. For
1448 example, if you'd like to apply a kill file to articles which contains
1449 a string `rmgroup' in subject in newsgroup `control', you can use the
1452 (setq gnus-apply-kill-hook
1455 (cond ((string-match \"control\" gnus-newsgroup-name)
1456 (gnus-kill \"Subject\" \"rmgroup\")
1457 (gnus-expunge \"X\"))))))")
1459 (defvar gnus-visual-mark-article-hook
1460 (list 'gnus-highlight-selected-summary)
1461 "*Hook run after selecting an article in the summary buffer.
1462 It is meant to be used for highlighting the article in some way. It
1463 is not run if `gnus-visual' is nil.")
1465 (defvar gnus-parse-headers-hook nil
1466 "*A hook called before parsing the headers.")
1468 (defvar gnus-exit-group-hook nil
1469 "*A hook called when exiting (not quitting) summary mode.")
1471 (defvar gnus-suspend-gnus-hook nil
1472 "*A hook called when suspending (not exiting) Gnus.")
1474 (defvar gnus-exit-gnus-hook nil
1475 "*A hook called when 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)))
1526 ;; Internal variables
1528 (defvar gnus-topic-indentation "") ;; Obsolete variable.
1530 (defvar gnus-goto-missing-group-function nil)
1532 (defvar gnus-override-subscribe-method nil)
1534 (defvar gnus-group-goto-next-group-function nil
1535 "Function to override finding the next group after listing groups.")
1537 (defconst gnus-article-mark-lists
1538 '((marked . tick) (replied . reply)
1539 (expirable . expire) (killed . killed)
1540 (bookmarks . bookmark) (dormant . dormant)
1541 (scored . score) (saved . save)
1544 ;; Avoid highlighting in kill files.
1545 (defvar gnus-summary-inhibit-highlight nil)
1546 (defvar gnus-newsgroup-selected-overlay nil)
1548 (defvar gnus-inhibit-hiding nil)
1549 (defvar gnus-group-indentation "")
1550 (defvar gnus-inhibit-limiting nil)
1552 (defvar gnus-article-mode-map nil)
1553 (defvar gnus-dribble-buffer nil)
1554 (defvar gnus-headers-retrieved-by nil)
1555 (defvar gnus-article-reply nil)
1556 (defvar gnus-override-method nil)
1557 (defvar gnus-article-check-size nil)
1559 (defvar gnus-nocem-hashtb nil)
1561 (defvar gnus-current-score-file nil)
1562 (defvar gnus-newsgroup-adaptive-score-file nil)
1563 (defvar gnus-scores-exclude-files nil)
1565 (defvar gnus-opened-servers nil)
1567 (defvar gnus-current-move-group nil)
1569 (defvar gnus-newsgroup-dependencies nil)
1570 (defvar gnus-newsgroup-async nil)
1571 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*")
1573 (defvar gnus-newsgroup-adaptive nil)
1575 (defvar gnus-summary-display-table nil)
1576 (defvar gnus-summary-display-article-function nil)
1578 (defvar gnus-summary-highlight-line-function nil
1579 "Function called after highlighting a summary line.")
1581 (defvar gnus-group-line-format-alist
1582 `((?M gnus-tmp-marked-mark ?c)
1583 (?S gnus-tmp-subscribed ?c)
1584 (?L gnus-tmp-level ?d)
1585 (?N (cond ((eq number t) "*" )
1589 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1590 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
1592 (?R gnus-tmp-number-of-read ?s)
1593 (?t gnus-tmp-number-total ?d)
1594 (?y gnus-tmp-number-of-unread ?s)
1595 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
1596 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
1597 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1598 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
1599 (?g gnus-tmp-group ?s)
1600 (?G gnus-tmp-qualified-group ?s)
1601 (?c (gnus-short-group-name gnus-tmp-group) ?s)
1602 (?D gnus-tmp-newsgroup-description ?s)
1603 (?o gnus-tmp-moderated ?c)
1604 (?O gnus-tmp-moderated-string ?s)
1605 (?p gnus-tmp-process-marked ?c)
1606 (?s gnus-tmp-news-server ?s)
1607 (?n gnus-tmp-news-method ?s)
1608 (?P gnus-group-indentation ?s)
1609 (?z gnus-tmp-news-method-string ?s)
1610 (?u gnus-tmp-user-defined ?s)))
1612 (defvar gnus-summary-line-format-alist
1613 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1614 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1615 (?s gnus-tmp-subject-or-nil ?s)
1616 (?n gnus-tmp-name ?s)
1617 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1619 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1621 (?F gnus-tmp-from ?s)
1622 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1623 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1624 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1625 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1626 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1627 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1628 (?L gnus-tmp-lines ?d)
1629 (?I gnus-tmp-indentation ?s)
1630 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1631 (?R gnus-tmp-replied ?c)
1632 (?\[ gnus-tmp-opening-bracket ?c)
1633 (?\] gnus-tmp-closing-bracket ?c)
1634 (?\> (make-string gnus-tmp-level ? ) ?s)
1635 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1636 (?i gnus-tmp-score ?d)
1637 (?z gnus-tmp-score-char ?c)
1638 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1639 (?U gnus-tmp-unread ?c)
1640 (?t (gnus-summary-number-of-articles-in-thread
1641 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1643 (?e (gnus-summary-number-of-articles-in-thread
1644 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1646 (?u gnus-tmp-user-defined ?s))
1647 "An alist of format specifications that can appear in summary lines,
1648 and what variables they correspond with, along with the type of the
1649 variable (string, integer, character, etc).")
1651 (defvar gnus-summary-dummy-line-format-alist
1652 (` ((?S gnus-tmp-subject ?s)
1653 (?N gnus-tmp-number ?d)
1654 (?u gnus-tmp-user-defined ?s))))
1656 (defvar gnus-summary-mode-line-format-alist
1657 (` ((?G gnus-tmp-group-name ?s)
1658 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1659 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1660 (?A gnus-tmp-article-number ?d)
1661 (?Z gnus-tmp-unread-and-unselected ?s)
1662 (?V gnus-version ?s)
1663 (?U gnus-tmp-unread ?d)
1664 (?S gnus-tmp-subject ?s)
1665 (?e gnus-tmp-unselected ?d)
1666 (?u gnus-tmp-user-defined ?s)
1667 (?d (length gnus-newsgroup-dormant) ?d)
1668 (?t (length gnus-newsgroup-marked) ?d)
1669 (?r (length gnus-newsgroup-reads) ?d)
1670 (?E gnus-newsgroup-expunged-tally ?d)
1671 (?s (gnus-current-score-file-nondirectory) ?s))))
1673 (defvar gnus-article-mode-line-format-alist
1674 gnus-summary-mode-line-format-alist)
1676 (defvar gnus-group-mode-line-format-alist
1677 (` ((?S gnus-tmp-news-server ?s)
1678 (?M gnus-tmp-news-method ?s)
1679 (?u gnus-tmp-user-defined ?s))))
1681 (defvar gnus-have-read-active-file nil)
1683 (defconst gnus-maintainer
1684 "gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls + Boys)"
1685 "The mail address of the Gnus maintainers.")
1687 (defconst gnus-version "September Gnus v0.37"
1688 "Version number for this version of Gnus.")
1690 (defvar gnus-info-nodes
1691 '((gnus-group-mode "(gnus)The Group Buffer")
1692 (gnus-summary-mode "(gnus)The Summary Buffer")
1693 (gnus-article-mode "(gnus)The Article Buffer"))
1694 "Assoc list of major modes and related Info nodes.")
1696 (defvar gnus-group-buffer "*Group*")
1697 (defvar gnus-summary-buffer "*Summary*")
1698 (defvar gnus-article-buffer "*Article*")
1699 (defvar gnus-server-buffer "*Server*")
1701 (defvar gnus-work-buffer " *gnus work*")
1703 (defvar gnus-original-article-buffer " *Original Article*")
1704 (defvar gnus-original-article nil)
1706 (defvar gnus-buffer-list nil
1707 "Gnus buffers that should be killed on exit.")
1709 (defvar gnus-server-alist nil
1710 "List of available servers.")
1712 (defvar gnus-slave nil
1713 "Whether this Gnus is a slave or not.")
1715 (defvar gnus-variable-list
1716 '(gnus-newsrc-options gnus-newsrc-options-n
1717 gnus-newsrc-last-checked-date
1718 gnus-newsrc-alist gnus-server-alist
1719 gnus-killed-list gnus-zombie-list
1720 gnus-topic-topology gnus-topic-alist
1722 "Gnus variables saved in the quick startup file.")
1724 (defvar gnus-newsrc-options nil
1725 "Options line in the .newsrc file.")
1727 (defvar gnus-newsrc-options-n nil
1728 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1730 (defvar gnus-newsrc-last-checked-date nil
1731 "Date Gnus last asked server for new newsgroups.")
1733 (defvar gnus-topic-topology nil
1734 "The complete topic hierarchy.")
1736 (defvar gnus-topic-alist nil
1737 "The complete topic-group alist.")
1739 (defvar gnus-newsrc-alist nil
1740 "Assoc list of read articles.
1741 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1743 (defvar gnus-newsrc-hashtb nil
1744 "Hashtable of gnus-newsrc-alist.")
1746 (defvar gnus-killed-list nil
1747 "List of killed newsgroups.")
1749 (defvar gnus-killed-hashtb nil
1750 "Hash table equivalent of gnus-killed-list.")
1752 (defvar gnus-zombie-list nil
1753 "List of almost dead newsgroups.")
1755 (defvar gnus-description-hashtb nil
1756 "Descriptions of newsgroups.")
1758 (defvar gnus-list-of-killed-groups nil
1759 "List of newsgroups that have recently been killed by the user.")
1761 (defvar gnus-active-hashtb nil
1762 "Hashtable of active articles.")
1764 (defvar gnus-moderated-list nil
1765 "List of moderated newsgroups.")
1767 (defvar gnus-group-marked nil)
1769 (defvar gnus-current-startup-file nil
1770 "Startup file for the current host.")
1772 (defvar gnus-last-search-regexp nil
1773 "Default regexp for article search command.")
1775 (defvar gnus-last-shell-command nil
1776 "Default shell command on article.")
1778 (defvar gnus-current-select-method nil
1779 "The current method for selecting a newsgroup.")
1781 (defvar gnus-group-list-mode nil)
1783 (defvar gnus-article-internal-prepare-hook nil)
1785 (defvar gnus-newsgroup-name nil)
1786 (defvar gnus-newsgroup-begin nil)
1787 (defvar gnus-newsgroup-end nil)
1788 (defvar gnus-newsgroup-last-rmail nil)
1789 (defvar gnus-newsgroup-last-mail nil)
1790 (defvar gnus-newsgroup-last-folder nil)
1791 (defvar gnus-newsgroup-last-file nil)
1792 (defvar gnus-newsgroup-auto-expire nil)
1793 (defvar gnus-newsgroup-active nil)
1795 (defvar gnus-newsgroup-data nil)
1796 (defvar gnus-newsgroup-data-reverse nil)
1797 (defvar gnus-newsgroup-limit nil)
1798 (defvar gnus-newsgroup-limits nil)
1800 (defvar gnus-newsgroup-unreads nil
1801 "List of unread articles in the current newsgroup.")
1803 (defvar gnus-newsgroup-unselected nil
1804 "List of unselected unread articles in the current newsgroup.")
1806 (defvar gnus-newsgroup-reads nil
1807 "Alist of read articles and article marks in the current newsgroup.")
1809 (defvar gnus-newsgroup-expunged-tally nil)
1811 (defvar gnus-newsgroup-marked nil
1812 "List of ticked articles in the current newsgroup (a subset of unread art).")
1814 (defvar gnus-newsgroup-killed nil
1815 "List of ranges of articles that have been through the scoring process.")
1817 (defvar gnus-newsgroup-cached nil
1818 "List of articles that come from the article cache.")
1820 (defvar gnus-newsgroup-saved nil
1821 "List of articles that have been saved.")
1823 (defvar gnus-newsgroup-kill-headers nil)
1825 (defvar gnus-newsgroup-replied nil
1826 "List of articles that have been replied to in the current newsgroup.")
1828 (defvar gnus-newsgroup-expirable nil
1829 "List of articles in the current newsgroup that can be expired.")
1831 (defvar gnus-newsgroup-processable nil
1832 "List of articles in the current newsgroup that can be processed.")
1834 (defvar gnus-newsgroup-bookmarks nil
1835 "List of articles in the current newsgroup that have bookmarks.")
1837 (defvar gnus-newsgroup-dormant nil
1838 "List of dormant articles in the current newsgroup.")
1840 (defvar gnus-newsgroup-scored nil
1841 "List of scored articles in the current newsgroup.")
1843 (defvar gnus-newsgroup-headers nil
1844 "List of article headers in the current newsgroup.")
1846 (defvar gnus-newsgroup-threads nil)
1848 (defvar gnus-newsgroup-prepared nil
1849 "Whether the current group has been prepared properly.")
1851 (defvar gnus-newsgroup-ancient nil
1852 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1854 (defvar gnus-newsgroup-sparse nil)
1856 (defvar gnus-current-article nil)
1857 (defvar gnus-article-current nil)
1858 (defvar gnus-current-headers nil)
1859 (defvar gnus-have-all-headers nil)
1860 (defvar gnus-last-article nil)
1861 (defvar gnus-newsgroup-history nil)
1862 (defvar gnus-current-kill-article nil)
1864 ;; Save window configuration.
1865 (defvar gnus-prev-winconf nil)
1867 (defvar gnus-summary-mark-positions nil)
1868 (defvar gnus-group-mark-positions nil)
1870 (defvar gnus-reffed-article-number nil)
1872 ;;; Let the byte-compiler know that we know about this variable.
1873 (defvar rmail-default-rmail-file)
1875 (defvar gnus-cache-removable-articles nil)
1877 (defvar gnus-dead-summary nil)
1879 (defconst gnus-summary-local-variables
1880 '(gnus-newsgroup-name
1881 gnus-newsgroup-begin gnus-newsgroup-end
1882 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1883 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1884 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1885 gnus-newsgroup-unselected gnus-newsgroup-marked
1886 gnus-newsgroup-reads gnus-newsgroup-saved
1887 gnus-newsgroup-replied gnus-newsgroup-expirable
1888 gnus-newsgroup-processable gnus-newsgroup-killed
1889 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1890 gnus-newsgroup-headers gnus-newsgroup-threads
1891 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1892 gnus-current-article gnus-current-headers gnus-have-all-headers
1893 gnus-last-article gnus-article-internal-prepare-hook
1894 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1895 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1896 gnus-newsgroup-async
1897 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1898 gnus-summary-mark-below gnus-newsgroup-active gnus-scores-exclude-files
1899 gnus-newsgroup-history gnus-newsgroup-ancient
1900 gnus-newsgroup-sparse
1901 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1902 gnus-newsgroup-adaptive-score-file
1903 (gnus-newsgroup-expunged-tally . 0)
1904 gnus-cache-removeable-articles gnus-newsgroup-cached
1905 gnus-newsgroup-data gnus-newsgroup-data-reverse
1906 gnus-newsgroup-limit gnus-newsgroup-limits)
1907 "Variables that are buffer-local to the summary buffers.")
1909 (defconst gnus-bug-message
1910 "Sending a bug report to the Gnus Towers.
1911 ========================================
1913 The buffer below is a mail buffer. When you press `C-c C-c', it will
1914 be sent to the Gnus Bug Exterminators.
1916 At the bottom of the buffer you'll see lots of variable settings.
1917 Please do not delete those. They will tell the Bug People what your
1918 environment is, so that it will be easier to locate the bugs.
1920 If you have found a bug that makes Emacs go \"beep\", set
1921 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
1922 and include the backtrace in your bug report.
1924 Please describe the bug in annoying, painstaking detail.
1926 Thank you for your help in stamping out bugs.
1929 ;;; End of variables.
1931 ;; Define some autoload functions Gnus might use.
1934 ;; This little mapcar goes through the list below and marks the
1935 ;; symbols in question as autoloaded functions.
1938 (let ((interactive (nth 1 (memq ':interactive package))))
1942 (when (consp function)
1943 (setq keymap (car (memq 'keymap function)))
1944 (setq function (car function)))
1945 (autoload function (car package) nil interactive keymap)))
1946 (if (eq (nth 1 package) ':interactive)
1949 '(("metamail" metamail-buffer)
1950 ("info" Info-goto-node)
1951 ("hexl" hexl-hex-string-to-integer)
1952 ("pp" pp pp-to-string pp-eval-expression)
1953 ("mail-extr" mail-extract-address-components)
1954 ("nnmail" nnmail-split-fancy nnmail-article-group)
1955 ("nnvirtual" nnvirtual-catchup-group)
1956 ("timezone" timezone-make-date-arpa-standard timezone-fix-time
1957 timezone-make-sortable-date timezone-make-time-string)
1958 ("sendmail" mail-position-on-field mail-setup)
1959 ("rmailout" rmail-output)
1960 ("rnewspost" news-mail-other-window news-reply-yank-original
1961 news-caesar-buffer-body)
1962 ("rmail" rmail-insert-rmail-file-header rmail-count-new-messages
1964 ("gnus-soup" :interactive t
1965 gnus-group-brew-soup gnus-brew-soup gnus-soup-add-article
1966 gnus-soup-send-replies gnus-soup-save-areas gnus-soup-pack-packet)
1967 ("nnsoup" nnsoup-pack-replies)
1968 ("gnus-mh" gnus-mh-mail-setup gnus-summary-save-article-folder
1969 gnus-Folder-save-name gnus-folder-save-name)
1970 ("gnus-mh" :interactive t gnus-summary-save-in-folder)
1971 ("gnus-vis" gnus-group-make-menu-bar gnus-summary-make-menu-bar
1972 gnus-server-make-menu-bar gnus-article-make-menu-bar
1973 gnus-browse-make-menu-bar gnus-highlight-selected-summary
1974 gnus-summary-highlight-line gnus-carpal-setup-buffer
1975 gnus-group-highlight-line
1976 gnus-article-add-button gnus-insert-next-page-button
1977 gnus-insert-prev-page-button gnus-visual-turn-off-edit-menu)
1978 ("gnus-vis" :interactive t
1979 gnus-article-push-button gnus-article-press-button
1980 gnus-article-highlight gnus-article-highlight-some
1981 gnus-article-highlight-headers gnus-article-highlight-signature
1982 gnus-article-add-buttons gnus-article-add-buttons-to-head
1983 gnus-article-next-button gnus-article-prev-button)
1984 ("gnus-demon" gnus-demon-add-nocem gnus-demon-add-scanmail
1985 gnus-demon-add-disconnection gnus-demon-add-handler
1986 gnus-demon-remove-handler)
1987 ("gnus-demon" :interactive t
1988 gnus-demon-init gnus-demon-cancel)
1989 ("gnus-salt" gnus-highlight-selected-tree gnus-possibly-generate-tree
1990 gnus-tree-open gnus-tree-close)
1991 ("gnus-nocem" gnus-nocem-scan-groups gnus-nocem-close)
1992 ("gnus-srvr" gnus-enter-server-buffer gnus-server-set-info)
1993 ("gnus-srvr" gnus-browse-foreign-server)
1994 ("gnus-cite" :interactive t
1995 gnus-article-highlight-citation gnus-article-hide-citation-maybe
1996 gnus-article-hide-citation gnus-article-fill-cited-article)
1997 ("gnus-kill" gnus-kill gnus-apply-kill-file-internal
1998 gnus-kill-file-edit-file gnus-kill-file-raise-followups-to-author
1999 gnus-execute gnus-expunge)
2000 ("gnus-cache" gnus-cache-possibly-enter-article gnus-cache-save-buffers
2001 gnus-cache-possibly-remove-articles gnus-cache-request-article
2002 gnus-cache-retrieve-headers gnus-cache-possibly-alter-active
2003 gnus-cache-enter-remove-article gnus-cached-article-p
2004 gnus-cache-open gnus-cache-close)
2005 ("gnus-cache" :interactive t gnus-jog-cache gnus-cache-enter-article
2006 gnus-cache-remove-article)
2007 ("gnus-score" :interactive t
2008 gnus-summary-increase-score gnus-summary-lower-score
2009 gnus-score-flush-cache gnus-score-close
2010 gnus-score-raise-same-subject-and-select
2011 gnus-score-raise-same-subject gnus-score-default
2012 gnus-score-raise-thread gnus-score-lower-same-subject-and-select
2013 gnus-score-lower-same-subject gnus-score-lower-thread
2014 gnus-possibly-score-headers)
2016 (gnus-summary-score-map keymap) gnus-score-save gnus-score-headers
2017 gnus-current-score-file-nondirectory gnus-score-adaptive
2018 gnus-score-find-trace gnus-score-file-name)
2019 ("gnus-edit" :interactive t gnus-score-customize)
2020 ("gnus-topic" :interactive t gnus-topic-mode)
2021 ("gnus-topic" gnus-topic-remove-group)
2022 ("gnus-salt" :interactive t gnus-pick-mode)
2023 ("gnus-uu" (gnus-uu-extract-map keymap) (gnus-uu-mark-map keymap))
2024 ("gnus-uu" :interactive t
2025 gnus-uu-digest-mail-forward gnus-uu-digest-post-forward
2026 gnus-uu-mark-series gnus-uu-mark-region gnus-uu-mark-buffer
2027 gnus-uu-mark-by-regexp gnus-uu-mark-all
2028 gnus-uu-mark-sparse gnus-uu-mark-thread gnus-uu-decode-uu
2029 gnus-uu-decode-uu-and-save gnus-uu-decode-unshar
2030 gnus-uu-decode-unshar-and-save gnus-uu-decode-save
2031 gnus-uu-decode-binhex gnus-uu-decode-uu-view
2032 gnus-uu-decode-uu-and-save-view gnus-uu-decode-unshar-view
2033 gnus-uu-decode-unshar-and-save-view gnus-uu-decode-save-view
2034 gnus-uu-decode-binhex-view)
2035 ("gnus-msg" (gnus-summary-send-map keymap)
2036 gnus-mail-yank-original gnus-mail-send-and-exit
2037 gnus-sendmail-setup-mail gnus-article-mail
2038 gnus-inews-message-id gnus-new-mail gnus-mail-reply)
2039 ("gnus-msg" :interactive t
2040 gnus-group-post-news gnus-group-mail gnus-summary-post-news
2041 gnus-summary-followup gnus-summary-followup-with-original
2042 gnus-summary-followup-and-reply
2043 gnus-summary-followup-and-reply-with-original
2044 gnus-summary-cancel-article gnus-summary-supersede-article
2045 gnus-post-news gnus-inews-news gnus-cancel-news
2046 gnus-summary-reply gnus-summary-reply-with-original
2047 gnus-summary-mail-forward gnus-summary-mail-other-window
2049 ("gnus-picon" :interactive t gnus-article-display-picons
2050 gnus-group-display-picons gnus-picons-article-display-x-face)
2051 ("gnus-vm" gnus-vm-mail-setup)
2052 ("gnus-vm" :interactive t gnus-summary-save-in-vm
2053 gnus-summary-save-article-vm gnus-yank-article))))
2057 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2058 ;; If you want the cursor to go somewhere else, set these two
2059 ;; functions in some startup hook to whatever you want.
2060 (defalias 'gnus-summary-position-point 'gnus-goto-colon)
2061 (defalias 'gnus-group-position-point 'gnus-goto-colon)
2063 ;;; Various macros and substs.
2065 (defun gnus-header-from (header)
2066 (mail-header-from header))
2068 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
2069 "Pop to BUFFER, evaluate FORMS, and then return to the original window."
2070 `(let ((GnusStartBufferWindow (selected-window)))
2073 (pop-to-buffer ,buffer)
2075 (select-window GnusStartBufferWindow))))
2077 (defmacro gnus-gethash (string hashtable)
2078 "Get hash value of STRING in HASHTABLE."
2079 `(symbol-value (intern-soft ,string ,hashtable)))
2081 (defmacro gnus-sethash (string value hashtable)
2082 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2083 `(set (intern ,string ,hashtable) ,value))
2085 (defmacro gnus-intern-safe (string hashtable)
2086 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2087 `(let ((symbol (intern ,string ,hashtable)))
2092 (defmacro gnus-group-unread (group)
2093 "Get the currently computed number of unread articles in GROUP."
2094 `(car (gnus-gethash ,group gnus-newsrc-hashtb)))
2096 (defmacro gnus-group-entry (group)
2097 "Get the newsrc entry for GROUP."
2098 `(gnus-gethash ,group gnus-newsrc-hashtb))
2100 (defmacro gnus-active (group)
2101 "Get active info on GROUP."
2102 `(gnus-gethash ,group gnus-active-hashtb))
2104 (defmacro gnus-set-active (group active)
2105 "Set GROUP's active info."
2106 `(gnus-sethash ,group ,active gnus-active-hashtb))
2108 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2109 ;; function `substring' might cut on a middle of multi-octet
2111 (defun gnus-truncate-string (str width)
2112 (substring str 0 width))
2114 ;; Added by Geoffrey T. Dairiki <dairiki@u.washington.edu>. A safe way
2115 ;; to limit the length of a string. This function is necessary since
2116 ;; `(substr "abc" 0 30)' pukes with "Args out of range".
2117 (defsubst gnus-limit-string (str width)
2118 (if (> (length str) width)
2119 (substring str 0 width)
2122 (defsubst gnus-simplify-subject-re (subject)
2123 "Remove \"Re:\" from subject lines."
2124 (if (string-match "^[Rr][Ee]: *" subject)
2125 (substring subject (match-end 0))
2128 (defsubst gnus-goto-char (point)
2129 (and point (goto-char point)))
2131 (defmacro gnus-buffer-exists-p (buffer)
2133 (funcall (if (stringp ,buffer) 'get-buffer 'buffer-name)
2136 (defmacro gnus-kill-buffer (buffer)
2137 `(let ((buf ,buffer))
2138 (if (gnus-buffer-exists-p buf)
2139 (kill-buffer buf))))
2141 (defsubst gnus-point-at-bol ()
2142 "Return point at the beginning of the line."
2149 (defsubst gnus-point-at-eol ()
2150 "Return point at the end of the line."
2157 ;; Delete the current line (and the next N lines.);
2158 (defmacro gnus-delete-line (&optional n)
2159 `(delete-region (progn (beginning-of-line) (point))
2160 (progn (forward-line ,(or n 1)) (point))))
2162 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
2163 (defvar gnus-init-inhibit nil)
2164 (defun gnus-read-init-file (&optional inhibit-next)
2165 (if gnus-init-inhibit
2166 (setq gnus-init-inhibit nil)
2167 (setq gnus-init-inhibit inhibit-next)
2169 (or (and (file-exists-p gnus-init-file)
2170 ;; Don't try to load a directory.
2171 (not (file-directory-p gnus-init-file)))
2172 (file-exists-p (concat gnus-init-file ".el"))
2173 (file-exists-p (concat gnus-init-file ".elc")))
2175 (load gnus-init-file nil t)
2177 (error "Error in %s: %s" gnus-init-file var))))))
2179 ;; Info access macros.
2181 (defmacro gnus-info-group (info)
2183 (defmacro gnus-info-rank (info)
2185 (defmacro gnus-info-read (info)
2187 (defmacro gnus-info-marks (info)
2189 (defmacro gnus-info-method (info)
2191 (defmacro gnus-info-params (info)
2194 (defmacro gnus-info-level (info)
2195 `(let ((rank (gnus-info-rank ,info)))
2199 (defmacro gnus-info-score (info)
2200 `(let ((rank (gnus-info-rank ,info)))
2201 (or (and (consp rank) (cdr rank)) 0)))
2203 (defmacro gnus-info-set-group (info group)
2204 `(setcar ,info ,group))
2205 (defmacro gnus-info-set-rank (info rank)
2206 `(setcar (nthcdr 1 ,info) ,rank))
2207 (defmacro gnus-info-set-read (info read)
2208 `(setcar (nthcdr 2 ,info) ,read))
2209 (defmacro gnus-info-set-marks (info marks)
2210 `(setcar (nthcdr 3 ,info) ,marks))
2211 (defmacro gnus-info-set-method (info method)
2212 `(setcar (nthcdr 4 ,info) ,method))
2213 (defmacro gnus-info-set-params (info params)
2214 `(setcar (nthcdr 5 ,info) ,params))
2216 (defmacro gnus-info-set-level (info level)
2217 `(let ((rank (cdr ,info)))
2218 (if (consp (car rank))
2219 (setcar (car rank) ,level)
2220 (setcar rank ,level))))
2221 (defmacro gnus-info-set-score (info score)
2222 `(let ((rank (cdr ,info)))
2223 (if (consp (car rank))
2224 (setcdr (car rank) ,score)
2225 (setcar rank (cons (car rank) ,score)))))
2227 (defmacro gnus-get-info (group)
2228 `(nth 2 (gnus-gethash ,group gnus-newsrc-hashtb)))
2230 (defun gnus-byte-code (func)
2231 "Return a form that can be `eval'ed based on FUNC."
2232 (let ((fval (symbol-function func)))
2233 (if (byte-code-function-p fval)
2234 (let ((flist (append fval nil)))
2235 (setcar flist 'byte-code)
2237 (cons 'progn (cdr (cdr fval))))))
2239 ;;; Load the compatability functions.
2246 ;; Format specs. The chunks below are the machine-generated forms
2247 ;; that are to be evaled as the result of the default format strings.
2248 ;; We write them in here to get them byte-compiled. That way the
2249 ;; default actions will be quite fast, while still retaining the full
2250 ;; flexibility of the user-defined format specs.
2252 ;; First we have lots of dummy defvars to let the compiler know these
2253 ;; are really dynamic variables.
2255 (defvar gnus-tmp-unread)
2256 (defvar gnus-tmp-replied)
2257 (defvar gnus-tmp-score-char)
2258 (defvar gnus-tmp-indentation)
2259 (defvar gnus-tmp-opening-bracket)
2260 (defvar gnus-tmp-lines)
2261 (defvar gnus-tmp-name)
2262 (defvar gnus-tmp-closing-bracket)
2263 (defvar gnus-tmp-subject-or-nil)
2264 (defvar gnus-tmp-subject)
2265 (defvar gnus-tmp-marked)
2266 (defvar gnus-tmp-marked-mark)
2267 (defvar gnus-tmp-subscribed)
2268 (defvar gnus-tmp-process-marked)
2269 (defvar gnus-tmp-number-of-unread)
2270 (defvar gnus-tmp-group-name)
2271 (defvar gnus-tmp-group)
2272 (defvar gnus-tmp-article-number)
2273 (defvar gnus-tmp-unread-and-unselected)
2274 (defvar gnus-tmp-news-method)
2275 (defvar gnus-tmp-news-server)
2276 (defvar gnus-tmp-article-number)
2277 (defvar gnus-mouse-face)
2278 (defvar gnus-mouse-face-prop)
2280 (defun gnus-summary-line-format-spec ()
2281 (insert gnus-tmp-unread gnus-tmp-replied
2282 gnus-tmp-score-char gnus-tmp-indentation)
2287 gnus-tmp-opening-bracket
2288 (format "%4d: %-20s"
2290 (if (> (length gnus-tmp-name) 20)
2291 (substring gnus-tmp-name 0 20)
2293 gnus-tmp-closing-bracket)
2295 gnus-mouse-face-prop gnus-mouse-face)
2296 (insert " " gnus-tmp-subject-or-nil "\n"))
2298 (defvar gnus-summary-line-format-spec
2299 (gnus-byte-code 'gnus-summary-line-format-spec))
2301 (defun gnus-summary-dummy-line-format-spec ()
2308 gnus-mouse-face-prop gnus-mouse-face)
2309 (insert " " gnus-tmp-subject "\n"))
2311 (defvar gnus-summary-dummy-line-format-spec
2312 (gnus-byte-code 'gnus-summary-dummy-line-format-spec))
2314 (defun gnus-group-line-format-spec ()
2315 (insert gnus-tmp-marked-mark gnus-tmp-subscribed
2316 gnus-tmp-process-marked
2317 gnus-group-indentation
2318 (format "%5s: " gnus-tmp-number-of-unread))
2322 (insert gnus-tmp-group "\n")
2324 gnus-mouse-face-prop gnus-mouse-face))
2325 (defvar gnus-group-line-format-spec
2326 (gnus-byte-code 'gnus-group-line-format-spec))
2328 (defvar gnus-format-specs
2329 `((version . ,emacs-version)
2330 (group ,gnus-group-line-format ,gnus-group-line-format-spec)
2331 (summary-dummy ,gnus-summary-dummy-line-format
2332 ,gnus-summary-dummy-line-format-spec)
2333 (summary ,gnus-summary-line-format ,gnus-summary-line-format-spec)))
2335 (defvar gnus-article-mode-line-format-spec nil)
2336 (defvar gnus-summary-mode-line-format-spec nil)
2337 (defvar gnus-group-mode-line-format-spec nil)
2339 ;;; Phew. All that gruft is over, fortunately.
2343 ;;; Gnus Utility Functions
2346 (defun gnus-extract-address-components (from)
2348 ;; First find the address - the thing with the @ in it. This may
2349 ;; not be accurate in mail addresses, but does the trick most of
2350 ;; the time in news messages.
2351 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
2352 (setq address (substring from (match-beginning 0) (match-end 0))))
2353 ;; Then we check whether the "name <address>" format is used.
2355 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2356 ;; Linear white space is not required.
2357 (string-match (concat "[ \t]*<" (regexp-quote address) ">") from)
2358 (and (setq name (substring from 0 (match-beginning 0)))
2359 ;; Strip any quotes from the name.
2360 (string-match "\".*\"" name)
2361 (setq name (substring name 1 (1- (match-end 0))))))
2362 ;; If not, then "address (name)" is used.
2364 (and (string-match "(.+)" from)
2365 (setq name (substring from (1+ (match-beginning 0))
2366 (1- (match-end 0)))))
2367 (and (string-match "()" from)
2368 (setq name address))
2369 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>.
2370 ;; XOVER might not support folded From headers.
2371 (and (string-match "(.*" from)
2372 (setq name (substring from (1+ (match-beginning 0))
2374 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2375 (list (or name from) (or address from))))
2377 (defun gnus-fetch-field (field)
2378 "Return the value of the header FIELD of current article."
2381 (let ((case-fold-search t))
2382 (nnheader-narrow-to-headers)
2383 (mail-fetch-field field)))))
2385 (defun gnus-goto-colon ()
2387 (search-forward ":" (gnus-point-at-eol) t))
2390 (defun gnus-update-format (var)
2391 "Update the format specification near point."
2396 ;; Find the end of the current word.
2397 (re-search-forward "[ \t\n]" nil t)
2399 (when (re-search-backward "\\(gnus-[-a-z]+-line-format\\)" nil t)
2400 (match-string 1)))))
2401 (let* ((type (intern (progn (string-match "gnus-\\([-a-z]+\\)-line" var)
2402 (match-string 1 var))))
2403 (entry (assq type gnus-format-specs))
2406 (setq gnus-format-specs (delq entry gnus-format-specs)))
2408 (intern (format "%s-spec" var))
2409 (gnus-parse-format (setq value (symbol-value (intern var)))
2410 (symbol-value (intern (format "%s-alist" var)))
2411 (not (string-match "mode" var))))
2412 (setq spec (symbol-value (intern (format "%s-spec" var))))
2413 (push (list type value spec) gnus-format-specs)
2415 (pop-to-buffer "*Gnus Format*")
2417 (lisp-interaction-mode)
2418 (insert (pp-to-string spec))))
2421 (defun gnus-update-format-specifications (&optional force)
2422 "Update all (necessary) format specifications."
2423 ;; Make the indentation array.
2424 (gnus-make-thread-indent-array)
2426 ;; See whether all the stored info needs to be flushed.
2428 (not (equal emacs-version
2429 (cdr (assq 'version gnus-format-specs)))))
2430 (setq gnus-format-specs nil))
2432 ;; Go through all the formats and see whether they need updating.
2433 (let ((types '(summary summary-dummy group
2434 summary-mode group-mode article-mode))
2435 new-format entry type val)
2436 (while (setq type (pop types))
2437 (setq new-format (symbol-value
2438 (intern (format "gnus-%s-line-format" type))))
2439 (setq entry (cdr (assq type gnus-format-specs)))
2441 (equal (car entry) new-format))
2442 ;; Use the old format.
2443 (set (intern (format "gnus-%s-line-format-spec" type))
2445 ;; This is a new format.
2447 (if (not (stringp new-format))
2448 ;; This is a function call or something.
2450 ;; This is a "real" format.
2454 (intern (format "gnus-%s-line-format-alist"
2455 (if (eq type 'article-mode)
2456 'summary-mode type))))
2457 (not (string-match "mode$" (symbol-name type))))))
2458 ;; Enter the new format spec into the list.
2461 (setcar (cdr entry) val)
2462 (setcar entry new-format))
2463 (push (list type new-format val) gnus-format-specs))
2464 (set (intern (format "gnus-%s-line-format-spec" type)) val))))
2466 (gnus-update-group-mark-positions)
2467 (gnus-update-summary-mark-positions)
2469 ;; See whether we need to read the description file.
2470 (if (and (string-match "%[-,0-9]*D" gnus-group-line-format)
2471 (not gnus-description-hashtb)
2472 gnus-read-active-file)
2473 (gnus-read-all-descriptions-files)))
2475 (defun gnus-update-summary-mark-positions ()
2476 "Compute where the summary marks are to go."
2478 (let ((gnus-replied-mark 129)
2479 (gnus-score-below-mark 130)
2480 (gnus-score-over-mark 130)
2484 (gnus-set-work-buffer)
2485 (gnus-summary-insert-line
2486 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2487 (goto-char (point-min))
2488 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2490 (goto-char (point-min))
2491 (setq pos (cons (cons 'replied (and (search-forward "\201" nil t)
2492 (- (point) 2))) pos))
2493 (goto-char (point-min))
2494 (setq pos (cons (cons 'score (and (search-forward "\202" nil t)
2495 (- (point) 2))) pos))
2496 (setq gnus-summary-mark-positions pos))))
2498 (defun gnus-update-group-mark-positions ()
2500 (let ((gnus-process-mark 128)
2501 (gnus-group-marked '("dummy.group")))
2502 (gnus-set-active "dummy.group" '(0 . 0))
2503 (gnus-set-work-buffer)
2504 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
2505 (goto-char (point-min))
2506 (setq gnus-group-mark-positions
2507 (list (cons 'process (and (search-forward "\200" nil t)
2508 (- (point) 2))))))))
2510 (defvar gnus-mouse-face-0 'highlight)
2511 (defvar gnus-mouse-face-1 'highlight)
2512 (defvar gnus-mouse-face-2 'highlight)
2513 (defvar gnus-mouse-face-3 'highlight)
2514 (defvar gnus-mouse-face-4 'highlight)
2516 (defun gnus-mouse-face-function (form type)
2518 (point) (progn ,@form (point))
2519 gnus-mouse-face-prop
2522 `(quote ,(symbol-value (intern (format "gnus-mouse-face-%d" type)))))))
2524 (defvar gnus-face-0 'bold)
2525 (defvar gnus-face-1 'italic)
2526 (defvar gnus-face-2 'bold-italic)
2527 (defvar gnus-face-3 'bold)
2528 (defvar gnus-face-4 'bold)
2530 (defun gnus-face-face-function (form type)
2532 (point) (progn ,@form (point))
2533 'face ',(symbol-value (intern (format "gnus-face-%d" type)))))
2535 (defun gnus-max-width-function (el max-width)
2536 (or (numberp max-width) (signal 'wrong-type-argument '(numberp max-width)))
2538 `(if (> (length ,el) ,max-width)
2539 (substring ,el 0 ,max-width)
2541 `(let ((val (eval ,el)))
2543 (setq val (int-to-string val)))
2544 (if (> (length val) ,max-width)
2545 (substring val 0 ,max-width)
2548 (defun gnus-parse-format (format spec-alist &optional insert)
2549 ;; This function parses the FORMAT string with the help of the
2550 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
2551 ;; string. If the FORMAT string contains the specifiers %( and %)
2552 ;; the text between them will have the mouse-face text property.
2554 "\\`\\(.*\\)%[0-9]?[{(]\\(.*\\)%[0-9]?[})]\\(.*\n?\\)\\'"
2556 (gnus-parse-complex-format format spec-alist)
2557 ;; This is a simple format.
2558 (gnus-parse-simple-format format spec-alist insert)))
2560 (defun gnus-parse-complex-format (format spec-alist)
2562 (gnus-set-work-buffer)
2564 (goto-char (point-min))
2565 (while (re-search-forward "\"" nil t)
2566 (replace-match "\\\"" nil t))
2567 (goto-char (point-min))
2569 (while (re-search-forward "%\\([0-9]+\\)?\\([{}()]\\)" nil t)
2570 (let ((number (if (match-beginning 1)
2571 (match-string 1) "0"))
2572 (delim (aref (match-string 2) 0)))
2573 (if (or (= delim ?\() (= delim ?\{))
2574 (replace-match (concat "\"(" (if (= delim ?\() "mouse" "face")
2576 (replace-match "\")\""))))
2577 (goto-char (point-max))
2579 (goto-char (point-min))
2580 (let ((form (read (current-buffer))))
2581 (cons 'progn (gnus-complex-form-to-spec form spec-alist)))))
2583 (defun gnus-complex-form-to-spec (form spec-alist)
2588 (gnus-parse-simple-format sform spec-alist t)
2589 (funcall (intern (format "gnus-%s-face-function"
2591 (gnus-complex-form-to-spec
2592 (cdr (cdr sform)) spec-alist)
2596 (defun gnus-parse-simple-format (format spec-alist &optional insert)
2597 ;; This function parses the FORMAT string with the help of the
2598 ;; SPEC-ALIST and returns a list that can be eval'ed to return a
2601 spec flist fstring newspec elem beg result dontinsert)
2603 (gnus-set-work-buffer)
2605 (goto-char (point-min))
2606 (while (re-search-forward "%[-0-9]*\\(,[0-9]+\\)?\\([^0-9]\\)\\(.\\)?"
2608 (if (= (setq spec (string-to-char (match-string 2))) ?%)
2610 beg (1+ (match-beginning 0)))
2611 ;; First check if there are any specs that look anything like
2612 ;; "%12,12A", ie. with a "max width specification". These have
2613 ;; to be treated specially.
2614 (if (setq beg (match-beginning 1))
2618 (1+ (match-beginning 1)) (match-end 1))))
2620 (setq beg (match-beginning 2)))
2621 ;; Find the specification from `spec-alist'.
2622 (unless (setq elem (cdr (assq spec spec-alist)))
2623 (setq elem '("*" ?s)))
2624 ;; Treat user defined format specifiers specially.
2625 (when (eq (car elem) 'gnus-tmp-user-defined)
2628 (list (intern (concat "gnus-user-format-function-"
2630 'gnus-tmp-header) ?s))
2631 (delete-region (match-beginning 3) (match-end 3)))
2632 (if (not (zerop max-width))
2633 (let ((el (car elem)))
2634 (cond ((= (car (cdr elem)) ?c)
2635 (setq el (list 'char-to-string el)))
2636 ((= (car (cdr elem)) ?d)
2637 (setq el (list 'int-to-string el))))
2638 (setq flist (cons (gnus-max-width-function el max-width)
2642 (setq flist (cons (car elem) flist))
2643 (setq newspec (car (cdr elem))))))
2644 ;; Remove the old specification (and possibly a ",12" string).
2645 (delete-region beg (match-end 2))
2646 ;; Insert the new specification.
2649 (setq fstring (buffer-substring 1 (point-max))))
2650 ;; Do some postprocessing to increase efficiency.
2655 ((string= fstring "")
2657 ;; Not a format string.
2658 ((not (string-match "%" fstring))
2660 ;; A format string with just a single string spec.
2661 ((string= fstring "%s")
2663 ;; A single character.
2664 ((string= fstring "%c")
2667 ((string= fstring "%d")
2670 (list `(princ ,(car flist)))
2671 (list `(int-to-string ,(car flist)))))
2672 ;; Just lots of chars and strings.
2673 ((string-match "\\`\\(%[cs]\\)+\\'" fstring)
2675 ;; A single string spec at the beginning of the spec.
2676 ((string-match "\\`%[sc][^%]+\\'" fstring)
2677 (list (car flist) (substring fstring 2)))
2678 ;; A single string spec in the middle of the spec.
2679 ((string-match "\\`\\([^%]+\\)%[sc]\\([^%]+\\)\\'" fstring)
2680 (list (match-string 1 fstring) (car flist) (match-string 2 fstring)))
2681 ;; A single string spec in the end of the spec.
2682 ((string-match "\\`\\([^%]+\\)%[sc]\\'" fstring)
2683 (list (match-string 1 fstring) (car flist)))
2684 ;; A more complex spec.
2686 (list (cons 'format (cons fstring (nreverse flist)))))))
2692 (cons 'insert result)))
2693 (cond ((stringp result)
2696 (cons 'concat result))
2699 (defun gnus-eval-format (format &optional alist props)
2700 "Eval the format variable FORMAT, using ALIST.
2701 If PROPS, insert the result."
2702 (let ((form (gnus-parse-format format alist props)))
2704 (add-text-properties (point) (progn (eval form) (point)) props)
2707 (defun gnus-remove-text-with-property (prop)
2708 "Delete all text in the current buffer with text property PROP."
2710 (goto-char (point-min))
2712 (while (get-text-property (point) prop)
2714 (goto-char (next-single-property-change (point) prop nil (point-max))))))
2716 (defun gnus-set-work-buffer ()
2717 (if (get-buffer gnus-work-buffer)
2719 (set-buffer gnus-work-buffer)
2721 (set-buffer (get-buffer-create gnus-work-buffer))
2722 (kill-all-local-variables)
2723 (buffer-disable-undo (current-buffer))
2724 (gnus-add-current-to-buffer-list)))
2726 ;; Article file names when saving.
2728 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2729 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2730 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
2731 Otherwise, it is like ~/News/news/group/num."
2734 (concat (if (gnus-use-long-file-name 'not-save)
2735 (gnus-capitalize-newsgroup newsgroup)
2736 (gnus-newsgroup-directory-form newsgroup))
2737 "/" (int-to-string (mail-header-number headers)))
2738 (or gnus-article-save-directory "~/News"))))
2740 (string-equal (file-name-directory default)
2741 (file-name-directory last-file))
2742 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2744 (or last-file default))))
2746 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2747 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2748 If variable `gnus-use-long-file-name' is non-nil, it is
2749 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2752 (concat (if (gnus-use-long-file-name 'not-save)
2754 (gnus-newsgroup-directory-form newsgroup))
2755 "/" (int-to-string (mail-header-number headers)))
2756 (or gnus-article-save-directory "~/News"))))
2758 (string-equal (file-name-directory default)
2759 (file-name-directory last-file))
2760 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2762 (or last-file default))))
2764 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2765 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2766 If variable `gnus-use-long-file-name' is non-nil, it is
2767 ~/News/News.group. Otherwise, it is like ~/News/news/group/news."
2770 (if (gnus-use-long-file-name 'not-save)
2771 (gnus-capitalize-newsgroup newsgroup)
2772 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2773 (or gnus-article-save-directory "~/News"))))
2775 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2776 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2777 If variable `gnus-use-long-file-name' is non-nil, it is
2778 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2781 (if (gnus-use-long-file-name 'not-save)
2783 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2784 (or gnus-article-save-directory "~/News"))))
2786 ;; For subscribing new newsgroup
2788 (defun gnus-subscribe-hierarchical-interactive (groups)
2789 (let ((groups (sort groups 'string<))
2790 prefixes prefix start ans group starts)
2792 (setq prefixes (list "^"))
2793 (while (and groups prefixes)
2794 (while (not (string-match (car prefixes) (car groups)))
2795 (setq prefixes (cdr prefixes)))
2796 (setq prefix (car prefixes))
2797 (setq start (1- (length prefix)))
2798 (if (and (string-match "[^\\.]\\." (car groups) start)
2801 (concat "^" (substring (car groups) 0 (match-end 0))))
2802 (string-match prefix (car (cdr groups))))
2804 (setq prefixes (cons prefix prefixes))
2805 (message "Descend hierarchy %s? ([y]nsq): "
2806 (substring prefix 1 (1- (length prefix))))
2807 (setq ans (read-char))
2810 (string-match prefix
2811 (setq group (car groups))))
2812 (setq gnus-killed-list
2813 (cons group gnus-killed-list))
2814 (gnus-sethash group group gnus-killed-hashtb)
2815 (setq groups (cdr groups)))
2816 (setq starts (cdr starts)))
2819 (string-match prefix
2820 (setq group (car groups))))
2821 (gnus-sethash group group gnus-killed-hashtb)
2822 (gnus-subscribe-alphabetically (car groups))
2823 (setq groups (cdr groups)))
2824 (setq starts (cdr starts)))
2827 (setq group (car groups))
2828 (setq gnus-killed-list (cons group gnus-killed-list))
2829 (gnus-sethash group group gnus-killed-hashtb)
2830 (setq groups (cdr groups))))
2832 (message "Subscribe %s? ([n]yq)" (car groups))
2833 (setq ans (read-char))
2834 (setq group (car groups))
2836 (gnus-subscribe-alphabetically (car groups))
2837 (gnus-sethash group group gnus-killed-hashtb))
2840 (setq group (car 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 (setq gnus-killed-list (cons group gnus-killed-list))
2846 (gnus-sethash group group gnus-killed-hashtb)))
2847 (setq groups (cdr groups)))))))
2849 (defun gnus-subscribe-randomly (newsgroup)
2850 "Subscribe new NEWSGROUP by making it the first newsgroup."
2851 (gnus-subscribe-newsgroup newsgroup))
2853 (defun gnus-subscribe-alphabetically (newgroup)
2854 "Subscribe new NEWSGROUP and insert it in alphabetical order."
2855 (let ((groups (cdr gnus-newsrc-alist))
2857 (while (and (not before) groups)
2858 (if (string< newgroup (car (car groups)))
2859 (setq before (car (car groups)))
2860 (setq groups (cdr groups))))
2861 (gnus-subscribe-newsgroup newgroup before)))
2863 (defun gnus-subscribe-hierarchically (newgroup)
2864 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
2865 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2867 (set-buffer (find-file-noselect gnus-current-startup-file))
2868 (let ((groupkey newgroup)
2870 (while (and (not before) groupkey)
2871 (goto-char (point-min))
2873 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
2874 (while (and (re-search-forward groupkey-re nil t)
2876 (setq before (match-string 1))
2877 (string< before newgroup)))))
2878 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
2880 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
2881 (substring groupkey (match-beginning 1) (match-end 1)))))
2882 (gnus-subscribe-newsgroup newgroup before))))
2884 (defun gnus-subscribe-interactively (group)
2885 "Subscribe the new GROUP interactively.
2886 It is inserted in hierarchical newsgroup order if subscribed. If not,
2888 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " group))
2889 (gnus-subscribe-hierarchically group)
2890 (push group gnus-killed-list)))
2892 (defun gnus-subscribe-zombies (group)
2893 "Make the new GROUP into a zombie group."
2894 (push group gnus-zombie-list))
2896 (defun gnus-subscribe-killed (group)
2897 "Make the new GROUP a killed group."
2898 (push group gnus-killed-list))
2900 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
2901 "Subscribe new NEWSGROUP.
2902 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
2903 the first newsgroup."
2904 ;; We subscribe the group by changing its level to `subscribed'.
2905 (gnus-group-change-level
2906 newsgroup gnus-level-default-subscribed
2907 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
2908 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))
2912 (defun gnus-newsgroup-directory-form (newsgroup)
2913 "Make hierarchical directory name from NEWSGROUP name."
2914 (let ((newsgroup (gnus-newsgroup-savable-name newsgroup))
2915 (len (length newsgroup))
2917 ;; If this is a foreign group, we don't want to translate the
2919 (if (setq idx (string-match ":" newsgroup))
2920 (aset newsgroup idx ?/)
2922 ;; Replace all occurrences of `.' with `/'.
2924 (if (= (aref newsgroup idx) ?.)
2925 (aset newsgroup idx ?/))
2926 (setq idx (1+ idx)))
2929 (defun gnus-newsgroup-savable-name (group)
2930 ;; Replace any slashes in a group name (eg. an ange-ftp nndoc group)
2932 (nnheader-replace-chars-in-string group ?/ ?.))
2934 (defun gnus-make-directory (dir)
2935 "Make DIRECTORY recursively."
2936 ;; Why don't we use `(make-directory dir 'parents)'? That's just one
2937 ;; of the many mysteries of the universe.
2938 (let* ((dir (expand-file-name dir default-directory))
2940 (if (string-match "/$" dir)
2941 (setq dir (substring dir 0 (match-beginning 0))))
2942 ;; First go down the path until we find a directory that exists.
2943 (while (not (file-exists-p dir))
2944 (setq dirs (cons dir dirs))
2945 (string-match "/[^/]+$" dir)
2946 (setq dir (substring dir 0 (match-beginning 0))))
2947 ;; Then create all the subdirs.
2948 (while (and dirs (not err))
2950 (make-directory (car dirs))
2951 (error (setq err t)))
2952 (setq dirs (cdr dirs)))
2953 ;; We return whether we were successful or not.
2956 (defun gnus-capitalize-newsgroup (newsgroup)
2957 "Capitalize NEWSGROUP name."
2958 (and (not (zerop (length newsgroup)))
2959 (concat (char-to-string (upcase (aref newsgroup 0)))
2960 (substring newsgroup 1))))
2962 ;; Various... things.
2964 (defun gnus-simplify-subject (subject &optional re-only)
2965 "Remove `Re:' and words in parentheses.
2966 If RE-ONLY is non-nil, strip leading `Re:'s only."
2967 (let ((case-fold-search t)) ;Ignore case.
2968 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
2969 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
2970 (setq subject (substring subject (match-end 0))))
2971 ;; Remove uninteresting prefixes.
2972 (if (and (not re-only)
2973 gnus-simplify-ignored-prefixes
2974 (string-match gnus-simplify-ignored-prefixes subject))
2975 (setq subject (substring subject (match-end 0))))
2976 ;; Remove words in parentheses from end.
2978 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
2979 (setq subject (substring subject 0 (match-beginning 0)))))
2980 ;; Return subject string.
2983 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
2985 ;; Written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
2986 (defun gnus-simplify-buffer-fuzzy ()
2987 (goto-char (point-min))
2988 (re-search-forward "^[ \t]*\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;][ \t]*" nil t)
2989 (goto-char (match-beginning 0))
2991 (looking-at "^[ \t]*\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;][ \t]*")
2992 (looking-at "^[[].*:[ \t].*[]]$"))
2993 (goto-char (point-min))
2994 (while (re-search-forward "^[ \t]*\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;][ \t]*"
2996 (replace-match "" t t))
2997 (goto-char (point-min))
2998 (while (re-search-forward "^[[].*:[ \t].*[]]$" nil t)
2999 (goto-char (match-end 0))
3002 (progn (goto-char (match-beginning 0)))
3003 (re-search-forward ":"))))
3004 (goto-char (point-min))
3005 (while (re-search-forward "[ \t\n]*[[{(][^()]*[]})][ \t]*$" nil t)
3006 (replace-match "" t t))
3007 (goto-char (point-min))
3008 (while (re-search-forward "[ \t]+" nil t)
3009 (replace-match " " t t))
3010 (goto-char (point-min))
3011 (while (re-search-forward "[ \t]+$" nil t)
3012 (replace-match "" t t))
3013 (goto-char (point-min))
3014 (while (re-search-forward "^[ \t]+" nil t)
3015 (replace-match "" t t))
3016 (goto-char (point-min))
3017 (if gnus-simplify-subject-fuzzy-regexp
3018 (if (listp gnus-simplify-subject-fuzzy-regexp)
3019 (let ((list gnus-simplify-subject-fuzzy-regexp))
3021 (goto-char (point-min))
3022 (while (re-search-forward (car list) nil t)
3023 (replace-match "" t t))
3024 (setq list (cdr list))))
3025 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
3026 (replace-match "" t t)))))
3028 (defun gnus-simplify-subject-fuzzy (subject)
3029 "Siplify a subject string fuzzily."
3031 (gnus-set-work-buffer)
3032 (let ((case-fold-search t))
3034 (inline (gnus-simplify-buffer-fuzzy))
3037 ;; Add the current buffer to the list of buffers to be killed on exit.
3038 (defun gnus-add-current-to-buffer-list ()
3039 (or (memq (current-buffer) gnus-buffer-list)
3040 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list))))
3042 (defun gnus-string> (s1 s2)
3043 (not (or (string< s1 s2)
3046 ;;; General various misc type functions.
3048 (defun gnus-clear-system ()
3049 "Clear all variables and buffers."
3050 ;; Clear Gnus variables.
3051 (let ((variables gnus-variable-list))
3053 (set (car variables) nil)
3054 (setq variables (cdr variables))))
3055 ;; Clear other internal variables.
3056 (setq gnus-list-of-killed-groups nil
3057 gnus-have-read-active-file nil
3058 gnus-newsrc-alist nil
3059 gnus-newsrc-hashtb nil
3060 gnus-killed-list nil
3061 gnus-zombie-list nil
3062 gnus-killed-hashtb nil
3063 gnus-active-hashtb nil
3064 gnus-moderated-list nil
3065 gnus-description-hashtb nil
3066 gnus-newsgroup-headers nil
3067 gnus-newsgroup-name nil
3068 gnus-server-alist nil
3069 gnus-opened-servers nil
3070 gnus-current-select-method nil)
3071 ;; Reset any score variables.
3072 (and gnus-use-scoring (gnus-score-close))
3073 ;; Kill the startup file.
3074 (and gnus-current-startup-file
3075 (get-file-buffer gnus-current-startup-file)
3076 (kill-buffer (get-file-buffer gnus-current-startup-file)))
3077 ;; Save any cache buffers.
3078 (and gnus-use-cache (gnus-cache-save-buffers))
3079 ;; Clear the dribble buffer.
3080 (gnus-dribble-clear)
3081 ;; Close down NoCeM.
3082 (and gnus-use-nocem (gnus-nocem-close))
3083 ;; Shut down the demons.
3084 (and gnus-use-demon (gnus-demon-cancel))
3085 ;; Kill global KILL file buffer.
3086 (if (get-file-buffer (gnus-newsgroup-kill-file nil))
3087 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
3088 (gnus-kill-buffer nntp-server-buffer)
3090 (and gnus-keep-backlog (gnus-backlog-shutdown))
3091 ;; Kill Gnus buffers.
3092 (while gnus-buffer-list
3093 (gnus-kill-buffer (car gnus-buffer-list))
3094 (setq gnus-buffer-list (cdr gnus-buffer-list))))
3096 (defun gnus-windows-old-to-new (setting)
3097 ;; First we take care of the really, really old Gnus 3 actions.
3098 (if (symbolp setting)
3100 (cond ((memq setting '(SelectArticle))
3102 ((memq setting '(SelectSubject ExpandSubject))
3104 ((memq setting '(SelectNewsgroup ExitNewsgroup))
3107 (if (or (listp setting)
3108 (not (and gnus-window-configuration
3109 (memq setting '(group summary article)))))
3111 (let* ((setting (if (eq setting 'group)
3112 (if (assq 'newsgroup gnus-window-configuration)
3114 'newsgroups) setting))
3115 (elem (car (cdr (assq setting gnus-window-configuration))))
3116 (total (apply '+ elem))
3117 (types '(group summary article))
3118 (pbuf (if (eq setting 'newsgroups) 'group 'summary))
3123 (or (not (numberp (nth i elem)))
3124 (zerop (nth i elem))
3126 (setq perc (/ (float (nth 0 elem)) total))
3127 (setq out (cons (if (eq pbuf (nth i types))
3128 (vector (nth i types) perc 'point)
3129 (vector (nth i types) perc))
3132 (list (nreverse out)))))
3134 (defun gnus-add-configuration (conf)
3135 "Add the window configuration CONF to `gnus-buffer-configuration'."
3136 (setq gnus-buffer-configuration
3137 (cons conf (delq (assq (car conf) gnus-buffer-configuration)
3138 gnus-buffer-configuration))))
3140 (defvar gnus-frame-list nil)
3142 (defun gnus-configure-frame (split &optional window)
3143 "Split WINDOW according to SPLIT."
3145 (setq window (get-buffer-window (current-buffer))))
3146 (select-window window)
3147 ;; This might be an old-stylee buffer config.
3148 (when (vectorp split)
3149 (setq split (append split nil)))
3150 (when (or (consp (car split))
3151 (vectorp (car split)))
3153 (push 'vertical split))
3154 ;; The SPLIT might be something that is to be evaled to
3155 ;; return a new SPLIT.
3156 (while (and (not (assq (car split) gnus-window-to-buffer))
3157 (gnus-functionp (car split)))
3158 (setq split (eval split)))
3159 (let* ((type (car split))
3161 (len (if (eq type 'horizontal) (window-width) (window-height)))
3163 (window-min-width (or gnus-window-min-width window-min-width))
3164 (window-min-height (or gnus-window-min-height window-min-height))
3165 s result new-win rest comp-subs size sub)
3167 ;; Nothing to do here.
3169 ;; Don't switch buffers.
3171 (and (memq 'point split) window))
3172 ;; This is a buffer to be selected.
3173 ((not (memq type '(frame horizontal vertical)))
3174 (let ((buffer (cond ((stringp type) type)
3175 (t (cdr (assq type gnus-window-to-buffer)))))
3178 (error "Illegal buffer type: %s" type))
3179 (unless (setq buf (get-buffer (if (symbolp buffer)
3180 (symbol-value buffer) buffer)))
3181 (setq buf (get-buffer-create (if (symbolp buffer)
3182 (symbol-value buffer) buffer))))
3183 (switch-to-buffer buf)
3184 ;; We return the window if it has the `point' spec.
3185 (and (memq 'point split) window)))
3186 ;; This is a frame split.
3188 (unless gnus-frame-list
3189 (setq gnus-frame-list (list (window-frame
3190 (get-buffer-window (current-buffer))))))
3192 params frame fresult)
3193 (while (< i (length subs))
3194 ;; Frame parameter is gotten from the sub-split.
3195 (setq params (cadr (elt subs i)))
3196 ;; It should be a list.
3197 (unless (listp params)
3199 ;; Create a new frame?
3200 (unless (setq frame (elt gnus-frame-list i))
3201 (nconc gnus-frame-list (list (setq frame (make-frame params)))))
3202 ;; Is the old frame still alive?
3203 (unless (frame-live-p frame)
3204 (setcar (nthcdr i gnus-frame-list)
3205 (setq frame (make-frame params))))
3206 ;; Select the frame in question and do more splits there.
3207 (select-frame frame)
3208 (setq fresult (or (gnus-configure-frame (elt subs i)) fresult))
3210 ;; Select the frame that has the selected buffer.
3212 (select-frame (window-frame fresult)))))
3213 ;; This is a normal split.
3215 (when (> (length subs) 0)
3216 ;; First we have to compute the sizes of all new windows.
3218 (setq sub (append (pop subs) nil))
3219 (while (and (not (assq (car sub) gnus-window-to-buffer))
3220 (gnus-functionp (car sub)))
3221 (setq sub (eval sub)))
3223 (push sub comp-subs)
3224 (setq size (cadar comp-subs))
3225 (cond ((equal size 1.0)
3226 (setq rest (car comp-subs))
3229 (setq s (floor (* size len))))
3233 (error "Illegal size: %s" size)))
3234 ;; Try to make sure that we are inside the safe limits.
3236 ((eq type 'horizontal)
3237 (setq s (max s window-min-width)))
3238 ((eq type 'vertical)
3239 (setq s (max s window-min-height))))
3240 (setcar (cdar comp-subs) s)
3242 ;; Take care of the "1.0" spec.
3244 (setcar (cdr rest) (- len total))
3245 (error "No 1.0 specs in %s" split))
3246 ;; The we do the actual splitting in a nice recursive
3248 (setq comp-subs (nreverse comp-subs))
3250 (if (null (cdr comp-subs))
3251 (setq new-win window)
3253 (split-window window (cadar comp-subs)
3254 (eq type 'horizontal))))
3255 (setq result (or (gnus-configure-frame
3256 (car comp-subs) window) result))
3257 (select-window new-win)
3258 (setq window new-win)
3259 (setq comp-subs (cdr comp-subs))))
3260 ;; Return the proper window, if any.
3262 (select-window result))))))
3264 (defvar gnus-frame-split-p nil)
3266 (defun gnus-configure-windows (setting &optional force)
3267 (setq setting (gnus-windows-old-to-new setting))
3268 (let ((split (if (symbolp setting)
3269 (car (cdr (assq setting gnus-buffer-configuration)))
3271 (in-buf (current-buffer))
3272 rule val w height hor ohor heights sub jump-buffer
3273 rel total to-buf all-visible)
3275 (setq gnus-frame-split-p nil)
3278 (error "No such setting: %s" setting))
3280 (if (and (not force)
3281 (setq all-visible (gnus-all-windows-visible-p split)))
3282 ;; All the windows mentioned are already visible, so we just
3283 ;; put point in the assigned buffer, and do not touch the
3285 (select-window all-visible)
3287 ;; Either remove all windows or just remove all Gnus windows.
3288 (let ((frame (selected-frame)))
3290 (if gnus-use-full-window
3291 ;; We want to remove all other windows.
3292 (if (not gnus-frame-split-p)
3293 ;; This is not a `frame' split, so we ignore the
3295 (delete-other-windows)
3296 ;; This is a `frame' split, so we delete all windows
3300 (unless (eq (cdr (assq 'minibuffer
3301 (frame-parameters frame)))
3303 (select-frame frame)
3304 (delete-other-windows)))
3306 ;; Just remove some windows.
3307 (gnus-remove-some-windows)
3308 (switch-to-buffer nntp-server-buffer))
3309 (select-frame frame)))
3311 (switch-to-buffer nntp-server-buffer)
3312 (gnus-configure-frame split (get-buffer-window (current-buffer))))))
3314 (defun gnus-all-windows-visible-p (split)
3315 (when (vectorp split)
3316 (setq split (append split nil)))
3317 (when (or (consp (car split))
3318 (vectorp (car split)))
3320 (push 'vertical split))
3321 ;; The SPLIT might be something that is to be evaled to
3322 ;; return a new SPLIT.
3323 (while (and (not (assq (car split) gnus-window-to-buffer))
3324 (gnus-functionp (car split)))
3325 (setq split (eval split)))
3326 (let* ((type (elt split 0)))
3330 ((not (or (eq type 'horizontal) (eq type 'vertical) (eq type 'frame)))
3331 (let ((buffer (cond ((stringp type) type)
3332 (t (cdr (assq type gnus-window-to-buffer)))))
3335 (error "Illegal buffer type: %s" type))
3336 (when (setq buf (get-buffer (if (symbolp buffer) (symbol-value buffer)
3338 (setq win (get-buffer-window buf t)))
3340 (if (memq 'point split)
3344 (when (eq type 'frame)
3345 (setq gnus-frame-split-p t))
3346 (let ((n (mapcar 'gnus-all-windows-visible-p
3350 (cond ((windowp (car n))
3357 (defun gnus-window-top-edge (&optional window)
3358 (nth 1 (window-edges window)))
3360 (defun gnus-remove-some-windows ()
3361 (let ((buffers gnus-window-to-buffer)
3362 buf bufs lowest-buf lowest)
3364 ;; Remove windows on all known Gnus buffers.
3366 (setq buf (cdr (car buffers)))
3368 (setq buf (and (boundp buf) (symbol-value buf))))
3370 (get-buffer-window buf)
3372 (setq bufs (cons buf bufs))
3374 (if (or (not lowest)
3375 (< (gnus-window-top-edge) lowest))
3377 (setq lowest (gnus-window-top-edge))
3378 (setq lowest-buf buf)))))
3379 (setq buffers (cdr buffers)))
3380 ;; Remove windows on *all* summary buffers.
3384 (let ((buf (window-buffer win)))
3385 (if (string-match "^\\*Summary" (buffer-name buf))
3387 (setq bufs (cons buf bufs))
3389 (if (or (not lowest)
3390 (< (gnus-window-top-edge) lowest))
3392 (setq lowest-buf buf)
3393 (setq lowest (gnus-window-top-edge))))))))))
3396 (pop-to-buffer lowest-buf)
3397 (switch-to-buffer nntp-server-buffer)))
3399 (and (not (eq (car bufs) lowest-buf))
3400 (delete-windows-on (car bufs)))
3401 (setq bufs (cdr bufs))))))
3403 (defun gnus-version ()
3404 "Version numbers of this version of Gnus."
3406 (let ((methods gnus-valid-select-methods)
3409 ;; Go through all the legal select methods and add their version
3410 ;; numbers to the total version string. Only the backends that are
3411 ;; currently in use will have their message numbers taken into
3414 (setq meth (intern (concat (car (car methods)) "-version")))
3416 (stringp (symbol-value meth))
3417 (setq mess (concat mess "; " (symbol-value meth))))
3418 (setq methods (cdr methods)))
3419 (gnus-message 2 mess)))
3421 (defun gnus-info-find-node ()
3422 "Find Info documentation of Gnus."
3424 ;; Enlarge info window if needed.
3425 (let ((mode major-mode)
3427 (Info-goto-node (car (cdr (assq mode gnus-info-nodes))))
3428 (setq gnus-info-buffer (current-buffer))
3429 (gnus-configure-windows 'info)))
3431 (defun gnus-days-between (date1 date2)
3432 ;; Return the number of days between date1 and date2.
3433 (- (gnus-day-number date1) (gnus-day-number date2)))
3435 (defun gnus-day-number (date)
3436 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
3437 (timezone-parse-date date))))
3438 (timezone-absolute-from-gregorian
3439 (nth 1 dat) (nth 2 dat) (car dat))))
3441 (defun gnus-encode-date (date)
3442 "Convert DATE to internal time."
3443 (let* ((parse (timezone-parse-date date))
3444 (date (mapcar (lambda (d) (and d (string-to-int d))) parse))
3445 (time (mapcar 'string-to-int (timezone-parse-time (aref parse 3)))))
3446 (encode-time (caddr time) (cadr time) (car time)
3447 (caddr date) (cadr date) (car date) (nth 4 date))))
3449 (defun gnus-time-minus (t1 t2)
3450 "Subtract two internal times."
3451 (let ((borrow (< (cadr t1) (cadr t2))))
3452 (list (- (car t1) (car t2) (if borrow 1 0))
3453 (- (+ (if borrow 65536 0) (cadr t1)) (cadr t2)))))
3455 (defun gnus-file-newer-than (file date)
3456 (let ((fdate (nth 5 (file-attributes file))))
3457 (or (> (car fdate) (car date))
3458 (and (= (car fdate) (car date))
3459 (> (nth 1 fdate) (nth 1 date))))))
3461 (defmacro gnus-define-keys (keymap &rest plist)
3462 "Define all keys in PLIST in KEYMAP."
3463 `(gnus-define-keys-1 (quote ,keymap) (quote ,plist)))
3465 (defun gnus-define-keys-1 (keymap plist)
3467 (error "Can't set keys in a null keymap"))
3468 (cond ((symbolp keymap)
3469 (setq keymap (symbol-value keymap)))
3471 (set (car keymap) nil)
3472 (define-prefix-command (car keymap))
3473 (define-key (symbol-value (caddr keymap)) (cadr keymap) (car keymap))
3474 (setq keymap (symbol-value (car keymap)))))
3477 (when (symbolp (setq key (pop plist)))
3478 (setq key (symbol-value key)))
3479 (define-key keymap key (pop plist)))))
3481 (defun gnus-group-read-only-p (&optional group)
3482 "Check whether GROUP supports editing or not.
3483 If GROUP is nil, `gnus-newsgroup-name' will be checked instead. Note
3484 that that variable is buffer-local to the summary buffers."
3485 (let ((group (or group gnus-newsgroup-name)))
3486 (not (gnus-check-backend-function 'request-replace-article group))))
3488 (defun gnus-group-total-expirable-p (group)
3489 "Check whether GROUP is total-expirable or not."
3490 (let ((params (gnus-info-params (gnus-get-info group))))
3491 (or (memq 'total-expire params)
3492 (cdr (assq 'total-expire params)) ; (total-expire . t)
3493 (and gnus-total-expirable-newsgroups ; Check var.
3494 (string-match gnus-total-expirable-newsgroups group)))))
3496 (defun gnus-group-auto-expirable-p (group)
3497 "Check whether GROUP is total-expirable or not."
3498 (let ((params (gnus-info-params (gnus-get-info group))))
3499 (or (memq 'auto-expire params)
3500 (cdr (assq 'auto-expire params)) ; (auto-expire . t)
3501 (and gnus-auto-expirable-newsgroups ; Check var.
3502 (string-match gnus-auto-expirable-newsgroups group)))))
3504 (defun gnus-virtual-group-p (group)
3505 "Say whether GROUP is virtual or not."
3506 (memq 'virtual (assoc (symbol-name (car (gnus-find-method-for-group group)))
3507 gnus-valid-select-methods)))
3509 (defsubst gnus-simplify-subject-fully (subject)
3510 "Simplify a subject string according to the user's wishes."
3512 ((null gnus-summary-gather-subject-limit)
3513 (gnus-simplify-subject-re subject))
3514 ((eq gnus-summary-gather-subject-limit 'fuzzy)
3515 (gnus-simplify-subject-fuzzy subject))
3516 ((numberp gnus-summary-gather-subject-limit)
3517 (gnus-limit-string (gnus-simplify-subject-re subject)
3518 gnus-summary-gather-subject-limit))
3522 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
3523 "Check whether two subjects are equal. If optional argument
3524 simple-first is t, first argument is already simplified."
3526 ((null simple-first)
3527 (equal (gnus-simplify-subject-fully s1)
3528 (gnus-simplify-subject-fully s2)))
3531 (gnus-simplify-subject-fully s2)))))
3533 ;; Returns a list of writable groups.
3534 (defun gnus-writable-groups ()
3535 (let ((alist gnus-newsrc-alist)
3538 (or (gnus-group-read-only-p (car (car alist)))
3539 (setq groups (cons (car (car alist)) groups)))
3540 (setq alist (cdr alist)))
3543 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
3545 (defun gnus-y-or-n-p (prompt)
3550 (defun gnus-yes-or-no-p (prompt)
3552 (yes-or-no-p prompt)
3555 ;; Check whether to use long file names.
3556 (defun gnus-use-long-file-name (symbol)
3557 ;; The variable has to be set...
3558 (and gnus-use-long-file-name
3559 ;; If it isn't a list, then we return t.
3560 (or (not (listp gnus-use-long-file-name))
3561 ;; If it is a list, and the list contains `symbol', we
3563 (not (memq symbol gnus-use-long-file-name)))))
3565 ;; I suspect there's a better way, but I haven't taken the time to do
3566 ;; it yet. -erik selberg@cs.washington.edu
3567 (defun gnus-dd-mmm (messy-date)
3568 "Return a string like DD-MMM from a big messy string"
3569 (let ((datevec (timezone-parse-date messy-date)))
3571 (or (aref datevec 2) "??")
3574 (nth (1- (string-to-number (aref datevec 1)))
3575 timezone-months-assoc))
3578 ;; Make a hash table (default and minimum size is 255).
3579 ;; Optional argument HASHSIZE specifies the table size.
3580 (defun gnus-make-hashtable (&optional hashsize)
3581 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0))
3583 ;; Make a number that is suitable for hashing; bigger than MIN and one
3585 (defun gnus-create-hash-size (min)
3591 ;; Show message if message has a lower level than `gnus-verbose'.
3592 ;; Guideline for numbers:
3593 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages
3594 ;; for things that take a long time, 7 - not very important messages
3595 ;; on stuff, 9 - messages inside loops.
3596 (defun gnus-message (level &rest args)
3597 (if (<= level gnus-verbose)
3598 (apply 'message args)
3599 ;; We have to do this format thingy here even if the result isn't
3600 ;; shown - the return value has to be the same as the return value
3602 (apply 'format args)))
3604 (defun gnus-functionp (form)
3605 "Return non-nil if FORM is funcallable."
3606 (or (and (symbolp form) (fboundp form))
3607 (and (listp form) (eq (car form) 'lambda))))
3609 ;; Generate a unique new group name.
3610 (defun gnus-generate-new-group-name (leaf)
3613 (while (gnus-gethash name gnus-newsrc-hashtb)
3614 (setq name (concat leaf "<" (int-to-string (setq num (1+ num))) ">")))
3617 ;; Find out whether the gnus-visual TYPE is wanted.
3618 (defun gnus-visual-p (&optional type class)
3619 (and gnus-visual ; Has to be non-nil, at least.
3620 (if (not type) ; We don't care about type.
3622 (if (listp gnus-visual) ; It's a list, so we check it.
3623 (or (memq type gnus-visual)
3624 (memq class gnus-visual))
3627 (defun gnus-parent-id (references)
3628 "Return the last Message-ID in REFERENCES."
3629 (when (and references
3630 (string-match "\\(<[^<>]+>\\)[ \t\n]*\\'" references))
3631 (substring references (match-beginning 1) (match-end 1))))
3633 (defun gnus-split-references (references)
3634 "Return a list of Message-IDs in REFERENCES."
3637 (while (string-match "<[^>]+>" references beg)
3638 (push (substring references (match-beginning 0) (setq beg (match-end 0)))
3642 (defun gnus-ephemeral-group-p (group)
3643 "Say whether GROUP is ephemeral or not."
3644 (assoc 'quit-config (gnus-find-method-for-group group)))
3646 (defun gnus-group-quit-config (group)
3647 "Return the quit-config of GROUP."
3648 (nth 1 (assoc 'quit-config (gnus-find-method-for-group group))))
3650 (defun gnus-simplify-mode-line ()
3651 "Make mode lines a bit simpler."
3652 (setq mode-line-modified "-- ")
3653 (when (listp mode-line-format)
3654 (make-local-variable 'mode-line-format)
3655 (setq mode-line-format (copy-sequence mode-line-format))
3656 (when (equal (nth 3 mode-line-format) " ")
3657 (setcar (nthcdr 3 mode-line-format) " "))))
3659 ;;; List and range functions
3661 (defun gnus-last-element (list)
3662 "Return last element of LIST."
3664 (setq list (cdr list)))
3667 (defun gnus-copy-sequence (list)
3668 "Do a complete, total copy of a list."
3669 (if (and (consp list) (not (consp (cdr list))))
3670 (cons (car list) (cdr list))
3671 (mapcar (lambda (elem) (if (consp elem)
3672 (if (consp (cdr elem))
3673 (gnus-copy-sequence elem)
3674 (cons (car elem) (cdr elem)))
3678 (defun gnus-set-difference (list1 list2)
3679 "Return a list of elements of LIST1 that do not appear in LIST2."
3680 (let ((list1 (copy-sequence list1)))
3682 (setq list1 (delq (car list2) list1))
3683 (setq list2 (cdr list2)))
3686 (defun gnus-sorted-complement (list1 list2)
3687 "Return a list of elements of LIST1 that do not appear in LIST2.
3688 Both lists have to be sorted over <."
3690 (if (or (null list1) (null list2))
3692 (while (and list1 list2)
3693 (cond ((= (car list1) (car list2))
3694 (setq list1 (cdr list1)
3696 ((< (car list1) (car list2))
3697 (setq out (cons (car list1) out))
3698 (setq list1 (cdr list1)))
3700 (setq out (cons (car list2) out))
3701 (setq list2 (cdr list2)))))
3702 (nconc (nreverse out) (or list1 list2)))))
3704 (defun gnus-intersection (list1 list2)
3707 (if (memq (car list2) list1)
3708 (setq result (cons (car list2) result)))
3709 (setq list2 (cdr list2)))
3712 (defun gnus-sorted-intersection (list1 list2)
3713 ;; LIST1 and LIST2 have to be sorted over <.
3715 (while (and list1 list2)
3716 (cond ((= (car list1) (car list2))
3717 (setq out (cons (car list1) out)
3720 ((< (car list1) (car list2))
3721 (setq list1 (cdr list1)))
3723 (setq list2 (cdr list2)))))
3726 (defun gnus-set-sorted-intersection (list1 list2)
3727 ;; LIST1 and LIST2 have to be sorted over <.
3728 ;; This function modifies LIST1.
3729 (let* ((top (cons nil list1))
3731 (while (and list1 list2)
3732 (cond ((= (car list1) (car list2))
3736 ((< (car list1) (car list2))
3737 (setcdr prev (cdr list1))
3738 (setq list1 (cdr list1)))
3740 (setq list2 (cdr list2)))))
3744 (defun gnus-compress-sequence (numbers &optional always-list)
3745 "Convert list of numbers to a list of ranges or a single range.
3746 If ALWAYS-LIST is non-nil, this function will always release a list of
3748 (let* ((first (car numbers))
3749 (last (car numbers))
3753 (if (not (listp (cdr numbers)))
3756 (cond ((= last (car numbers)) nil) ;Omit duplicated number
3757 ((= (1+ last) (car numbers)) ;Still in sequence
3758 (setq last (car numbers)))
3759 (t ;End of one sequence
3761 (cons (if (= first last) first
3762 (cons first last)) result))
3763 (setq first (car numbers))
3764 (setq last (car numbers))))
3765 (setq numbers (cdr numbers)))
3766 (if (and (not always-list) (null result))
3767 (if (= first last) (list first) (cons first last))
3768 (nreverse (cons (if (= first last) first (cons first last))
3771 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
3772 (defun gnus-uncompress-range (ranges)
3773 "Expand a list of ranges into a list of numbers.
3774 RANGES is either a single range on the form `(num . num)' or a list of
3776 (let (first last result)
3780 ((not (listp (cdr ranges)))
3781 (setq first (car ranges))
3782 (setq last (cdr ranges))
3783 (while (<= first last)
3784 (setq result (cons first result))
3785 (setq first (1+ first)))
3789 (if (atom (car ranges))
3790 (if (numberp (car ranges))
3791 (setq result (cons (car ranges) result)))
3792 (setq first (car (car ranges)))
3793 (setq last (cdr (car ranges)))
3794 (while (<= first last)
3795 (setq result (cons first result))
3796 (setq first (1+ first))))
3797 (setq ranges (cdr ranges)))
3798 (nreverse result)))))
3800 (defun gnus-add-to-range (ranges list)
3801 "Return a list of ranges that has all articles from both RANGES and LIST.
3802 Note: LIST has to be sorted over `<'."
3804 (gnus-compress-sequence list t)
3805 (setq list (copy-sequence list))
3806 (or (listp (cdr ranges))
3807 (setq ranges (list ranges)))
3809 ilist lowest highest temp)
3810 (while (and ranges list)
3812 (setq lowest (or (and (atom (car ranges)) (car ranges))
3813 (car (car ranges))))
3814 (while (and list (cdr list) (< (car (cdr list)) lowest))
3815 (setq list (cdr list)))
3816 (if (< (car ilist) lowest)
3819 (setq list (cdr list))
3821 (setq out (nconc (gnus-compress-sequence ilist t) out))))
3822 (setq highest (or (and (atom (car ranges)) (car ranges))
3823 (cdr (car ranges))))
3824 (while (and list (<= (car list) highest))
3825 (setq list (cdr list)))
3826 (setq ranges (cdr ranges)))
3828 (setq out (nconc (gnus-compress-sequence list t) out)))
3829 (setq out (sort out (lambda (r1 r2)
3830 (< (or (and (atom r1) r1) (car r1))
3831 (or (and (atom r2) r2) (car r2))))))
3834 (if (atom (car ranges))
3836 (if (atom (car (cdr ranges)))
3837 (if (= (1+ (car ranges)) (car (cdr ranges)))
3839 (setcar ranges (cons (car ranges)
3840 (car (cdr ranges))))
3841 (setcdr ranges (cdr (cdr ranges)))))
3842 (if (= (1+ (car ranges)) (car (car (cdr ranges))))
3844 (setcar (car (cdr ranges)) (car ranges))
3845 (setcar ranges (car (cdr ranges)))
3846 (setcdr ranges (cdr (cdr ranges)))))))
3848 (if (atom (car (cdr ranges)))
3849 (if (= (1+ (cdr (car ranges))) (car (cdr ranges)))
3851 (setcdr (car ranges) (car (cdr ranges)))
3852 (setcdr ranges (cdr (cdr ranges)))))
3853 (if (= (1+ (cdr (car ranges))) (car (car (cdr ranges))))
3855 (setcdr (car ranges) (cdr (car (cdr ranges))))
3856 (setcdr ranges (cdr (cdr ranges))))))))
3857 (setq ranges (cdr ranges)))
3860 (defun gnus-remove-from-range (ranges list)
3861 "Return a list of ranges that has all articles from LIST removed from RANGES.
3862 Note: LIST has to be sorted over `<'."
3863 ;; !!! This function shouldn't look like this, but I've got a headache.
3864 (gnus-compress-sequence
3865 (gnus-sorted-complement
3866 (gnus-uncompress-range ranges) list)))
3868 (defun gnus-member-of-range (number ranges)
3869 (if (not (listp (cdr ranges)))
3870 (and (>= number (car ranges))
3871 (<= number (cdr ranges)))
3874 (if (numberp (car ranges))
3875 (>= number (car ranges))
3876 (>= number (car (car ranges))))
3878 (if (if (numberp (car ranges))
3879 (= number (car ranges))
3880 (and (>= number (car (car ranges)))
3881 (<= number (cdr (car ranges)))))
3882 (setq not-stop nil))
3883 (setq ranges (cdr ranges)))
3886 (defun gnus-range-length (range)
3887 "Return the length RANGE would have if uncompressed."
3888 (length (gnus-uncompress-range range)))
3890 (defun gnus-sublist-p (list sublist)
3891 "Test whether all elements in SUBLIST are members of LIST."
3894 (unless (memq (pop sublist) list)
3904 (defvar gnus-group-mode-map nil)
3905 (put 'gnus-group-mode 'mode-class 'special)
3907 (unless gnus-group-mode-map
3908 (setq gnus-group-mode-map (make-keymap))
3909 (suppress-keymap gnus-group-mode-map)
3913 " " gnus-group-read-group
3914 "=" gnus-group-select-group
3915 "\M- " gnus-group-unhidden-select-group
3916 "\r" gnus-group-select-group
3917 "\M-\r" gnus-group-quick-select-group
3918 "j" gnus-group-jump-to-group
3919 "n" gnus-group-next-unread-group
3920 "p" gnus-group-prev-unread-group
3921 "\177" gnus-group-prev-unread-group
3922 "N" gnus-group-next-group
3923 "P" gnus-group-prev-group
3924 "\M-n" gnus-group-next-unread-group-same-level
3925 "\M-p" gnus-group-prev-unread-group-same-level
3926 "," gnus-group-best-unread-group
3927 "." gnus-group-first-unread-group
3928 "u" gnus-group-unsubscribe-current-group
3929 "U" gnus-group-unsubscribe-group
3930 "c" gnus-group-catchup-current
3931 "C" gnus-group-catchup-current-all
3932 "l" gnus-group-list-groups
3933 "L" gnus-group-list-all-groups
3935 "g" gnus-group-get-new-news
3936 "\M-g" gnus-group-get-new-news-this-group
3937 "R" gnus-group-restart
3938 "r" gnus-group-read-init-file
3939 "B" gnus-group-browse-foreign-server
3940 "b" gnus-group-check-bogus-groups
3941 "F" gnus-find-new-newsgroups
3942 "\C-c\C-d" gnus-group-describe-group
3943 "\M-d" gnus-group-describe-all-groups
3944 "\C-c\C-a" gnus-group-apropos
3945 "\C-c\M-\C-a" gnus-group-description-apropos
3946 "a" gnus-group-post-news
3947 "\ek" gnus-group-edit-local-kill
3948 "\eK" gnus-group-edit-global-kill
3949 "\C-k" gnus-group-kill-group
3950 "\C-y" gnus-group-yank-group
3951 "\C-w" gnus-group-kill-region
3952 "\C-x\C-t" gnus-group-transpose-groups
3953 "\C-c\C-l" gnus-group-list-killed
3954 "\C-c\C-x" gnus-group-expire-articles
3955 "\C-c\M-\C-x" gnus-group-expire-all-groups
3957 "s" gnus-group-save-newsrc
3958 "z" gnus-group-suspend
3959 "Z" gnus-group-clear-dribble
3962 "?" gnus-group-describe-briefly
3963 "\C-c\C-i" gnus-info-find-node
3964 "\M-e" gnus-group-edit-group-method
3965 "^" gnus-group-enter-server-mode
3966 gnus-mouse-2 gnus-mouse-pick-group
3967 "<" beginning-of-buffer
3970 "\C-c\C-s" gnus-group-sort-groups
3972 "\C-c\M-g" gnus-activate-all-groups
3973 "\M-&" gnus-group-universal-argument
3974 "#" gnus-group-mark-group
3975 "\M-#" gnus-group-unmark-group)
3978 (gnus-group-mark-map "M" gnus-group-mode-map)
3979 "m" gnus-group-mark-group
3980 "u" gnus-group-unmark-group
3981 "w" gnus-group-mark-region
3982 "m" gnus-group-mark-buffer
3983 "r" gnus-group-mark-regexp
3984 "U" gnus-group-unmark-all-groups)
3987 (gnus-group-group-map "G" gnus-group-mode-map)
3988 "d" gnus-group-make-directory-group
3989 "h" gnus-group-make-help-group
3990 "a" gnus-group-make-archive-group
3991 "k" gnus-group-make-kiboze-group
3992 "m" gnus-group-make-group
3993 "E" gnus-group-edit-group
3994 "e" gnus-group-edit-group-method
3995 "p" gnus-group-edit-group-parameters
3996 "v" gnus-group-add-to-virtual
3997 "V" gnus-group-make-empty-virtual
3998 "D" gnus-group-enter-directory
3999 "f" gnus-group-make-doc-group
4000 "r" gnus-group-rename-group
4001 "\177" gnus-group-delete-group)
4004 (gnus-group-soup-map "s" gnus-group-group-map)
4005 "b" gnus-group-brew-soup
4006 "w" gnus-soup-save-areas
4007 "s" gnus-soup-send-replies
4008 "p" gnus-soup-pack-packet
4009 "r" nnsoup-pack-replies)
4012 (gnus-group-sort-map "S" gnus-group-group-map)
4013 "s" gnus-group-sort-groups
4014 "a" gnus-group-sort-groups-by-alphabet
4015 "u" gnus-group-sort-groups-by-unread
4016 "l" gnus-group-sort-groups-by-level
4017 "v" gnus-group-sort-groups-by-score
4018 "r" gnus-group-sort-groups-by-rank
4019 "m" gnus-group-sort-groups-by-method)
4022 (gnus-group-list-map "A" gnus-group-mode-map)
4023 "k" gnus-group-list-killed
4024 "z" gnus-group-list-zombies
4025 "s" gnus-group-list-groups
4026 "u" gnus-group-list-all-groups
4027 "A" gnus-group-list-active
4028 "a" gnus-group-apropos
4029 "d" gnus-group-description-apropos
4030 "m" gnus-group-list-matching
4031 "M" gnus-group-list-all-matching
4032 "l" gnus-group-list-level)
4035 (gnus-group-score-map "W" gnus-group-mode-map)
4036 "f" gnus-score-flush-cache)
4039 (gnus-group-help-map "H" gnus-group-mode-map)
4040 "f" gnus-group-fetch-faq)
4043 (gnus-group-sub-map "S" gnus-group-mode-map)
4044 "l" gnus-group-set-current-level
4045 "t" gnus-group-unsubscribe-current-group
4046 "s" gnus-group-unsubscribe-group
4047 "k" gnus-group-kill-group
4048 "y" gnus-group-yank-group
4049 "w" gnus-group-kill-region
4050 "\C-k" gnus-group-kill-level
4051 "z" gnus-group-kill-all-zombies))
4053 (defun gnus-group-mode ()
4054 "Major mode for reading news.
4056 All normal editing commands are switched off.
4057 \\<gnus-group-mode-map>
4058 The group buffer lists (some of) the groups available. For instance,
4059 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
4060 lists all zombie groups.
4062 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
4063 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
4065 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
4067 The following commands are available:
4069 \\{gnus-group-mode-map}"
4071 (when (and menu-bar-mode
4072 (gnus-visual-p 'group-menu 'menu))
4073 (gnus-group-make-menu-bar))
4074 (kill-all-local-variables)
4075 (gnus-simplify-mode-line)
4076 (setq major-mode 'gnus-group-mode)
4077 (setq mode-name "Group")
4078 (gnus-group-set-mode-line)
4079 (setq mode-line-process nil)
4080 (use-local-map gnus-group-mode-map)
4081 (buffer-disable-undo (current-buffer))
4082 (setq truncate-lines t)
4083 (setq buffer-read-only t)
4084 (run-hooks 'gnus-group-mode-hook))
4086 (defun gnus-mouse-pick-group (e)
4087 "Enter the group under the mouse pointer."
4090 (gnus-group-read-group nil))
4092 ;; Look at LEVEL and find out what the level is really supposed to be.
4093 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
4094 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
4095 (defun gnus-group-default-level (&optional level number-or-nil)
4097 (gnus-group-use-permanent-levels
4098 (setq gnus-group-default-list-level
4099 (or level gnus-group-default-list-level))
4100 (or gnus-group-default-list-level gnus-level-subscribed))
4104 (or level gnus-group-default-list-level gnus-level-subscribed))))
4107 (defun gnus-slave-no-server (&optional arg)
4108 "Read network news as a slave, without connecting to local server"
4110 (gnus-no-server arg t))
4113 (defun gnus-no-server (&optional arg slave)
4115 If ARG is a positive number, Gnus will use that as the
4116 startup level. If ARG is nil, Gnus will be started at level 2.
4117 If ARG is non-nil and not a positive number, Gnus will
4118 prompt the user for the name of an NNTP server to use.
4119 As opposed to `gnus', this command will not connect to the local server."
4121 (make-local-variable 'gnus-group-use-permanent-levels)
4122 (setq gnus-group-use-permanent-levels t)
4123 (gnus (or arg (1- gnus-level-default-subscribed)) t slave))
4126 (defun gnus-slave (&optional arg)
4127 "Read news as a slave."
4129 (gnus arg nil 'slave))
4132 (defun gnus-other-frame (&optional arg)
4133 "Pop up a frame to read news."
4135 (if (get-buffer gnus-group-buffer)
4136 (let ((pop-up-frames t))
4138 (select-frame (make-frame))
4142 (defun gnus (&optional arg dont-connect slave)
4144 If ARG is non-nil and a positive number, Gnus will use that as the
4145 startup level. If ARG is non-nil and not a positive number, Gnus will
4146 prompt the user for the name of an NNTP server to use."
4149 (if (get-buffer gnus-group-buffer)
4151 (switch-to-buffer gnus-group-buffer)
4152 (gnus-group-get-new-news))
4155 (nnheader-init-server-buffer)
4156 (gnus-read-init-file)
4157 (setq gnus-slave slave)
4159 (gnus-group-setup-buffer)
4160 (let ((buffer-read-only nil))
4162 (if (not gnus-inhibit-startup-message)
4164 (gnus-group-startup-message)
4167 (let ((level (and (numberp arg) (> arg 0) arg))
4173 (gnus-start-news-server (and arg (not level))))))
4174 (if (and (not dont-connect)
4177 (run-hooks 'gnus-startup-hook)
4178 ;; NNTP server is successfully open.
4180 ;; Find the current startup file name.
4181 (setq gnus-current-startup-file
4182 (gnus-make-newsrc-file gnus-startup-file))
4184 ;; Read the dribble file.
4185 (and (or gnus-slave gnus-use-dribble-file) (gnus-dribble-read-file))
4187 (gnus-summary-make-display-table)
4188 ;; Do the actual startup.
4189 (gnus-setup-news nil level)
4190 ;; Generate the group buffer.
4191 (gnus-group-list-groups level)
4192 (gnus-group-first-unread-group)
4193 (gnus-configure-windows 'group)
4194 (gnus-group-set-mode-line))))))
4196 (defun gnus-unload ()
4197 "Unload all Gnus features."
4199 (or (boundp 'load-history)
4200 (error "Sorry, `gnus-unload' is not implemented in this Emacs version."))
4201 (let ((history load-history)
4204 (and (string-match "^\\(gnus\\|nn\\)" (caar history))
4205 (setq feature (cdr (assq 'provide (car history))))
4206 (unload-feature feature 'force))
4207 (setq history (cdr history)))))
4209 (defun gnus-compile ()
4210 "Byte-compile the user-defined format specs."
4212 (let ((entries gnus-format-specs)
4213 entry gnus-tmp-func)
4215 (gnus-message 7 "Compiling format specs...")
4218 (setq entry (pop entries))
4219 (if (eq (car entry) 'version)
4220 (setq gnus-format-specs (delq entry gnus-format-specs))
4221 (when (and (listp (caddr entry))
4222 (not (eq 'byte-code (caaddr entry))))
4223 (fset 'gnus-tmp-func
4224 `(lambda () ,(caddr entry)))
4225 (byte-compile 'gnus-tmp-func)
4226 (setcar (cddr entry) (gnus-byte-code 'gnus-tmp-func)))))
4228 (push (cons 'version emacs-version) gnus-format-specs)
4230 (gnus-message 7 "Compiling user specs...done"))))
4232 (defun gnus-indent-rigidly (start end arg)
4233 "Indent rigidly using only spaces and no tabs."
4236 (narrow-to-region start end)
4237 (indent-rigidly start end arg)
4238 (goto-char (point-min))
4239 (while (search-forward "\t" nil t)
4240 (replace-match " " t t)))))
4242 (defun gnus-group-startup-message (&optional x y)
4243 "Insert startup message in current buffer."
4244 ;; Insert the message.
4249 _ ___ __ ___ __ _ ___
4268 ;; And then hack it.
4269 (gnus-indent-rigidly (point-min) (point-max)
4270 (/ (max (- (window-width) (or x 46)) 0) 2))
4271 (goto-char (point-min))
4273 (let* ((pheight (count-lines (point-min) (point-max)))
4274 (wheight (window-height))
4275 (rest (- wheight pheight)))
4276 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
4278 (goto-char (point-min))
4279 (and (search-forward "Praxis" nil t)
4280 (put-text-property (match-beginning 0) (match-end 0) 'face 'bold))
4281 (goto-char (point-min))
4282 (let* ((mode-string (gnus-group-set-mode-line)))
4283 (setq mode-line-buffer-identification
4284 (list (concat gnus-version (substring (car mode-string) 4))))
4285 (set-buffer-modified-p t)))
4287 (defun gnus-group-setup-buffer ()
4288 (or (get-buffer gnus-group-buffer)
4290 (switch-to-buffer gnus-group-buffer)
4291 (gnus-add-current-to-buffer-list)
4293 (and gnus-carpal (gnus-carpal-setup-buffer 'group)))))
4295 (defun gnus-group-list-groups (&optional level unread lowest)
4296 "List newsgroups with level LEVEL or lower that have unread articles.
4297 Default is all subscribed groups.
4298 If argument UNREAD is non-nil, groups with no unread articles are also
4300 (interactive (list (if current-prefix-arg
4301 (prefix-numeric-value current-prefix-arg)
4303 (gnus-group-default-level nil t)
4304 gnus-group-default-list-level
4305 gnus-level-subscribed))))
4307 (setq level (car gnus-group-list-mode)
4308 unread (cdr gnus-group-list-mode)))
4309 (setq level (gnus-group-default-level level))
4310 (gnus-group-setup-buffer) ;May call from out of group buffer
4311 (gnus-update-format-specifications)
4312 (let ((case-fold-search nil)
4313 (props (text-properties-at (gnus-point-at-bol)))
4314 (group (gnus-group-group-name)))
4315 (funcall gnus-group-prepare-function level unread lowest)
4316 (if (zerop (buffer-size))
4317 (gnus-message 5 gnus-no-groups-message)
4318 (goto-char (point-max))
4319 (when (or (not gnus-group-goto-next-group-function)
4320 (not (funcall gnus-group-goto-next-group-function
4323 ;; Go to the first group with unread articles.
4324 (gnus-group-search-forward t)
4325 ;; Find the right group to put point on. If the current group
4326 ;; has disappeared in the new listing, try to find the next
4327 ;; one. If no next one can be found, just leave point at the
4328 ;; first newsgroup in the buffer.
4329 (if (not (gnus-goto-char
4331 (point-min) (point-max)
4332 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
4333 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
4335 (not (gnus-goto-char
4337 (point-min) (point-max) 'gnus-group
4339 (car (car newsrc)) gnus-active-hashtb)))))
4340 (setq newsrc (cdr newsrc)))
4341 (or newsrc (progn (goto-char (point-max))
4342 (forward-line -1)))))))
4343 ;; Adjust cursor point.
4344 (gnus-group-position-point))))
4346 (defun gnus-group-list-level (level &optional all)
4347 "List groups on LEVEL.
4348 If ALL (the prefix), also list groups that have no unread articles."
4349 (interactive "nList groups on level: \nP")
4350 (gnus-group-list-groups level all level))
4352 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
4353 "List all newsgroups with unread articles of level LEVEL or lower.
4354 If ALL is non-nil, list groups that have no unread articles.
4355 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
4356 If REGEXP, only list groups matching REGEXP."
4357 (set-buffer gnus-group-buffer)
4358 (let ((buffer-read-only nil)
4359 (newsrc (cdr gnus-newsrc-alist))
4360 (lowest (or lowest 1))
4361 info clevel unread group params)
4363 (if (< lowest gnus-level-zombie)
4364 ;; List living groups.
4366 (setq info (car newsrc)
4367 group (gnus-info-group info)
4368 params (gnus-info-params info)
4370 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
4371 (and unread ; This group might be bogus
4373 (string-match regexp group))
4374 (<= (setq clevel (gnus-info-level info)) level)
4376 (or all ; We list all groups?
4377 (and gnus-group-list-inactive-groups
4378 (eq unread t)) ; We list unactivated groups
4379 (> unread 0) ; We list groups with unread articles
4380 (and gnus-list-groups-with-ticked-articles
4381 (cdr (assq 'tick (gnus-info-marks info))))
4382 ; And groups with tickeds
4383 ;; Check for permanent visibility.
4384 (and gnus-permanently-visible-groups
4385 (string-match gnus-permanently-visible-groups
4387 (memq 'visible params)
4388 (cdr (assq 'visible params)))
4389 (gnus-group-insert-group-line
4390 group (gnus-info-level info)
4391 (gnus-info-marks info) unread (gnus-info-method info)))))
4393 ;; List dead groups.
4394 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
4395 (gnus-group-prepare-flat-list-dead
4396 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
4397 gnus-level-zombie ?Z
4399 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
4400 (gnus-group-prepare-flat-list-dead
4401 (setq gnus-killed-list (sort gnus-killed-list 'string<))
4402 gnus-level-killed ?K regexp))
4404 (gnus-group-set-mode-line)
4405 (setq gnus-group-list-mode (cons level all))
4406 (run-hooks 'gnus-group-prepare-hook)))
4408 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
4409 ;; List zombies and killed lists somewhat faster, which was
4410 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
4411 ;; this by ignoring the group format specification altogether.
4414 ;; This loop is used when listing groups that match some
4417 (setq group (pop groups))
4418 (when (string-match regexp group)
4419 (add-text-properties
4420 (point) (prog1 (1+ (point))
4421 (insert " " mark " *: " group "\n"))
4422 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4424 'gnus-level level))))
4425 ;; This loop is used when listing all groups.
4427 (add-text-properties
4428 (point) (prog1 (1+ (point))
4429 (insert " " mark " *: "
4430 (setq group (pop groups)) "\n"))
4431 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4433 'gnus-level level))))))
4435 (defmacro gnus-group-real-name (group)
4436 "Find the real name of a foreign newsgroup."
4437 `(let ((gname ,group))
4438 (if (string-match ":[^:]+$" gname)
4439 (substring gname (1+ (match-beginning 0)))
4442 (defsubst gnus-server-add-address (method)
4443 (let ((method-name (symbol-name (car method))))
4444 (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
4445 (not (assq (intern (concat method-name "-address")) method)))
4446 (append method (list (list (intern (concat method-name "-address"))
4450 (defsubst gnus-server-get-method (group method)
4451 ;; Input either a server name, and extended server name, or a
4452 ;; select method, and return a select method.
4453 (cond ((stringp method)
4454 (gnus-server-to-method method))
4455 ((and (stringp (car method)) group)
4456 (gnus-server-extend-method group method))
4458 (gnus-server-add-address method))))
4460 (defun gnus-server-to-method (server)
4461 "Map virtual server names to select methods."
4462 (or (and (equal server "native") gnus-select-method)
4463 (cdr (assoc server gnus-server-alist))))
4465 (defmacro gnus-server-equal (ss1 ss2)
4466 "Say whether two servers are equal."
4470 (and (= (length s1) (length s2))
4472 (while (and s1 (member (car s1) s2))
4476 (defun gnus-group-prefixed-name (group method)
4477 "Return the whole name from GROUP and METHOD."
4478 (and (stringp method) (setq method (gnus-server-to-method method)))
4479 (concat (format "%s" (car method))
4481 (assoc (format "%s" (car method)) (gnus-methods-using 'address))
4482 (not (string= (nth 1 method) "")))
4483 (concat "+" (nth 1 method)))
4486 (defun gnus-group-real-prefix (group)
4487 "Return the prefix of the current group name."
4488 (if (string-match "^[^:]+:" group)
4489 (substring group 0 (match-end 0))
4492 (defun gnus-group-method-name (group)
4493 "Return the method used for selecting GROUP."
4494 (let ((prefix (gnus-group-real-prefix group)))
4495 (if (equal prefix "")
4497 (if (string-match "^[^\\+]+\\+" prefix)
4498 (list (intern (substring prefix 0 (1- (match-end 0))))
4499 (substring prefix (match-end 0) (1- (length prefix))))
4500 (list (intern (substring prefix 0 (1- (length prefix)))) "")))))
4502 (defsubst gnus-secondary-method-p (method)
4503 "Return whether METHOD is a secondary select method."
4504 (let ((methods gnus-secondary-select-methods)
4505 (gmethod (gnus-server-get-method nil method)))
4507 (not (equal (gnus-server-get-method nil (car methods))
4509 (setq methods (cdr methods)))
4512 (defun gnus-group-foreign-p (group)
4513 "Say whether a group is foreign or not."
4514 (and (not (gnus-group-native-p group))
4515 (not (gnus-group-secondary-p group))))
4517 (defun gnus-group-native-p (group)
4518 "Say whether the group is native or not."
4519 (not (string-match ":" group)))
4521 (defun gnus-group-secondary-p (group)
4522 "Say whether the group is secondary or not."
4523 (gnus-secondary-method-p (gnus-find-method-for-group group)))
4525 (defun gnus-group-get-parameter (group &optional symbol)
4526 "Returns the group parameters for GROUP.
4527 If SYMBOL, return the value of that symbol in the group parameters."
4528 (let ((params (gnus-info-params (gnus-get-info group))))
4530 (gnus-group-parameter-value params symbol)
4533 (defun gnus-group-parameter-value (params symbol)
4534 "Return the value of SYMBOL in group PARAMS."
4535 (or (car (memq symbol params)) ; It's either a simple symbol
4536 (cdr (assq symbol params)))) ; or a cons.
4538 (defun gnus-group-add-parameter (group param)
4539 "Add parameter PARAM to GROUP."
4540 (let ((info (gnus-get-info group)))
4542 () ; This is a dead group. We just ignore it.
4543 ;; Cons the new param to the old one and update.
4544 (gnus-group-set-info (cons param (gnus-info-params info))
4547 (defun gnus-group-add-score (group &optional score)
4548 "Add SCORE to the GROUP score.
4549 If SCORE is nil, add 1 to the score of GROUP."
4550 (let ((info (gnus-get-info group)))
4551 (gnus-info-set-score info (+ (gnus-info-score info) (or score 1)))))
4553 (defun gnus-summary-bubble-group ()
4554 "Increase the score of the current group.
4555 This is a handy function to add to `gnus-summary-exit-hook' to
4556 increase the score of each group you read."
4557 (gnus-group-add-score gnus-newsgroup-name))
4559 (defun gnus-group-set-info (info &optional method-only-group part)
4560 (let* ((entry (gnus-gethash
4561 (or method-only-group (gnus-info-group info))
4562 gnus-newsrc-hashtb))
4564 (info (if method-only-group (nth 2 entry) info)))
4565 (when method-only-group
4567 (error "Trying to change non-existent group %s" method-only-group))
4568 ;; We have received parts of the actual group info - either the
4569 ;; select method or the group parameters. We first check
4570 ;; whether we have to extend the info, and if so, do that.
4571 (let ((len (length info))
4572 (total (if (eq part 'method) 5 6)))
4574 (setcdr (nthcdr (1- len) info)
4575 (make-list (- total len) nil)))
4576 ;; Then we enter the new info.
4577 (setcar (nthcdr (1- total) info) part-info)))
4579 ;; This is a new group, so we just create it.
4581 (set-buffer gnus-group-buffer)
4582 (if (gnus-info-method info)
4583 ;; It's a foreign group...
4584 (gnus-group-make-group
4585 (gnus-group-real-name (gnus-info-group info))
4586 (prin1-to-string (car (gnus-info-method info)))
4587 (nth 1 (gnus-info-method info)))
4588 ;; It's a native group.
4589 (gnus-group-make-group (gnus-info-group info)))
4590 (gnus-message 6 "Note: New group created")
4592 (gnus-gethash (gnus-group-prefixed-name
4593 (gnus-group-real-name (gnus-info-group info))
4594 (or (gnus-info-method info) gnus-select-method))
4595 gnus-newsrc-hashtb))))
4596 ;; Whether it was a new group or not, we now have the entry, so we
4597 ;; can do the update.
4600 (setcar (nthcdr 2 entry) info)
4601 (when (and (not (eq (car entry) t))
4602 (gnus-active (gnus-info-group info)))
4603 (let ((marked (gnus-info-marks info)))
4604 (setcar entry (length (gnus-list-of-unread-articles
4606 (error "No such group: %s" (gnus-info-group info)))))
4608 (defun gnus-group-set-method-info (group select-method)
4609 (gnus-group-set-info select-method group 'method))
4611 (defun gnus-group-set-params-info (group params)
4612 (gnus-group-set-info params group 'params))
4614 (defun gnus-group-update-group-line ()
4615 "Update the current line in the group buffer."
4616 (let* ((buffer-read-only nil)
4617 (group (gnus-group-group-name))
4618 (gnus-group-indentation (gnus-group-group-indentation))
4619 (entry (and group (gnus-gethash group gnus-newsrc-hashtb))))
4621 (not (gnus-ephemeral-group-p group))
4623 (concat "(gnus-group-set-info '"
4624 (prin1-to-string (nth 2 entry)) ")")))
4626 (gnus-group-insert-group-line-info group)
4628 (gnus-group-position-point)))
4630 (defun gnus-group-insert-group-line-info (group)
4631 "Insert GROUP on the current line."
4632 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
4636 ;; (Un)subscribed group.
4637 (setq info (nth 2 entry))
4638 (gnus-group-insert-group-line
4639 group (gnus-info-level info) (gnus-info-marks info)
4640 (or (car entry) t) (gnus-info-method info)))
4641 ;; This group is dead.
4642 (gnus-group-insert-group-line
4644 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
4646 (if (setq active (gnus-active group))
4647 (- (1+ (cdr active)) (car active)) 0)
4650 (defun gnus-group-insert-group-line
4651 (gnus-tmp-group gnus-tmp-level gnus-tmp-marked number
4653 "Insert a group line in the group buffer."
4654 (let* ((gnus-tmp-active (gnus-active gnus-tmp-group))
4655 (gnus-tmp-number-total
4657 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
4659 (gnus-tmp-number-of-unread
4660 (if (numberp number) (int-to-string (max 0 number))
4662 (gnus-tmp-number-of-read
4663 (if (numberp number)
4664 (int-to-string (max 0 (- gnus-tmp-number-total number)))
4666 (gnus-tmp-subscribed
4667 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
4668 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
4669 ((= gnus-tmp-level gnus-level-zombie) ?Z)
4671 (gnus-tmp-qualified-group (gnus-group-real-name gnus-tmp-group))
4672 (gnus-tmp-newsgroup-description
4673 (if gnus-description-hashtb
4674 (or (gnus-gethash gnus-tmp-group gnus-description-hashtb) "")
4677 (if (member gnus-tmp-group gnus-moderated-list) ?m ? ))
4678 (gnus-tmp-moderated-string
4679 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
4681 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
4682 (gnus-tmp-news-server (or (car (cdr gnus-tmp-method)) ""))
4683 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
4684 (gnus-tmp-news-method-string
4686 (format "(%s:%s)" (car gnus-tmp-method)
4687 (car (cdr gnus-tmp-method))) ""))
4688 (gnus-tmp-marked-mark
4689 (if (and (numberp number)
4691 (cdr (assq 'tick gnus-tmp-marked)))
4693 (gnus-tmp-process-marked
4694 (if (member gnus-tmp-group gnus-group-marked)
4695 gnus-process-mark ? ))
4696 (buffer-read-only nil)
4697 header gnus-tmp-header) ; passed as parameter to user-funcs.
4699 (add-text-properties
4703 (eval gnus-group-line-format-spec))
4704 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
4705 gnus-unread ,(if (numberp number)
4706 (string-to-int gnus-tmp-number-of-unread)
4708 gnus-marked ,gnus-tmp-marked-mark
4709 gnus-indentation ,gnus-group-indentation
4710 gnus-level ,gnus-tmp-level))
4711 (when (gnus-visual-p 'group-highlight 'highlight)
4713 (run-hooks 'gnus-group-update-hook)
4715 ;; Allow XEmacs to remove front-sticky text properties.
4716 (gnus-group-remove-excess-properties)))
4718 (defun gnus-group-update-group (group &optional visible-only)
4719 "Update all lines where GROUP appear.
4720 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
4723 (set-buffer gnus-group-buffer)
4724 ;; The buffer may be narrowed.
4727 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
4729 found buffer-read-only visible)
4730 ;; Enter the current status into the dribble buffer.
4731 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
4732 (if (and entry (not (gnus-ephemeral-group-p group)))
4734 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
4736 ;; Find all group instances. If topics are in use, each group
4737 ;; may be listed in more than once.
4738 (while (setq loc (text-property-any
4739 loc (point-max) 'gnus-group ident))
4742 (let ((gnus-group-indentation (gnus-group-group-indentation)))
4744 (gnus-group-insert-group-line-info group))
4745 (setq loc (1+ loc)))
4746 (unless (or found visible-only)
4747 ;; No such line in the buffer, find out where it's supposed to
4748 ;; go, and insert it there (or at the end of the buffer).
4749 (if gnus-goto-missing-group-function
4750 (funcall gnus-goto-missing-group-function group)
4751 (let ((entry (cdr (cdr (gnus-gethash group gnus-newsrc-hashtb)))))
4752 (while (and entry (car entry)
4756 (point-min) (point-max)
4757 'gnus-group (gnus-intern-safe
4759 gnus-active-hashtb)))))
4760 (setq entry (cdr entry)))
4761 (or entry (goto-char (point-max)))))
4762 ;; Finally insert the line.
4763 (let ((gnus-group-indentation (gnus-group-group-indentation)))
4764 (gnus-group-insert-group-line-info group)))
4765 (gnus-group-set-mode-line)))))
4767 (defun gnus-group-set-mode-line ()
4768 (when (memq 'group gnus-updated-mode-lines)
4769 (let* ((gformat (or gnus-group-mode-line-format-spec
4770 (setq gnus-group-mode-line-format-spec
4772 gnus-group-mode-line-format
4773 gnus-group-mode-line-format-alist))))
4774 (gnus-tmp-news-server (car (cdr gnus-select-method)))
4775 (gnus-tmp-news-method (car gnus-select-method))
4777 gnus-tmp-header ;Dummy binding for user-defined formats
4778 ;; Get the resulting string.
4779 (mode-string (eval gformat)))
4780 ;; If the line is too long, we chop it off.
4781 (when (> (length mode-string) max-len)
4782 (setq mode-string (substring mode-string 0 (- max-len 4))))
4784 (setq mode-line-buffer-identification (list mode-string))
4785 (set-buffer-modified-p t)))))
4787 (defun gnus-group-group-name ()
4788 "Get the name of the newsgroup on the current line."
4789 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
4790 (and group (symbol-name group))))
4792 (defun gnus-group-group-level ()
4793 "Get the level of the newsgroup on the current line."
4794 (get-text-property (gnus-point-at-bol) 'gnus-level))
4796 (defun gnus-group-group-indentation ()
4797 "Get the indentation of the newsgroup on the current line."
4798 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation) ""))
4800 (defun gnus-group-group-unread ()
4801 "Get the number of unread articles of the newsgroup on the current line."
4802 (get-text-property (gnus-point-at-bol) 'gnus-unread))
4804 (defun gnus-group-search-forward (&optional backward all level first-too)
4805 "Find the next newsgroup with unread articles.
4806 If BACKWARD is non-nil, find the previous newsgroup instead.
4807 If ALL is non-nil, just find any newsgroup.
4808 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
4810 If FIRST-TOO, the current line is also eligible as a target."
4811 (let ((way (if backward -1 1))
4812 (low gnus-level-killed)
4815 (if (and backward (progn (beginning-of-line)) (bobp))
4817 (or first-too (forward-line way))
4825 (get-text-property (point) 'gnus-unread)))
4826 (and (numberp unread) (> unread 0)))
4827 (setq lev (get-text-property (point)
4829 (<= lev gnus-level-subscribed)))
4831 (and (setq lev (get-text-property (point)
4840 (zerop (forward-line way)))))
4842 (progn (gnus-group-position-point) t)
4843 (goto-char (or pos beg))
4846 ;;; Gnus group mode commands
4850 (defun gnus-group-mark-group (n &optional unmark no-advance)
4851 "Mark the current group."
4853 (let ((buffer-read-only nil)
4857 (setq group (gnus-group-group-name))
4861 (or (cdr (assq 'process gnus-group-mark-positions)) 2))
4866 (setq gnus-group-marked (delete group gnus-group-marked)))
4868 (setq gnus-group-marked
4869 (cons group (delete group gnus-group-marked))))
4871 (or no-advance (zerop (gnus-group-next-group 1))))
4873 (gnus-summary-position-point)
4876 (defun gnus-group-unmark-group (n)
4877 "Remove the mark from the current group."
4879 (gnus-group-mark-group n 'unmark)
4880 (gnus-group-position-point))
4882 (defun gnus-group-unmark-all-groups ()
4883 "Unmark all groups."
4884 (let ((groups gnus-group-marked))
4887 (gnus-group-remove-mark (pop groups)))))
4888 (gnus-group-position-point))
4890 (defun gnus-group-mark-region (unmark beg end)
4891 "Mark all groups between point and mark.
4892 If UNMARK, remove the mark instead."
4893 (interactive "P\nr")
4894 (let ((num (count-lines beg end)))
4897 (- num (gnus-group-mark-group num unmark)))))
4899 (defun gnus-group-mark-buffer (&optional unmark)
4900 "Mark all groups in the buffer.
4901 If UNMARK, remove the mark instead."
4903 (gnus-group-mark-region unmark (point-min) (point-max)))
4905 (defun gnus-group-mark-regexp (regexp)
4906 "Mark all groups that match some regexp."
4907 (interactive "sMark (regexp): ")
4908 (let ((alist (cdr gnus-newsrc-alist))
4911 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
4912 (gnus-group-set-mark group))))
4913 (gnus-group-position-point))
4915 (defun gnus-group-remove-mark (group)
4916 "Remove the process mark from GROUP and move point there.
4917 Return nil if the group isn't displayed."
4918 (if (gnus-group-goto-group group)
4920 (gnus-group-mark-group 1 'unmark t)
4922 (setq gnus-group-marked
4923 (delete group gnus-group-marked))
4926 (defun gnus-group-set-mark (group)
4927 "Set the process mark on GROUP."
4928 (if (gnus-group-goto-group group)
4930 (gnus-group-mark-group 1 nil t))
4931 (setq gnus-group-marked
4932 (cons group (delete group gnus-group-marked)))))
4934 (defun gnus-group-universal-argument (arg &optional groups func)
4935 "Perform any command on all groups accoring to the process/prefix convention."
4937 (let ((groups (or groups (gnus-group-process-prefix arg)))
4939 (if (eq (setq func (or func
4942 (substitute-command-keys
4943 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
4946 (message "Undefined key")
4949 (gnus-group-remove-mark (setq group (pop groups)))
4950 (command-execute func))))
4951 (gnus-group-position-point))
4953 (defun gnus-group-process-prefix (n)
4954 "Return a list of groups to work on.
4955 Take into consideration N (the prefix) and the list of marked groups."
4958 (setq n (prefix-numeric-value n))
4959 ;; There is a prefix, so we return a list of the N next
4961 (let ((way (if (< n 0) -1 1))
4966 (setq group (gnus-group-group-name)))
4967 (setq groups (cons group groups))
4969 (gnus-group-next-group way)))
4971 ((and (boundp 'transient-mark-mode)
4974 ;; Work on the region between point and mark.
4975 (let ((max (max (point) (mark)))
4978 (goto-char (min (point) (mark)))
4981 (push (gnus-group-group-name) groups)
4982 (zerop (gnus-group-next-group 1))
4984 (nreverse groups))))
4986 ;; No prefix, but a list of marked articles.
4987 (reverse gnus-group-marked))
4989 ;; Neither marked articles or a prefix, so we return the
4991 (let ((group (gnus-group-group-name)))
4992 (and group (list group))))))
4994 ;; Selecting groups.
4996 (defun gnus-group-read-group (&optional all no-article group)
4997 "Read news in this newsgroup.
4998 If the prefix argument ALL is non-nil, already read articles become
4999 readable. IF ALL is a number, fetch this number of articles. If the
5000 optional argument NO-ARTICLE is non-nil, no article will be
5001 auto-selected upon group entry. If GROUP is non-nil, fetch that
5004 (let ((group (or group (gnus-group-group-name)))
5005 number active marked entry)
5006 (or group (error "No group on current line"))
5007 (setq marked (nth 3 (nth 2 (setq entry (gnus-gethash
5008 group gnus-newsrc-hashtb)))))
5009 ;; This group might be a dead group. In that case we have to get
5010 ;; the number of unread articles from `gnus-active-hashtb'.
5012 (cond ((numberp all) all)
5014 ((setq active (gnus-active group))
5015 (- (1+ (cdr active)) (car active)))))
5016 (gnus-summary-read-group
5017 group (or all (and (numberp number)
5018 (zerop (+ number (length (cdr (assq 'tick marked)))
5019 (length (cdr (assq 'dormant marked)))))))
5022 (defun gnus-group-select-group (&optional all)
5023 "Select this newsgroup.
5024 No article is selected automatically.
5025 If ALL is non-nil, already read articles become readable.
5026 If ALL is a number, fetch this number of articles."
5028 (gnus-group-read-group all t))
5030 (defun gnus-group-quick-select-group (&optional all)
5031 "Select the current group \"quickly\".
5032 This means that no highlighting or scoring will be performed."
5035 gnus-score-find-score-files-function
5036 gnus-apply-kill-hook
5037 gnus-summary-expunge-below)
5038 (gnus-group-read-group all t)))
5040 (defun gnus-group-visible-select-group (&optional all)
5041 "Select the current group without hiding any articles."
5043 (let ((gnus-inhibit-limiting t))
5044 (gnus-group-read-group all t)))
5047 (defun gnus-fetch-group (group)
5048 "Start Gnus if necessary and enter GROUP.
5049 Returns whether the fetching was successful or not."
5050 (interactive "sGroup name: ")
5051 (or (get-buffer gnus-group-buffer)
5053 (gnus-group-select-group))
5055 ;; Enter a group that is not in the group buffer. Non-nil is returned
5056 ;; if selection was successful.
5057 (defun gnus-group-read-ephemeral-group
5058 (group method &optional activate quit-config)
5059 (let ((group (if (gnus-group-foreign-p group) group
5060 (gnus-group-prefixed-name group method))))
5063 (list t nil (list group gnus-level-default-subscribed nil nil
5067 (if quit-config quit-config
5068 (cons (current-buffer) 'summary)))))))
5070 (set-buffer gnus-group-buffer)
5071 (or (gnus-check-server method)
5072 (error "Unable to contact server: %s" (gnus-status-message method)))
5073 (if activate (or (gnus-request-group group)
5074 (error "Couldn't request group")))
5076 (gnus-group-read-group t t group)
5080 (defun gnus-group-jump-to-group (group)
5081 "Jump to newsgroup GROUP."
5083 (list (completing-read
5084 "Group: " gnus-active-hashtb nil
5085 (memq gnus-select-method gnus-have-read-active-file))))
5087 (if (equal group "")
5088 (error "Empty group name"))
5090 (let ((b (text-property-any
5091 (point-min) (point-max)
5092 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
5093 (unless (gnus-ephemeral-group-p group)
5095 ;; Either go to the line in the group buffer...
5097 ;; ... or insert the line.
5100 (gnus-activate-group group)
5101 (error "%s error: %s" group (gnus-status-message group)))
5103 (gnus-group-update-group group)
5104 (goto-char (text-property-any
5105 (point-min) (point-max)
5106 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))
5107 ;; Adjust cursor point.
5108 (gnus-group-position-point)))
5110 (defun gnus-group-goto-group (group)
5111 "Goto to newsgroup GROUP."
5113 (let ((b (text-property-any (point-min) (point-max)
5114 'gnus-group (gnus-intern-safe
5115 group gnus-active-hashtb))))
5116 (and b (goto-char b)))))
5118 (defun gnus-group-next-group (n)
5119 "Go to next N'th newsgroup.
5120 If N is negative, search backward instead.
5121 Returns the difference between N and the number of skips actually
5124 (gnus-group-next-unread-group n t))
5126 (defun gnus-group-next-unread-group (n &optional all level)
5127 "Go to next N'th unread newsgroup.
5128 If N is negative, search backward instead.
5129 If ALL is non-nil, choose any newsgroup, unread or not.
5130 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
5131 such group can be found, the next group with a level higher than
5133 Returns the difference between N and the number of skips actually
5136 (let ((backward (< n 0))
5139 (gnus-group-search-forward
5140 backward (or (not gnus-group-goto-unread) all) level))
5142 (if (/= 0 n) (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
5143 (if level " on this level or higher" "")))
5146 (defun gnus-group-prev-group (n)
5147 "Go to previous N'th newsgroup.
5148 Returns the difference between N and the number of skips actually
5151 (gnus-group-next-unread-group (- n) t))
5153 (defun gnus-group-prev-unread-group (n)
5154 "Go to previous N'th unread newsgroup.
5155 Returns the difference between N and the number of skips actually
5158 (gnus-group-next-unread-group (- n)))
5160 (defun gnus-group-next-unread-group-same-level (n)
5161 "Go to next N'th unread newsgroup on the same level.
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 (gnus-group-group-level))
5167 (gnus-group-position-point))
5169 (defun gnus-group-prev-unread-group-same-level (n)
5170 "Go to next N'th unread newsgroup on the same level.
5171 Returns the difference between N and the number of skips actually
5174 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
5175 (gnus-group-position-point))
5177 (defun gnus-group-best-unread-group (&optional exclude-group)
5178 "Go to the group with the highest level.
5179 If EXCLUDE-GROUP, do not go to that group."
5181 (goto-char (point-min))
5184 (while (setq unread (get-text-property (point) 'gnus-unread))
5185 (if (and (numberp unread) (> unread 0))
5187 (if (and (< (get-text-property (point) 'gnus-level) best)
5188 (or (not exclude-group)
5189 (not (equal exclude-group (gnus-group-group-name)))))
5191 (setq best (get-text-property (point) 'gnus-level))
5192 (setq best-point (point))))))
5194 (if best-point (goto-char best-point))
5195 (gnus-summary-position-point)
5196 (and best-point (gnus-group-group-name))))
5198 (defun gnus-group-first-unread-group ()
5199 "Go to the first group with unread articles."
5202 (let ((opoint (point))
5204 (goto-char (point-min))
5205 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
5206 (and (numberp unread) ; Not a topic.
5207 (not (zerop unread))) ; Has unread articles.
5208 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
5211 nil)) ; Not success.
5212 (gnus-group-position-point)))
5214 (defun gnus-group-enter-server-mode ()
5215 "Jump to the server buffer."
5217 (gnus-enter-server-buffer))
5219 (defun gnus-group-make-group (name &optional method address)
5220 "Add a new newsgroup.
5221 The user will be prompted for a NAME, for a select METHOD, and an
5225 (read-string "Group name: ")
5228 "Method: " (append gnus-valid-select-methods gnus-server-alist)
5230 (if (assoc method gnus-valid-select-methods)
5232 (if (memq 'prompt-address
5233 (assoc method gnus-valid-select-methods))
5234 (read-string "Address: ")
5236 (list method nil)))))
5239 (set-buffer gnus-group-buffer)
5240 (let* ((meth (and method (if address (list (intern method) address)
5242 (nname (if method (gnus-group-prefixed-name name meth) name))
5244 (and (gnus-gethash nname gnus-newsrc-hashtb)
5245 (error "Group %s already exists" nname))
5246 (gnus-group-change-level
5247 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
5248 gnus-level-default-subscribed gnus-level-killed
5249 (and (gnus-group-group-name)
5250 (gnus-gethash (gnus-group-group-name)
5251 gnus-newsrc-hashtb))
5253 (gnus-set-active nname (cons 1 0))
5254 (or (gnus-ephemeral-group-p name)
5256 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")")))
5257 (gnus-group-insert-group-line-info nname)
5259 (if (assoc method gnus-valid-select-methods)
5260 (require (intern method)))
5261 (and (gnus-check-backend-function 'request-create-group nname)
5262 (gnus-request-create-group nname))
5265 (defun gnus-group-delete-group (group &optional force)
5266 "Delete the current group.
5267 If FORCE (the prefix) is non-nil, all the articles in the group will
5268 be deleted. This is \"deleted\" as in \"removed forever from the face
5269 of the Earth\". There is no undo."
5271 (list (gnus-group-group-name)
5272 current-prefix-arg))
5273 (or group (error "No group to rename"))
5274 (or (gnus-check-backend-function 'request-delete-group group)
5275 (error "This backend does not support group deletion"))
5277 (if (not (gnus-yes-or-no-p
5279 "Do you really want to delete %s%s? "
5280 group (if force " and all its contents" ""))))
5282 (gnus-message 6 "Deleting group %s..." group)
5283 (if (not (gnus-request-delete-group group force))
5285 (gnus-message 3 "Couldn't delete group %s" group)
5287 (gnus-message 6 "Deleting group %s...done" group)
5288 (gnus-group-goto-group group)
5289 (gnus-group-kill-group 1 t)
5291 (gnus-group-position-point)))
5293 (defun gnus-group-rename-group (group new-name)
5296 (gnus-group-group-name)
5298 (or (gnus-check-backend-function
5299 'request-rename-group (gnus-group-group-name))
5300 (error "This backend does not support renaming groups"))
5301 (read-string "New group name: "))))
5303 (or (gnus-check-backend-function 'request-rename-group group)
5304 (error "This backend does not support renaming groups"))
5306 (or group (error "No group to rename"))
5307 (and (string-match "^[ \t]*$" new-name)
5308 (error "Not a valid group name"))
5310 ;; We find the proper prefixed name.
5312 (gnus-group-prefixed-name
5313 (gnus-group-real-name new-name)
5314 (gnus-info-method (gnus-get-info group))))
5316 (gnus-message 6 "Renaming group %s to %s..." group new-name)
5318 (if (not (gnus-request-rename-group group new-name))
5320 (gnus-message 3 "Couldn't rename group %s to %s" group new-name)
5322 ;; We rename the group internally by killing it...
5323 (gnus-group-goto-group group)
5324 (gnus-group-kill-group)
5325 ;; ... changing its name ...
5326 (setcar (cdr (car gnus-list-of-killed-groups))
5328 ;; ... and then yanking it. Magic!
5329 (gnus-group-yank-group)
5330 (gnus-set-active new-name (gnus-active group))
5331 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
5333 (gnus-group-position-point)))
5336 (defun gnus-group-edit-group (group &optional part)
5337 "Edit the group on the current line."
5338 (interactive (list (gnus-group-group-name)))
5339 (let ((done-func '(lambda ()
5340 "Exit editing mode and update the information."
5342 (gnus-group-edit-group-done 'part 'group)))
5343 (part (or part 'info))
5344 (winconf (current-window-configuration))
5346 (or group (error "No group on current line"))
5347 (or (setq info (gnus-get-info group))
5348 (error "Killed group; can't be edited"))
5349 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5350 (gnus-configure-windows 'edit-group)
5351 (gnus-add-current-to-buffer-list)
5353 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
5354 (use-local-map (copy-keymap emacs-lisp-mode-map))
5355 (local-set-key "\C-c\C-c" done-func)
5356 (make-local-variable 'gnus-prev-winconf)
5357 (setq gnus-prev-winconf winconf)
5358 ;; We modify the func to let it know what part it is editing.
5359 (setcar (cdr (nth 4 done-func)) (list 'quote part))
5360 (setcar (cdr (cdr (nth 4 done-func))) group)
5365 ";; Type `C-c C-c' after editing the select method.\n\n")
5367 ";; Type `C-c C-c' after editing the group parameters.\n\n")
5369 ";; Type `C-c C-c' after editing the group info.\n\n")))
5372 (cond ((eq part 'method)
5373 (or (gnus-info-method info) "native"))
5375 (gnus-info-params info))
5379 (defun gnus-group-edit-group-method (group)
5380 "Edit the select method of GROUP."
5381 (interactive (list (gnus-group-group-name)))
5382 (gnus-group-edit-group group 'method))
5384 (defun gnus-group-edit-group-parameters (group)
5385 "Edit the group parameters of GROUP."
5386 (interactive (list (gnus-group-group-name)))
5387 (gnus-group-edit-group group 'params))
5389 (defun gnus-group-edit-group-done (part group)
5390 "Get info from buffer, update variables and jump to the group buffer."
5391 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5392 (goto-char (point-min))
5393 (let* ((form (read (current-buffer)))
5394 (winconf gnus-prev-winconf)
5395 (new-group (when (eq part 'info)
5396 (if (or (not (nth 4 form))
5398 gnus-select-method (nth 4 form)))
5399 (gnus-group-real-name (car form))
5400 (gnus-group-prefixed-name
5401 (gnus-group-real-name (car form)) (nth 4 form))))))
5405 (when new-group (setcar form new-group))
5406 (gnus-group-set-info form))
5407 (gnus-group-set-info form group part))
5408 (kill-buffer (current-buffer))
5409 (and winconf (set-window-configuration winconf))
5410 (set-buffer gnus-group-buffer)
5411 (when (and new-group
5412 (not (equal new-group group)))
5413 (when (gnus-group-goto-group group)
5414 (gnus-group-kill-group 1))
5415 (gnus-activate-group new-group))
5416 (gnus-group-update-group (or new-group group))
5417 (gnus-group-position-point)))
5419 (defun gnus-group-make-help-group ()
5420 "Create the Gnus documentation group."
5422 (let ((path load-path)
5423 (name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
5425 (and (gnus-gethash name gnus-newsrc-hashtb)
5426 (error "Documentation group already exists"))
5428 (setq dir (file-name-as-directory (expand-file-name (pop path)))
5430 (when (or (file-exists-p (setq file (concat dir "gnus-tut.txt")))
5432 (setq file (concat (file-name-directory
5433 (directory-file-name dir))
5434 "etc/gnus-tut.txt"))))
5437 (message "Couldn't find doc group")
5438 (gnus-group-make-group
5439 (gnus-group-real-name name)
5441 (list 'nndoc-address file)
5442 (list 'nndoc-article-type 'mbox)))))
5443 (gnus-group-position-point))
5445 (defun gnus-group-make-doc-group (file type)
5446 "Create a group that uses a single file as the source."
5448 (list (read-file-name "File name: ")
5449 (and current-prefix-arg 'ask)))
5450 (when (eq type 'ask)
5455 "%sFile type (mbox, babyl, digest, forward, mmfd, guess) [mbdfag]: "
5457 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
5458 ((= char ?b) 'babyl)
5459 ((= char ?d) 'digest)
5460 ((= char ?f) 'forward)
5462 (t (setq err (format "%c unknown. " char))
5465 (let* ((file (expand-file-name file))
5466 (name (gnus-generate-new-group-name
5467 (gnus-group-prefixed-name
5468 (file-name-nondirectory file) '(nndoc "")))))
5469 (gnus-group-make-group
5470 (gnus-group-real-name name)
5472 (list 'nndoc-address file)
5473 (list 'nndoc-article-type (or type 'guess))))
5475 (gnus-group-position-point)))
5477 (defun gnus-group-make-archive-group (&optional all)
5478 "Create the (ding) Gnus archive group of the most recent articles.
5479 Given a prefix, create a full group."
5481 (let ((group (gnus-group-prefixed-name
5482 (if all "ding.archives" "ding.recent") '(nndir ""))))
5483 (and (gnus-gethash group gnus-newsrc-hashtb)
5484 (error "Archive group already exists"))
5485 (gnus-group-make-group
5486 (gnus-group-real-name group)
5487 (list 'nndir (if all "hpc" "edu")
5488 (list 'nndir-directory
5489 (if all gnus-group-archive-directory
5490 gnus-group-recent-archive-directory)))))
5492 (gnus-group-position-point))
5494 (defun gnus-group-make-directory-group (dir)
5495 "Create an nndir group.
5496 The user will be prompted for a directory. The contents of this
5497 directory will be used as a newsgroup. The directory should contain
5498 mail messages or news articles in files that have numeric names."
5500 (list (read-file-name "Create group from directory: ")))
5501 (or (file-exists-p dir) (error "No such directory"))
5502 (or (file-directory-p dir) (error "Not a directory"))
5506 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
5508 (gnus-group-prefixed-name
5509 (concat (file-name-as-directory (directory-file-name dir))
5512 (setq ext (format "<%d>" (setq i (1+ i)))))
5513 (gnus-group-make-group
5514 (gnus-group-real-name group)
5515 (list 'nndir group (list 'nndir-directory dir))))
5517 (gnus-group-position-point))
5519 (defun gnus-group-make-kiboze-group (group address scores)
5520 "Create an nnkiboze group.
5521 The user will be prompted for a name, a regexp to match groups, and
5522 score file entries for articles to include in the group."
5525 (read-string "nnkiboze group name: ")
5526 (read-string "Source groups (regexp): ")
5527 (let ((headers (mapcar (lambda (group) (list group))
5528 '("subject" "from" "number" "date" "message-id"
5529 "references" "chars" "lines" "xref"
5530 "followup" "all" "body" "head")))
5531 scores header regexp regexps)
5532 (while (not (equal "" (setq header (completing-read
5533 "Match on header: " headers nil t))))
5535 (while (not (equal "" (setq regexp (read-string
5536 (format "Match on %s (string): "
5538 (setq regexps (cons (list regexp nil nil 'r) regexps)))
5539 (setq scores (cons (cons header regexps) scores)))
5541 (gnus-group-make-group group "nnkiboze" address)
5543 (gnus-set-work-buffer)
5544 (let (emacs-lisp-mode-hook)
5545 (pp scores (current-buffer)))
5546 (write-region (point-min) (point-max)
5547 (gnus-score-file-name (concat "nnkiboze:" group))))
5549 (gnus-group-position-point))
5551 (defun gnus-group-add-to-virtual (n vgroup)
5552 "Add the current group to a virtual group."
5554 (list current-prefix-arg
5555 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
5557 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
5558 (error "%s is not an nnvirtual group" vgroup))
5559 (let* ((groups (gnus-group-process-prefix n))
5560 (method (gnus-info-method (gnus-get-info vgroup))))
5561 (setcar (cdr method)
5563 (nth 1 method) "\\|"
5566 (gnus-group-remove-mark s)
5567 (concat "\\(^" (regexp-quote s) "$\\)"))
5569 (gnus-group-position-point))
5571 (defun gnus-group-make-empty-virtual (group)
5572 "Create a new, fresh, empty virtual group."
5573 (interactive "sCreate new, empty virtual group: ")
5574 (let* ((method (list 'nnvirtual "^$"))
5575 (pgroup (gnus-group-prefixed-name group method)))
5576 ;; Check whether it exists already.
5577 (and (gnus-gethash pgroup gnus-newsrc-hashtb)
5578 (error "Group %s already exists." pgroup))
5579 ;; Subscribe the new group after the group on the current line.
5580 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
5581 (gnus-group-update-group pgroup)
5583 (gnus-group-position-point)))
5585 (defun gnus-group-enter-directory (dir)
5586 "Enter an ephemeral nneething group."
5587 (interactive "DDirectory to read: ")
5588 (let* ((method (list 'nneething dir))
5589 (leaf (gnus-group-prefixed-name
5590 (file-name-nondirectory (directory-file-name dir))
5592 (name (gnus-generate-new-group-name leaf)))
5593 (let ((nneething-read-only t))
5594 (or (gnus-group-read-ephemeral-group
5596 (cons (current-buffer) (if (eq major-mode 'gnus-summary-mode)
5598 (error "Couldn't enter %s" dir)))))
5600 ;; Group sorting commands
5601 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
5603 (defun gnus-group-sort-groups (func &optional reverse)
5604 "Sort the group buffer according to FUNC.
5605 If REVERSE, reverse the sorting order."
5606 (interactive (list gnus-group-sort-function
5607 current-prefix-arg))
5609 ((not (listp func)) func)
5611 ((= 1 (length func)) (car func))
5613 ,(gnus-make-sort-function
5614 (reverse func)))))))
5615 ;; We peel off the dummy group from the alist.
5617 (when (equal (car (gnus-info-group gnus-newsrc-alist)) "dummy.group")
5618 (pop gnus-newsrc-alist))
5620 (setq gnus-newsrc-alist
5621 (sort gnus-newsrc-alist func))
5623 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
5624 ;; Regenerate the hash table.
5625 (gnus-make-hashtable-from-newsrc-alist)
5626 (gnus-group-list-groups))))
5628 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
5629 "Sort the group buffer alphabetically by group name.
5630 If REVERSE, sort in reverse order."
5632 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
5634 (defun gnus-group-sort-groups-by-unread (&optional reverse)
5635 "Sort the group buffer by number of unread articles.
5636 If REVERSE, sort in reverse order."
5638 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
5640 (defun gnus-group-sort-groups-by-level (&optional reverse)
5641 "Sort the group buffer by group level.
5642 If REVERSE, sort in reverse order."
5644 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
5646 (defun gnus-group-sort-groups-by-score (&optional reverse)
5647 "Sort the group buffer by group score.
5648 If REVERSE, sort in reverse order."
5650 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
5652 (defun gnus-group-sort-groups-by-rank (&optional reverse)
5653 "Sort the group buffer by group rank.
5654 If REVERSE, sort in reverse order."
5656 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
5658 (defun gnus-group-sort-groups-by-method (&optional reverse)
5659 "Sort the group buffer alphabetically by backend name.
5660 If REVERSE, sort in reverse order."
5662 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
5664 (defun gnus-group-sort-by-alphabet (info1 info2)
5665 "Sort alphabetically."
5666 (string< (gnus-info-group info1) (gnus-info-group info2)))
5668 (defun gnus-group-sort-by-unread (info1 info2)
5669 "Sort by number of unread articles."
5670 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
5671 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
5672 (< (or (and (numberp n1) n1) 0)
5673 (or (and (numberp n2) n2) 0))))
5675 (defun gnus-group-sort-by-level (info1 info2)
5677 (< (gnus-info-level info1) (gnus-info-level info2)))
5679 (defun gnus-group-sort-by-method (info1 info2)
5680 "Sort alphabetically by backend name."
5681 (string< (symbol-name (car (gnus-find-method-for-group
5682 (gnus-info-group info1) info1)))
5683 (symbol-name (car (gnus-find-method-for-group
5684 (gnus-info-group info2) info2)))))
5686 (defun gnus-group-sort-by-score (info1 info2)
5687 "Sort by group score."
5688 (< (gnus-info-score info1) (gnus-info-score info2)))
5690 (defun gnus-group-sort-by-rank (info1 info2)
5691 "Sort by level and score."
5692 (let ((level1 (gnus-info-level info1))
5693 (level2 (gnus-info-level info2)))
5694 (or (< level1 level2)
5695 (and (= level1 level2)
5696 (< (gnus-info-score info1) (gnus-info-score info2))))))
5698 ;; Group catching up.
5700 (defun gnus-group-catchup-current (&optional n all)
5701 "Mark all articles not marked as unread in current newsgroup as read.
5702 If prefix argument N is numeric, the ARG next newsgroups will be
5703 caught up. If ALL is non-nil, marked articles will also be marked as
5704 read. Cross references (Xref: header) of articles are ignored.
5705 The difference between N and actual number of newsgroups that were
5706 caught up is returned."
5708 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
5712 "Do you really want to mark all articles as read? "
5713 "Mark all unread articles as read? "))))
5715 (let ((groups (gnus-group-process-prefix n))
5718 ;; Virtual groups have to be given special treatment.
5719 (let ((method (gnus-find-method-for-group (car groups))))
5720 (if (eq 'nnvirtual (car method))
5721 (nnvirtual-catchup-group
5722 (gnus-group-real-name (car groups)) (nth 1 method) all)))
5723 (gnus-group-remove-mark (car groups))
5725 (gnus-group-goto-group (car groups))
5726 (gnus-group-catchup (car groups) all))
5727 (gnus-group-update-group-line)
5728 (setq ret (1+ ret)))
5729 (setq groups (cdr groups)))
5730 (gnus-group-next-unread-group 1)
5733 (defun gnus-group-catchup-current-all (&optional n)
5734 "Mark all articles in current newsgroup as read.
5735 Cross references (Xref: header) of articles are ignored."
5737 (gnus-group-catchup-current n 'all))
5739 (defun gnus-group-catchup (group &optional all)
5740 "Mark all articles in GROUP as read.
5741 If ALL is non-nil, all articles are marked as read.
5742 The return value is the number of articles that were marked as read,
5743 or nil if no action could be taken."
5744 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5746 ;; Do the updating only if the newsgroup isn't killed.
5747 (if (not (numberp (car entry)))
5748 (gnus-message 1 "Can't catch up; non-active group")
5749 ;; Do auto-expirable marks if that's required.
5750 (when (gnus-group-auto-expirable-p group)
5751 (gnus-add-marked-articles
5752 group 'expire (gnus-list-of-unread-articles group))
5754 (let ((marks (nth 3 (nth 2 entry))))
5755 (gnus-add-marked-articles
5756 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))
5757 (gnus-add-marked-articles
5758 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))))))
5760 (gnus-update-read-articles group nil)
5761 ;; Also nix out the lists of marks and dormants.
5763 (gnus-add-marked-articles group 'tick nil nil 'force)
5764 (gnus-add-marked-articles group 'dormant nil nil 'force))
5765 (run-hooks 'gnus-group-catchup-group-hook)
5768 (defun gnus-group-expire-articles (&optional n)
5769 "Expire all expirable articles in the current newsgroup."
5771 (let ((groups (gnus-group-process-prefix n))
5774 (error "No groups to expire"))
5775 (while (setq group (pop groups))
5776 (gnus-group-remove-mark group)
5777 (when (gnus-check-backend-function 'request-expire-articles group)
5778 (gnus-message 6 "Expiring articles in %s..." group)
5779 (let* ((info (gnus-get-info group))
5780 (expirable (if (gnus-group-total-expirable-p group)
5781 (cons nil (gnus-list-of-read-articles group))
5782 (assq 'expire (gnus-info-marks info))))
5783 (expiry-wait (gnus-group-get-parameter group 'expiry-wait)))
5786 (gnus-compress-sequence
5788 (let ((nnmail-expiry-wait-function nil)
5789 (nnmail-expiry-wait expiry-wait))
5790 (gnus-request-expire-articles
5791 (gnus-uncompress-sequence (cdr expirable)) group))
5792 (gnus-request-expire-articles
5793 (gnus-uncompress-sequence (cdr expirable))
5795 (gnus-message 6 "Expiring articles in %s...done" group)))
5796 (gnus-group-position-point))))
5799 (defun gnus-group-expire-all-groups ()
5800 "Expire all expirable articles in all newsgroups."
5803 (gnus-message 5 "Expiring...")
5804 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
5805 (cdr gnus-newsrc-alist))))
5806 (gnus-group-expire-articles nil)))
5807 (gnus-group-position-point)
5808 (gnus-message 5 "Expiring...done"))
5810 (defun gnus-group-set-current-level (n level)
5811 "Set the level of the next N groups to LEVEL."
5816 (let ((s (read-string
5817 (format "Level (default %s): " (gnus-group-group-level)))))
5818 (if (string-match "^\\s-*$" s)
5819 (int-to-string (gnus-group-group-level))
5821 (or (and (>= level 1) (<= level gnus-level-killed))
5822 (error "Illegal level: %d" level))
5823 (let ((groups (gnus-group-process-prefix n))
5826 (setq group (car groups)
5827 groups (cdr groups))
5828 (gnus-group-remove-mark group)
5829 (gnus-message 6 "Changed level of %s from %d to %d"
5830 group (or (gnus-group-group-level) gnus-level-killed)
5832 (gnus-group-change-level
5833 group level (or (gnus-group-group-level) gnus-level-killed))
5834 (gnus-group-update-group-line)))
5835 (gnus-group-position-point))
5837 (defun gnus-group-unsubscribe-current-group (&optional n)
5838 "Toggle subscription of the current group.
5839 If given numerical prefix, toggle the N next groups."
5841 (let ((groups (gnus-group-process-prefix n))
5844 (setq group (car groups)
5845 groups (cdr groups))
5846 (gnus-group-remove-mark group)
5847 (gnus-group-unsubscribe-group
5848 group (if (<= (gnus-group-group-level) gnus-level-subscribed)
5849 gnus-level-default-unsubscribed
5850 gnus-level-default-subscribed) t)
5851 (gnus-group-update-group-line))
5852 (gnus-group-next-group 1)))
5854 (defun gnus-group-unsubscribe-group (group &optional level silent)
5855 "Toggle subscription to GROUP.
5856 Killed newsgroups are subscribed. If SILENT, don't try to update the
5859 (list (completing-read
5860 "Group: " gnus-active-hashtb nil
5861 (memq gnus-select-method gnus-have-read-active-file))))
5862 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
5864 ((string-match "^[ \t]$" group)
5865 (error "Empty group name"))
5867 ;; Toggle subscription flag.
5868 (gnus-group-change-level
5869 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
5870 gnus-level-subscribed)
5871 (1+ gnus-level-subscribed)
5872 gnus-level-default-subscribed)))
5874 (gnus-group-update-group group)))
5875 ((and (stringp group)
5876 (or (not (memq gnus-select-method gnus-have-read-active-file))
5877 (gnus-active group)))
5878 ;; Add new newsgroup.
5879 (gnus-group-change-level
5881 (if level level gnus-level-default-subscribed)
5882 (or (and (member group gnus-zombie-list)
5885 (and (gnus-group-group-name)
5886 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
5888 (gnus-group-update-group group)))
5889 (t (error "No such newsgroup: %s" group)))
5890 (gnus-group-position-point)))
5892 (defun gnus-group-transpose-groups (n)
5893 "Move the current newsgroup up N places.
5894 If given a negative prefix, move down instead. The difference between
5895 N and the number of steps taken is returned."
5897 (or (gnus-group-group-name)
5898 (error "No group on current line"))
5899 (gnus-group-kill-group 1)
5901 (forward-line (- n))
5902 (gnus-group-yank-group)
5903 (gnus-group-position-point)))
5905 (defun gnus-group-kill-all-zombies ()
5906 "Kill all zombie newsgroups."
5908 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
5909 (setq gnus-zombie-list nil)
5910 (gnus-group-list-groups))
5912 (defun gnus-group-kill-region (begin end)
5913 "Kill newsgroups in current region (excluding current point).
5914 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
5929 (beginning-of-line) ;Important when LINES < 1
5930 (gnus-group-kill-group lines)))
5932 (defun gnus-group-kill-group (&optional n discard)
5933 "Kill the next N groups.
5934 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
5935 However, only groups that were alive can be yanked; already killed
5936 groups or zombie groups can't be yanked.
5937 The return value is the name of the group that was killed, or a list
5940 (let ((buffer-read-only nil)
5941 (groups (gnus-group-process-prefix n))
5942 group entry level out)
5943 (if (< (length groups) 10)
5944 ;; This is faster when there are few groups.
5946 (push (setq group (pop groups)) out)
5947 (gnus-group-remove-mark group)
5948 (setq level (gnus-group-group-level))
5950 (if (and (not discard)
5951 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
5952 (setq gnus-list-of-killed-groups
5953 (cons (cons (car entry) (nth 2 entry))
5954 gnus-list-of-killed-groups)))
5955 (gnus-group-change-level
5956 (if entry entry group) gnus-level-killed (if entry nil level)))
5957 ;; If there are lots and lots of groups to be killed, we use
5958 ;; this thing instead.
5960 (setq groups (nreverse groups))
5962 (gnus-group-remove-mark (car groups))
5964 (when (setq entry (gnus-gethash (pop groups) gnus-newsrc-hashtb))
5965 (push (cons (car entry) (nth 2 entry))
5966 gnus-list-of-killed-groups)
5967 (setcdr (cdr entry) (cdr (cdr (cdr entry))))))
5968 (gnus-make-hashtable-from-newsrc-alist)))
5970 (gnus-group-position-point)
5971 (if (< (length out) 2) (car out) (nreverse out))))
5973 (defun gnus-group-yank-group (&optional arg)
5974 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
5975 inserting it before the current newsgroup. The numeric ARG specifies
5976 how many newsgroups are to be yanked. The name of the newsgroup yanked
5977 is returned, or (if several groups are yanked) a list of yanked groups
5980 (setq arg (or arg 1))
5981 (let (info group prev out)
5982 (while (>= (decf arg) 0)
5983 (if (not (setq info (pop gnus-list-of-killed-groups)))
5984 (error "No more newsgroups to yank"))
5985 (push (setq group (nth 1 info)) out)
5986 ;; Find which newsgroup to insert this one before - search
5987 ;; backward until something suitable is found. If there are no
5988 ;; other newsgroups in this buffer, just make this newsgroup the
5990 (setq prev (gnus-group-group-name))
5991 (gnus-group-change-level
5992 info (nth 2 info) gnus-level-killed
5993 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
5995 (gnus-group-insert-group-line-info group))
5997 (gnus-group-position-point)
5998 (if (< (length out) 2) (car out) (nreverse out))))
6000 (defun gnus-group-kill-level (level)
6001 "Kill all groups that is on a certain LEVEL."
6002 (interactive "nKill all groups on level: ")
6004 ((= level gnus-level-zombie)
6005 (setq gnus-killed-list
6006 (nconc gnus-zombie-list gnus-killed-list))
6007 (setq gnus-zombie-list nil))
6008 ((and (< level gnus-level-zombie)
6010 (or gnus-expert-user
6013 "Do you really want to kill all groups on level %d? "
6015 (let* ((prev gnus-newsrc-alist)
6018 (if (= (gnus-info-level level) level)
6019 (setcdr prev (cdr alist))
6021 (setq alist (cdr alist)))
6022 (gnus-make-hashtable-from-newsrc-alist)
6023 (gnus-group-list-groups)))
6025 (error "Can't kill; illegal level: %d" level))))
6027 (defun gnus-group-list-all-groups (&optional arg)
6028 "List all newsgroups with level ARG or lower.
6029 Default is gnus-level-unsubscribed, which lists all subscribed and most
6030 unsubscribed groups."
6032 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
6034 ;; Redefine this to list ALL killed groups if prefix arg used.
6035 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
6036 (defun gnus-group-list-killed (&optional arg)
6037 "List all killed newsgroups in the group buffer.
6038 If ARG is non-nil, list ALL killed groups known to Gnus. This may
6039 entail asking the server for the groups."
6041 ;; Find all possible killed newsgroups if arg.
6043 ;; First make sure active file has been read.
6044 (unless gnus-have-read-active-file
6045 (let ((gnus-read-active-file t))
6046 (gnus-read-active-file)))
6047 (or gnus-killed-hashtb (gnus-make-hashtable-from-killed))
6048 ;; Go through all newsgroups that are known to Gnus - enlarge kill list
6052 (group (symbol-name sym)))
6053 (if (or (null group)
6054 (gnus-gethash group gnus-killed-hashtb)
6055 (gnus-gethash group gnus-newsrc-hashtb))
6057 (let ((do-sub (gnus-matches-options-n group)))
6058 (if (or (eq do-sub 'subscribe) (eq do-sub 'ignore))
6060 (setq groups (1+ groups))
6061 (setq gnus-killed-list
6062 (cons group gnus-killed-list))
6063 (gnus-sethash group group gnus-killed-hashtb))))))
6064 gnus-active-hashtb))
6065 (if (not gnus-killed-list)
6066 (gnus-message 6 "No killed groups")
6067 (let (gnus-group-list-mode)
6068 (funcall gnus-group-prepare-function
6069 gnus-level-killed t gnus-level-killed))
6070 (goto-char (point-min)))
6071 (gnus-group-position-point))
6073 (defun gnus-group-list-zombies ()
6074 "List all zombie newsgroups in the group buffer."
6076 (if (not gnus-zombie-list)
6077 (gnus-message 6 "No zombie groups")
6078 (let (gnus-group-list-mode)
6079 (funcall gnus-group-prepare-function
6080 gnus-level-zombie t gnus-level-zombie))
6081 (goto-char (point-min)))
6082 (gnus-group-position-point))
6084 (defun gnus-group-list-active ()
6085 "List all groups that are available from the server(s)."
6087 ;; First we make sure that we have really read the active file.
6088 (unless gnus-have-read-active-file
6089 (let ((gnus-read-active-file t))
6090 (gnus-read-active-file)))
6091 ;; Find all groups and sort them.
6097 (and (symbol-value sym)
6098 (setq list (cons (symbol-name sym) list))))
6102 (buffer-read-only nil))
6105 (gnus-group-insert-group-line-info (car groups))
6106 (setq groups (cdr groups)))
6107 (goto-char (point-min))))
6109 (defun gnus-activate-all-groups (level)
6110 "Activate absolutely all groups."
6111 (interactive (list 7))
6112 (let ((gnus-activate-level level)
6113 (gnus-activate-foreign-newsgroups level))
6114 (gnus-group-get-new-news)))
6116 (defun gnus-group-get-new-news (&optional arg)
6117 "Get newly arrived articles.
6118 If ARG is a number, it specifies which levels you are interested in
6119 re-scanning. If ARG is non-nil and not a number, this will force
6120 \"hard\" re-reading of the active files from all servers."
6122 (run-hooks 'gnus-get-new-news-hook)
6123 ;; We might read in new NoCeM messages here.
6124 (and gnus-use-nocem (gnus-nocem-scan-groups))
6125 ;; If ARG is not a number, then we read the active file.
6129 (let ((gnus-read-active-file t))
6130 (gnus-read-active-file))
6133 (setq arg (gnus-group-default-level arg t))
6134 (if (and gnus-read-active-file (not arg))
6136 (gnus-read-active-file)
6137 (gnus-get-unread-articles arg))
6138 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
6139 (gnus-get-unread-articles arg)))
6140 (gnus-group-list-groups))
6142 (defun gnus-group-get-new-news-this-group (&optional n)
6143 "Check for newly arrived news in the current group (and the N-1 next groups).
6144 The difference between N and the number of newsgroup checked is returned.
6145 If N is negative, this group and the N-1 previous groups will be checked."
6147 (let* ((groups (gnus-group-process-prefix n))
6148 (ret (if (numberp n) (- n (length groups)) 0))
6151 (setq group (car groups)
6152 groups (cdr groups))
6153 (gnus-group-remove-mark group)
6154 (unless (gnus-get-new-news-in-group group)
6156 (gnus-message 3 "%s error: %s" group (gnus-status-message group))))
6157 (when gnus-goto-next-group-when-activating
6158 (gnus-group-next-unread-group 1 t))
6159 (gnus-summary-position-point)
6162 (defun gnus-get-new-news-in-group (group)
6163 (when (and group (gnus-activate-group group 'scan))
6164 (gnus-get-unread-articles-in-group
6165 (gnus-get-info group) (gnus-active group) t)
6166 (when (gnus-group-goto-group group)
6167 (gnus-group-update-group-line))
6170 (defun gnus-group-fetch-faq (group &optional faq-dir)
6171 "Fetch the FAQ for the current group."
6174 (gnus-group-real-name (gnus-group-group-name))
6175 (cond (current-prefix-arg
6177 "Faq dir: " (and (listp gnus-group-faq-directory)
6178 gnus-group-faq-directory))))))
6180 (setq faq-dir (if (listp gnus-group-faq-directory)
6181 (car gnus-group-faq-directory)
6182 gnus-group-faq-directory)))
6183 (or group (error "No group name given"))
6184 (let ((file (concat (file-name-as-directory faq-dir)
6185 (gnus-group-real-name group))))
6186 (if (not (file-exists-p file))
6187 (error "No such file: %s" file)
6190 (defun gnus-group-describe-group (force &optional group)
6191 "Display a description of the current newsgroup."
6192 (interactive (list current-prefix-arg (gnus-group-group-name)))
6193 (and force (setq gnus-description-hashtb nil))
6194 (let ((method (gnus-find-method-for-group group))
6196 (or group (error "No group name given"))
6197 (and (or (and gnus-description-hashtb
6198 ;; We check whether this group's method has been
6199 ;; queried for a description file.
6201 (gnus-group-prefixed-name "" method)
6202 gnus-description-hashtb))
6203 (setq desc (gnus-group-get-description group))
6204 (gnus-read-descriptions-file method))
6206 (or desc (gnus-gethash group gnus-description-hashtb)
6207 "No description available")))))
6209 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6210 (defun gnus-group-describe-all-groups (&optional force)
6211 "Pop up a buffer with descriptions of all newsgroups."
6213 (and force (setq gnus-description-hashtb nil))
6214 (if (not (or gnus-description-hashtb
6215 (gnus-read-all-descriptions-files)))
6216 (error "Couldn't request descriptions file"))
6217 (let ((buffer-read-only nil)
6223 (insert (format " *: %-20s %s\n" (symbol-name group)
6224 (symbol-value group)))
6225 (add-text-properties
6226 b (1+ b) (list 'gnus-group group
6227 'gnus-unread t 'gnus-marked nil
6228 'gnus-level (1+ gnus-level-subscribed))))
6229 gnus-description-hashtb)
6230 (goto-char (point-min))
6231 (gnus-group-position-point)))
6233 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
6234 (defun gnus-group-apropos (regexp &optional search-description)
6235 "List all newsgroups that have names that match a regexp."
6236 (interactive "sGnus apropos (regexp): ")
6238 (obuf (current-buffer))
6240 ;; Go through all newsgroups that are known to Gnus.
6243 (and (symbol-name group)
6244 (string-match regexp (symbol-name group))
6245 (setq groups (cons (symbol-name group) groups))))
6247 ;; Go through all descriptions that are known to Gnus.
6248 (if search-description
6251 (and (string-match regexp (symbol-value group))
6252 (gnus-active (symbol-name group))
6253 (setq groups (cons (symbol-name group) groups))))
6254 gnus-description-hashtb))
6256 (gnus-message 3 "No groups matched \"%s\"." regexp)
6257 ;; Print out all the groups.
6259 (pop-to-buffer "*Gnus Help*")
6260 (buffer-disable-undo (current-buffer))
6262 (setq groups (sort groups 'string<))
6264 ;; Groups may be entered twice into the list of groups.
6265 (if (not (string= (car groups) prev))
6267 (insert (setq prev (car groups)) "\n")
6268 (if (and gnus-description-hashtb
6269 (setq des (gnus-gethash (car groups)
6270 gnus-description-hashtb)))
6271 (insert " " des "\n"))))
6272 (setq groups (cdr groups)))
6273 (goto-char (point-min))))
6274 (pop-to-buffer obuf)))
6276 (defun gnus-group-description-apropos (regexp)
6277 "List all newsgroups that have names or descriptions that match a regexp."
6278 (interactive "sGnus description apropos (regexp): ")
6279 (if (not (or gnus-description-hashtb
6280 (gnus-read-all-descriptions-files)))
6281 (error "Couldn't request descriptions file"))
6282 (gnus-group-apropos regexp t))
6284 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6285 (defun gnus-group-list-matching (level regexp &optional all lowest)
6286 "List all groups with unread articles that match REGEXP.
6287 If the prefix LEVEL is non-nil, it should be a number that says which
6288 level to cut off listing groups.
6289 If ALL, also list groups with no unread articles.
6290 If LOWEST, don't list groups with level lower than LOWEST."
6291 (interactive "P\nsList newsgroups matching: ")
6292 (gnus-group-prepare-flat (or level gnus-level-subscribed)
6293 all (or lowest 1) regexp)
6294 (goto-char (point-min))
6295 (gnus-group-position-point))
6297 (defun gnus-group-list-all-matching (level regexp &optional lowest)
6298 "List all groups that match REGEXP.
6299 If the prefix LEVEL is non-nil, it should be a number that says which
6300 level to cut off listing groups.
6301 If LOWEST, don't list groups with level lower than LOWEST."
6302 (interactive "P\nsList newsgroups matching: ")
6303 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
6305 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
6306 (defun gnus-group-save-newsrc (&optional force)
6307 "Save the Gnus startup files.
6308 If FORCE, force saving whether it is necessary or not."
6310 (gnus-save-newsrc-file force))
6312 (defun gnus-group-restart (&optional arg)
6313 "Force Gnus to read the .newsrc file."
6315 (gnus-save-newsrc-file)
6316 (gnus-setup-news 'force)
6317 (gnus-group-list-groups arg))
6319 (defun gnus-group-read-init-file ()
6320 "Read the Gnus elisp init file."
6322 (gnus-read-init-file))
6324 (defun gnus-group-check-bogus-groups (&optional silent)
6325 "Check bogus newsgroups.
6326 If given a prefix, don't ask for confirmation before removing a bogus
6329 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
6330 (gnus-group-list-groups))
6332 (defun gnus-group-edit-global-kill (&optional article group)
6333 "Edit the global kill file.
6334 If GROUP, edit that local kill file instead."
6336 (setq gnus-current-kill-article article)
6337 (gnus-kill-file-edit-file group)
6340 (substitute-command-keys
6341 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
6342 (if group "local" "global")))))
6344 (defun gnus-group-edit-local-kill (article group)
6345 "Edit a local kill file."
6346 (interactive (list nil (gnus-group-group-name)))
6347 (gnus-group-edit-global-kill article group))
6349 (defun gnus-group-force-update ()
6350 "Update `.newsrc' file."
6352 (gnus-save-newsrc-file))
6354 (defun gnus-group-suspend ()
6355 "Suspend the current Gnus session.
6356 In fact, cleanup buffers except for group mode buffer.
6357 The hook gnus-suspend-gnus-hook is called before actually suspending."
6359 (run-hooks 'gnus-suspend-gnus-hook)
6360 ;; Kill Gnus buffers except for group mode buffer.
6361 (let ((group-buf (get-buffer gnus-group-buffer)))
6362 ;; Do this on a separate list in case the user does a ^G before we finish
6363 (let ((gnus-buffer-list
6364 (delq group-buf (delq gnus-dribble-buffer
6365 (append gnus-buffer-list nil)))))
6366 (while gnus-buffer-list
6367 (gnus-kill-buffer (car gnus-buffer-list))
6368 (setq gnus-buffer-list (cdr gnus-buffer-list))))
6371 (setq gnus-buffer-list (list group-buf))
6372 (bury-buffer group-buf)
6373 (delete-windows-on group-buf t)))))
6375 (defun gnus-group-clear-dribble ()
6376 "Clear all information from the dribble buffer."
6378 (gnus-dribble-clear)
6379 (gnus-message 7 "Cleared dribble buffer"))
6381 (defun gnus-group-exit ()
6382 "Quit reading news after updating .newsrc.eld and .newsrc.
6383 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6385 (if (or noninteractive ;For gnus-batch-kill
6386 (not (gnus-server-opened gnus-select-method)) ;NNTP connection closed
6387 (not gnus-interactive-exit) ;Without confirmation
6389 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
6391 (run-hooks 'gnus-exit-gnus-hook)
6392 ;; Offer to save data from non-quitted summary buffers.
6393 (gnus-offer-save-summaries)
6394 ;; Save the newsrc file(s).
6395 (gnus-save-newsrc-file)
6397 (gnus-close-backends)
6398 ;; Shut down the cache.
6399 (when gnus-use-cache
6401 ;; Reset everything.
6402 (gnus-clear-system))))
6404 (defun gnus-close-backends ()
6405 ;; Send a close request to all backends that support such a request.
6406 (let ((methods gnus-valid-select-methods)
6409 (if (fboundp (setq func (intern (concat (car (car methods))
6410 "-request-close"))))
6412 (setq methods (cdr methods)))))
6414 (defun gnus-group-quit ()
6415 "Quit reading news without updating .newsrc.eld or .newsrc.
6416 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6418 (when (or noninteractive ;For gnus-batch-kill
6419 (zerop (buffer-size))
6420 (not (gnus-server-opened gnus-select-method))
6422 (not gnus-current-startup-file)
6424 (format "Quit reading news without saving %s? "
6425 (file-name-nondirectory gnus-current-startup-file))))
6426 (run-hooks 'gnus-exit-gnus-hook)
6427 (if gnus-use-full-window
6428 (delete-other-windows)
6429 (gnus-remove-some-windows))
6431 (gnus-close-backends)
6432 ;; Shut down the cache.
6433 (when gnus-use-cache
6435 (gnus-clear-system)))
6437 (defun gnus-offer-save-summaries ()
6438 "Offer to save all active summary buffers."
6440 (let ((buflist (buffer-list))
6442 ;; Go through all buffers and find all summaries.
6444 (and (setq bufname (buffer-name (car buflist)))
6445 (string-match "Summary" bufname)
6447 (set-buffer bufname)
6448 ;; We check that this is, indeed, a summary buffer.
6449 (and (eq major-mode 'gnus-summary-mode)
6450 ;; Also make sure this isn't bogus.
6451 gnus-newsgroup-prepared))
6452 (push bufname buffers))
6453 (setq buflist (cdr buflist)))
6454 ;; Go through all these summary buffers and offer to save them.
6457 "Update summary buffer %s? "
6458 (lambda (buf) (set-buffer buf) (gnus-summary-exit))
6461 (defun gnus-group-describe-briefly ()
6462 "Give a one line description of the group mode commands."
6464 (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")))
6466 (defun gnus-group-browse-foreign-server (method)
6467 "Browse a foreign news server.
6468 If called interactively, this function will ask for a select method
6469 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
6470 If not, METHOD should be a list where the first element is the method
6471 and the second element is the address."
6473 (list (let ((how (completing-read
6475 (append gnus-valid-select-methods gnus-server-alist)
6476 nil t (cons "nntp" 0))))
6477 ;; We either got a backend name or a virtual server name.
6478 ;; If the first, we also need an address.
6479 (if (assoc how gnus-valid-select-methods)
6481 ;; Suggested by mapjph@bath.ac.uk.
6484 (mapcar (lambda (server) (list server))
6485 gnus-secondary-servers)))
6486 ;; We got a server name, so we find the method.
6487 (gnus-server-to-method how)))))
6488 (gnus-browse-foreign-server method))
6492 ;;; Gnus summary mode
6495 (defvar gnus-summary-mode-map nil)
6497 (put 'gnus-summary-mode 'mode-class 'special)
6499 (unless gnus-summary-mode-map
6500 (setq gnus-summary-mode-map (make-keymap))
6501 (suppress-keymap gnus-summary-mode-map)
6503 ;; Non-orthogonal keys
6506 gnus-summary-mode-map
6507 " " gnus-summary-next-page
6508 "\177" gnus-summary-prev-page
6509 "\r" gnus-summary-scroll-up
6510 "n" gnus-summary-next-unread-article
6511 "p" gnus-summary-prev-unread-article
6512 "N" gnus-summary-next-article
6513 "P" gnus-summary-prev-article
6514 "\M-\C-n" gnus-summary-next-same-subject
6515 "\M-\C-p" gnus-summary-prev-same-subject
6516 "\M-n" gnus-summary-next-unread-subject
6517 "\M-p" gnus-summary-prev-unread-subject
6518 "." gnus-summary-first-unread-article
6519 "," gnus-summary-best-unread-article
6520 "\M-s" gnus-summary-search-article-forward
6521 "\M-r" gnus-summary-search-article-backward
6522 "<" gnus-summary-beginning-of-article
6523 ">" gnus-summary-end-of-article
6524 "j" gnus-summary-goto-article
6525 "^" gnus-summary-refer-parent-article
6526 "\M-^" gnus-summary-refer-article
6527 "u" gnus-summary-tick-article-forward
6528 "!" gnus-summary-tick-article-forward
6529 "U" gnus-summary-tick-article-backward
6530 "d" gnus-summary-mark-as-read-forward
6531 "D" gnus-summary-mark-as-read-backward
6532 "E" gnus-summary-mark-as-expirable
6533 "\M-u" gnus-summary-clear-mark-forward
6534 "\M-U" gnus-summary-clear-mark-backward
6535 "k" gnus-summary-kill-same-subject-and-select
6536 "\C-k" gnus-summary-kill-same-subject
6537 "\M-\C-k" gnus-summary-kill-thread
6538 "\M-\C-l" gnus-summary-lower-thread
6539 "e" gnus-summary-edit-article
6540 "#" gnus-summary-mark-as-processable
6541 "\M-#" gnus-summary-unmark-as-processable
6542 "\M-\C-t" gnus-summary-toggle-threads
6543 "\M-\C-s" gnus-summary-show-thread
6544 "\M-\C-h" gnus-summary-hide-thread
6545 "\M-\C-f" gnus-summary-next-thread
6546 "\M-\C-b" gnus-summary-prev-thread
6547 "\M-\C-u" gnus-summary-up-thread
6548 "\M-\C-d" gnus-summary-down-thread
6549 "&" gnus-summary-execute-command
6550 "c" gnus-summary-catchup-and-exit
6551 "\C-w" gnus-summary-mark-region-as-read
6552 "\C-t" gnus-summary-toggle-truncation
6553 "?" gnus-summary-mark-as-dormant
6554 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
6555 "\C-c\C-s\C-n" gnus-summary-sort-by-number
6556 "\C-c\C-s\C-a" gnus-summary-sort-by-author
6557 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
6558 "\C-c\C-s\C-d" gnus-summary-sort-by-date
6559 "\C-c\C-s\C-i" gnus-summary-sort-by-score
6560 "=" gnus-summary-expand-window
6561 "\C-x\C-s" gnus-summary-reselect-current-group
6562 "\M-g" gnus-summary-rescan-group
6563 "w" gnus-summary-stop-page-breaking
6564 "\C-c\C-r" gnus-summary-caesar-message
6565 "\M-t" gnus-summary-toggle-mime
6566 "f" gnus-summary-followup
6567 "F" gnus-summary-followup-with-original
6568 "C" gnus-summary-cancel-article
6569 "r" gnus-summary-reply
6570 "R" gnus-summary-reply-with-original
6571 "\C-c\C-f" gnus-summary-mail-forward
6572 "o" gnus-summary-save-article
6573 "\C-o" gnus-summary-save-article-mail
6574 "|" gnus-summary-pipe-output
6575 "\M-k" gnus-summary-edit-local-kill
6576 "\M-K" gnus-summary-edit-global-kill
6578 "\C-c\C-d" gnus-summary-describe-group
6579 "q" gnus-summary-exit
6580 "Q" gnus-summary-exit-no-update
6581 "\C-c\C-i" gnus-info-find-node
6582 gnus-mouse-2 gnus-mouse-pick-article
6583 "m" gnus-summary-mail-other-window
6584 "a" gnus-summary-post-news
6585 "x" gnus-summary-limit-to-unread
6586 "s" gnus-summary-isearch-article
6587 "t" gnus-article-hide-headers
6588 "g" gnus-summary-show-article
6589 "l" gnus-summary-goto-last-article
6590 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
6591 "\C-d" gnus-summary-enter-digest-group
6593 "*" gnus-cache-enter-article
6594 "\M-*" gnus-cache-remove-article
6595 "\M-&" gnus-summary-universal-argument
6596 "\C-l" gnus-recenter
6597 "I" gnus-summary-increase-score
6598 "L" gnus-summary-lower-score
6600 "V" gnus-summary-score-map
6601 "X" gnus-uu-extract-map
6602 "S" gnus-summary-send-map)
6604 ;; Sort of orthogonal keymap
6606 (gnus-summary-mark-map "M" gnus-summary-mode-map)
6607 "t" gnus-summary-tick-article-forward
6608 "!" gnus-summary-tick-article-forward
6609 "d" gnus-summary-mark-as-read-forward
6610 "r" gnus-summary-mark-as-read-forward
6611 "c" gnus-summary-clear-mark-forward
6612 " " gnus-summary-clear-mark-forward
6613 "e" gnus-summary-mark-as-expirable
6614 "x" gnus-summary-mark-as-expirable
6615 "?" gnus-summary-mark-as-dormant
6616 "b" gnus-summary-set-bookmark
6617 "B" gnus-summary-remove-bookmark
6618 "#" gnus-summary-mark-as-processable
6619 "\M-#" gnus-summary-unmark-as-processable
6620 "S" gnus-summary-limit-include-expunged
6621 "C" gnus-summary-catchup
6622 "H" gnus-summary-catchup-to-here
6623 "\C-c" gnus-summary-catchup-all
6624 "k" gnus-summary-kill-same-subject-and-select
6625 "K" gnus-summary-kill-same-subject
6626 "P" gnus-uu-mark-map)
6629 (gnus-summary-mscore-map "V" gnus-summary-mode-map)
6630 "c" gnus-summary-clear-above
6631 "u" gnus-summary-tick-above
6632 "m" gnus-summary-mark-above
6633 "k" gnus-summary-kill-below)
6636 (gnus-summary-limit-map "/" gnus-summary-mode-map)
6637 "/" gnus-summary-limit-to-subject
6638 "n" gnus-summary-limit-to-articles
6639 "w" gnus-summary-pop-limit
6640 "s" gnus-summary-limit-to-subject
6641 "a" gnus-summary-limit-to-author
6642 "u" gnus-summary-limit-to-unread
6643 "m" gnus-summary-limit-to-marks
6644 "v" gnus-summary-limit-to-score
6645 "D" gnus-summary-limit-include-dormant
6646 "d" gnus-summary-limit-exclude-dormant
6647 ;; "t" gnus-summary-limit-exclude-thread
6648 "E" gnus-summary-limit-include-expunged
6649 "c" gnus-summary-limit-exclude-childless-dormant
6650 "C" gnus-summary-limit-mark-excluded-as-read)
6653 (gnus-summary-goto-map "G" gnus-summary-mode-map)
6654 "n" gnus-summary-next-unread-article
6655 "p" gnus-summary-prev-unread-article
6656 "N" gnus-summary-next-article
6657 "P" gnus-summary-prev-article
6658 "\C-n" gnus-summary-next-same-subject
6659 "\C-p" gnus-summary-prev-same-subject
6660 "\M-n" gnus-summary-next-unread-subject
6661 "\M-p" gnus-summary-prev-unread-subject
6662 "f" gnus-summary-first-unread-article
6663 "b" gnus-summary-best-unread-article
6664 "g" gnus-summary-goto-subject
6665 "l" gnus-summary-goto-last-article
6666 "p" gnus-summary-pop-article)
6669 (gnus-summary-thread-map "T" gnus-summary-mode-map)
6670 "k" gnus-summary-kill-thread
6671 "l" gnus-summary-lower-thread
6672 "i" gnus-summary-raise-thread
6673 "T" gnus-summary-toggle-threads
6674 "t" gnus-summary-rethread-current
6675 "^" gnus-summary-reparent-thread
6676 "s" gnus-summary-show-thread
6677 "S" gnus-summary-show-all-threads
6678 "h" gnus-summary-hide-thread
6679 "H" gnus-summary-hide-all-threads
6680 "n" gnus-summary-next-thread
6681 "p" gnus-summary-prev-thread
6682 "u" gnus-summary-up-thread
6683 "o" gnus-summary-top-thread
6684 "d" gnus-summary-down-thread
6685 "#" gnus-uu-mark-thread
6686 "\M-#" gnus-uu-unmark-thread)
6689 (gnus-summary-exit-map "Z" gnus-summary-mode-map)
6690 "c" gnus-summary-catchup-and-exit
6691 "C" gnus-summary-catchup-all-and-exit
6692 "E" gnus-summary-exit-no-update
6693 "Q" gnus-summary-exit
6694 "Z" gnus-summary-exit
6695 "n" gnus-summary-catchup-and-goto-next-group
6696 "R" gnus-summary-reselect-current-group
6697 "G" gnus-summary-rescan-group
6698 "N" gnus-summary-next-group
6699 "P" gnus-summary-prev-group)
6702 (gnus-summary-article-map "A" gnus-summary-mode-map)
6703 " " gnus-summary-next-page
6704 "n" gnus-summary-next-page
6705 "\177" gnus-summary-prev-page
6706 "p" gnus-summary-prev-page
6707 "\r" gnus-summary-scroll-up
6708 "<" gnus-summary-beginning-of-article
6709 ">" gnus-summary-end-of-article
6710 "b" gnus-summary-beginning-of-article
6711 "e" gnus-summary-end-of-article
6712 "^" gnus-summary-refer-parent-article
6713 "r" gnus-summary-refer-parent-article
6714 "R" gnus-summary-refer-references
6715 "g" gnus-summary-show-article
6716 "s" gnus-summary-isearch-article)
6719 (gnus-summary-wash-map "W" gnus-summary-mode-map)
6720 "b" gnus-article-add-buttons
6721 "B" gnus-article-add-buttons-to-head
6722 "o" gnus-article-treat-overstrike
6723 ;; "w" gnus-article-word-wrap
6724 "w" gnus-article-fill-cited-article
6725 "c" gnus-article-remove-cr
6726 "L" gnus-article-remove-trailing-blank-lines
6727 "q" gnus-article-de-quoted-unreadable
6728 "f" gnus-article-display-x-face
6729 "l" gnus-summary-stop-page-breaking
6730 "r" gnus-summary-caesar-message
6731 "t" gnus-article-hide-headers
6732 "v" gnus-summary-verbose-headers
6733 "m" gnus-summary-toggle-mime)
6736 (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
6737 "a" gnus-article-hide
6738 "h" gnus-article-hide-headers
6739 "b" gnus-article-hide-boring-headers
6740 "s" gnus-article-hide-signature
6741 "c" gnus-article-hide-citation
6742 "p" gnus-article-hide-pgp
6743 "\C-c" gnus-article-hide-citation-maybe)
6746 (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
6747 "a" gnus-article-highlight
6748 "h" gnus-article-highlight-headers
6749 "c" gnus-article-highlight-citation
6750 "s" gnus-article-highlight-signature)
6753 (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
6754 "z" gnus-article-date-ut
6755 "u" gnus-article-date-ut
6756 "l" gnus-article-date-local
6757 "e" gnus-article-date-lapsed
6758 "o" gnus-article-date-original)
6761 (gnus-summary-help-map "H" gnus-summary-mode-map)
6763 "f" gnus-summary-fetch-faq
6764 "d" gnus-summary-describe-group
6765 "h" gnus-summary-describe-briefly
6766 "i" gnus-info-find-node)
6769 (gnus-summary-backend-map "B" gnus-summary-mode-map)
6770 "e" gnus-summary-expire-articles
6771 "\M-\C-e" gnus-summary-expire-articles-now
6772 "\177" gnus-summary-delete-article
6773 "m" gnus-summary-move-article
6774 "r" gnus-summary-respool-article
6775 "w" gnus-summary-edit-article
6776 "c" gnus-summary-copy-article
6777 "B" gnus-summary-crosspost-article
6778 "q" gnus-summary-respool-query
6779 "i" gnus-summary-import-article)
6782 (gnus-summary-save-map "O" gnus-summary-mode-map)
6783 "o" gnus-summary-save-article
6784 "m" gnus-summary-save-article-mail
6785 "r" gnus-summary-save-article-rmail
6786 "f" gnus-summary-save-article-file
6787 "b" gnus-summary-save-article-body-file
6788 "h" gnus-summary-save-article-folder
6789 "v" gnus-summary-save-article-vm
6790 "p" gnus-summary-pipe-output
6791 "s" gnus-soup-add-article)
6797 (defun gnus-summary-mode (&optional group)
6798 "Major mode for reading articles.
6800 All normal editing commands are switched off.
6801 \\<gnus-summary-mode-map>
6802 Each line in this buffer represents one article. To read an
6803 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
6804 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
6807 You can also post articles and send mail from this buffer. To
6808 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
6809 of an article, type `\\[gnus-summary-reply]'.
6811 There are approx. one gazillion commands you can execute in this
6812 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
6814 The following commands are available:
6816 \\{gnus-summary-mode-map}"
6818 (when (and menu-bar-mode
6819 (gnus-visual-p 'summary-menu 'menu))
6820 (gnus-summary-make-menu-bar))
6821 (kill-all-local-variables)
6822 (let ((locals gnus-summary-local-variables))
6824 (if (consp (car locals))
6826 (make-local-variable (car (car locals)))
6827 (set (car (car locals)) (eval (cdr (car locals)))))
6828 (make-local-variable (car locals))
6829 (set (car locals) nil))
6830 (setq locals (cdr locals))))
6831 (gnus-make-thread-indent-array)
6832 (gnus-simplify-mode-line)
6833 (setq major-mode 'gnus-summary-mode)
6834 (setq mode-name "Summary")
6835 (make-local-variable 'minor-mode-alist)
6836 (use-local-map gnus-summary-mode-map)
6837 (buffer-disable-undo (current-buffer))
6838 (setq buffer-read-only t) ;Disable modification
6839 (setq truncate-lines t)
6840 (setq selective-display t)
6841 (setq selective-display-ellipses t) ;Display `...'
6842 (setq buffer-display-table gnus-summary-display-table)
6843 (setq gnus-newsgroup-name group)
6844 (run-hooks 'gnus-summary-mode-hook))
6846 (defun gnus-summary-make-display-table ()
6847 ;; Change the display table. Odd characters have a tendency to mess
6848 ;; up nicely formatted displays - we make all possible glyphs
6849 ;; display only a single character.
6851 ;; We start from the standard display table, if any.
6852 (setq gnus-summary-display-table
6853 (or (copy-sequence standard-display-table)
6854 (make-display-table)))
6855 ;; Nix out all the control chars...
6857 (while (>= (setq i (1- i)) 0)
6858 (aset gnus-summary-display-table i [??])))
6859 ;; ... but not newline and cr, of course. (cr is necessary for the
6860 ;; selective display).
6861 (aset gnus-summary-display-table ?\n nil)
6862 (aset gnus-summary-display-table ?\r nil)
6863 ;; We nix out any glyphs over 126 that are not set already.
6865 (while (>= (setq i (1- i)) 127)
6866 ;; Only modify if the entry is nil.
6867 (or (aref gnus-summary-display-table i)
6868 (aset gnus-summary-display-table i [??])))))
6870 (defun gnus-summary-clear-local-variables ()
6871 (let ((locals gnus-summary-local-variables))
6873 (if (consp (car locals))
6874 (and (vectorp (car (car locals)))
6875 (set (car (car locals)) nil))
6876 (and (vectorp (car locals))
6877 (set (car locals) nil)))
6878 (setq locals (cdr locals)))))
6880 ;; Summary data functions.
6882 (defmacro gnus-data-number (data)
6885 (defmacro gnus-data-set-number (data number)
6886 `(setcar ,data ,number))
6888 (defmacro gnus-data-mark (data)
6891 (defmacro gnus-data-set-mark (data mark)
6892 `(setcar (nthcdr 1 ,data) ,mark))
6894 (defmacro gnus-data-pos (data)
6897 (defmacro gnus-data-set-pos (data pos)
6898 `(setcar (nthcdr 2 ,data) ,pos))
6900 (defmacro gnus-data-header (data)
6903 (defmacro gnus-data-level (data)
6906 (defmacro gnus-data-unread-p (data)
6907 `(= (nth 1 ,data) gnus-unread-mark))
6909 (defmacro gnus-data-pseudo-p (data)
6910 `(consp (nth 3 ,data)))
6912 (defmacro gnus-data-find (number)
6913 `(assq ,number gnus-newsgroup-data))
6915 (defmacro gnus-data-find-list (number &optional data)
6916 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
6917 (memq (assq ,number bdata)
6920 (defmacro gnus-data-make (number mark pos header level)
6921 `(list ,number ,mark ,pos ,header ,level))
6923 (defun gnus-data-enter (after-article number mark pos header level offset)
6924 (let ((data (gnus-data-find-list after-article)))
6925 (or data (error "No such article: %d" after-article))
6926 (setcdr data (cons (gnus-data-make number mark pos header level)
6928 (setq gnus-newsgroup-data-reverse nil)
6929 (gnus-data-update-list (cdr (cdr data)) offset)))
6931 (defun gnus-data-enter-list (after-article list &optional offset)
6933 (let ((data (and after-article (gnus-data-find-list after-article)))
6935 (or data (not after-article) (error "No such article: %d" after-article))
6936 ;; Find the last element in the list to be spliced into the main
6939 (setq list (cdr list)))
6942 (setcdr list gnus-newsgroup-data)
6943 (setq gnus-newsgroup-data ilist)
6944 (and offset (gnus-data-update-list (cdr list) offset)))
6945 (setcdr list (cdr data))
6947 (and offset (gnus-data-update-list (cdr data) offset)))
6948 (setq gnus-newsgroup-data-reverse nil))))
6950 (defun gnus-data-remove (article &optional offset)
6951 (let ((data gnus-newsgroup-data))
6952 (if (= (gnus-data-number (car data)) article)
6953 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
6954 gnus-newsgroup-data-reverse nil)
6956 (and (= (gnus-data-number (car (cdr data))) article)
6958 (setcdr data (cdr (cdr data)))
6959 (and offset (gnus-data-update-list (cdr data) offset))
6961 gnus-newsgroup-data-reverse nil)))
6962 (setq data (cdr data))))))
6964 (defmacro gnus-data-list (backward)
6966 (or gnus-newsgroup-data-reverse
6967 (setq gnus-newsgroup-data-reverse
6968 (reverse gnus-newsgroup-data)))
6969 gnus-newsgroup-data))
6971 (defun gnus-data-update-list (data offset)
6972 "Add OFFSET to the POS of all data entries in DATA."
6974 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
6975 (setq data (cdr data))))
6977 (defun gnus-data-compute-positions ()
6978 "Compute the positions of all articles."
6979 (let ((data gnus-newsgroup-data)
6982 (when (setq pos (text-property-any
6983 (point-min) (point-max)
6984 'gnus-number (gnus-data-number (car data))))
6985 (gnus-data-set-pos (car data) (+ pos 3)))
6986 (setq data (cdr data)))))
6988 (defun gnus-summary-article-pseudo-p (article)
6989 "Say whether this article is a pseudo article or not."
6990 (not (vectorp (gnus-data-header (gnus-data-find article)))))
6992 (defun gnus-article-parent-p (number)
6993 "Say whether this article is a parent or not."
6994 (let* ((data (gnus-data-find-list number)))
6995 (and (cdr data) ; There has to be an article after...
6996 (< (gnus-data-level (car data)) ; And it has to have a higher level.
6997 (gnus-data-level (nth 1 data))))))
6999 (defmacro gnus-summary-skip-intangible ()
7000 "If the current article is intangible, then jump to a different article."
7001 '(let ((to (get-text-property (point) 'gnus-intangible)))
7003 (gnus-summary-goto-subject to))))
7005 (defmacro gnus-summary-article-intangible-p ()
7006 "Say whether this article is intangible or not."
7007 '(get-text-property (point) 'gnus-intangible))
7009 ;; Some summary mode macros.
7011 (defmacro gnus-summary-article-number ()
7012 "The article number of the article on the current line.
7013 If there isn's an article number here, then we return the current
7016 (gnus-summary-skip-intangible)
7017 (or (get-text-property (point) 'gnus-number)
7018 (gnus-summary-last-subject))))
7020 (defmacro gnus-summary-article-header (&optional number)
7021 `(gnus-data-header (gnus-data-find
7022 ,(or number '(gnus-summary-article-number)))))
7024 (defmacro gnus-summary-thread-level (&optional number)
7025 `(if (and (eq gnus-summary-make-false-root 'dummy)
7026 (get-text-property (point) 'gnus-intangible))
7028 (gnus-data-level (gnus-data-find
7029 ,(or number '(gnus-summary-article-number))))))
7031 (defmacro gnus-summary-article-mark (&optional number)
7032 `(gnus-data-mark (gnus-data-find
7033 ,(or number '(gnus-summary-article-number)))))
7035 (defmacro gnus-summary-article-pos (&optional number)
7036 `(gnus-data-pos (gnus-data-find
7037 ,(or number '(gnus-summary-article-number)))))
7039 (defmacro gnus-summary-article-subject (&optional number)
7040 "Return current subject string or nil if nothing."
7043 `(gnus-data-header (assq ,number gnus-newsgroup-data))
7044 '(gnus-data-header (assq (gnus-summary-article-number)
7045 gnus-newsgroup-data)))))
7048 (mail-header-subject headers))))
7050 (defmacro gnus-summary-article-score (&optional number)
7051 "Return current article score."
7052 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
7053 gnus-newsgroup-scored))
7054 gnus-summary-default-score 0))
7056 (defun gnus-summary-article-children (&optional number)
7057 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
7058 (level (gnus-data-level (car data)))
7060 (while (and (setq data (cdr data))
7061 (> (setq l (gnus-data-level (car data))) level))
7062 (and (= (1+ level) l)
7063 (setq children (cons (gnus-data-number (car data))
7065 (nreverse children)))
7067 (defun gnus-summary-article-parent (&optional number)
7068 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
7069 (gnus-data-list t)))
7070 (level (gnus-data-level (car data)))
7073 () ; This is a root.
7074 ;; We search until we find an article with a level less than
7075 ;; this one. That function has to be the parent.
7076 (while (and (setq data (cdr data))
7077 (not (< (gnus-data-level (car data)) level))))
7078 (and data (gnus-data-number (car data))))))
7081 ;; Various summary mode internalish functions.
7083 (defun gnus-mouse-pick-article (e)
7086 (gnus-summary-next-page nil t))
7088 (defun gnus-summary-setup-buffer (group)
7089 "Initialize summary buffer."
7090 (let ((buffer (concat "*Summary " group "*")))
7091 (if (get-buffer buffer)
7094 (setq gnus-summary-buffer (current-buffer))
7095 (not gnus-newsgroup-prepared))
7096 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
7097 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
7098 (gnus-add-current-to-buffer-list)
7099 (gnus-summary-mode group)
7101 (gnus-carpal-setup-buffer 'summary))
7102 (unless gnus-single-article-buffer
7103 (make-local-variable 'gnus-article-buffer)
7104 (make-local-variable 'gnus-original-article-buffer))
7105 (setq gnus-newsgroup-name group)
7108 (defun gnus-set-global-variables ()
7109 ;; Set the global equivalents of the summary buffer-local variables
7110 ;; to the latest values they had. These reflect the summary buffer
7111 ;; that was in action when the last article was fetched.
7112 (when (eq major-mode 'gnus-summary-mode)
7113 (setq gnus-summary-buffer (current-buffer))
7114 (let ((name gnus-newsgroup-name)
7115 (marked gnus-newsgroup-marked)
7116 (unread gnus-newsgroup-unreads)
7117 (headers gnus-current-headers)
7118 (data gnus-newsgroup-data)
7119 (article-buffer gnus-article-buffer)
7120 (score-file gnus-current-score-file))
7122 (set-buffer gnus-group-buffer)
7123 (setq gnus-newsgroup-name name)
7124 (setq gnus-newsgroup-marked marked)
7125 (setq gnus-newsgroup-unreads unread)
7126 (setq gnus-current-headers headers)
7127 (setq gnus-newsgroup-data data)
7128 (setq gnus-article-buffer article-buffer)
7129 (setq gnus-current-score-file score-file)))))
7131 (defun gnus-summary-last-article-p (&optional article)
7132 "Return whether ARTICLE is the last article in the buffer."
7133 (if (not (setq article (or article (gnus-summary-article-number))))
7134 t ; All non-existant numbers are the last article. :-)
7135 (cdr (gnus-data-find-list article))))
7137 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
7138 "Insert a dummy root in the summary buffer."
7140 (add-text-properties
7141 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
7142 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
7144 (defvar gnus-thread-indent-array nil)
7145 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
7146 (defun gnus-make-thread-indent-array ()
7148 (if (and gnus-thread-indent-array
7149 (= gnus-thread-indent-level gnus-thread-indent-array-level))
7151 (setq gnus-thread-indent-array (make-vector 201 "")
7152 gnus-thread-indent-array-level gnus-thread-indent-level)
7154 (aset gnus-thread-indent-array n
7155 (make-string (* n gnus-thread-indent-level) ? ))
7158 (defun gnus-summary-insert-line
7159 (gnus-tmp-header gnus-tmp-level gnus-tmp-current gnus-tmp-unread
7160 gnus-tmp-replied gnus-tmp-expirable gnus-tmp-subject-or-nil
7161 &optional gnus-tmp-dummy gnus-tmp-score gnus-tmp-process)
7162 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
7163 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
7164 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
7165 (gnus-tmp-score-char
7166 (if (or (null gnus-summary-default-score)
7167 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
7168 gnus-summary-zcore-fuzz)) ?
7169 (if (< gnus-tmp-score gnus-summary-default-score)
7170 gnus-score-below-mark gnus-score-over-mark)))
7171 (gnus-tmp-replied (cond (gnus-tmp-process gnus-process-mark)
7172 ((memq gnus-tmp-current gnus-newsgroup-cached)
7174 (gnus-tmp-replied gnus-replied-mark)
7175 ((memq gnus-tmp-current gnus-newsgroup-saved)
7177 (t gnus-unread-mark)))
7178 (gnus-tmp-from (mail-header-from gnus-tmp-header))
7181 ((string-match "(.+)" gnus-tmp-from)
7182 (substring gnus-tmp-from
7183 (1+ (match-beginning 0)) (1- (match-end 0))))
7184 ((string-match "<[^>]+> *$" gnus-tmp-from)
7185 (let ((beg (match-beginning 0)))
7186 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
7187 (substring gnus-tmp-from (1+ (match-beginning 0))
7188 (1- (match-end 0))))
7189 (substring gnus-tmp-from 0 beg))))
7191 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
7192 (gnus-tmp-number (mail-header-number gnus-tmp-header))
7193 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
7194 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
7195 (buffer-read-only nil))
7196 (when (string= gnus-tmp-name "")
7197 (setq gnus-tmp-name gnus-tmp-from))
7198 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
7201 (progn (eval gnus-summary-line-format-spec) (point))
7202 'gnus-number gnus-tmp-number)
7203 (when (gnus-visual-p 'summary-highlight 'highlight)
7205 (run-hooks 'gnus-summary-update-hook)
7208 (defun gnus-summary-update-line (&optional dont-update)
7209 ;; Update summary line after change.
7210 (when (and gnus-summary-default-score
7211 (not gnus-summary-inhibit-highlight))
7212 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
7213 (article (gnus-summary-article-number))
7214 (score (gnus-summary-article-score article)))
7216 (if (and gnus-summary-mark-below
7217 (< (gnus-summary-article-score)
7218 gnus-summary-mark-below))
7219 ;; This article has a low score, so we mark it as read.
7220 (when (memq article gnus-newsgroup-unreads)
7221 (gnus-summary-mark-article-as-read gnus-low-score-mark))
7222 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
7223 ;; This article was previously marked as read on account
7224 ;; of a low score, but now it has risen, so we mark it as
7226 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
7227 (gnus-summary-update-mark
7228 (if (or (null gnus-summary-default-score)
7229 (<= (abs (- score gnus-summary-default-score))
7230 gnus-summary-zcore-fuzz)) ?
7231 (if (< score gnus-summary-default-score)
7232 gnus-score-below-mark gnus-score-over-mark)) 'score))
7233 ;; Do visual highlighting.
7234 (when (gnus-visual-p 'summary-highlight 'highlight)
7235 (run-hooks 'gnus-summary-update-hook)))))
7237 (defvar gnus-tmp-new-adopts nil)
7239 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
7240 ;; Sum up all elements (and sub-elements) in a list.
7242 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
7244 ((and (consp thread) (cdr thread))
7247 'gnus-summary-number-of-articles-in-thread (cdr thread))))
7250 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
7253 (when (and level (zerop level) gnus-tmp-new-adopts)
7256 'gnus-summary-number-of-articles-in-thread
7257 gnus-tmp-new-adopts))))
7259 (if (> number 1) gnus-not-empty-thread-mark
7260 gnus-empty-thread-mark)
7263 (defun gnus-summary-set-local-parameters (group)
7264 "Go through the local params of GROUP and set all variable specs in that list."
7265 (let ((params (gnus-info-params (gnus-get-info group)))
7268 (setq elem (car params)
7269 params (cdr params))
7270 (and (consp elem) ; Has to be a cons.
7271 (consp (cdr elem)) ; The cdr has to be a list.
7272 (symbolp (car elem)) ; Has to be a symbol in there.
7273 (progn ; So we set it.
7274 (make-local-variable (car elem))
7275 (set (car elem) (eval (nth 1 elem))))))))
7277 (defun gnus-summary-read-group
7278 (group &optional show-all no-article kill-buffer no-display)
7279 "Start reading news in newsgroup GROUP.
7280 If SHOW-ALL is non-nil, already read articles are also listed.
7281 If NO-ARTICLE is non-nil, no article is selected initially.
7282 If NO-DISPLAY, don't generate a summary buffer."
7283 (gnus-message 5 "Retrieving newsgroup: %s..." group)
7284 (let* ((new-group (gnus-summary-setup-buffer group))
7285 (quit-config (gnus-group-quit-config group))
7286 (did-select (and new-group (gnus-select-newsgroup group show-all))))
7288 ;; This summary buffer exists already, so we just select it.
7290 (gnus-set-global-variables)
7292 (gnus-kill-or-deaden-summary kill-buffer))
7293 (gnus-configure-windows 'summary 'force)
7294 (gnus-set-mode-line 'summary)
7295 (gnus-summary-position-point)
7298 ;; We couldn't select this group.
7300 (when (and (eq major-mode 'gnus-summary-mode)
7301 (not (equal (current-buffer) kill-buffer)))
7302 (kill-buffer (current-buffer))
7303 (if (not quit-config)
7305 (set-buffer gnus-group-buffer)
7306 (gnus-group-jump-to-group group)
7307 (gnus-group-next-unread-group 1))
7308 (if (not (buffer-name (car quit-config)))
7309 (gnus-configure-windows 'group 'force)
7310 (set-buffer (car quit-config))
7311 (and (eq major-mode 'gnus-summary-mode)
7312 (gnus-set-global-variables))
7313 (gnus-configure-windows (cdr quit-config)))))
7314 (gnus-message 3 "Can't select group")
7316 ;; The user did a `C-g' while prompting for number of articles,
7317 ;; so we exit this group.
7318 ((eq did-select 'quit)
7319 (and (eq major-mode 'gnus-summary-mode)
7320 (not (equal (current-buffer) kill-buffer))
7321 (kill-buffer (current-buffer)))
7323 (gnus-kill-or-deaden-summary kill-buffer))
7324 (if (not quit-config)
7326 (set-buffer gnus-group-buffer)
7327 (gnus-group-jump-to-group group)
7328 (gnus-group-next-unread-group 1)
7329 (gnus-configure-windows 'group 'force))
7330 (if (not (buffer-name (car quit-config)))
7331 (gnus-configure-windows 'group 'force)
7332 (set-buffer (car quit-config))
7333 (and (eq major-mode 'gnus-summary-mode)
7334 (gnus-set-global-variables))
7335 (gnus-configure-windows (cdr quit-config))))
7336 ;; Finally signal the quit.
7338 ;; The group was successfully selected.
7340 (gnus-set-global-variables)
7341 ;; Save the active value in effect when the group was entered.
7342 (setq gnus-newsgroup-active
7344 (gnus-active gnus-newsgroup-name)))
7345 ;; You can change the summary buffer in some way with this hook.
7346 (run-hooks 'gnus-select-group-hook)
7347 ;; Set any local variables in the group parameters.
7348 (gnus-summary-set-local-parameters gnus-newsgroup-name)
7349 (gnus-update-format-specifications)
7350 ;; Do score processing.
7351 (when gnus-use-scoring
7352 (gnus-possibly-score-headers))
7353 ;; Check whether to fill in the gaps in the threads.
7354 (when gnus-build-sparse-threads
7355 (gnus-build-sparse-threads))
7356 ;; Find the initial limit.
7357 (gnus-summary-initial-limit show-all)
7358 ;; Generate the summary buffer.
7360 (gnus-summary-prepare))
7361 (when gnus-use-trees
7362 (gnus-tree-open group)
7363 (setq gnus-summary-highlight-line-function
7364 'gnus-tree-highlight-article))
7365 ;; If the summary buffer is empty, but there are some low-scored
7366 ;; articles or some excluded dormants, we include these in the
7368 (when (and (zerop (buffer-size))
7370 (cond (gnus-newsgroup-dormant
7371 (gnus-summary-limit-include-dormant))
7372 ((and gnus-newsgroup-scored show-all)
7373 (gnus-summary-limit-include-expunged))))
7374 ;; Function `gnus-apply-kill-file' must be called in this hook.
7375 (run-hooks 'gnus-apply-kill-hook)
7376 (if (and (zerop (buffer-size))
7379 ;; This newsgroup is empty.
7380 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
7381 (gnus-message 6 "No unread news")
7383 (gnus-kill-or-deaden-summary kill-buffer))
7384 ;; Return nil from this function.
7386 ;; Hide conversation thread subtrees. We cannot do this in
7387 ;; gnus-summary-prepare-hook since kill processing may not
7388 ;; work with hidden articles.
7389 (and gnus-show-threads
7390 gnus-thread-hide-subtree
7391 (gnus-summary-hide-all-threads))
7392 ;; Show first unread article if requested.
7393 (if (and (not no-article)
7395 gnus-newsgroup-unreads
7396 gnus-auto-select-first)
7397 (if (eq gnus-auto-select-first 'best)
7398 (gnus-summary-best-unread-article)
7399 (gnus-summary-first-unread-article))
7400 ;; Don't select any articles, just move point to the first
7401 ;; article in the group.
7402 (goto-char (point-min))
7403 (gnus-summary-position-point)
7404 (gnus-set-mode-line 'summary)
7405 (gnus-configure-windows 'summary 'force))
7406 ;; If we are in async mode, we send some info to the backend.
7407 (when gnus-newsgroup-async
7408 (gnus-request-asynchronous gnus-newsgroup-name gnus-newsgroup-data))
7410 (gnus-kill-or-deaden-summary kill-buffer))
7411 (when (get-buffer-window gnus-group-buffer)
7412 ;; Gotta use windows, because recenter does wierd stuff if
7413 ;; the current buffer ain't the displayed window.
7414 (let ((owin (selected-window)))
7415 (select-window (get-buffer-window gnus-group-buffer))
7416 (when (gnus-group-goto-group group)
7418 (select-window owin))))
7419 ;; Mark this buffer as "prepared".
7420 (setq gnus-newsgroup-prepared t)
7423 (defun gnus-summary-prepare ()
7424 "Generate the summary buffer."
7425 (let ((buffer-read-only nil))
7427 (setq gnus-newsgroup-data nil
7428 gnus-newsgroup-data-reverse nil)
7429 (run-hooks 'gnus-summary-generate-hook)
7430 ;; Generate the buffer, either with threads or without.
7431 (when gnus-newsgroup-headers
7432 (gnus-summary-prepare-threads
7433 (if gnus-show-threads
7434 (gnus-sort-gathered-threads
7435 (funcall gnus-summary-thread-gathering-function
7437 (gnus-cut-threads (gnus-make-threads)))))
7438 ;; Unthreaded display.
7439 (gnus-sort-articles gnus-newsgroup-headers))))
7440 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
7441 ;; Call hooks for modifying summary buffer.
7442 (goto-char (point-min))
7443 (run-hooks 'gnus-summary-prepare-hook)))
7445 (defun gnus-gather-threads-by-subject (threads)
7446 "Gather threads by looking at Subject headers."
7447 (if (not gnus-summary-make-false-root)
7449 (let ((hashtb (gnus-make-hashtable 1023))
7452 subject hthread whole-subject)
7454 (setq whole-subject (mail-header-subject (car (car threads))))
7455 (if (and gnus-summary-gather-exclude-subject
7456 (string-match gnus-summary-gather-exclude-subject
7458 () ; We don't want to do anything with this article.
7459 ;; We simplify the subject before looking it up in the
7463 ;; Truncate the subject.
7464 ((numberp gnus-summary-gather-subject-limit)
7465 (setq subject (gnus-simplify-subject-re whole-subject))
7466 (if (> (length subject) gnus-summary-gather-subject-limit)
7467 (substring subject 0 gnus-summary-gather-subject-limit)
7469 ;; Fuzzily simplify it.
7470 ((eq 'fuzzy gnus-summary-gather-subject-limit)
7471 (gnus-simplify-subject-fuzzy whole-subject))
7472 ;; Just remove the leading "Re:".
7474 (gnus-simplify-subject-re whole-subject))))
7476 (if (setq hthread (gnus-gethash subject hashtb))
7478 ;; We enter a dummy root into the thread, if we
7479 ;; haven't done that already.
7480 (unless (stringp (car (car hthread)))
7481 (setcar hthread (list whole-subject (car hthread))))
7482 ;; We add this new gathered thread to this gathered
7484 (setcdr (car hthread)
7485 (nconc (cdr (car hthread)) (list (car threads))))
7486 ;; Remove it from the list of threads.
7487 (setcdr prev (cdr threads))
7488 (setq threads prev))
7489 ;; Enter this thread into the hash table.
7490 (gnus-sethash subject threads hashtb)))
7492 (setq threads (cdr threads)))
7495 (defun gnus-summary-gather-threads-by-references (threads)
7496 "Gather threads by looking at References headers."
7497 (let ((idhashtb (gnus-make-hashtable 1023))
7498 (thhashtb (gnus-make-hashtable 1023))
7501 ids references id gthread gid entered)
7503 (when (setq references (mail-header-references (caar threads)))
7504 (setq id (mail-header-id (caar threads)))
7505 (setq ids (gnus-split-references references))
7508 (if (not (setq gid (gnus-gethash (car ids) idhashtb)))
7510 (gnus-sethash (car ids) id idhashtb)
7511 (gnus-sethash id threads thhashtb))
7512 (setq gthread (gnus-gethash gid thhashtb))
7514 ;; We enter a dummy root into the thread, if we
7515 ;; haven't done that already.
7516 (unless (stringp (caar gthread))
7517 (setcar gthread (list (mail-header-subject (caar gthread))
7519 ;; We add this new gathered thread to this gathered
7521 (setcdr (car gthread)
7522 (nconc (cdar gthread) (list (car threads)))))
7523 ;; Add it into the thread hash table.
7524 (gnus-sethash id gthread thhashtb)
7526 ;; Remove it from the list of threads.
7527 (setcdr prev (cdr threads))
7528 (setq threads prev))
7529 (setq ids (cdr ids))))
7531 (setq threads (cdr threads)))
7534 (defun gnus-sort-gathered-threads (threads)
7535 "Sort subtreads inside each gathered thread by article number."
7536 (let ((result threads))
7538 (when (stringp (car (car threads)))
7539 (setcdr (car threads)
7540 (sort (cdr (car threads)) 'gnus-thread-sort-by-number)))
7541 (setq threads (cdr threads)))
7544 (defun gnus-make-threads ()
7545 "Go through the dependency hashtb and find the roots. Return all threads."
7549 (unless (car (symbol-value refs))
7550 ;; These threads do not refer back to any other articles,
7551 ;; so they're roots.
7552 (setq threads (append (cdr (symbol-value refs)) threads))))
7553 gnus-newsgroup-dependencies)
7556 (defun gnus-build-sparse-threads ()
7557 (let ((headers gnus-newsgroup-headers)
7558 (deps gnus-newsgroup-dependencies)
7559 header references generation relations
7560 cthread subject child end pthread relation)
7561 ;; First we create an alist of generations/relations, where
7562 ;; generations is how much we trust the ralation, and the relation
7564 (gnus-message 7 "Making sparse threads...")
7566 (nnheader-set-temp-buffer " *gnus sparse threads*")
7567 (while (setq header (pop headers))
7568 (when (and (setq references (mail-header-references header))
7569 (not (string= references "")))
7571 (setq child (downcase (mail-header-id header))
7572 subject (mail-header-subject header))
7574 (while (search-backward ">" nil t)
7575 (setq end (1+ (point)))
7576 (when (search-backward "<" nil t)
7577 (push (list (incf generation)
7578 child (setq child (downcase
7579 (buffer-substring (point) end)))
7582 (push (list (1+ generation) child nil subject) relations)
7584 (kill-buffer (current-buffer)))
7585 ;; Sort over trustworthiness.
7586 (setq relations (sort relations (lambda (r1 r2) (< (car r1) (car r2)))))
7587 (while (setq relation (pop relations))
7588 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
7589 (unless (car (symbol-value cthread))
7590 ;; Make this article the parent of these threads.
7591 (setcar (symbol-value cthread)
7592 (vector gnus-reffed-article-number
7596 (or (caddr relation) "") 0 0 "")))
7597 (set cthread (list (vector gnus-reffed-article-number
7599 "" "" (cadr relation)
7600 (or (caddr relation) "") 0 0 ""))))
7601 (push gnus-reffed-article-number gnus-newsgroup-limit)
7602 (push gnus-reffed-article-number gnus-newsgroup-sparse)
7603 (push (cons gnus-reffed-article-number gnus-sparse-mark)
7604 gnus-newsgroup-reads)
7605 (decf gnus-reffed-article-number)
7606 ;; Make this new thread the child of its parent.
7607 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
7608 (setcdr (symbol-value pthread)
7609 (nconc (cdr (symbol-value pthread))
7610 (list (symbol-value cthread))))
7611 (set pthread (list nil (symbol-value cthread))))))
7612 (gnus-message 7 "Making sparse threads...done")))
7614 (defun gnus-build-old-threads ()
7615 ;; Look at all the articles that refer back to old articles, and
7616 ;; fetch the headers for the articles that aren't there. This will
7617 ;; build complete threads - if the roots haven't been expired by the
7622 (when (not (car (symbol-value refs)))
7623 (setq heads (cdr (symbol-value refs)))
7625 (if (memq (mail-header-number (car (car heads)))
7626 gnus-newsgroup-dormant)
7627 (setq heads (cdr heads))
7628 (setq id (symbol-name refs))
7629 (while (and (setq id (gnus-build-get-header id))
7630 (not (car (gnus-gethash
7631 id gnus-newsgroup-dependencies)))))
7632 (setq heads nil)))))
7633 gnus-newsgroup-dependencies)))
7635 (defun gnus-build-get-header (id)
7636 ;; Look through the buffer of NOV lines and find the header to
7637 ;; ID. Enter this line into the dependencies hash table, and return
7638 ;; the id of the parent article (if any).
7639 (let ((deps gnus-newsgroup-dependencies)
7643 (set-buffer nntp-server-buffer)
7644 (goto-char (point-min))
7645 (while (and (not found) (search-forward id nil t))
7647 (setq found (looking-at
7648 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
7649 (regexp-quote id))))
7650 (or found (beginning-of-line 2)))
7655 (setq header (gnus-nov-parse-line
7656 (read (current-buffer)) deps))
7657 (gnus-parent-id (mail-header-references header))))))
7659 (let ((number (mail-header-number header)))
7660 (push number gnus-newsgroup-limit)
7661 (push header gnus-newsgroup-headers)
7662 (if (memq number gnus-newsgroup-unselected)
7664 (push number gnus-newsgroup-unreads)
7665 (setq gnus-newsgroup-unselected
7666 (delq number gnus-newsgroup-unselected)))
7667 (push number gnus-newsgroup-ancient)))))))
7669 (defun gnus-summary-update-article (article &optional header)
7670 "Update ARTICLE in the summary buffer."
7671 (let ((id (mail-header-id (gnus-summary-article-header article)))
7672 (data (gnus-data-find article)))
7673 (setcar (gnus-id-to-thread id) nil)
7674 (gnus-summary-insert-subject id)
7675 ;; Set the (possibly) new article number in the data structure.
7676 (gnus-data-set-number data (gnus-id-to-article id))))
7678 (defun gnus-rebuild-thread (id)
7679 "Rebuild the thread containing ID."
7680 (let ((dep gnus-newsgroup-dependencies)
7681 (buffer-read-only nil)
7682 current headers refs thread art data)
7683 (if (not gnus-show-threads)
7684 (setq thread (list (car (gnus-id-to-thread id))))
7685 ;; Get the thread this article is part of.
7686 (setq thread (gnus-remove-thread id)))
7687 (setq current (save-excursion
7688 (and (zerop (forward-line -1))
7689 (gnus-summary-article-number))))
7690 ;; If this is a gathered thread, we have to go some re-gathering.
7691 (when (stringp (car thread))
7692 (let ((subject (car thread))
7694 (setq thread (cdr thread))
7696 (unless (memq (setq thr (gnus-id-to-thread
7698 (mail-header-id (car (car thread))))))
7701 (setq thread (cdr thread)))
7702 ;; We now have all (unique) roots.
7703 (if (= (length roots) 1)
7704 ;; All the loose roots are now one solid root.
7705 (setq thread (car roots))
7706 (setq thread (cons subject (gnus-sort-threads roots))))))
7709 ;; We then insert this thread into the summary buffer.
7710 (let (gnus-newsgroup-data gnus-newsgroup-threads)
7711 (gnus-summary-prepare-threads (list thread))
7712 (setq data (nreverse gnus-newsgroup-data))
7713 (setq threads gnus-newsgroup-threads))
7714 ;; We splice the new data into the data structure.
7715 (gnus-data-enter-list current data)
7716 (gnus-data-compute-positions)
7717 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
7719 (defun gnus-id-to-thread (id)
7720 "Return the (sub-)thread where ID appears."
7721 (gnus-gethash (downcase id) gnus-newsgroup-dependencies))
7723 (defun gnus-id-to-article (id)
7724 "Return the article number of ID."
7725 (let ((thread (gnus-id-to-thread id)))
7727 (mail-header-number (car thread)))))
7729 (defun gnus-id-to-header (id)
7730 "Return the article headers of ID."
7731 (car (gnus-id-to-thread id)))
7733 (defun gnus-article-displayed-root-p (article)
7734 "Say whether ARTICLE is a root(ish) article."
7735 (let ((level (gnus-summary-thread-level article))
7741 (null (setq particle (gnus-id-to-article
7743 (mail-header-references
7744 (gnus-summary-article-header article))))))
7745 (null (gnus-summary-thread-level particle)))))))
7747 (defun gnus-root-id (id)
7748 "Return the id of the root of the thread where ID appears."
7750 (while (and id (setq prev (car (gnus-gethash
7752 gnus-newsgroup-dependencies))))
7754 id (gnus-parent-id (mail-header-references prev))))
7757 (defun gnus-remove-thread (id &optional dont-remove)
7758 "Remove the thread that has ID in it."
7759 (let ((dep gnus-newsgroup-dependencies)
7760 headers thread prev last-id)
7761 ;; First go up in this thread until we find the root.
7762 (setq last-id (gnus-root-id id))
7763 (setq headers (list (car (gnus-id-to-thread last-id))
7764 (car (car (cdr (gnus-id-to-thread last-id))))))
7765 ;; We have now found the real root of this thread. It might have
7766 ;; been gathered into some loose thread, so we have to search
7767 ;; through the threads to find the thread we wanted.
7768 (let ((threads gnus-newsgroup-threads)
7771 (setq sub (car threads))
7772 (if (stringp (car sub))
7773 ;; This is a gathered threads, so we look at the roots
7774 ;; below it to find whether this article in in this
7777 (setq sub (cdr sub))
7779 (when (member (car (car sub)) headers)
7780 (setq thread (car threads)
7783 (setq sub (cdr sub))))
7784 ;; It's an ordinary thread, so we check it.
7785 (when (eq (car sub) (car headers))
7788 (setq threads (cdr threads)))
7789 ;; If this article is in no thread, then it's a root.
7792 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
7793 (setq thread (gnus-gethash (downcase last-id) dep)))
7796 thread ; We return this thread.
7798 (if (stringp (car thread))
7800 ;; If we use dummy roots, then we have to remove the
7801 ;; dummy root as well.
7802 (when (eq gnus-summary-make-false-root 'dummy)
7805 (setq thread (cdr thread))
7807 (gnus-remove-thread-1 (car thread))
7808 (setq thread (cdr thread))))
7809 (gnus-remove-thread-1 thread))))))))
7811 (defun gnus-remove-thread-1 (thread)
7812 "Remove the thread THREAD recursively."
7813 (let ((number (mail-header-number (car thread)))
7815 (when (setq pos (text-property-any
7816 (point-min) (point-max) 'gnus-number number))
7819 (gnus-data-remove number))
7820 (setq thread (cdr thread))
7822 (gnus-remove-thread-1 (car thread))
7823 (setq thread (cdr thread)))))
7825 (defun gnus-sort-threads (threads)
7827 (if (not gnus-thread-sort-functions)
7829 (let ((func (if (= 1 (length gnus-thread-sort-functions))
7830 (car gnus-thread-sort-functions)
7832 ,(gnus-make-sort-function
7833 (reverse gnus-thread-sort-functions))))))
7834 (gnus-message 7 "Sorting threads...")
7837 (gnus-message 7 "Sorting threads...done")))))
7839 (defun gnus-sort-articles (articles)
7841 (when gnus-article-sort-functions
7842 (let ((func (if (= 1 (length gnus-article-sort-functions))
7843 (car gnus-article-sort-functions)
7845 ,(gnus-make-sort-function
7846 (reverse gnus-article-sort-functions))))))
7847 (gnus-message 7 "Sorting articles...")
7849 (setq gnus-newsgroup-headers (sort articles func))
7850 (gnus-message 7 "Sorting articles...done")))))
7852 (defun gnus-make-sort-function (funs)
7853 "Return a composite sort condition based on the functions in FUNC."
7855 `(or (,(car funs) t1 t2)
7856 (and (not (,(car funs) t2 t1))
7857 ,(gnus-make-sort-function (cdr funs))))
7858 `(,(car funs) t1 t2)))
7860 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
7861 (defmacro gnus-thread-header (thread)
7862 ;; Return header of first article in THREAD.
7863 ;; Note that THREAD must never, ever be anything else than a variable -
7864 ;; using some other form will lead to serious barfage.
7865 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
7866 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
7867 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
7870 (defsubst gnus-article-sort-by-number (h1 h2)
7871 "Sort articles by article number."
7872 (< (mail-header-number h1)
7873 (mail-header-number h2)))
7875 (defun gnus-thread-sort-by-number (h1 h2)
7876 "Sort threads by root article number."
7877 (gnus-article-sort-by-number
7878 (gnus-thread-header h1) (gnus-thread-header h2)))
7880 (defsubst gnus-article-sort-by-author (h1 h2)
7881 "Sort articles by root author."
7883 (let ((extract (funcall
7884 gnus-extract-address-components
7885 (mail-header-from h1))))
7886 (or (car extract) (cdr extract)))
7887 (let ((extract (funcall
7888 gnus-extract-address-components
7889 (mail-header-from h2))))
7890 (or (car extract) (cdr extract)))))
7892 (defun gnus-thread-sort-by-author (h1 h2)
7893 "Sort threads by root author."
7894 (gnus-article-sort-by-author
7895 (gnus-thread-header h1) (gnus-thread-header h2)))
7897 (defsubst gnus-article-sort-by-subject (h1 h2)
7898 "Sort articles by root subject."
7900 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
7901 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
7903 (defun gnus-thread-sort-by-subject (h1 h2)
7904 "Sort threads by root subject."
7905 (gnus-article-sort-by-subject
7906 (gnus-thread-header h1) (gnus-thread-header h2)))
7908 (defsubst gnus-article-sort-by-date (h1 h2)
7909 "Sort articles by root article date."
7911 (gnus-sortable-date (mail-header-date h1))
7912 (gnus-sortable-date (mail-header-date h2))))
7914 (defun gnus-thread-sort-by-date (h1 h2)
7915 "Sort threads by root article date."
7916 (gnus-article-sort-by-date
7917 (gnus-thread-header h1) (gnus-thread-header h2)))
7919 (defsubst gnus-article-sort-by-score (h1 h2)
7920 "Sort articles by root article score.
7921 Unscored articles will be counted as having a score of zero."
7922 (> (or (cdr (assq (mail-header-number h1)
7923 gnus-newsgroup-scored))
7924 gnus-summary-default-score 0)
7925 (or (cdr (assq (mail-header-number h2)
7926 gnus-newsgroup-scored))
7927 gnus-summary-default-score 0)))
7929 (defun gnus-thread-sort-by-score (h1 h2)
7930 "Sort threads by root article score."
7931 (gnus-article-sort-by-score
7932 (gnus-thread-header h1) (gnus-thread-header h2)))
7934 (defun gnus-thread-sort-by-total-score (h1 h2)
7935 "Sort threads by the sum of all scores in the thread.
7936 Unscored articles will be counted as having a score of zero."
7937 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
7939 (defun gnus-thread-total-score (thread)
7940 ;; This function find the total score of THREAD.
7942 (if (stringp (car thread))
7943 (apply gnus-thread-score-function 0
7944 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
7945 (gnus-thread-total-score-1 thread))
7946 (gnus-thread-total-score-1 (list thread))))
7948 (defun gnus-thread-total-score-1 (root)
7949 ;; This function find the total score of the thread below ROOT.
7950 (setq root (car root))
7951 (apply gnus-thread-score-function
7952 (or (cdr (assq (mail-header-number root) gnus-newsgroup-scored))
7953 gnus-summary-default-score 0)
7954 (mapcar 'gnus-thread-total-score
7955 (cdr (gnus-gethash (downcase (mail-header-id root))
7956 gnus-newsgroup-dependencies)))))
7958 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
7959 (defvar gnus-tmp-prev-subject nil)
7960 (defvar gnus-tmp-false-parent nil)
7961 (defvar gnus-tmp-root-expunged nil)
7962 (defvar gnus-tmp-dummy-line nil)
7964 (defun gnus-summary-prepare-threads (threads)
7965 "Prepare summary buffer from THREADS and indentation LEVEL.
7966 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
7967 or a straight list of headers."
7968 (gnus-message 7 "Generating summary...")
7970 (setq gnus-newsgroup-threads threads)
7973 (let ((gnus-tmp-level 0)
7974 (default-score (or gnus-summary-default-score 0))
7975 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
7976 thread number subject stack state gnus-tmp-gathered beg-match
7977 new-roots gnus-tmp-new-adopts thread-end
7978 gnus-tmp-header gnus-tmp-unread
7979 gnus-tmp-replied gnus-tmp-subject-or-nil
7980 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
7981 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
7982 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
7984 (setq gnus-tmp-prev-subject nil)
7986 (if (vectorp (car threads))
7987 ;; If this is a straight (sic) list of headers, then a
7988 ;; threaded summary display isn't required, so we just create
7989 ;; an unthreaded one.
7990 (gnus-summary-prepare-unthreaded threads)
7992 ;; Do the threaded display.
7994 (while (or threads stack gnus-tmp-new-adopts new-roots)
7996 (if (and (= gnus-tmp-level 0)
7997 (not (setq gnus-tmp-dummy-line nil))
7999 (= (car (car stack)) 0))
8000 (not gnus-tmp-false-parent)
8001 (or gnus-tmp-new-adopts new-roots))
8002 (if gnus-tmp-new-adopts
8003 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
8004 thread (list (car gnus-tmp-new-adopts))
8005 gnus-tmp-header (car (car thread))
8006 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
8008 (setq thread (list (car new-roots))
8009 gnus-tmp-header (car (car thread))
8010 new-roots (cdr new-roots))))
8013 ;; If there are some threads, we do them before the
8014 ;; threads on the stack.
8015 (setq thread threads
8016 gnus-tmp-header (car (car thread)))
8017 ;; There were no current threads, so we pop something off
8019 (setq state (car stack)
8020 gnus-tmp-level (car state)
8023 gnus-tmp-header (car (car thread)))))
8025 (setq gnus-tmp-false-parent nil)
8026 (setq gnus-tmp-root-expunged nil)
8027 (setq thread-end nil)
8029 (if (stringp gnus-tmp-header)
8030 ;; The header is a dummy root.
8032 ((eq gnus-summary-make-false-root 'adopt)
8033 ;; We let the first article adopt the rest.
8034 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
8035 (cdr (cdr (car thread)))))
8036 (setq gnus-tmp-gathered
8038 (lambda (h) (mail-header-number (car h)))
8039 (cdr (cdr (car thread))))
8041 (setq thread (cons (list (car (car thread))
8042 (car (cdr (car thread))))
8044 (setq gnus-tmp-level -1
8045 gnus-tmp-false-parent t))
8046 ((eq gnus-summary-make-false-root 'empty)
8047 ;; We print adopted articles with empty subject fields.
8048 (setq gnus-tmp-gathered
8050 (lambda (h) (mail-header-number (car h)))
8051 (cdr (cdr (car thread))))
8053 (setq gnus-tmp-level -1))
8054 ((eq gnus-summary-make-false-root 'dummy)
8055 ;; We remember that we probably want to output a dummy
8057 (setq gnus-tmp-dummy-line gnus-tmp-header)
8058 (setq gnus-tmp-prev-subject gnus-tmp-header))
8060 ;; We do not make a root for the gathered
8061 ;; sub-threads at all.
8062 (setq gnus-tmp-level -1)))
8064 (setq number (mail-header-number gnus-tmp-header)
8065 subject (mail-header-subject gnus-tmp-header))
8068 ;; If the thread has changed subject, we might want to make
8069 ;; this subthread into a root.
8070 ((and (null gnus-thread-ignore-subject)
8071 (not (zerop gnus-tmp-level))
8072 gnus-tmp-prev-subject
8074 (gnus-subject-equal gnus-tmp-prev-subject subject))))
8075 (setq new-roots (nconc new-roots (list (car thread)))
8077 gnus-tmp-header nil))
8078 ;; If the article lies outside the current limit,
8079 ;; then we do not display it.
8080 ((and (not (memq number gnus-newsgroup-limit))
8081 (not gnus-tmp-dummy-line))
8082 (setq gnus-tmp-gathered
8084 (lambda (h) (mail-header-number (car h)))
8087 (setq gnus-tmp-new-adopts (if (cdr (car thread))
8088 (append gnus-tmp-new-adopts
8090 gnus-tmp-new-adopts)
8092 gnus-tmp-header nil)
8093 (when (zerop gnus-tmp-level)
8094 (setq gnus-tmp-root-expunged t)))
8095 ;; Perhaps this article is to be marked as read?
8096 ((and gnus-summary-mark-below
8097 (< (or (cdr (assq number gnus-newsgroup-scored))
8099 gnus-summary-mark-below))
8100 (setq gnus-newsgroup-unreads
8101 (delq number gnus-newsgroup-unreads))
8102 (if gnus-newsgroup-auto-expire
8103 (push number gnus-newsgroup-expirable)
8104 (push (cons number gnus-low-score-mark)
8105 gnus-newsgroup-reads))))
8107 (when gnus-tmp-header
8108 ;; We may have an old dummy line to output before this
8110 (if gnus-tmp-dummy-line
8112 (gnus-summary-insert-dummy-line
8113 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
8114 (setq gnus-tmp-dummy-line nil))
8116 ;; Compute the mark.
8120 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8121 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8122 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8123 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8124 (t (or (cdr (assq number gnus-newsgroup-reads))
8125 gnus-ancient-mark))))
8127 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
8128 gnus-tmp-header gnus-tmp-level)
8129 gnus-newsgroup-data)
8131 ;; Actually insert the line.
8133 gnus-tmp-subject-or-nil
8135 ((and gnus-thread-ignore-subject
8136 gnus-tmp-prev-subject
8137 (not (inline (gnus-subject-equal
8138 gnus-tmp-prev-subject subject))))
8140 ((zerop gnus-tmp-level)
8141 (if (and (eq gnus-summary-make-false-root 'empty)
8142 (memq number gnus-tmp-gathered)
8143 gnus-tmp-prev-subject
8144 (inline (gnus-subject-equal
8145 gnus-tmp-prev-subject subject)))
8146 gnus-summary-same-subject
8148 (t gnus-summary-same-subject)))
8149 (if (and (eq gnus-summary-make-false-root 'adopt)
8150 (= gnus-tmp-level 1)
8151 (memq number gnus-tmp-gathered))
8152 (setq gnus-tmp-opening-bracket ?\<
8153 gnus-tmp-closing-bracket ?\>)
8154 (setq gnus-tmp-opening-bracket ?\[
8155 gnus-tmp-closing-bracket ?\]))
8157 gnus-tmp-indentation
8158 (aref gnus-thread-indent-array gnus-tmp-level)
8159 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
8160 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
8161 gnus-summary-default-score 0)
8163 (if (or (null gnus-summary-default-score)
8164 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
8165 gnus-summary-zcore-fuzz)) ?
8166 (if (< gnus-tmp-score gnus-summary-default-score)
8167 gnus-score-below-mark gnus-score-over-mark))
8169 (cond ((memq number gnus-newsgroup-processable)
8171 ((memq number gnus-newsgroup-cached)
8173 ((memq number gnus-newsgroup-replied)
8175 (t gnus-unread-mark))
8176 gnus-tmp-from (mail-header-from gnus-tmp-header)
8179 ((string-match "(.+)" gnus-tmp-from)
8180 (substring gnus-tmp-from
8181 (1+ (match-beginning 0)) (1- (match-end 0))))
8182 ((string-match "<[^>]+> *$" gnus-tmp-from)
8183 (setq beg-match (match-beginning 0))
8184 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
8185 (substring gnus-tmp-from (1+ (match-beginning 0))
8186 (1- (match-end 0))))
8187 (substring gnus-tmp-from 0 beg-match)))
8189 (when (string= gnus-tmp-name "")
8190 (setq gnus-tmp-name gnus-tmp-from))
8191 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
8194 (progn (eval gnus-summary-line-format-spec) (point))
8195 'gnus-number number)
8198 (run-hooks 'gnus-summary-update-hook)
8203 (setq gnus-tmp-prev-subject subject)))
8205 (when (nth 1 thread)
8206 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
8207 (incf gnus-tmp-level)
8208 (setq threads (if thread-end nil (cdr (car thread))))
8210 (setq gnus-tmp-level 0)))))
8211 (gnus-message 7 "Generating summary...done"))
8213 (defun gnus-summary-prepare-unthreaded (headers)
8214 "Generate an unthreaded summary buffer based on HEADERS."
8215 (let (header number mark)
8218 (setq header (car headers)
8219 headers (cdr headers)
8220 number (mail-header-number header))
8222 ;; We may have to root out some bad articles...
8223 (when (memq number gnus-newsgroup-limit)
8224 (when (and gnus-summary-mark-below
8225 (< (or (cdr (assq number gnus-newsgroup-scored))
8226 gnus-summary-default-score 0)
8227 gnus-summary-mark-below))
8228 (setq gnus-newsgroup-unreads
8229 (delq number gnus-newsgroup-unreads))
8230 (if gnus-newsgroup-auto-expire
8231 (push number gnus-newsgroup-expirable)
8232 (push (cons number gnus-low-score-mark)
8233 gnus-newsgroup-reads)))
8237 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8238 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8239 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8240 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8241 (t (or (cdr (assq number gnus-newsgroup-reads))
8242 gnus-ancient-mark))))
8243 (setq gnus-newsgroup-data
8244 (cons (gnus-data-make number mark (1+ (point)) header 0)
8245 gnus-newsgroup-data))
8246 (gnus-summary-insert-line
8247 header 0 nil mark (memq number gnus-newsgroup-replied)
8248 (memq number gnus-newsgroup-expirable)
8249 (mail-header-subject header) nil
8250 (cdr (assq number gnus-newsgroup-scored))
8251 (memq number gnus-newsgroup-processable))))))
8253 (defun gnus-select-newsgroup (group &optional read-all)
8254 "Select newsgroup GROUP.
8255 If READ-ALL is non-nil, all articles in the group are selected."
8256 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
8257 (info (nth 2 entry))
8258 articles fetched-articles cached)
8260 (or (gnus-check-server
8261 (setq gnus-current-select-method (gnus-find-method-for-group group)))
8262 (error "Couldn't open server"))
8264 (or (and entry (not (eq (car entry) t))) ; Either it's active...
8265 (gnus-activate-group group) ; Or we can activate it...
8266 (progn ; Or we bug out.
8267 (kill-buffer (current-buffer))
8268 (error "Couldn't request group %s: %s"
8269 group (gnus-status-message group))))
8271 (setq gnus-newsgroup-name group)
8272 (setq gnus-newsgroup-unselected nil)
8273 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
8275 (and gnus-asynchronous
8276 (gnus-check-backend-function
8277 'request-asynchronous gnus-newsgroup-name)
8278 (setq gnus-newsgroup-async
8279 (gnus-request-asynchronous gnus-newsgroup-name)))
8281 ;; Adjust and set lists of article marks.
8283 (gnus-adjust-marked-articles info))
8285 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8286 (when (gnus-virtual-group-p group)
8287 (setq cached gnus-newsgroup-cached))
8289 (setq gnus-newsgroup-unreads
8290 (gnus-set-difference
8291 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
8292 gnus-newsgroup-dormant))
8294 (setq gnus-newsgroup-processable nil)
8296 (setq articles (gnus-articles-to-read group read-all))
8300 (gnus-message 3 "Couldn't select newsgroup -- no articles to display")
8302 ((eq articles 0) nil)
8304 ;; Init the dependencies hash table.
8305 (setq gnus-newsgroup-dependencies
8306 (gnus-make-hashtable (length articles)))
8307 ;; Retrieve the headers and read them in.
8308 (gnus-message 5 "Fetching headers...")
8309 (setq gnus-newsgroup-headers
8311 (setq gnus-headers-retrieved-by
8312 (gnus-retrieve-headers
8313 articles gnus-newsgroup-name
8314 ;; We might want to fetch old headers, but
8315 ;; not if there is only 1 article.
8316 (and gnus-fetch-old-headers
8318 (not (eq gnus-fetch-old-headers 'some))
8319 (not (numberp gnus-fetch-old-headers)))
8320 (> (length articles) 1))))))
8321 (gnus-get-newsgroup-headers-xover articles)
8322 (gnus-get-newsgroup-headers)))
8323 (gnus-message 5 "Fetching headers...done")
8325 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8327 (setq gnus-newsgroup-cached cached))
8329 ;; Set the initial limit.
8330 (setq gnus-newsgroup-limit (copy-sequence articles))
8331 ;; Remove canceled articles from the list of unread articles.
8332 (setq gnus-newsgroup-unreads
8333 (gnus-set-sorted-intersection
8334 gnus-newsgroup-unreads
8335 (setq fetched-articles
8336 (mapcar (lambda (headers) (mail-header-number headers))
8337 gnus-newsgroup-headers))))
8338 ;; Removed marked articles that do not exist.
8339 (gnus-update-missing-marks
8340 (gnus-sorted-complement fetched-articles articles))
8341 ;; We might want to build some more threads first.
8342 (and gnus-fetch-old-headers
8343 (eq gnus-headers-retrieved-by 'nov)
8344 (gnus-build-old-threads))
8345 ;; Check whether auto-expire is to be done in this group.
8346 (setq gnus-newsgroup-auto-expire
8347 (gnus-group-auto-expirable-p group))
8348 ;; First and last article in this newsgroup.
8349 (and gnus-newsgroup-headers
8350 (setq gnus-newsgroup-begin
8351 (mail-header-number (car gnus-newsgroup-headers)))
8352 (setq gnus-newsgroup-end
8354 (gnus-last-element gnus-newsgroup-headers))))
8355 (setq gnus-reffed-article-number -1)
8356 ;; GROUP is successfully selected.
8357 (or gnus-newsgroup-headers t)))))
8359 (defun gnus-articles-to-read (group read-all)
8360 ;; Find out what articles the user wants to read.
8362 ;; Select all articles if `read-all' is non-nil, or if there
8363 ;; are no unread articles.
8365 (and (zerop (length gnus-newsgroup-marked))
8366 (zerop (length gnus-newsgroup-unreads))))
8367 (gnus-uncompress-range (gnus-active group))
8368 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
8369 (copy-sequence gnus-newsgroup-unreads))
8371 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
8372 (scored (length scored-list))
8373 (number (length articles))
8374 (marked (+ (length gnus-newsgroup-marked)
8375 (length gnus-newsgroup-dormant)))
8383 ((and (or (<= scored marked) (= scored number))
8384 (numberp gnus-large-newsgroup)
8385 (> number gnus-large-newsgroup))
8389 "How many articles from %s (default %d): "
8390 gnus-newsgroup-name number))))
8391 (if (string-match "^[ \t]*$" input) number input)))
8392 ((and (> scored marked) (< scored number))
8395 (format "%s %s (%d scored, %d total): "
8396 "How many articles from"
8397 group scored number))))
8398 (if (string-match "^[ \t]*$" input)
8402 (setq select (if (stringp select) (string-to-number select) select))
8403 (if (or (null select) (zerop select))
8405 (if (and (not (zerop scored)) (<= (abs select) scored))
8407 (setq articles (sort scored-list '<))
8408 (setq number (length articles)))
8409 (setq articles (copy-sequence articles)))
8411 (if (< (abs select) number)
8413 ;; Select the N oldest articles.
8414 (setcdr (nthcdr (1- (abs select)) articles) nil)
8415 ;; Select the N most recent articles.
8416 (setq articles (nthcdr (- number select) articles))))
8417 (setq gnus-newsgroup-unselected
8418 (gnus-sorted-intersection
8419 gnus-newsgroup-unreads
8420 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
8423 (defun gnus-killed-articles (killed articles)
8426 (if (inline (gnus-member-of-range (car articles) killed))
8427 (setq out (cons (car articles) out)))
8428 (setq articles (cdr articles)))
8431 (defun gnus-uncompress-marks (marks)
8432 "Uncompress the mark ranges in MARKS."
8433 (let ((uncompressed '(score bookmark))
8436 (if (memq (caar marks) uncompressed)
8437 (push (car marks) out)
8438 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
8439 (setq marks (cdr marks)))
8442 (defun gnus-adjust-marked-articles (info)
8443 "Set all article lists and remove all marks that are no longer legal."
8444 (let* ((marked-lists (gnus-info-marks info))
8445 (active (gnus-active (gnus-info-group info)))
8448 (types gnus-article-mark-lists)
8449 (uncompressed '(score bookmark))
8450 marks var articles article mark)
8453 (setq marks (pop marked-lists))
8454 (set (setq var (intern (format "gnus-newsgroup-%s"
8455 (car (rassq (setq mark (car marks))
8457 (if (memq (car marks) uncompressed) (cdr marks)
8458 (gnus-uncompress-range (cdr marks))))
8460 (setq articles (symbol-value var))
8462 ;; All articles have to be subsets of the active articles.
8464 ;; Adjust "simple" lists.
8465 ((memq mark '(tick dormant expirable reply killed save))
8467 (when (or (< (setq article (pop articles)) min) (> article max))
8468 (set var (delq article (symbol-value var))))))
8470 ((memq mark '(score bookmark))
8472 (when (or (< (car (setq article (pop articles))) min)
8473 (> (car article) max))
8474 (set var (delq article (symbol-value var))))))))))
8476 (defun gnus-update-missing-marks (missing)
8477 "Go through the list of MISSING articles and remove them mark lists."
8479 (let ((types gnus-article-mark-lists)
8481 ;; Go through all types.
8483 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
8484 (when (symbol-value var)
8485 ;; This list has articles. So we delete all missing articles
8489 (set var (delq (pop m) (symbol-value var)))))))))
8491 (defun gnus-update-marks ()
8492 "Enter the various lists of marked articles into the newsgroup info list."
8493 (let ((types gnus-article-mark-lists)
8494 (info (gnus-get-info gnus-newsgroup-name))
8495 (uncompressed '(score bookmark killed))
8496 var type list newmarked symbol)
8498 ;; Add all marks lists that are non-nil to the list of marks lists.
8500 (setq type (pop types))
8501 (when (setq list (symbol-value
8503 (intern (format "gnus-newsgroup-%s"
8505 (push (cons (cdr type)
8506 (if (memq (cdr type) uncompressed) list
8507 (gnus-compress-sequence (set symbol (sort list '<)) t)))
8510 ;; Enter these new marks into the info of the group.
8512 (setcar (nthcdr 3 info) newmarked)
8513 ;; Add the marks lists to the end of the info.
8515 (setcdr (nthcdr 2 info) (list newmarked))))
8517 ;; Cut off the end of the info if there's nothing else there.
8521 (when (nthcdr (decf i) info)
8522 (setcdr (nthcdr i info) nil)))))))
8524 (defun gnus-add-marked-articles (group type articles &optional info force)
8525 ;; Add ARTICLES of TYPE to the info of GROUP.
8526 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
8527 ;; add, but replace marked articles of TYPE with ARTICLES.
8528 (let ((info (or info (gnus-get-info group)))
8529 (uncompressed '(score bookmark killed))
8532 (and (not (setq marked (nthcdr 3 info)))
8533 (setcdr (nthcdr 2 info)
8534 (list (list (cons type (gnus-compress-sequence
8536 (and (not (setq m (assq type (car marked))))
8538 (cons (cons type (gnus-compress-sequence articles t) )
8541 (setcdr m (gnus-compress-sequence articles t))
8542 (setcdr m (gnus-compress-sequence
8543 (sort (nconc (gnus-uncompress-range m)
8544 (copy-sequence articles)) '<) t))))))
8546 (defun gnus-set-mode-line (where)
8547 "This function sets the mode line of the article or summary buffers.
8548 If WHERE is `summary', the summary mode line format will be used."
8549 ;; Is this mode line one we keep updated?
8550 (when (memq where gnus-updated-mode-lines)
8553 ;; We evaluate this in the summary buffer since these
8554 ;; variables are buffer-local to that buffer.
8555 (set-buffer gnus-summary-buffer)
8556 ;; We bind all these variables that are used in the `eval' form
8558 (let* ((mformat (symbol-value
8560 (format "gnus-%s-mode-line-format-spec" where))))
8561 (gnus-tmp-group-name gnus-newsgroup-name)
8562 (gnus-tmp-article-number (or gnus-current-article 0))
8563 (gnus-tmp-unread gnus-newsgroup-unreads)
8564 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
8565 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
8566 (gnus-tmp-unread-and-unselected
8567 (cond ((and (zerop gnus-tmp-unread-and-unticked)
8568 (zerop gnus-tmp-unselected)) "")
8569 ((zerop gnus-tmp-unselected)
8570 (format "{%d more}" gnus-tmp-unread-and-unticked))
8571 (t (format "{%d(+%d) more}"
8572 gnus-tmp-unread-and-unticked
8573 gnus-tmp-unselected))))
8575 (if (and gnus-current-headers
8576 (vectorp gnus-current-headers))
8577 (mail-header-subject gnus-current-headers) ""))
8579 gnus-tmp-header);; passed as argument to any user-format-funcs
8580 (setq mode-string (eval mformat))
8581 (setq max-len (max 4 (if gnus-mode-non-string-length
8583 gnus-mode-non-string-length)
8584 (length mode-string))))
8585 ;; We might have to chop a bit of the string off...
8586 (when (> (length mode-string) max-len)
8588 (concat (gnus-truncate-string mode-string (- max-len 3))
8590 ;; Pad the mode string a bit.
8591 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
8592 ;; Update the mode line.
8593 (setq mode-line-buffer-identification (list mode-string))
8594 (set-buffer-modified-p t))))
8596 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
8597 "Go through the HEADERS list and add all Xrefs to a hash table.
8598 The resulting hash table is returned, or nil if no Xrefs were found."
8599 (let* ((from-method (gnus-find-method-for-group from-newsgroup))
8600 (virtual (gnus-virtual-group-p from-newsgroup))
8601 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
8602 (xref-hashtb (make-vector 63 0))
8603 start group entry number xrefs header)
8605 (setq header (pop headers))
8606 (when (and (setq xrefs (mail-header-xref header))
8607 (not (memq (setq number (mail-header-number header))
8610 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
8611 (setq start (match-end 0))
8612 (setq group (concat prefix (substring xrefs (match-beginning 1)
8615 (string-to-int (substring xrefs (match-beginning 2)
8617 (if (setq entry (gnus-gethash group xref-hashtb))
8618 (setcdr entry (cons number (cdr entry)))
8619 (gnus-sethash group (cons number nil) xref-hashtb)))))
8620 (and start xref-hashtb)))
8622 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
8623 "Look through all the headers and mark the Xrefs as read."
8624 (let ((virtual (gnus-virtual-group-p from-newsgroup))
8625 name entry info xref-hashtb idlist method nth4)
8627 (set-buffer gnus-group-buffer)
8628 (when (setq xref-hashtb
8629 (gnus-create-xref-hashtb from-newsgroup headers unreads))
8632 (unless (string= from-newsgroup (setq name (symbol-name group)))
8633 (setq idlist (symbol-value group))
8634 ;; Dead groups are not updated.
8636 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
8638 (if (stringp (setq nth4 (gnus-info-method info)))
8639 (setq nth4 (gnus-server-to-method nth4))))
8640 ;; Only do the xrefs if the group has the same
8641 ;; select method as the group we have just read.
8642 (or (gnus-methods-equal-p
8643 nth4 (gnus-find-method-for-group from-newsgroup))
8645 (equal nth4 (setq method (gnus-find-method-for-group
8647 (and (equal (car nth4) (car method))
8648 (equal (nth 1 nth4) (nth 1 method))))
8649 gnus-use-cross-reference
8650 (or (not (eq gnus-use-cross-reference t))
8652 ;; Only do cross-references on subscribed
8653 ;; groups, if that is what is wanted.
8654 (<= (gnus-info-level info) gnus-level-subscribed))
8655 (gnus-group-make-articles-read name idlist))))
8658 (defun gnus-group-make-articles-read (group articles)
8660 (entry (gnus-gethash group gnus-newsrc-hashtb))
8661 (info (nth 2 entry))
8662 (active (gnus-active group))
8664 ;; First peel off all illegal article numbers.
8666 (let ((ids articles)
8670 (if (and first (> id (cdr active)))
8672 ;; We'll end up in this situation in one particular
8673 ;; obscure situation. If you re-scan a group and get
8674 ;; a new article that is cross-posted to a different
8675 ;; group that has not been re-scanned, you might get
8676 ;; crossposted article that has a higher number than
8677 ;; Gnus believes possible. So we re-activate this
8678 ;; group as well. This might mean doing the
8679 ;; crossposting thingy will *increase* the number
8680 ;; of articles in some groups. Tsk, tsk.
8681 (setq active (or (gnus-activate-group group) active))))
8682 (if (or (> id (cdr active))
8683 (< id (car active)))
8684 (setq articles (delq id articles)))
8685 (setq ids (cdr ids)))))
8686 ;; If the read list is nil, we init it.
8688 (null (gnus-info-read info))
8690 (gnus-info-set-read info (cons 1 (1- (car active)))))
8691 ;; Then we add the read articles to the range.
8696 (gnus-info-read info) (setq articles (sort articles '<)))))
8697 ;; Then we have to re-compute how many unread
8698 ;; articles there are in this group.
8703 (setq num (- (1+ (cdr active)) (car active))))
8704 ((not (listp (cdr range)))
8705 (setq num (- (cdr active) (- (1+ (cdr range))
8709 (if (numberp (car range))
8711 (setq num (+ num (- (1+ (cdr (car range)))
8712 (car (car range))))))
8713 (setq range (cdr range)))
8714 (setq num (- (cdr active) num))))
8715 ;; Update the number of unread articles.
8717 ;; Update the group buffer.
8718 (gnus-group-update-group group t)))))
8720 (defun gnus-methods-equal-p (m1 m2)
8721 (let ((m1 (or m1 gnus-select-method))
8722 (m2 (or m2 gnus-select-method)))
8724 (and (eq (car m1) (car m2))
8725 (or (not (memq 'address (assoc (symbol-name (car m1))
8726 gnus-valid-select-methods)))
8727 (equal (nth 1 m1) (nth 1 m2)))))))
8729 (defsubst gnus-header-value ()
8730 (buffer-substring (match-end 0) (gnus-point-at-eol)))
8732 (defvar gnus-newsgroup-none-id 0)
8734 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
8735 (let ((cur nntp-server-buffer)
8738 (save-excursion (set-buffer gnus-summary-buffer)
8739 gnus-newsgroup-dependencies)))
8740 headers id id-dep ref-dep end ref)
8742 (set-buffer nntp-server-buffer)
8743 (let ((case-fold-search t)
8744 in-reply-to header number p lines)
8745 (goto-char (point-min))
8746 ;; Search to the beginning of the next header. Error messages
8747 ;; do not begin with 2 or 3.
8748 (while (re-search-forward "^[23][0-9]+ " nil t)
8751 ;; This implementation of this function, with nine
8752 ;; search-forwards instead of the one re-search-forward and
8753 ;; a case (which basically was the old function) is actually
8754 ;; about twice as fast, even though it looks messier. You
8755 ;; can't have everything, I guess. Speed and elegance
8756 ;; doesn't always go hand in hand.
8765 (narrow-to-region (point)
8766 (or (and (search-forward "\n.\n" nil t)
8772 (if (search-forward "\nsubject: " nil t)
8773 (gnus-header-value) "(none)"))
8777 (if (search-forward "\nfrom: " nil t)
8778 (gnus-header-value) "(nobody)"))
8782 (if (search-forward "\ndate: " nil t)
8783 (gnus-header-value) ""))
8787 (if (search-forward "\nmessage-id: " nil t)
8788 (setq id (gnus-header-value))
8789 ;; If there was no message-id, we just fake one to make
8790 ;; subsequent routines simpler.
8791 (setq id (concat "none+"
8793 (setq gnus-newsgroup-none-id
8794 (1+ gnus-newsgroup-none-id)))))))
8798 (if (search-forward "\nreferences: " nil t)
8801 (setq end (match-end 0))
8808 (search-backward ">" end t)
8811 (search-backward "<" end t)
8813 ;; Get the references from the in-reply-to header if there
8814 ;; were no references and the in-reply-to header looks
8816 (if (and (search-forward "\nin-reply-to: " nil t)
8817 (setq in-reply-to (gnus-header-value))
8818 (string-match "<[^>]+>" in-reply-to))
8820 (setq ref (substring in-reply-to (match-beginning 0)
8822 (setq ref (downcase ref))))
8829 (if (search-forward "\nlines: " nil t)
8830 (if (numberp (setq lines (read cur)))
8836 (and (search-forward "\nxref: " nil t)
8837 (gnus-header-value)))))
8838 (if (and gnus-nocem-hashtb
8839 (gnus-gethash id gnus-nocem-hashtb))
8842 ;; We do the threading while we read the headers. The
8843 ;; message-id and the last reference are both entered into
8844 ;; the same hash table. Some tippy-toeing around has to be
8845 ;; done in case an article has arrived before the article
8846 ;; which it refers to.
8847 (if (boundp (setq id-dep (intern (downcase id) dependencies)))
8848 (if (and (car (symbol-value id-dep))
8850 ;; An article with this Message-ID has already
8851 ;; been seen, so we ignore this one, except we add
8852 ;; any additional Xrefs (in case the two articles
8853 ;; came from different servers).
8855 (mail-header-set-xref
8856 (car (symbol-value id-dep))
8857 (concat (or (mail-header-xref
8858 (car (symbol-value id-dep))) "")
8859 (or (mail-header-xref header) "")))
8861 (setcar (symbol-value id-dep) header))
8862 (set id-dep (list header))))
8864 (if (boundp (setq ref-dep (intern ref dependencies)))
8865 (setcdr (symbol-value ref-dep)
8866 (nconc (cdr (symbol-value ref-dep))
8867 (list (symbol-value id-dep))))
8868 (set ref-dep (list nil (symbol-value id-dep))))
8869 (setq headers (cons header headers)))
8870 (goto-char (point-max))
8872 (nreverse headers)))))
8874 ;; The following macros and functions were written by Felix Lee
8875 ;; <flee@cse.psu.edu>.
8877 (defmacro gnus-nov-read-integer ()
8879 (if (= (following-char) ?\t)
8881 (let ((num (condition-case nil (read buffer) (error nil))))
8882 (if (numberp num) num 0)))
8883 (or (eobp) (forward-char 1))))
8885 (defmacro gnus-nov-skip-field ()
8886 '(search-forward "\t" eol 'move))
8888 (defmacro gnus-nov-field ()
8889 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
8891 ;; Goes through the xover lines and returns a list of vectors
8892 (defun gnus-get-newsgroup-headers-xover (sequence &optional force-new)
8893 "Parse the news overview data in the server buffer, and return a
8894 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
8895 ;; Get the Xref when the users reads the articles since most/some
8896 ;; NNTP servers do not include Xrefs when using XOVER.
8897 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
8898 (let ((cur nntp-server-buffer)
8899 (dependencies gnus-newsgroup-dependencies)
8900 number headers header)
8902 (set-buffer nntp-server-buffer)
8903 ;; Allow the user to mangle the headers before parsing them.
8904 (run-hooks 'gnus-parse-headers-hook)
8905 ;; Allow the user to mangle the headers before parsing them.
8906 (run-hooks 'gnus-parse-headers-hook)
8907 (goto-char (point-min))
8908 (while (and sequence (not (eobp)))
8909 (setq number (read cur))
8910 (while (and sequence (< (car sequence) number))
8911 (setq sequence (cdr sequence)))
8913 (eq number (car sequence))
8915 (setq sequence (cdr sequence))
8917 (inline (gnus-nov-parse-line
8918 number dependencies force-new)))
8919 (setq headers (cons header headers)))))
8921 (setq headers (nreverse headers)))
8924 ;; This function has to be called with point after the article number
8925 ;; on the beginning of the line.
8926 (defun gnus-nov-parse-line (number dependencies &optional force-new)
8928 (eol (gnus-point-at-eol))
8929 (buffer (current-buffer))
8930 header ref id id-dep ref-dep)
8932 ;; overview: [num subject from date id refs chars lines misc]
8933 (narrow-to-region (point) eol)
8934 (or (eobp) (forward-char))
8940 (gnus-nov-field) ; subject
8941 (gnus-nov-field) ; from
8942 (gnus-nov-field) ; date
8943 (setq id (or (gnus-nov-field)
8946 (setq none (1+ none)))))) ; id
8949 (let ((beg (point)))
8950 (search-forward "\t" eol)
8951 (if (search-backward ">" beg t)
8957 (search-backward "<" beg t)
8960 (gnus-nov-field)) ; refs
8961 (gnus-nov-read-integer) ; chars
8962 (gnus-nov-read-integer) ; lines
8963 (if (= (following-char) ?\n)
8965 (gnus-nov-field)) ; misc
8969 (gnus-message 4 "Strange nov line")
8975 ;; We build the thread tree.
8977 (if (and gnus-nocem-hashtb
8978 (gnus-gethash id gnus-nocem-hashtb))
8981 (if (boundp (setq id-dep (intern (downcase id) dependencies)))
8982 (if (and (car (symbol-value id-dep))
8984 ;; An article with this Message-ID has already been seen,
8985 ;; so we ignore this one, except we add any additional
8986 ;; Xrefs (in case the two articles came from different
8989 (mail-header-set-xref
8990 (car (symbol-value id-dep))
8991 (concat (or (mail-header-xref
8992 (car (symbol-value id-dep))) "")
8993 (or (mail-header-xref header) "")))
8995 (setcar (symbol-value id-dep) header))
8996 (set id-dep (list header)))))
8999 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
9000 (setcdr (symbol-value ref-dep)
9001 (nconc (cdr (symbol-value ref-dep))
9002 (list (symbol-value id-dep))))
9003 (set ref-dep (list nil (symbol-value id-dep))))))
9006 (defun gnus-article-get-xrefs ()
9007 "Fill in the Xref value in `gnus-current-headers', if necessary.
9008 This is meant to be called in `gnus-article-internal-prepare-hook'."
9009 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
9010 gnus-current-headers)))
9011 (or (not gnus-use-cross-reference)
9013 (and (mail-header-xref headers)
9014 (not (string= (mail-header-xref headers) "")))
9015 (let ((case-fold-search t)
9018 (nnheader-narrow-to-headers)
9019 (goto-char (point-min))
9020 (if (or (and (eq (downcase (following-char)) ?x)
9021 (looking-at "Xref:"))
9022 (search-forward "\nXref:" nil t))
9024 (goto-char (1+ (match-end 0)))
9025 (setq xref (buffer-substring (point)
9026 (progn (end-of-line) (point))))
9027 (mail-header-set-xref headers xref))))))))
9029 (defun gnus-summary-insert-subject (id)
9030 "Find article ID and insert the summary line for that article."
9031 (let ((header (gnus-read-header id))
9032 (number (and (numberp id) id)))
9034 ;; Rebuild the thread that this article is part of and go to the
9035 ;; article we have fetched.
9036 (gnus-rebuild-thread (mail-header-id header))
9037 (gnus-summary-goto-subject (setq number (mail-header-number header))))
9038 (when (and (numberp number)
9040 ;; We have to update the boundaries even if we can't fetch the
9041 ;; article if ID is a number -- so that the next `P' or `N'
9042 ;; command will fetch the previous (or next) article even
9043 ;; if the one we tried to fetch this time has been canceled.
9044 (and (> number gnus-newsgroup-end)
9045 (setq gnus-newsgroup-end number))
9046 (and (< number gnus-newsgroup-begin)
9047 (setq gnus-newsgroup-begin number))
9048 (setq gnus-newsgroup-unselected
9049 (delq number gnus-newsgroup-unselected)))
9050 ;; Report back a success?
9051 (and header number)))
9053 (defun gnus-summary-work-articles (n)
9054 "Return a list of articles to be worked upon. The prefix argument,
9055 the list of process marked articles, and the current article will be
9056 taken into consideration."
9058 ((and n (numberp n))
9059 ;; A numerical prefix has been given.
9060 (let ((backward (< n 0))
9066 (push (setq article (gnus-summary-article-number))
9069 (gnus-summary-find-prev nil article)
9070 (gnus-summary-find-next nil article)))
9072 (nreverse articles)))
9073 ((and (boundp 'transient-mark-mode)
9076 ;; Work on the region between point and mark.
9077 (let ((max (max (point) (mark)))
9080 (goto-char (min (point) (mark)))
9083 (push (setq article (gnus-summary-article-number)) articles)
9084 (gnus-summary-find-next nil article)
9086 (nreverse articles))))
9087 (gnus-newsgroup-processable
9088 ;; There are process-marked articles present.
9089 (reverse gnus-newsgroup-processable))
9091 ;; Just return the current article.
9092 (list (gnus-summary-article-number)))))
9094 (defun gnus-summary-search-group (&optional backward use-level)
9095 "Search for next unread newsgroup.
9096 If optional argument BACKWARD is non-nil, search backward instead."
9098 (set-buffer gnus-group-buffer)
9099 (if (gnus-group-search-forward
9100 backward nil (if use-level (gnus-group-group-level) nil))
9101 (gnus-group-group-name))))
9103 (defun gnus-summary-best-group (&optional exclude-group)
9104 "Find the name of the best unread group.
9105 If EXCLUDE-GROUP, do not go to this group."
9107 (set-buffer gnus-group-buffer)
9109 (gnus-group-best-unread-group exclude-group))))
9111 (defun gnus-summary-find-next (&optional unread article backward)
9112 (if backward (gnus-summary-find-prev)
9113 (let* ((article (or article (gnus-summary-article-number)))
9114 (arts (gnus-data-find-list article))
9116 (when (or (not gnus-summary-check-current)
9118 (not (gnus-data-unread-p (car arts))))
9119 (setq arts (cdr arts)))
9124 (when (gnus-data-unread-p (car arts))
9125 (setq result (car arts)
9127 (setq arts (cdr arts)))
9130 (goto-char (gnus-data-pos result))
9131 (gnus-data-number result)))))
9133 (defun gnus-summary-find-prev (&optional unread article)
9134 (let* ((article (or article (gnus-summary-article-number)))
9135 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
9137 (when (or (not gnus-summary-check-current)
9139 (not (gnus-data-unread-p (car arts))))
9140 (setq arts (cdr arts)))
9145 (and (gnus-data-unread-p (car arts))
9146 (setq result (car arts)
9148 (setq arts (cdr arts)))
9152 (goto-char (gnus-data-pos result))
9153 (gnus-data-number result)))))
9155 (defun gnus-summary-find-subject (subject &optional unread backward article)
9156 (let* ((simp-subject (gnus-simplify-subject-fully subject))
9157 (article (or article (gnus-summary-article-number)))
9158 (articles (gnus-data-list backward))
9159 (arts (gnus-data-find-list article articles))
9161 (when (or (not gnus-summary-check-current)
9163 (not (gnus-data-unread-p (car arts))))
9164 (setq arts (cdr arts)))
9166 (and (or (not unread)
9167 (gnus-data-unread-p (car arts)))
9168 (vectorp (gnus-data-header (car arts)))
9170 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
9171 (setq result (car arts)
9173 (setq arts (cdr arts)))
9175 (goto-char (gnus-data-pos result))
9176 (gnus-data-number result))))
9178 (defun gnus-summary-search-forward (&optional unread subject backward)
9180 (gnus-summary-find-subject subject unread backward))
9182 (gnus-summary-find-prev unread))
9184 (gnus-summary-find-next unread))))
9186 (defun gnus-recenter (&optional n)
9187 "Center point in window and redisplay frame.
9188 Also do horizontal recentering."
9190 (gnus-horizontal-recenter)
9193 (defun gnus-summary-recenter ()
9194 "Center point in the summary window.
9195 If `gnus-auto-center-summary' is nil, or the article buffer isn't
9196 displayed, no centering will be performed."
9197 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
9198 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
9199 (let* ((top (cond ((< (window-height) 4) 0)
9200 ((< (window-height) 7) 1)
9202 (height (1- (window-height)))
9203 (bottom (save-excursion (goto-char (point-max))
9204 (forward-line (- height))
9206 (window (get-buffer-window (current-buffer))))
9207 ;; The user has to want it.
9208 (when gnus-auto-center-summary
9209 (when (get-buffer-window gnus-article-buffer)
9210 ;; Only do recentering when the article buffer is displayed,
9211 ;; Set the window start to either `bottom', which is the biggest
9212 ;; possible valid number, or the second line from the top,
9213 ;; whichever is the least.
9215 window (min bottom (save-excursion
9216 (forward-line (- top)) (point)))))
9217 ;; Do horizontal recentering while we're at it.
9218 (when (get-buffer-window (current-buffer) t)
9219 (let ((selected (selected-window)))
9220 (select-window (get-buffer-window (current-buffer) t))
9221 (gnus-summary-position-point)
9222 (gnus-horizontal-recenter)
9223 (select-window selected))))))
9225 (defun gnus-horizontal-recenter ()
9226 "Recenter the current buffer horizontally."
9227 (if (< (current-column) (/ (window-width) 2))
9228 (set-window-hscroll (get-buffer-window (current-buffer) t) 0)
9229 (let* ((orig (point))
9230 (end (window-end (get-buffer-window (current-buffer) t)))
9232 ;; Find the longest line currently displayed in the window.
9233 (goto-char (window-start))
9234 (while (and (not (eobp))
9237 (setq max (max max (current-column)))
9240 ;; Scroll horizontally to center (sort of) the point.
9241 (if (> max (window-width))
9243 (get-buffer-window (current-buffer) t)
9244 (min (- (current-column) (/ (window-width) 3))
9245 (+ 2 (- max (window-width)))))
9246 (set-window-hscroll (get-buffer-window (current-buffer) t) 0))
9249 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
9250 (defun gnus-short-group-name (group &optional levels)
9251 "Collapse GROUP name LEVELS."
9258 (while (string-match "\\." group skip)
9259 (setq skip (match-end 0)
9262 (if (string-match ":" group)
9263 (setq foreign (substring group 0 (match-end 0))
9264 group (substring group (match-end 0))))
9266 (if (and (string-match "\\." group)
9267 (> levels (- gnus-group-uncollapsed-levels 1)))
9268 (setq name (concat name (substring group 0 1))
9269 group (substring group (match-end 0))
9271 name (concat name "."))
9272 (setq name (concat foreign name group)
9276 (defun gnus-summary-jump-to-group (newsgroup)
9277 "Move point to NEWSGROUP in group mode buffer."
9278 ;; Keep update point of group mode buffer if visible.
9279 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
9280 (save-window-excursion
9281 ;; Take care of tree window mode.
9282 (if (get-buffer-window gnus-group-buffer)
9283 (pop-to-buffer gnus-group-buffer))
9284 (gnus-group-jump-to-group newsgroup))
9286 ;; Take care of tree window mode.
9287 (if (get-buffer-window gnus-group-buffer)
9288 (pop-to-buffer gnus-group-buffer)
9289 (set-buffer gnus-group-buffer))
9290 (gnus-group-jump-to-group newsgroup))))
9292 ;; This function returns a list of article numbers based on the
9293 ;; difference between the ranges of read articles in this group and
9294 ;; the range of active articles.
9295 (defun gnus-list-of-unread-articles (group)
9296 (let* ((read (gnus-info-read (gnus-get-info group)))
9297 (active (gnus-active group))
9300 ;; If none are read, then all are unread.
9302 (setq first (car active))
9303 ;; If the range of read articles is a single range, then the
9304 ;; first unread article is the article after the last read
9305 ;; article. Sounds logical, doesn't it?
9306 (if (not (listp (cdr read)))
9307 (setq first (1+ (cdr read)))
9308 ;; `read' is a list of ranges.
9309 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
9310 (car (car read)))) 1)
9314 (while (< first nlast)
9315 (setq unread (cons first unread))
9316 (setq first (1+ first))))
9317 (setq first (1+ (if (atom (car read)) (car read) (cdr (car read)))))
9318 (setq nlast (if (atom (car (cdr read)))
9320 (car (car (cdr read)))))
9321 (setq read (cdr read)))))
9322 ;; And add the last unread articles.
9323 (while (<= first last)
9324 (setq unread (cons first unread))
9325 (setq first (1+ first)))
9326 ;; Return the list of unread articles.
9329 (defun gnus-list-of-read-articles (group)
9330 "Return a list of unread, unticked and non-dormant articles."
9331 (let* ((info (gnus-get-info group))
9332 (marked (gnus-info-marks info))
9333 (active (gnus-active group)))
9335 (gnus-set-difference
9336 (gnus-sorted-complement
9337 (gnus-uncompress-range active)
9338 (gnus-list-of-unread-articles group))
9340 (gnus-uncompress-range (cdr (assq 'dormant marked)))
9341 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
9343 ;; Various summary commands
9345 (defun gnus-summary-universal-argument (arg)
9346 "Perform any operation on all articles that are process/prefixed."
9348 (gnus-set-global-variables)
9349 (let ((articles (gnus-summary-work-articles arg))
9356 (substitute-command-keys
9357 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
9361 (message "Undefined key")
9365 (gnus-summary-goto-subject (setq article (pop articles)))
9366 (command-execute func)
9367 (gnus-summary-remove-process-mark article)))))
9368 (gnus-summary-position-point))
9370 (defun gnus-summary-toggle-truncation (&optional arg)
9371 "Toggle truncation of summary lines.
9372 With arg, turn line truncation on iff arg is positive."
9374 (setq truncate-lines
9375 (if (null arg) (not truncate-lines)
9376 (> (prefix-numeric-value arg) 0)))
9379 (defun gnus-summary-reselect-current-group (&optional all rescan)
9380 "Exit and then reselect the current newsgroup.
9381 The prefix argument ALL means to select all articles."
9383 (gnus-set-global-variables)
9384 (let ((current-subject (gnus-summary-article-number))
9385 (group gnus-newsgroup-name))
9386 (setq gnus-newsgroup-begin nil)
9388 ;; We have to adjust the point of group mode buffer because the
9389 ;; current point was moved to the next unread newsgroup by
9391 (gnus-summary-jump-to-group group)
9394 (gnus-group-get-new-news-this-group 1)))
9395 (gnus-group-read-group all t)
9396 (gnus-summary-goto-subject current-subject)))
9398 (defun gnus-summary-rescan-group (&optional all)
9399 "Exit the newsgroup, ask for new articles, and select the newsgroup."
9401 (gnus-summary-reselect-current-group all t))
9403 (defun gnus-summary-update-info ()
9404 (let* ((group gnus-newsgroup-name))
9405 (when gnus-newsgroup-kill-headers
9406 (setq gnus-newsgroup-killed
9407 (gnus-compress-sequence
9409 (gnus-set-sorted-intersection
9410 (gnus-uncompress-range gnus-newsgroup-killed)
9411 (setq gnus-newsgroup-unselected
9412 (sort gnus-newsgroup-unselected '<)))
9413 (setq gnus-newsgroup-unreads
9414 (sort gnus-newsgroup-unreads '<))) t)))
9415 (unless (listp (cdr gnus-newsgroup-killed))
9416 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
9417 (let ((headers gnus-newsgroup-headers))
9418 (gnus-close-group group)
9419 (run-hooks 'gnus-exit-group-hook)
9420 (unless gnus-save-score
9421 (setq gnus-newsgroup-scored nil))
9422 ;; Set the new ranges of read articles.
9423 (gnus-update-read-articles
9424 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
9425 ;; Set the current article marks.
9427 ;; Do the cross-ref thing.
9428 (when gnus-use-cross-reference
9429 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
9430 ;; Do adaptive scoring, and possibly save score files.
9431 (when gnus-newsgroup-adaptive
9432 (gnus-score-adaptive))
9433 (when gnus-use-scoring
9435 ;; Do not switch windows but change the buffer to work.
9436 (set-buffer gnus-group-buffer)
9437 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
9438 (gnus-group-update-group group)))))
9440 (defun gnus-summary-exit (&optional temporary)
9441 "Exit reading current newsgroup, and then return to group selection mode.
9442 gnus-exit-group-hook is called with no arguments if that value is non-nil."
9444 (gnus-set-global-variables)
9445 (gnus-kill-save-kill-buffer)
9446 (let* ((group gnus-newsgroup-name)
9447 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
9449 (buf (current-buffer)))
9450 (run-hooks 'gnus-summary-prepare-exit-hook)
9451 (when gnus-use-cache
9452 (gnus-cache-possibly-remove-articles)
9453 (gnus-cache-save-buffers))
9454 (when gnus-use-trees
9455 (gnus-tree-close group))
9456 ;; Make all changes in this group permanent.
9457 (gnus-summary-update-info)
9458 ;; Make sure where I was, and go to next newsgroup.
9459 (set-buffer gnus-group-buffer)
9461 (gnus-group-jump-to-group group)
9462 (gnus-group-next-unread-group 1))
9463 (run-hooks 'gnus-summary-exit-hook)
9466 ;; If we have several article buffers, we kill them at exit.
9467 (unless gnus-single-article-buffer
9468 (gnus-kill-buffer gnus-article-buffer)
9469 (gnus-kill-buffer gnus-original-article-buffer))
9471 (if (not gnus-kill-summary-on-exit)
9472 (gnus-deaden-summary)
9473 ;; We set all buffer-local variables to nil. It is unclear why
9474 ;; this is needed, but if we don't, buffer-local variables are
9475 ;; not garbage-collected, it seems. This would the lead to en
9476 ;; ever-growing Emacs.
9477 (gnus-summary-clear-local-variables)
9478 (when (get-buffer gnus-article-buffer)
9479 (bury-buffer gnus-article-buffer))
9480 ;; We clear the global counterparts of the buffer-local
9481 ;; variables as well, just to be on the safe side.
9482 (gnus-configure-windows 'group 'force)
9483 (gnus-summary-clear-local-variables)
9484 ;; Return to group mode buffer.
9485 (if (eq mode 'gnus-summary-mode)
9486 (gnus-kill-buffer buf)))
9487 (setq gnus-current-select-method gnus-select-method)
9488 (pop-to-buffer gnus-group-buffer)
9489 ;; Clear the current group name.
9490 (if (not quit-config)
9492 (gnus-group-jump-to-group group)
9493 (gnus-group-next-unread-group 1)
9494 (gnus-configure-windows 'group 'force))
9495 (if (not (buffer-name (car quit-config)))
9496 (gnus-configure-windows 'group 'force)
9497 (set-buffer (car quit-config))
9498 (and (eq major-mode 'gnus-summary-mode)
9499 (gnus-set-global-variables))
9500 (gnus-configure-windows (cdr quit-config))))
9502 (setq gnus-newsgroup-name nil)))))
9504 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
9505 (defun gnus-summary-exit-no-update (&optional no-questions)
9506 "Quit reading current newsgroup without updating read article info."
9508 (gnus-set-global-variables)
9509 (let* ((group gnus-newsgroup-name)
9510 (quit-config (gnus-group-quit-config group)))
9511 (when (or no-questions
9513 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
9514 ;; If we have several article buffers, we kill them at exit.
9515 (unless gnus-single-article-buffer
9516 (gnus-kill-buffer gnus-article-buffer)
9517 (gnus-kill-buffer gnus-original-article-buffer))
9518 (if (not gnus-kill-summary-on-exit)
9519 (gnus-deaden-summary)
9520 (gnus-close-group group)
9521 (gnus-summary-clear-local-variables)
9522 (set-buffer gnus-group-buffer)
9523 (gnus-summary-clear-local-variables)
9524 (when (get-buffer gnus-summary-buffer)
9525 (kill-buffer gnus-summary-buffer)))
9526 (when gnus-use-trees
9527 (gnus-tree-close group))
9528 (when (get-buffer gnus-article-buffer)
9529 (bury-buffer gnus-article-buffer))
9530 ;; Return to the group buffer.
9531 (gnus-configure-windows 'group 'force)
9532 ;; Clear the current group name.
9533 (setq gnus-newsgroup-name nil)
9534 (when (equal (gnus-group-group-name) group)
9535 (gnus-group-next-unread-group 1))
9537 (if (not (buffer-name (car quit-config)))
9538 (gnus-configure-windows 'group 'force)
9539 (set-buffer (car quit-config))
9540 (when (eq major-mode 'gnus-summary-mode)
9541 (gnus-set-global-variables))
9542 (gnus-configure-windows (cdr quit-config)))))))
9546 (defvar gnus-dead-summary-mode-map nil)
9548 (if gnus-dead-summary-mode-map
9550 (setq gnus-dead-summary-mode-map (make-keymap))
9551 (suppress-keymap gnus-dead-summary-mode-map)
9552 (substitute-key-definition
9553 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
9554 (let ((keys '("\C-d" "\r" "\177")))
9556 (define-key gnus-dead-summary-mode-map
9557 (pop keys) 'gnus-summary-wake-up-the-dead))))
9559 (defvar gnus-dead-summary-mode nil
9560 "Minor mode for Gnus summary buffers.")
9562 (defun gnus-dead-summary-mode (&optional arg)
9563 "Minor mode for Gnus summary buffers."
9565 (when (eq major-mode 'gnus-summary-mode)
9566 (make-local-variable 'gnus-dead-summary-mode)
9567 (setq gnus-dead-summary-mode
9568 (if (null arg) (not gnus-dead-summary-mode)
9569 (> (prefix-numeric-value arg) 0)))
9570 (when gnus-dead-summary-mode
9571 (unless (assq 'gnus-dead-summary-mode minor-mode-alist)
9572 (push '(gnus-dead-summary-mode " Dead") minor-mode-alist))
9573 (unless (assq 'gnus-dead-summary-mode minor-mode-map-alist)
9574 (push (cons 'gnus-dead-summary-mode gnus-dead-summary-mode-map)
9575 minor-mode-map-alist)))))
9577 (defun gnus-deaden-summary ()
9578 "Make the current summary buffer into a dead summary buffer."
9579 ;; Kill any previous dead summary buffer.
9580 (when (and gnus-dead-summary
9581 (buffer-name gnus-dead-summary))
9583 (set-buffer gnus-dead-summary)
9584 (when gnus-dead-summary-mode
9585 (kill-buffer (current-buffer)))))
9586 ;; Make this the current dead summary.
9587 (setq gnus-dead-summary (current-buffer))
9588 (gnus-dead-summary-mode 1)
9589 (let ((name (buffer-name)))
9590 (when (string-match "Summary" name)
9592 (concat (substring name 0 (match-beginning 0)) "Dead "
9593 (substring name (match-beginning 0))) t))))
9595 (defun gnus-kill-or-deaden-summary (buffer)
9596 "Kill or deaden the summary BUFFER."
9597 (cond (gnus-kill-summary-on-exit
9598 (when (and gnus-use-trees
9599 (and (get-buffer buffer)
9600 (buffer-name (get-buffer buffer))))
9602 (set-buffer (get-buffer buffer))
9603 (gnus-tree-close gnus-newsgroup-name)))
9604 (gnus-kill-buffer buffer))
9605 ((and (get-buffer buffer)
9606 (buffer-name (get-buffer buffer)))
9609 (gnus-deaden-summary)))))
9611 (defun gnus-summary-wake-up-the-dead (&rest args)
9612 "Wake up the dead summary buffer."
9614 (gnus-dead-summary-mode -1)
9615 (let ((name (buffer-name)))
9616 (when (string-match "Dead " name)
9618 (concat (substring name 0 (match-beginning 0))
9619 (substring name (match-end 0))) t)))
9620 (gnus-message 3 "This dead summary is now alive again"))
9622 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
9623 (defun gnus-summary-fetch-faq (&optional faq-dir)
9624 "Fetch the FAQ for the current group.
9625 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
9629 (if current-prefix-arg
9631 "Faq dir: " (and (listp gnus-group-faq-directory)
9632 gnus-group-faq-directory)))))
9633 (let (gnus-faq-buffer)
9634 (and (setq gnus-faq-buffer
9635 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
9636 (gnus-configure-windows 'summary-faq))))
9638 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
9639 (defun gnus-summary-describe-group (&optional force)
9640 "Describe the current newsgroup."
9642 (gnus-group-describe-group force gnus-newsgroup-name))
9644 (defun gnus-summary-describe-briefly ()
9645 "Describe summary mode commands briefly."
9648 (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")))
9650 ;; Walking around group mode buffer from summary mode.
9652 (defun gnus-summary-next-group (&optional no-article target-group backward)
9653 "Exit current newsgroup and then select next unread newsgroup.
9654 If prefix argument NO-ARTICLE is non-nil, no article is selected
9655 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
9656 previous group instead."
9658 (gnus-set-global-variables)
9659 (let ((current-group gnus-newsgroup-name)
9660 (current-buffer (current-buffer))
9662 ;; First we semi-exit this group to update Xrefs and all variables.
9663 ;; We can't do a real exit, because the window conf must remain
9664 ;; the same in case the user is prompted for info, and we don't
9665 ;; want the window conf to change before that...
9666 (gnus-summary-exit t)
9667 (while (not entered)
9668 ;; Then we find what group we are supposed to enter.
9669 (set-buffer gnus-group-buffer)
9670 (gnus-group-jump-to-group current-group)
9673 (if (eq gnus-keep-same-level 'best)
9674 (gnus-summary-best-group gnus-newsgroup-name)
9675 (gnus-summary-search-group backward gnus-keep-same-level))))
9676 (if (not target-group)
9677 ;; There are no further groups, so we return to the group
9680 (gnus-message 5 "Returning to the group buffer")
9682 (set-buffer current-buffer)
9683 (gnus-summary-exit))
9684 ;; We try to enter the target group.
9685 (gnus-group-jump-to-group target-group)
9686 (let ((unreads (gnus-group-group-unread)))
9687 (if (and (or (eq t unreads)
9688 (and unreads (not (zerop unreads))))
9689 (gnus-summary-read-group
9690 target-group nil no-article current-buffer))
9692 (setq current-group target-group
9693 target-group nil)))))))
9695 (defun gnus-summary-prev-group (&optional no-article)
9696 "Exit current newsgroup and then select previous unread newsgroup.
9697 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
9699 (gnus-summary-next-group no-article nil t))
9701 ;; Walking around summary lines.
9703 (defun gnus-summary-first-subject (&optional unread)
9704 "Go to the first unread subject.
9705 If UNREAD is non-nil, go to the first unread article.
9706 Returns the article selected or nil if there are no unread articles."
9711 ((null gnus-newsgroup-data)
9712 (gnus-message 3 "No articles in the group")
9714 ;; Pick the first article.
9716 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
9717 (gnus-data-number (car gnus-newsgroup-data)))
9718 ;; No unread articles.
9719 ((null gnus-newsgroup-unreads)
9720 (gnus-message 3 "No more unread articles")
9722 ;; Find the first unread article.
9724 (let ((data gnus-newsgroup-data))
9726 (not (gnus-data-unread-p (car data))))
9727 (setq data (cdr data)))
9730 (goto-char (gnus-data-pos (car data)))
9731 (gnus-data-number (car data)))))))
9732 (gnus-summary-position-point)))
9734 (defun gnus-summary-next-subject (n &optional unread dont-display)
9735 "Go to next N'th summary line.
9736 If N is negative, go to the previous N'th subject line.
9737 If UNREAD is non-nil, only unread articles are selected.
9738 The difference between N and the actual number of steps taken is
9741 (let ((backward (< n 0))
9745 (gnus-summary-find-prev unread)
9746 (gnus-summary-find-next unread)))
9748 (if (/= 0 n) (gnus-message 7 "No more%s articles"
9749 (if unread " unread" "")))
9752 (gnus-summary-recenter)
9753 (gnus-summary-position-point)))
9756 (defun gnus-summary-next-unread-subject (n)
9757 "Go to next N'th unread summary line."
9759 (gnus-summary-next-subject n t))
9761 (defun gnus-summary-prev-subject (n &optional unread)
9762 "Go to previous N'th summary line.
9763 If optional argument UNREAD is non-nil, only unread article is selected."
9765 (gnus-summary-next-subject (- n) unread))
9767 (defun gnus-summary-prev-unread-subject (n)
9768 "Go to previous N'th unread summary line."
9770 (gnus-summary-next-subject (- n) t))
9772 (defun gnus-summary-goto-subject (article &optional force silent)
9773 "Go the subject line of ARTICLE.
9774 If FORCE, also allow jumping to articles not currently shown."
9776 (data (gnus-data-find article)))
9777 ;; We read in the article if we have to.
9780 (gnus-summary-insert-subject article)
9781 (setq data (gnus-data-find article)))
9786 (gnus-message 3 "Can't find article %d" article))
9788 (goto-char (gnus-data-pos data))
9791 ;; Walking around summary lines with displaying articles.
9793 (defun gnus-summary-expand-window (&optional arg)
9794 "Make the summary buffer take up the entire Emacs frame.
9795 Given a prefix, will force an `article' buffer configuration."
9797 (gnus-set-global-variables)
9799 (gnus-configure-windows 'article 'force)
9800 (gnus-configure-windows 'summary 'force)))
9802 (defun gnus-summary-display-article (article &optional all-header)
9803 "Display ARTICLE in article buffer."
9804 (gnus-set-global-variables)
9808 (if gnus-summary-display-article-function
9809 (funcall gnus-summary-display-article-function article all-header)
9810 (gnus-article-prepare article all-header))
9811 (run-hooks 'gnus-select-article-hook)
9812 (gnus-summary-recenter)
9813 (gnus-summary-goto-subject article)
9814 (when gnus-use-trees
9815 (gnus-possibly-generate-tree article)
9816 (gnus-highlight-selected-tree article))
9817 ;; Successfully display article.
9818 (gnus-article-set-window-start
9819 (cdr (assq article gnus-newsgroup-bookmarks)))
9822 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
9823 "Select the current article.
9824 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
9825 non-nil, the article will be re-fetched even if it already present in
9826 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
9828 (let ((article (or article (gnus-summary-article-number)))
9829 (all-headers (not (not all-headers))) ;Must be T or NIL.
9830 gnus-summary-display-article-function
9833 (gnus-summary-article-pseudo-p article)
9834 (error "This is a pseudo-article."))
9837 (set-buffer gnus-summary-buffer)
9838 (if (or (and gnus-single-article-buffer
9839 (or (null gnus-current-article)
9840 (null gnus-article-current)
9841 (null (get-buffer gnus-article-buffer))
9842 (not (eq article (cdr gnus-article-current)))
9843 (not (equal (car gnus-article-current)
9844 gnus-newsgroup-name))))
9845 (and (not gnus-single-article-buffer)
9846 (null gnus-current-article))
9848 ;; The requested article is different from the current article.
9850 (gnus-summary-display-article article all-headers)
9852 (if (or all-headers gnus-show-all-headers)
9853 (gnus-article-show-all-headers))
9856 (gnus-article-set-window-start
9857 (cdr (assq article gnus-newsgroup-bookmarks)))))))
9859 (defun gnus-summary-set-current-mark (&optional current-mark)
9860 "Obsolete function."
9863 (defun gnus-summary-next-article (&optional unread subject backward push)
9864 "Select the next article.
9865 If UNREAD, only unread articles are selected.
9866 If SUBJECT, only articles with SUBJECT are selected.
9867 If BACKWARD, the previous article is selected instead of the next."
9869 (gnus-set-global-variables)
9872 ;; Is there such an article?
9873 ((and (gnus-summary-search-forward unread subject backward)
9874 (or (gnus-summary-display-article (gnus-summary-article-number))
9875 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
9876 (gnus-summary-position-point))
9877 ;; If not, we try the first unread, if that is wanted.
9879 gnus-auto-select-same
9880 (or (gnus-summary-first-unread-article)
9881 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
9882 (gnus-summary-position-point)
9883 (gnus-message 6 "Wrapped"))
9884 ;; Try to get next/previous article not displayed in this group.
9885 ((and gnus-auto-extend-newsgroup
9886 (not unread) (not subject))
9887 (gnus-summary-goto-article
9888 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
9890 ;; Go to next/previous group.
9892 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
9893 (gnus-summary-jump-to-group gnus-newsgroup-name))
9894 (let ((cmd last-command-char)
9896 (if (eq gnus-keep-same-level 'best)
9897 (gnus-summary-best-group gnus-newsgroup-name)
9898 (gnus-summary-search-group backward gnus-keep-same-level))))
9899 ;; For some reason, the group window gets selected. We change
9901 (select-window (get-buffer-window (current-buffer)))
9902 ;; Select next unread newsgroup automagically.
9904 ((not gnus-auto-select-next)
9905 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
9906 ((or (eq gnus-auto-select-next 'quietly)
9907 (and (eq gnus-auto-select-next 'slightly-quietly)
9909 (and (eq gnus-auto-select-next 'almost-quietly)
9910 (gnus-summary-last-article-p)))
9912 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
9914 (gnus-message 7 "No more%s articles (%s)..."
9915 (if unread " unread" "")
9916 (if group (concat "selecting " group)
9918 (gnus-summary-next-group nil group backward)))
9920 (gnus-summary-walk-group-buffer
9921 gnus-newsgroup-name cmd unread backward))))))))
9923 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward)
9924 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
9925 (?\C-p (gnus-group-prev-unread-group 1))))
9926 keve key group ended)
9928 (set-buffer gnus-group-buffer)
9929 (gnus-summary-jump-to-group from-group)
9931 (if (eq gnus-keep-same-level 'best)
9932 (gnus-summary-best-group gnus-newsgroup-name)
9933 (gnus-summary-search-group backward gnus-keep-same-level))))
9936 5 "No more%s articles%s" (if unread " unread" "")
9938 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
9939 (format " (Type %s for %s [%s])"
9940 (single-key-description cmd) group
9941 (car (gnus-gethash group gnus-newsrc-hashtb)))
9942 (format " (Type %s to exit %s)"
9943 (single-key-description cmd)
9944 gnus-newsgroup-name)))
9945 ;; Confirm auto selection.
9946 (setq key (car (setq keve (gnus-read-event-char))))
9949 ((assq key keystrokes)
9950 (let ((obuf (current-buffer)))
9951 (switch-to-buffer gnus-group-buffer)
9953 (gnus-group-jump-to-group group))
9954 (eval (car (cdr (assq key keystrokes))))
9955 (setq group (gnus-group-group-name))
9956 (switch-to-buffer obuf))
9960 (gnus-ephemeral-group-p gnus-newsgroup-name))
9962 (gnus-summary-next-group nil group backward)))
9964 (push (cdr keve) unread-command-events))))))
9966 (defun gnus-read-event-char ()
9967 "Get the next event."
9968 (let ((event (read-event)))
9969 (cons (and (numberp event) event) event)))
9971 (defun gnus-summary-next-unread-article ()
9972 "Select unread article after current one."
9974 (gnus-summary-next-article t (and gnus-auto-select-same
9975 (gnus-summary-article-subject))))
9977 (defun gnus-summary-prev-article (&optional unread subject)
9978 "Select the article after the current one.
9979 If UNREAD is non-nil, only unread articles are selected."
9981 (gnus-summary-next-article unread subject t))
9983 (defun gnus-summary-prev-unread-article ()
9984 "Select unred article before current one."
9986 (gnus-summary-prev-article t (and gnus-auto-select-same
9987 (gnus-summary-article-subject))))
9989 (defun gnus-summary-next-page (&optional lines circular)
9990 "Show next page of the selected article.
9991 If at the end of the current article, select the next article.
9992 LINES says how many lines should be scrolled up.
9994 If CIRCULAR is non-nil, go to the start of the article instead of
9995 selecting the next article when reaching the end of the current
9998 (setq gnus-summary-buffer (current-buffer))
9999 (gnus-set-global-variables)
10000 (let ((article (gnus-summary-article-number))
10002 (gnus-configure-windows 'article)
10003 (if (or (null gnus-current-article)
10004 (null gnus-article-current)
10005 (/= article (cdr gnus-article-current))
10006 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10007 ;; Selected subject is different from current article's.
10008 (gnus-summary-display-article article)
10009 (gnus-eval-in-buffer-window
10010 gnus-article-buffer
10011 (setq endp (gnus-article-next-page lines)))
10014 (gnus-summary-beginning-of-article))
10016 (gnus-message 3 "End of message"))
10018 (if (eq gnus-summary-goto-unread 'always)
10019 (gnus-summary-next-article)
10020 (gnus-summary-next-unread-article))))))
10021 (gnus-summary-recenter)
10022 (gnus-summary-position-point)))
10024 (defun gnus-summary-prev-page (&optional lines)
10025 "Show previous page of selected article.
10026 Argument LINES specifies lines to be scrolled down."
10028 (gnus-set-global-variables)
10029 (let ((article (gnus-summary-article-number)))
10030 (gnus-configure-windows 'article)
10031 (if (or (null gnus-current-article)
10032 (null gnus-article-current)
10033 (/= article (cdr gnus-article-current))
10034 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10035 ;; Selected subject is different from current article's.
10036 (gnus-summary-display-article article)
10037 (gnus-summary-recenter)
10038 (gnus-eval-in-buffer-window gnus-article-buffer
10039 (gnus-article-prev-page lines))))
10040 (gnus-summary-position-point))
10042 (defun gnus-summary-scroll-up (lines)
10043 "Scroll up (or down) one line current article.
10044 Argument LINES specifies lines to be scrolled up (or down if negative)."
10046 (gnus-set-global-variables)
10047 (gnus-configure-windows 'article)
10048 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
10049 (gnus-eval-in-buffer-window
10050 gnus-article-buffer
10052 (if (gnus-article-next-page lines)
10053 (gnus-message 3 "End of message")))
10055 (gnus-article-prev-page (- lines))))))
10056 (gnus-summary-recenter)
10057 (gnus-summary-position-point))
10059 (defun gnus-summary-next-same-subject ()
10060 "Select next article which has the same subject as current one."
10062 (gnus-set-global-variables)
10063 (gnus-summary-next-article nil (gnus-summary-article-subject)))
10065 (defun gnus-summary-prev-same-subject ()
10066 "Select previous article which has the same subject as current one."
10068 (gnus-set-global-variables)
10069 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
10071 (defun gnus-summary-next-unread-same-subject ()
10072 "Select next unread article which has the same subject as current one."
10074 (gnus-set-global-variables)
10075 (gnus-summary-next-article t (gnus-summary-article-subject)))
10077 (defun gnus-summary-prev-unread-same-subject ()
10078 "Select previous unread article which has the same subject as current one."
10080 (gnus-set-global-variables)
10081 (gnus-summary-prev-article t (gnus-summary-article-subject)))
10083 (defun gnus-summary-first-unread-article ()
10084 "Select the first unread article.
10085 Return nil if there are no unread articles."
10087 (gnus-set-global-variables)
10089 (if (gnus-summary-first-subject t)
10091 (gnus-summary-show-thread)
10092 (gnus-summary-first-subject t)
10093 (gnus-summary-display-article (gnus-summary-article-number))))
10094 (gnus-summary-position-point)))
10096 (defun gnus-summary-best-unread-article ()
10097 "Select the unread article with the highest score."
10099 (gnus-set-global-variables)
10100 (let ((best -1000000)
10101 (data gnus-newsgroup-data)
10104 (and (gnus-data-unread-p (car data))
10106 (gnus-summary-article-score (gnus-data-number (car data))))
10109 article (gnus-data-number (car data))))
10110 (setq data (cdr data)))
10112 (gnus-summary-goto-article article)
10113 (error "No unread articles"))
10114 (gnus-summary-position-point)))
10116 (defun gnus-summary-last-subject ()
10117 "Go to the last displayed subject line in the group."
10118 (let ((article (gnus-data-number (car (gnus-data-list t)))))
10120 (gnus-summary-goto-subject article))))
10122 (defun gnus-summary-goto-article (article &optional all-headers force)
10123 "Fetch ARTICLE and display it if it exists.
10124 If ALL-HEADERS is non-nil, no header lines are hidden."
10130 (mapcar (lambda (number) (list (int-to-string number)))
10131 gnus-newsgroup-limit)))
10135 (if (gnus-summary-goto-subject article force)
10136 (gnus-summary-display-article article all-headers)
10137 (gnus-message 4 "Couldn't go to article %s" article) nil)
10138 (gnus-summary-position-point)))
10140 (defun gnus-summary-goto-last-article ()
10141 "Go to the previously read article."
10144 (and gnus-last-article
10145 (gnus-summary-goto-article gnus-last-article))
10146 (gnus-summary-position-point)))
10148 (defun gnus-summary-pop-article (number)
10149 "Pop one article off the history and go to the previous.
10150 NUMBER articles will be popped off."
10153 (setq gnus-newsgroup-history
10154 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
10156 (gnus-summary-goto-article (car to))
10157 (error "Article history empty")))
10158 (gnus-summary-position-point))
10160 ;; Summary commands and functions for limiting the summary buffer.
10162 (defun gnus-summary-limit-to-articles (n)
10163 "Limit the summary buffer to the next N articles.
10164 If not given a prefix, use the process marked articles instead."
10166 (gnus-set-global-variables)
10168 (let ((articles (gnus-summary-work-articles n)))
10169 (setq gnus-newsgroup-processable nil)
10170 (gnus-summary-limit articles))
10171 (gnus-summary-position-point)))
10173 (defun gnus-summary-pop-limit (&optional total)
10174 "Restore the previous limit.
10175 If given a prefix, remove all limits."
10177 (gnus-set-global-variables)
10179 (setq gnus-newsgroup-limits
10180 (list (mapcar (lambda (h) (mail-header-number h))
10181 gnus-newsgroup-headers))))
10182 (unless gnus-newsgroup-limits
10183 (error "No limit to pop"))
10185 (gnus-summary-limit nil 'pop)
10186 (gnus-summary-position-point)))
10188 (defun gnus-summary-limit-to-subject (subject &optional header)
10189 "Limit the summary buffer to articles that have subjects that match a regexp."
10190 (interactive "sRegexp: ")
10192 (setq header "subject"))
10193 (when (not (equal "" subject))
10195 (let ((articles (gnus-summary-find-matching "subject" subject 'all)))
10196 (or articles (error "Found no matches for \"%s\"" subject))
10197 (gnus-summary-limit articles))
10198 (gnus-summary-position-point))))
10200 (defun gnus-summary-limit-to-author (from)
10201 "Limit the summary buffer to articles that have authors that match a regexp."
10202 (interactive "sRegexp: ")
10203 (gnus-summary-limit-to-subject from "from"))
10205 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10207 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10209 (defun gnus-summary-limit-to-unread (&optional all)
10210 "Limit the summary buffer to articles that are not marked as read.
10211 If ALL is non-nil, limit strictly to unread articles."
10214 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
10215 (gnus-summary-limit-to-marks
10216 ;; Concat all the marks that say that an article is read and have
10218 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
10219 gnus-killed-mark gnus-kill-file-mark
10220 gnus-low-score-mark gnus-expirable-mark
10221 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark)
10224 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10225 (make-obsolete 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10227 (defun gnus-summary-limit-to-marks (marks &optional reverse)
10228 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
10229 If REVERSE, limit the summary buffer to articles that are not marked
10230 with MARKS. MARKS can either be a string of marks or a list of marks.
10231 Returns how many articles were removed."
10232 (interactive "sMarks: ")
10233 (gnus-set-global-variables)
10235 (let ((data gnus-newsgroup-data)
10236 (marks (if (listp marks) marks
10237 (append marks nil))) ; Transform to list.
10240 (and (if reverse (not (memq (gnus-data-mark (car data)) marks))
10241 (memq (gnus-data-mark (car data)) marks))
10242 (setq articles (cons (gnus-data-number (car data)) articles)))
10243 (setq data (cdr data)))
10244 (gnus-summary-limit articles))
10245 (gnus-summary-position-point)))
10247 (defun gnus-summary-limit-to-score (&optional score)
10248 "Limit to articles with score at or above SCORE."
10250 (gnus-set-global-variables)
10251 (setq score (if score
10252 (prefix-numeric-value score)
10253 (or gnus-summary-default-score 0)))
10254 (let ((data gnus-newsgroup-data)
10257 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
10259 (push (gnus-data-number (car data)) articles))
10260 (setq data (cdr data)))
10262 (gnus-summary-limit articles)
10263 (gnus-summary-position-point))))
10265 (defun gnus-summary-limit-include-dormant ()
10266 "Display all the hidden articles that are marked as dormant."
10268 (gnus-set-global-variables)
10269 (or gnus-newsgroup-dormant
10270 (error "There are no dormant articles in this group"))
10272 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
10273 (gnus-summary-position-point)))
10275 (defun gnus-summary-limit-exclude-dormant ()
10276 "Hide all dormant articles."
10278 (gnus-set-global-variables)
10280 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
10281 (gnus-summary-position-point)))
10283 (defun gnus-summary-limit-exclude-childless-dormant ()
10284 "Hide all dormant articles that have no children."
10286 (gnus-set-global-variables)
10287 (let ((data gnus-newsgroup-data)
10289 ;; Find all articles that are either not dormant or have
10292 (and (or (not (= (gnus-data-mark (car data)) gnus-dormant-mark))
10293 (gnus-article-parent-p (gnus-data-number (car data))))
10294 (setq articles (cons (gnus-data-number (car data))
10296 (setq data (cdr data)))
10297 ;; Do the limiting.
10299 (gnus-summary-limit articles)
10300 (gnus-summary-position-point))))
10302 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
10303 "Mark all unread excluded articles as read.
10304 If ALL, mark even excluded ticked and dormants as read."
10306 (let ((articles (gnus-sorted-complement
10308 (mapcar (lambda (h) (mail-header-number h))
10309 gnus-newsgroup-headers)
10311 (sort gnus-newsgroup-limit '<)))
10313 (setq gnus-newsgroup-unreads nil)
10315 (setq gnus-newsgroup-dormant nil
10316 gnus-newsgroup-marked nil
10317 gnus-newsgroup-reads
10319 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
10320 gnus-newsgroup-reads))
10321 (while (setq article (pop articles))
10322 (unless (or (memq article gnus-newsgroup-dormant)
10323 (memq article gnus-newsgroup-marked))
10324 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
10327 (defun gnus-summary-limit (articles &optional pop)
10329 ;; We pop the previous limit off the stack and use that.
10330 (setq articles (car gnus-newsgroup-limits)
10331 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
10332 ;; We use the new limit, so we push the old limit on the stack.
10333 (setq gnus-newsgroup-limits
10334 (cons gnus-newsgroup-limit gnus-newsgroup-limits)))
10336 (setq gnus-newsgroup-limit articles)
10337 (let ((total (length gnus-newsgroup-data))
10338 (data (gnus-data-find-list (gnus-summary-article-number)))
10340 ;; This will do all the work of generating the new summary buffer
10341 ;; according to the new limit.
10342 (gnus-summary-prepare)
10343 ;; Hide any threads, possibly.
10344 (and gnus-show-threads
10345 gnus-thread-hide-subtree
10346 (gnus-summary-hide-all-threads))
10347 ;; Try to return to the article you were at, or one in the
10350 ;; We try to find some article after the current one.
10352 (and (gnus-summary-goto-subject
10353 (gnus-data-number (car data)) nil t)
10356 (setq data (cdr data))))
10358 ;; If there is no data, that means that we were after the last
10359 ;; article. The same goes when we can't find any articles
10360 ;; after the current one.
10362 (goto-char (point-max))
10363 (gnus-summary-find-prev)))
10364 ;; We return how many articles were removed from the summary
10365 ;; buffer as a result of the new limit.
10366 (- total (length gnus-newsgroup-data))))
10368 (defsubst gnus-cut-thread (thread)
10369 "Go forwards in the thread until we find an article that we want to display."
10370 (if (eq gnus-fetch-old-headers 'some)
10372 (memq (mail-header-number (car thread))
10373 gnus-newsgroup-ancient)
10374 (<= (length (cdr thread)) 1))
10375 (setq thread (cadr thread)))
10377 (memq (mail-header-number (car thread)) gnus-newsgroup-sparse)
10378 (= (length (cdr thread)) 1))
10379 (setq thread (cadr thread))))
10382 (defun gnus-cut-threads (threads)
10383 "Cut off all uninteresting articles from the beginning of threads."
10384 (when (or (eq gnus-fetch-old-headers 'some)
10385 (eq gnus-build-sparse-threads 'some)
10386 (eq gnus-build-sparse-threads 'more))
10387 (let ((th threads))
10389 (setcar th (gnus-cut-thread (car th)))
10390 (setq th (cdr th)))))
10393 (defun gnus-summary-initial-limit (&optional show-if-empty)
10394 "Figure out what the initial limit is supposed to be on group entry.
10395 This entails weeding out unwanted dormants, low-scored articles,
10396 fetch-old-headers verbiage, and so on."
10397 ;; Most groups have nothing to remove.
10398 (if (or gnus-inhibit-limiting
10399 (and (null gnus-newsgroup-dormant)
10400 (not (eq gnus-fetch-old-headers 'some))
10401 (null gnus-summary-expunge-below)
10402 (not (eq gnus-build-sparse-threads 'some))
10403 (not (eq gnus-build-sparse-threads 'more))
10404 (null gnus-thread-expunge-below)))
10406 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10407 (setq gnus-newsgroup-limit nil)
10410 (unless (car (symbol-value node))
10411 ;; These threads have no parents -- they are roots.
10412 (let ((nodes (cdr (symbol-value node)))
10415 (if (and gnus-thread-expunge-below
10416 (< (gnus-thread-total-score (car nodes))
10417 gnus-thread-expunge-below))
10418 (gnus-expunge-thread (pop nodes))
10419 (setq thread (pop nodes))
10420 (gnus-summary-limit-children thread))))))
10421 gnus-newsgroup-dependencies)
10422 ;; If this limitation resulted in an empty group, we might
10423 ;; pop the previous limit and use it instead.
10424 (when (and (not gnus-newsgroup-limit)
10426 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
10427 gnus-newsgroup-limit))
10429 (defun gnus-summary-limit-children (thread)
10430 "Return 1 if this subthread is visible and 0 if it is not."
10431 ;; First we get the number of visible children to this thread. This
10432 ;; is done by recursing down the thread using this function, so this
10433 ;; will really go down to a leaf article first, before slowly
10434 ;; working its way up towards the root.
10438 (apply '+ (mapcar 'gnus-summary-limit-children
10441 (number (mail-header-number (car thread)))
10444 ;; If this article is dormant and has absolutely no visible
10445 ;; children, then this article isn't visible.
10446 (and (memq number gnus-newsgroup-dormant)
10448 ;; If this is a "fetch-old-headered" and there is only one
10449 ;; visible child (or less), then we don't want this article.
10450 (and (eq gnus-fetch-old-headers 'some)
10451 (memq number gnus-newsgroup-ancient)
10453 ;; If this is a sparsely inserted article with no children,
10454 ;; we don't want it.
10455 (and (eq gnus-build-sparse-threads 'some)
10456 (memq number gnus-newsgroup-sparse)
10458 ;; If we use expunging, and this article is really
10459 ;; low-scored, then we don't want this article.
10460 (when (and gnus-summary-expunge-below
10462 (or (cdr (assq number gnus-newsgroup-scored))
10463 gnus-summary-default-score))
10464 gnus-summary-expunge-below))
10465 ;; We increase the expunge-tally here, but that has
10466 ;; nothing to do with the limits, really.
10467 (incf gnus-newsgroup-expunged-tally)
10468 ;; We also mark as read here, if that's wanted.
10469 (when (and gnus-summary-mark-below
10470 (< score gnus-summary-mark-below))
10471 (setq gnus-newsgroup-unreads
10472 (delq number gnus-newsgroup-unreads))
10473 (if gnus-newsgroup-auto-expire
10474 (push number gnus-newsgroup-expirable)
10475 (push (cons number gnus-low-score-mark)
10476 gnus-newsgroup-reads)))
10478 ;; Nope, invisible article.
10480 ;; Ok, this article is to be visible, so we add it to the limit
10482 (setq gnus-newsgroup-limit (cons number gnus-newsgroup-limit))
10485 (defun gnus-expunge-thread (thread)
10486 "Mark all articles in THREAD as read."
10487 (let* ((number (mail-header-number (car thread))))
10488 (incf gnus-newsgroup-expunged-tally)
10489 ;; We also mark as read here, if that's wanted.
10490 (setq gnus-newsgroup-unreads
10491 (delq number gnus-newsgroup-unreads))
10492 (if gnus-newsgroup-auto-expire
10493 (push number gnus-newsgroup-expirable)
10494 (push (cons number gnus-low-score-mark)
10495 gnus-newsgroup-reads)))
10496 ;; Go recursively through all subthreads.
10497 (mapcar 'gnus-expunge-thread (cdr thread)))
10499 ;; Summary article oriented commands
10501 (defun gnus-summary-refer-parent-article (n)
10502 "Refer parent article N times.
10503 The difference between N and the number of articles fetched is returned."
10505 (gnus-set-global-variables)
10509 (let* ((header (gnus-summary-article-header))
10511 ;; If we try to find the parent of the currently
10512 ;; displayed article, then we take a look at the actual
10513 ;; References header, since this is slightly more
10514 ;; reliable than the References field we got from the
10516 (if (and (eq (mail-header-number header)
10517 (cdr gnus-article-current))
10518 (equal gnus-newsgroup-name
10519 (car gnus-article-current)))
10521 (set-buffer gnus-original-article-buffer)
10522 (nnheader-narrow-to-headers)
10524 (mail-fetch-field "references")
10526 ;; It's not the current article, so we take a bet on
10527 ;; the value we got from the server.
10528 (mail-header-references header))))
10530 (or (gnus-summary-refer-article (gnus-parent-id ref))
10531 (gnus-message 1 "Couldn't find parent"))
10532 (gnus-message 1 "No references in article %d"
10533 (gnus-summary-article-number))
10536 (gnus-summary-position-point)
10539 (defun gnus-summary-refer-references ()
10540 "Fetch all articles mentioned in the References header.
10541 Return how many articles were fetched."
10543 (gnus-set-global-variables)
10544 (let ((ref (mail-header-references (gnus-summary-article-header)))
10545 (current (gnus-summary-article-number))
10547 ;; For each Message-ID in the References header...
10548 (while (string-match "<[^>]*>" ref)
10550 ;; ... fetch that article.
10551 (gnus-summary-refer-article
10552 (prog1 (match-string 0 ref)
10553 (setq ref (substring ref (match-end 0))))))
10554 (gnus-summary-goto-subject current)
10555 (gnus-summary-position-point)
10558 (defun gnus-summary-refer-article (message-id)
10559 "Fetch an article specified by MESSAGE-ID."
10560 (interactive "sMessage-ID: ")
10561 (when (and (stringp message-id)
10562 (not (zerop (length message-id))))
10563 ;; Construct the correct Message-ID if necessary.
10564 ;; Suggested by tale@pawl.rpi.edu.
10565 (unless (string-match "^<" message-id)
10566 (setq message-id (concat "<" message-id)))
10567 (unless (string-match ">$" message-id)
10568 (setq message-id (concat message-id ">")))
10569 (let ((header (car (gnus-gethash (downcase message-id)
10570 gnus-newsgroup-dependencies))))
10572 ;; The article is present in the buffer, to we just go to it.
10573 (gnus-summary-goto-article (mail-header-number header) nil t)
10574 ;; We fetch the article
10575 (let ((gnus-override-method gnus-refer-article-method)
10577 ;; Start the special refer-article method, if necessary.
10578 (when gnus-refer-article-method
10579 (gnus-check-server gnus-refer-article-method))
10580 ;; Fetch the header, and display the article.
10581 (if (setq number (gnus-summary-insert-subject message-id))
10582 (gnus-summary-select-article nil nil nil number)
10583 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
10585 (defun gnus-summary-enter-digest-group (&optional force)
10586 "Enter a digest group based on the current article."
10588 (gnus-set-global-variables)
10589 (gnus-summary-select-article)
10590 (let ((name (format "%s-%d"
10591 (gnus-group-prefixed-name
10592 gnus-newsgroup-name (list 'nndoc ""))
10593 gnus-current-article))
10594 (ogroup gnus-newsgroup-name)
10595 (case-fold-search t)
10596 (buf (current-buffer))
10599 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
10600 (insert-buffer-substring gnus-original-article-buffer)
10602 (goto-char (point-min))
10603 (or (search-forward "\n\n" nil t) (point)))
10604 (goto-char (point-min))
10605 (delete-matching-lines "^\\(Path\\):")
10608 (if (gnus-group-read-ephemeral-group
10609 name `(nndoc ,name (nndoc-address
10611 (nndoc-article-type ,(if force 'digest 'guess))) t)
10612 ;; Make all postings to this group go to the parent group.
10613 (setcdr (nthcdr 4 (gnus-get-info name))
10614 (list (list (cons 'to-group ogroup))))
10615 ;; Couldn't select this doc group.
10616 (switch-to-buffer buf)
10617 (gnus-set-global-variables)
10618 (gnus-configure-windows 'summary)
10619 (gnus-message 3 "Article couldn't be entered?"))
10620 (kill-buffer dig))))
10622 (defun gnus-summary-isearch-article (&optional regexp-p)
10623 "Do incremental search forward on the current article.
10624 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
10626 (gnus-set-global-variables)
10627 (gnus-summary-select-article)
10628 (gnus-configure-windows 'article)
10629 (gnus-eval-in-buffer-window
10630 gnus-article-buffer
10631 (goto-char (point-min))
10632 (isearch-forward regexp-p)))
10634 (defun gnus-summary-search-article-forward (regexp &optional backward)
10635 "Search for an article containing REGEXP forward.
10636 If BACKWARD, search backward instead."
10639 (format "Search article %s (regexp%s): "
10640 (if current-prefix-arg "backward" "forward")
10641 (if gnus-last-search-regexp
10642 (concat ", default " gnus-last-search-regexp)
10644 current-prefix-arg))
10645 (gnus-set-global-variables)
10646 (if (string-equal regexp "")
10647 (setq regexp (or gnus-last-search-regexp ""))
10648 (setq gnus-last-search-regexp regexp))
10649 (if (gnus-summary-search-article regexp backward)
10650 (gnus-article-set-window-start
10651 (cdr (assq (gnus-summary-article-number) gnus-newsgroup-bookmarks)))
10652 (error "Search failed: \"%s\"" regexp)))
10654 (defun gnus-summary-search-article-backward (regexp)
10655 "Search for an article containing REGEXP backward."
10658 (format "Search article backward (regexp%s): "
10659 (if gnus-last-search-regexp
10660 (concat ", default " gnus-last-search-regexp)
10662 (gnus-summary-search-article-forward regexp 'backward))
10664 (defun gnus-summary-search-article (regexp &optional backward)
10665 "Search for an article containing REGEXP.
10666 Optional argument BACKWARD means do search for backward.
10667 gnus-select-article-hook is not called during the search."
10668 (let ((gnus-select-article-hook nil) ;Disable hook.
10669 (gnus-mark-article-hook nil) ;Inhibit marking as read.
10672 (function re-search-backward) (function re-search-forward)))
10675 ;; Hidden thread subtrees must be searched for ,too.
10676 (gnus-summary-show-all-threads)
10677 ;; First of all, search current article.
10678 ;; We don't want to read article again from NNTP server nor reset
10680 (gnus-summary-select-article)
10681 (gnus-message 9 "Searching article: %d..." gnus-current-article)
10682 (setq last gnus-current-article)
10683 (gnus-eval-in-buffer-window
10684 gnus-article-buffer
10687 ;; Begin search from current point.
10688 (setq found (funcall re-search regexp nil t))))
10689 ;; Then search next articles.
10690 (while (and (not found)
10691 (gnus-summary-display-article
10692 (if backward (gnus-summary-find-prev)
10693 (gnus-summary-find-next))))
10694 (gnus-message 9 "Searching article: %d..." gnus-current-article)
10695 (gnus-eval-in-buffer-window
10696 gnus-article-buffer
10699 (goto-char (if backward (point-max) (point-min)))
10700 (setq found (funcall re-search regexp nil t)))))
10702 ;; Adjust article pointer.
10703 (or (eq last gnus-current-article)
10704 (setq gnus-last-article last))
10705 ;; Return T if found such article.
10708 (defun gnus-summary-find-matching (header regexp &optional backward unread
10710 "Return a list of all articles that match REGEXP on HEADER.
10711 The search stars on the current article and goes forwards unless
10712 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
10713 If UNREAD is non-nil, only unread articles will
10714 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
10715 in the comparisons."
10716 (let ((data (if (eq backward 'all) gnus-newsgroup-data
10717 (gnus-data-find-list
10718 (gnus-summary-article-number) (gnus-data-list backward))))
10719 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
10720 (case-fold-search (not not-case-fold))
10722 (or (fboundp (intern (concat "mail-header-" header)))
10723 (error "%s is not a valid header" header))
10725 (setq d (car data))
10726 (and (or (not unread) ; We want all articles...
10727 (gnus-data-unread-p d)) ; Or just unreads.
10728 (vectorp (gnus-data-header d)) ; It's not a pseudo.
10729 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
10730 (setq articles (cons (gnus-data-number d) articles))) ; Success!
10731 (setq data (cdr data)))
10732 (nreverse articles)))
10734 (defun gnus-summary-execute-command (header regexp command &optional backward)
10735 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
10736 If HEADER is an empty string (or nil), the match is done on the entire
10737 article. If BACKWARD (the prefix) is non-nil, search backward instead."
10739 (list (let ((completion-ignore-case t))
10742 (mapcar (lambda (string) (list string))
10743 '("Number" "Subject" "From" "Lines" "Date"
10744 "Message-ID" "Xref" "References" "Body"))
10745 nil 'require-match))
10746 (read-string "Regexp: ")
10747 (read-key-sequence "Command: ")
10748 current-prefix-arg))
10749 (when (equal header "Body")
10751 (gnus-set-global-variables)
10752 ;; Hidden thread subtrees must be searched as well.
10753 (gnus-summary-show-all-threads)
10754 ;; We don't want to change current point nor window configuration.
10756 (save-window-excursion
10757 (gnus-message 6 "Executing %s..." (key-description command))
10758 ;; We'd like to execute COMMAND interactively so as to give arguments.
10759 (gnus-execute header regexp
10760 `(lambda () (call-interactively ',(key-binding command)))
10762 (gnus-message 6 "Executing %s...done" (key-description command)))))
10764 (defun gnus-summary-beginning-of-article ()
10765 "Scroll the article back to the beginning."
10767 (gnus-set-global-variables)
10768 (gnus-summary-select-article)
10769 (gnus-configure-windows 'article)
10770 (gnus-eval-in-buffer-window
10771 gnus-article-buffer
10773 (goto-char (point-min))
10774 (and gnus-break-pages (gnus-narrow-to-page))))
10776 (defun gnus-summary-end-of-article ()
10777 "Scroll to the end of the article."
10779 (gnus-set-global-variables)
10780 (gnus-summary-select-article)
10781 (gnus-configure-windows 'article)
10782 (gnus-eval-in-buffer-window
10783 gnus-article-buffer
10785 (goto-char (point-max))
10787 (and gnus-break-pages (gnus-narrow-to-page))))
10789 (defun gnus-summary-show-article (&optional arg)
10790 "Force re-fetching of the current article.
10791 If ARG (the prefix) is non-nil, show the raw article without any
10792 article massaging functions being run."
10794 (gnus-set-global-variables)
10796 ;; Select the article the normal way.
10797 (gnus-summary-select-article nil 'force)
10798 ;; Bind the article treatment functions to nil.
10799 (let ((gnus-have-all-headers t)
10800 gnus-article-display-hook
10801 gnus-article-prepare-hook
10803 (gnus-summary-select-article nil 'force)))
10804 ; (gnus-configure-windows 'article)
10805 (gnus-summary-position-point))
10807 (defun gnus-summary-verbose-headers (&optional arg)
10808 "Toggle permanent full header display.
10809 If ARG is a positive number, turn header display on.
10810 If ARG is a negative number, turn header display off."
10812 (gnus-set-global-variables)
10813 (gnus-summary-toggle-header arg)
10814 (setq gnus-show-all-headers
10815 (cond ((or (not (numberp arg))
10817 (not gnus-show-all-headers))
10821 (defun gnus-summary-toggle-header (&optional arg)
10822 "Show the headers if they are hidden, or hide them if they are shown.
10823 If ARG is a positive number, show the entire header.
10824 If ARG is a negative number, hide the unwanted header lines."
10826 (gnus-set-global-variables)
10828 (set-buffer gnus-article-buffer)
10829 (let* ((buffer-read-only nil)
10830 (inhibit-point-motion-hooks t)
10831 (hidden (text-property-any
10832 (goto-char (point-min)) (search-forward "\n\n")
10835 (goto-char (point-min))
10836 (when (search-forward "\n\n" nil t)
10837 (delete-region (point-min) (1- (point))))
10838 (goto-char (point-min))
10840 (set-buffer gnus-original-article-buffer)
10841 (goto-char (point-min))
10842 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
10843 (insert-buffer-substring gnus-original-article-buffer 1 e)
10844 (let ((gnus-inhibit-hiding t))
10845 (run-hooks 'gnus-article-display-hook))
10846 (if (or (not hidden) (and (numberp arg) (< arg 0)))
10847 (gnus-article-hide-headers)))))
10849 (defun gnus-summary-show-all-headers ()
10850 "Make all header lines visible."
10852 (gnus-set-global-variables)
10853 (gnus-article-show-all-headers))
10855 (defun gnus-summary-toggle-mime (&optional arg)
10856 "Toggle MIME processing.
10857 If ARG is a positive number, turn MIME processing on."
10859 (gnus-set-global-variables)
10860 (setq gnus-show-mime
10861 (if (null arg) (not gnus-show-mime)
10862 (> (prefix-numeric-value arg) 0)))
10863 (gnus-summary-select-article t 'force))
10865 (defun gnus-summary-caesar-message (&optional arg)
10866 "Caesar rotate the current article by 13.
10867 The numerical prefix specifies how manu places to rotate each letter
10870 (gnus-set-global-variables)
10871 (gnus-summary-select-article)
10872 (let ((mail-header-separator ""))
10873 (gnus-eval-in-buffer-window
10874 gnus-article-buffer
10877 (let ((start (window-start)))
10878 (news-caesar-buffer-body arg)
10879 (set-window-start (get-buffer-window (current-buffer)) start))))))
10881 (defun gnus-summary-stop-page-breaking ()
10882 "Stop page breaking in the current article."
10884 (gnus-set-global-variables)
10885 (gnus-summary-select-article)
10886 (gnus-eval-in-buffer-window gnus-article-buffer (widen)))
10888 (defun gnus-summary-move-article (&optional n to-newsgroup select-method action)
10889 "Move the current article to a different newsgroup.
10890 If N is a positive number, move the N next articles.
10891 If N is a negative number, move the N previous articles.
10892 If N is nil and any articles have been marked with the process mark,
10893 move those articles instead.
10894 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
10895 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
10896 re-spool using this method.
10898 For this function to work, both the current newsgroup and the
10899 newsgroup that you want to move to have to support the `request-move'
10900 and `request-accept' functions."
10902 (unless action (setq action 'move))
10903 (gnus-set-global-variables)
10904 ;; Check whether the source group supports the required functions.
10905 (cond ((and (eq action 'move)
10906 (not (gnus-check-backend-function
10907 'request-move-article gnus-newsgroup-name)))
10908 (error "The current group does not support article moving"))
10909 ((and (eq action 'crosspost)
10910 (not (gnus-check-backend-function
10911 'request-replace-article gnus-newsgroup-name)))
10912 (error "The current group does not support article editing")))
10913 (let ((articles (gnus-summary-work-articles n))
10914 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
10915 (names '((move "move" "Moving")
10916 (copy "copy" "Copying")
10917 (crosspost "crosspost" "Crossposting")))
10918 (copy-buf (save-excursion
10919 (nnheader-set-temp-buffer " *copy article*")))
10920 art-group to-method new-xref article)
10921 (unless (assq action names)
10922 (error "Unknown action %s" action))
10923 ;; Read the newsgroup name.
10924 (when (and (not to-newsgroup)
10925 (not select-method))
10927 (gnus-read-move-group-name
10928 (cadr (assq action names))
10929 gnus-current-move-group articles prefix))
10930 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
10931 (setq to-method (if select-method (list select-method "")
10932 (gnus-find-method-for-group to-newsgroup)))
10933 ;;(when (equal to-newsgroup gnus-newsgroup-name)
10934 ;;(error "Can't %s to the same group you're already in" action))
10935 ;; Check the method we are to move this article to...
10936 (or (gnus-check-backend-function 'request-accept-article (car to-method))
10937 (error "%s does not support article copying" (car to-method)))
10938 (or (gnus-check-server to-method)
10939 (error "Can't open server %s" (car to-method)))
10940 (gnus-message 6 "%s to %s: %s..."
10941 (caddr (assq action names))
10942 (or select-method to-newsgroup) articles)
10944 (setq article (pop articles))
10948 ;; Move the article.
10950 (gnus-request-move-article
10951 article ; Article to move
10952 gnus-newsgroup-name ; From newsgrouo
10953 (nth 1 (gnus-find-method-for-group
10954 gnus-newsgroup-name)) ; Server
10955 (list 'gnus-request-accept-article
10957 (list 'quote select-method)
10959 (not articles)) ; Accept form
10960 (not articles))) ; Only save nov last time
10961 ;; Copy the article.
10964 (set-buffer copy-buf)
10965 (gnus-request-article-this-buffer article gnus-newsgroup-name)
10966 (gnus-request-accept-article
10967 (if select-method select-method to-newsgroup)
10969 ;; Crosspost the article.
10970 ((eq action 'crosspost)
10971 (let ((xref (mail-header-xref (gnus-summary-article-header article))))
10972 (setq new-xref (concat gnus-newsgroup-name ":" article))
10973 (if (and xref (not (string= xref "")))
10975 (when (string-match "^Xref: " xref)
10976 (setq xref (substring xref (match-end 0))))
10977 (setq new-xref (concat xref " " new-xref)))
10978 (setq new-xref (concat (system-name) " " new-xref)))
10980 (set-buffer copy-buf)
10981 (gnus-request-article-this-buffer article gnus-newsgroup-name)
10982 (nnheader-replace-header "xref" new-xref)
10983 (gnus-request-accept-article
10984 (if select-method select-method to-newsgroup)
10985 (not articles)))))))
10986 (if (not art-group)
10987 (gnus-message 1 "Couldn't %s article %s"
10988 (cadr (assq action names)) article)
10991 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
10993 (gnus-group-prefixed-name
10995 (if select-method (list select-method "")
10996 (gnus-find-method-for-group to-newsgroup)))
10997 gnus-newsrc-hashtb)))
10998 (info (nth 2 entry)))
10999 ;; Update the group that has been moved to.
11001 (memq action '(move copy)))
11002 (unless (memq article gnus-newsgroup-unreads)
11003 (gnus-info-set-read
11004 info (gnus-add-to-range (gnus-info-read info)
11005 (list (cdr art-group)))))
11007 ;; Copy any marks over to the new group.
11008 (let ((marks gnus-article-mark-lists)
11009 (to-article (cdr art-group)))
11011 ;; See whether the article is to be put in the cache.
11012 (when gnus-use-cache
11013 (gnus-cache-possibly-enter-article
11014 (gnus-info-group info) to-article
11015 (let ((header (copy-sequence
11016 (gnus-summary-article-header article))))
11017 (mail-header-set-number header to-article)
11019 (memq article gnus-newsgroup-marked)
11020 (memq article gnus-newsgroup-dormant)
11021 (memq article gnus-newsgroup-unreads)))
11024 (when (memq article (symbol-value
11025 (intern (format "gnus-newsgroup-%s"
11027 (gnus-add-marked-articles
11028 (gnus-info-group info) (cdar marks)
11029 (list to-article) info))
11030 (setq marks (cdr marks)))))
11032 ;; Update the Xref header in this article to point to
11033 ;; the new crossposted article we have just created.
11034 (when (eq action 'crosspost)
11036 (set-buffer copy-buf)
11037 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11038 (nnheader-replace-header
11039 "xref" (concat new-xref " " (gnus-group-prefixed-name
11040 (car art-group) to-method)
11041 ":" (cdr art-group)))
11042 (gnus-request-replace-article
11043 article gnus-newsgroup-name (current-buffer)))))
11045 (gnus-summary-goto-subject article)
11046 (gnus-summary-mark-article article gnus-canceled-mark))
11047 (gnus-summary-remove-process-mark article))
11048 (gnus-kill-buffer copy-buf)
11049 (gnus-summary-position-point)
11050 (gnus-set-mode-line 'summary)))
11052 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
11053 "Move the current article to a different newsgroup.
11054 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11055 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
11056 re-spool using this method."
11058 (gnus-summary-move-article n nil nil 'copy))
11060 (defun gnus-summary-crosspost-article (&optional n)
11061 "Crosspost the current article to some other group."
11063 (gnus-summary-move-article n nil nil 'crosspost))
11065 (defun gnus-summary-respool-article (&optional n respool-method)
11066 "Respool the current article.
11067 The article will be squeezed through the mail spooling process again,
11068 which means that it will be put in some mail newsgroup or other
11069 depending on `nnmail-split-methods'.
11070 If N is a positive number, respool the N next articles.
11071 If N is a negative number, respool the N previous articles.
11072 If N is nil and any articles have been marked with the process mark,
11073 respool those articles instead.
11075 Respooling can be done both from mail groups and \"real\" newsgroups.
11076 In the former case, the articles in question will be moved from the
11077 current group into whatever groups they are destined to. In the
11078 latter case, they will be copied into the relevant groups."
11080 (gnus-set-global-variables)
11081 (let ((respool-methods (gnus-methods-using 'respool))
11083 (symbol-name (car (gnus-find-method-for-group gnus-newsgroup-name)))))
11085 (setq respool-method
11087 "What method do you want to use when respooling? "
11088 respool-methods nil t methname)))
11089 (or (string= respool-method "")
11090 (if (assoc (symbol-name
11091 (car (gnus-find-method-for-group gnus-newsgroup-name)))
11093 (gnus-summary-move-article n nil (intern respool-method))
11094 (gnus-summary-copy-article n nil (intern respool-method))))))
11096 (defun gnus-summary-import-article (file)
11097 "Import a random file into a mail newsgroup."
11098 (interactive "fImport file: ")
11099 (gnus-set-global-variables)
11100 (let ((group gnus-newsgroup-name)
11101 (now (current-time))
11103 (or (gnus-check-backend-function 'request-accept-article group)
11104 (error "%s does not support article importing" group))
11105 (or (file-readable-p file)
11106 (not (file-regular-p file))
11107 (error "Can't read %s" file))
11109 (set-buffer (get-buffer-create " *import file*"))
11110 (buffer-disable-undo (current-buffer))
11112 (insert-file-contents file)
11113 (goto-char (point-min))
11114 (unless (nnheader-article-p)
11115 ;; This doesn't look like an article, so we fudge some headers.
11116 (setq atts (file-attributes file)
11117 lines (count-lines (point-min) (point-max)))
11118 (insert "From: " (read-string "From: ") "\n"
11119 "Subject: " (read-string "Subject: ") "\n"
11120 "Date: " (timezone-make-date-arpa-standard
11121 (current-time-string (nth 5 atts))
11122 (current-time-zone now)
11123 (current-time-zone now)) "\n"
11124 "Message-ID: " (gnus-inews-message-id) "\n"
11125 "Lines: " (int-to-string lines) "\n"
11126 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
11127 (gnus-request-accept-article group t)
11128 (kill-buffer (current-buffer)))))
11130 (defun gnus-summary-expire-articles ()
11131 "Expire all articles that are marked as expirable in the current group."
11133 (gnus-set-global-variables)
11134 (when (gnus-check-backend-function
11135 'request-expire-articles gnus-newsgroup-name)
11136 ;; This backend supports expiry.
11137 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
11138 (expirable (if total
11139 (gnus-list-of-read-articles gnus-newsgroup-name)
11140 (setq gnus-newsgroup-expirable
11141 (sort gnus-newsgroup-expirable '<))))
11142 (expiry-wait (gnus-group-get-parameter
11143 gnus-newsgroup-name 'expiry-wait))
11146 ;; There are expirable articles in this group, so we run them
11147 ;; through the expiry process.
11148 (gnus-message 6 "Expiring articles...")
11149 ;; The list of articles that weren't expired is returned.
11151 (let ((nnmail-expiry-wait-function nil)
11152 (nnmail-expiry-wait expiry-wait))
11153 (setq es (gnus-request-expire-articles
11154 expirable gnus-newsgroup-name)))
11155 (setq es (gnus-request-expire-articles
11156 expirable gnus-newsgroup-name)))
11157 (or total (setq gnus-newsgroup-expirable es))
11158 ;; We go through the old list of expirable, and mark all
11159 ;; really expired articles as nonexistent.
11160 (unless (eq es expirable) ;If nothing was expired, we don't mark.
11161 (let ((gnus-use-cache nil))
11163 (unless (memq (car expirable) es)
11164 (when (gnus-data-find (car expirable))
11165 (gnus-summary-mark-article
11166 (car expirable) gnus-canceled-mark)))
11167 (setq expirable (cdr expirable)))))
11168 (gnus-message 6 "Expiring articles...done")))))
11170 (defun gnus-summary-expire-articles-now ()
11171 "Expunge all expirable articles in the current group.
11172 This means that *all* articles that are marked as expirable will be
11173 deleted forever, right now."
11175 (gnus-set-global-variables)
11176 (or gnus-expert-user
11178 "Are you really, really, really sure you want to expunge? ")
11180 (let ((nnmail-expiry-wait 'immediate)
11181 (nnmail-expiry-wait-function nil))
11182 (gnus-summary-expire-articles)))
11184 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
11185 (defun gnus-summary-delete-article (&optional n)
11186 "Delete the N next (mail) articles.
11187 This command actually deletes articles. This is not a marking
11188 command. The article will disappear forever from your life, never to
11190 If N is negative, delete backwards.
11191 If N is nil and articles have been marked with the process mark,
11192 delete these instead."
11194 (gnus-set-global-variables)
11195 (or (gnus-check-backend-function 'request-expire-articles
11196 gnus-newsgroup-name)
11197 (error "The current newsgroup does not support article deletion."))
11198 ;; Compute the list of articles to delete.
11199 (let ((articles (gnus-summary-work-articles n))
11201 (if (and gnus-novice-user
11202 (not (gnus-y-or-n-p
11203 (format "Do you really want to delete %s forever? "
11204 (if (> (length articles) 1) "these articles"
11205 "this article")))))
11207 ;; Delete the articles.
11208 (setq not-deleted (gnus-request-expire-articles
11209 articles gnus-newsgroup-name 'force))
11211 (gnus-summary-remove-process-mark (car articles))
11212 ;; The backend might not have been able to delete the article
11214 (or (memq (car articles) not-deleted)
11215 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
11216 (setq articles (cdr articles))))
11217 (gnus-summary-position-point)
11218 (gnus-set-mode-line 'summary)
11221 (defun gnus-summary-edit-article (&optional force)
11222 "Enter into a buffer and edit the current article.
11223 This will have permanent effect only in mail groups.
11224 If FORCE is non-nil, allow editing of articles even in read-only
11228 (set-buffer gnus-summary-buffer)
11229 (gnus-set-global-variables)
11230 (when (and (not force)
11231 (gnus-group-read-only-p))
11232 (error "The current newsgroup does not support article editing."))
11233 (gnus-summary-select-article t nil t)
11234 (gnus-configure-windows 'article)
11235 (select-window (get-buffer-window gnus-article-buffer))
11236 (gnus-message 6 "C-c C-c to end edits")
11237 (setq buffer-read-only nil)
11239 (use-local-map (copy-keymap (current-local-map)))
11240 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
11241 (buffer-enable-undo)
11243 (goto-char (point-min))
11244 (search-forward "\n\n" nil t)))
11246 (defun gnus-summary-edit-article-done ()
11247 "Make edits to the current article permanent."
11249 (if (gnus-group-read-only-p)
11251 (gnus-summary-edit-article-postpone)
11253 1 "The current newsgroup does not support article editing.")
11255 (let ((buf (buffer-substring-no-properties (point-min) (point-max))))
11258 (if (not (gnus-request-replace-article
11259 (cdr gnus-article-current) (car gnus-article-current)
11261 (error "Couldn't replace article.")
11262 (gnus-article-mode)
11263 (use-local-map gnus-article-mode-map)
11264 (setq buffer-read-only t)
11265 (buffer-disable-undo (current-buffer))
11266 (gnus-configure-windows 'summary)
11267 (gnus-summary-update-article (cdr gnus-article-current)))
11268 (run-hooks 'gnus-article-display-hook)
11269 (and (gnus-visual-p 'summary-highlight 'highlight)
11270 (run-hooks 'gnus-visual-mark-article-hook)))))
11272 (defun gnus-summary-edit-article-postpone ()
11273 "Postpone changes to the current article."
11275 (gnus-article-mode)
11276 (use-local-map gnus-article-mode-map)
11277 (setq buffer-read-only t)
11278 (buffer-disable-undo (current-buffer))
11279 (gnus-configure-windows 'summary)
11280 (and (gnus-visual-p 'summary-highlight 'highlight)
11281 (run-hooks 'gnus-visual-mark-article-hook)))
11283 (defun gnus-summary-respool-query ()
11284 "Query where the respool algorithm would put this article."
11286 (gnus-set-global-variables)
11287 (gnus-summary-select-article)
11289 (set-buffer gnus-article-buffer)
11291 (goto-char (point-min))
11292 (search-forward "\n\n")
11293 (narrow-to-region (point-min) (point))
11294 (pp-eval-expression
11295 (list 'quote (mapcar 'car (nnmail-article-group 'identity)))))))
11297 ;; Summary score commands.
11299 ;; Suggested by boubaker@cenatls.cena.dgac.fr.
11301 (defun gnus-summary-raise-score (n)
11302 "Raise the score of the current article by N."
11304 (gnus-set-global-variables)
11305 (gnus-summary-set-score (+ (gnus-summary-article-score) n)))
11307 (defun gnus-summary-set-score (n)
11308 "Set the score of the current article to N."
11310 (gnus-set-global-variables)
11312 (gnus-summary-show-thread)
11313 (let ((buffer-read-only nil))
11315 (gnus-summary-update-mark
11316 (if (= n (or gnus-summary-default-score 0)) ?
11317 (if (< n (or gnus-summary-default-score 0))
11318 gnus-score-below-mark gnus-score-over-mark)) 'score))
11319 (let* ((article (gnus-summary-article-number))
11320 (score (assq article gnus-newsgroup-scored)))
11321 (if score (setcdr score n)
11322 (setq gnus-newsgroup-scored
11323 (cons (cons article n) gnus-newsgroup-scored))))
11324 (gnus-summary-update-line)))
11326 (defun gnus-summary-current-score ()
11327 "Return the score of the current article."
11329 (gnus-set-global-variables)
11330 (message "%s" (gnus-summary-article-score)))
11332 ;; Summary marking commands.
11334 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
11335 "Mark articles which has the same subject as read, and then select the next.
11336 If UNMARK is positive, remove any kind of mark.
11337 If UNMARK is negative, tick articles."
11339 (gnus-set-global-variables)
11341 (setq unmark (prefix-numeric-value unmark)))
11343 (gnus-summary-mark-same-subject
11344 (gnus-summary-article-subject) unmark)))
11345 ;; Select next unread article. If auto-select-same mode, should
11346 ;; select the first unread article.
11347 (gnus-summary-next-article t (and gnus-auto-select-same
11348 (gnus-summary-article-subject)))
11349 (gnus-message 7 "%d article%s marked as %s"
11350 count (if (= count 1) " is" "s are")
11351 (if unmark "unread" "read"))))
11353 (defun gnus-summary-kill-same-subject (&optional unmark)
11354 "Mark articles which has the same subject as read.
11355 If UNMARK is positive, remove any kind of mark.
11356 If UNMARK is negative, tick articles."
11358 (gnus-set-global-variables)
11360 (setq unmark (prefix-numeric-value unmark)))
11362 (gnus-summary-mark-same-subject
11363 (gnus-summary-article-subject) unmark)))
11364 ;; If marked as read, go to next unread subject.
11366 ;; Go to next unread subject.
11367 (gnus-summary-next-subject 1 t))
11368 (gnus-message 7 "%d articles are marked as %s"
11369 count (if unmark "unread" "read"))))
11371 (defun gnus-summary-mark-same-subject (subject &optional unmark)
11372 "Mark articles with same SUBJECT as read, and return marked number.
11373 If optional argument UNMARK is positive, remove any kinds of marks.
11374 If optional argument UNMARK is negative, mark articles as unread instead."
11378 ((null unmark) ; Mark as read.
11381 (gnus-summary-mark-article-as-read gnus-killed-mark)
11382 (gnus-summary-show-thread) t)
11383 (gnus-summary-find-subject subject))
11384 (setq count (1+ count))))
11385 ((> unmark 0) ; Tick.
11388 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
11389 (gnus-summary-show-thread) t)
11390 (gnus-summary-find-subject subject))
11391 (setq count (1+ count))))
11392 (t ; Mark as unread.
11395 (gnus-summary-mark-article-as-unread gnus-unread-mark)
11396 (gnus-summary-show-thread) t)
11397 (gnus-summary-find-subject subject))
11398 (setq count (1+ count)))))
11399 (gnus-set-mode-line 'summary)
11400 ;; Return the number of marked articles.
11403 (defun gnus-summary-mark-as-processable (n &optional unmark)
11404 "Set the process mark on the next N articles.
11405 If N is negative, mark backward instead. If UNMARK is non-nil, remove
11406 the process mark instead. The difference between N and the actual
11407 number of articles marked is returned."
11409 (gnus-set-global-variables)
11410 (let ((backward (< n 0))
11415 (gnus-summary-remove-process-mark
11416 (gnus-summary-article-number))
11417 (gnus-summary-set-process-mark (gnus-summary-article-number)))
11418 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
11420 (if (/= 0 n) (gnus-message 7 "No more articles"))
11421 (gnus-summary-recenter)
11422 (gnus-summary-position-point)
11425 (defun gnus-summary-unmark-as-processable (n)
11426 "Remove the process mark from the next N articles.
11427 If N is negative, mark backward instead. The difference between N and
11428 the actual number of articles marked is returned."
11430 (gnus-set-global-variables)
11431 (gnus-summary-mark-as-processable n t))
11433 (defun gnus-summary-unmark-all-processable ()
11434 "Remove the process mark from all articles."
11436 (gnus-set-global-variables)
11438 (while gnus-newsgroup-processable
11439 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
11440 (gnus-summary-position-point))
11442 (defun gnus-summary-mark-as-expirable (n)
11443 "Mark N articles forward as expirable.
11444 If N is negative, mark backward instead. The difference between N and
11445 the actual number of articles marked is returned."
11447 (gnus-set-global-variables)
11448 (gnus-summary-mark-forward n gnus-expirable-mark))
11450 (defun gnus-summary-mark-article-as-replied (article)
11451 "Mark ARTICLE replied and update the summary line."
11452 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
11453 (let ((buffer-read-only nil))
11454 (when (gnus-summary-goto-subject article)
11455 (gnus-summary-update-secondary-mark article))))
11457 (defun gnus-summary-set-bookmark (article)
11458 "Set a bookmark in current article."
11459 (interactive (list (gnus-summary-article-number)))
11460 (gnus-set-global-variables)
11461 (if (or (not (get-buffer gnus-article-buffer))
11462 (not gnus-current-article)
11463 (not gnus-article-current)
11464 (not (equal gnus-newsgroup-name (car gnus-article-current))))
11465 (error "No current article selected"))
11466 ;; Remove old bookmark, if one exists.
11467 (let ((old (assq article gnus-newsgroup-bookmarks)))
11468 (if old (setq gnus-newsgroup-bookmarks
11469 (delq old gnus-newsgroup-bookmarks))))
11470 ;; Set the new bookmark, which is on the form
11471 ;; (article-number . line-number-in-body).
11472 (setq gnus-newsgroup-bookmarks
11476 (set-buffer gnus-article-buffer)
11480 (goto-char (point-min))
11481 (search-forward "\n\n" nil t)
11484 gnus-newsgroup-bookmarks))
11485 (gnus-message 6 "A bookmark has been added to the current article."))
11487 (defun gnus-summary-remove-bookmark (article)
11488 "Remove the bookmark from the current article."
11489 (interactive (list (gnus-summary-article-number)))
11490 (gnus-set-global-variables)
11491 ;; Remove old bookmark, if one exists.
11492 (let ((old (assq article gnus-newsgroup-bookmarks)))
11495 (setq gnus-newsgroup-bookmarks
11496 (delq old gnus-newsgroup-bookmarks))
11497 (gnus-message 6 "Removed bookmark."))
11498 (gnus-message 6 "No bookmark in current article."))))
11500 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11501 (defun gnus-summary-mark-as-dormant (n)
11502 "Mark N articles forward as dormant.
11503 If N is negative, mark backward instead. The difference between N and
11504 the actual number of articles marked is returned."
11506 (gnus-set-global-variables)
11507 (gnus-summary-mark-forward n gnus-dormant-mark))
11509 (defun gnus-summary-set-process-mark (article)
11510 "Set the process mark on ARTICLE and update the summary line."
11511 (setq gnus-newsgroup-processable
11513 (delq article gnus-newsgroup-processable)))
11514 (when (gnus-summary-goto-subject article)
11515 (gnus-summary-show-thread)
11516 (gnus-summary-update-secondary-mark article)))
11518 (defun gnus-summary-remove-process-mark (article)
11519 "Remove the process mark from ARTICLE and update the summary line."
11520 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
11521 (when (gnus-summary-goto-subject article)
11522 (gnus-summary-show-thread)
11523 (gnus-summary-update-secondary-mark article)))
11525 (defun gnus-summary-set-saved-mark (article)
11526 "Set the process mark on ARTICLE and update the summary line."
11527 (push article gnus-newsgroup-saved)
11528 (when (gnus-summary-goto-subject article)
11529 (gnus-summary-update-secondary-mark article)))
11531 (defun gnus-summary-mark-forward (n &optional mark no-expire)
11532 "Mark N articles as read forwards.
11533 If N is negative, mark backwards instead.
11534 Mark with MARK. If MARK is ? , ?! or ??, articles will be
11536 The difference between N and the actual number of articles marked is
11539 (gnus-set-global-variables)
11540 (let ((backward (< n 0))
11541 (gnus-summary-goto-unread
11542 (and gnus-summary-goto-unread
11543 (not (eq gnus-summary-goto-unread 'never))
11544 (not (memq mark (list gnus-unread-mark
11545 gnus-ticked-mark gnus-dormant-mark)))))
11547 (mark (or mark gnus-del-mark)))
11548 (while (and (> n 0)
11549 (gnus-summary-mark-article nil mark no-expire)
11550 (zerop (gnus-summary-next-subject
11552 (and gnus-summary-goto-unread
11553 (not (eq gnus-summary-goto-unread 'never)))
11556 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11557 (gnus-summary-recenter)
11558 (gnus-summary-position-point)
11559 (gnus-set-mode-line 'summary)
11562 (defun gnus-summary-mark-article-as-read (mark)
11563 "Mark the current article quickly as read with MARK."
11564 (let ((article (gnus-summary-article-number)))
11565 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11566 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11567 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11568 (setq gnus-newsgroup-reads
11569 (cons (cons article mark) gnus-newsgroup-reads))
11570 ;; Possibly remove from cache, if that is used.
11571 (and gnus-use-cache (gnus-cache-enter-remove-article article))
11572 ;; Allow the backend to change the mark.
11573 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
11574 ;; Check for auto-expiry.
11575 (when (and gnus-newsgroup-auto-expire
11576 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
11577 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
11578 (= mark gnus-ancient-mark)
11579 (= mark gnus-read-mark) (= mark gnus-souped-mark)))
11580 (setq mark gnus-expirable-mark)
11581 (push article gnus-newsgroup-expirable))
11582 ;; Set the mark in the buffer.
11583 (gnus-summary-update-mark mark 'unread)
11586 (defun gnus-summary-mark-article-as-unread (mark)
11587 "Mark the current article quickly as unread with MARK."
11588 (let ((article (gnus-summary-article-number)))
11589 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11590 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11591 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
11592 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
11593 (cond ((= mark gnus-ticked-mark)
11594 (push article gnus-newsgroup-marked))
11595 ((= mark gnus-dormant-mark)
11596 (push article gnus-newsgroup-dormant))
11598 (push article gnus-newsgroup-unreads)))
11599 (setq gnus-newsgroup-reads
11600 (delq (assq article gnus-newsgroup-reads)
11601 gnus-newsgroup-reads))
11603 ;; See whether the article is to be put in the cache.
11604 (and gnus-use-cache
11605 (vectorp (gnus-summary-article-header article))
11607 (gnus-cache-possibly-enter-article
11608 gnus-newsgroup-name article
11609 (gnus-summary-article-header article)
11610 (= mark gnus-ticked-mark)
11611 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11614 (gnus-summary-update-mark mark 'unread)
11617 (defun gnus-summary-mark-article (&optional article mark no-expire)
11618 "Mark ARTICLE with MARK. MARK can be any character.
11619 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
11620 `??' (dormant) and `?E' (expirable).
11621 If MARK is nil, then the default character `?D' is used.
11622 If ARTICLE is nil, then the article on the current line will be
11624 ;; The mark might be a string.
11625 (and (stringp mark)
11626 (setq mark (aref mark 0)))
11627 ;; If no mark is given, then we check auto-expiring.
11628 (and (not no-expire)
11629 gnus-newsgroup-auto-expire
11631 (and (numberp mark)
11632 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
11633 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
11634 (= mark gnus-read-mark) (= mark gnus-souped-mark))))
11635 (setq mark gnus-expirable-mark))
11636 (let* ((mark (or mark gnus-del-mark))
11637 (article (or article (gnus-summary-article-number))))
11638 (or article (error "No article on current line"))
11639 (if (or (= mark gnus-unread-mark)
11640 (= mark gnus-ticked-mark)
11641 (= mark gnus-dormant-mark))
11642 (gnus-mark-article-as-unread article mark)
11643 (gnus-mark-article-as-read article mark))
11645 ;; See whether the article is to be put in the cache.
11646 (and gnus-use-cache
11647 (not (= mark gnus-canceled-mark))
11648 (vectorp (gnus-summary-article-header article))
11650 (gnus-cache-possibly-enter-article
11651 gnus-newsgroup-name article
11652 (gnus-summary-article-header article)
11653 (= mark gnus-ticked-mark)
11654 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11656 (if (gnus-summary-goto-subject article nil t)
11657 (let ((buffer-read-only nil))
11658 (gnus-summary-show-thread)
11660 (gnus-summary-update-mark mark 'unread)
11663 (defun gnus-summary-update-secondary-mark (article)
11664 "Update the secondary (read, process, cache) mark."
11665 (gnus-summary-update-mark
11666 (cond ((memq article gnus-newsgroup-processable)
11668 ((memq article gnus-newsgroup-cached)
11670 ((memq article gnus-newsgroup-replied)
11672 ((memq article gnus-newsgroup-saved)
11674 (t gnus-unread-mark))
11676 (when (gnus-visual-p 'summary-highlight 'highlight)
11677 (run-hooks 'gnus-summary-update-hook))
11680 (defun gnus-summary-update-mark (mark type)
11681 (beginning-of-line)
11682 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
11683 (buffer-read-only nil))
11685 ;; Go to the right position on the line.
11686 (forward-char forward)
11687 ;; Replace the old mark with the new mark.
11688 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
11689 ;; Optionally update the marks by some user rule.
11690 (when (eq type 'unread)
11691 (gnus-data-set-mark
11692 (gnus-data-find (gnus-summary-article-number)) mark)
11693 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
11695 (defun gnus-mark-article-as-read (article &optional mark)
11696 "Enter ARTICLE in the pertinent lists and remove it from others."
11697 ;; Make the article expirable.
11698 (let ((mark (or mark gnus-del-mark)))
11699 (if (= mark gnus-expirable-mark)
11700 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
11701 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
11702 ;; Remove from unread and marked lists.
11703 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11704 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11705 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11706 (push (cons article mark) gnus-newsgroup-reads)
11707 ;; Possibly remove from cache, if that is used.
11708 (when gnus-use-cache
11709 (gnus-cache-enter-remove-article article))))
11711 (defun gnus-mark-article-as-unread (article &optional mark)
11712 "Enter ARTICLE in the pertinent lists and remove it from others."
11713 (let ((mark (or mark gnus-ticked-mark)))
11714 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11715 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11716 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
11717 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11718 (cond ((= mark gnus-ticked-mark)
11719 (push article gnus-newsgroup-marked))
11720 ((= mark gnus-dormant-mark)
11721 (push article gnus-newsgroup-dormant))
11723 (push article gnus-newsgroup-unreads)))
11724 (setq gnus-newsgroup-reads
11725 (delq (assq article gnus-newsgroup-reads)
11726 gnus-newsgroup-reads))))
11728 (defalias 'gnus-summary-mark-as-unread-forward
11729 'gnus-summary-tick-article-forward)
11730 (make-obsolete 'gnus-summary-mark-as-unread-forward
11731 'gnus-summary-tick-article-forward)
11732 (defun gnus-summary-tick-article-forward (n)
11733 "Tick N articles forwards.
11734 If N is negative, tick backwards instead.
11735 The difference between N and the number of articles ticked is returned."
11737 (gnus-summary-mark-forward n gnus-ticked-mark))
11739 (defalias 'gnus-summary-mark-as-unread-backward
11740 'gnus-summary-tick-article-backward)
11741 (make-obsolete 'gnus-summary-mark-as-unread-backward
11742 'gnus-summary-tick-article-backward)
11743 (defun gnus-summary-tick-article-backward (n)
11744 "Tick N articles backwards.
11745 The difference between N and the number of articles ticked is returned."
11747 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
11749 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
11750 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
11751 (defun gnus-summary-tick-article (&optional article clear-mark)
11752 "Mark current article as unread.
11753 Optional 1st argument ARTICLE specifies article number to be marked as unread.
11754 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
11755 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
11756 gnus-ticked-mark)))
11758 (defun gnus-summary-mark-as-read-forward (n)
11759 "Mark N articles as read forwards.
11760 If N is negative, mark backwards instead.
11761 The difference between N and the actual number of articles marked is
11764 (gnus-summary-mark-forward n gnus-del-mark t))
11766 (defun gnus-summary-mark-as-read-backward (n)
11767 "Mark the N articles as read backwards.
11768 The difference between N and the actual number of articles marked is
11771 (gnus-summary-mark-forward (- n) gnus-del-mark t))
11773 (defun gnus-summary-mark-as-read (&optional article mark)
11774 "Mark current article as read.
11775 ARTICLE specifies the article to be marked as read.
11776 MARK specifies a string to be inserted at the beginning of the line."
11777 (gnus-summary-mark-article article mark))
11779 (defun gnus-summary-clear-mark-forward (n)
11780 "Clear marks from N articles forward.
11781 If N is negative, clear backward instead.
11782 The difference between N and the number of marks cleared is returned."
11784 (gnus-summary-mark-forward n gnus-unread-mark))
11786 (defun gnus-summary-clear-mark-backward (n)
11787 "Clear marks from N articles backward.
11788 The difference between N and the number of marks cleared is returned."
11790 (gnus-summary-mark-forward (- n) gnus-unread-mark))
11792 (defun gnus-summary-mark-unread-as-read ()
11793 "Intended to be used by `gnus-summary-mark-article-hook'."
11794 (when (memq gnus-current-article gnus-newsgroup-unreads)
11795 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
11797 (defun gnus-summary-mark-region-as-read (point mark all)
11798 "Mark all unread articles between point and mark as read.
11799 If given a prefix, mark all articles between point and mark as read,
11800 even ticked and dormant ones."
11801 (interactive "r\nP")
11805 (beginning-of-line)
11810 (memq (setq article (gnus-summary-article-number))
11811 gnus-newsgroup-unreads))
11812 (gnus-summary-mark-article article gnus-del-mark))
11814 (gnus-summary-find-next))))))
11816 (defun gnus-summary-mark-below (score mark)
11817 "Mark articles with score less than SCORE with MARK."
11818 (interactive "P\ncMark: ")
11819 (gnus-set-global-variables)
11820 (setq score (if score
11821 (prefix-numeric-value score)
11822 (or gnus-summary-default-score 0)))
11824 (set-buffer gnus-summary-buffer)
11825 (goto-char (point-min))
11828 (and (< (gnus-summary-article-score) score)
11829 (gnus-summary-mark-article nil mark))
11830 (gnus-summary-find-next)))))
11832 (defun gnus-summary-kill-below (&optional score)
11833 "Mark articles with score below SCORE as read."
11835 (gnus-set-global-variables)
11836 (gnus-summary-mark-below score gnus-killed-mark))
11838 (defun gnus-summary-clear-above (&optional score)
11839 "Clear all marks from articles with score above SCORE."
11841 (gnus-set-global-variables)
11842 (gnus-summary-mark-above score gnus-unread-mark))
11844 (defun gnus-summary-tick-above (&optional score)
11845 "Tick all articles with score above SCORE."
11847 (gnus-set-global-variables)
11848 (gnus-summary-mark-above score gnus-ticked-mark))
11850 (defun gnus-summary-mark-above (score mark)
11851 "Mark articles with score over SCORE with MARK."
11852 (interactive "P\ncMark: ")
11853 (gnus-set-global-variables)
11854 (setq score (if score
11855 (prefix-numeric-value score)
11856 (or gnus-summary-default-score 0)))
11858 (set-buffer gnus-summary-buffer)
11859 (goto-char (point-min))
11861 (if (> (gnus-summary-article-score) score)
11862 (gnus-summary-mark-article nil mark))
11864 (gnus-summary-find-next)))))
11866 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11867 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
11868 (defun gnus-summary-limit-include-expunged ()
11869 "Display all the hidden articles that were expunged for low scores."
11871 (gnus-set-global-variables)
11872 (let ((buffer-read-only nil))
11873 (let ((scored gnus-newsgroup-scored)
11876 (or (gnus-summary-goto-subject (car (car scored)))
11877 (and (setq h (gnus-summary-article-header (car (car scored))))
11878 (< (cdr (car scored)) gnus-summary-expunge-below)
11879 (setq headers (cons h headers))))
11880 (setq scored (cdr scored)))
11881 (or headers (error "No expunged articles hidden."))
11882 (goto-char (point-min))
11883 (gnus-summary-prepare-unthreaded (nreverse headers)))
11884 (goto-char (point-min))
11885 (gnus-summary-position-point)))
11887 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
11888 "Mark all articles not marked as unread in this newsgroup as read.
11889 If prefix argument ALL is non-nil, all articles are marked as read.
11890 If QUIETLY is non-nil, no questions will be asked.
11891 If TO-HERE is non-nil, it should be a point in the buffer. All
11892 articles before this point will be marked as read.
11893 The number of articles marked as read is returned."
11895 (gnus-set-global-variables)
11898 (not gnus-interactive-catchup) ;Without confirmation?
11902 "Mark absolutely all articles as read? "
11903 "Mark all unread articles as read? ")))
11905 (not gnus-newsgroup-adaptive)
11906 (not gnus-newsgroup-auto-expire))
11909 (setq gnus-newsgroup-marked nil
11910 gnus-newsgroup-dormant nil))
11911 (setq gnus-newsgroup-unreads nil))
11912 ;; We actually mark all articles as canceled, which we
11913 ;; have to do when using auto-expiry or adaptive scoring.
11914 (gnus-summary-show-all-threads)
11915 (if (gnus-summary-first-subject (not all))
11917 (if to-here (< (point) to-here) t)
11918 (gnus-summary-mark-article-as-read gnus-catchup-mark)
11919 (gnus-summary-find-next (not all)))))
11921 (setq gnus-newsgroup-unreads nil))
11922 (gnus-set-mode-line 'summary)))
11923 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
11924 (if (and (not to-here) (eq 'nnvirtual (car method)))
11925 (nnvirtual-catchup-group
11926 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
11927 (gnus-summary-position-point)))
11929 (defun gnus-summary-catchup-to-here (&optional all)
11930 "Mark all unticked articles before the current one as read.
11931 If ALL is non-nil, also mark ticked and dormant articles as read."
11933 (gnus-set-global-variables)
11935 (let ((beg (point)))
11936 ;; We check that there are unread articles.
11937 (when (or all (gnus-summary-find-prev))
11938 (gnus-summary-catchup all t beg))))
11939 (gnus-summary-position-point))
11941 (defun gnus-summary-catchup-all (&optional quietly)
11942 "Mark all articles in this newsgroup as read."
11944 (gnus-set-global-variables)
11945 (gnus-summary-catchup t quietly))
11947 (defun gnus-summary-catchup-and-exit (&optional all quietly)
11948 "Mark all articles not marked as unread in this newsgroup as read, then exit.
11949 If prefix argument ALL is non-nil, all articles are marked as read."
11951 (gnus-set-global-variables)
11952 (gnus-summary-catchup all quietly nil 'fast)
11953 ;; Select next newsgroup or exit.
11954 (if (eq gnus-auto-select-next 'quietly)
11955 (gnus-summary-next-group nil)
11956 (gnus-summary-exit)))
11958 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
11959 "Mark all articles in this newsgroup as read, and then exit."
11961 (gnus-set-global-variables)
11962 (gnus-summary-catchup-and-exit t quietly))
11964 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
11965 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
11966 "Mark all articles in this group as read and select the next group.
11967 If given a prefix, mark all articles, unread as well as ticked, as
11970 (gnus-set-global-variables)
11972 (gnus-summary-catchup all))
11973 (gnus-summary-next-article t nil nil t))
11975 ;; Thread-based commands.
11977 (defun gnus-summary-articles-in-thread (&optional article)
11978 "Return a list of all articles in the current thread.
11979 If ARTICLE is non-nil, return all articles in the thread that starts
11980 with that article."
11981 (let* ((article (or article (gnus-summary-article-number)))
11982 (data (gnus-data-find-list article))
11983 (top-level (gnus-data-level (car data)))
11985 (cond ((null gnus-thread-operation-ignore-subject)
11986 (gnus-simplify-subject-re
11987 (mail-header-subject (gnus-data-header (car data)))))
11988 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
11989 (gnus-simplify-subject-fuzzy
11990 (mail-header-subject (gnus-data-header (car data)))))
11994 () ; This article doesn't exist.
11996 (and (or (not top-subject)
11997 (string= top-subject
11998 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
11999 (gnus-simplify-subject-fuzzy
12000 (mail-header-subject
12001 (gnus-data-header (car data))))
12002 (gnus-simplify-subject-re
12003 (mail-header-subject
12004 (gnus-data-header (car data)))))))
12005 (setq articles (cons (gnus-data-number (car data)) articles)))
12006 (if (and (setq data (cdr data))
12007 (> (gnus-data-level (car data)) top-level))
12010 ;; Return the list of articles.
12011 (nreverse articles))))
12013 (defun gnus-summary-rethread-current ()
12014 "Rethread the thread the current article is part of."
12016 (gnus-set-global-variables)
12017 (let* ((gnus-show-threads t)
12018 (article (gnus-summary-article-number))
12019 (id (mail-header-id (gnus-summary-article-header)))
12020 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
12022 (error "No article on the current line"))
12023 (gnus-rebuild-thread id)
12024 (gnus-summary-goto-subject article)))
12026 (defun gnus-summary-reparent-thread ()
12027 "Make current article child of the marked (or previous) article.
12029 Note that the re-threading will only work if `gnus-thread-ignore-subject'
12030 is non-nil or the Subject: of both articles are the same."
12032 (or (not (gnus-group-read-only-p))
12033 (error "The current newsgroup does not support article editing."))
12034 (or (<= (length gnus-newsgroup-processable) 1)
12035 (error "No more than one article may be marked."))
12036 (save-window-excursion
12037 (let ((gnus-article-buffer " *reparent*")
12038 (current-article (gnus-summary-article-number))
12039 ; first grab the marked article, otherwise one line up.
12040 (parent-article (if (not (null gnus-newsgroup-processable))
12041 (car gnus-newsgroup-processable)
12043 (if (eq (forward-line -1) 0)
12044 (gnus-summary-article-number)
12045 (error "Beginning of summary buffer."))))))
12046 (or (not (eq current-article parent-article))
12047 (error "An article may not be self-referential."))
12048 (let ((message-id (mail-header-id
12049 (gnus-summary-article-header parent-article))))
12050 (or (and message-id (not (equal message-id "")))
12051 (error "No message-id in desired parent."))
12052 (gnus-summary-select-article t t nil current-article)
12053 (set-buffer gnus-article-buffer)
12054 (setq buffer-read-only nil)
12055 (let ((buf (buffer-substring-no-properties (point-min) (point-max))))
12058 (goto-char (point-min))
12059 (if (search-forward-regexp "^References: " nil t)
12060 (insert message-id " " )
12061 (insert "References: " message-id "\n"))
12062 (or (gnus-request-replace-article current-article
12063 (car gnus-article-current)
12064 gnus-article-buffer)
12065 (error "Couldn't replace article."))
12066 (set-buffer gnus-summary-buffer)
12067 (gnus-summary-unmark-all-processable)
12068 (gnus-summary-rethread-current)
12069 (message "Article %d is now the child of article %d."
12070 current-article parent-article)))))
12072 (defun gnus-summary-toggle-threads (&optional arg)
12073 "Toggle showing conversation threads.
12074 If ARG is positive number, turn showing conversation threads on."
12076 (gnus-set-global-variables)
12077 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
12078 (setq gnus-show-threads
12079 (if (null arg) (not gnus-show-threads)
12080 (> (prefix-numeric-value arg) 0)))
12081 (gnus-summary-prepare)
12082 (gnus-summary-goto-subject current)
12083 (gnus-summary-position-point)))
12085 (defun gnus-summary-show-all-threads ()
12086 "Show all threads."
12088 (gnus-set-global-variables)
12090 (let ((buffer-read-only nil))
12091 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
12092 (gnus-summary-position-point))
12094 (defun gnus-summary-show-thread ()
12095 "Show thread subtrees.
12096 Returns nil if no thread was there to be shown."
12098 (gnus-set-global-variables)
12099 (let ((buffer-read-only nil)
12101 ;; first goto end then to beg, to have point at beg after let
12102 (end (progn (end-of-line) (point)))
12103 (beg (progn (beginning-of-line) (point))))
12105 ;; Any hidden lines here?
12106 (search-forward "\r" end t)
12107 (subst-char-in-region beg end ?\^M ?\n t)
12109 (gnus-summary-position-point))))
12111 (defun gnus-summary-hide-all-threads ()
12112 "Hide all thread subtrees."
12114 (gnus-set-global-variables)
12116 (goto-char (point-min))
12117 (gnus-summary-hide-thread)
12118 (while (zerop (gnus-summary-next-thread 1 t))
12119 (gnus-summary-hide-thread)))
12120 (gnus-summary-position-point))
12122 (defun gnus-summary-hide-thread ()
12123 "Hide thread subtrees.
12124 Returns nil if no threads were there to be hidden."
12126 (gnus-set-global-variables)
12127 (let ((buffer-read-only nil)
12129 (article (gnus-summary-article-number))
12131 ;; Go forward until either the buffer ends or the subthread
12133 (when (and (not (eobp))
12134 (or (zerop (gnus-summary-next-thread 1 t))
12135 (goto-char (point-max))))
12138 (if (and (> (point) start)
12139 (search-backward "\n" start t))
12141 (subst-char-in-region start (point) ?\n ?\^M)
12142 (gnus-summary-goto-subject article))
12145 (gnus-summary-position-point)))))
12147 (defun gnus-summary-go-to-next-thread (&optional previous)
12148 "Go to the same level (or less) next thread.
12149 If PREVIOUS is non-nil, go to previous thread instead.
12150 Return the article number moved to, or nil if moving was impossible."
12151 (let* ((level (gnus-summary-thread-level))
12152 (article (gnus-summary-article-number))
12153 (data (cdr (gnus-data-find-list article (gnus-data-list previous))))
12156 (if (<= (gnus-data-level (car data)) level)
12157 (setq oart (gnus-data-number (car data))
12159 (setq data (cdr data))))
12161 (gnus-summary-goto-subject oart))))
12163 (defun gnus-summary-next-thread (n &optional silent)
12164 "Go to the same level next N'th thread.
12165 If N is negative, search backward instead.
12166 Returns the difference between N and the number of skips actually
12169 If SILENT, don't output messages."
12171 (gnus-set-global-variables)
12172 (let ((backward (< n 0))
12175 (while (and (> n 0)
12176 (setq old (save-excursion (forward-line 1) (point)))
12177 (gnus-summary-go-to-next-thread backward))
12178 (when (and (eq gnus-summary-make-false-root 'dummy)
12179 (setq dum (text-property-not-all
12180 old (point) 'gnus-intangible nil)))
12183 (gnus-summary-position-point)
12184 (when (and (not silent) (/= 0 n))
12185 (gnus-message 7 "No more threads"))
12188 (defun gnus-summary-prev-thread (n)
12189 "Go to the same level previous N'th thread.
12190 Returns the difference between N and the number of skips actually
12193 (gnus-set-global-variables)
12194 (gnus-summary-next-thread (- n)))
12196 (defun gnus-summary-go-down-thread ()
12197 "Go down one level in the current thread."
12198 (let ((children (gnus-summary-article-children)))
12200 (gnus-summary-goto-subject (car children)))))
12202 (defun gnus-summary-go-up-thread ()
12203 "Go up one level in the current thread."
12204 (let ((parent (gnus-summary-article-parent)))
12206 (gnus-summary-goto-subject parent))))
12208 (defun gnus-summary-down-thread (n)
12209 "Go down thread N steps.
12210 If N is negative, go up instead.
12211 Returns the difference between N and how many steps down that were
12214 (gnus-set-global-variables)
12217 (while (and (> n 0)
12218 (if up (gnus-summary-go-up-thread)
12219 (gnus-summary-go-down-thread)))
12221 (gnus-summary-position-point)
12222 (if (/= 0 n) (gnus-message 7 "Can't go further"))
12225 (defun gnus-summary-up-thread (n)
12226 "Go up thread N steps.
12227 If N is negative, go up instead.
12228 Returns the difference between N and how many steps down that were
12231 (gnus-set-global-variables)
12232 (gnus-summary-down-thread (- n)))
12234 (defun gnus-summary-top-thread ()
12235 "Go to the top of the thread."
12237 (gnus-set-global-variables)
12238 (while (gnus-summary-go-up-thread))
12239 (gnus-summary-article-number))
12241 (defun gnus-summary-kill-thread (&optional unmark)
12242 "Mark articles under current thread as read.
12243 If the prefix argument is positive, remove any kinds of marks.
12244 If the prefix argument is negative, tick articles instead."
12246 (gnus-set-global-variables)
12248 (setq unmark (prefix-numeric-value unmark)))
12249 (let ((articles (gnus-summary-articles-in-thread)))
12251 ;; Expand the thread.
12252 (gnus-summary-show-thread)
12253 ;; Mark all the articles.
12255 (gnus-summary-goto-subject (car articles))
12256 (cond ((null unmark)
12257 (gnus-summary-mark-article-as-read gnus-killed-mark))
12259 (gnus-summary-mark-article-as-unread gnus-unread-mark))
12261 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
12262 (setq articles (cdr articles))))
12263 ;; Hide killed subtrees.
12265 gnus-thread-hide-killed
12266 (gnus-summary-hide-thread))
12267 ;; If marked as read, go to next unread subject.
12269 ;; Go to next unread subject.
12270 (gnus-summary-next-subject 1 t)))
12271 (gnus-set-mode-line 'summary))
12273 ;; Summary sorting commands
12275 (defun gnus-summary-sort-by-number (&optional reverse)
12276 "Sort summary buffer by article number.
12277 Argument REVERSE means reverse order."
12279 (gnus-summary-sort 'number reverse))
12281 (defun gnus-summary-sort-by-author (&optional reverse)
12282 "Sort summary buffer by author name alphabetically.
12283 If case-fold-search is non-nil, case of letters is ignored.
12284 Argument REVERSE means reverse order."
12286 (gnus-summary-sort 'author reverse))
12288 (defun gnus-summary-sort-by-subject (&optional reverse)
12289 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
12290 If case-fold-search is non-nil, case of letters is ignored.
12291 Argument REVERSE means reverse order."
12293 (gnus-summary-sort 'subject reverse))
12295 (defun gnus-summary-sort-by-date (&optional reverse)
12296 "Sort summary buffer by date.
12297 Argument REVERSE means reverse order."
12299 (gnus-summary-sort 'date reverse))
12301 (defun gnus-summary-sort-by-score (&optional reverse)
12302 "Sort summary buffer by score.
12303 Argument REVERSE means reverse order."
12305 (gnus-summary-sort 'score reverse))
12307 (defun gnus-summary-sort (predicate reverse)
12308 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
12309 (gnus-set-global-variables)
12310 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
12311 (article (intern (format "gnus-article-sort-by-%s" predicate)))
12312 (gnus-thread-sort-functions
12317 (,thread t2 t1)))))
12318 (gnus-article-sort-functions
12323 (,article t2 t1)))))
12325 (gnus-summary-prepare-hook nil))
12326 ;; We do the sorting by regenerating the threads.
12327 (gnus-summary-prepare)
12328 ;; Hide subthreads if needed.
12329 (when (and gnus-show-threads gnus-thread-hide-subtree)
12330 (gnus-summary-hide-all-threads)))
12331 ;; If in async mode, we send some info to the backend.
12332 (when gnus-newsgroup-async
12333 (gnus-request-asynchronous
12334 gnus-newsgroup-name gnus-newsgroup-data)))
12336 (defun gnus-sortable-date (date)
12337 "Make sortable string by string-lessp from DATE.
12338 Timezone package is used."
12339 (let* ((date (timezone-fix-time date nil nil)) ;[Y M D H M S]
12340 (year (aref date 0))
12341 (month (aref date 1))
12342 (day (aref date 2)))
12343 (timezone-make-sortable-date
12345 (timezone-make-time-string
12346 (aref date 3) (aref date 4) (aref date 5)))))
12349 ;; Summary saving commands.
12351 (defun gnus-summary-save-article (&optional n not-saved)
12352 "Save the current article using the default saver function.
12353 If N is a positive number, save the N next articles.
12354 If N is a negative number, save the N previous articles.
12355 If N is nil and any articles have been marked with the process mark,
12356 save those articles instead.
12357 The variable `gnus-default-article-saver' specifies the saver function."
12359 (gnus-set-global-variables)
12360 (let ((articles (gnus-summary-work-articles n))
12361 file header article)
12363 (setq header (gnus-summary-article-header
12364 (setq article (pop articles))))
12365 (if (not (vectorp header))
12366 ;; This is a pseudo-article.
12367 (if (assq 'name header)
12368 (gnus-copy-file (cdr (assq 'name header)))
12369 (gnus-message 1 "Article %d is unsaveable" article))
12370 ;; This is a real article.
12371 (save-window-excursion
12372 (gnus-summary-select-article t nil nil article))
12373 (unless gnus-save-all-headers
12374 ;; Remove headers accoring to `gnus-saved-headers'.
12375 (let ((gnus-visible-headers
12376 (or gnus-saved-headers gnus-visible-headers)))
12377 (gnus-article-hide-headers nil t)))
12378 ;; Remove any X-Gnus lines.
12380 (set-buffer gnus-article-buffer)
12382 (let ((buffer-read-only nil))
12383 (nnheader-narrow-to-headers)
12384 (while (re-search-forward "^X-Gnus" nil t)
12385 (gnus-delete-line)))))
12386 (save-window-excursion
12387 (if (not gnus-default-article-saver)
12388 (error "No default saver is defined.")
12389 (setq file (funcall
12390 gnus-default-article-saver
12392 ((not gnus-prompt-before-saving)
12394 ((eq gnus-prompt-before-saving 'always)
12397 (gnus-summary-remove-process-mark article)
12399 (gnus-summary-set-saved-mark article))))
12400 (gnus-summary-position-point)
12403 (defun gnus-summary-pipe-output (&optional arg)
12404 "Pipe the current article to a subprocess.
12405 If N is a positive number, pipe the N next articles.
12406 If N is a negative number, pipe the N previous articles.
12407 If N is nil and any articles have been marked with the process mark,
12408 pipe those articles instead."
12410 (gnus-set-global-variables)
12411 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
12412 (gnus-summary-save-article arg t))
12413 (gnus-configure-windows 'pipe))
12415 (defun gnus-summary-save-article-mail (&optional arg)
12416 "Append the current article to an mail file.
12417 If N is a positive number, save the N next articles.
12418 If N is a negative number, save the N previous articles.
12419 If N is nil and any articles have been marked with the process mark,
12420 save those articles instead."
12422 (gnus-set-global-variables)
12423 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
12424 (gnus-summary-save-article arg)))
12426 (defun gnus-summary-save-article-rmail (&optional arg)
12427 "Append the current article to an rmail file.
12428 If N is a positive number, save the N next articles.
12429 If N is a negative number, save the N previous articles.
12430 If N is nil and any articles have been marked with the process mark,
12431 save those articles instead."
12433 (gnus-set-global-variables)
12434 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
12435 (gnus-summary-save-article arg)))
12437 (defun gnus-summary-save-article-file (&optional arg)
12438 "Append the current article to a file.
12439 If N is a positive number, save the N next articles.
12440 If N is a negative number, save the N previous articles.
12441 If N is nil and any articles have been marked with the process mark,
12442 save those articles instead."
12444 (gnus-set-global-variables)
12445 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
12446 (gnus-summary-save-article arg)))
12448 (defun gnus-summary-save-article-body-file (&optional arg)
12449 "Append the current article body to a file.
12450 If N is a positive number, save the N next articles.
12451 If N is a negative number, save the N previous articles.
12452 If N is nil and any articles have been marked with the process mark,
12453 save those articles instead."
12455 (gnus-set-global-variables)
12456 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
12457 (gnus-summary-save-article arg)))
12459 (defun gnus-get-split-value (methods)
12460 "Return a value based on the split METHODS."
12461 (let (split-name method result match)
12464 (set-buffer gnus-original-article-buffer)
12466 (nnheader-narrow-to-headers)
12468 (goto-char (point-min))
12469 (setq method (pop methods))
12470 (setq match (pop method))
12473 ;; Regular expression.
12475 (re-search-forward match nil t)
12477 ((gnus-functionp match)
12481 (setq result (funcall match gnus-newsgroup-name))))
12486 (setq result (eval match)))))
12487 (setq split-name (append (cdr methods) split-name))
12488 (cond ((stringp result)
12489 (push result split-name))
12491 (setq split-name (append result split-name)))))))))
12494 (defun gnus-read-move-group-name (prompt default articles prefix)
12495 "Read a group name."
12496 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
12498 (format "Where do you want to %s %s? "
12500 (if (> (length articles) 1)
12501 (format "these %d articles" (length articles))
12509 (format "(default %s) " default)
12511 gnus-active-hashtb nil nil prefix))
12512 ((= 1 (length split-name))
12513 (completing-read prom gnus-active-hashtb
12514 nil nil (cons (car split-name) 0)))
12517 prom (mapcar (lambda (el) (list el)) (nreverse split-name)))))))
12520 (if (or (string= to-newsgroup "")
12521 (string= to-newsgroup prefix))
12522 (setq to-newsgroup (or default "")))
12523 (or (gnus-active to-newsgroup)
12524 (gnus-activate-group to-newsgroup)
12525 (error "No such group: %s" to-newsgroup)))
12528 (defun gnus-read-save-file-name (prompt default-name)
12529 (let* ((split-name (gnus-get-split-value gnus-split-methods))
12531 ;; Let the split methods have their say.
12533 ;; No split name was found.
12536 (concat prompt " (default "
12537 (file-name-nondirectory default-name) ") ")
12538 (file-name-directory default-name)
12540 ;; A single split name was found
12541 ((= 1 (length split-name))
12543 (concat prompt " (default " (car split-name) ") ")
12544 gnus-article-save-directory
12545 (concat gnus-article-save-directory (car split-name))))
12546 ;; A list of splits was found.
12548 (setq split-name (mapcar (lambda (el) (list el))
12549 (nreverse split-name)))
12550 (let ((result (completing-read
12551 (concat prompt " ") split-name nil nil)))
12552 (concat gnus-article-save-directory
12553 (if (string= result "")
12554 (car (car split-name))
12556 ;; If we have read a directory, we append the default file name.
12557 (when (file-directory-p file)
12558 (setq file (concat (file-name-as-directory file)
12559 (file-name-nondirectory default-name))))
12560 ;; Possibly translate some charaters.
12561 (nnheader-translate-file-chars file)))
12563 (defun gnus-article-archive-name (group)
12564 "Return the first instance of an \"Archive-name\" in the current buffer."
12565 (let ((case-fold-search t))
12566 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
12567 (match-string 1))))
12569 (defun gnus-summary-save-in-rmail (&optional filename)
12570 "Append this article to Rmail file.
12571 Optional argument FILENAME specifies file name.
12572 Directory to save to is default to `gnus-article-save-directory' which
12573 is initialized from the SAVEDIR environment variable."
12575 (gnus-set-global-variables)
12576 (let ((default-name
12577 (funcall gnus-rmail-save-name gnus-newsgroup-name
12578 gnus-current-headers gnus-newsgroup-last-rmail)))
12580 (cond ((eq filename 'default)
12582 (filename filename)
12583 (t (gnus-read-save-file-name
12584 "Save in rmail file:" default-name))))
12585 (gnus-make-directory (file-name-directory filename))
12586 (gnus-eval-in-buffer-window
12587 gnus-original-article-buffer
12591 (gnus-output-to-rmail filename))))
12592 ;; Remember the directory name to save articles
12593 (setq gnus-newsgroup-last-rmail filename)))
12595 (defun gnus-summary-save-in-mail (&optional filename)
12596 "Append this article to Unix mail file.
12597 Optional argument FILENAME specifies file name.
12598 Directory to save to is default to `gnus-article-save-directory' which
12599 is initialized from the SAVEDIR environment variable."
12601 (gnus-set-global-variables)
12602 (let ((default-name
12603 (funcall gnus-mail-save-name gnus-newsgroup-name
12604 gnus-current-headers gnus-newsgroup-last-mail)))
12606 (cond ((eq filename 'default)
12608 (filename filename)
12609 (t (gnus-read-save-file-name
12610 "Save in Unix mail file:" default-name))))
12612 (expand-file-name filename
12614 (file-name-directory default-name))))
12615 (gnus-make-directory (file-name-directory filename))
12616 (gnus-eval-in-buffer-window
12617 gnus-original-article-buffer
12621 (if (and (file-readable-p filename) (mail-file-babyl-p filename))
12622 (gnus-output-to-rmail filename)
12623 (let ((mail-use-rfc822 t))
12624 (rmail-output filename 1 t t))))))
12625 ;; Remember the directory name to save articles.
12626 (setq gnus-newsgroup-last-mail filename)))
12628 (defun gnus-summary-save-in-file (&optional filename)
12629 "Append this article to file.
12630 Optional argument FILENAME specifies file name.
12631 Directory to save to is default to `gnus-article-save-directory' which
12632 is initialized from the SAVEDIR environment variable."
12634 (gnus-set-global-variables)
12635 (let ((default-name
12636 (funcall gnus-file-save-name gnus-newsgroup-name
12637 gnus-current-headers gnus-newsgroup-last-file)))
12639 (cond ((eq filename 'default)
12641 (filename filename)
12642 (t (gnus-read-save-file-name
12643 "Save in file:" default-name))))
12644 (gnus-make-directory (file-name-directory filename))
12645 (gnus-eval-in-buffer-window
12646 gnus-article-buffer
12650 (gnus-output-to-file filename))))
12651 ;; Remember the directory name to save articles.
12652 (setq gnus-newsgroup-last-file filename)))
12654 (defun gnus-summary-save-body-in-file (&optional filename)
12655 "Append this article body to a file.
12656 Optional argument FILENAME specifies file name.
12657 The directory to save in defaults to `gnus-article-save-directory' which
12658 is initialized from the SAVEDIR environment variable."
12660 (gnus-set-global-variables)
12661 (let ((default-name
12662 (funcall gnus-file-save-name gnus-newsgroup-name
12663 gnus-current-headers gnus-newsgroup-last-file)))
12665 (cond ((eq filename 'default)
12667 (filename filename)
12668 (t (gnus-read-save-file-name
12669 "Save body in file:" default-name))))
12670 (gnus-make-directory (file-name-directory filename))
12671 (gnus-eval-in-buffer-window
12672 gnus-article-buffer
12676 (goto-char (point-min))
12677 (and (search-forward "\n\n" nil t)
12678 (narrow-to-region (point) (point-max)))
12679 (gnus-output-to-file filename))))
12680 ;; Remember the directory name to save articles.
12681 (setq gnus-newsgroup-last-file filename)))
12683 (defun gnus-summary-save-in-pipe (&optional command)
12684 "Pipe this article to subprocess."
12686 (gnus-set-global-variables)
12688 (cond ((eq command 'default)
12689 gnus-last-shell-command)
12691 (t (read-string "Shell command on article: "
12692 gnus-last-shell-command))))
12693 (if (string-equal command "")
12694 (setq command gnus-last-shell-command))
12695 (gnus-eval-in-buffer-window
12696 gnus-article-buffer
12699 (shell-command-on-region (point-min) (point-max) command nil)))
12700 (setq gnus-last-shell-command command))
12702 ;; Summary extract commands
12704 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
12705 (let ((buffer-read-only nil)
12706 (article (gnus-summary-article-number))
12708 (or (gnus-summary-goto-subject article)
12709 (error (format "No such article: %d" article)))
12710 (gnus-summary-position-point)
12711 ;; If all commands are to be bunched up on one line, we collect
12713 (if gnus-view-pseudos-separately
12715 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
12718 (setq action (cdr (assq 'action (car ps))))
12719 (setq files (list (cdr (assq 'name (car ps)))))
12720 (while (and ps (cdr ps)
12721 (string= (or action "1")
12722 (or (cdr (assq 'action (car (cdr ps)))) "2")))
12723 (setq files (cons (cdr (assq 'name (car (cdr ps)))) files))
12724 (setcdr ps (cdr (cdr ps))))
12727 (if (not (string-match "%s" action))
12728 (setq files (cons " " files)))
12729 (setq files (cons " " files))
12730 (and (assq 'execute (car ps))
12731 (setcdr (assq 'execute (car ps))
12732 (funcall (if (string-match "%s" action)
12735 (mapconcat (lambda (f) f) files " ")))))
12736 (setq ps (cdr ps)))))
12737 (if (and gnus-view-pseudos (not not-view))
12739 (and (assq 'execute (car pslist))
12740 (gnus-execute-command (cdr (assq 'execute (car pslist)))
12741 (eq gnus-view-pseudos 'not-confirm)))
12742 (setq pslist (cdr pslist)))
12745 (setq after-article (or (cdr (assq 'article (car pslist)))
12746 (gnus-summary-article-number)))
12747 (gnus-summary-goto-subject after-article)
12750 (insert " " (file-name-nondirectory
12751 (cdr (assq 'name (car pslist))))
12752 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
12754 (forward-line -1) ; back to `b'
12755 (add-text-properties
12756 b e (list 'gnus-number gnus-reffed-article-number
12757 gnus-mouse-face-prop gnus-mouse-face))
12759 after-article gnus-reffed-article-number
12760 gnus-unread-mark b (car pslist) 0 (- e b))
12761 (push gnus-reffed-article-number gnus-newsgroup-unreads)
12762 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
12763 (setq pslist (cdr pslist)))))))
12765 (defun gnus-pseudos< (p1 p2)
12766 (let ((c1 (cdr (assq 'action p1)))
12767 (c2 (cdr (assq 'action p2))))
12768 (and c1 c2 (string< c1 c2))))
12770 (defun gnus-request-pseudo-article (props)
12771 (cond ((assq 'execute props)
12772 (gnus-execute-command (cdr (assq 'execute props)))))
12773 (let ((gnus-current-article (gnus-summary-article-number)))
12774 (run-hooks 'gnus-mark-article-hook)))
12776 (defun gnus-execute-command (command &optional automatic)
12778 (gnus-article-setup-buffer)
12779 (set-buffer gnus-article-buffer)
12780 (let ((command (if automatic command (read-string "Command: " command)))
12781 (buffer-read-only nil))
12783 (insert "$ " command "\n\n")
12784 (if gnus-view-pseudo-asynchronously
12785 (start-process "gnus-execute" nil "sh" "-c" command)
12786 (call-process "sh" nil t nil "-c" command)))))
12788 (defun gnus-copy-file (file &optional to)
12791 (list (read-file-name "Copy file: " default-directory)
12792 (read-file-name "Copy file to: " default-directory)))
12793 (gnus-set-global-variables)
12794 (or to (setq to (read-file-name "Copy file to: " default-directory)))
12795 (and (file-directory-p to)
12796 (setq to (concat (file-name-as-directory to)
12797 (file-name-nondirectory file))))
12798 (copy-file file to))
12800 ;; Summary kill commands.
12802 (defun gnus-summary-edit-global-kill (article)
12803 "Edit the \"global\" kill file."
12804 (interactive (list (gnus-summary-article-number)))
12805 (gnus-set-global-variables)
12806 (gnus-group-edit-global-kill article))
12808 (defun gnus-summary-edit-local-kill ()
12809 "Edit a local kill file applied to the current newsgroup."
12811 (gnus-set-global-variables)
12812 (setq gnus-current-headers (gnus-summary-article-header))
12813 (gnus-set-global-variables)
12814 (gnus-group-edit-local-kill
12815 (gnus-summary-article-number) gnus-newsgroup-name))
12819 ;;; Gnus article mode
12822 (put 'gnus-article-mode 'mode-class 'special)
12824 (if gnus-article-mode-map
12826 (setq gnus-article-mode-map (make-keymap))
12827 (suppress-keymap gnus-article-mode-map)
12830 gnus-article-mode-map
12831 " " gnus-article-goto-next-page
12832 "\177" gnus-article-goto-prev-page
12833 "\C-c^" gnus-article-refer-article
12834 "h" gnus-article-show-summary
12835 "s" gnus-article-show-summary
12836 "\C-c\C-m" gnus-article-mail
12837 "?" gnus-article-describe-briefly
12838 gnus-mouse-2 gnus-article-push-button
12839 "\r" gnus-article-press-button
12840 "\t" gnus-article-next-button
12841 "\M-\t" gnus-article-prev-button
12842 "\C-c\C-b" gnus-bug)
12844 (substitute-key-definition
12845 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map))
12848 (defun gnus-article-mode ()
12849 "Major mode for displaying an article.
12851 All normal editing commands are switched off.
12853 The following commands are available:
12855 \\<gnus-article-mode-map>
12856 \\[gnus-article-next-page]\t Scroll the article one page forwards
12857 \\[gnus-article-prev-page]\t Scroll the article one page backwards
12858 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
12859 \\[gnus-article-show-summary]\t Display the summary buffer
12860 \\[gnus-article-mail]\t Send a reply to the address near point
12861 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
12862 \\[gnus-info-find-node]\t Go to the Gnus info node"
12864 (when (and menu-bar-mode
12865 (gnus-visual-p 'article-menu 'menu))
12866 (gnus-article-make-menu-bar))
12867 (kill-all-local-variables)
12868 (gnus-simplify-mode-line)
12869 (setq mode-name "Article")
12870 (setq major-mode 'gnus-article-mode)
12871 (make-local-variable 'minor-mode-alist)
12872 (or (assq 'gnus-show-mime minor-mode-alist)
12873 (setq minor-mode-alist
12874 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
12875 (use-local-map gnus-article-mode-map)
12876 (make-local-variable 'page-delimiter)
12877 (setq page-delimiter gnus-page-delimiter)
12878 (buffer-disable-undo (current-buffer))
12879 (setq buffer-read-only t) ;Disable modification
12880 (run-hooks 'gnus-article-mode-hook))
12882 (defun gnus-article-setup-buffer ()
12883 "Initialize the article buffer."
12884 (let* ((name (if gnus-single-article-buffer "*Article*"
12885 (concat "*Article " gnus-newsgroup-name "*")))
12887 (progn (string-match "\\*Article" name)
12888 (concat " *Original Article"
12889 (substring name (match-end 0))))))
12890 (setq gnus-article-buffer name)
12891 (setq gnus-original-article-buffer original)
12892 ;; This might be a variable local to the summary buffer.
12893 (unless gnus-single-article-buffer
12895 (set-buffer gnus-summary-buffer)
12896 (setq gnus-article-buffer name)
12897 (setq gnus-original-article-buffer original))
12898 (make-local-variable 'gnus-summary-buffer))
12899 (if (get-buffer name)
12902 (buffer-disable-undo (current-buffer))
12903 (setq buffer-read-only t)
12904 (gnus-add-current-to-buffer-list)
12905 (or (eq major-mode 'gnus-article-mode)
12906 (gnus-article-mode))
12909 (set-buffer (get-buffer-create name))
12910 (gnus-add-current-to-buffer-list)
12911 (gnus-article-mode)
12912 (current-buffer)))))
12914 ;; Set article window start at LINE, where LINE is the number of lines
12915 ;; from the head of the article.
12916 (defun gnus-article-set-window-start (&optional line)
12918 (get-buffer-window gnus-article-buffer)
12920 (set-buffer gnus-article-buffer)
12921 (goto-char (point-min))
12924 (gnus-message 6 "Moved to bookmark")
12925 (search-forward "\n\n" nil t)
12926 (forward-line line)
12929 (defun gnus-kill-all-overlays ()
12930 "Delete all overlays in the current buffer."
12931 (when (fboundp 'overlay-lists)
12932 (let* ((overlayss (overlay-lists))
12933 (buffer-read-only nil)
12934 (overlays (nconc (car overlayss) (cdr overlayss))))
12936 (delete-overlay (pop overlays))))))
12938 (defun gnus-request-article-this-buffer (article group)
12939 "Get an article and insert it into this buffer."
12943 (gnus-kill-all-overlays)
12944 (setq group (or group gnus-newsgroup-name))
12946 ;; Open server if it has closed.
12947 (gnus-check-server (gnus-find-method-for-group group))
12949 ;; Using `gnus-request-article' directly will insert the article into
12950 ;; `nntp-server-buffer' - so we'll save some time by not having to
12951 ;; copy it from the server buffer into the article buffer.
12953 ;; We only request an article by message-id when we do not have the
12954 ;; headers for it, so we'll have to get those.
12955 (when (stringp article)
12956 (let ((gnus-override-method gnus-refer-article-method))
12957 (gnus-read-header article)))
12959 ;; If the article number is negative, that means that this article
12960 ;; doesn't belong in this newsgroup (possibly), so we find its
12961 ;; message-id and request it by id instead of number.
12962 (when (numberp article)
12964 (set-buffer gnus-summary-buffer)
12965 (let ((header (gnus-summary-article-header article)))
12968 ((memq article gnus-newsgroup-sparse)
12969 ;; This is a sparse gap article.
12970 (setq article (mail-header-id header)))
12972 ;; It's a real article.
12973 (setq article (mail-header-id header)))
12975 ;; It is an extracted pseudo-article.
12976 (setq article 'pseudo)
12977 (gnus-request-pseudo-article header))))
12979 (let ((method (gnus-find-method-for-group
12980 gnus-newsgroup-name)))
12981 (if (not (eq (car method) 'nneething))
12983 (let ((dir (concat (file-name-as-directory (nth 1 method))
12984 (mail-header-subject header))))
12985 (if (file-directory-p dir)
12987 (setq article 'nneething)
12988 (gnus-group-enter-directory dir)))))))))
12991 ;; We first check `gnus-original-article-buffer'.
12992 ((and (equal (car gnus-original-article) group)
12993 (eq (cdr gnus-original-article) article)
12994 (get-buffer gnus-original-article-buffer))
12995 (insert-buffer-substring gnus-original-article-buffer)
12997 ;; Check the backlog.
12998 ((and gnus-keep-backlog
12999 (gnus-backlog-request-article group article (current-buffer)))
13001 ;; Check the cache.
13002 ((and gnus-use-cache
13004 (gnus-cache-request-article article group))
13006 ;; Get the article and put into the article buffer.
13007 ((or (stringp article) (numberp article))
13008 (let ((gnus-override-method
13009 (and (stringp article) gnus-refer-article-method))
13010 (buffer-read-only nil))
13012 (gnus-kill-all-overlays)
13013 (if (gnus-request-article article group (current-buffer))
13015 (and gnus-keep-backlog
13016 (gnus-backlog-enter-article
13017 group article (current-buffer)))
13019 ;; It was a pseudo.
13022 ;; Take the article from the original article buffer
13023 ;; and place it in the buffer it's supposed to be in.
13024 (setq gnus-original-article (cons group article))
13025 (when (equal (buffer-name (current-buffer))
13026 (buffer-name (get-buffer gnus-article-buffer)))
13028 (if (get-buffer gnus-original-article-buffer)
13029 (set-buffer (get-buffer gnus-original-article-buffer))
13030 (set-buffer (get-buffer-create gnus-original-article-buffer))
13031 (buffer-disable-undo (current-buffer))
13032 (setq major-mode 'gnus-original-article-mode)
13033 (setq buffer-read-only t)
13034 (gnus-add-current-to-buffer-list))
13035 (let (buffer-read-only)
13037 (insert-buffer-substring gnus-article-buffer))))
13039 ;; Update sparse articles.
13040 (when (memq article gnus-newsgroup-sparse)
13041 (gnus-summary-update-article article))))
13043 (defun gnus-read-header (id)
13044 "Read the headers of article ID and enter them into the Gnus system."
13045 (let ((group gnus-newsgroup-name)
13046 (headers gnus-newsgroup-headers)
13048 ;; First we check to see whether the header in question is already
13051 ;; This is a Message-ID.
13052 (setq header (gnus-id-to-header id))
13053 ;; This is an article number.
13054 (setq header (gnus-summary-article-header id)))
13056 ;; We have found the header.
13058 ;; We have to really fetch the header to this article.
13060 (if (gnus-check-backend-function 'request-head group)
13061 (gnus-request-head id group)
13062 (gnus-request-article id group)))
13064 (set-buffer nntp-server-buffer)
13065 (and (search-forward "\n\n" nil t)
13066 (delete-region (1- (point)) (point-max)))
13067 (goto-char (point-max))
13069 (goto-char (point-min))
13078 gnus-reffed-article-number)))
13079 " Article retrieved.\n"))
13080 (if (not (setq header (car (gnus-get-newsgroup-headers))))
13081 () ; Malformed head.
13082 (if (and (stringp id)
13083 (not (string= (gnus-group-real-name group)
13085 ;; If we fetched by Message-ID and the article came
13086 ;; from a different group, we fudge some bogus article
13087 ;; numbers for this article.
13088 (mail-header-set-number header gnus-reffed-article-number))
13089 (decf gnus-reffed-article-number)
13090 (push header gnus-newsgroup-headers)
13091 (setq gnus-current-headers header)
13092 (push (mail-header-number header) gnus-newsgroup-limit)
13095 (defun gnus-article-prepare (article &optional all-headers header)
13096 "Prepare ARTICLE in article mode buffer.
13097 ARTICLE should either be an article number or a Message-ID.
13098 If ARTICLE is an id, HEADER should be the article headers.
13099 If ALL-HEADERS is non-nil, no headers are hidden."
13101 ;; Make sure we start in a summary buffer.
13102 (unless (eq major-mode 'gnus-summary-mode)
13103 (set-buffer gnus-summary-buffer))
13104 (setq gnus-summary-buffer (current-buffer))
13105 ;; Make sure the connection to the server is alive.
13106 (unless (gnus-server-opened
13107 (gnus-find-method-for-group gnus-newsgroup-name))
13108 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
13109 (gnus-request-group gnus-newsgroup-name t))
13110 (let* ((article (if header (mail-header-number header) article))
13111 (summary-buffer (current-buffer))
13112 (internal-hook gnus-article-internal-prepare-hook)
13113 (group gnus-newsgroup-name)
13116 (gnus-article-setup-buffer)
13117 (set-buffer gnus-article-buffer)
13118 ;; Deactivate active regions.
13119 (when (and (boundp 'transient-mark-mode)
13120 transient-mark-mode)
13121 (setq mark-active nil))
13122 (if (not (setq result (let ((buffer-read-only nil))
13123 (gnus-request-article-this-buffer
13125 ;; There is no such article.
13127 (when (and (numberp article)
13128 (not (memq article gnus-newsgroup-sparse)))
13129 (setq gnus-article-current
13130 (cons gnus-newsgroup-name article))
13131 (set-buffer gnus-summary-buffer)
13132 (setq gnus-current-article article)
13133 (gnus-summary-mark-article article gnus-canceled-mark))
13134 (unless (memq article gnus-newsgroup-sparse)
13136 1 "No such article (may have expired or been canceled)")
13139 (if (or (eq result 'pseudo) (eq result 'nneething))
13142 (set-buffer summary-buffer)
13143 (setq gnus-last-article gnus-current-article
13144 gnus-newsgroup-history (cons gnus-current-article
13145 gnus-newsgroup-history)
13146 gnus-current-article 0
13147 gnus-current-headers nil
13148 gnus-article-current nil)
13149 (if (eq result 'nneething)
13150 (gnus-configure-windows 'summary)
13151 (gnus-configure-windows 'article))
13152 (gnus-set-global-variables))
13153 (gnus-set-mode-line 'article))
13154 ;; The result from the `request' was an actual article -
13155 ;; or at least some text that is now displayed in the
13157 (if (and (numberp article)
13158 (not (eq article gnus-current-article)))
13159 ;; Seems like a new article has been selected.
13160 ;; `gnus-current-article' must be an article number.
13162 (set-buffer summary-buffer)
13163 (setq gnus-last-article gnus-current-article
13164 gnus-newsgroup-history (cons gnus-current-article
13165 gnus-newsgroup-history)
13166 gnus-current-article article
13167 gnus-current-headers
13168 (gnus-summary-article-header gnus-current-article)
13169 gnus-article-current
13170 (cons gnus-newsgroup-name gnus-current-article))
13171 (unless (vectorp gnus-current-headers)
13172 (setq gnus-current-headers nil))
13173 (gnus-summary-show-thread)
13174 (run-hooks 'gnus-mark-article-hook)
13175 (gnus-set-mode-line 'summary)
13176 (and (gnus-visual-p 'article-highlight 'highlight)
13177 (run-hooks 'gnus-visual-mark-article-hook))
13178 ;; Set the global newsgroup variables here.
13179 ;; Suggested by Jim Sisolak
13180 ;; <sisolak@trans4.neep.wisc.edu>.
13181 (gnus-set-global-variables)
13182 (setq gnus-have-all-headers
13183 (or all-headers gnus-show-all-headers))
13184 (and gnus-use-cache
13185 (vectorp (gnus-summary-article-header article))
13186 (gnus-cache-possibly-enter-article
13188 (gnus-summary-article-header article)
13189 (memq article gnus-newsgroup-marked)
13190 (memq article gnus-newsgroup-dormant)
13191 (memq article gnus-newsgroup-unreads)))))
13192 ;; Hooks for getting information from the article.
13193 ;; This hook must be called before being narrowed.
13194 (let (buffer-read-only)
13195 (run-hooks 'internal-hook)
13196 (run-hooks 'gnus-article-prepare-hook)
13197 ;; Decode MIME message.
13199 (if (or (not gnus-strict-mime)
13200 (gnus-fetch-field "Mime-Version"))
13201 (funcall gnus-show-mime-method)
13202 (funcall gnus-decode-encoded-word-method)))
13203 ;; Perform the article display hooks.
13204 (run-hooks 'gnus-article-display-hook))
13206 (goto-char (point-min))
13207 (and gnus-break-pages (gnus-narrow-to-page))
13208 (gnus-set-mode-line 'article)
13209 (gnus-configure-windows 'article)
13210 (goto-char (point-min))
13213 (defun gnus-article-show-all-headers ()
13214 "Show all article headers in article mode buffer."
13216 (gnus-article-setup-buffer)
13217 (set-buffer gnus-article-buffer)
13218 (let ((buffer-read-only nil))
13219 (remove-text-properties (point-min) (point-max)
13220 gnus-hidden-properties))))
13222 (defun gnus-article-hide-headers-if-wanted ()
13223 "Hide unwanted headers if `gnus-have-all-headers' is nil.
13224 Provided for backwards compatibility."
13225 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers)
13226 gnus-inhibit-hiding
13227 (gnus-article-hide-headers)))
13229 (defun gnus-article-hide-headers (&optional arg delete)
13230 "Toggle whether to hide unwanted headers and possibly sort them as well.
13231 If given a negative prefix, always show; if given a positive prefix,
13234 (unless (gnus-article-check-hidden-text 'headers arg)
13235 ;; This function might be inhibited.
13236 (unless gnus-inhibit-hiding
13238 (set-buffer gnus-article-buffer)
13240 (let ((buffer-read-only nil)
13241 (ignored (when (not (stringp gnus-visible-headers))
13242 (cond ((stringp gnus-ignored-headers)
13243 gnus-ignored-headers)
13244 ((listp gnus-ignored-headers)
13245 (mapconcat 'identity gnus-ignored-headers
13248 (cond ((stringp gnus-visible-headers)
13249 gnus-visible-headers)
13250 ((listp gnus-visible-headers)
13251 (mapconcat 'identity gnus-visible-headers "\\|"))))
13252 want-list beg want-l)
13253 ;; First we narrow to just the headers.
13255 (goto-char (point-min))
13256 ;; Hide any "From " lines at the beginning of (mail) articles.
13257 (while (looking-at "From ")
13260 (add-text-properties
13261 (point-min) (point)
13262 (nconc (list 'gnus-type 'headers) gnus-hidden-properties)))
13263 ;; Then treat the rest of the header lines.
13266 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
13267 ;; Then we use the two regular expressions
13268 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
13269 ;; select which header lines is to remain visible in the
13271 (goto-char (point-min))
13272 (while (re-search-forward "^[^ \t]*:" nil t)
13273 (beginning-of-line)
13274 ;; We add the headers we want to keep to a list and delete
13275 ;; them from the buffer.
13276 (if (or (and visible (looking-at visible))
13277 (and ignored (not (looking-at ignored))))
13279 (push (buffer-substring
13283 ;; Be sure to get multi-line headers...
13284 (re-search-forward "^[^ \t]*:" nil t)
13285 (beginning-of-line)
13288 (delete-region beg (point)))
13290 ;; Sort the headers that we want to display.
13291 (setq want-list (sort want-list 'gnus-article-header-less))
13292 (goto-char (point-min))
13294 (insert (pop want-list)))
13295 ;; We make the unwanted headers invisible.
13297 (delete-region (point-min) (point-max))
13298 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
13299 (add-text-properties
13300 (point) (point-max)
13301 (nconc (list 'gnus-type 'headers)
13302 gnus-hidden-properties)))))))))
13304 (defsubst gnus-article-header-rank (header)
13305 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
13306 (let ((list gnus-sorted-header-list)
13309 (when (string-match (car list) header)
13311 (setq list (cdr list))
13315 (defun gnus-article-header-less (h1 h2)
13316 "Say whether string H1 is \"less\" than string H2."
13317 (< (gnus-article-header-rank h1)
13318 (gnus-article-header-rank h2)))
13320 (defun gnus-article-hide-boring-headers (&optional arg)
13321 "Toggle hiding of headers that aren't very interesting.
13322 If given a negative prefix, always show; if given a positive prefix,
13325 (unless (gnus-article-check-hidden-text 'boring-headers arg)
13327 (set-buffer gnus-article-buffer)
13329 (let ((buffer-read-only nil)
13330 (list gnus-boring-article-headers)
13331 (inhibit-point-motion-hooks t)
13333 (nnheader-narrow-to-headers)
13335 (setq elem (pop list))
13336 (goto-char (point-min))
13338 ;; Hide empty headers.
13340 (while (re-search-forward "^[^:]+:[ \t]\n[^ \t]" nil t)
13342 (add-text-properties
13343 (progn (beginning-of-line) (point))
13346 (if (re-search-forward "^[^ \t]" nil t)
13347 (match-beginning 0)
13349 (nconc (list 'gnus-type 'boring-headers)
13350 gnus-hidden-properties))))
13351 ;; Hide boring Newsgroups header.
13352 ((eq elem 'newsgroups)
13353 (when (equal (mail-fetch-field "newsgroups")
13354 (gnus-group-real-name gnus-newsgroup-name))
13355 (gnus-article-hide-header "newsgroups")))
13356 ((eq elem 'followup-to)
13357 (when (equal (mail-fetch-field "followup-to")
13358 (mail-fetch-field "newsgroups"))
13359 (gnus-article-hide-header "followup-to")))
13360 ((eq elem 'reply-to)
13361 (let ((from (mail-fetch-field "from"))
13362 (reply-to (mail-fetch-field "reply-to")))
13366 (nth 1 (mail-extract-address-components from))
13367 (nth 1 (mail-extract-address-components reply-to))))
13368 (gnus-article-hide-header "reply-to"))))
13370 (let ((date (mail-fetch-field "date")))
13372 (< (gnus-days-between date (current-time-string))
13374 (gnus-article-hide-header "date")))))))))))
13376 (defun gnus-article-hide-header (header)
13378 (goto-char (point-min))
13379 (when (re-search-forward (concat "^" header ":") nil t)
13380 (add-text-properties
13381 (progn (beginning-of-line) (point))
13384 (if (re-search-forward "^[^ \t]" nil t)
13385 (match-beginning 0)
13387 (nconc (list 'gnus-type 'boring-headers)
13388 gnus-hidden-properties)))))
13390 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
13391 (defun gnus-article-treat-overstrike ()
13392 "Translate overstrikes into bold text."
13395 (set-buffer gnus-article-buffer)
13396 (let ((buffer-read-only nil))
13397 (while (search-forward "\b" nil t)
13398 (let ((next (following-char))
13399 (previous (char-after (- (point) 2))))
13400 (cond ((eq next previous)
13401 (put-text-property (- (point) 2) (point) 'invisible t)
13402 (put-text-property (point) (1+ (point)) 'face 'bold))
13404 (put-text-property (1- (point)) (1+ (point)) 'invisible t)
13406 (- (point) 2) (1- (point)) 'face 'underline))
13408 (put-text-property (- (point) 2) (point) 'invisible t)
13410 (point) (1+ (point)) 'face 'underline))))))))
13412 (defun gnus-article-word-wrap ()
13413 "Format too long lines."
13416 (set-buffer gnus-article-buffer)
13417 (let ((buffer-read-only nil)
13420 (goto-char (point-min))
13421 (search-forward "\n\n" nil t)
13423 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
13424 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
13425 (adaptive-fill-mode t))
13426 (while (not (eobp))
13427 (and (>= (current-column) (min fill-column (window-width)))
13428 (/= (preceding-char) ?:)
13429 (fill-paragraph nil))
13430 (end-of-line 2))))))
13432 (defun gnus-article-remove-cr ()
13433 "Remove carriage returns from an article."
13436 (set-buffer gnus-article-buffer)
13437 (let ((buffer-read-only nil))
13438 (goto-char (point-min))
13439 (while (search-forward "\r" nil t)
13440 (replace-match "" t t)))))
13442 (defun gnus-article-remove-trailing-blank-lines ()
13443 "Remove all trailing blank lines from the article."
13446 (set-buffer gnus-article-buffer)
13447 (let ((buffer-read-only nil))
13448 (goto-char (point-max))
13452 (while (looking-at "^[ \t]*$")
13457 (defun gnus-article-display-x-face (&optional force)
13458 "Look for an X-Face header and display it if present."
13459 (interactive (list 'force))
13461 (set-buffer gnus-article-buffer)
13462 ;; Delete the old process, if any.
13463 (when (process-status "gnus-x-face")
13464 (delete-process "gnus-x-face"))
13465 (let ((inhibit-point-motion-hooks t)
13466 (case-fold-search nil)
13469 (nnheader-narrow-to-headers)
13470 (setq from (mail-fetch-field "from"))
13471 (goto-char (point-min))
13472 (when (and gnus-article-x-face-command
13474 ;; Check whether this face is censored.
13475 (not gnus-article-x-face-too-ugly)
13476 (and gnus-article-x-face-too-ugly from
13477 (not (string-match gnus-article-x-face-too-ugly
13479 ;; Has to be present.
13480 (re-search-forward "^X-Face: " nil t))
13481 ;; We now have the area of the buffer where the X-Face is stored.
13482 (let ((beg (point))
13483 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
13484 ;; We display the face.
13485 (if (symbolp gnus-article-x-face-command)
13486 ;; The command is a lisp function, so we call it.
13487 (if (gnus-functionp gnus-article-x-face-command)
13488 (funcall gnus-article-x-face-command beg end)
13489 (error "%s is not a function" gnus-article-x-face-command))
13490 ;; The command is a string, so we interpret the command
13491 ;; as a, well, command, and fork it off.
13492 (let ((process-connection-type nil))
13493 (process-kill-without-query
13495 "gnus-x-face" nil "sh" "-c" gnus-article-x-face-command))
13496 (process-send-region "gnus-x-face" beg end)
13497 (process-send-eof "gnus-x-face")))))))))
13499 (defun gnus-headers-decode-quoted-printable ()
13500 "Hack to remove QP encoding from headers."
13501 (let ((case-fold-search t)
13502 (inhibit-point-motion-hooks t)
13504 (goto-char (point-min))
13505 (while (re-search-forward "=\\?iso-8859-1\\?q\\?\\([^?\t\n]*\\)\\?=" nil t)
13506 (setq string (match-string 1))
13507 (narrow-to-region (match-beginning 0) (match-end 0))
13508 (delete-region (point-min) (point-max))
13510 (gnus-mime-decode-quoted-printable (goto-char (point-min)) (point-max))
13511 (subst-char-in-region (point-min) (point-max) ?_ ? )
13513 (goto-char (point-min)))))
13515 (defun gnus-article-de-quoted-unreadable (&optional force)
13516 "Do a naive translation of a quoted-printable-encoded article.
13517 This is in no way, shape or form meant as a replacement for real MIME
13518 processing, but is simply a stop-gap measure until MIME support is
13520 If FORCE, decode the article whether it is marked as quoted-printable
13522 (interactive (list 'force))
13524 (set-buffer gnus-article-buffer)
13525 (let ((case-fold-search t)
13526 (buffer-read-only nil)
13527 (type (gnus-fetch-field "content-transfer-encoding")))
13529 (and type (string-match "quoted-printable" type)))
13530 (gnus-headers-decode-quoted-printable)
13531 (goto-char (point-min))
13532 (search-forward "\n\n" nil 'move)
13533 (gnus-mime-decode-quoted-printable (point) (point-max))))))
13535 (defun gnus-mime-decode-quoted-printable (from to)
13536 "Decode Quoted-Printable in the region between FROM and TO."
13538 (while (search-forward "=" to t)
13539 (cond ((eq (following-char) ?\n)
13542 ((looking-at "[0-9A-F][0-9A-F]")
13544 (insert (hexl-hex-string-to-integer
13545 (buffer-substring (point) (+ 2 (point)))))
13549 ((gnus-message 3 "Malformed MIME quoted-printable message")))))
13551 (defun gnus-article-hide-pgp (&optional arg)
13552 "Toggle hiding of any PGP headers and signatures in the current article.
13553 If given a negative prefix, always show; if given a positive prefix,
13556 (unless (gnus-article-check-hidden-text 'pgp arg)
13558 (set-buffer gnus-article-buffer)
13559 (let ((props (nconc (list 'gnus-type 'pgp) gnus-hidden-properties))
13560 buffer-read-only beg end)
13562 (goto-char (point-min))
13563 ;; Hide the "header".
13564 (and (search-forward "\n-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
13565 (add-text-properties (match-beginning 0) (match-end 0) props))
13567 ;; Hide the actual signature.
13568 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
13569 (setq end (match-beginning 0))
13570 (add-text-properties
13571 (match-beginning 0)
13572 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
13574 ;; Perhaps we shouldn't hide to the end of the buffer
13575 ;; if there is no end to the signature?
13578 ;; Hide "- " PGP quotation markers.
13579 (when (and beg end)
13580 (narrow-to-region beg end)
13581 (goto-char (point-min))
13582 (while (re-search-forward "^- " nil t)
13583 (add-text-properties (match-beginning 0) (match-end 0) props))
13586 (defun gnus-article-hide-signature (&optional arg)
13587 "Hide the signature in the current article.
13588 If given a negative prefix, always show; if given a positive prefix,
13591 (unless (gnus-article-check-hidden-text 'signature arg)
13593 (set-buffer gnus-article-buffer)
13595 (let ((buffer-read-only nil))
13596 (when (gnus-narrow-to-signature)
13597 (add-text-properties
13598 (point-min) (point-max)
13599 (nconc (list 'gnus-type 'signature)
13600 gnus-hidden-properties))))))))
13602 (defvar gnus-signature-limit nil
13603 "Provide a limit to what is considered a signature.
13604 If it is a number, no signature may not be longer (in characters) than
13605 that number. If it is a function, the function will be called without
13606 any parameters, and if it returns nil, there is no signature in the
13607 buffer. If it is a string, it will be used as a regexp. If it
13608 matches, the text in question is not a signature.")
13610 (defun gnus-narrow-to-signature ()
13611 "Narrow to the signature."
13613 (goto-char (point-max))
13614 (when (re-search-backward gnus-signature-separator nil t)
13616 (when (or (null gnus-signature-limit)
13617 (and (numberp gnus-signature-limit)
13618 (< (- (point-max) (point)) gnus-signature-limit))
13619 (and (gnus-functionp gnus-signature-limit)
13620 (funcall gnus-signature-limit))
13621 (and (stringp gnus-signature-limit)
13622 (not (re-search-forward gnus-signature-limit nil t))))
13623 (narrow-to-region (point) (point-max))
13626 (defun gnus-article-check-hidden-text (type arg)
13627 "Return nil if hiding is necessary."
13629 (set-buffer gnus-article-buffer)
13630 (let ((hide (gnus-article-hidden-text-p type)))
13631 (cond ((or (and (null arg) (eq hide 'hidden))
13632 (and arg (< 0 (prefix-numeric-value arg))))
13633 (gnus-article-show-hidden-text type))
13635 (gnus-article-show-hidden-text type t))
13638 (defun gnus-article-hidden-text-p (type)
13639 "Say whether the current buffer contains hidden text of type TYPE."
13640 (let ((pos (text-property-any (point-min) (point-max) 'gnus-type type))
13643 (if (get-text-property pos 'invisible)
13647 (defun gnus-article-hide (&optional arg force)
13648 "Hide all the gruft in the current article.
13649 This means that PGP stuff, signatures, cited text and (some)
13650 headers will be hidden.
13651 If given a prefix, show the hidden text instead."
13652 (interactive (list current-prefix-arg 'force))
13653 (gnus-article-hide-headers arg)
13654 (gnus-article-hide-pgp arg)
13655 (gnus-article-hide-citation-maybe arg force)
13656 (gnus-article-hide-signature arg))
13658 (defun gnus-article-show-hidden-text (type &optional hide)
13659 "Show all hidden text of type TYPE.
13660 If HIDE, hide the text instead."
13662 (set-buffer gnus-article-buffer)
13663 (let ((buffer-read-only nil)
13664 (inhibit-point-motion-hooks t)
13666 (while (gnus-goto-char (text-property-any
13667 beg (point-max) 'gnus-type type))
13671 (add-text-properties beg (point) gnus-hidden-properties)
13672 (remove-text-properties beg (point) gnus-hidden-properties))
13673 (setq beg (point)))
13676 (defvar gnus-article-time-units
13677 `((year . ,(* 365.25 24 60 60))
13678 (week . ,(* 7 24 60 60))
13679 (day . ,(* 24 60 60))
13680 (hour . ,(* 60 60))
13683 "Mapping from time units to seconds.")
13685 (defun gnus-article-date-ut (&optional type highlight)
13686 "Convert DATE date to universal time in the current article.
13687 If TYPE is `local', convert to local time; if it is `lapsed', output
13688 how much time has lapsed since DATE."
13689 (interactive (list 'ut t))
13690 (let* ((header (or gnus-current-headers
13691 (gnus-summary-article-header) ""))
13692 (date (and (vectorp header) (mail-header-date header)))
13693 (date-regexp "^Date: \\|^X-Sent: ")
13694 (now (current-time))
13695 (inhibit-point-motion-hooks t))
13696 (when (and date (not (string= date "")))
13698 (set-buffer gnus-article-buffer)
13700 (nnheader-narrow-to-headers)
13701 (let ((buffer-read-only nil))
13702 ;; Delete any old Date headers.
13703 (if (zerop (nnheader-remove-header date-regexp t))
13704 (beginning-of-line)
13705 (goto-char (point-max)))
13708 ;; Convert to the local timezone. We have to slap a
13709 ;; `condition-case' round the calls to the timezone
13710 ;; functions since they aren't particularly resistant to
13713 (concat "Date: " (condition-case ()
13714 (timezone-make-date-arpa-standard date)
13717 ;; Convert to Universal Time.
13721 (timezone-make-date-arpa-standard date nil "UT")
13724 ;; Get the original date from the article.
13725 ((eq type 'original)
13726 (concat "Date: " date "\n"))
13727 ;; Do an X-Sent lapsed format.
13729 ;; If the date is seriously mangled, the timezone
13730 ;; functions are liable to bug out, so we condition-case
13731 ;; the entire thing.
13736 (timezone-make-date-arpa-standard
13737 (current-time-string now)
13738 (current-time-zone now) "UT"))
13740 (timezone-make-date-arpa-standard
13743 (real-sec (+ (* (float (car real-time)) 65536)
13745 (sec (abs real-sec))
13751 ;; This is a bit convoluted, but basically we go
13752 ;; through the time units for years, weeks, etc,
13753 ;; and divide things to see whether that results
13754 ;; in positive answers.
13757 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
13758 ;; The (remaining) seconds are too few to
13759 ;; be divided into this time unit.
13761 ;; It's big enough, so we output it.
13762 (setq sec (- sec (* num (cdr unit))))
13764 (concat (if prev ", " "") (int-to-string
13766 " " (symbol-name (car unit))
13767 (if (> num 1) "s" ""))
13769 gnus-article-time-units "")
13770 ;; If dates are odd, then it might appear like the
13771 ;; article was sent in the future.
13774 " in the future\n")))))
13776 (error "Unknown conversion type: %s" type)))))
13777 ;; Do highlighting.
13778 (when (and highlight (gnus-visual-p 'article-highlight 'highlight))
13779 (gnus-article-highlight-headers)))))))
13781 (defun gnus-article-date-local (&optional highlight)
13782 "Convert the current article date to the local timezone."
13783 (interactive (list t))
13784 (gnus-article-date-ut 'local highlight))
13786 (defun gnus-article-date-original (&optional highlight)
13787 "Convert the current article date to what it was originally.
13788 This is only useful if you have used some other date conversion
13789 function and want to see what the date was before converting."
13790 (interactive (list t))
13791 (gnus-article-date-ut 'original highlight))
13793 (defun gnus-article-date-lapsed (&optional highlight)
13794 "Convert the current article date to time lapsed since it was sent."
13795 (interactive (list t))
13796 (gnus-article-date-ut 'lapsed highlight))
13798 (defun gnus-article-maybe-highlight ()
13799 "Do some article highlighting if `gnus-visual' is non-nil."
13800 (if (gnus-visual-p 'article-highlight 'highlight)
13801 (gnus-article-highlight-some)))
13805 (defun gnus-output-to-rmail (file-name)
13806 "Append the current article to an Rmail file named FILE-NAME."
13808 ;; Most of these codes are borrowed from rmailout.el.
13809 (setq file-name (expand-file-name file-name))
13810 (setq rmail-default-rmail-file file-name)
13811 (let ((artbuf (current-buffer))
13812 (tmpbuf (get-buffer-create " *Gnus-output*")))
13814 (or (get-file-buffer file-name)
13815 (file-exists-p file-name)
13816 (if (gnus-yes-or-no-p
13817 (concat "\"" file-name "\" does not exist, create it? "))
13818 (let ((file-buffer (create-file-buffer file-name)))
13820 (set-buffer file-buffer)
13821 (rmail-insert-rmail-file-header)
13822 (let ((require-final-newline nil))
13823 (write-region (point-min) (point-max) file-name t 1)))
13824 (kill-buffer file-buffer))
13825 (error "Output file does not exist")))
13826 (set-buffer tmpbuf)
13827 (buffer-disable-undo (current-buffer))
13829 (insert-buffer-substring artbuf)
13830 (gnus-convert-article-to-rmail)
13831 ;; Decide whether to append to a file or to an Emacs buffer.
13832 (let ((outbuf (get-file-buffer file-name)))
13834 (append-to-file (point-min) (point-max) file-name)
13835 ;; File has been visited, in buffer OUTBUF.
13836 (set-buffer outbuf)
13837 (let ((buffer-read-only nil)
13838 (msg (and (boundp 'rmail-current-message)
13839 (symbol-value 'rmail-current-message))))
13840 ;; If MSG is non-nil, buffer is in RMAIL mode.
13843 (narrow-to-region (point-max) (point-max))))
13844 (insert-buffer-substring tmpbuf)
13847 (goto-char (point-min))
13849 (search-backward "\^_")
13850 (narrow-to-region (point) (point-max))
13851 (goto-char (1+ (point-min)))
13852 (rmail-count-new-messages t)
13853 (rmail-show-message msg)))))))
13854 (kill-buffer tmpbuf)))
13856 (defun gnus-output-to-file (file-name)
13857 "Append the current article to a file named FILE-NAME."
13858 (setq file-name (expand-file-name file-name))
13859 (let ((artbuf (current-buffer))
13860 (tmpbuf (get-buffer-create " *Gnus-output*")))
13862 (set-buffer tmpbuf)
13863 (buffer-disable-undo (current-buffer))
13865 (insert-buffer-substring artbuf)
13866 ;; Append newline at end of the buffer as separator, and then
13867 ;; save it to file.
13868 (goto-char (point-max))
13870 (append-to-file (point-min) (point-max) file-name))
13871 (kill-buffer tmpbuf)))
13873 (defun gnus-convert-article-to-rmail ()
13874 "Convert article in current buffer to Rmail message format."
13875 (let ((buffer-read-only nil))
13876 ;; Convert article directly into Babyl format.
13877 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
13878 (goto-char (point-min))
13879 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
13880 (while (search-forward "\n\^_" nil t) ;single char
13881 (replace-match "\n^_" t t)) ;2 chars: "^" and "_"
13882 (goto-char (point-max))
13885 (defun gnus-narrow-to-page (&optional arg)
13886 "Narrow the article buffer to a page.
13887 If given a numerical ARG, move forward ARG pages."
13889 (setq arg (if arg (prefix-numeric-value arg) 0))
13891 (set-buffer gnus-article-buffer)
13892 (goto-char (point-min))
13894 (when (gnus-visual-p 'page-marker)
13895 (let ((buffer-read-only nil))
13896 (gnus-remove-text-with-property 'gnus-prev)
13897 (gnus-remove-text-with-property 'gnus-next)))
13900 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
13902 (re-search-forward page-delimiter nil 'move arg)))
13903 (goto-char (match-end 0)))
13906 (if (re-search-forward page-delimiter nil 'move)
13907 (match-beginning 0)
13909 (when (and (gnus-visual-p 'page-marker)
13910 (not (= (point-min) 1)))
13912 (goto-char (point-min))
13913 (gnus-insert-prev-page-button)))
13914 (when (and (gnus-visual-p 'page-marker)
13915 (not (= (1- (point-max)) (buffer-size))))
13917 (goto-char (point-max))
13918 (gnus-insert-next-page-button)))))
13921 ;; Article mode commands
13923 (defun gnus-article-goto-next-page ()
13924 "Show the next page of the article."
13926 (when (gnus-article-next-page)
13927 (gnus-article-read-summary-keys nil ?n)))
13929 (defun gnus-article-goto-prev-page ()
13930 "Show the next page of the article."
13932 (if (bobp) (gnus-article-read-summary-keys nil ?n)
13933 (gnus-article-prev-page nil)))
13935 (defun gnus-article-next-page (&optional lines)
13936 "Show the next page of the current article.
13937 If end of article, return non-nil. Otherwise return nil.
13938 Argument LINES specifies lines to be scrolled up."
13940 (move-to-window-line -1)
13941 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
13942 (if (save-excursion
13944 (and (pos-visible-in-window-p) ;Not continuation line.
13946 ;; Nothing in this page.
13947 (if (or (not gnus-break-pages)
13950 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
13952 (gnus-narrow-to-page 1) ;Go to next page.
13954 ;; More in this page.
13958 ;; Long lines may cause an end-of-buffer error.
13959 (goto-char (point-max))))
13962 (defun gnus-article-prev-page (&optional lines)
13963 "Show previous page of current article.
13964 Argument LINES specifies lines to be scrolled down."
13966 (move-to-window-line 0)
13967 (if (and gnus-break-pages
13969 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
13971 (gnus-narrow-to-page -1) ;Go to previous page.
13972 (goto-char (point-max))
13975 (scroll-down lines)
13978 (defun gnus-article-refer-article ()
13979 "Read article specified by message-id around point."
13981 (let ((point (point)))
13982 (search-forward ">" nil t) ;Move point to end of "<....>".
13983 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
13984 (let ((message-id (match-string 1)))
13986 (set-buffer gnus-summary-buffer)
13987 (gnus-summary-refer-article message-id))
13988 (goto-char (point))
13989 (error "No references around point"))))
13991 (defun gnus-article-show-summary ()
13992 "Reconfigure windows to show summary buffer."
13994 (gnus-configure-windows 'article)
13995 (gnus-summary-goto-subject gnus-current-article))
13997 (defun gnus-article-describe-briefly ()
13998 "Describe article mode commands briefly."
14001 (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")))
14003 (defun gnus-article-summary-command ()
14004 "Execute the last keystroke in the summary buffer."
14006 (let ((obuf (current-buffer))
14007 (owin (current-window-configuration))
14009 (switch-to-buffer gnus-summary-buffer 'norecord)
14010 (setq func (lookup-key (current-local-map) (this-command-keys)))
14011 (call-interactively func)
14013 (set-window-configuration owin)
14014 (set-window-point (get-buffer-window (current-buffer)) (point))))
14016 (defun gnus-article-summary-command-nosave ()
14017 "Execute the last keystroke in the summary buffer."
14020 (pop-to-buffer gnus-summary-buffer 'norecord)
14021 (setq func (lookup-key (current-local-map) (this-command-keys)))
14022 (call-interactively func)))
14024 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
14025 "Read a summary buffer key sequence and execute it from the article buffer."
14028 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
14029 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
14033 (set-buffer gnus-summary-buffer)
14034 (push (or key last-command-event) unread-command-events)
14035 (setq keys (read-key-sequence nil)))
14038 (if (member keys nosaves)
14040 (pop-to-buffer gnus-summary-buffer 'norecord)
14041 (if (setq func (lookup-key (current-local-map) keys))
14042 (call-interactively func)
14044 (let ((obuf (current-buffer))
14045 (owin (current-window-configuration))
14048 (if not-restore-window
14049 (pop-to-buffer gnus-summary-buffer 'norecord)
14050 (switch-to-buffer gnus-summary-buffer 'norecord))
14051 (setq in-buffer (current-buffer))
14052 (if (setq func (lookup-key (current-local-map) keys))
14053 (call-interactively func)
14055 (when (eq in-buffer (current-buffer))
14057 (unless not-restore-window
14058 (set-window-configuration owin))
14059 (set-window-point (get-buffer-window (current-buffer)) opoint))))))
14062 ;; Basic ideas by emv@math.lsa.umich.edu (Edward Vielmetti)
14065 (defalias 'gnus-batch-kill 'gnus-batch-score)
14067 (defun gnus-batch-score ()
14068 "Run batched scoring.
14069 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
14070 Newsgroups is a list of strings in Bnews format. If you want to score
14071 the comp hierarchy, you'd say \"comp.all\". If you would not like to
14072 score the alt hierarchy, you'd say \"!alt.all\"."
14075 (gnus-newsrc-parse-options
14076 (apply (function concat)
14077 (mapcar (lambda (g) (concat g " "))
14078 command-line-args-left))))
14079 (gnus-expert-user t)
14080 (nnmail-spool-file nil)
14081 (gnus-use-dribble-file nil)
14082 (yes (car yes-and-no))
14083 (no (cdr yes-and-no))
14085 ;; Disable verbose message.
14086 gnus-novice-user gnus-large-newsgroup)
14087 ;; Eat all arguments.
14088 (setq command-line-args-left nil)
14091 ;; Apply kills to specified newsgroups in command line arguments.
14092 (setq newsrc (cdr gnus-newsrc-alist))
14094 (setq group (car (car newsrc)))
14095 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
14096 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed)
14098 (or (eq (car entry) t)
14099 (not (zerop (car entry)))))
14100 (if yes (string-match yes group) t)
14101 (or (null no) (not (string-match no group))))
14103 (gnus-summary-read-group group nil t nil t)
14104 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
14105 (gnus-summary-exit))))
14106 (setq newsrc (cdr newsrc)))
14108 (switch-to-buffer gnus-group-buffer)
14109 (gnus-group-save-newsrc)))
14111 (defun gnus-apply-kill-file ()
14112 "Apply a kill file to the current newsgroup.
14113 Returns the number of articles marked as read."
14114 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
14115 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14116 (gnus-apply-kill-file-internal)
14119 (defun gnus-kill-save-kill-buffer ()
14121 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14122 (if (get-file-buffer file)
14124 (set-buffer (get-file-buffer file))
14125 (and (buffer-modified-p) (save-buffer))
14126 (kill-buffer (current-buffer)))))))
14128 (defvar gnus-kill-file-name "KILL"
14129 "Suffix of the kill files.")
14131 (defun gnus-newsgroup-kill-file (newsgroup)
14132 "Return the name of a kill file name for NEWSGROUP.
14133 If NEWSGROUP is nil, return the global kill file name instead."
14134 (cond ((or (null newsgroup)
14135 (string-equal newsgroup ""))
14136 ;; The global KILL file is placed at top of the directory.
14137 (expand-file-name gnus-kill-file-name
14138 (or gnus-kill-files-directory "~/News")))
14139 ((gnus-use-long-file-name 'not-kill)
14140 ;; Append ".KILL" to newsgroup name.
14141 (expand-file-name (concat (gnus-newsgroup-savable-name newsgroup)
14142 "." gnus-kill-file-name)
14143 (or gnus-kill-files-directory "~/News")))
14145 ;; Place "KILL" under the hierarchical directory.
14146 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
14147 "/" gnus-kill-file-name)
14148 (or gnus-kill-files-directory "~/News")))))
14155 (defvar gnus-dribble-ignore nil)
14156 (defvar gnus-dribble-eval-file nil)
14158 (defun gnus-dribble-file-name ()
14159 "Return the dribble file for the current .newsrc."
14161 (if gnus-dribble-directory
14162 (concat (file-name-as-directory gnus-dribble-directory)
14163 (file-name-nondirectory gnus-current-startup-file))
14164 gnus-current-startup-file)
14167 (defun gnus-dribble-enter (string)
14168 "Enter STRING into the dribble buffer."
14169 (if (and (not gnus-dribble-ignore)
14170 gnus-dribble-buffer
14171 (buffer-name gnus-dribble-buffer))
14172 (let ((obuf (current-buffer)))
14173 (set-buffer gnus-dribble-buffer)
14174 (insert string "\n")
14175 (set-window-point (get-buffer-window (current-buffer)) (point-max))
14176 (set-buffer obuf))))
14178 (defun gnus-dribble-read-file ()
14179 "Read the dribble file from disk."
14180 (let ((dribble-file (gnus-dribble-file-name)))
14182 (set-buffer (setq gnus-dribble-buffer
14184 (file-name-nondirectory dribble-file))))
14185 (gnus-add-current-to-buffer-list)
14187 (setq buffer-file-name dribble-file)
14189 (buffer-disable-undo (current-buffer))
14190 (bury-buffer (current-buffer))
14191 (set-buffer-modified-p nil)
14192 (let ((auto (make-auto-save-file-name))
14193 (gnus-dribble-ignore t))
14194 (when (or (file-exists-p auto) (file-exists-p dribble-file))
14195 ;; Load whichever file is newest -- the auto save file
14196 ;; or the "real" file.
14197 (if (file-newer-than-file-p auto dribble-file)
14198 (insert-file-contents auto)
14199 (insert-file-contents dribble-file))
14200 (unless (zerop (buffer-size))
14201 (set-buffer-modified-p t))
14202 ;; Set the file modes to reflect the .newsrc file modes.
14204 (when (file-exists-p gnus-current-startup-file)
14205 (set-file-modes dribble-file
14206 (file-modes gnus-current-startup-file)))
14207 ;; Possibly eval the file later.
14208 (when (gnus-y-or-n-p
14209 "Auto-save file exists. Do you want to read it? ")
14210 (setq gnus-dribble-eval-file t)))))))
14212 (defun gnus-dribble-eval-file ()
14213 (if (not gnus-dribble-eval-file)
14215 (setq gnus-dribble-eval-file nil)
14217 (let ((gnus-dribble-ignore t))
14218 (set-buffer gnus-dribble-buffer)
14219 (eval-buffer (current-buffer))))))
14221 (defun gnus-dribble-delete-file ()
14222 (if (file-exists-p (gnus-dribble-file-name))
14223 (delete-file (gnus-dribble-file-name)))
14224 (if gnus-dribble-buffer
14226 (set-buffer gnus-dribble-buffer)
14227 (let ((auto (make-auto-save-file-name)))
14228 (if (file-exists-p auto)
14229 (delete-file auto))
14231 (set-buffer-modified-p nil)))))
14233 (defun gnus-dribble-save ()
14234 (if (and gnus-dribble-buffer
14235 (buffer-name gnus-dribble-buffer))
14237 (set-buffer gnus-dribble-buffer)
14240 (defun gnus-dribble-clear ()
14242 (if (gnus-buffer-exists-p gnus-dribble-buffer)
14244 (set-buffer gnus-dribble-buffer)
14246 (set-buffer-modified-p nil)
14247 (setq buffer-saved-size (buffer-size))))))
14250 ;;; Server Communication
14253 (defun gnus-start-news-server (&optional confirm)
14254 "Open a method for getting news.
14255 If CONFIRM is non-nil, the user will be asked for an NNTP server."
14257 (if gnus-current-select-method
14258 ;; Stream is already opened.
14260 ;; Open NNTP server.
14261 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
14264 ;; Read server name with completion.
14265 (setq gnus-nntp-server
14266 (completing-read "NNTP server: "
14267 (mapcar (lambda (server) (list server))
14268 (cons (list gnus-nntp-server)
14269 gnus-secondary-servers))
14270 nil nil gnus-nntp-server))))
14272 (if (and gnus-nntp-server
14273 (stringp gnus-nntp-server)
14274 (not (string= gnus-nntp-server "")))
14275 (setq gnus-select-method
14276 (cond ((or (string= gnus-nntp-server "")
14277 (string= gnus-nntp-server "::"))
14278 (list 'nnspool (system-name)))
14279 ((string-match "^:" gnus-nntp-server)
14280 (list 'nnmh gnus-nntp-server
14281 (list 'nnmh-directory
14282 (file-name-as-directory
14284 (concat "~/" (substring
14285 gnus-nntp-server 1)))))
14286 (list 'nnmh-get-new-mail nil)))
14288 (list 'nntp gnus-nntp-server)))))
14290 (setq how (car gnus-select-method))
14291 (cond ((eq how 'nnspool)
14293 (gnus-message 5 "Looking up local news spool..."))
14296 (gnus-message 5 "Looking up mh spool..."))
14299 (setq gnus-current-select-method gnus-select-method)
14300 (run-hooks 'gnus-open-server-hook)
14302 ;; gnus-open-server-hook might have opened it
14303 (gnus-server-opened gnus-select-method)
14304 (gnus-open-server gnus-select-method)
14307 "%s (%s) open error: '%s'. Continue? "
14308 (car gnus-select-method) (cadr gnus-select-method)
14309 (gnus-status-message gnus-select-method)))
14311 (gnus-message 1 "Couldn't open server on %s"
14312 (nth 1 gnus-select-method))
14316 (defun gnus-check-group (group)
14317 "Try to make sure that the server where GROUP exists is alive."
14318 (let ((method (gnus-find-method-for-group group)))
14319 (or (gnus-server-opened method)
14320 (gnus-open-server method))))
14322 (defun gnus-check-server (&optional method)
14323 "Check whether the connection to METHOD is down.
14324 If METHOD is nil, use `gnus-select-method'.
14325 If it is down, start it up (again)."
14326 (let ((method (or method gnus-select-method)))
14327 ;; Transform virtual server names into select methods.
14328 (when (stringp method)
14329 (setq method (gnus-server-to-method method)))
14330 (if (gnus-server-opened method)
14331 ;; The stream is already opened.
14333 ;; Open the server.
14334 (gnus-message 5 "Opening %s server on %s..." (car method) (nth 1 method))
14335 (run-hooks 'gnus-open-server-hook)
14337 (gnus-open-server method)
14340 (defun gnus-get-function (method function)
14341 "Return a function symbol based on METHOD and FUNCTION."
14342 ;; Translate server names into methods.
14344 (error "Attempted use of a nil select method"))
14345 (when (stringp method)
14346 (setq method (gnus-server-to-method method)))
14347 (let ((func (intern (format "%s-%s" (car method) function))))
14348 ;; If the functions isn't bound, we require the backend in
14350 (unless (fboundp func)
14351 (require (car method))
14352 (unless (fboundp func)
14353 ;; This backend doesn't implement this function.
14354 (error "No such function: %s" func)))
14357 ;;; Interface functions to the backends.
14359 (defun gnus-open-server (method)
14360 "Open a connection to METHOD."
14361 (let ((elem (assoc method gnus-opened-servers)))
14362 ;; If this method was previously denied, we just return nil.
14363 (if (eq (nth 1 elem) 'denied)
14365 (gnus-message 1 "Denied server")
14367 ;; Open the server.
14369 (funcall (gnus-get-function method 'open-server)
14370 (nth 1 method) (nthcdr 2 method))))
14371 ;; If this hasn't been opened before, we add it to the list.
14373 (setq elem (list method nil)
14374 gnus-opened-servers (cons elem gnus-opened-servers)))
14375 ;; Set the status of this server.
14376 (setcar (cdr elem) (if result 'ok 'denied))
14377 ;; Return the result from the "open" call.
14380 (defun gnus-close-server (method)
14381 "Close the connection to METHOD."
14382 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
14384 (defun gnus-request-list (method)
14385 "Request the active file from METHOD."
14386 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
14388 (defun gnus-request-list-newsgroups (method)
14389 "Request the newsgroups file from METHOD."
14390 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
14392 (defun gnus-request-newgroups (date method)
14393 "Request all new groups since DATE from METHOD."
14394 (funcall (gnus-get-function method 'request-newgroups)
14395 date (nth 1 method)))
14397 (defun gnus-server-opened (method)
14398 "Check whether a connection to METHOD has been opened."
14399 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
14401 (defun gnus-status-message (method)
14402 "Return the status message from METHOD.
14403 If METHOD is a string, it is interpreted as a group name. The method
14404 this group uses will be queried."
14405 (let ((method (if (stringp method) (gnus-find-method-for-group method)
14407 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
14409 (defun gnus-request-group (group &optional dont-check method)
14410 "Request GROUP. If DONT-CHECK, no information is required."
14411 (let ((method (or method (gnus-find-method-for-group group))))
14412 (funcall (gnus-get-function method 'request-group)
14413 (gnus-group-real-name group) (nth 1 method) dont-check)))
14415 (defun gnus-request-asynchronous (group &optional articles)
14416 "Request that GROUP behave asynchronously.
14417 ARTICLES is the `data' of the group."
14418 (let ((method (gnus-find-method-for-group group)))
14419 (funcall (gnus-get-function method 'request-asynchronous)
14420 (gnus-group-real-name group) (nth 1 method) articles)))
14422 (defun gnus-list-active-group (group)
14423 "Request active information on GROUP."
14424 (let ((method (gnus-find-method-for-group group))
14425 (func 'list-active-group))
14426 (when (gnus-check-backend-function func group)
14427 (funcall (gnus-get-function method func)
14428 (gnus-group-real-name group) (nth 1 method)))))
14430 (defun gnus-request-group-description (group)
14431 "Request a description of GROUP."
14432 (let ((method (gnus-find-method-for-group group))
14433 (func 'request-group-description))
14434 (when (gnus-check-backend-function func group)
14435 (funcall (gnus-get-function method func)
14436 (gnus-group-real-name group) (nth 1 method)))))
14438 (defun gnus-close-group (group)
14439 "Request the GROUP be closed."
14440 (let ((method (gnus-find-method-for-group group)))
14441 (funcall (gnus-get-function method 'close-group)
14442 (gnus-group-real-name group) (nth 1 method))))
14444 (defun gnus-retrieve-headers (articles group &optional fetch-old)
14445 "Request headers for ARTICLES in GROUP.
14446 If FETCH-OLD, retrieve all headers (or some subset thereof) in the group."
14447 (let ((method (gnus-find-method-for-group group)))
14448 (if (and gnus-use-cache (numberp (car articles)))
14449 (gnus-cache-retrieve-headers articles group fetch-old)
14450 (funcall (gnus-get-function method 'retrieve-headers)
14451 articles (gnus-group-real-name group) (nth 1 method)
14454 (defun gnus-retrieve-groups (groups method)
14455 "Request active information on GROUPS from METHOD."
14456 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method)))
14458 (defun gnus-request-type (group &optional article)
14459 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
14460 (let ((method (gnus-find-method-for-group group)))
14461 (if (not (gnus-check-backend-function 'request-type (car method)))
14463 (funcall (gnus-get-function method 'request-type)
14464 (gnus-group-real-name group) article))))
14466 (defun gnus-request-update-mark (group article mark)
14467 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
14468 (let ((method (gnus-find-method-for-group group)))
14469 (if (not (gnus-check-backend-function 'request-update-mark (car method)))
14471 (funcall (gnus-get-function method 'request-update-mark)
14472 (gnus-group-real-name group) article mark))))
14474 (defun gnus-request-article (article group &optional buffer)
14475 "Request the ARTICLE in GROUP.
14476 ARTICLE can either be an article number or an article Message-ID.
14477 If BUFFER, insert the article in that group."
14478 (let ((method (gnus-find-method-for-group group)))
14479 (funcall (gnus-get-function method 'request-article)
14480 article (gnus-group-real-name group) (nth 1 method) buffer)))
14482 (defun gnus-request-head (article group)
14483 "Request the head of ARTICLE in GROUP."
14484 (let ((method (gnus-find-method-for-group group)))
14485 (funcall (gnus-get-function method 'request-head)
14486 article (gnus-group-real-name group) (nth 1 method))))
14488 (defun gnus-request-body (article group)
14489 "Request the body of ARTICLE in GROUP."
14490 (let ((method (gnus-find-method-for-group group)))
14491 (funcall (gnus-get-function method 'request-body)
14492 article (gnus-group-real-name group) (nth 1 method))))
14494 (defun gnus-request-post (method)
14495 "Post the current buffer using METHOD."
14496 (funcall (gnus-get-function method 'request-post) (nth 1 method)))
14498 (defun gnus-request-scan (group method)
14499 "Request a SCAN being performed in GROUP from METHOD.
14500 If GROUP is nil, all groups on METHOD are scanned."
14501 (let ((method (if group (gnus-find-method-for-group group) method)))
14502 (funcall (gnus-get-function method 'request-scan)
14503 (and group (gnus-group-real-name group)) (nth 1 method))))
14505 (defsubst gnus-request-update-info (info method)
14506 "Request that METHOD update INFO."
14507 (when (gnus-check-backend-function 'request-update-info (car method))
14508 (funcall (gnus-get-function method 'request-update-info)
14509 (gnus-group-real-name (gnus-info-group info))
14510 info (nth 1 method))))
14512 (defun gnus-request-expire-articles (articles group &optional force)
14513 (let ((method (gnus-find-method-for-group group)))
14514 (funcall (gnus-get-function method 'request-expire-articles)
14515 articles (gnus-group-real-name group) (nth 1 method)
14518 (defun gnus-request-move-article
14519 (article group server accept-function &optional last)
14520 (let ((method (gnus-find-method-for-group group)))
14521 (funcall (gnus-get-function method 'request-move-article)
14522 article (gnus-group-real-name group)
14523 (nth 1 method) accept-function last)))
14525 (defun gnus-request-accept-article (group &optional last method)
14526 ;; Make sure there's a newline at the end of the article.
14527 (goto-char (point-max))
14530 (let ((func (if (symbolp group) group
14531 (car (or method (gnus-find-method-for-group group))))))
14532 (funcall (intern (format "%s-request-accept-article" func))
14533 (if (stringp group) (gnus-group-real-name group) group)
14536 (defun gnus-request-replace-article (article group buffer)
14537 (let ((func (car (gnus-find-method-for-group group))))
14538 (funcall (intern (format "%s-request-replace-article" func))
14539 article (gnus-group-real-name group) buffer)))
14541 (defun gnus-request-associate-buffer (group)
14542 (let ((method (gnus-find-method-for-group group)))
14543 (funcall (gnus-get-function method 'request-associate-buffer)
14544 (gnus-group-real-name group))))
14546 (defun gnus-request-restore-buffer (article group)
14547 "Request a new buffer restored to the state of ARTICLE."
14548 (let ((method (gnus-find-method-for-group group)))
14549 (funcall (gnus-get-function method 'request-restore-buffer)
14550 article (gnus-group-real-name group) (nth 1 method))))
14552 (defun gnus-request-create-group (group &optional method)
14553 (let ((method (or method (gnus-find-method-for-group group))))
14554 (funcall (gnus-get-function method 'request-create-group)
14555 (gnus-group-real-name group) (nth 1 method))))
14557 (defun gnus-request-delete-group (group &optional force)
14558 (let ((method (gnus-find-method-for-group group)))
14559 (funcall (gnus-get-function method 'request-delete-group)
14560 (gnus-group-real-name group) force (nth 1 method))))
14562 (defun gnus-request-rename-group (group new-name)
14563 (let ((method (gnus-find-method-for-group group)))
14564 (funcall (gnus-get-function method 'request-rename-group)
14565 (gnus-group-real-name group)
14566 (gnus-group-real-name new-name) (nth 1 method))))
14568 (defun gnus-member-of-valid (symbol group)
14569 "Find out if GROUP has SYMBOL as part of its \"valid\" spec."
14570 (memq symbol (assoc
14571 (symbol-name (car (gnus-find-method-for-group group)))
14572 gnus-valid-select-methods)))
14574 (defun gnus-method-option-p (method option)
14575 "Return non-nil if select METHOD has OPTION as a parameter."
14576 (memq option (assoc (format "%s" (car method))
14577 gnus-valid-select-methods)))
14579 (defun gnus-server-extend-method (group method)
14580 ;; This function "extends" a virtual server. If the server is
14581 ;; "hello", and the select method is ("hello" (my-var "something"))
14582 ;; in the group "alt.alt", this will result in a new virtual server
14583 ;; called "hello+alt.alt".
14585 (gnus-copy-sequence
14586 (if (equal (car method) "native") gnus-select-method
14587 (cdr (assoc (car method) gnus-server-alist))))))
14588 (setcar (cdr entry) (concat (nth 1 entry) "+" group))
14589 (nconc entry (cdr method))))
14591 (defun gnus-find-method-for-group (group &optional info)
14592 "Find the select method that GROUP uses."
14593 (or gnus-override-method
14595 gnus-select-method)
14596 (let ((info (or info (gnus-get-info group)))
14599 (not (setq method (gnus-info-method info))))
14600 (setq method gnus-select-method)
14602 (cond ((stringp method)
14603 (gnus-server-to-method method))
14604 ((stringp (car method))
14605 (gnus-server-extend-method group method))
14608 (gnus-server-add-address method))))
14610 (defun gnus-check-backend-function (func group)
14611 "Check whether GROUP supports function FUNC."
14612 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
14614 (fboundp (intern (format "%s-%s" method func)))))
14616 (defun gnus-methods-using (feature)
14617 "Find all methods that have FEATURE."
14618 (let ((valids gnus-valid-select-methods)
14621 (if (memq feature (car valids))
14622 (setq outs (cons (car valids) outs)))
14623 (setq valids (cdr valids)))
14627 ;;; Active & Newsrc File Handling
14630 (defun gnus-setup-news (&optional rawfile level)
14631 "Setup news information.
14632 If RAWFILE is non-nil, the .newsrc file will also be read.
14633 If LEVEL is non-nil, the news will be set up at level LEVEL."
14634 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile)))))
14635 ;; Clear some variables to re-initialize news information.
14636 (if init (setq gnus-newsrc-alist nil
14637 gnus-active-hashtb nil))
14639 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
14640 (if init (gnus-read-newsrc-file rawfile))
14642 ;; If we don't read the complete active file, we fill in the
14644 (if (or (null gnus-read-active-file)
14645 (eq gnus-read-active-file 'some))
14646 (gnus-update-active-hashtb-from-killed))
14648 ;; Read the active file and create `gnus-active-hashtb'.
14649 ;; If `gnus-read-active-file' is nil, then we just create an empty
14650 ;; hash table. The partial filling out of the hash table will be
14651 ;; done in `gnus-get-unread-articles'.
14652 (and gnus-read-active-file
14654 (gnus-read-active-file))
14656 (or gnus-active-hashtb
14657 (setq gnus-active-hashtb (make-vector 4095 0)))
14659 ;; Initialize the cache.
14660 (when gnus-use-cache
14663 ;; Possibly eval the dribble file.
14664 (and init (or gnus-use-dribble-file gnus-slave) (gnus-dribble-eval-file))
14666 (gnus-update-format-specifications)
14668 ;; Find new newsgroups and treat them.
14669 (if (and init gnus-check-new-newsgroups (not level)
14670 (gnus-check-server gnus-select-method))
14671 (gnus-find-new-newsgroups))
14673 ;; Find the number of unread articles in each non-dead group.
14674 (let ((gnus-read-active-file (and (not level) gnus-read-active-file)))
14675 (gnus-get-unread-articles level))
14677 (if (and init gnus-check-bogus-newsgroups
14678 gnus-read-active-file (not level)
14679 (gnus-server-opened gnus-select-method))
14680 (gnus-check-bogus-newsgroups))))
14682 (defun gnus-find-new-newsgroups (&optional arg)
14683 "Search for new newsgroups and add them.
14684 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
14685 The `-n' option line from .newsrc is respected.
14686 If ARG (the prefix), use the `ask-server' method to query
14687 the server for new groups."
14689 (let ((check (if (or (and arg (not (listp gnus-check-new-newsgroups)))
14690 (null gnus-read-active-file)
14691 (eq gnus-read-active-file 'some))
14692 'ask-server gnus-check-new-newsgroups)))
14693 (unless (gnus-check-first-time-used)
14694 (if (or (consp check)
14695 (eq check 'ask-server))
14696 (gnus-ask-server-for-new-groups)
14698 group new-newsgroups)
14699 (gnus-message 5 "Looking for new newsgroups...")
14700 (or gnus-have-read-active-file (gnus-read-active-file))
14701 (setq gnus-newsrc-last-checked-date (current-time-string))
14702 (if (not gnus-killed-hashtb) (gnus-make-hashtable-from-killed))
14703 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
14704 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
14707 (if (or (null (setq group (symbol-name sym)))
14709 (null (symbol-value sym))
14710 (gnus-gethash group gnus-killed-hashtb)
14711 (gnus-gethash group gnus-newsrc-hashtb))
14713 (let ((do-sub (gnus-matches-options-n group)))
14715 ((eq do-sub 'subscribe)
14716 (setq groups (1+ groups))
14717 (gnus-sethash group group gnus-killed-hashtb)
14718 (funcall gnus-subscribe-options-newsgroup-method group))
14719 ((eq do-sub 'ignore)
14722 (setq groups (1+ groups))
14723 (gnus-sethash group group gnus-killed-hashtb)
14724 (if gnus-subscribe-hierarchical-interactive
14725 (setq new-newsgroups (cons group new-newsgroups))
14726 (funcall gnus-subscribe-newsgroup-method group)))))))
14727 gnus-active-hashtb)
14729 (gnus-subscribe-hierarchical-interactive new-newsgroups))
14730 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
14732 (gnus-message 6 "%d new newsgroup%s arrived."
14733 groups (if (> groups 1) "s have" " has"))
14734 (gnus-message 6 "No new newsgroups.")))))))
14736 (defun gnus-matches-options-n (group)
14737 ;; Returns `subscribe' if the group is to be unconditionally
14738 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
14739 ;; no match for the group.
14741 ;; First we check the two user variables.
14743 ((and gnus-options-subscribe
14744 (string-match gnus-options-subscribe group))
14746 ((and gnus-auto-subscribed-groups
14747 (string-match gnus-auto-subscribed-groups group))
14749 ((and gnus-options-not-subscribe
14750 (string-match gnus-options-not-subscribe group))
14752 ;; Then we go through the list that was retrieved from the .newsrc
14753 ;; file. This list has elements on the form
14754 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
14755 ;; is in the reverse order of the options line) is returned.
14757 (let ((regs gnus-newsrc-options-n))
14759 (not (string-match (car (car regs)) group)))
14760 (setq regs (cdr regs)))
14761 (and regs (cdr (car regs)))))))
14763 (defun gnus-ask-server-for-new-groups ()
14764 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
14765 (methods (cons gnus-select-method
14767 gnus-message-archive-method
14769 (and (consp gnus-check-new-newsgroups)
14770 gnus-check-new-newsgroups)
14771 gnus-secondary-select-methods))))
14773 (new-date (current-time-string))
14774 group new-newsgroups got-new method hashtb
14775 gnus-override-subscribe-method)
14776 ;; Go through both primary and secondary select methods and
14777 ;; request new newsgroups.
14778 (while (setq method (gnus-server-get-method nil (pop methods)))
14779 (setq gnus-override-subscribe-method method)
14780 (when (and (gnus-check-server method)
14781 (gnus-request-newgroups date method))
14784 (setq hashtb (gnus-make-hashtable 100))
14785 (set-buffer nntp-server-buffer)
14786 ;; Enter all the new groups into a hashtable.
14787 (gnus-active-to-gnus-format method hashtb 'ignore)))
14788 ;; Now all new groups from `method' are in `hashtb'.
14790 (lambda (group-sym)
14791 (if (or (null (setq group (symbol-name group-sym)))
14792 (null (symbol-value group-sym))
14793 (gnus-gethash group gnus-newsrc-hashtb)
14794 (member group gnus-zombie-list)
14795 (member group gnus-killed-list))
14796 ;; The group is already known.
14798 ;; Make this group active.
14799 (when (symbol-value group-sym)
14800 (gnus-set-active group (symbol-value group-sym)))
14801 ;; Check whether we want it or not.
14802 (let ((do-sub (gnus-matches-options-n group)))
14804 ((eq do-sub 'subscribe)
14806 (gnus-sethash group group gnus-killed-hashtb)
14807 (funcall gnus-subscribe-options-newsgroup-method group))
14808 ((eq do-sub 'ignore)
14812 (gnus-sethash group group gnus-killed-hashtb)
14813 (if gnus-subscribe-hierarchical-interactive
14814 (push group new-newsgroups)
14815 (funcall gnus-subscribe-newsgroup-method group)))))))
14817 (when new-newsgroups
14818 (gnus-subscribe-hierarchical-interactive new-newsgroups)))
14819 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
14821 (gnus-message 6 "%d new newsgroup%s arrived."
14822 groups (if (> groups 1) "s have" " has")))
14823 (and got-new (setq gnus-newsrc-last-checked-date new-date))
14826 (defun gnus-check-first-time-used ()
14827 (if (or (> (length gnus-newsrc-alist) 1)
14828 (file-exists-p gnus-startup-file)
14829 (file-exists-p (concat gnus-startup-file ".el"))
14830 (file-exists-p (concat gnus-startup-file ".eld")))
14832 (gnus-message 6 "First time user; subscribing you to default groups")
14833 (or gnus-have-read-active-file (gnus-read-active-file))
14834 (setq gnus-newsrc-last-checked-date (current-time-string))
14835 (let ((groups gnus-default-subscribed-newsgroups)
14839 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
14842 (if (null (setq group (symbol-name sym)))
14844 (let ((do-sub (gnus-matches-options-n group)))
14846 ((eq do-sub 'subscribe)
14847 (gnus-sethash group group gnus-killed-hashtb)
14848 (funcall gnus-subscribe-options-newsgroup-method group))
14849 ((eq do-sub 'ignore)
14852 (setq gnus-killed-list (cons group gnus-killed-list)))))))
14853 gnus-active-hashtb)
14855 (if (gnus-active (car groups))
14856 (gnus-group-change-level
14857 (car groups) gnus-level-default-subscribed gnus-level-killed))
14858 (setq groups (cdr groups)))
14859 (gnus-group-make-help-group)
14860 (and gnus-novice-user
14861 (gnus-message 7 "`A k' to list killed groups"))))))
14863 (defun gnus-subscribe-group (group previous &optional method)
14864 (gnus-group-change-level
14866 (list t group gnus-level-default-subscribed nil nil method)
14868 gnus-level-default-subscribed gnus-level-killed previous t))
14870 ;; `gnus-group-change-level' is the fundamental function for changing
14871 ;; subscription levels of newsgroups. This might mean just changing
14872 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
14873 ;; again, which subscribes/unsubscribes a group, which is equally
14874 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
14875 ;; from 8-9 to 1-7 means that you remove the group from the list of
14876 ;; killed (or zombie) groups and add them to the (kinda) subscribed
14877 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
14878 ;; which is trivial.
14879 ;; ENTRY can either be a string (newsgroup name) or a list (if
14880 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
14881 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
14883 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
14884 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
14886 (defun gnus-group-change-level (entry level &optional oldlevel
14887 previous fromkilled)
14888 (let (group info active num)
14889 ;; Glean what info we can from the arguments
14891 (if fromkilled (setq group (nth 1 entry))
14892 (setq group (car (nth 2 entry))))
14893 (setq group entry))
14894 (if (and (stringp entry)
14896 (< oldlevel gnus-level-zombie))
14897 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
14898 (if (and (not oldlevel)
14900 (setq oldlevel (car (cdr (nth 2 entry)))))
14901 (if (stringp previous)
14902 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
14904 (if (and (>= oldlevel gnus-level-zombie)
14905 (gnus-gethash group gnus-newsrc-hashtb))
14906 ;; We are trying to subscribe a group that is already
14910 (or (gnus-ephemeral-group-p group)
14911 (gnus-dribble-enter
14912 (format "(gnus-group-change-level %S %S %S %S %S)"
14913 group level oldlevel (car (nth 2 previous)) fromkilled)))
14915 ;; Then we remove the newgroup from any old structures, if needed.
14916 ;; If the group was killed, we remove it from the killed or zombie
14917 ;; list. If not, and it is in fact going to be killed, we remove
14918 ;; it from the newsrc hash table and assoc.
14919 (cond ((>= oldlevel gnus-level-zombie)
14920 (if (= oldlevel gnus-level-zombie)
14921 (setq gnus-zombie-list (delete group gnus-zombie-list))
14922 (setq gnus-killed-list (delete group gnus-killed-list))))
14924 (if (and (>= level gnus-level-zombie)
14927 (gnus-sethash (car (nth 2 entry)) nil gnus-newsrc-hashtb)
14929 (setcdr (gnus-gethash (car (nth 3 entry))
14930 gnus-newsrc-hashtb)
14932 (setcdr (cdr entry) (cdr (cdr (cdr entry))))))))
14934 ;; Finally we enter (if needed) the list where it is supposed to
14935 ;; go, and change the subscription level. If it is to be killed,
14936 ;; we enter it into the killed or zombie list.
14937 (cond ((>= level gnus-level-zombie)
14938 ;; Remove from the hash table.
14939 (gnus-sethash group nil gnus-newsrc-hashtb)
14940 ;; We do not enter foreign groups into the list of dead
14942 (unless (gnus-group-foreign-p group)
14943 (if (= level gnus-level-zombie)
14944 (setq gnus-zombie-list (cons group gnus-zombie-list))
14945 (setq gnus-killed-list (cons group gnus-killed-list)))))
14947 ;; If the list is to be entered into the newsrc assoc, and
14948 ;; it was killed, we have to create an entry in the newsrc
14949 ;; hashtb format and fix the pointers in the newsrc assoc.
14950 (if (>= oldlevel gnus-level-zombie)
14954 (setq info (cdr entry))
14955 (setq num (car entry)))
14956 (setq active (gnus-active group))
14958 (if active (- (1+ (cdr active)) (car active)) t))
14959 ;; Check whether the group is foreign. If so, the
14960 ;; foreign select method has to be entered into the
14962 (let ((method (or gnus-override-subscribe-method
14963 (gnus-group-method-name group))))
14964 (if (eq method gnus-select-method)
14965 (setq info (list group level nil))
14966 (setq info (list group level nil nil method)))))
14969 (let ((p gnus-newsrc-alist))
14970 (while (cdr (cdr p))
14973 (setq entry (cons info (cdr (cdr previous))))
14976 (setcdr (cdr previous) entry)
14977 (gnus-sethash group (cons num (cdr previous))
14978 gnus-newsrc-hashtb))
14979 (setcdr previous entry)
14980 (gnus-sethash group (cons num previous)
14981 gnus-newsrc-hashtb))
14983 (setcdr (gnus-gethash (car (car (cdr entry)))
14984 gnus-newsrc-hashtb)
14986 ;; It was alive, and it is going to stay alive, so we
14987 ;; just change the level and don't change any pointers or
14988 ;; hash table entries.
14989 (setcar (cdr (car (cdr (cdr entry)))) level))))
14990 (when gnus-group-change-level-function
14991 (funcall gnus-group-change-level-function group level oldlevel)))))
14993 (defun gnus-kill-newsgroup (newsgroup)
14994 "Obsolete function. Kills a newsgroup."
14995 (gnus-group-change-level
14996 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed))
14998 (defun gnus-check-bogus-newsgroups (&optional confirm)
14999 "Remove bogus newsgroups.
15000 If CONFIRM is non-nil, the user has to confirm the deletion of every
15002 (let ((newsrc (cdr gnus-newsrc-alist))
15003 bogus group entry info)
15004 (gnus-message 5 "Checking bogus newsgroups...")
15005 (unless gnus-have-read-active-file
15006 (gnus-read-active-file))
15007 (when (member gnus-select-method gnus-have-read-active-file)
15008 ;; Find all bogus newsgroup that are subscribed.
15010 (setq info (pop newsrc)
15011 group (gnus-info-group info))
15012 (unless (or (gnus-active group) ; Active
15013 (gnus-info-method info) ; Foreign
15015 (not (gnus-y-or-n-p
15016 (format "Remove bogus newsgroup: %s " group)))))
15017 ;; Found a bogus newsgroup.
15018 (push group bogus)))
15019 ;; Remove all bogus subscribed groups by first killing them, and
15020 ;; then removing them from the list of killed groups.
15022 (when (setq entry (gnus-gethash (setq group (pop bogus))
15023 gnus-newsrc-hashtb))
15024 (gnus-group-change-level entry gnus-level-killed)
15025 (setq gnus-killed-list (delete group gnus-killed-list))))
15026 ;; Then we remove all bogus groups from the list of killed and
15027 ;; zombie groups. They are are removed without confirmation.
15028 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
15031 (setq killed (symbol-value (car dead-lists)))
15033 (unless (gnus-active (setq group (pop killed)))
15034 ;; The group is bogus.
15035 ;; !!!Slow as hell.
15036 (set (car dead-lists)
15037 (delete group (symbol-value (car dead-lists))))))
15038 (setq dead-lists (cdr dead-lists))))
15039 (gnus-message 5 "Checking bogus newsgroups...done"))))
15041 (defun gnus-check-duplicate-killed-groups ()
15042 "Remove duplicates from the list of killed groups."
15044 (let ((killed gnus-killed-list))
15046 (gnus-message 9 "%d" (length killed))
15047 (setcdr killed (delete (car killed) (cdr killed)))
15048 (setq killed (cdr killed)))))
15050 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
15051 ;; and compute how many unread articles there are in each group.
15052 (defun gnus-get-unread-articles (&optional level)
15053 (let* ((newsrc (cdr gnus-newsrc-alist))
15054 (level (or level gnus-activate-level (1+ gnus-level-subscribed)))
15057 (cond ((and gnus-activate-foreign-newsgroups
15058 (not (numberp gnus-activate-foreign-newsgroups)))
15059 (1+ gnus-level-subscribed))
15060 ((numberp gnus-activate-foreign-newsgroups)
15061 gnus-activate-foreign-newsgroups)
15064 info group active virtuals method fmethod)
15065 (gnus-message 5 "Checking new news...")
15068 (setq info (car newsrc)
15069 group (gnus-info-group info)
15070 active (gnus-active group))
15072 ;; Check newsgroups. If the user doesn't want to check them, or
15073 ;; they can't be checked (for instance, if the news server can't
15074 ;; be reached) we just set the number of unread articles in this
15075 ;; newsgroup to t. This means that Gnus thinks that there are
15076 ;; unread articles, but it has no idea how many.
15077 (if (and (setq method (gnus-info-method info))
15078 (not (gnus-server-equal
15080 (setq fmethod (gnus-server-get-method nil method))))
15081 (not (gnus-secondary-method-p method)))
15082 ;; These groups are foreign. Check the level.
15083 (if (<= (gnus-info-level info) foreign-level)
15084 (setq active (gnus-activate-group (gnus-info-group info) 'scan)))
15086 ;; These groups are native or secondary.
15087 (if (<= (gnus-info-level info) level)
15088 (or gnus-read-active-file
15089 (setq active (gnus-activate-group
15090 (gnus-info-group info) 'scan)))))
15093 (gnus-get-unread-articles-in-group info active t)
15094 ;; The group couldn't be reached, so we nix out the number of
15095 ;; unread articles and stuff.
15096 (gnus-set-active group nil)
15097 (setcar (gnus-gethash group gnus-newsrc-hashtb) t))
15099 (setq newsrc (cdr newsrc)))
15101 (gnus-message 5 "Checking new news...done")))
15103 ;; Create a hash table out of the newsrc alist. The `car's of the
15104 ;; alist elements are used as keys.
15105 (defun gnus-make-hashtable-from-newsrc-alist ()
15106 (let ((alist gnus-newsrc-alist)
15107 (ohashtb gnus-newsrc-hashtb)
15109 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
15111 (setq prev (setq gnus-newsrc-alist
15112 (if (equal (car (car gnus-newsrc-alist))
15115 (cons (list "dummy.group" 0 nil) alist)))))
15119 (cons (and ohashtb (car (gnus-gethash (car (car alist)) ohashtb)))
15121 gnus-newsrc-hashtb)
15123 alist (cdr alist)))))
15125 (defun gnus-make-hashtable-from-killed ()
15126 "Create a hash table from the killed and zombie lists."
15127 (let ((lists '(gnus-killed-list gnus-zombie-list))
15129 (setq gnus-killed-hashtb
15130 (gnus-make-hashtable
15131 (+ (length gnus-killed-list) (length gnus-zombie-list))))
15133 (setq list (symbol-value (car lists)))
15134 (setq lists (cdr lists))
15136 (gnus-sethash (car list) (car list) gnus-killed-hashtb)
15137 (setq list (cdr list))))))
15139 (defun gnus-get-unread-articles-in-group (info active &optional update)
15140 ;; Allow the backend to update the info in the group.
15142 (gnus-request-update-info
15143 info (gnus-find-method-for-group (gnus-info-group info))))
15144 (let* ((range (gnus-info-read info))
15146 (marked (gnus-info-marks info)))
15147 ;; If a cache is present, we may have to alter the active info.
15148 (and gnus-use-cache
15149 (gnus-cache-possibly-alter-active (gnus-info-group info) active))
15150 ;; Modify the list of read articles according to what articles
15151 ;; are available; then tally the unread articles and add the
15152 ;; number to the group hash table entry.
15154 ((zerop (cdr active))
15157 (setq num (- (1+ (cdr active)) (car active))))
15158 ((not (listp (cdr range)))
15159 ;; Fix a single (num . num) range according to the
15160 ;; active hash table.
15161 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
15162 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
15163 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
15164 ;; Compute number of unread articles.
15165 (setq num (max 0 (- (cdr active) (- (1+ (cdr range)) (car range))))))
15167 ;; The read list is a list of ranges. Fix them according to
15168 ;; the active hash table.
15169 ;; First peel off any elements that are below the lower
15171 (while (and (cdr range)
15173 (or (and (atom (car (cdr range))) (car (cdr range)))
15174 (car (car (cdr range))))))
15175 (if (numberp (car range))
15178 (or (and (numberp (car (cdr range)))
15180 (cdr (car (cdr range))))))
15181 (setcdr (car range)
15182 (or (and (numberp (nth 1 range)) (nth 1 range))
15183 (cdr (car (cdr range))))))
15184 (setcdr range (cdr (cdr range))))
15185 ;; Adjust the first element to be the same as the lower limit.
15186 (if (and (not (atom (car range)))
15187 (< (cdr (car range)) (car active)))
15188 (setcdr (car range) (1- (car active))))
15189 ;; Then we want to peel off any elements that are higher
15190 ;; than the upper active limit.
15191 (let ((srange range))
15192 ;; Go past all legal elements.
15193 (while (and (cdr srange)
15194 (<= (or (and (atom (car (cdr srange)))
15195 (car (cdr srange)))
15196 (car (car (cdr srange)))) (cdr active)))
15197 (setq srange (cdr srange)))
15199 ;; Nuke all remaining illegal elements.
15200 (setcdr srange nil))
15202 ;; Adjust the final element.
15203 (if (and (not (atom (car srange)))
15204 (> (cdr (car srange)) (cdr active)))
15205 (setcdr (car srange) (cdr active))))
15206 ;; Compute the number of unread articles.
15208 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
15209 (cdr (car range))))
15210 (or (and (atom (car range)) (car range))
15211 (car (car range))))))
15212 (setq range (cdr range)))
15213 (setq num (max 0 (- (cdr active) num)))))
15214 ;; Set the number of unread articles.
15215 (setcar (gnus-gethash (gnus-info-group info) gnus-newsrc-hashtb) num)
15218 (defun gnus-activate-group (group &optional scan)
15219 ;; Check whether a group has been activated or not.
15220 ;; If SCAN, request a scan of that group as well.
15221 (let ((method (gnus-find-method-for-group group))
15223 (and (gnus-check-server method)
15224 ;; We escape all bugs and quit here to make it possible to
15225 ;; continue if a group is so out-there that it reports bugs
15229 (gnus-check-backend-function 'request-scan (car method))
15230 (gnus-request-scan group method))
15233 (gnus-request-group group)
15237 (set-buffer nntp-server-buffer)
15238 (goto-char (point-min))
15239 ;; Parse the result we got from `gnus-request-group'.
15240 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
15242 (goto-char (match-beginning 1))
15244 group (setq active (cons (read (current-buffer))
15245 (read (current-buffer)))))
15246 ;; Return the new active info.
15249 (defun gnus-update-read-articles (group unread)
15250 "Update the list of read and ticked articles in GROUP using the
15251 UNREAD and TICKED lists.
15252 Note: UNSELECTED has to be sorted over `<'.
15253 Returns whether the updating was successful."
15254 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
15255 (entry (gnus-gethash group gnus-newsrc-hashtb))
15256 (info (nth 2 entry))
15257 (marked (gnus-info-marks info))
15259 (unread (sort (copy-sequence unread) '<))
15261 (if (or (not info) (not active))
15262 ;; There is no info on this group if it was, in fact,
15263 ;; killed. Gnus stores no information on killed groups, so
15264 ;; there's nothing to be done.
15265 ;; One could store the information somewhere temporarily,
15266 ;; perhaps... Hmmm...
15268 ;; Remove any negative articles numbers.
15269 (while (and unread (< (car unread) 0))
15270 (setq unread (cdr unread)))
15271 ;; Remove any expired article numbers
15272 (while (and unread (< (car unread) (car active)))
15273 (setq unread (cdr unread)))
15274 ;; Compute the ranges of read articles by looking at the list of
15275 ;; unread articles.
15277 (if (/= (car unread) prev)
15278 (setq read (cons (if (= prev (1- (car unread))) prev
15279 (cons prev (1- (car unread)))) read)))
15280 (setq prev (1+ (car unread)))
15281 (setq unread (cdr unread)))
15282 (when (<= prev (cdr active))
15283 (setq read (cons (cons prev (cdr active)) read)))
15284 ;; Enter this list into the group info.
15285 (gnus-info-set-read
15286 info (if (> (length read) 1) (nreverse read) read))
15287 ;; Set the number of unread articles in gnus-newsrc-hashtb.
15288 (gnus-get-unread-articles-in-group info (gnus-active group))
15291 (defun gnus-make-articles-unread (group articles)
15292 "Mark ARTICLES in GROUP as unread."
15293 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
15294 (gnus-gethash (gnus-group-real-name group)
15295 gnus-newsrc-hashtb))))
15296 (ranges (gnus-info-read info))
15299 (when (gnus-member-of-range
15300 (setq article (pop articles)) ranges)
15301 (setq news (cons article news))))
15303 (gnus-info-set-read
15304 info (gnus-remove-from-range (gnus-info-read info) (nreverse news)))
15305 (gnus-group-update-group group t))))
15307 ;; Enter all dead groups into the hashtb.
15308 (defun gnus-update-active-hashtb-from-killed ()
15309 (let ((hashtb (setq gnus-active-hashtb (make-vector 4095 0)))
15310 (lists (list gnus-killed-list gnus-zombie-list))
15313 (setq killed (car lists))
15315 (gnus-sethash (car killed) nil hashtb)
15316 (setq killed (cdr killed)))
15317 (setq lists (cdr lists)))))
15319 ;; Get the active file(s) from the backend(s).
15320 (defun gnus-read-active-file ()
15321 (gnus-group-set-mode-line)
15322 (let ((methods (nconc (copy-sequence
15323 (if (gnus-check-server gnus-select-method)
15324 ;; The native server is available.
15325 (cons gnus-select-method
15326 gnus-secondary-select-methods)
15327 ;; The native server is down, so we just do the
15329 gnus-secondary-select-methods))
15330 (list gnus-message-archive-method)))
15332 (setq gnus-have-read-active-file nil)
15334 (set-buffer nntp-server-buffer)
15336 (let* ((method (gnus-server-get-method nil (car methods)))
15337 (where (nth 1 method))
15338 (mesg (format "Reading active file%s via %s..."
15339 (if (and where (not (zerop (length where))))
15340 (concat " from " where) "")
15342 (gnus-message 5 mesg)
15343 (if (not (gnus-check-server method))
15345 ;; Request that the backend scan its incoming messages.
15346 (and (gnus-check-backend-function 'request-scan (car method))
15347 (gnus-request-scan nil method))
15349 ((and (eq gnus-read-active-file 'some)
15350 (gnus-check-backend-function 'retrieve-groups (car method)))
15351 (let ((newsrc (cdr gnus-newsrc-alist))
15352 (gmethod (gnus-server-get-method nil method))
15355 (and (gnus-server-equal
15356 (gnus-find-method-for-group
15357 (car (car newsrc)) (car newsrc))
15359 (setq groups (cons (gnus-group-real-name
15360 (car (car newsrc))) groups)))
15361 (setq newsrc (cdr newsrc)))
15362 (gnus-check-server method)
15363 (setq list-type (gnus-retrieve-groups groups method))
15367 1 "Cannot read partial active file from %s server."
15371 ((eq list-type 'active)
15372 (gnus-active-to-gnus-format method gnus-active-hashtb))
15374 (gnus-groups-to-gnus-format method gnus-active-hashtb)))))
15376 (if (not (gnus-request-list method))
15378 (unless (equal method gnus-message-archive-method)
15379 (gnus-message 1 "Cannot read active file from %s server."
15382 (gnus-active-to-gnus-format method)
15383 ;; We mark this active file as read.
15384 (setq gnus-have-read-active-file
15385 (cons method gnus-have-read-active-file))
15386 (gnus-message 5 "%sdone" mesg))))))
15387 (setq methods (cdr methods))))))
15389 ;; Read an active file and place the results in `gnus-active-hashtb'.
15390 (defun gnus-active-to-gnus-format (&optional method hashtb ignore-errors)
15392 (setq method gnus-select-method))
15393 (let ((cur (current-buffer))
15395 (if (and gnus-active-hashtb
15396 (not (equal method gnus-select-method)))
15398 (setq gnus-active-hashtb
15399 (if (equal method gnus-select-method)
15400 (gnus-make-hashtable
15401 (count-lines (point-min) (point-max)))
15402 (gnus-make-hashtable 4096))))))
15403 (flag-hashtb (gnus-make-hashtable 60)))
15404 ;; Delete unnecessary lines.
15405 (goto-char (point-min))
15406 (while (search-forward "\nto." nil t)
15407 (delete-region (1+ (match-beginning 0))
15408 (progn (forward-line 1) (point))))
15409 (or (string= gnus-ignored-newsgroups "")
15411 (goto-char (point-min))
15412 (delete-matching-lines gnus-ignored-newsgroups)))
15413 ;; Make the group names readable as a lisp expression even if they
15414 ;; contain special characters.
15415 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
15416 (goto-char (point-max))
15417 (while (re-search-backward "[][';?()#]" nil t)
15419 ;; If these are groups from a foreign select method, we insert the
15420 ;; group prefix in front of the group names.
15421 (and method (not (gnus-server-equal
15422 (gnus-server-get-method nil method)
15423 (gnus-server-get-method nil gnus-select-method)))
15424 (let ((prefix (gnus-group-prefixed-name "" method)))
15425 (goto-char (point-min))
15426 (while (and (not (eobp))
15427 (progn (insert prefix)
15428 (zerop (forward-line 1)))))))
15429 ;; Store the active file in a hash table.
15430 (goto-char (point-min))
15431 (if (string-match "%[oO]" gnus-group-line-format)
15432 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
15433 ;; If we want information on moderated groups, we use this
15435 (let* ((mod-hashtb (make-vector 7 0))
15436 (m (intern "m" mod-hashtb))
15438 (while (not (eobp))
15439 (condition-case nil
15441 (narrow-to-region (point) (gnus-point-at-eol))
15442 (setq group (let ((obarray hashtb)) (read cur)))
15443 (if (and (numberp (setq max (read cur)))
15444 (numberp (setq min (read cur)))
15446 (skip-chars-forward " \t")
15448 (or (= (following-char) ?=)
15449 (= (following-char) ?x)
15450 (= (following-char) ?j)))))
15451 (set group (cons min max))
15453 ;; Enter moderated groups into a list.
15454 (if (eq (let ((obarray mod-hashtb)) (read cur)) m)
15455 (setq gnus-moderated-list
15456 (cons (symbol-name group) gnus-moderated-list))))
15463 ;; And if we do not care about moderation, we use this loop,
15464 ;; which is faster.
15465 (let (group max min)
15466 (while (not (eobp))
15469 (narrow-to-region (point) (gnus-point-at-eol))
15470 ;; group gets set to a symbol interned in the hash table
15471 ;; (what a hack!!) - jwz
15472 (setq group (let ((obarray hashtb)) (read cur)))
15473 (if (and (numberp (setq max (read cur)))
15474 (numberp (setq min (read cur)))
15476 (skip-chars-forward " \t")
15478 (or (= (following-char) ?=)
15479 (= (following-char) ?x)
15480 (= (following-char) ?j)))))
15481 (set group (cons min max))
15489 (gnus-message 3 "Warning - illegal active: %s"
15491 (gnus-point-at-bol) (gnus-point-at-eol)))))))
15493 (forward-line 1))))))
15495 (defun gnus-groups-to-gnus-format (method &optional hashtb)
15496 ;; Parse a "groups" active file.
15497 (let ((cur (current-buffer))
15499 (if (and method gnus-active-hashtb)
15501 (setq gnus-active-hashtb
15502 (gnus-make-hashtable
15503 (count-lines (point-min) (point-max)))))))
15504 (prefix (and method
15505 (not (gnus-server-equal
15506 (gnus-server-get-method nil method)
15507 (gnus-server-get-method nil gnus-select-method)))
15508 (gnus-group-prefixed-name "" method))))
15510 (goto-char (point-min))
15511 ;; We split this into to separate loops, one with the prefix
15512 ;; and one without to speed the reading up somewhat.
15514 (let (min max opoint group)
15515 (while (not (eobp))
15518 (read cur) (read cur)
15519 (setq min (read cur)
15522 (skip-chars-forward " \t")
15525 (set (let ((obarray hashtb)) (read cur))
15527 (error (and group (symbolp group) (set group nil))))
15529 (let (min max group)
15530 (while (not (eobp))
15532 (if (= (following-char) ?2)
15534 (read cur) (read cur)
15535 (setq min (read cur)
15537 (set (setq group (let ((obarray hashtb)) (read cur)))
15539 (error (and group (symbolp group) (set group nil))))
15540 (forward-line 1))))))
15542 (defun gnus-read-newsrc-file (&optional force)
15543 "Read startup file.
15544 If FORCE is non-nil, the .newsrc file is read."
15545 ;; Reset variables that might be defined in the .newsrc.eld file.
15546 (let ((variables gnus-variable-list))
15548 (set (car variables) nil)
15549 (setq variables (cdr variables))))
15550 (let* ((newsrc-file gnus-current-startup-file)
15551 (quick-file (concat newsrc-file ".el")))
15553 ;; We always load the .newsrc.eld file. If always contains
15554 ;; much information that can not be gotten from the .newsrc
15555 ;; file (ticked articles, killed groups, foreign methods, etc.)
15556 (gnus-read-newsrc-el-file quick-file)
15559 (and (file-newer-than-file-p newsrc-file quick-file)
15560 (file-newer-than-file-p newsrc-file
15561 (concat quick-file "d")))
15562 (not gnus-newsrc-alist))
15563 ;; We read the .newsrc file. Note that if there if a
15564 ;; .newsrc.eld file exists, it has already been read, and
15565 ;; the `gnus-newsrc-hashtb' has been created. While reading
15566 ;; the .newsrc file, Gnus will only use the information it
15567 ;; can find there for changing the data already read -
15568 ;; ie. reading the .newsrc file will not trash the data
15569 ;; already read (except for read articles).
15571 (gnus-message 5 "Reading %s..." newsrc-file)
15572 (set-buffer (find-file-noselect newsrc-file))
15573 (buffer-disable-undo (current-buffer))
15574 (gnus-newsrc-to-gnus-format)
15575 (kill-buffer (current-buffer))
15576 (gnus-message 5 "Reading %s...done" newsrc-file)))
15578 ;; Read any slave files.
15580 (gnus-master-read-slave-newsrc)))))
15582 (defun gnus-read-newsrc-el-file (file)
15583 (let ((ding-file (concat file "d")))
15584 ;; We always, always read the .eld file.
15585 (gnus-message 5 "Reading %s..." ding-file)
15586 (let (gnus-newsrc-assoc)
15587 (condition-case nil
15588 (load ding-file t t t)
15590 (gnus-message 1 "Error in %s" ding-file)
15592 (when gnus-newsrc-assoc
15593 (setq gnus-newsrc-alist gnus-newsrc-assoc)))
15594 (gnus-make-hashtable-from-newsrc-alist)
15595 (when (file-newer-than-file-p file ding-file)
15596 ;; Old format quick file
15597 (gnus-message 5 "Reading %s..." file)
15598 ;; The .el file is newer than the .eld file, so we read that one
15600 (gnus-read-old-newsrc-el-file file))))
15602 ;; Parse the old-style quick startup file
15603 (defun gnus-read-old-newsrc-el-file (file)
15604 (let (newsrc killed marked group m)
15606 (let ((gnus-killed-assoc nil)
15607 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc)
15609 (condition-case nil
15612 (setq newsrc gnus-newsrc-assoc
15613 killed gnus-killed-assoc
15614 marked gnus-marked-assoc)))
15615 (setq gnus-newsrc-alist nil)
15617 (setq group (car newsrc))
15618 (let ((info (gnus-get-info (car group))))
15621 (gnus-info-set-read info (cdr (cdr group)))
15622 (gnus-info-set-level
15623 info (if (nth 1 group) gnus-level-default-subscribed
15624 gnus-level-default-unsubscribed))
15625 (setq gnus-newsrc-alist (cons info gnus-newsrc-alist)))
15626 (setq gnus-newsrc-alist
15630 (if (nth 1 group) gnus-level-default-subscribed
15631 gnus-level-default-unsubscribed)
15632 (cdr (cdr group))))
15633 gnus-newsrc-alist)))
15634 (if (setq m (assoc (car group) marked))
15635 (gnus-info-set-marks
15636 info (cons (list (cons 'tick (gnus-compress-sequence
15637 (sort (cdr m) '<) t)))
15639 (setq newsrc (cdr newsrc)))
15640 (setq newsrc killed)
15642 (setcar newsrc (car (car newsrc)))
15643 (setq newsrc (cdr newsrc)))
15644 (setq gnus-killed-list killed))
15645 ;; The .el file version of this variable does not begin with
15646 ;; "options", while the .eld version does, so we just add it if it
15649 gnus-newsrc-options
15651 (and (not (string-match "^ *options" gnus-newsrc-options))
15652 (setq gnus-newsrc-options (concat "options " gnus-newsrc-options)))
15653 (and (not (string-match "\n$" gnus-newsrc-options))
15654 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n")))
15655 ;; Finally, if we read some options lines, we parse them.
15656 (or (string= gnus-newsrc-options "")
15657 (gnus-newsrc-parse-options gnus-newsrc-options))))
15659 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))
15660 (gnus-make-hashtable-from-newsrc-alist)))
15662 (defun gnus-make-newsrc-file (file)
15663 "Make server dependent file name by catenating FILE and server host name."
15664 (let* ((file (expand-file-name file nil))
15665 (real-file (concat file "-" (nth 1 gnus-select-method))))
15666 (if (or (file-exists-p real-file)
15667 (file-exists-p (concat real-file ".el"))
15668 (file-exists-p (concat real-file ".eld")))
15671 (defun gnus-newsrc-to-gnus-format ()
15672 (setq gnus-newsrc-options "")
15673 (setq gnus-newsrc-options-n nil)
15675 (or gnus-active-hashtb
15676 (setq gnus-active-hashtb (make-vector 4095 0)))
15677 (let ((buf (current-buffer))
15678 (already-read (> (length gnus-newsrc-alist) 1))
15679 group subscribed options-symbol newsrc Options-symbol
15681 (goto-char (point-min))
15682 ;; We intern the symbol `options' in the active hashtb so that we
15683 ;; can `eq' against it later.
15684 (set (setq options-symbol (intern "options" gnus-active-hashtb)) nil)
15685 (set (setq Options-symbol (intern "Options" gnus-active-hashtb)) nil)
15687 (while (not (eobp))
15688 ;; We first read the first word on the line by narrowing and
15689 ;; then reading into `gnus-active-hashtb'. Most groups will
15690 ;; already exist in that hashtb, so this will save some string
15694 (progn (skip-chars-forward "^ \t!:\n") (point)))
15695 (goto-char (point-min))
15697 (and (/= (point-min) (point-max))
15698 (let ((obarray gnus-active-hashtb)) (read buf))))
15700 ;; Now, the symbol we have read is either `options' or a group
15701 ;; name. If it is an options line, we just add it to a string.
15703 ((or (eq symbol options-symbol)
15704 (eq symbol Options-symbol))
15705 (setq gnus-newsrc-options
15706 ;; This concating is quite inefficient, but since our
15707 ;; thorough studies show that approx 99.37% of all
15708 ;; .newsrc files only contain a single options line, we
15709 ;; don't give a damn, frankly, my dear.
15710 (concat gnus-newsrc-options
15712 (gnus-point-at-bol)
15713 ;; Options may continue on the next line.
15714 (or (and (re-search-forward "^[^ \t]" nil 'move)
15715 (progn (beginning-of-line) (point)))
15719 ;; Group names can be just numbers.
15720 (when (numberp symbol)
15721 (setq symbol (intern (int-to-string symbol) gnus-active-hashtb)))
15722 (or (boundp symbol) (set symbol nil))
15723 ;; It was a group name.
15724 (setq subscribed (= (following-char) ?:)
15725 group (symbol-name symbol)
15728 ;; If the line ends here, this is clearly a buggy line, so
15729 ;; we put point a the beginning of line and let the cond
15730 ;; below do the error handling.
15731 (beginning-of-line)
15732 ;; We skip to the beginning of the ranges.
15733 (skip-chars-forward "!: \t"))
15734 ;; We are now at the beginning of the list of read articles.
15735 ;; We read them range by range.
15738 ((looking-at "[0-9]+")
15739 ;; We narrow and read a number instead of buffer-substring/
15740 ;; string-to-int because it's faster. narrow/widen is
15741 ;; faster than save-restriction/narrow, and save-restriction
15742 ;; produces a garbage object.
15744 (narrow-to-region (match-beginning 0) (match-end 0))
15747 ;; If the next character is a dash, then this is a range.
15748 (if (= (following-char) ?-)
15750 ;; We read the upper bound of the range.
15752 (if (not (looking-at "[0-9]+"))
15753 ;; This is a buggy line, by we pretend that
15754 ;; it's kinda OK. Perhaps the user should be
15756 (setq reads (cons num1 reads))
15761 (narrow-to-region (match-beginning 0)
15766 ;; It was just a simple number, so we add it to the
15768 (setq reads (cons num1 reads)))
15769 ;; If the next char in ?\n, then we have reached the end
15770 ;; of the line and return nil.
15771 (/= (following-char) ?\n))
15772 ((= (following-char) ?\n)
15773 ;; End of line, so we end.
15776 ;; Not numbers and not eol, so this might be a buggy
15779 ;; If it was eob instead of ?\n, we allow it.
15781 ;; The line was buggy.
15783 (gnus-message 3 "Mangled line: %s"
15784 (buffer-substring (gnus-point-at-bol)
15785 (gnus-point-at-eol)))
15789 ;; Skip past ", ". Spaces are illegal in these ranges, but
15790 ;; we allow them, because it's a common mistake to put a
15791 ;; space after the comma.
15792 (skip-chars-forward ", "))
15794 ;; We have already read .newsrc.eld, so we gently update the
15795 ;; data in the hash table with the information we have just
15798 (let ((info (gnus-get-info group))
15801 ;; There is an entry for this file in the alist.
15803 (gnus-info-set-read info (nreverse reads))
15804 ;; We update the level very gently. In fact, we
15805 ;; only change it if there's been a status change
15806 ;; from subscribed to unsubscribed, or vice versa.
15807 (setq level (gnus-info-level info))
15808 (cond ((and (<= level gnus-level-subscribed)
15810 (setq level (if reads
15811 gnus-level-default-unsubscribed
15812 (1+ gnus-level-default-unsubscribed))))
15813 ((and (> level gnus-level-subscribed) subscribed)
15814 (setq level gnus-level-default-subscribed)))
15815 (gnus-info-set-level info level))
15816 ;; This is a new group.
15817 (setq info (list group
15819 gnus-level-default-subscribed
15821 (1+ gnus-level-subscribed)
15822 gnus-level-default-unsubscribed))
15823 (nreverse reads))))
15824 (setq newsrc (cons info newsrc))))))
15827 (setq newsrc (nreverse newsrc))
15829 (if (not already-read)
15831 ;; We now have two newsrc lists - `newsrc', which is what we
15832 ;; have read from .newsrc, and `gnus-newsrc-alist', which is
15833 ;; what we've read from .newsrc.eld. We have to merge these
15834 ;; lists. We do this by "attaching" any (foreign) groups in the
15835 ;; gnus-newsrc-alist to the (native) group that precedes them.
15836 (let ((rc (cdr gnus-newsrc-alist))
15837 (prev gnus-newsrc-alist)
15840 (or (null (nth 4 (car rc))) ; It's a native group.
15841 (assoc (car (car rc)) newsrc) ; It's already in the alist.
15842 (if (setq entry (assoc (car (car prev)) newsrc))
15843 (setcdr (setq mentry (memq entry newsrc))
15844 (cons (car rc) (cdr mentry)))
15845 (setq newsrc (cons (car rc) newsrc))))
15849 (setq gnus-newsrc-alist newsrc)
15850 ;; We make the newsrc hashtb.
15851 (gnus-make-hashtable-from-newsrc-alist)
15853 ;; Finally, if we read some options lines, we parse them.
15854 (or (string= gnus-newsrc-options "")
15855 (gnus-newsrc-parse-options gnus-newsrc-options))))
15857 ;; Parse options lines to find "options -n !all rec.all" and stuff.
15858 ;; The return value will be a list on the form
15859 ;; ((regexp1 . ignore)
15860 ;; (regexp2 . subscribe)...)
15861 ;; When handling new newsgroups, groups that match a `ignore' regexp
15862 ;; will be ignored, and groups that match a `subscribe' regexp will be
15863 ;; subscribed. A line like
15864 ;; options -n !all rec.all
15865 ;; will lead to a list that looks like
15866 ;; (("^rec\\..+" . subscribe)
15867 ;; ("^.+" . ignore))
15868 ;; So all "rec.*" groups will be subscribed, while all the other
15869 ;; groups will be ignored. Note that "options -n !all rec.all" is very
15870 ;; different from "options -n rec.all !all".
15871 (defun gnus-newsrc-parse-options (options)
15874 (gnus-set-work-buffer)
15875 (insert (regexp-quote options))
15876 ;; First we treat all continuation lines.
15877 (goto-char (point-min))
15878 (while (re-search-forward "\n[ \t]+" nil t)
15879 (replace-match " " t t))
15880 ;; Then we transform all "all"s into ".+"s.
15881 (goto-char (point-min))
15882 (while (re-search-forward "\\ball\\b" nil t)
15883 (replace-match ".+" t t))
15884 (goto-char (point-min))
15885 ;; We remove all other options than the "-n" ones.
15886 (while (re-search-forward "[ \t]-[^n][^-]*" nil t)
15887 (replace-match " ")
15889 (goto-char (point-min))
15891 ;; We are only interested in "options -n" lines - we
15892 ;; ignore the other option lines.
15893 (while (re-search-forward "[ \t]-n" nil t)
15895 (or (save-excursion
15896 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t)
15898 (gnus-point-at-eol)))
15899 ;; Search for all "words"...
15900 (while (re-search-forward "[^ \t,\n]+" eol t)
15901 (if (= (char-after (match-beginning 0)) ?!)
15902 ;; If the word begins with a bang (!), this is a "not"
15903 ;; spec. We put this spec (minus the bang) and the
15904 ;; symbol `ignore' into the list.
15905 (setq out (cons (cons (concat
15906 "^" (buffer-substring
15907 (1+ (match-beginning 0))
15910 ;; There was no bang, so this is a "yes" spec.
15911 (setq out (cons (cons (concat "^" (match-string 0))
15912 'subscribe) out)))))
15914 (setq gnus-newsrc-options-n out))))
15916 (defun gnus-save-newsrc-file (&optional force)
15917 "Save .newsrc file."
15918 ;; Note: We cannot save .newsrc file if all newsgroups are removed
15919 ;; from the variable gnus-newsrc-alist.
15920 (when (and (or gnus-newsrc-alist gnus-killed-list)
15921 gnus-current-startup-file)
15923 (if (and (or gnus-use-dribble-file gnus-slave)
15925 (or (not gnus-dribble-buffer)
15926 (not (buffer-name gnus-dribble-buffer))
15927 (zerop (save-excursion
15928 (set-buffer gnus-dribble-buffer)
15930 (gnus-message 4 "(No changes need to be saved)")
15931 (run-hooks 'gnus-save-newsrc-hook)
15933 (gnus-slave-save-newsrc)
15935 (when gnus-save-newsrc-file
15936 (gnus-message 5 "Saving %s..." gnus-current-startup-file)
15937 (gnus-gnus-to-newsrc-format)
15938 (gnus-message 5 "Saving %s...done" gnus-current-startup-file))
15939 ;; Save .newsrc.eld.
15940 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
15941 (make-local-variable 'version-control)
15942 (setq version-control 'never)
15943 (setq buffer-file-name
15944 (concat gnus-current-startup-file ".eld"))
15945 (gnus-add-current-to-buffer-list)
15946 (buffer-disable-undo (current-buffer))
15948 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file)
15949 (gnus-gnus-to-quick-newsrc-format)
15950 (run-hooks 'gnus-save-quick-newsrc-hook)
15952 (kill-buffer (current-buffer))
15954 5 "Saving %s.eld...done" gnus-current-startup-file))
15955 (gnus-dribble-delete-file)))))
15957 (defun gnus-gnus-to-quick-newsrc-format ()
15958 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
15959 (insert ";; Gnus startup file.\n")
15960 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
15961 (insert ";; to read .newsrc.\n")
15962 (insert "(setq gnus-newsrc-file-version "
15963 (prin1-to-string gnus-version) ")\n")
15965 (if gnus-save-killed-list gnus-variable-list
15966 ;; Remove the `gnus-killed-list' from the list of variables
15967 ;; to be saved, if required.
15968 (delq 'gnus-killed-list (copy-sequence gnus-variable-list))))
15969 ;; Peel off the "dummy" group.
15970 (gnus-newsrc-alist (cdr gnus-newsrc-alist))
15972 ;; Insert the variables into the file.
15974 (when (and (boundp (setq variable (pop variables)))
15975 (symbol-value variable))
15976 (insert "(setq " (symbol-name variable) " '"
15977 (prin1-to-string (symbol-value variable)) ")\n")))))
15979 (defun gnus-gnus-to-newsrc-format ()
15980 ;; Generate and save the .newsrc file.
15981 (let ((newsrc (cdr gnus-newsrc-alist))
15984 (set-buffer (create-file-buffer gnus-current-startup-file))
15985 (setq buffer-file-name gnus-current-startup-file)
15986 (buffer-disable-undo (current-buffer))
15989 (if gnus-newsrc-options (insert gnus-newsrc-options))
15990 ;; Write subscribed and unsubscribed.
15992 (setq info (car newsrc))
15993 (if (not (gnus-info-method info))
15994 ;; Don't write foreign groups to .newsrc.
15996 (insert (gnus-info-group info)
15997 (if (> (gnus-info-level info) gnus-level-subscribed)
15999 (if (setq ranges (gnus-info-read info))
16002 (if (not (listp (cdr ranges)))
16003 (if (= (car ranges) (cdr ranges))
16004 (insert (int-to-string (car ranges)))
16005 (insert (int-to-string (car ranges)) "-"
16006 (int-to-string (cdr ranges))))
16008 (setq range (car ranges)
16009 ranges (cdr ranges))
16010 (if (or (atom range) (= (car range) (cdr range)))
16011 (insert (int-to-string
16012 (or (and (atom range) range)
16014 (insert (int-to-string (car range)) "-"
16015 (int-to-string (cdr range))))
16016 (if ranges (insert ","))))))
16018 (setq newsrc (cdr newsrc)))
16019 (make-local-variable 'version-control)
16020 (setq version-control 'never)
16021 ;; It has been reported that sometime the modtime on the .newsrc
16022 ;; file seems to be off. We really do want to overwrite it, so
16023 ;; we clear the modtime here before saving. It's a bit odd,
16025 ;; sometimes the modtime clear isn't sufficient. most brute force:
16026 ;; delete the silly thing entirely first. but this fails to provide
16027 ;; such niceties as .newsrc~ creation.
16028 (if gnus-modtime-botch
16029 (delete-file gnus-startup-file)
16030 (clear-visited-file-modtime))
16031 (run-hooks 'gnus-save-standard-newsrc-hook)
16033 (kill-buffer (current-buffer)))))
16036 ;;; Slave functions.
16038 (defun gnus-slave-save-newsrc ()
16040 (set-buffer gnus-dribble-buffer)
16042 (make-temp-name (concat gnus-current-startup-file "-slave-"))))
16043 (write-region (point-min) (point-max) slave-name nil 'nomesg))))
16045 (defun gnus-master-read-slave-newsrc ()
16048 (file-name-directory gnus-current-startup-file)
16052 (file-name-nondirectory gnus-current-startup-file)
16056 (if (not slave-files)
16057 () ; There are no slave files to read.
16058 (gnus-message 7 "Reading slave newsrcs...")
16060 (set-buffer (get-buffer-create " *gnus slave*"))
16061 (buffer-disable-undo (current-buffer))
16063 (sort (mapcar (lambda (file)
16064 (list (nth 5 (file-attributes file)) file))
16067 (or (< (car (car f1)) (car (car f2)))
16068 (< (nth 1 (car f1)) (nth 1 (car f2)))))))
16071 (setq file (nth 1 (car slave-files)))
16072 (insert-file-contents file)
16073 (if (condition-case ()
16075 (eval-buffer (current-buffer))
16078 (gnus-message 3 "Possible error in %s" file)
16082 (or gnus-slave ; Slaves shouldn't delete these files.
16086 (setq slave-files (cdr slave-files))))
16087 (gnus-message 7 "Reading slave newsrcs...done"))))
16090 ;;; Group description.
16092 (defun gnus-read-all-descriptions-files ()
16093 (let ((methods (cons gnus-select-method
16094 (cons gnus-message-archive-method
16095 gnus-secondary-select-methods))))
16097 (gnus-read-descriptions-file (car methods))
16098 (setq methods (cdr methods)))
16101 (defun gnus-read-descriptions-file (&optional method)
16102 (let ((method (or method gnus-select-method)))
16103 ;; We create the hashtable whether we manage to read the desc file
16104 ;; to avoid trying to re-read after a failed read.
16105 (or gnus-description-hashtb
16106 (setq gnus-description-hashtb
16107 (gnus-make-hashtable (length gnus-active-hashtb))))
16108 ;; Mark this method's desc file as read.
16109 (gnus-sethash (gnus-group-prefixed-name "" method) "Has read"
16110 gnus-description-hashtb)
16112 (gnus-message 5 "Reading descriptions file via %s..." (car method))
16114 ((not (gnus-check-server method))
16115 (gnus-message 1 "Couldn't open server")
16117 ((not (gnus-request-list-newsgroups method))
16118 (gnus-message 1 "Couldn't read newsgroups descriptions")
16124 (set-buffer nntp-server-buffer)
16125 (goto-char (point-min))
16126 (if (or (search-forward "\n.\n" nil t)
16127 (goto-char (point-max)))
16129 (beginning-of-line)
16130 (narrow-to-region (point-min) (point))))
16131 (goto-char (point-min))
16132 (while (not (eobp))
16133 ;; If we get an error, we set group to 0, which is not a
16137 (let ((obarray gnus-description-hashtb))
16138 ;; Group is set to a symbol interned in this
16140 (read nntp-server-buffer))
16142 (skip-chars-forward " \t")
16143 ;; ... which leads to this line being effectively ignored.
16144 (and (symbolp group)
16145 (set group (buffer-substring
16146 (point) (progn (end-of-line) (point)))))
16147 (forward-line 1))))
16148 (gnus-message 5 "Reading descriptions file...done")
16151 (defun gnus-group-get-description (group)
16152 "Get the description of a group by sending XGTITLE to the server."
16153 (when (gnus-request-group-description group)
16155 (set-buffer nntp-server-buffer)
16156 (goto-char (point-min))
16157 (when (looking-at "[^ \t]+[ \t]+\\(.*\\)")
16158 (match-string 1)))))
16161 ;;; Buffering of read articles.
16164 (defvar gnus-backlog-buffer " *Gnus Backlog*")
16165 (defvar gnus-backlog-articles nil)
16166 (defvar gnus-backlog-hashtb nil)
16168 (defun gnus-backlog-buffer ()
16169 "Return the backlog buffer."
16170 (or (get-buffer gnus-backlog-buffer)
16172 (set-buffer (get-buffer-create gnus-backlog-buffer))
16173 (buffer-disable-undo (current-buffer))
16174 (setq buffer-read-only t)
16175 (gnus-add-current-to-buffer-list)
16176 (get-buffer gnus-backlog-buffer))))
16178 (defun gnus-backlog-setup ()
16179 "Initialize backlog variables."
16180 (unless gnus-backlog-hashtb
16181 (setq gnus-backlog-hashtb (make-vector 1023 0))))
16183 (defun gnus-backlog-shutdown ()
16184 "Clear all backlog variables and buffers."
16185 (when (get-buffer gnus-backlog-buffer)
16186 (kill-buffer gnus-backlog-buffer))
16187 (setq gnus-backlog-hashtb nil
16188 gnus-backlog-articles nil))
16190 (defun gnus-backlog-enter-article (group number buffer)
16191 (gnus-backlog-setup)
16192 (let ((ident (intern (concat group ":" (int-to-string number))
16193 gnus-backlog-hashtb))
16195 (if (memq ident gnus-backlog-articles)
16196 () ; It's already kept.
16197 ;; Remove the oldest article, if necessary.
16198 (and (numberp gnus-keep-backlog)
16199 (>= (length gnus-backlog-articles) gnus-keep-backlog)
16200 (gnus-backlog-remove-oldest-article))
16201 (setq gnus-backlog-articles (cons ident gnus-backlog-articles))
16202 ;; Insert the new article.
16204 (set-buffer (gnus-backlog-buffer))
16205 (let (buffer-read-only)
16206 (goto-char (point-max))
16207 (or (bolp) (insert "\n"))
16209 (insert-buffer-substring buffer)
16210 ;; Tag the beginning of the article with the ident.
16211 (put-text-property b (1+ b) 'gnus-backlog ident))))))
16213 (defun gnus-backlog-remove-oldest-article ()
16215 (set-buffer (gnus-backlog-buffer))
16216 (goto-char (point-min))
16217 (if (zerop (buffer-size))
16218 () ; The buffer is empty.
16219 (let ((ident (get-text-property (point) 'gnus-backlog))
16221 ;; Remove the ident from the list of articles.
16223 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
16224 ;; Delete the article itself.
16226 (point) (next-single-property-change
16227 (1+ (point)) 'gnus-backlog nil (point-max)))))))
16229 (defun gnus-backlog-request-article (group number buffer)
16230 (gnus-backlog-setup)
16231 (let ((ident (intern (concat group ":" (int-to-string number))
16232 gnus-backlog-hashtb))
16234 (when (memq ident gnus-backlog-articles)
16235 ;; It was in the backlog.
16237 (set-buffer (gnus-backlog-buffer))
16238 (if (not (setq beg (text-property-any
16239 (point-min) (point-max) 'gnus-backlog
16241 ;; It wasn't in the backlog after all.
16243 (setq gnus-backlog-articles (delq ident gnus-backlog-articles))
16245 ;; Find the end (i. e., the beginning of the next article).
16247 (next-single-property-change
16248 (1+ beg) 'gnus-backlog (current-buffer) (point-max)))))
16249 (let ((buffer-read-only nil))
16251 (insert-buffer-substring gnus-backlog-buffer beg end)
16254 ;; Allow redefinition of Gnus functions.
16256 (gnus-ems-redefine)
16260 ;;; gnus.el ends here