1 ;;; gnus.el --- a newsreader for GNU Emacs
2 ;; Copyright (C) 1987,88,89,90,93,94,95,96 Free Software Foundation, Inc.
4 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
5 ;; Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval '(run-hooks 'gnus-load-hook))
35 (eval-when-compile (require 'cl))
37 ;; Site dependent variables. These variables should be defined in
40 (defvar gnus-default-nntp-server nil
41 "Specify a default NNTP server.
42 This variable should be defined in paths.el, and should never be set
44 If you want to change servers, you should use `gnus-select-method'.
45 See the documentation to that variable.")
47 (defvar gnus-backup-default-subscribed-newsgroups
48 '("news.announce.newusers" "news.groups.questions" "gnu.emacs.gnus")
49 "Default default new newsgroups the first time Gnus is run.
50 Should be set in paths.el, and shouldn't be touched by the user.")
52 (defvar gnus-local-domain nil
53 "Local domain name without a host name.
54 The DOMAINNAME environment variable is used instead if it is defined.
55 If the `system-name' function returns the full Internet name, there is
56 no need to set this variable.")
58 (defvar gnus-local-organization nil
59 "String with a description of what organization (if any) the user belongs to.
60 The ORGANIZATION environment variable is used instead if it is defined.
61 If this variable contains a function, this function will be called
62 with the current newsgroup name as the argument. The function should
65 In any case, if the string (either in the variable, in the environment
66 variable, or returned by the function) is a file name, the contents of
67 this file will be used as the organization.")
69 (defvar gnus-use-generic-from nil
70 "If nil, the full host name will be the system name prepended to the domain name.
71 If this is a string, the full host name will be this string.
72 If this is non-nil, non-string, the domain name will be used as the
75 (defvar gnus-use-generic-path nil
76 "If nil, use the NNTP server name in the Path header.
77 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@src.doc.ic.ac.uk:/usenet/news-FAQS/"
190 "/ftp@ftp.seas.gwu.edu:/pub/rtfm/"
191 "/ftp@rtfm.mit.edu:/pub/usenet/news.answers/"
192 "/ftp@ftp.uni-paderborn.de:/pub/FAQ/"
193 "/ftp@ftp.sunet.se:/pub/usenet/"
194 "/ftp@nctuccca.edu.tw:/USENET/FAQ/"
195 "/ftp@hwarang.postech.ac.kr:/pub/usenet/news.answers/"
196 "/ftp@ftp.hk.super.net:/mirror/faqs/")
197 "*Directory where the group FAQs are stored.
198 This will most commonly be on a remote machine, and the file will be
201 This variable can also be a list of directories. In that case, the
202 first element in the list will be used by default, and the others will
203 be used as backup sites.
205 Note that Gnus uses an aol machine as the default directory. If this
206 feels fundamentally unclean, just think of it as a way to finally get
207 something of value back from them.
209 If the default site is too slow, try one of these:
211 North America: mirrors.aol.com /pub/rtfm/usenet
212 ftp.seas.gwu.edu /pub/rtfm
213 rtfm.mit.edu /pub/usenet/news.answers
214 Europe: ftp.uni-paderborn.de /pub/FAQ
215 src.doc.ic.ac.uk /usenet/news-FAQS
216 ftp.sunet.se /pub/usenet
217 Asia: nctuccca.edu.tw /USENET/FAQ
218 hwarang.postech.ac.kr /pub/usenet/news.answers
219 ftp.hk.super.net /mirror/faqs")
221 (defvar gnus-group-archive-directory
222 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
223 "*The address of the (ding) archives.")
225 (defvar gnus-group-recent-archive-directory
226 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
227 "*The address of the most recent (ding) articles.")
229 (defvar gnus-default-subscribed-newsgroups nil
230 "*This variable lists what newsgroups should be subscribed the first time Gnus is used.
231 It should be a list of strings.
232 If it is `t', Gnus will not do anything special the first time it is
233 started; it'll just use the normal newsgroups subscription methods.")
235 (defvar gnus-use-cross-reference t
236 "*Non-nil means that cross referenced articles will be marked as read.
237 If nil, ignore cross references. If t, mark articles as read in
238 subscribed newsgroups. If neither t nor nil, mark as read in all
241 (defvar gnus-single-article-buffer t
242 "*If non-nil, display all articles in the same buffer.
243 If nil, each group will get its own article buffer.")
245 (defvar gnus-use-dribble-file t
246 "*Non-nil means that Gnus will use a dribble file to store user updates.
247 If Emacs should crash without saving the .newsrc files, complete
248 information can be restored from the dribble file.")
250 (defvar gnus-dribble-directory nil
251 "*The directory where dribble files will be saved.
252 If this variable is nil, the directory where the .newsrc files are
253 saved will be used.")
255 (defvar gnus-asynchronous nil
256 "*If non-nil, Gnus will supply backends with data needed for async article fetching.")
258 (defvar gnus-kill-summary-on-exit t
259 "*If non-nil, kill the summary buffer when you exit from it.
260 If nil, the summary will become a \"*Dead Summary*\" buffer, and
261 it will be killed sometime later.")
263 (defvar gnus-large-newsgroup 200
264 "*The number of articles which indicates a large newsgroup.
265 If the number of articles in a newsgroup is greater than this value,
266 confirmation is required for selecting the newsgroup.")
268 ;; Suggested by Andrew Eskilsson <pi92ae@lelle.pt.hk-r.se>.
269 (defvar gnus-no-groups-message "No news is horrible news"
270 "*Message displayed by Gnus when no groups are available.")
272 (defvar gnus-use-long-file-name (not (memq system-type '(usg-unix-v xenix)))
273 "*Non-nil means that the default name of a file to save articles in is the group name.
274 If it's nil, the directory form of the group name is used instead.
276 If this variable is a list, and the list contains the element
277 `not-score', long file names will not be used for score files; if it
278 contains the element `not-save', long file names will not be used for
279 saving; and if it contains the element `not-kill', long file names
280 will not be used for kill files.")
282 (defvar gnus-article-save-directory (or (getenv "SAVEDIR") "~/News/")
283 "*Name of the directory articles will be saved in (default \"~/News\").
284 Initialized from the SAVEDIR environment variable.")
286 (defvar gnus-kill-files-directory (or (getenv "SAVEDIR") "~/News/")
287 "*Name of the directory where kill files will be stored (default \"~/News\").
288 Initialized from the SAVEDIR environment variable.")
290 (defvar gnus-default-article-saver 'gnus-summary-save-in-rmail
291 "*A function to save articles in your favorite format.
292 The function must be interactively callable (in other words, it must
293 be an Emacs command).
295 Gnus provides the following functions:
297 * gnus-summary-save-in-rmail (Rmail format)
298 * gnus-summary-save-in-mail (Unix mail format)
299 * gnus-summary-save-in-folder (MH folder)
300 * gnus-summary-save-in-file (article format).
301 * gnus-summary-save-in-vm (use VM's folder format).")
303 (defvar gnus-prompt-before-saving 'always
304 "*This variable says how much prompting is to be done when saving articles.
305 If it is nil, no prompting will be done, and the articles will be
306 saved to the default files. If this variable is `always', each and
307 every article that is saved will be preceded by a prompt, even when
308 saving large batches of articles. If this variable is neither nil not
309 `always', there the user will be prompted once for a file name for
310 each invocation of the saving commands.")
312 (defvar gnus-rmail-save-name (function gnus-plain-save-name)
313 "*A function generating a file name to save articles in Rmail format.
314 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
316 (defvar gnus-mail-save-name (function gnus-plain-save-name)
317 "*A function generating a file name to save articles in Unix mail format.
318 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
320 (defvar gnus-folder-save-name (function gnus-folder-save-name)
321 "*A function generating a file name to save articles in MH folder.
322 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER.")
324 (defvar gnus-file-save-name (function gnus-numeric-save-name)
325 "*A function generating a file name to save articles in article format.
326 The function is called with NEWSGROUP, HEADERS, and optional
329 (defvar gnus-split-methods
330 '((gnus-article-archive-name))
331 "*Variable used to suggest where articles are to be saved.
332 For instance, if you would like to save articles related to Gnus in
333 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
334 you could set this variable to something like:
336 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
337 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
339 This variable is an alist where the where the key is the match and the
340 value is a list of possible files to save in if the match is non-nil.
342 If the match is a string, it is used as a regexp match on the
343 article. If the match is a symbol, that symbol will be funcalled
344 from the buffer of the article to be saved with the newsgroup as the
345 parameter. If it is a list, it will be evaled in the same buffer.
347 If this form or function returns a string, this string will be used as
348 a possible file name; and if it returns a non-nil list, that list will
349 be used as possible file names.")
351 (defvar gnus-move-split-methods nil
352 "*Variable used to suggest where articles are to be moved to.
353 It uses the same syntax as the `gnus-split-methods' variable.")
355 (defvar gnus-save-score nil
356 "*If non-nil, save group scoring info.")
358 (defvar gnus-use-adaptive-scoring nil
359 "*If non-nil, use some adaptive scoring scheme.")
361 (defvar gnus-use-cache nil
362 "*If nil, Gnus will ignore the article cache.
363 If `passive', it will allow entering (and reading) articles
364 explicitly entered into the cache. If anything else, use the
365 cache to the full extent of the law.")
367 (defvar gnus-use-trees nil
368 "*If non-nil, display a thread tree buffer.")
370 (defvar gnus-use-grouplens nil
371 "*If non-nil, use GroupLens ratings.")
373 (defvar gnus-keep-backlog nil
374 "*If non-nil, Gnus will keep read articles for later re-retrieval.
375 If it is a number N, then Gnus will only keep the last N articles
376 read. If it is neither nil nor a number, Gnus will keep all read
377 articles. This is not a good idea.")
379 (defvar gnus-use-nocem nil
380 "*If non-nil, Gnus will read NoCeM cancel messages.")
382 (defvar gnus-use-demon nil
383 "If non-nil, Gnus might use some demons.")
385 (defvar gnus-use-scoring t
386 "*If non-nil, enable scoring.")
388 (defvar gnus-use-picons nil
389 "*If non-nil, display picons.")
391 (defvar gnus-fetch-old-headers nil
392 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
393 If an unread article in the group refers to an older, already read (or
394 just marked as read) article, the old article will not normally be
395 displayed in the Summary buffer. If this variable is non-nil, Gnus
396 will attempt to grab the headers to the old articles, and thereby
397 build complete threads. If it has the value `some', only enough
398 headers to connect otherwise loose threads will be displayed.
399 This variable can also be a number. In that case, no more than that
400 number of old headers will be fetched.
402 The server has to support NOV for any of this to work.")
405 ;(defvar gnus-visual t
406 ; "*If non-nil, will do various highlighting.
407 ;If nil, no mouse highlights (or any other highlights) will be
408 ;performed. This might speed up Gnus some when generating large group
409 ;and summary buffers.")
411 (defvar gnus-novice-user t
412 "*Non-nil means that you are a usenet novice.
413 If non-nil, verbose messages may be displayed and confirmations may be
416 (defvar gnus-expert-user nil
417 "*Non-nil means that you will never be asked for confirmation about anything.
418 And that means *anything*.")
420 (defvar gnus-verbose 7
421 "*Integer that says how verbose Gnus should be.
422 The higher the number, the more messages Gnus will flash to say what
423 it's doing. At zero, Gnus will be totally mute; at five, Gnus will
424 display most important messages; and at ten, Gnus will keep on
425 jabbering all the time.")
427 (defvar gnus-keep-same-level nil
428 "*Non-nil means that the next newsgroup after the current will be on the same level.
429 When you type, for instance, `n' after reading the last article in the
430 current newsgroup, you will go to the next newsgroup. If this variable
431 is nil, the next newsgroup will be the next from the group
433 If this variable is non-nil, Gnus will either put you in the
434 next newsgroup with the same level, or, if no such newsgroup is
435 available, the next newsgroup with the lowest possible level higher
436 than the current level.
437 If this variable is `best', Gnus will make the next newsgroup the one
438 with the best level.")
440 (defvar gnus-summary-make-false-root 'adopt
441 "*nil means that Gnus won't gather loose threads.
442 If the root of a thread has expired or been read in a previous
443 session, the information necessary to build a complete thread has been
444 lost. Instead of having many small sub-threads from this original thread
445 scattered all over the summary buffer, Gnus can gather them.
447 If non-nil, Gnus will try to gather all loose sub-threads from an
448 original thread into one large thread.
450 If this variable is non-nil, it should be one of `none', `adopt',
453 If this variable is `none', Gnus will not make a false root, but just
454 present the sub-threads after another.
455 If this variable is `dummy', Gnus will create a dummy root that will
456 have all the sub-threads as children.
457 If this variable is `adopt', Gnus will make one of the \"children\"
458 the parent and mark all the step-children as such.
459 If this variable is `empty', the \"children\" are printed with empty
460 subject fields. (Or rather, they will be printed with a string
461 given by the `gnus-summary-same-subject' variable.)")
463 (defvar gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
464 "*A regexp to match subjects to be excluded from loose thread gathering.
465 As loose thread gathering is done on subjects only, that means that
466 there can be many false gatherings performed. By rooting out certain
467 common subjects, gathering might become saner.")
469 (defvar gnus-summary-gather-subject-limit nil
470 "*Maximum length of subject comparisons when gathering loose threads.
471 Use nil to compare full subjects. Setting this variable to a low
472 number will help gather threads that have been corrupted by
473 newsreaders chopping off subject lines, but it might also mean that
474 unrelated articles that have subject that happen to begin with the
475 same few characters will be incorrectly gathered.
477 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
478 comparing subjects.")
480 (defvar gnus-simplify-ignored-prefixes nil
481 "*Regexp, matches for which are removed from subject lines when simplifying.")
483 (defvar gnus-build-sparse-threads nil
484 "*If non-nil, fill in the gaps in threads.
485 If `some', only fill in the gaps that are needed to tie loose threads
486 together. If `more', fill in all leaf nodes that Gnus can find. If
487 non-nil and non-`some', fill in all gaps that Gnus manages to guess.")
489 (defvar gnus-summary-thread-gathering-function 'gnus-gather-threads-by-subject
490 "Function used for gathering loose threads.
491 There are two pre-defined functions: `gnus-gather-threads-by-subject',
492 which only takes Subjects into consideration; and
493 `gnus-gather-threads-by-references', which compared the References
494 headers of the articles to find matches.")
496 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
497 (defvar gnus-summary-same-subject ""
498 "*String indicating that the current article has the same subject as the previous.
499 This variable will only be used if the value of
500 `gnus-summary-make-false-root' is `empty'.")
502 (defvar gnus-summary-goto-unread t
503 "*If non-nil, marking commands will go to the next unread article.
504 If `never', \\<gnus-summary-mode-map>\\[gnus-summary-next-page] will go to the next article,
505 whether it is read or not.")
507 (defvar gnus-group-goto-unread t
508 "*If non-nil, movement commands will go to the next unread and subscribed group.")
510 (defvar gnus-goto-next-group-when-activating t
511 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group.")
513 (defvar gnus-check-new-newsgroups t
514 "*Non-nil means that Gnus will add new newsgroups at startup.
515 If this variable is `ask-server', Gnus will ask the server for new
516 groups since the last time it checked. This means that the killed list
517 is no longer necessary, so you could set `gnus-save-killed-list' to
520 A variant is to have this variable be a list of select methods. Gnus
521 will then use the `ask-server' method on all these select methods to
522 query for new groups from all those servers.
525 (setq gnus-check-new-newsgroups
526 '((nntp \"some.server\") (nntp \"other.server\")))
528 If this variable is nil, then you have to tell Gnus explicitly to
529 check for new newsgroups with \\<gnus-group-mode-map>\\[gnus-find-new-newsgroups].")
531 (defvar gnus-check-bogus-newsgroups nil
532 "*Non-nil means that Gnus will check and remove bogus newsgroup at startup.
533 If this variable is nil, then you have to tell Gnus explicitly to
534 check for bogus newsgroups with \\<gnus-group-mode-map>\\[gnus-group-check-bogus-groups].")
536 (defvar gnus-read-active-file t
537 "*Non-nil means that Gnus will read the entire active file at startup.
538 If this variable is nil, Gnus will only know about the groups in your
541 If this variable is `some', Gnus will try to only read the relevant
542 parts of the active file from the server. Not all servers support
543 this, and it might be quite slow with other servers, but this should
544 generally be faster than both the t and nil value.
546 If you set this variable to nil or `some', you probably still want to
547 be told about new newsgroups that arrive. To do that, set
548 `gnus-check-new-newsgroups' to `ask-server'. This may not work
549 properly with all servers.")
551 (defvar gnus-level-subscribed 5
552 "*Groups with levels less than or equal to this variable are subscribed.")
554 (defvar gnus-level-unsubscribed 7
555 "*Groups with levels less than or equal to this variable are unsubscribed.
556 Groups with levels less than `gnus-level-subscribed', which should be
557 less than this variable, are subscribed.")
559 (defvar gnus-level-zombie 8
560 "*Groups with this level are zombie groups.")
562 (defvar gnus-level-killed 9
563 "*Groups with this level are killed.")
565 (defvar gnus-level-default-subscribed 3
566 "*New subscribed groups will be subscribed at this level.")
568 (defvar gnus-level-default-unsubscribed 6
569 "*New unsubscribed groups will be unsubscribed at this level.")
571 (defvar gnus-activate-level (1+ gnus-level-subscribed)
572 "*Groups higher than this level won't be activated on startup.
573 Setting this variable to something log might save lots of time when
574 you have many groups that you aren't interested in.")
576 (defvar gnus-activate-foreign-newsgroups 4
577 "*If nil, Gnus will not check foreign newsgroups at startup.
578 If it is non-nil, it should be a number between one and nine. Foreign
579 newsgroups that have a level lower or equal to this number will be
580 activated on startup. For instance, if you want to active all
581 subscribed newsgroups, but not the rest, you'd set this variable to
582 `gnus-level-subscribed'.
584 If you subscribe to lots of newsgroups from different servers, startup
585 might take a while. By setting this variable to nil, you'll save time,
586 but you won't be told how many unread articles there are in the
589 (defvar gnus-save-newsrc-file t
590 "*Non-nil means that Gnus will save the `.newsrc' file.
591 Gnus always saves its own startup file, which is called
592 \".newsrc.eld\". The file called \".newsrc\" is in a format that can
593 be readily understood by other newsreaders. If you don't plan on
594 using other newsreaders, set this variable to nil to save some time on
597 (defvar gnus-save-killed-list t
598 "*If non-nil, save the list of killed groups to the startup file.
599 If you set this variable to nil, you'll save both time (when starting
600 and quitting) and space (both memory and disk), but it will also mean
601 that Gnus has no record of which groups are new and which are old, so
602 the automatic new newsgroups subscription methods become meaningless.
604 You should always set `gnus-check-new-newsgroups' to `ask-server' or
605 nil if you set this variable to nil.")
607 (defvar gnus-interactive-catchup t
608 "*If non-nil, require your confirmation when catching up a group.")
610 (defvar gnus-interactive-post t
611 "*If non-nil, group name will be asked for when posting.")
613 (defvar gnus-interactive-exit t
614 "*If non-nil, require your confirmation when exiting Gnus.")
616 (defvar gnus-kill-killed t
617 "*If non-nil, Gnus will apply kill files to already killed articles.
618 If it is nil, Gnus will never apply kill files to articles that have
619 already been through the scoring process, which might very well save lots
622 (defvar gnus-extract-address-components 'gnus-extract-address-components
623 "*Function for extracting address components from a From header.
624 Two pre-defined function exist: `gnus-extract-address-components',
625 which is the default, quite fast, and too simplistic solution, and
626 `mail-extract-address-components', which works much better, but is
629 (defvar gnus-summary-default-score 0
630 "*Default article score level.
631 If this variable is nil, scoring will be disabled.")
633 (defvar gnus-summary-zcore-fuzz 0
634 "*Fuzziness factor for the zcore in the summary buffer.
635 Articles with scores closer than this to `gnus-summary-default-score'
636 will not be marked.")
638 (defvar gnus-simplify-subject-fuzzy-regexp nil
639 "*Strings to be removed when doing fuzzy matches.
640 This can either be a regular expression or list of regular expressions
641 that will be removed from subject strings if fuzzy subject
642 simplification is selected.")
644 (defvar gnus-permanently-visible-groups nil
645 "*Regexp to match groups that should always be listed in the group buffer.
646 This means that they will still be listed when there are no unread
647 articles in the groups.")
649 (defvar gnus-list-groups-with-ticked-articles t
650 "*If non-nil, list groups that have only ticked articles.
651 If nil, only list groups that have unread articles.")
653 (defvar gnus-group-default-list-level gnus-level-subscribed
654 "*Default listing level.
655 Ignored if `gnus-group-use-permanent-levels' is non-nil.")
657 (defvar gnus-group-use-permanent-levels nil
658 "*If non-nil, once you set a level, Gnus will use this level.")
660 (defvar gnus-group-list-inactive-groups t
661 "*If non-nil, inactive groups will be listed.")
663 (defvar gnus-show-mime nil
664 "*If non-nil, do mime processing of articles.
665 The articles will simply be fed to the function given by
666 `gnus-show-mime-method'.")
668 (defvar gnus-strict-mime t
669 "*If nil, MIME-decode even if there is no Mime-Version header in the article.")
671 (defvar gnus-show-mime-method 'metamail-buffer
672 "*Function to process a MIME message.
673 The function is called from the article buffer.")
675 (defvar gnus-decode-encoded-word-method (lambda ())
676 "*Function to decode a MIME encoded-words.
677 The function is called from the article buffer.")
679 (defvar gnus-show-threads t
680 "*If non-nil, display threads in summary mode.")
682 (defvar gnus-thread-hide-subtree nil
683 "*If non-nil, hide all threads initially.
684 If threads are hidden, you have to run the command
685 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
686 to expose hidden threads.")
688 (defvar gnus-thread-hide-killed t
689 "*If non-nil, hide killed threads automatically.")
691 (defvar gnus-thread-ignore-subject nil
692 "*If non-nil, ignore subjects and do all threading based on the Reference header.
693 If nil, which is the default, articles that have different subjects
694 from their parents will start separate threads.")
696 (defvar gnus-thread-operation-ignore-subject t
697 "*If non-nil, subjects will be ignored when doing thread commands.
698 This affects commands like `gnus-summary-kill-thread' and
699 `gnus-summary-lower-thread'.
701 If this variable is nil, articles in the same thread with different
702 subjects will not be included in the operation in question. If this
703 variable is `fuzzy', only articles that have subjects that are fuzzily
704 equal will be included.")
706 (defvar gnus-thread-indent-level 4
707 "*Number that says how much each sub-thread should be indented.")
709 (defvar gnus-ignored-newsgroups
710 (purecopy (mapconcat 'identity
711 '("^to\\." ; not "real" groups
712 "^[0-9. \t]+ " ; all digits in name
713 "[][\"#'()]" ; bogus characters
716 "*A regexp to match uninteresting newsgroups in the active file.
717 Any lines in the active file matching this regular expression are
718 removed from the newsgroup list before anything else is done to it,
719 thus making them effectively non-existent.")
721 (defvar gnus-ignored-headers
722 "^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:"
723 "*All headers that match this regexp will be hidden.
724 This variable can also be a list of regexps of headers to be ignored.
725 If `gnus-visible-headers' is non-nil, this variable will be ignored.")
727 (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-"
728 "*All headers that do not match this regexp will be hidden.
729 This variable can also be a list of regexp of headers to remain visible.
730 If this variable is non-nil, `gnus-ignored-headers' will be ignored.")
732 (defvar gnus-sorted-header-list
733 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^To:"
734 "^Cc:" "^Date:" "^Organization:")
735 "*This variable is a list of regular expressions.
736 If it is non-nil, headers that match the regular expressions will
737 be placed first in the article buffer in the sequence specified by
740 (defvar gnus-boring-article-headers
741 '(empty followup-to reply-to)
742 "*Headers that are only to be displayed if they have interesting data.
743 Possible values in this list are `empty', `newsgroups', `followup-to',
744 `reply-to', and `date'.")
746 (defvar gnus-show-all-headers nil
747 "*If non-nil, don't hide any headers.")
749 (defvar gnus-save-all-headers t
750 "*If non-nil, don't remove any headers before saving.")
752 (defvar gnus-saved-headers gnus-visible-headers
753 "*Headers to keep if `gnus-save-all-headers' is nil.
754 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
755 If that variable is nil, however, all headers that match this regexp
756 will be kept while the rest will be deleted before saving.")
758 (defvar gnus-inhibit-startup-message nil
759 "*If non-nil, the startup message will not be displayed.")
761 (defvar gnus-signature-separator "^-- *$"
762 "Regexp matching signature separator.")
764 (defvar gnus-signature-limit nil
765 "Provide a limit to what is considered a signature.
766 If it is a number, no signature may not be longer (in characters) than
767 that number. If it is a function, the function will be called without
768 any parameters, and if it returns nil, there is no signature in the
769 buffer. If it is a string, it will be used as a regexp. If it
770 matches, the text in question is not a signature.")
772 (defvar gnus-auto-extend-newsgroup t
773 "*If non-nil, extend newsgroup forward and backward when requested.")
775 (defvar gnus-auto-select-first t
776 "*If nil, don't select the first unread article when entering a group.
777 If this variable is `best', select the highest-scored unread article
778 in the group. If neither nil nor `best', select the first unread
781 If you want to prevent automatic selection of the first unread article
782 in some newsgroups, set the variable to nil in
783 `gnus-select-group-hook'.")
785 (defvar gnus-auto-select-next t
786 "*If non-nil, offer to go to the next group from the end of the previous.
787 If the value is t and the next newsgroup is empty, Gnus will exit
788 summary mode and go back to group mode. If the value is neither nil
789 nor t, Gnus will select the following unread newsgroup. In
790 particular, if the value is the symbol `quietly', the next unread
791 newsgroup will be selected without any confirmation, and if it is
792 `almost-quietly', the next group will be selected without any
793 confirmation if you are located on the last article in the group.
794 Finally, if this variable is `slightly-quietly', the `Z n' command
795 will go to the next group without confirmation.")
797 (defvar gnus-auto-select-same nil
798 "*If non-nil, select the next article with the same subject.")
800 (defvar gnus-summary-check-current nil
801 "*If non-nil, consider the current article when moving.
802 The \"unread\" movement commands will stay on the same line if the
803 current article is unread.")
805 (defvar gnus-auto-center-summary t
806 "*If non-nil, always center the current summary buffer.
807 In particular, if `vertical' do only vertical recentering. If non-nil
808 and non-`vertical', do both horizontal and vertical recentering.")
810 (defvar gnus-break-pages t
811 "*If non-nil, do page breaking on articles.
812 The page delimiter is specified by the `gnus-page-delimiter'
815 (defvar gnus-page-delimiter "^\^L"
816 "*Regexp describing what to use as article page delimiters.
817 The default value is \"^\^L\", which is a form linefeed at the
818 beginning of a line.")
820 (defvar gnus-use-full-window t
821 "*If non-nil, use the entire Emacs screen.")
823 (defvar gnus-window-configuration nil
824 "Obsolete variable. See `gnus-buffer-configuration'.")
826 (defvar gnus-window-min-width 2
827 "*Minimum width of Gnus buffers.")
829 (defvar gnus-window-min-height 1
830 "*Minimum height of Gnus buffers.")
832 (defvar gnus-buffer-configuration
836 (if gnus-carpal '(group-carpal 4))))
840 (if gnus-carpal '(summary-carpal 4))))
847 (if gnus-carpal '(summary-carpal 4))
849 (vertical ((height . 5) (width . 15)
851 (left . -1) (top . 1))
861 (if gnus-carpal '(summary-carpal 4))
862 (if gnus-use-trees '(tree 0.25))
867 (if gnus-carpal '(server-carpal 2))))
871 (if gnus-carpal '(browse-carpal 2))))
887 (article 1.0 point)))
898 (edit-group 1.0 point)))
902 (edit-server 1.0 point)))
906 (edit-score 1.0 point)))
933 (if gnus-carpal '(summary-carpal 4))
934 ("*Shell Command Output*" 1.0)))
946 "Window configuration for all possible Gnus buffers.
947 This variable is a list of lists. Each of these lists has a NAME and
948 a RULE. The NAMEs are commonsense names like `group', which names a
949 rule used when displaying the group buffer; `summary', which names a
950 rule for what happens when you enter a group and do not display an
951 article buffer; and so on. See the value of this variable for a
952 complete list of NAMEs.
954 Each RULE is a list of vectors. The first element in this vector is
955 the name of the buffer to be displayed; the second element is the
956 percentage of the screen this buffer is to occupy (a number in the
957 0.0-0.99 range); the optional third element is `point', which should
958 be present to denote which buffer point is to go to after making this
959 buffer configuration.")
961 (defvar gnus-window-to-buffer
962 '((group . gnus-group-buffer)
963 (summary . gnus-summary-buffer)
964 (article . gnus-article-buffer)
965 (server . gnus-server-buffer)
966 (browse . "*Gnus Browse Server*")
967 (edit-group . gnus-group-edit-buffer)
968 (edit-server . gnus-server-edit-buffer)
969 (group-carpal . gnus-carpal-group-buffer)
970 (summary-carpal . gnus-carpal-summary-buffer)
971 (server-carpal . gnus-carpal-server-buffer)
972 (browse-carpal . gnus-carpal-browse-buffer)
973 (edit-score . gnus-score-edit-buffer)
974 (mail . gnus-mail-buffer)
975 (post . gnus-post-news-buffer)
976 (faq . gnus-faq-buffer)
977 (picons . "*Picons*")
978 (tree . gnus-tree-buffer)
979 (info . gnus-info-buffer)
980 (article-copy . gnus-article-copy)
981 (draft . gnus-draft-buffer))
982 "Mapping from short symbols to buffer names or buffer variables.")
984 (defvar gnus-carpal nil
985 "*If non-nil, display clickable icons.")
987 (defvar gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies
988 "*Function called with a group name when new group is detected.
989 A few pre-made functions are supplied: `gnus-subscribe-randomly'
990 inserts new groups at the beginning of the list of groups;
991 `gnus-subscribe-alphabetically' inserts new groups in strict
992 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
993 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
994 for your decision; `gnus-subscribe-killed' kills all new groups.")
996 ;; Suggested by a bug report by Hallvard B Furuseth.
997 ;; <h.b.furuseth@usit.uio.no>.
998 (defvar gnus-subscribe-options-newsgroup-method
999 (function gnus-subscribe-alphabetically)
1000 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines.
1001 If, for instance, you want to subscribe to all newsgroups in the
1002 \"no\" and \"alt\" hierarchies, you'd put the following in your
1005 options -n no.all alt.all
1007 Gnus will the subscribe all new newsgroups in these hierarchies with
1008 the subscription method in this variable.")
1010 (defvar gnus-subscribe-hierarchical-interactive nil
1011 "*If non-nil, Gnus will offer to subscribe hierarchically.
1012 When a new hierarchy appears, Gnus will ask the user:
1014 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
1016 If the user pressed `d', Gnus will descend the hierarchy, `y' will
1017 subscribe to all newsgroups in the hierarchy and `s' will skip this
1018 hierarchy in its entirety.")
1020 (defvar gnus-group-sort-function 'gnus-group-sort-by-alphabet
1021 "*Function used for sorting the group buffer.
1022 This function will be called with group info entries as the arguments
1023 for the groups to be sorted. Pre-made functions include
1024 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-unread',
1025 `gnus-group-sort-by-level', `gnus-group-sort-by-score', and
1026 `gnus-group-sort-by-rank'.
1028 This variable can also be a list of sorting functions. In that case,
1029 the most significant sort function should be the last function in the
1032 ;; Mark variables suggested by Thomas Michanek
1033 ;; <Thomas.Michanek@telelogic.se>.
1034 (defvar gnus-unread-mark ?
1035 "*Mark used for unread articles.")
1036 (defvar gnus-ticked-mark ?!
1037 "*Mark used for ticked articles.")
1038 (defvar gnus-dormant-mark ??
1039 "*Mark used for dormant articles.")
1040 (defvar gnus-del-mark ?r
1041 "*Mark used for del'd articles.")
1042 (defvar gnus-read-mark ?R
1043 "*Mark used for read articles.")
1044 (defvar gnus-expirable-mark ?E
1045 "*Mark used for expirable articles.")
1046 (defvar gnus-killed-mark ?K
1047 "*Mark used for killed articles.")
1048 (defvar gnus-souped-mark ?F
1049 "*Mark used for killed articles.")
1050 (defvar gnus-kill-file-mark ?X
1051 "*Mark used for articles killed by kill files.")
1052 (defvar gnus-low-score-mark ?Y
1053 "*Mark used for articles with a low score.")
1054 (defvar gnus-catchup-mark ?C
1055 "*Mark used for articles that are caught up.")
1056 (defvar gnus-replied-mark ?A
1057 "*Mark used for articles that have been replied to.")
1058 (defvar gnus-cached-mark ?*
1059 "*Mark used for articles that are in the cache.")
1060 (defvar gnus-saved-mark ?S
1061 "*Mark used for articles that have been saved to.")
1062 (defvar gnus-process-mark ?#
1064 (defvar gnus-ancient-mark ?O
1065 "*Mark used for ancient articles.")
1066 (defvar gnus-sparse-mark ?Q
1067 "*Mark used for sparsely reffed articles.")
1068 (defvar gnus-canceled-mark ?G
1069 "*Mark used for canceled articles.")
1070 (defvar gnus-score-over-mark ?+
1071 "*Score mark used for articles with high scores.")
1072 (defvar gnus-score-below-mark ?-
1073 "*Score mark used for articles with low scores.")
1074 (defvar gnus-empty-thread-mark ?
1075 "*There is no thread under the article.")
1076 (defvar gnus-not-empty-thread-mark ?=
1077 "*There is a thread under the article.")
1079 (defvar gnus-view-pseudo-asynchronously nil
1080 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
1082 (defvar gnus-view-pseudos nil
1083 "*If `automatic', pseudo-articles will be viewed automatically.
1084 If `not-confirm', pseudos will be viewed automatically, and the user
1085 will not be asked to confirm the command.")
1087 (defvar gnus-view-pseudos-separately t
1088 "*If non-nil, one pseudo-article will be created for each file to be viewed.
1089 If nil, all files that use the same viewing command will be given as a
1090 list of parameters to that command.")
1092 (defvar gnus-insert-pseudo-articles t
1093 "*If non-nil, insert pseudo-articles when decoding articles.")
1095 (defvar gnus-group-line-format "%M%S%p%P%5y: %(%g%)%l\n"
1096 "*Format of group lines.
1097 It works along the same lines as a normal formatting string,
1098 with some simple extensions.
1100 %M Only marked articles (character, \"*\" or \" \")
1101 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
1102 %L Level of subscribedness (integer)
1103 %N Number of unread articles (integer)
1104 %I Number of dormant articles (integer)
1105 %i Number of ticked and dormant (integer)
1106 %T Number of ticked articles (integer)
1107 %R Number of read articles (integer)
1108 %t Total number of articles (integer)
1109 %y Number of unread, unticked articles (integer)
1110 %G Group name (string)
1111 %g Qualified group name (string)
1112 %D Group description (string)
1113 %s Select method (string)
1114 %o Moderated group (char, \"m\")
1115 %p Process mark (char)
1116 %O Moderated group (string, \"(m)\" or \"\")
1117 %P Topic indentation (string)
1118 %l Whether there are GroupLens predictions for this group (string)
1119 %n Select from where (string)
1120 %z A string that look like `<%s:%n>' if a foreign select method is used
1121 %u User defined specifier. The next character in the format string should
1122 be a letter. Gnus will call the function gnus-user-format-function-X,
1123 where X is the letter following %u. The function will be passed the
1124 current header as argument. The function should return a string, which
1125 will be inserted into the buffer just like information from any other
1128 Text between %( and %) will be highlighted with `gnus-mouse-face' when
1129 the mouse point move inside the area. There can only be one such area.
1131 Note that this format specification is not always respected. For
1132 reasons of efficiency, when listing killed groups, this specification
1133 is ignored altogether. If the spec is changed considerably, your
1134 output may end up looking strange when listing both alive and killed
1137 If you use %o or %O, reading the active file will be slower and quite
1138 a bit of extra memory will be used. %D will also worsen performance.
1139 Also note that if you change the format specification to include any
1140 of these specs, you must probably re-start Gnus to see them go into
1143 (defvar gnus-summary-line-format "%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n"
1144 "*The format specification of the lines in the summary buffer.
1146 It works along the same lines as a normal formatting string,
1147 with some simple extensions.
1149 %N Article number, left padded with spaces (string)
1151 %s Subject if it is at the root of a thread, and \"\" otherwise (string)
1152 %n Name of the poster (string)
1153 %a Extracted name of the poster (string)
1154 %A Extracted address of the poster (string)
1155 %F Contents of the From: header (string)
1156 %x Contents of the Xref: header (string)
1157 %D Date of the article (string)
1158 %d Date of the article (string) in DD-MMM format
1159 %M Message-id of the article (string)
1160 %r References of the article (string)
1161 %c Number of characters in the article (integer)
1162 %L Number of lines in the article (integer)
1163 %I Indentation based on thread level (a string of spaces)
1164 %T A string with two possible values: 80 spaces if the article
1165 is on thread level two or larger and 0 spaces on level one
1166 %R \"A\" if this article has been replied to, \" \" otherwise (character)
1167 %U Status of this article (character, \"R\", \"K\", \"-\" or \" \")
1168 %[ Opening bracket (character, \"[\" or \"<\")
1169 %] Closing bracket (character, \"]\" or \">\")
1170 %> Spaces of length thread-level (string)
1171 %< Spaces of length (- 20 thread-level) (string)
1172 %i Article score (number)
1173 %z Article zcore (character)
1174 %t Number of articles under the current thread (number).
1175 %e Whether the thread is empty or not (character).
1176 %l GroupLens score (number)
1177 %u User defined specifier. The next character in the format string should
1178 be a letter. Gnus will call the function gnus-user-format-function-X,
1179 where X is the letter following %u. The function will be passed the
1180 current header as argument. The function should return a string, which
1181 will be inserted into the summary just like information from any other
1184 Text between %( and %) will be highlighted with `gnus-mouse-face'
1185 when the mouse point is placed inside the area. There can only be one
1188 The %U (status), %R (replied) and %z (zcore) specs have to be handled
1189 with care. For reasons of efficiency, Gnus will compute what column
1190 these characters will end up in, and \"hard-code\" that. This means that
1191 it is illegal to have these specs after a variable-length spec. Well,
1192 you might not be arrested, but your summary buffer will look strange,
1193 which is bad enough.
1195 The smart choice is to have these specs as for to the left as
1198 This restriction may disappear in later versions of Gnus.")
1200 (defvar gnus-summary-dummy-line-format
1202 "*The format specification for the dummy roots in the summary buffer.
1203 It works along the same lines as a normal formatting string,
1204 with some simple extensions.
1208 (defvar gnus-summary-mode-line-format "Gnus: %%b [%A] %Z"
1209 "*The format specification for the summary mode line.
1210 It works along the same lines as a normal formatting string,
1211 with some simple extensions:
1214 %p Unprefixed group name
1215 %A Current article number
1217 %U Number of unread articles in the group
1218 %e Number of unselected articles in the group
1219 %Z A string with unread/unselected article counts
1220 %g Shortish group name
1221 %S Subject of the current article
1222 %u User-defined spec
1223 %s Current score file name
1224 %d Number of dormant articles
1225 %r Number of articles that have been marked as read in this session
1226 %E Number of articles expunged by the score files")
1228 (defvar gnus-article-mode-line-format "Gnus: %%b %S"
1229 "*The format specification for the article mode line.
1230 See `gnus-summary-mode-line-format' for a closer description.")
1232 (defvar gnus-group-mode-line-format "Gnus: %%b {%M:%S}"
1233 "*The format specification for the group mode line.
1234 It works along the same lines as a normal formatting string,
1235 with some simple extensions:
1237 %S The native news server.
1238 %M The native select method.")
1240 (defvar gnus-valid-select-methods
1241 '(("nntp" post address prompt-address)
1242 ("nnspool" post address)
1243 ("nnvirtual" post-mail virtual prompt-address)
1244 ("nnmbox" mail respool address)
1245 ("nnml" mail respool address)
1246 ("nnmh" mail respool address)
1247 ("nndir" post-mail prompt-address address)
1248 ("nneething" none address prompt-address)
1249 ("nndoc" none address prompt-address)
1250 ("nnbabyl" mail address respool)
1251 ("nnkiboze" post address virtual)
1252 ("nnsoup" post-mail address)
1253 ("nndraft" post-mail)
1254 ("nnfolder" mail respool address))
1255 "An alist of valid select methods.
1256 The first element of each list lists should be a string with the name
1257 of the select method. The other elements may be be the category of
1258 this method (ie. `post', `mail', `none' or whatever) or other
1259 properties that this method has (like being respoolable).
1260 If you implement a new select method, all you should have to change is
1261 this variable. I think.")
1263 (defvar gnus-updated-mode-lines '(group article summary tree)
1264 "*List of buffers that should update their mode lines.
1265 The list may contain the symbols `group', `article' and `summary'. If
1266 the corresponding symbol is present, Gnus will keep that mode line
1267 updated with information that may be pertinent.
1268 If this variable is nil, screen refresh may be quicker.")
1270 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>.
1271 (defvar gnus-mode-non-string-length nil
1272 "*Max length of mode-line non-string contents.
1273 If this is nil, Gnus will take space as is needed, leaving the rest
1274 of the modeline intact.")
1277 ;(defvar gnus-mouse-face 'highlight
1278 ; "*Face used for mouse highlighting in Gnus.
1279 ;No mouse highlights will be done if `gnus-visual' is nil.")
1281 (defvar gnus-summary-mark-below nil
1282 "*Mark all articles with a score below this variable as read.
1283 This variable is local to each summary buffer and usually set by the
1286 (defvar gnus-article-sort-functions '(gnus-article-sort-by-number)
1287 "*List of functions used for sorting articles in the summary buffer.
1288 This variable is only used when not using a threaded display.")
1290 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number)
1291 "*List of functions used for sorting threads in the summary buffer.
1292 By default, threads are sorted by article number.
1294 Each function takes two threads and return non-nil if the first thread
1295 should be sorted before the other. If you use more than one function,
1296 the primary sort function should be the last. You should probably
1297 always include `gnus-thread-sort-by-number' in the list of sorting
1298 functions -- preferably first.
1300 Ready-mady functions include `gnus-thread-sort-by-number',
1301 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
1302 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
1303 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').")
1305 (defvar gnus-thread-score-function '+
1306 "*Function used for calculating the total score of a thread.
1308 The function is called with the scores of the article and each
1309 subthread and should then return the score of the thread.
1311 Some functions you can use are `+', `max', or `min'.")
1313 (defvar gnus-summary-expunge-below nil
1314 "All articles that have a score less than this variable will be expunged.")
1316 (defvar gnus-thread-expunge-below nil
1317 "All threads that have a total score less than this variable will be expunged.
1318 See `gnus-thread-score-function' for en explanation of what a
1319 \"thread score\" is.")
1321 (defvar gnus-auto-subscribed-groups
1322 "^nnml\\|^nnfolder\\|^nnmbox\\|^nnmh\\|^nnbabyl"
1323 "*All new groups that match this regexp will be subscribed automatically.
1324 Note that this variable only deals with new groups. It has no effect
1325 whatsoever on old groups.")
1327 (defvar gnus-options-subscribe nil
1328 "*All new groups matching this regexp will be subscribed unconditionally.
1329 Note that this variable deals only with new newsgroups. This variable
1330 does not affect old newsgroups.")
1332 (defvar gnus-options-not-subscribe nil
1333 "*All new groups matching this regexp will be ignored.
1334 Note that this variable deals only with new newsgroups. This variable
1335 does not affect old (already subscribed) newsgroups.")
1337 (defvar gnus-auto-expirable-newsgroups nil
1338 "*Groups in which to automatically mark read articles as expirable.
1339 If non-nil, this should be a regexp that should match all groups in
1340 which to perform auto-expiry. This only makes sense for mail groups.")
1342 (defvar gnus-total-expirable-newsgroups nil
1343 "*Groups in which to perform expiry of all read articles.
1344 Use with extreme caution. All groups that match this regexp will be
1345 expiring - which means that all read articles will be deleted after
1346 (say) one week. (This only goes for mail groups and the like, of
1349 (defvar gnus-group-uncollapsed-levels 1
1350 "Number of group name elements to leave alone when making a short group name.")
1352 (defvar gnus-hidden-properties '(invisible t intangible t)
1353 "Property list to use for hiding text.")
1355 (defvar gnus-modtime-botch nil
1356 "*Non-nil means .newsrc should be deleted prior to save.
1357 Its use is due to the bogus appearance that .newsrc was modified on
1362 (defvar gnus-group-mode-hook nil
1363 "*A hook for Gnus group mode.")
1365 (defvar gnus-summary-mode-hook nil
1366 "*A hook for Gnus summary mode.
1367 This hook is run before any variables are set in the summary buffer.")
1369 (defvar gnus-article-mode-hook nil
1370 "*A hook for Gnus article mode.")
1372 (defvar gnus-summary-prepare-exit-hook nil
1373 "*A hook called when preparing to exit from the summary buffer.
1374 It calls `gnus-summary-expire-articles' by default.")
1375 (add-hook 'gnus-summary-prepare-exit-hook 'gnus-summary-expire-articles)
1377 (defvar gnus-summary-exit-hook nil
1378 "*A hook called on exit from the summary buffer.")
1380 (defvar gnus-group-catchup-group-hook nil
1381 "*A hook run when catching up a group from the group buffer.")
1383 (defvar gnus-open-server-hook nil
1384 "*A hook called just before opening connection to the news server.")
1386 (defvar gnus-load-hook nil
1387 "*A hook run while Gnus is loaded.")
1389 (defvar gnus-startup-hook nil
1390 "*A hook called at startup.
1391 This hook is called after Gnus is connected to the NNTP server.")
1393 (defvar gnus-get-new-news-hook nil
1394 "*A hook run just before Gnus checks for new news.")
1396 (defvar gnus-after-getting-new-news-hook nil
1397 "*A hook run after Gnus checks for new news.")
1399 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat
1400 "*A function that is called to generate the group buffer.
1401 The function is called with three arguments: The first is a number;
1402 all group with a level less or equal to that number should be listed,
1403 if the second is non-nil, empty groups should also be displayed. If
1404 the third is non-nil, it is a number. No groups with a level lower
1405 than this number should be displayed.
1407 The only current function implemented is `gnus-group-prepare-flat'.")
1409 (defvar gnus-group-prepare-hook nil
1410 "*A hook called after the group buffer has been generated.
1411 If you want to modify the group buffer, you can use this hook.")
1413 (defvar gnus-summary-prepare-hook nil
1414 "*A hook called after the summary buffer has been generated.
1415 If you want to modify the summary buffer, you can use this hook.")
1417 (defvar gnus-summary-generate-hook nil
1418 "*A hook run just before generating the summary buffer.
1419 This hook is commonly used to customize threading variables and the
1422 (defvar gnus-article-prepare-hook nil
1423 "*A hook called after an article has been prepared in the article buffer.
1424 If you want to run a special decoding program like nkf, use this hook.")
1426 ;(defvar gnus-article-display-hook nil
1427 ; "*A hook called after the article is displayed in the article buffer.
1428 ;The hook is designed to change the contents of the article
1429 ;buffer. Typical functions that this hook may contain are
1430 ;`gnus-article-hide-headers' (hide selected headers),
1431 ;`gnus-article-maybe-highlight' (perform fancy article highlighting),
1432 ;`gnus-article-hide-signature' (hide signature) and
1433 ;`gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).")
1434 ;(add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted)
1435 ;(add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike)
1436 ;(add-hook 'gnus-article-display-hook 'gnus-article-maybe-highlight)
1438 (defvar gnus-article-x-face-command
1439 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | xv -quit -"
1440 "String or function to be executed to display an X-Face header.
1441 If it is a string, the command will be executed in a sub-shell
1442 asynchronously. The compressed face will be piped to this command.")
1444 (defvar gnus-article-x-face-too-ugly nil
1445 "Regexp matching posters whose face shouldn't be shown automatically.")
1447 (defvar gnus-select-group-hook nil
1448 "*A hook called when a newsgroup is selected.
1450 If you'd like to simplify subjects like the
1451 `gnus-summary-next-same-subject' command does, you can use the
1454 (setq gnus-select-group-hook
1457 (mapcar (lambda (header)
1458 (mail-header-set-subject
1460 (gnus-simplify-subject
1461 (mail-header-subject header) 're-only)))
1462 gnus-newsgroup-headers))))")
1464 (defvar gnus-select-article-hook nil
1465 "*A hook called when an article is selected.")
1467 (defvar gnus-apply-kill-hook '(gnus-apply-kill-file)
1468 "*A hook called to apply kill files to a group.
1469 This hook is intended to apply a kill file to the selected newsgroup.
1470 The function `gnus-apply-kill-file' is called by default.
1472 Since a general kill file is too heavy to use only for a few
1473 newsgroups, I recommend you to use a lighter hook function. For
1474 example, if you'd like to apply a kill file to articles which contains
1475 a string `rmgroup' in subject in newsgroup `control', you can use the
1478 (setq gnus-apply-kill-hook
1481 (cond ((string-match \"control\" gnus-newsgroup-name)
1482 (gnus-kill \"Subject\" \"rmgroup\")
1483 (gnus-expunge \"X\"))))))")
1485 (defvar gnus-visual-mark-article-hook
1486 (list 'gnus-highlight-selected-summary)
1487 "*Hook run after selecting an article in the summary buffer.
1488 It is meant to be used for highlighting the article in some way. It
1489 is not run if `gnus-visual' is nil.")
1491 (defvar gnus-parse-headers-hook nil
1492 "*A hook called before parsing the headers.")
1494 (defvar gnus-exit-group-hook nil
1495 "*A hook called when exiting (not quitting) summary mode.")
1497 (defvar gnus-suspend-gnus-hook nil
1498 "*A hook called when suspending (not exiting) Gnus.")
1500 (defvar gnus-exit-gnus-hook nil
1501 "*A hook called when exiting Gnus.")
1503 (defvar gnus-after-exiting-gnus-hook nil
1504 "*A hook called after exiting Gnus.")
1506 (defvar gnus-save-newsrc-hook nil
1507 "*A hook called before saving any of the newsrc files.")
1509 (defvar gnus-save-quick-newsrc-hook nil
1510 "*A hook called just before saving the quick newsrc file.
1511 Can be used to turn version control on or off.")
1513 (defvar gnus-save-standard-newsrc-hook nil
1514 "*A hook called just before saving the standard newsrc file.
1515 Can be used to turn version control on or off.")
1517 (defvar gnus-summary-update-hook
1518 (list 'gnus-summary-highlight-line)
1519 "*A hook called when a summary line is changed.
1520 The hook will not be called if `gnus-visual' is nil.
1522 The default function `gnus-summary-highlight-line' will
1523 highlight the line according to the `gnus-summary-highlight'
1526 (defvar gnus-group-update-hook '(gnus-group-highlight-line)
1527 "*A hook called when a group line is changed.
1528 The hook will not be called if `gnus-visual' is nil.
1530 The default function `gnus-group-highlight-line' will
1531 highlight the line according to the `gnus-group-highlight'
1534 (defvar gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
1535 "*A hook called when an article is selected for the first time.
1536 The hook is intended to mark an article as read (or unread)
1537 automatically when it is selected.")
1539 (defvar gnus-group-change-level-function nil
1540 "Function run when a group level is changed.
1541 It is called with three parameters -- GROUP, LEVEL and OLDLEVEL.")
1543 ;; Remove any hilit infestation.
1544 (add-hook 'gnus-startup-hook
1546 (remove-hook 'gnus-summary-prepare-hook
1547 'hilit-rehighlight-buffer-quietly)
1548 (remove-hook 'gnus-summary-prepare-hook 'hilit-install-line-hooks)
1549 (setq gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read))
1550 (remove-hook 'gnus-article-prepare-hook
1551 'hilit-rehighlight-buffer-quietly)))
1554 ;; Internal variables
1556 (defvar gnus-server-alist nil
1557 "List of available servers.")
1559 (defvar gnus-group-indentation-function nil)
1561 (defvar gnus-topic-indentation "") ;; Obsolete variable.
1563 (defvar gnus-goto-missing-group-function nil)
1565 (defvar gnus-override-subscribe-method nil)
1567 (defvar gnus-group-goto-next-group-function nil
1568 "Function to override finding the next group after listing groups.")
1570 (defconst gnus-article-mark-lists
1571 '((marked . tick) (replied . reply)
1572 (expirable . expire) (killed . killed)
1573 (bookmarks . bookmark) (dormant . dormant)
1574 (scored . score) (saved . save)
1578 ;; Avoid highlighting in kill files.
1579 (defvar gnus-summary-inhibit-highlight nil)
1580 (defvar gnus-newsgroup-selected-overlay nil)
1582 (defvar gnus-inhibit-hiding nil)
1583 (defvar gnus-group-indentation "")
1584 (defvar gnus-inhibit-limiting nil)
1585 (defvar gnus-created-frames nil)
1587 (defvar gnus-article-mode-map nil)
1588 (defvar gnus-dribble-buffer nil)
1589 (defvar gnus-headers-retrieved-by nil)
1590 (defvar gnus-article-reply nil)
1591 (defvar gnus-override-method nil)
1592 (defvar gnus-article-check-size nil)
1594 (defvar gnus-current-score-file nil)
1595 (defvar gnus-newsgroup-adaptive-score-file nil)
1596 (defvar gnus-scores-exclude-files nil)
1598 (defvar gnus-opened-servers nil)
1600 (defvar gnus-current-move-group nil)
1602 (defvar gnus-newsgroup-dependencies nil)
1603 (defvar gnus-newsgroup-async nil)
1604 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*")
1606 (defvar gnus-newsgroup-adaptive nil)
1608 (defvar gnus-summary-display-table nil)
1609 (defvar gnus-summary-display-article-function nil)
1611 (defvar gnus-summary-highlight-line-function nil
1612 "Function called after highlighting a summary line.")
1614 (defvar gnus-group-line-format-alist
1615 `((?M gnus-tmp-marked-mark ?c)
1616 (?S gnus-tmp-subscribed ?c)
1617 (?L gnus-tmp-level ?d)
1618 (?N (cond ((eq number t) "*" )
1622 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1623 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
1625 (?R gnus-tmp-number-of-read ?s)
1626 (?t gnus-tmp-number-total ?d)
1627 (?y gnus-tmp-number-of-unread ?s)
1628 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
1629 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
1630 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1631 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
1632 (?g gnus-tmp-group ?s)
1633 (?G gnus-tmp-qualified-group ?s)
1634 (?c (gnus-short-group-name gnus-tmp-group) ?s)
1635 (?D gnus-tmp-newsgroup-description ?s)
1636 (?o gnus-tmp-moderated ?c)
1637 (?O gnus-tmp-moderated-string ?s)
1638 (?p gnus-tmp-process-marked ?c)
1639 (?s gnus-tmp-news-server ?s)
1640 (?n gnus-tmp-news-method ?s)
1641 (?P gnus-group-indentation ?s)
1642 (?l gnus-tmp-grouplens ?s)
1643 (?z gnus-tmp-news-method-string ?s)
1644 (?u gnus-tmp-user-defined ?s)))
1646 (defvar gnus-summary-line-format-alist
1647 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1648 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1649 (?s gnus-tmp-subject-or-nil ?s)
1650 (?n gnus-tmp-name ?s)
1651 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1653 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1655 (?F gnus-tmp-from ?s)
1656 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1657 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1658 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1659 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1660 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1661 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1662 (?L gnus-tmp-lines ?d)
1663 (?I gnus-tmp-indentation ?s)
1664 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1665 (?R gnus-tmp-replied ?c)
1666 (?\[ gnus-tmp-opening-bracket ?c)
1667 (?\] gnus-tmp-closing-bracket ?c)
1668 (?\> (make-string gnus-tmp-level ? ) ?s)
1669 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1670 (?i gnus-tmp-score ?d)
1671 (?z gnus-tmp-score-char ?c)
1672 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1673 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1674 (?U gnus-tmp-unread ?c)
1675 (?t (gnus-summary-number-of-articles-in-thread
1676 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1678 (?e (gnus-summary-number-of-articles-in-thread
1679 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1681 (?u gnus-tmp-user-defined ?s))
1682 "An alist of format specifications that can appear in summary lines,
1683 and what variables they correspond with, along with the type of the
1684 variable (string, integer, character, etc).")
1686 (defvar gnus-summary-dummy-line-format-alist
1687 `((?S gnus-tmp-subject ?s)
1688 (?N gnus-tmp-number ?d)
1689 (?u gnus-tmp-user-defined ?s)))
1691 (defvar gnus-summary-mode-line-format-alist
1692 `((?G gnus-tmp-group-name ?s)
1693 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1694 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1695 (?A gnus-tmp-article-number ?d)
1696 (?Z gnus-tmp-unread-and-unselected ?s)
1697 (?V gnus-version ?s)
1698 (?U gnus-tmp-unread ?d)
1699 (?S gnus-tmp-subject ?s)
1700 (?e gnus-tmp-unselected ?d)
1701 (?u gnus-tmp-user-defined ?s)
1702 (?d (length gnus-newsgroup-dormant) ?d)
1703 (?t (length gnus-newsgroup-marked) ?d)
1704 (?r (length gnus-newsgroup-reads) ?d)
1705 (?E gnus-newsgroup-expunged-tally ?d)
1706 (?s (gnus-current-score-file-nondirectory) ?s)))
1708 (defvar gnus-article-mode-line-format-alist
1709 gnus-summary-mode-line-format-alist)
1711 (defvar gnus-group-mode-line-format-alist
1712 `((?S gnus-tmp-news-server ?s)
1713 (?M gnus-tmp-news-method ?s)
1714 (?u gnus-tmp-user-defined ?s)))
1716 (defvar gnus-have-read-active-file nil)
1718 (defconst gnus-maintainer
1719 "gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls + Boys)"
1720 "The mail address of the Gnus maintainers.")
1722 (defconst gnus-version "September Gnus v0.57"
1723 "Version number for this version of Gnus.")
1725 (defvar gnus-info-nodes
1726 '((gnus-group-mode "(gnus)The Group Buffer")
1727 (gnus-summary-mode "(gnus)The Summary Buffer")
1728 (gnus-article-mode "(gnus)The Article Buffer"))
1729 "Assoc list of major modes and related Info nodes.")
1731 (defvar gnus-group-buffer "*Group*")
1732 (defvar gnus-summary-buffer "*Summary*")
1733 (defvar gnus-article-buffer "*Article*")
1734 (defvar gnus-server-buffer "*Server*")
1736 (defvar gnus-work-buffer " *gnus work*")
1738 (defvar gnus-original-article-buffer " *Original Article*")
1739 (defvar gnus-original-article nil)
1741 (defvar gnus-buffer-list nil
1742 "Gnus buffers that should be killed on exit.")
1744 (defvar gnus-slave nil
1745 "Whether this Gnus is a slave or not.")
1747 (defvar gnus-variable-list
1748 '(gnus-newsrc-options gnus-newsrc-options-n
1749 gnus-newsrc-last-checked-date
1750 gnus-newsrc-alist gnus-server-alist
1751 gnus-killed-list gnus-zombie-list
1752 gnus-topic-topology gnus-topic-alist
1754 "Gnus variables saved in the quick startup file.")
1756 (defvar gnus-newsrc-options nil
1757 "Options line in the .newsrc file.")
1759 (defvar gnus-newsrc-options-n nil
1760 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1762 (defvar gnus-newsrc-last-checked-date nil
1763 "Date Gnus last asked server for new newsgroups.")
1765 (defvar gnus-topic-topology nil
1766 "The complete topic hierarchy.")
1768 (defvar gnus-topic-alist nil
1769 "The complete topic-group alist.")
1771 (defvar gnus-newsrc-alist nil
1772 "Assoc list of read articles.
1773 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1775 (defvar gnus-newsrc-hashtb nil
1776 "Hashtable of gnus-newsrc-alist.")
1778 (defvar gnus-killed-list nil
1779 "List of killed newsgroups.")
1781 (defvar gnus-killed-hashtb nil
1782 "Hash table equivalent of gnus-killed-list.")
1784 (defvar gnus-zombie-list nil
1785 "List of almost dead newsgroups.")
1787 (defvar gnus-description-hashtb nil
1788 "Descriptions of newsgroups.")
1790 (defvar gnus-list-of-killed-groups nil
1791 "List of newsgroups that have recently been killed by the user.")
1793 (defvar gnus-active-hashtb nil
1794 "Hashtable of active articles.")
1796 (defvar gnus-moderated-list nil
1797 "List of moderated newsgroups.")
1799 (defvar gnus-group-marked nil)
1801 (defvar gnus-current-startup-file nil
1802 "Startup file for the current host.")
1804 (defvar gnus-last-search-regexp nil
1805 "Default regexp for article search command.")
1807 (defvar gnus-last-shell-command nil
1808 "Default shell command on article.")
1810 (defvar gnus-current-select-method nil
1811 "The current method for selecting a newsgroup.")
1813 (defvar gnus-group-list-mode nil)
1815 (defvar gnus-article-internal-prepare-hook nil)
1817 (defvar gnus-newsgroup-name nil)
1818 (defvar gnus-newsgroup-begin nil)
1819 (defvar gnus-newsgroup-end nil)
1820 (defvar gnus-newsgroup-last-rmail nil)
1821 (defvar gnus-newsgroup-last-mail nil)
1822 (defvar gnus-newsgroup-last-folder nil)
1823 (defvar gnus-newsgroup-last-file nil)
1824 (defvar gnus-newsgroup-auto-expire nil)
1825 (defvar gnus-newsgroup-active nil)
1827 (defvar gnus-newsgroup-data nil)
1828 (defvar gnus-newsgroup-data-reverse nil)
1829 (defvar gnus-newsgroup-limit nil)
1830 (defvar gnus-newsgroup-limits nil)
1832 (defvar gnus-newsgroup-unreads nil
1833 "List of unread articles in the current newsgroup.")
1835 (defvar gnus-newsgroup-unselected nil
1836 "List of unselected unread articles in the current newsgroup.")
1838 (defvar gnus-newsgroup-reads nil
1839 "Alist of read articles and article marks in the current newsgroup.")
1841 (defvar gnus-newsgroup-expunged-tally nil)
1843 (defvar gnus-newsgroup-marked nil
1844 "List of ticked articles in the current newsgroup (a subset of unread art).")
1846 (defvar gnus-newsgroup-killed nil
1847 "List of ranges of articles that have been through the scoring process.")
1849 (defvar gnus-newsgroup-cached nil
1850 "List of articles that come from the article cache.")
1852 (defvar gnus-newsgroup-saved nil
1853 "List of articles that have been saved.")
1855 (defvar gnus-newsgroup-kill-headers nil)
1857 (defvar gnus-newsgroup-replied nil
1858 "List of articles that have been replied to in the current newsgroup.")
1860 (defvar gnus-newsgroup-expirable nil
1861 "List of articles in the current newsgroup that can be expired.")
1863 (defvar gnus-newsgroup-processable nil
1864 "List of articles in the current newsgroup that can be processed.")
1866 (defvar gnus-newsgroup-bookmarks nil
1867 "List of articles in the current newsgroup that have bookmarks.")
1869 (defvar gnus-newsgroup-dormant nil
1870 "List of dormant articles in the current newsgroup.")
1872 (defvar gnus-newsgroup-scored nil
1873 "List of scored articles in the current newsgroup.")
1875 (defvar gnus-newsgroup-headers nil
1876 "List of article headers in the current newsgroup.")
1878 (defvar gnus-newsgroup-threads nil)
1880 (defvar gnus-newsgroup-prepared nil
1881 "Whether the current group has been prepared properly.")
1883 (defvar gnus-newsgroup-ancient nil
1884 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1886 (defvar gnus-newsgroup-sparse nil)
1888 (defvar gnus-current-article nil)
1889 (defvar gnus-article-current nil)
1890 (defvar gnus-current-headers nil)
1891 (defvar gnus-have-all-headers nil)
1892 (defvar gnus-last-article nil)
1893 (defvar gnus-newsgroup-history nil)
1894 (defvar gnus-current-kill-article nil)
1896 ;; Save window configuration.
1897 (defvar gnus-prev-winconf nil)
1899 (defvar gnus-summary-mark-positions nil)
1900 (defvar gnus-group-mark-positions nil)
1902 (defvar gnus-reffed-article-number nil)
1904 ;;; Let the byte-compiler know that we know about this variable.
1905 (defvar rmail-default-rmail-file)
1907 (defvar gnus-cache-removable-articles nil)
1909 (defvar gnus-dead-summary nil)
1911 (defconst gnus-summary-local-variables
1912 '(gnus-newsgroup-name
1913 gnus-newsgroup-begin gnus-newsgroup-end
1914 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1915 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1916 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1917 gnus-newsgroup-unselected gnus-newsgroup-marked
1918 gnus-newsgroup-reads gnus-newsgroup-saved
1919 gnus-newsgroup-replied gnus-newsgroup-expirable
1920 gnus-newsgroup-processable gnus-newsgroup-killed
1921 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1922 gnus-newsgroup-headers gnus-newsgroup-threads
1923 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1924 gnus-current-article gnus-current-headers gnus-have-all-headers
1925 gnus-last-article gnus-article-internal-prepare-hook
1926 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1927 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1928 gnus-newsgroup-async
1929 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1930 gnus-summary-mark-below gnus-newsgroup-active gnus-scores-exclude-files
1931 gnus-newsgroup-history gnus-newsgroup-ancient
1932 gnus-newsgroup-sparse
1933 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1934 gnus-newsgroup-adaptive-score-file
1935 (gnus-newsgroup-expunged-tally . 0)
1936 gnus-cache-removable-articles gnus-newsgroup-cached
1937 gnus-newsgroup-data gnus-newsgroup-data-reverse
1938 gnus-newsgroup-limit gnus-newsgroup-limits)
1939 "Variables that are buffer-local to the summary buffers.")
1941 (defconst gnus-bug-message
1942 "Sending a bug report to the Gnus Towers.
1943 ========================================
1945 The buffer below is a mail buffer. When you press `C-c C-c', it will
1946 be sent to the Gnus Bug Exterminators.
1948 At the bottom of the buffer you'll see lots of variable settings.
1949 Please do not delete those. They will tell the Bug People what your
1950 environment is, so that it will be easier to locate the bugs.
1952 If you have found a bug that makes Emacs go \"beep\", set
1953 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
1954 and include the backtrace in your bug report.
1956 Please describe the bug in annoying, painstaking detail.
1958 Thank you for your help in stamping out bugs.
1961 ;;; End of variables.
1963 ;; Define some autoload functions Gnus might use.
1966 ;; This little mapcar goes through the list below and marks the
1967 ;; symbols in question as autoloaded functions.
1970 (let ((interactive (nth 1 (memq ':interactive package))))
1974 (when (consp function)
1975 (setq keymap (car (memq 'keymap function)))
1976 (setq function (car function)))
1977 (autoload function (car package) nil interactive keymap)))
1978 (if (eq (nth 1 package) ':interactive)
1981 '(("metamail" metamail-buffer)
1982 ("info" Info-goto-node)
1983 ("hexl" hexl-hex-string-to-integer)
1984 ("pp" pp pp-to-string pp-eval-expression)
1985 ("mail-extr" mail-extract-address-components)
1986 ("nnmail" nnmail-split-fancy nnmail-article-group)
1987 ("nnvirtual" nnvirtual-catchup-group)
1988 ("timezone" timezone-make-date-arpa-standard timezone-fix-time
1989 timezone-make-sortable-date timezone-make-time-string)
1990 ("sendmail" mail-position-on-field mail-setup)
1991 ("rmailout" rmail-output)
1992 ("rnewspost" news-mail-other-window news-reply-yank-original
1993 news-caesar-buffer-body)
1994 ("rmail" rmail-insert-rmail-file-header rmail-count-new-messages
1996 ("gnus-soup" :interactive t
1997 gnus-group-brew-soup gnus-brew-soup gnus-soup-add-article
1998 gnus-soup-send-replies gnus-soup-save-areas gnus-soup-pack-packet)
1999 ("nnsoup" nnsoup-pack-replies)
2000 ("gnus-mh" gnus-mh-mail-setup gnus-summary-save-article-folder
2001 gnus-Folder-save-name gnus-folder-save-name)
2002 ("gnus-mh" :interactive t gnus-summary-save-in-folder)
2003 ("gnus-vis" gnus-group-make-menu-bar gnus-summary-make-menu-bar
2004 gnus-server-make-menu-bar gnus-article-make-menu-bar
2005 gnus-browse-make-menu-bar gnus-highlight-selected-summary
2006 gnus-summary-highlight-line gnus-carpal-setup-buffer
2007 gnus-group-highlight-line
2008 gnus-article-add-button gnus-insert-next-page-button
2009 gnus-insert-prev-page-button gnus-visual-turn-off-edit-menu)
2010 ("gnus-vis" :interactive t
2011 gnus-article-push-button gnus-article-press-button
2012 gnus-article-highlight gnus-article-highlight-some
2013 gnus-article-highlight-headers gnus-article-highlight-signature
2014 gnus-article-add-buttons gnus-article-add-buttons-to-head
2015 gnus-article-next-button gnus-article-prev-button)
2016 ("gnus-demon" gnus-demon-add-nocem gnus-demon-add-scanmail
2017 gnus-demon-add-disconnection gnus-demon-add-handler
2018 gnus-demon-remove-handler)
2019 ("gnus-demon" :interactive t
2020 gnus-demon-init gnus-demon-cancel)
2021 ("gnus-salt" gnus-highlight-selected-tree gnus-possibly-generate-tree
2022 gnus-tree-open gnus-tree-close)
2023 ("gnus-nocem" gnus-nocem-scan-groups gnus-nocem-close
2024 gnus-nocem-unwanted-article-p)
2025 ("gnus-srvr" gnus-enter-server-buffer gnus-server-set-info)
2026 ("gnus-srvr" gnus-browse-foreign-server)
2027 ("gnus-cite" :interactive t
2028 gnus-article-highlight-citation gnus-article-hide-citation-maybe
2029 gnus-article-hide-citation gnus-article-fill-cited-article)
2030 ("gnus-kill" gnus-kill gnus-apply-kill-file-internal
2031 gnus-kill-file-edit-file gnus-kill-file-raise-followups-to-author
2032 gnus-execute gnus-expunge)
2033 ("gnus-cache" gnus-cache-possibly-enter-article gnus-cache-save-buffers
2034 gnus-cache-possibly-remove-articles gnus-cache-request-article
2035 gnus-cache-retrieve-headers gnus-cache-possibly-alter-active
2036 gnus-cache-enter-remove-article gnus-cached-article-p
2037 gnus-cache-open gnus-cache-close gnus-cache-update-article)
2038 ("gnus-cache" :interactive t gnus-jog-cache gnus-cache-enter-article
2039 gnus-cache-remove-article)
2040 ("gnus-score" :interactive t
2041 gnus-summary-increase-score gnus-summary-lower-score
2042 gnus-score-flush-cache gnus-score-close
2043 gnus-score-raise-same-subject-and-select
2044 gnus-score-raise-same-subject gnus-score-default
2045 gnus-score-raise-thread gnus-score-lower-same-subject-and-select
2046 gnus-score-lower-same-subject gnus-score-lower-thread
2047 gnus-possibly-score-headers)
2049 (gnus-summary-score-map keymap) gnus-score-save gnus-score-headers
2050 gnus-current-score-file-nondirectory gnus-score-adaptive
2051 gnus-score-find-trace gnus-score-file-name)
2052 ("gnus-edit" :interactive t gnus-score-customize)
2053 ("gnus-topic" :interactive t gnus-topic-mode)
2054 ("gnus-topic" gnus-topic-remove-group)
2055 ("gnus-salt" :interactive t gnus-pick-mode gnus-binary-mode)
2056 ("gnus-uu" (gnus-uu-extract-map keymap) (gnus-uu-mark-map keymap))
2057 ("gnus-uu" :interactive t
2058 gnus-uu-digest-mail-forward gnus-uu-digest-post-forward
2059 gnus-uu-mark-series gnus-uu-mark-region gnus-uu-mark-buffer
2060 gnus-uu-mark-by-regexp gnus-uu-mark-all
2061 gnus-uu-mark-sparse gnus-uu-mark-thread gnus-uu-decode-uu
2062 gnus-uu-decode-uu-and-save gnus-uu-decode-unshar
2063 gnus-uu-decode-unshar-and-save gnus-uu-decode-save
2064 gnus-uu-decode-binhex gnus-uu-decode-uu-view
2065 gnus-uu-decode-uu-and-save-view gnus-uu-decode-unshar-view
2066 gnus-uu-decode-unshar-and-save-view gnus-uu-decode-save-view
2067 gnus-uu-decode-binhex-view)
2068 ("gnus-msg" (gnus-summary-send-map keymap)
2069 gnus-mail-yank-original gnus-mail-send-and-exit
2070 gnus-sendmail-setup-mail gnus-article-mail
2071 gnus-inews-message-id gnus-new-mail gnus-mail-reply)
2072 ("gnus-msg" :interactive t
2073 gnus-group-post-news gnus-group-mail gnus-summary-post-news
2074 gnus-summary-followup gnus-summary-followup-with-original
2075 gnus-summary-followup-and-reply
2076 gnus-summary-followup-and-reply-with-original
2077 gnus-summary-cancel-article gnus-summary-supersede-article
2078 gnus-post-news gnus-inews-news gnus-cancel-news
2079 gnus-summary-reply gnus-summary-reply-with-original
2080 gnus-summary-mail-forward gnus-summary-mail-other-window
2082 ("gnus-picon" :interactive t gnus-article-display-picons
2083 gnus-group-display-picons gnus-picons-article-display-x-face)
2084 ("gnus-gl" bbb-login bbb-logout bbb-grouplens-group-p
2085 gnus-grouplens-mode)
2086 ("gnus-vm" gnus-vm-mail-setup)
2087 ("gnus-vm" :interactive t gnus-summary-save-in-vm
2088 gnus-summary-save-article-vm gnus-yank-article))))
2092 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2093 ;; If you want the cursor to go somewhere else, set these two
2094 ;; functions in some startup hook to whatever you want.
2095 (defalias 'gnus-summary-position-point 'gnus-goto-colon)
2096 (defalias 'gnus-group-position-point 'gnus-goto-colon)
2098 ;;; Various macros and substs.
2100 (defun gnus-header-from (header)
2101 (mail-header-from header))
2103 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
2104 "Pop to BUFFER, evaluate FORMS, and then return to the original window."
2105 (let ((tempvar (make-symbol "GnusStartBufferWindow")))
2106 `(let ((,tempvar (selected-window)))
2109 (pop-to-buffer ,buffer)
2111 (select-window ,tempvar)))))
2113 (defmacro gnus-gethash (string hashtable)
2114 "Get hash value of STRING in HASHTABLE."
2115 `(symbol-value (intern-soft ,string ,hashtable)))
2117 (defmacro gnus-sethash (string value hashtable)
2118 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2119 `(set (intern ,string ,hashtable) ,value))
2121 (defmacro gnus-intern-safe (string hashtable)
2122 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2123 `(let ((symbol (intern ,string ,hashtable)))
2128 (defmacro gnus-group-unread (group)
2129 "Get the currently computed number of unread articles in GROUP."
2130 `(car (gnus-gethash ,group gnus-newsrc-hashtb)))
2132 (defmacro gnus-group-entry (group)
2133 "Get the newsrc entry for GROUP."
2134 `(gnus-gethash ,group gnus-newsrc-hashtb))
2136 (defmacro gnus-active (group)
2137 "Get active info on GROUP."
2138 `(gnus-gethash ,group gnus-active-hashtb))
2140 (defmacro gnus-set-active (group active)
2141 "Set GROUP's active info."
2142 `(gnus-sethash ,group ,active gnus-active-hashtb))
2144 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2145 ;; function `substring' might cut on a middle of multi-octet
2147 (defun gnus-truncate-string (str width)
2148 (substring str 0 width))
2150 ;; Added by Geoffrey T. Dairiki <dairiki@u.washington.edu>. A safe way
2151 ;; to limit the length of a string. This function is necessary since
2152 ;; `(substr "abc" 0 30)' pukes with "Args out of range".
2153 (defsubst gnus-limit-string (str width)
2154 (if (> (length str) width)
2155 (substring str 0 width)
2158 (defsubst gnus-simplify-subject-re (subject)
2159 "Remove \"Re:\" from subject lines."
2160 (if (string-match "^[Rr][Ee]: *" subject)
2161 (substring subject (match-end 0))
2164 (defsubst gnus-functionp (form)
2165 "Return non-nil if FORM is funcallable."
2166 (or (and (symbolp form) (fboundp form))
2167 (and (listp form) (eq (car form) 'lambda))))
2169 (defsubst gnus-goto-char (point)
2170 (and point (goto-char point)))
2172 (defmacro gnus-buffer-exists-p (buffer)
2173 `(let ((buffer ,buffer))
2175 (funcall (if (stringp buffer) 'get-buffer 'buffer-name)
2178 (defmacro gnus-kill-buffer (buffer)
2179 `(let ((buf ,buffer))
2180 (if (gnus-buffer-exists-p buf)
2181 (kill-buffer buf))))
2183 (defsubst gnus-point-at-bol ()
2184 "Return point at the beginning of the line."
2191 (defsubst gnus-point-at-eol ()
2192 "Return point at the end of the line."
2199 (defun gnus-alive-p ()
2200 "Say whether Gnus is running or not."
2201 (and gnus-group-buffer
2202 (get-buffer gnus-group-buffer)))
2204 ;; Delete the current line (and the next N lines.);
2205 (defmacro gnus-delete-line (&optional n)
2206 `(delete-region (progn (beginning-of-line) (point))
2207 (progn (forward-line ,(or n 1)) (point))))
2209 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
2210 (defvar gnus-init-inhibit nil)
2211 (defun gnus-read-init-file (&optional inhibit-next)
2212 (if gnus-init-inhibit
2213 (setq gnus-init-inhibit nil)
2214 (setq gnus-init-inhibit inhibit-next)
2216 (or (and (file-exists-p gnus-init-file)
2217 ;; Don't try to load a directory.
2218 (not (file-directory-p gnus-init-file)))
2219 (file-exists-p (concat gnus-init-file ".el"))
2220 (file-exists-p (concat gnus-init-file ".elc")))
2222 (load gnus-init-file nil t)
2224 (error "Error in %s: %s" gnus-init-file var))))))
2226 ;; Info access macros.
2228 (defmacro gnus-info-group (info)
2230 (defmacro gnus-info-rank (info)
2232 (defmacro gnus-info-read (info)
2234 (defmacro gnus-info-marks (info)
2236 (defmacro gnus-info-method (info)
2238 (defmacro gnus-info-params (info)
2241 (defmacro gnus-info-level (info)
2242 `(let ((rank (gnus-info-rank ,info)))
2246 (defmacro gnus-info-score (info)
2247 `(let ((rank (gnus-info-rank ,info)))
2248 (or (and (consp rank) (cdr rank)) 0)))
2250 (defmacro gnus-info-set-group (info group)
2251 `(setcar ,info ,group))
2252 (defmacro gnus-info-set-rank (info rank)
2253 `(setcar (nthcdr 1 ,info) ,rank))
2254 (defmacro gnus-info-set-read (info read)
2255 `(setcar (nthcdr 2 ,info) ,read))
2256 (defmacro gnus-info-set-marks (info marks)
2257 `(setcar (nthcdr 3 ,info) ,marks))
2258 (defmacro gnus-info-set-method (info method)
2259 `(setcar (nthcdr 4 ,info) ,method))
2260 (defmacro gnus-info-set-params (info params)
2261 `(setcar (nthcdr 5 ,info) ,params))
2263 (defmacro gnus-info-set-level (info level)
2264 `(let ((rank (cdr ,info)))
2265 (if (consp (car rank))
2266 (setcar (car rank) ,level)
2267 (setcar rank ,level))))
2268 (defmacro gnus-info-set-score (info score)
2269 `(let ((rank (cdr ,info)))
2270 (if (consp (car rank))
2271 (setcdr (car rank) ,score)
2272 (setcar rank (cons (car rank) ,score)))))
2274 (defmacro gnus-get-info (group)
2275 `(nth 2 (gnus-gethash ,group gnus-newsrc-hashtb)))
2277 (defun gnus-byte-code (func)
2278 "Return a form that can be `eval'ed based on FUNC."
2279 (let ((fval (symbol-function func)))
2280 (if (byte-code-function-p fval)
2281 (let ((flist (append fval nil)))
2282 (setcar flist 'byte-code)
2284 (cons 'progn (cddr fval)))))
2286 ;;; Load the compatability functions.
2296 (defvar gnus-shutdown-alist nil)
2298 (defun gnus-add-shutdown (function &rest symbols)
2299 "Run FUNCTION whenever one of SYMBOLS is shut down."
2300 (push (cons function symbols) gnus-shutdown-alist))
2302 (defun gnus-shutdown (symbol)
2303 "Shut down everything that waits for SYMBOL."
2304 (let ((alist gnus-shutdown-alist)
2306 (while (setq entry (pop alist))
2307 (when (memq symbol (cdr entry))
2308 (funcall (car entry))))))
2312 ;; Format specs. The chunks below are the machine-generated forms
2313 ;; that are to be evaled as the result of the default format strings.
2314 ;; We write them in here to get them byte-compiled. That way the
2315 ;; default actions will be quite fast, while still retaining the full
2316 ;; flexibility of the user-defined format specs.
2318 ;; First we have lots of dummy defvars to let the compiler know these
2319 ;; are really dynamic variables.
2321 (defvar gnus-tmp-unread)
2322 (defvar gnus-tmp-replied)
2323 (defvar gnus-tmp-score-char)
2324 (defvar gnus-tmp-indentation)
2325 (defvar gnus-tmp-opening-bracket)
2326 (defvar gnus-tmp-lines)
2327 (defvar gnus-tmp-name)
2328 (defvar gnus-tmp-closing-bracket)
2329 (defvar gnus-tmp-subject-or-nil)
2330 (defvar gnus-tmp-subject)
2331 (defvar gnus-tmp-marked)
2332 (defvar gnus-tmp-marked-mark)
2333 (defvar gnus-tmp-subscribed)
2334 (defvar gnus-tmp-process-marked)
2335 (defvar gnus-tmp-number-of-unread)
2336 (defvar gnus-tmp-group-name)
2337 (defvar gnus-tmp-group)
2338 (defvar gnus-tmp-article-number)
2339 (defvar gnus-tmp-unread-and-unselected)
2340 (defvar gnus-tmp-news-method)
2341 (defvar gnus-tmp-news-server)
2342 (defvar gnus-tmp-article-number)
2343 (defvar gnus-mouse-face)
2344 (defvar gnus-mouse-face-prop)
2346 (defun gnus-summary-line-format-spec ()
2347 (insert gnus-tmp-unread gnus-tmp-replied
2348 gnus-tmp-score-char gnus-tmp-indentation)
2353 gnus-tmp-opening-bracket
2354 (format "%4d: %-20s"
2356 (if (> (length gnus-tmp-name) 20)
2357 (substring gnus-tmp-name 0 20)
2359 gnus-tmp-closing-bracket)
2361 gnus-mouse-face-prop gnus-mouse-face)
2362 (insert " " gnus-tmp-subject-or-nil "\n"))
2364 (defvar gnus-summary-line-format-spec
2365 (gnus-byte-code 'gnus-summary-line-format-spec))
2367 (defun gnus-summary-dummy-line-format-spec ()
2374 gnus-mouse-face-prop gnus-mouse-face)
2375 (insert " " gnus-tmp-subject "\n"))
2377 (defvar gnus-summary-dummy-line-format-spec
2378 (gnus-byte-code 'gnus-summary-dummy-line-format-spec))
2380 (defun gnus-group-line-format-spec ()
2381 (insert gnus-tmp-marked-mark gnus-tmp-subscribed
2382 gnus-tmp-process-marked
2383 gnus-group-indentation
2384 (format "%5s: " gnus-tmp-number-of-unread))
2388 (insert gnus-tmp-group "\n")
2390 gnus-mouse-face-prop gnus-mouse-face))
2391 (defvar gnus-group-line-format-spec
2392 (gnus-byte-code 'gnus-group-line-format-spec))
2394 (defvar gnus-format-specs
2395 `((version . ,emacs-version)
2396 (group ,gnus-group-line-format ,gnus-group-line-format-spec)
2397 (summary-dummy ,gnus-summary-dummy-line-format
2398 ,gnus-summary-dummy-line-format-spec)
2399 (summary ,gnus-summary-line-format ,gnus-summary-line-format-spec)))
2401 (defvar gnus-article-mode-line-format-spec nil)
2402 (defvar gnus-summary-mode-line-format-spec nil)
2403 (defvar gnus-group-mode-line-format-spec nil)
2405 ;;; Phew. All that gruft is over, fortunately.
2409 ;;; Gnus Utility Functions
2412 (defun gnus-extract-address-components (from)
2414 ;; First find the address - the thing with the @ in it. This may
2415 ;; not be accurate in mail addresses, but does the trick most of
2416 ;; the time in news messages.
2417 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
2418 (setq address (substring from (match-beginning 0) (match-end 0))))
2419 ;; Then we check whether the "name <address>" format is used.
2421 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2422 ;; Linear white space is not required.
2423 (string-match (concat "[ \t]*<" (regexp-quote address) ">") from)
2424 (and (setq name (substring from 0 (match-beginning 0)))
2425 ;; Strip any quotes from the name.
2426 (string-match "\".*\"" name)
2427 (setq name (substring name 1 (1- (match-end 0))))))
2428 ;; If not, then "address (name)" is used.
2430 (and (string-match "(.+)" from)
2431 (setq name (substring from (1+ (match-beginning 0))
2432 (1- (match-end 0)))))
2433 (and (string-match "()" from)
2434 (setq name address))
2435 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>.
2436 ;; XOVER might not support folded From headers.
2437 (and (string-match "(.*" from)
2438 (setq name (substring from (1+ (match-beginning 0))
2440 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2441 (list (or name from) (or address from))))
2443 (defun gnus-fetch-field (field)
2444 "Return the value of the header FIELD of current article."
2447 (let ((case-fold-search t))
2448 (nnheader-narrow-to-headers)
2449 (mail-fetch-field field)))))
2451 (defun gnus-goto-colon ()
2453 (search-forward ":" (gnus-point-at-eol) t))
2456 (defun gnus-update-format (var)
2457 "Update the format specification near point."
2462 ;; Find the end of the current word.
2463 (re-search-forward "[ \t\n]" nil t)
2465 (when (re-search-backward "\\(gnus-[-a-z]+-line-format\\)" nil t)
2466 (match-string 1)))))
2467 (let* ((type (intern (progn (string-match "gnus-\\([-a-z]+\\)-line" var)
2468 (match-string 1 var))))
2469 (entry (assq type gnus-format-specs))
2472 (setq gnus-format-specs (delq entry gnus-format-specs)))
2474 (intern (format "%s-spec" var))
2475 (gnus-parse-format (setq value (symbol-value (intern var)))
2476 (symbol-value (intern (format "%s-alist" var)))
2477 (not (string-match "mode" var))))
2478 (setq spec (symbol-value (intern (format "%s-spec" var))))
2479 (push (list type value spec) gnus-format-specs)
2481 (pop-to-buffer "*Gnus Format*")
2483 (lisp-interaction-mode)
2484 (insert (pp-to-string spec))))
2486 (defun gnus-update-format-specifications (&optional force)
2487 "Update all (necessary) format specifications."
2488 ;; Make the indentation array.
2489 (gnus-make-thread-indent-array)
2491 ;; See whether all the stored info needs to be flushed.
2493 (not (equal emacs-version
2494 (cdr (assq 'version gnus-format-specs)))))
2495 (setq gnus-format-specs nil))
2497 ;; Go through all the formats and see whether they need updating.
2498 (let ((types '(summary summary-dummy group
2499 summary-mode group-mode article-mode))
2500 new-format entry type val)
2501 (while (setq type (pop types))
2502 ;; Jump to the proper buffer to find out the value of
2503 ;; the variable, if possible. (It may be buffer-local.)
2505 (let ((buffer (intern (format "gnus-%s-buffer" type)))
2507 (when (and (boundp buffer)
2508 (setq val (symbol-value buffer))
2510 (buffer-name (get-buffer val)))
2511 (set-buffer (get-buffer val)))
2512 (setq new-format (symbol-value
2513 (intern (format "gnus-%s-line-format" type))))))
2514 (setq entry (cdr (assq type gnus-format-specs)))
2516 (equal (car entry) new-format))
2517 ;; Use the old format.
2518 (set (intern (format "gnus-%s-line-format-spec" type))
2520 ;; This is a new format.
2522 (if (not (stringp new-format))
2523 ;; This is a function call or something.
2525 ;; This is a "real" format.
2529 (intern (format "gnus-%s-line-format-alist"
2530 (if (eq type 'article-mode)
2531 'summary-mode type))))
2532 (not (string-match "mode$" (symbol-name type))))))
2533 ;; Enter the new format spec into the list.
2536 (setcar (cdr entry) val)
2537 (setcar entry new-format))
2538 (push (list type new-format val) gnus-format-specs))
2539 (set (intern (format "gnus-%s-line-format-spec" type)) val))))
2541 (unless (assq 'version gnus-format-specs)
2542 (push (cons 'version emacs-version) gnus-format-specs))
2544 (gnus-update-group-mark-positions)
2545 (gnus-update-summary-mark-positions))
2547 (defun gnus-update-summary-mark-positions ()
2548 "Compute where the summary marks are to go."
2550 (let ((gnus-replied-mark 129)
2551 (gnus-score-below-mark 130)
2552 (gnus-score-over-mark 130)
2556 (gnus-set-work-buffer)
2557 (gnus-summary-insert-line
2558 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2559 (goto-char (point-min))
2560 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2562 (goto-char (point-min))
2563 (push (cons 'replied (and (search-forward "\201" nil t) (- (point) 2)))
2565 (goto-char (point-min))
2566 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2568 (setq gnus-summary-mark-positions pos))))
2570 (defun gnus-update-group-mark-positions ()
2572 (let ((gnus-process-mark 128)
2573 (gnus-group-marked '("dummy.group")))
2574 (gnus-set-active "dummy.group" '(0 . 0))
2575 (gnus-set-work-buffer)
2576 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
2577 (goto-char (point-min))
2578 (setq gnus-group-mark-positions
2579 (list (cons 'process (and (search-forward "\200" nil t)
2580 (- (point) 2))))))))
2582 (defvar gnus-mouse-face-0 'highlight)
2583 (defvar gnus-mouse-face-1 'highlight)
2584 (defvar gnus-mouse-face-2 'highlight)
2585 (defvar gnus-mouse-face-3 'highlight)
2586 (defvar gnus-mouse-face-4 'highlight)
2588 (defun gnus-mouse-face-function (form type)
2590 (point) (progn ,@form (point))
2591 gnus-mouse-face-prop
2594 `(quote ,(symbol-value (intern (format "gnus-mouse-face-%d" type)))))))
2596 (defvar gnus-face-0 'bold)
2597 (defvar gnus-face-1 'italic)
2598 (defvar gnus-face-2 'bold-italic)
2599 (defvar gnus-face-3 'bold)
2600 (defvar gnus-face-4 'bold)
2602 (defun gnus-face-face-function (form type)
2604 (point) (progn ,@form (point))
2605 'face ',(symbol-value (intern (format "gnus-face-%d" type)))))
2607 (defun gnus-max-width-function (el max-width)
2608 (or (numberp max-width) (signal 'wrong-type-argument '(numberp max-width)))
2610 `(if (> (length ,el) ,max-width)
2611 (substring ,el 0 ,max-width)
2613 `(let ((val (eval ,el)))
2615 (setq val (int-to-string val)))
2616 (if (> (length val) ,max-width)
2617 (substring val 0 ,max-width)
2620 (defun gnus-parse-format (format spec-alist &optional insert)
2621 ;; This function parses the FORMAT string with the help of the
2622 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
2623 ;; string. If the FORMAT string contains the specifiers %( and %)
2624 ;; the text between them will have the mouse-face text property.
2626 "\\`\\(.*\\)%[0-9]?[{(]\\(.*\\)%[0-9]?[})]\\(.*\n?\\)\\'"
2628 (gnus-parse-complex-format format spec-alist)
2629 ;; This is a simple format.
2630 (gnus-parse-simple-format format spec-alist insert)))
2632 (defun gnus-parse-complex-format (format spec-alist)
2634 (gnus-set-work-buffer)
2636 (goto-char (point-min))
2637 (while (re-search-forward "\"" nil t)
2638 (replace-match "\\\"" nil t))
2639 (goto-char (point-min))
2641 (while (re-search-forward "%\\([0-9]+\\)?\\([{}()]\\)" nil t)
2642 (let ((number (if (match-beginning 1)
2643 (match-string 1) "0"))
2644 (delim (aref (match-string 2) 0)))
2645 (if (or (= delim ?\() (= delim ?\{))
2646 (replace-match (concat "\"(" (if (= delim ?\() "mouse" "face")
2648 (replace-match "\")\""))))
2649 (goto-char (point-max))
2651 (goto-char (point-min))
2652 (let ((form (read (current-buffer))))
2653 (cons 'progn (gnus-complex-form-to-spec form spec-alist)))))
2655 (defun gnus-complex-form-to-spec (form spec-alist)
2660 (gnus-parse-simple-format sform spec-alist t)
2661 (funcall (intern (format "gnus-%s-face-function" (car sform)))
2662 (gnus-complex-form-to-spec (cddr sform) spec-alist)
2666 (defun gnus-parse-simple-format (format spec-alist &optional insert)
2667 ;; This function parses the FORMAT string with the help of the
2668 ;; SPEC-ALIST and returns a list that can be eval'ed to return a
2671 spec flist fstring newspec elem beg result dontinsert)
2673 (gnus-set-work-buffer)
2675 (goto-char (point-min))
2676 (while (re-search-forward "%[-0-9]*\\(,[0-9]+\\)?\\([^0-9]\\)\\(.\\)?"
2678 (if (= (setq spec (string-to-char (match-string 2))) ?%)
2680 beg (1+ (match-beginning 0)))
2681 ;; First check if there are any specs that look anything like
2682 ;; "%12,12A", ie. with a "max width specification". These have
2683 ;; to be treated specially.
2684 (if (setq beg (match-beginning 1))
2688 (1+ (match-beginning 1)) (match-end 1))))
2690 (setq beg (match-beginning 2)))
2691 ;; Find the specification from `spec-alist'.
2692 (unless (setq elem (cdr (assq spec spec-alist)))
2693 (setq elem '("*" ?s)))
2694 ;; Treat user defined format specifiers specially.
2695 (when (eq (car elem) 'gnus-tmp-user-defined)
2698 (list (intern (concat "gnus-user-format-function-"
2700 'gnus-tmp-header) ?s))
2701 (delete-region (match-beginning 3) (match-end 3)))
2702 (if (not (zerop max-width))
2703 (let ((el (car elem)))
2704 (cond ((= (cadr elem) ?c)
2705 (setq el (list 'char-to-string el)))
2707 (setq el (list 'int-to-string el))))
2708 (setq flist (cons (gnus-max-width-function el max-width)
2712 (setq flist (cons (car elem) flist))
2713 (setq newspec (cadr elem)))))
2714 ;; Remove the old specification (and possibly a ",12" string).
2715 (delete-region beg (match-end 2))
2716 ;; Insert the new specification.
2719 (setq fstring (buffer-substring 1 (point-max))))
2720 ;; Do some postprocessing to increase efficiency.
2725 ((string= fstring "")
2727 ;; Not a format string.
2728 ((not (string-match "%" fstring))
2730 ;; A format string with just a single string spec.
2731 ((string= fstring "%s")
2733 ;; A single character.
2734 ((string= fstring "%c")
2737 ((string= fstring "%d")
2740 (list `(princ ,(car flist)))
2741 (list `(int-to-string ,(car flist)))))
2742 ;; Just lots of chars and strings.
2743 ((string-match "\\`\\(%[cs]\\)+\\'" fstring)
2745 ;; A single string spec at the beginning of the spec.
2746 ((string-match "\\`%[sc][^%]+\\'" fstring)
2747 (list (car flist) (substring fstring 2)))
2748 ;; A single string spec in the middle of the spec.
2749 ((string-match "\\`\\([^%]+\\)%[sc]\\([^%]+\\)\\'" fstring)
2750 (list (match-string 1 fstring) (car flist) (match-string 2 fstring)))
2751 ;; A single string spec in the end of the spec.
2752 ((string-match "\\`\\([^%]+\\)%[sc]\\'" fstring)
2753 (list (match-string 1 fstring) (car flist)))
2754 ;; A more complex spec.
2756 (list (cons 'format (cons fstring (nreverse flist)))))))
2762 (cons 'insert result)))
2763 (cond ((stringp result)
2766 (cons 'concat result))
2769 (defun gnus-eval-format (format &optional alist props)
2770 "Eval the format variable FORMAT, using ALIST.
2771 If PROPS, insert the result."
2772 (let ((form (gnus-parse-format format alist props)))
2774 (add-text-properties (point) (progn (eval form) (point)) props)
2777 (defun gnus-remove-text-with-property (prop)
2778 "Delete all text in the current buffer with text property PROP."
2780 (goto-char (point-min))
2782 (while (get-text-property (point) prop)
2784 (goto-char (next-single-property-change (point) prop nil (point-max))))))
2786 (defun gnus-set-work-buffer ()
2787 (if (get-buffer gnus-work-buffer)
2789 (set-buffer gnus-work-buffer)
2791 (set-buffer (get-buffer-create gnus-work-buffer))
2792 (kill-all-local-variables)
2793 (buffer-disable-undo (current-buffer))
2794 (gnus-add-current-to-buffer-list)))
2796 ;; Article file names when saving.
2798 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2799 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2800 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
2801 Otherwise, it is like ~/News/news/group/num."
2804 (concat (if (gnus-use-long-file-name 'not-save)
2805 (gnus-capitalize-newsgroup newsgroup)
2806 (gnus-newsgroup-directory-form newsgroup))
2807 "/" (int-to-string (mail-header-number headers)))
2808 (or gnus-article-save-directory "~/News"))))
2810 (string-equal (file-name-directory default)
2811 (file-name-directory last-file))
2812 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2814 (or last-file default))))
2816 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2817 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2818 If variable `gnus-use-long-file-name' is non-nil, it is
2819 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2822 (concat (if (gnus-use-long-file-name 'not-save)
2824 (gnus-newsgroup-directory-form newsgroup))
2825 "/" (int-to-string (mail-header-number headers)))
2826 (or gnus-article-save-directory "~/News"))))
2828 (string-equal (file-name-directory default)
2829 (file-name-directory last-file))
2830 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2832 (or last-file default))))
2834 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2835 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2836 If variable `gnus-use-long-file-name' is non-nil, it is
2837 ~/News/News.group. Otherwise, it is like ~/News/news/group/news."
2840 (if (gnus-use-long-file-name 'not-save)
2841 (gnus-capitalize-newsgroup newsgroup)
2842 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2843 (or gnus-article-save-directory "~/News"))))
2845 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2846 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2847 If variable `gnus-use-long-file-name' is non-nil, it is
2848 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2851 (if (gnus-use-long-file-name 'not-save)
2853 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2854 (or gnus-article-save-directory "~/News"))))
2856 ;; For subscribing new newsgroup
2858 (defun gnus-subscribe-hierarchical-interactive (groups)
2859 (let ((groups (sort groups 'string<))
2860 prefixes prefix start ans group starts)
2862 (setq prefixes (list "^"))
2863 (while (and groups prefixes)
2864 (while (not (string-match (car prefixes) (car groups)))
2865 (setq prefixes (cdr prefixes)))
2866 (setq prefix (car prefixes))
2867 (setq start (1- (length prefix)))
2868 (if (and (string-match "[^\\.]\\." (car groups) start)
2871 (concat "^" (substring (car groups) 0 (match-end 0))))
2872 (string-match prefix (cadr groups)))
2874 (setq prefixes (cons prefix prefixes))
2875 (message "Descend hierarchy %s? ([y]nsq): "
2876 (substring prefix 1 (1- (length prefix))))
2877 (setq ans (read-char))
2880 (string-match prefix
2881 (setq group (car groups))))
2882 (setq gnus-killed-list
2883 (cons group gnus-killed-list))
2884 (gnus-sethash group group gnus-killed-hashtb)
2885 (setq groups (cdr groups)))
2886 (setq starts (cdr starts)))
2889 (string-match prefix
2890 (setq group (car groups))))
2891 (gnus-sethash group group gnus-killed-hashtb)
2892 (gnus-subscribe-alphabetically (car groups))
2893 (setq groups (cdr groups)))
2894 (setq starts (cdr starts)))
2897 (setq group (car groups))
2898 (setq gnus-killed-list (cons group gnus-killed-list))
2899 (gnus-sethash group group gnus-killed-hashtb)
2900 (setq groups (cdr groups))))
2902 (message "Subscribe %s? ([n]yq)" (car groups))
2903 (setq ans (read-char))
2904 (setq group (car groups))
2906 (gnus-subscribe-alphabetically (car groups))
2907 (gnus-sethash group group gnus-killed-hashtb))
2910 (setq group (car groups))
2911 (setq gnus-killed-list (cons group gnus-killed-list))
2912 (gnus-sethash group group gnus-killed-hashtb)
2913 (setq groups (cdr groups))))
2915 (setq gnus-killed-list (cons group gnus-killed-list))
2916 (gnus-sethash group group gnus-killed-hashtb)))
2917 (setq groups (cdr groups)))))))
2919 (defun gnus-subscribe-randomly (newsgroup)
2920 "Subscribe new NEWSGROUP by making it the first newsgroup."
2921 (gnus-subscribe-newsgroup newsgroup))
2923 (defun gnus-subscribe-alphabetically (newgroup)
2924 "Subscribe new NEWSGROUP and insert it in alphabetical order."
2925 (let ((groups (cdr gnus-newsrc-alist))
2927 (while (and (not before) groups)
2928 (if (string< newgroup (caar groups))
2929 (setq before (caar groups))
2930 (setq groups (cdr groups))))
2931 (gnus-subscribe-newsgroup newgroup before)))
2933 (defun gnus-subscribe-hierarchically (newgroup)
2934 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
2935 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2937 (set-buffer (find-file-noselect gnus-current-startup-file))
2938 (let ((groupkey newgroup)
2940 (while (and (not before) groupkey)
2941 (goto-char (point-min))
2943 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
2944 (while (and (re-search-forward groupkey-re nil t)
2946 (setq before (match-string 1))
2947 (string< before newgroup)))))
2948 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
2950 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
2951 (substring groupkey (match-beginning 1) (match-end 1)))))
2952 (gnus-subscribe-newsgroup newgroup before))))
2954 (defun gnus-subscribe-interactively (group)
2955 "Subscribe the new GROUP interactively.
2956 It is inserted in hierarchical newsgroup order if subscribed. If not,
2958 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " group))
2959 (gnus-subscribe-hierarchically group)
2960 (push group gnus-killed-list)))
2962 (defun gnus-subscribe-zombies (group)
2963 "Make the new GROUP into a zombie group."
2964 (push group gnus-zombie-list))
2966 (defun gnus-subscribe-killed (group)
2967 "Make the new GROUP a killed group."
2968 (push group gnus-killed-list))
2970 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
2971 "Subscribe new NEWSGROUP.
2972 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
2973 the first newsgroup."
2974 ;; We subscribe the group by changing its level to `subscribed'.
2975 (gnus-group-change-level
2976 newsgroup gnus-level-default-subscribed
2977 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
2978 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))
2982 (defun gnus-newsgroup-directory-form (newsgroup)
2983 "Make hierarchical directory name from NEWSGROUP name."
2984 (let ((newsgroup (gnus-newsgroup-savable-name newsgroup))
2985 (len (length newsgroup))
2987 ;; If this is a foreign group, we don't want to translate the
2989 (if (setq idx (string-match ":" newsgroup))
2990 (aset newsgroup idx ?/)
2992 ;; Replace all occurrences of `.' with `/'.
2994 (if (= (aref newsgroup idx) ?.)
2995 (aset newsgroup idx ?/))
2996 (setq idx (1+ idx)))
2999 (defun gnus-newsgroup-savable-name (group)
3000 ;; Replace any slashes in a group name (eg. an ange-ftp nndoc group)
3002 (nnheader-replace-chars-in-string group ?/ ?.))
3004 (defun gnus-make-directory (dir)
3005 "Make DIRECTORY recursively."
3006 ;; Why don't we use `(make-directory dir 'parents)'? That's just one
3007 ;; of the many mysteries of the universe.
3008 (let* ((dir (expand-file-name dir default-directory))
3010 (if (string-match "/$" dir)
3011 (setq dir (substring dir 0 (match-beginning 0))))
3012 ;; First go down the path until we find a directory that exists.
3013 (while (not (file-exists-p dir))
3014 (setq dirs (cons dir dirs))
3015 (string-match "/[^/]+$" dir)
3016 (setq dir (substring dir 0 (match-beginning 0))))
3017 ;; Then create all the subdirs.
3018 (while (and dirs (not err))
3020 (make-directory (car dirs))
3021 (error (setq err t)))
3022 (setq dirs (cdr dirs)))
3023 ;; We return whether we were successful or not.
3026 (defun gnus-capitalize-newsgroup (newsgroup)
3027 "Capitalize NEWSGROUP name."
3028 (and (not (zerop (length newsgroup)))
3029 (concat (char-to-string (upcase (aref newsgroup 0)))
3030 (substring newsgroup 1))))
3032 ;; Various... things.
3034 (defun gnus-simplify-subject (subject &optional re-only)
3035 "Remove `Re:' and words in parentheses.
3036 If RE-ONLY is non-nil, strip leading `Re:'s only."
3037 (let ((case-fold-search t)) ;Ignore case.
3038 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
3039 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
3040 (setq subject (substring subject (match-end 0))))
3041 ;; Remove uninteresting prefixes.
3042 (if (and (not re-only)
3043 gnus-simplify-ignored-prefixes
3044 (string-match gnus-simplify-ignored-prefixes subject))
3045 (setq subject (substring subject (match-end 0))))
3046 ;; Remove words in parentheses from end.
3048 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
3049 (setq subject (substring subject 0 (match-beginning 0)))))
3050 ;; Return subject string.
3053 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
3055 ;; Written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
3056 (defun gnus-simplify-buffer-fuzzy ()
3057 (goto-char (point-min))
3058 (while (search-forward "\t" nil t)
3059 (replace-match " " t t))
3060 (goto-char (point-min))
3061 (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *" nil t)
3062 (goto-char (match-beginning 0))
3064 (looking-at "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
3065 (looking-at "^[[].*: .*[]]$"))
3066 (goto-char (point-min))
3067 (while (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *"
3069 (replace-match "" t t))
3070 (goto-char (point-min))
3071 (while (re-search-forward "^[[].*: .*[]]$" nil t)
3072 (goto-char (match-end 0))
3075 (progn (goto-char (match-beginning 0)))
3076 (re-search-forward ":"))))
3077 (goto-char (point-min))
3078 (while (re-search-forward " *[[{(][^()\n]*[]})] *$" nil t)
3079 (replace-match "" t t))
3080 (goto-char (point-min))
3081 (while (re-search-forward " +" nil t)
3082 (replace-match " " t t))
3083 (goto-char (point-min))
3084 (while (re-search-forward " $" nil t)
3085 (replace-match "" t t))
3086 (goto-char (point-min))
3087 (while (re-search-forward "^ +" nil t)
3088 (replace-match "" t t))
3089 (goto-char (point-min))
3090 (when gnus-simplify-subject-fuzzy-regexp
3091 (if (listp gnus-simplify-subject-fuzzy-regexp)
3092 (let ((list gnus-simplify-subject-fuzzy-regexp))
3094 (goto-char (point-min))
3095 (while (re-search-forward (car list) nil t)
3096 (replace-match "" t t))
3097 (setq list (cdr list))))
3098 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
3099 (replace-match "" t t)))))
3101 (defun gnus-simplify-subject-fuzzy (subject)
3102 "Siplify a subject string fuzzily."
3104 (gnus-set-work-buffer)
3105 (let ((case-fold-search t))
3107 (inline (gnus-simplify-buffer-fuzzy))
3110 ;; Add the current buffer to the list of buffers to be killed on exit.
3111 (defun gnus-add-current-to-buffer-list ()
3112 (or (memq (current-buffer) gnus-buffer-list)
3113 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list))))
3115 (defun gnus-string> (s1 s2)
3116 (not (or (string< s1 s2)
3119 ;;; General various misc type functions.
3121 (defun gnus-clear-system ()
3122 "Clear all variables and buffers."
3123 ;; Clear Gnus variables.
3124 (let ((variables gnus-variable-list))
3126 (set (car variables) nil)
3127 (setq variables (cdr variables))))
3128 ;; Clear other internal variables.
3129 (setq gnus-list-of-killed-groups nil
3130 gnus-have-read-active-file nil
3131 gnus-newsrc-alist nil
3132 gnus-newsrc-hashtb nil
3133 gnus-killed-list nil
3134 gnus-zombie-list nil
3135 gnus-killed-hashtb nil
3136 gnus-active-hashtb nil
3137 gnus-moderated-list nil
3138 gnus-description-hashtb nil
3139 gnus-current-headers nil
3140 gnus-thread-indent-array nil
3141 gnus-newsgroup-headers nil
3142 gnus-newsgroup-name nil
3143 gnus-server-alist nil
3144 gnus-group-list-mode nil
3145 gnus-opened-servers nil
3146 gnus-current-select-method nil)
3147 (gnus-shutdown 'gnus)
3148 ;; Kill the startup file.
3149 (and gnus-current-startup-file
3150 (get-file-buffer gnus-current-startup-file)
3151 (kill-buffer (get-file-buffer gnus-current-startup-file)))
3152 ;; Clear the dribble buffer.
3153 (gnus-dribble-clear)
3154 ;; Kill global KILL file buffer.
3155 (when (get-file-buffer (gnus-newsgroup-kill-file nil))
3156 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
3157 (gnus-kill-buffer nntp-server-buffer)
3158 ;; Kill Gnus buffers.
3159 (while gnus-buffer-list
3160 (gnus-kill-buffer (pop gnus-buffer-list)))
3161 ;; Remove Gnus frames.
3162 (while gnus-created-frames
3163 (when (frame-live-p (car gnus-created-frames))
3164 ;; We slap a condition-case around this `delete-frame' to ensure
3165 ;; agains errors if we try do delete the single frame that's left.
3167 (delete-frame (car gnus-created-frames))
3169 (pop gnus-created-frames)))
3171 (defun gnus-windows-old-to-new (setting)
3172 ;; First we take care of the really, really old Gnus 3 actions.
3173 (when (symbolp setting)
3175 ;; Take care of ooold GNUS 3.x values.
3176 (cond ((eq setting 'SelectArticle) 'article)
3177 ((memq setting '(SelectSubject ExpandSubject)) 'summary)
3178 ((memq setting '(SelectNewsgroup ExitNewsgroup)) 'group)
3180 (if (or (listp setting)
3181 (not (and gnus-window-configuration
3182 (memq setting '(group summary article)))))
3184 (let* ((setting (if (eq setting 'group)
3185 (if (assq 'newsgroup gnus-window-configuration)
3187 'newsgroups) setting))
3188 (elem (cadr (assq setting gnus-window-configuration)))
3189 (total (apply '+ elem))
3190 (types '(group summary article))
3191 (pbuf (if (eq setting 'newsgroups) 'group 'summary))
3196 (or (not (numberp (nth i elem)))
3197 (zerop (nth i elem))
3199 (setq perc (/ (float (nth 0 elem)) total))
3200 (setq out (cons (if (eq pbuf (nth i types))
3201 (vector (nth i types) perc 'point)
3202 (vector (nth i types) perc))
3205 (list (nreverse out)))))
3208 (defun gnus-add-configuration (conf)
3209 "Add the window configuration CONF to `gnus-buffer-configuration'."
3210 (setq gnus-buffer-configuration
3211 (cons conf (delq (assq (car conf) gnus-buffer-configuration)
3212 gnus-buffer-configuration))))
3214 (defvar gnus-frame-list nil)
3216 (defun gnus-configure-frame (split &optional window)
3217 "Split WINDOW according to SPLIT."
3219 (setq window (get-buffer-window (current-buffer))))
3220 (select-window window)
3221 ;; This might be an old-stylee buffer config.
3222 (when (vectorp split)
3223 (setq split (append split nil)))
3224 (when (or (consp (car split))
3225 (vectorp (car split)))
3227 (push 'vertical split))
3228 ;; The SPLIT might be something that is to be evaled to
3229 ;; return a new SPLIT.
3230 (while (and (not (assq (car split) gnus-window-to-buffer))
3231 (gnus-functionp (car split)))
3232 (setq split (eval split)))
3233 (let* ((type (car split))
3235 (len (if (eq type 'horizontal) (window-width) (window-height)))
3237 (window-min-width (or gnus-window-min-width window-min-width))
3238 (window-min-height (or gnus-window-min-height window-min-height))
3239 s result new-win rest comp-subs size sub)
3241 ;; Nothing to do here.
3243 ;; Don't switch buffers.
3245 (and (memq 'point split) window))
3246 ;; This is a buffer to be selected.
3247 ((not (memq type '(frame horizontal vertical)))
3248 (let ((buffer (cond ((stringp type) type)
3249 (t (cdr (assq type gnus-window-to-buffer)))))
3252 (error "Illegal buffer type: %s" type))
3253 (unless (setq buf (get-buffer (if (symbolp buffer)
3254 (symbol-value buffer) buffer)))
3255 (setq buf (get-buffer-create (if (symbolp buffer)
3256 (symbol-value buffer) buffer))))
3257 (switch-to-buffer buf)
3258 ;; We return the window if it has the `point' spec.
3259 (and (memq 'point split) window)))
3260 ;; This is a frame split.
3262 (unless gnus-frame-list
3263 (setq gnus-frame-list (list (window-frame
3264 (get-buffer-window (current-buffer))))))
3266 params frame fresult)
3267 (while (< i (length subs))
3268 ;; Frame parameter is gotten from the sub-split.
3269 (setq params (cadr (elt subs i)))
3270 ;; It should be a list.
3271 (unless (listp params)
3273 ;; Create a new frame?
3274 (unless (setq frame (elt gnus-frame-list i))
3275 (nconc gnus-frame-list (list (setq frame (make-frame params))))
3276 (push frame gnus-created-frames))
3277 ;; Is the old frame still alive?
3278 (unless (frame-live-p frame)
3279 (setcar (nthcdr i gnus-frame-list)
3280 (setq frame (make-frame params))))
3281 ;; Select the frame in question and do more splits there.
3282 (select-frame frame)
3283 (setq fresult (or (gnus-configure-frame (elt subs i)) fresult))
3285 ;; Select the frame that has the selected buffer.
3287 (select-frame (window-frame fresult)))))
3288 ;; This is a normal split.
3290 (when (> (length subs) 0)
3291 ;; First we have to compute the sizes of all new windows.
3293 (setq sub (append (pop subs) nil))
3294 (while (and (not (assq (car sub) gnus-window-to-buffer))
3295 (gnus-functionp (car sub)))
3296 (setq sub (eval sub)))
3298 (push sub comp-subs)
3299 (setq size (cadar comp-subs))
3300 (cond ((equal size 1.0)
3301 (setq rest (car comp-subs))
3304 (setq s (floor (* size len))))
3308 (error "Illegal size: %s" size)))
3309 ;; Try to make sure that we are inside the safe limits.
3311 ((eq type 'horizontal)
3312 (setq s (max s window-min-width)))
3313 ((eq type 'vertical)
3314 (setq s (max s window-min-height))))
3315 (setcar (cdar comp-subs) s)
3317 ;; Take care of the "1.0" spec.
3319 (setcar (cdr rest) (- len total))
3320 (error "No 1.0 specs in %s" split))
3321 ;; The we do the actual splitting in a nice recursive
3323 (setq comp-subs (nreverse comp-subs))
3325 (if (null (cdr comp-subs))
3326 (setq new-win window)
3328 (split-window window (cadar comp-subs)
3329 (eq type 'horizontal))))
3330 (setq result (or (gnus-configure-frame
3331 (car comp-subs) window) result))
3332 (select-window new-win)
3333 (setq window new-win)
3334 (setq comp-subs (cdr comp-subs))))
3335 ;; Return the proper window, if any.
3337 (select-window result))))))
3339 (defvar gnus-frame-split-p nil)
3341 (defun gnus-configure-windows (setting &optional force)
3342 (setq setting (gnus-windows-old-to-new setting))
3343 (let ((split (if (symbolp setting)
3344 (cadr (assq setting gnus-buffer-configuration))
3348 (setq gnus-frame-split-p nil)
3351 (error "No such setting: %s" setting))
3353 (if (and (setq all-visible (gnus-all-windows-visible-p split))
3355 ;; All the windows mentioned are already visible, so we just
3356 ;; put point in the assigned buffer, and do not touch the
3358 (select-window all-visible)
3360 ;; Either remove all windows or just remove all Gnus windows.
3361 (let ((frame (selected-frame)))
3363 (if gnus-use-full-window
3364 ;; We want to remove all other windows.
3365 (if (not gnus-frame-split-p)
3366 ;; This is not a `frame' split, so we ignore the
3368 (delete-other-windows)
3369 ;; This is a `frame' split, so we delete all windows
3373 (unless (eq (cdr (assq 'minibuffer
3374 (frame-parameters frame)))
3376 (select-frame frame)
3377 (delete-other-windows)))
3379 ;; Just remove some windows.
3380 (gnus-remove-some-windows)
3381 (switch-to-buffer nntp-server-buffer))
3382 (select-frame frame)))
3384 (switch-to-buffer nntp-server-buffer)
3385 (gnus-configure-frame split (get-buffer-window (current-buffer))))))
3387 (defun gnus-all-windows-visible-p (split)
3388 "Say whether all buffers in SPLIT are currently visible.
3389 In particular, the value returned will be the window that
3391 (let ((stack (list split))
3393 type buffer win buf)
3394 (while (and (setq split (pop stack))
3396 ;; Be backwards compatible.
3397 (when (vectorp split)
3398 (setq split (append split nil)))
3399 (when (or (consp (car split))
3400 (vectorp (car split)))
3402 (push 'vertical split))
3403 ;; The SPLIT might be something that is to be evaled to
3404 ;; return a new SPLIT.
3405 (while (and (not (assq (car split) gnus-window-to-buffer))
3406 (gnus-functionp (car split)))
3407 (setq split (eval split)))
3409 (setq type (elt split 0))
3414 ((not (memq type '(horizontal vertical frame)))
3415 (setq buffer (cond ((stringp type) type)
3416 (t (cdr (assq type gnus-window-to-buffer)))))
3418 (error "Illegal buffer type: %s" type))
3419 (when (setq buf (get-buffer (if (symbolp buffer)
3420 (symbol-value buffer)
3422 (setq win (get-buffer-window buf t)))
3424 (when (memq 'point split)
3425 (setq all-visible win))
3426 (setq all-visible nil)))
3428 (when (eq type 'frame)
3429 (setq gnus-frame-split-p t))
3430 (setq stack (append (cddr split) stack)))))
3431 (unless (eq all-visible t)
3434 (defun gnus-window-top-edge (&optional window)
3435 (nth 1 (window-edges window)))
3437 (defun gnus-remove-some-windows ()
3438 (let ((buffers gnus-window-to-buffer)
3439 buf bufs lowest-buf lowest)
3441 ;; Remove windows on all known Gnus buffers.
3443 (setq buf (cdar buffers))
3445 (setq buf (and (boundp buf) (symbol-value buf))))
3447 (get-buffer-window buf)
3449 (setq bufs (cons buf bufs))
3451 (if (or (not lowest)
3452 (< (gnus-window-top-edge) lowest))
3454 (setq lowest (gnus-window-top-edge))
3455 (setq lowest-buf buf)))))
3456 (setq buffers (cdr buffers)))
3457 ;; Remove windows on *all* summary buffers.
3460 (let ((buf (window-buffer win)))
3461 (if (string-match "^\\*Summary" (buffer-name buf))
3463 (setq bufs (cons buf bufs))
3465 (if (or (not lowest)
3466 (< (gnus-window-top-edge) lowest))
3468 (setq lowest-buf buf)
3469 (setq lowest (gnus-window-top-edge)))))))))
3472 (pop-to-buffer lowest-buf)
3473 (switch-to-buffer nntp-server-buffer)))
3475 (and (not (eq (car bufs) lowest-buf))
3476 (delete-windows-on (car bufs)))
3477 (setq bufs (cdr bufs))))))
3479 (defun gnus-version ()
3480 "Version numbers of this version of Gnus."
3482 (let ((methods gnus-valid-select-methods)
3485 ;; Go through all the legal select methods and add their version
3486 ;; numbers to the total version string. Only the backends that are
3487 ;; currently in use will have their message numbers taken into
3490 (setq meth (intern (concat (caar methods) "-version")))
3492 (stringp (symbol-value meth))
3493 (setq mess (concat mess "; " (symbol-value meth))))
3494 (setq methods (cdr methods)))
3495 (gnus-message 2 mess)))
3497 (defun gnus-info-find-node ()
3498 "Find Info documentation of Gnus."
3500 ;; Enlarge info window if needed.
3501 (let ((mode major-mode)
3503 (Info-goto-node (cadr (assq mode gnus-info-nodes)))
3504 (setq gnus-info-buffer (current-buffer))
3505 (gnus-configure-windows 'info)))
3507 (defun gnus-days-between (date1 date2)
3508 ;; Return the number of days between date1 and date2.
3509 (- (gnus-day-number date1) (gnus-day-number date2)))
3511 (defun gnus-day-number (date)
3512 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
3513 (timezone-parse-date date))))
3514 (timezone-absolute-from-gregorian
3515 (nth 1 dat) (nth 2 dat) (car dat))))
3517 (defun gnus-encode-date (date)
3518 "Convert DATE to internal time."
3519 (let* ((parse (timezone-parse-date date))
3520 (date (mapcar (lambda (d) (and d (string-to-int d))) parse))
3521 (time (mapcar 'string-to-int (timezone-parse-time (aref parse 3)))))
3522 (encode-time (caddr time) (cadr time) (car time)
3523 (caddr date) (cadr date) (car date) (nth 4 date))))
3525 (defun gnus-time-minus (t1 t2)
3526 "Subtract two internal times."
3527 (let ((borrow (< (cadr t1) (cadr t2))))
3528 (list (- (car t1) (car t2) (if borrow 1 0))
3529 (- (+ (if borrow 65536 0) (cadr t1)) (cadr t2)))))
3531 (defun gnus-file-newer-than (file date)
3532 (let ((fdate (nth 5 (file-attributes file))))
3533 (or (> (car fdate) (car date))
3534 (and (= (car fdate) (car date))
3535 (> (nth 1 fdate) (nth 1 date))))))
3537 (defmacro gnus-local-set-keys (&rest plist)
3538 "Set the keys in PLIST in the current keymap."
3539 `(gnus-define-keys-1 (current-local-map) ',plist))
3541 (defmacro gnus-define-keys (keymap &rest plist)
3542 "Define all keys in PLIST in KEYMAP."
3543 `(gnus-define-keys-1 (quote ,keymap) (quote ,plist)))
3545 (put 'gnus-define-keys 'lisp-indent-function 1)
3546 (put 'gnus-define-keys 'lisp-indent-hook 1)
3547 (put 'gnus-define-keymap 'lisp-indent-function 1)
3548 (put 'gnus-define-keymap 'lisp-indent-hook 1)
3550 (defmacro gnus-define-keymap (keymap &rest plist)
3551 "Define all keys in PLIST in KEYMAP."
3552 `(gnus-define-keys-1 ,keymap (quote ,plist)))
3554 (defun gnus-define-keys-1 (keymap plist)
3556 (error "Can't set keys in a null keymap"))
3557 (cond ((symbolp keymap)
3558 (setq keymap (symbol-value keymap)))
3561 (set (car keymap) nil)
3562 (define-prefix-command (car keymap))
3563 (define-key (symbol-value (caddr keymap)) (cadr keymap) (car keymap))
3564 (setq keymap (symbol-value (car keymap)))))
3567 (when (symbolp (setq key (pop plist)))
3568 (setq key (symbol-value key)))
3569 (define-key keymap key (pop plist)))))
3571 (defun gnus-group-read-only-p (&optional group)
3572 "Check whether GROUP supports editing or not.
3573 If GROUP is nil, `gnus-newsgroup-name' will be checked instead. Note
3574 that that variable is buffer-local to the summary buffers."
3575 (let ((group (or group gnus-newsgroup-name)))
3576 (not (gnus-check-backend-function 'request-replace-article group))))
3578 (defun gnus-group-total-expirable-p (group)
3579 "Check whether GROUP is total-expirable or not."
3580 (let ((params (gnus-info-params (gnus-get-info group))))
3581 (or (memq 'total-expire params)
3582 (cdr (assq 'total-expire params)) ; (total-expire . t)
3583 (and gnus-total-expirable-newsgroups ; Check var.
3584 (string-match gnus-total-expirable-newsgroups group)))))
3586 (defun gnus-group-auto-expirable-p (group)
3587 "Check whether GROUP is total-expirable or not."
3588 (let ((params (gnus-info-params (gnus-get-info group))))
3589 (or (memq 'auto-expire params)
3590 (cdr (assq 'auto-expire params)) ; (auto-expire . t)
3591 (and gnus-auto-expirable-newsgroups ; Check var.
3592 (string-match gnus-auto-expirable-newsgroups group)))))
3594 (defun gnus-virtual-group-p (group)
3595 "Say whether GROUP is virtual or not."
3596 (memq 'virtual (assoc (symbol-name (car (gnus-find-method-for-group group)))
3597 gnus-valid-select-methods)))
3599 (defsubst gnus-simplify-subject-fully (subject)
3600 "Simplify a subject string according to the user's wishes."
3602 ((null gnus-summary-gather-subject-limit)
3603 (gnus-simplify-subject-re subject))
3604 ((eq gnus-summary-gather-subject-limit 'fuzzy)
3605 (gnus-simplify-subject-fuzzy subject))
3606 ((numberp gnus-summary-gather-subject-limit)
3607 (gnus-limit-string (gnus-simplify-subject-re subject)
3608 gnus-summary-gather-subject-limit))
3612 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
3613 "Check whether two subjects are equal. If optional argument
3614 simple-first is t, first argument is already simplified."
3616 ((null simple-first)
3617 (equal (gnus-simplify-subject-fully s1)
3618 (gnus-simplify-subject-fully s2)))
3621 (gnus-simplify-subject-fully s2)))))
3623 ;; Returns a list of writable groups.
3624 (defun gnus-writable-groups ()
3625 (let ((alist gnus-newsrc-alist)
3627 (while (setq group (car (pop alist)))
3628 (unless (gnus-group-read-only-p group)
3629 (push group groups)))
3632 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
3634 (defun gnus-y-or-n-p (prompt)
3639 (defun gnus-yes-or-no-p (prompt)
3641 (yes-or-no-p prompt)
3644 ;; Check whether to use long file names.
3645 (defun gnus-use-long-file-name (symbol)
3646 ;; The variable has to be set...
3647 (and gnus-use-long-file-name
3648 ;; If it isn't a list, then we return t.
3649 (or (not (listp gnus-use-long-file-name))
3650 ;; If it is a list, and the list contains `symbol', we
3652 (not (memq symbol gnus-use-long-file-name)))))
3654 ;; I suspect there's a better way, but I haven't taken the time to do
3655 ;; it yet. -erik selberg@cs.washington.edu
3656 (defun gnus-dd-mmm (messy-date)
3657 "Return a string like DD-MMM from a big messy string"
3658 (let ((datevec (timezone-parse-date messy-date)))
3661 ;; Make sure leading zeroes are stripped.
3662 (number-to-string (string-to-number (aref datevec 2)))
3666 (nth (1- (string-to-number (aref datevec 1)))
3667 timezone-months-assoc))
3670 ;; Make a hash table (default and minimum size is 255).
3671 ;; Optional argument HASHSIZE specifies the table size.
3672 (defun gnus-make-hashtable (&optional hashsize)
3673 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0))
3675 ;; Make a number that is suitable for hashing; bigger than MIN and one
3677 (defun gnus-create-hash-size (min)
3683 ;; Show message if message has a lower level than `gnus-verbose'.
3684 ;; Guideline for numbers:
3685 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages
3686 ;; for things that take a long time, 7 - not very important messages
3687 ;; on stuff, 9 - messages inside loops.
3688 (defun gnus-message (level &rest args)
3689 (if (<= level gnus-verbose)
3690 (apply 'message args)
3691 ;; We have to do this format thingy here even if the result isn't
3692 ;; shown - the return value has to be the same as the return value
3694 (apply 'format args)))
3696 ;; Generate a unique new group name.
3697 (defun gnus-generate-new-group-name (leaf)
3700 (while (gnus-gethash name gnus-newsrc-hashtb)
3701 (setq name (concat leaf "<" (int-to-string (setq num (1+ num))) ">")))
3704 (defsubst gnus-hide-text (b e props)
3705 "Set text PROPS on the B to E region, extending `intangble' 1 past B."
3706 (add-text-properties b e props)
3707 (when (memq 'intangible props)
3708 (put-text-property (max (1- b) (point-min))
3709 b 'intangible (cddr (memq 'intangible props)))))
3711 (defsubst gnus-unhide-text (b e)
3712 "Remove hidden text properties from region between B and E."
3713 (remove-text-properties b e gnus-hidden-properties)
3714 (when (memq 'intangible gnus-hidden-properties)
3715 (put-text-property (max (1- b) (point-min))
3716 b 'intangible nil)))
3718 (defun gnus-hide-text-type (b e type)
3719 "Hide text of TYPE between B and E."
3720 (gnus-hide-text b e (cons 'gnus-type (cons type gnus-hidden-properties))))
3722 ;; Find out whether the gnus-visual TYPE is wanted.
3723 (defun gnus-visual-p (&optional type class)
3724 (and gnus-visual ; Has to be non-nil, at least.
3725 (if (not type) ; We don't care about type.
3727 (if (listp gnus-visual) ; It's a list, so we check it.
3728 (or (memq type gnus-visual)
3729 (memq class gnus-visual))
3732 (defun gnus-parent-id (references)
3733 "Return the last Message-ID in REFERENCES."
3734 (when (and references
3735 (string-match "\\(<[^<>]+>\\)[ \t\n]*\\'" references))
3736 (substring references (match-beginning 1) (match-end 1))))
3738 (defun gnus-split-references (references)
3739 "Return a list of Message-IDs in REFERENCES."
3742 (while (string-match "<[^>]+>" references beg)
3743 (push (substring references (match-beginning 0) (setq beg (match-end 0)))
3747 (defun gnus-buffer-live-p (buffer)
3748 "Say whether BUFFER is alive or not."
3751 (buffer-name (get-buffer buffer))))
3753 (defun gnus-ephemeral-group-p (group)
3754 "Say whether GROUP is ephemeral or not."
3755 (gnus-group-get-parameter group 'quit-config))
3757 (defun gnus-group-quit-config (group)
3758 "Return the quit-config of GROUP."
3759 (gnus-group-get-parameter group 'quit-config))
3761 (defun gnus-simplify-mode-line ()
3762 "Make mode lines a bit simpler."
3763 (setq mode-line-modified "-- ")
3764 (when (listp mode-line-format)
3765 (make-local-variable 'mode-line-format)
3766 (setq mode-line-format (copy-sequence mode-line-format))
3767 (when (equal (nth 3 mode-line-format) " ")
3768 (setcar (nthcdr 3 mode-line-format) " "))))
3770 ;;; List and range functions
3772 (defun gnus-last-element (list)
3773 "Return last element of LIST."
3775 (setq list (cdr list)))
3778 (defun gnus-copy-sequence (list)
3779 "Do a complete, total copy of a list."
3780 (if (and (consp list) (not (consp (cdr list))))
3781 (cons (car list) (cdr list))
3782 (mapcar (lambda (elem) (if (consp elem)
3783 (if (consp (cdr elem))
3784 (gnus-copy-sequence elem)
3785 (cons (car elem) (cdr elem)))
3789 (defun gnus-set-difference (list1 list2)
3790 "Return a list of elements of LIST1 that do not appear in LIST2."
3791 (let ((list1 (copy-sequence list1)))
3793 (setq list1 (delq (car list2) list1))
3794 (setq list2 (cdr list2)))
3797 (defun gnus-sorted-complement (list1 list2)
3798 "Return a list of elements of LIST1 that do not appear in LIST2.
3799 Both lists have to be sorted over <."
3801 (if (or (null list1) (null list2))
3803 (while (and list1 list2)
3804 (cond ((= (car list1) (car list2))
3805 (setq list1 (cdr list1)
3807 ((< (car list1) (car list2))
3808 (setq out (cons (car list1) out))
3809 (setq list1 (cdr list1)))
3811 (setq out (cons (car list2) out))
3812 (setq list2 (cdr list2)))))
3813 (nconc (nreverse out) (or list1 list2)))))
3815 (defun gnus-intersection (list1 list2)
3818 (if (memq (car list2) list1)
3819 (setq result (cons (car list2) result)))
3820 (setq list2 (cdr list2)))
3823 (defun gnus-sorted-intersection (list1 list2)
3824 ;; LIST1 and LIST2 have to be sorted over <.
3826 (while (and list1 list2)
3827 (cond ((= (car list1) (car list2))
3828 (setq out (cons (car list1) out)
3831 ((< (car list1) (car list2))
3832 (setq list1 (cdr list1)))
3834 (setq list2 (cdr list2)))))
3837 (defun gnus-set-sorted-intersection (list1 list2)
3838 ;; LIST1 and LIST2 have to be sorted over <.
3839 ;; This function modifies LIST1.
3840 (let* ((top (cons nil list1))
3842 (while (and list1 list2)
3843 (cond ((= (car list1) (car list2))
3847 ((< (car list1) (car list2))
3848 (setcdr prev (cdr list1))
3849 (setq list1 (cdr list1)))
3851 (setq list2 (cdr list2)))))
3855 (defun gnus-compress-sequence (numbers &optional always-list)
3856 "Convert list of numbers to a list of ranges or a single range.
3857 If ALWAYS-LIST is non-nil, this function will always release a list of
3859 (let* ((first (car numbers))
3860 (last (car numbers))
3864 (if (not (listp (cdr numbers)))
3867 (cond ((= last (car numbers)) nil) ;Omit duplicated number
3868 ((= (1+ last) (car numbers)) ;Still in sequence
3869 (setq last (car numbers)))
3870 (t ;End of one sequence
3872 (cons (if (= first last) first
3873 (cons first last)) result))
3874 (setq first (car numbers))
3875 (setq last (car numbers))))
3876 (setq numbers (cdr numbers)))
3877 (if (and (not always-list) (null result))
3878 (if (= first last) (list first) (cons first last))
3879 (nreverse (cons (if (= first last) first (cons first last))
3882 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
3883 (defun gnus-uncompress-range (ranges)
3884 "Expand a list of ranges into a list of numbers.
3885 RANGES is either a single range on the form `(num . num)' or a list of
3887 (let (first last result)
3891 ((not (listp (cdr ranges)))
3892 (setq first (car ranges))
3893 (setq last (cdr ranges))
3894 (while (<= first last)
3895 (setq result (cons first result))
3896 (setq first (1+ first)))
3900 (if (atom (car ranges))
3901 (if (numberp (car ranges))
3902 (setq result (cons (car ranges) result)))
3903 (setq first (caar ranges))
3904 (setq last (cdar ranges))
3905 (while (<= first last)
3906 (setq result (cons first result))
3907 (setq first (1+ first))))
3908 (setq ranges (cdr ranges)))
3909 (nreverse result)))))
3911 (defun gnus-add-to-range (ranges list)
3912 "Return a list of ranges that has all articles from both RANGES and LIST.
3913 Note: LIST has to be sorted over `<'."
3915 (gnus-compress-sequence list t)
3916 (setq list (copy-sequence list))
3917 (or (listp (cdr ranges))
3918 (setq ranges (list ranges)))
3920 ilist lowest highest temp)
3921 (while (and ranges list)
3923 (setq lowest (or (and (atom (car ranges)) (car ranges))
3925 (while (and list (cdr list) (< (cadr list) lowest))
3926 (setq list (cdr list)))
3927 (if (< (car ilist) lowest)
3930 (setq list (cdr list))
3932 (setq out (nconc (gnus-compress-sequence ilist t) out))))
3933 (setq highest (or (and (atom (car ranges)) (car ranges))
3935 (while (and list (<= (car list) highest))
3936 (setq list (cdr list)))
3937 (setq ranges (cdr ranges)))
3939 (setq out (nconc (gnus-compress-sequence list t) out)))
3940 (setq out (sort out (lambda (r1 r2)
3941 (< (or (and (atom r1) r1) (car r1))
3942 (or (and (atom r2) r2) (car r2))))))
3945 (if (atom (car ranges))
3947 (if (atom (cadr ranges))
3948 (if (= (1+ (car ranges)) (cadr ranges))
3950 (setcar ranges (cons (car ranges)
3952 (setcdr ranges (cddr ranges))))
3953 (if (= (1+ (car ranges)) (caadr ranges))
3955 (setcar (cadr ranges) (car ranges))
3956 (setcar ranges (cadr ranges))
3957 (setcdr ranges (cddr ranges))))))
3959 (if (atom (cadr ranges))
3960 (if (= (1+ (cdar ranges)) (cadr ranges))
3962 (setcdr (car ranges) (cadr ranges))
3963 (setcdr ranges (cddr ranges))))
3964 (if (= (1+ (cdar ranges)) (caadr ranges))
3966 (setcdr (car ranges) (cdadr ranges))
3967 (setcdr ranges (cddr ranges)))))))
3968 (setq ranges (cdr ranges)))
3971 (defun gnus-remove-from-range (ranges list)
3972 "Return a list of ranges that has all articles from LIST removed from RANGES.
3973 Note: LIST has to be sorted over `<'."
3974 ;; !!! This function shouldn't look like this, but I've got a headache.
3975 (gnus-compress-sequence
3976 (gnus-sorted-complement
3977 (gnus-uncompress-range ranges) list)))
3979 (defun gnus-member-of-range (number ranges)
3980 (if (not (listp (cdr ranges)))
3981 (and (>= number (car ranges))
3982 (<= number (cdr ranges)))
3985 (if (numberp (car ranges))
3986 (>= number (car ranges))
3987 (>= number (caar ranges)))
3989 (if (if (numberp (car ranges))
3990 (= number (car ranges))
3991 (and (>= number (caar ranges))
3992 (<= number (cdar ranges))))
3993 (setq not-stop nil))
3994 (setq ranges (cdr ranges)))
3997 (defun gnus-range-length (range)
3998 "Return the length RANGE would have if uncompressed."
3999 (length (gnus-uncompress-range range)))
4001 (defun gnus-sublist-p (list sublist)
4002 "Test whether all elements in SUBLIST are members of LIST."
4005 (unless (memq (pop sublist) list)
4015 (defvar gnus-group-mode-map nil)
4016 (put 'gnus-group-mode 'mode-class 'special)
4018 (unless gnus-group-mode-map
4019 (setq gnus-group-mode-map (make-keymap))
4020 (suppress-keymap gnus-group-mode-map)
4022 (gnus-define-keys gnus-group-mode-map
4023 " " gnus-group-read-group
4024 "=" gnus-group-select-group
4025 "\r" gnus-group-select-group
4026 "\M-\r" gnus-group-quick-select-group
4027 "j" gnus-group-jump-to-group
4028 "n" gnus-group-next-unread-group
4029 "p" gnus-group-prev-unread-group
4030 "\177" gnus-group-prev-unread-group
4031 [delete] gnus-group-prev-unread-group
4032 "N" gnus-group-next-group
4033 "P" gnus-group-prev-group
4034 "\M-n" gnus-group-next-unread-group-same-level
4035 "\M-p" gnus-group-prev-unread-group-same-level
4036 "," gnus-group-best-unread-group
4037 "." gnus-group-first-unread-group
4038 "u" gnus-group-unsubscribe-current-group
4039 "U" gnus-group-unsubscribe-group
4040 "c" gnus-group-catchup-current
4041 "C" gnus-group-catchup-current-all
4042 "l" gnus-group-list-groups
4043 "L" gnus-group-list-all-groups
4045 "g" gnus-group-get-new-news
4046 "\M-g" gnus-group-get-new-news-this-group
4047 "R" gnus-group-restart
4048 "r" gnus-group-read-init-file
4049 "B" gnus-group-browse-foreign-server
4050 "b" gnus-group-check-bogus-groups
4051 "F" gnus-find-new-newsgroups
4052 "\C-c\C-d" gnus-group-describe-group
4053 "\M-d" gnus-group-describe-all-groups
4054 "\C-c\C-a" gnus-group-apropos
4055 "\C-c\M-\C-a" gnus-group-description-apropos
4056 "a" gnus-group-post-news
4057 "\ek" gnus-group-edit-local-kill
4058 "\eK" gnus-group-edit-global-kill
4059 "\C-k" gnus-group-kill-group
4060 "\C-y" gnus-group-yank-group
4061 "\C-w" gnus-group-kill-region
4062 "\C-x\C-t" gnus-group-transpose-groups
4063 "\C-c\C-l" gnus-group-list-killed
4064 "\C-c\C-x" gnus-group-expire-articles
4065 "\C-c\M-\C-x" gnus-group-expire-all-groups
4067 "s" gnus-group-save-newsrc
4068 "z" gnus-group-suspend
4069 "Z" gnus-group-clear-dribble
4072 "?" gnus-group-describe-briefly
4073 "\C-c\C-i" gnus-info-find-node
4074 "\M-e" gnus-group-edit-group-method
4075 "^" gnus-group-enter-server-mode
4076 gnus-mouse-2 gnus-mouse-pick-group
4077 "<" beginning-of-buffer
4080 "\C-c\C-s" gnus-group-sort-groups
4082 "\C-c\M-g" gnus-activate-all-groups
4083 "\M-&" gnus-group-universal-argument
4084 "#" gnus-group-mark-group
4085 "\M-#" gnus-group-unmark-group)
4087 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
4088 "m" gnus-group-mark-group
4089 "u" gnus-group-unmark-group
4090 "w" gnus-group-mark-region
4091 "m" gnus-group-mark-buffer
4092 "r" gnus-group-mark-regexp
4093 "U" gnus-group-unmark-all-groups)
4095 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
4096 "d" gnus-group-make-directory-group
4097 "h" gnus-group-make-help-group
4098 "a" gnus-group-make-archive-group
4099 "k" gnus-group-make-kiboze-group
4100 "m" gnus-group-make-group
4101 "E" gnus-group-edit-group
4102 "e" gnus-group-edit-group-method
4103 "p" gnus-group-edit-group-parameters
4104 "v" gnus-group-add-to-virtual
4105 "V" gnus-group-make-empty-virtual
4106 "D" gnus-group-enter-directory
4107 "f" gnus-group-make-doc-group
4108 "r" gnus-group-rename-group
4109 "\177" gnus-group-delete-group
4110 [delete] gnus-group-delete-group)
4112 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
4113 "b" gnus-group-brew-soup
4114 "w" gnus-soup-save-areas
4115 "s" gnus-soup-send-replies
4116 "p" gnus-soup-pack-packet
4117 "r" nnsoup-pack-replies)
4119 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
4120 "s" gnus-group-sort-groups
4121 "a" gnus-group-sort-groups-by-alphabet
4122 "u" gnus-group-sort-groups-by-unread
4123 "l" gnus-group-sort-groups-by-level
4124 "v" gnus-group-sort-groups-by-score
4125 "r" gnus-group-sort-groups-by-rank
4126 "m" gnus-group-sort-groups-by-method)
4128 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
4129 "k" gnus-group-list-killed
4130 "z" gnus-group-list-zombies
4131 "s" gnus-group-list-groups
4132 "u" gnus-group-list-all-groups
4133 "A" gnus-group-list-active
4134 "a" gnus-group-apropos
4135 "d" gnus-group-description-apropos
4136 "m" gnus-group-list-matching
4137 "M" gnus-group-list-all-matching
4138 "l" gnus-group-list-level)
4140 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
4141 "f" gnus-score-flush-cache)
4143 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
4144 "f" gnus-group-fetch-faq)
4146 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
4147 "l" gnus-group-set-current-level
4148 "t" gnus-group-unsubscribe-current-group
4149 "s" gnus-group-unsubscribe-group
4150 "k" gnus-group-kill-group
4151 "y" gnus-group-yank-group
4152 "w" gnus-group-kill-region
4153 "\C-k" gnus-group-kill-level
4154 "z" gnus-group-kill-all-zombies))
4156 (defun gnus-group-mode ()
4157 "Major mode for reading news.
4159 All normal editing commands are switched off.
4160 \\<gnus-group-mode-map>
4161 The group buffer lists (some of) the groups available. For instance,
4162 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
4163 lists all zombie groups.
4165 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
4166 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
4168 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
4170 The following commands are available:
4172 \\{gnus-group-mode-map}"
4174 (when (and menu-bar-mode
4175 (gnus-visual-p 'group-menu 'menu))
4176 (gnus-group-make-menu-bar))
4177 (kill-all-local-variables)
4178 (gnus-simplify-mode-line)
4179 (setq major-mode 'gnus-group-mode)
4180 (setq mode-name "Group")
4181 (gnus-group-set-mode-line)
4182 (setq mode-line-process nil)
4183 (use-local-map gnus-group-mode-map)
4184 (buffer-disable-undo (current-buffer))
4185 (setq truncate-lines t)
4186 (setq buffer-read-only t)
4187 (run-hooks 'gnus-group-mode-hook))
4189 (defun gnus-mouse-pick-group (e)
4190 "Enter the group under the mouse pointer."
4193 (gnus-group-read-group nil))
4195 ;; Look at LEVEL and find out what the level is really supposed to be.
4196 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
4197 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
4198 (defun gnus-group-default-level (&optional level number-or-nil)
4200 (gnus-group-use-permanent-levels
4201 (setq gnus-group-default-list-level
4202 (or level gnus-group-default-list-level))
4203 (or gnus-group-default-list-level gnus-level-subscribed))
4207 (or level gnus-group-default-list-level gnus-level-subscribed))))
4210 (defun gnus-slave-no-server (&optional arg)
4211 "Read network news as a slave, without connecting to local server"
4213 (gnus-no-server arg t))
4216 (defun gnus-no-server (&optional arg slave)
4218 If ARG is a positive number, Gnus will use that as the
4219 startup level. If ARG is nil, Gnus will be started at level 2.
4220 If ARG is non-nil and not a positive number, Gnus will
4221 prompt the user for the name of an NNTP server to use.
4222 As opposed to `gnus', this command will not connect to the local server."
4224 (let ((gnus-group-use-permanent-levels t))
4225 (gnus (or arg (1- gnus-level-default-subscribed)) t slave))
4226 (make-local-variable 'gnus-group-use-permanent-levels)
4227 (setq gnus-group-use-permanent-levels t))
4230 (defun gnus-slave (&optional arg)
4231 "Read news as a slave."
4233 (gnus arg nil 'slave))
4236 (defun gnus-other-frame (&optional arg)
4237 "Pop up a frame to read news."
4239 (if (get-buffer gnus-group-buffer)
4240 (let ((pop-up-frames t))
4242 (select-frame (make-frame))
4246 (defun gnus (&optional arg dont-connect slave)
4248 If ARG is non-nil and a positive number, Gnus will use that as the
4249 startup level. If ARG is non-nil and not a positive number, Gnus will
4250 prompt the user for the name of an NNTP server to use."
4253 (if (get-buffer gnus-group-buffer)
4255 (switch-to-buffer gnus-group-buffer)
4256 (gnus-group-get-new-news))
4259 (nnheader-init-server-buffer)
4260 (gnus-read-init-file)
4261 (setq gnus-slave slave)
4263 (gnus-group-setup-buffer)
4264 (let ((buffer-read-only nil))
4266 (if (not gnus-inhibit-startup-message)
4268 (gnus-group-startup-message)
4271 (let ((level (and (numberp arg) (> arg 0) arg))
4277 (gnus-start-news-server (and arg (not level))))))
4278 (if (and (not dont-connect)
4281 (run-hooks 'gnus-startup-hook)
4282 ;; NNTP server is successfully open.
4284 ;; Find the current startup file name.
4285 (setq gnus-current-startup-file
4286 (gnus-make-newsrc-file gnus-startup-file))
4288 ;; Read the dribble file.
4289 (and (or gnus-slave gnus-use-dribble-file) (gnus-dribble-read-file))
4291 ;; Allow using GroupLens predictions.
4292 (when gnus-use-grouplens
4294 (add-hook 'gnus-summary-mode-hook 'gnus-grouplens-mode))
4296 (gnus-summary-make-display-table)
4297 ;; Do the actual startup.
4298 (gnus-setup-news nil level dont-connect)
4299 ;; Generate the group buffer.
4300 (gnus-group-list-groups level)
4301 (gnus-group-first-unread-group)
4302 (gnus-configure-windows 'group)
4303 (gnus-group-set-mode-line))))))
4305 (defun gnus-unload ()
4306 "Unload all Gnus features."
4308 (or (boundp 'load-history)
4309 (error "Sorry, `gnus-unload' is not implemented in this Emacs version."))
4310 (let ((history load-history)
4313 (and (string-match "^\\(gnus\\|nn\\)" (caar history))
4314 (setq feature (cdr (assq 'provide (car history))))
4315 (unload-feature feature 'force))
4316 (setq history (cdr history)))))
4318 (defun gnus-compile ()
4319 "Byte-compile the user-defined format specs."
4321 (let ((entries gnus-format-specs)
4322 entry gnus-tmp-func)
4324 (gnus-message 7 "Compiling format specs...")
4327 (setq entry (pop entries))
4328 (if (eq (car entry) 'version)
4329 (setq gnus-format-specs (delq entry gnus-format-specs))
4330 (when (and (listp (caddr entry))
4331 (not (eq 'byte-code (caaddr entry))))
4332 (fset 'gnus-tmp-func
4333 `(lambda () ,(caddr entry)))
4334 (byte-compile 'gnus-tmp-func)
4335 (setcar (cddr entry) (gnus-byte-code 'gnus-tmp-func)))))
4337 (push (cons 'version emacs-version) gnus-format-specs)
4339 (gnus-message 7 "Compiling user specs...done"))))
4341 (defun gnus-indent-rigidly (start end arg)
4342 "Indent rigidly using only spaces and no tabs."
4345 (narrow-to-region start end)
4346 (indent-rigidly start end arg)
4347 (goto-char (point-min))
4348 (while (search-forward "\t" nil t)
4349 (replace-match " " t t)))))
4351 (defun gnus-group-startup-message (&optional x y)
4352 "Insert startup message in current buffer."
4353 ;; Insert the message.
4358 _ ___ __ ___ __ _ ___
4377 ;; And then hack it.
4378 (gnus-indent-rigidly (point-min) (point-max)
4379 (/ (max (- (window-width) (or x 46)) 0) 2))
4380 (goto-char (point-min))
4382 (let* ((pheight (count-lines (point-min) (point-max)))
4383 (wheight (window-height))
4384 (rest (- wheight pheight)))
4385 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
4387 (goto-char (point-min))
4388 (and (search-forward "Praxis" nil t)
4389 (put-text-property (match-beginning 0) (match-end 0) 'face 'bold))
4390 (goto-char (point-min))
4391 (let* ((mode-string (gnus-group-set-mode-line)))
4392 (setq mode-line-buffer-identification
4393 (list (concat gnus-version (substring (car mode-string) 4))))
4394 (set-buffer-modified-p t)))
4396 (defun gnus-group-setup-buffer ()
4397 (or (get-buffer gnus-group-buffer)
4399 (switch-to-buffer gnus-group-buffer)
4400 (gnus-add-current-to-buffer-list)
4402 (and gnus-carpal (gnus-carpal-setup-buffer 'group)))))
4404 (defun gnus-group-list-groups (&optional level unread lowest)
4405 "List newsgroups with level LEVEL or lower that have unread articles.
4406 Default is all subscribed groups.
4407 If argument UNREAD is non-nil, groups with no unread articles are also
4409 (interactive (list (if current-prefix-arg
4410 (prefix-numeric-value current-prefix-arg)
4412 (gnus-group-default-level nil t)
4413 gnus-group-default-list-level
4414 gnus-level-subscribed))))
4416 (setq level (car gnus-group-list-mode)
4417 unread (cdr gnus-group-list-mode)))
4418 (setq level (gnus-group-default-level level))
4419 (gnus-group-setup-buffer) ;May call from out of group buffer
4420 (gnus-update-format-specifications)
4421 (let ((case-fold-search nil)
4422 (props (text-properties-at (gnus-point-at-bol)))
4423 (group (gnus-group-group-name)))
4424 (set-buffer gnus-group-buffer)
4425 (funcall gnus-group-prepare-function level unread lowest)
4426 (if (zerop (buffer-size))
4427 (gnus-message 5 gnus-no-groups-message)
4428 (goto-char (point-max))
4429 (when (or (not gnus-group-goto-next-group-function)
4430 (not (funcall gnus-group-goto-next-group-function
4433 ;; Go to the first group with unread articles.
4434 (gnus-group-search-forward t)
4435 ;; Find the right group to put point on. If the current group
4436 ;; has disappeared in the new listing, try to find the next
4437 ;; one. If no next one can be found, just leave point at the
4438 ;; first newsgroup in the buffer.
4439 (if (not (gnus-goto-char
4441 (point-min) (point-max)
4442 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
4443 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
4445 (not (gnus-goto-char
4447 (point-min) (point-max) 'gnus-group
4449 (caar newsrc) gnus-active-hashtb)))))
4450 (setq newsrc (cdr newsrc)))
4451 (or newsrc (progn (goto-char (point-max))
4452 (forward-line -1)))))))
4453 ;; Adjust cursor point.
4454 (gnus-group-position-point))))
4456 (defun gnus-group-list-level (level &optional all)
4457 "List groups on LEVEL.
4458 If ALL (the prefix), also list groups that have no unread articles."
4459 (interactive "nList groups on level: \nP")
4460 (gnus-group-list-groups level all level))
4462 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
4463 "List all newsgroups with unread articles of level LEVEL or lower.
4464 If ALL is non-nil, list groups that have no unread articles.
4465 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
4466 If REGEXP, only list groups matching REGEXP."
4467 (set-buffer gnus-group-buffer)
4468 (let ((buffer-read-only nil)
4469 (newsrc (cdr gnus-newsrc-alist))
4470 (lowest (or lowest 1))
4471 info clevel unread group params)
4473 (if (< lowest gnus-level-zombie)
4474 ;; List living groups.
4476 (setq info (car newsrc)
4477 group (gnus-info-group info)
4478 params (gnus-info-params info)
4480 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
4481 (and unread ; This group might be bogus
4483 (string-match regexp group))
4484 (<= (setq clevel (gnus-info-level info)) level)
4486 (or all ; We list all groups?
4487 (if (eq unread t) ; Unactivated?
4488 gnus-group-list-inactive-groups ; We list unactivated
4489 (> unread 0)) ; We list groups with unread articles
4490 (and gnus-list-groups-with-ticked-articles
4491 (cdr (assq 'tick (gnus-info-marks info))))
4492 ; And groups with tickeds
4493 ;; Check for permanent visibility.
4494 (and gnus-permanently-visible-groups
4495 (string-match gnus-permanently-visible-groups
4497 (memq 'visible params)
4498 (cdr (assq 'visible params)))
4499 (gnus-group-insert-group-line
4500 group (gnus-info-level info)
4501 (gnus-info-marks info) unread (gnus-info-method info)))))
4503 ;; List dead groups.
4504 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
4505 (gnus-group-prepare-flat-list-dead
4506 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
4507 gnus-level-zombie ?Z
4509 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
4510 (gnus-group-prepare-flat-list-dead
4511 (setq gnus-killed-list (sort gnus-killed-list 'string<))
4512 gnus-level-killed ?K regexp))
4514 (gnus-group-set-mode-line)
4515 (setq gnus-group-list-mode (cons level all))
4516 (run-hooks 'gnus-group-prepare-hook)))
4518 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
4519 ;; List zombies and killed lists somewhat faster, which was
4520 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
4521 ;; this by ignoring the group format specification altogether.
4524 ;; This loop is used when listing groups that match some
4527 (setq group (pop groups))
4528 (when (string-match regexp group)
4529 (add-text-properties
4530 (point) (prog1 (1+ (point))
4531 (insert " " mark " *: " group "\n"))
4532 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4534 'gnus-level level))))
4535 ;; This loop is used when listing all groups.
4537 (add-text-properties
4538 (point) (prog1 (1+ (point))
4539 (insert " " mark " *: "
4540 (setq group (pop groups)) "\n"))
4541 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4543 'gnus-level level))))))
4545 (defmacro gnus-group-real-name (group)
4546 "Find the real name of a foreign newsgroup."
4547 `(let ((gname ,group))
4548 (if (string-match ":[^:]+$" gname)
4549 (substring gname (1+ (match-beginning 0)))
4552 (defsubst gnus-server-add-address (method)
4553 (let ((method-name (symbol-name (car method))))
4554 (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
4555 (not (assq (intern (concat method-name "-address")) method)))
4556 (append method (list (list (intern (concat method-name "-address"))
4560 (defsubst gnus-server-get-method (group method)
4561 ;; Input either a server name, and extended server name, or a
4562 ;; select method, and return a select method.
4563 (cond ((stringp method)
4564 (gnus-server-to-method method))
4565 ((and (stringp (car method)) group)
4566 (gnus-server-extend-method group method))
4568 (gnus-server-add-address method))))
4570 (defun gnus-server-to-method (server)
4571 "Map virtual server names to select methods."
4573 ;; Perhaps this is the native server?
4574 (and (equal server "native") gnus-select-method)
4575 ;; It should be in the server alist.
4576 (cdr (assoc server gnus-server-alist))
4577 ;; If not, we look through all the opened server
4578 ;; to see whether we can find it there.
4579 (let ((opened gnus-opened-servers))
4581 (not (equal server (format "%s:%s" (caaar opened)
4586 (defmacro gnus-method-equal (ss1 ss2)
4587 "Say whether two servers are equal."
4591 (and (= (length s1) (length s2))
4593 (while (and s1 (member (car s1) s2))
4597 (defun gnus-server-equal (m1 m2)
4598 "Say whether two methods are equal."
4599 (let ((m1 (cond ((null m1) gnus-select-method)
4600 ((stringp m1) (gnus-server-to-method m1))
4602 (m2 (cond ((null m2) gnus-select-method)
4603 ((stringp m2) (gnus-server-to-method m2))
4605 (gnus-method-equal m1 m2)))
4607 (defun gnus-group-prefixed-name (group method)
4608 "Return the whole name from GROUP and METHOD."
4609 (and (stringp method) (setq method (gnus-server-to-method method)))
4610 (concat (format "%s" (car method))
4612 (or (assoc (format "%s" (car method))
4613 (gnus-methods-using 'address))
4614 (gnus-server-equal method gnus-message-archive-method))
4616 (not (string= (nth 1 method) "")))
4617 (concat "+" (nth 1 method)))
4620 (defun gnus-group-real-prefix (group)
4621 "Return the prefix of the current group name."
4622 (if (string-match "^[^:]+:" group)
4623 (substring group 0 (match-end 0))
4626 (defun gnus-group-method (group)
4627 "Return the server or method used for selecting GROUP."
4628 (let ((prefix (gnus-group-real-prefix group)))
4629 (if (equal prefix "")
4631 (let ((servers gnus-opened-servers)
4633 backend possible found)
4634 (if (string-match "^[^\\+]+\\+" prefix)
4635 (setq backend (intern (substring prefix 0 (1- (match-end 0))))
4636 server (substring prefix (match-end 0) (1- (length prefix))))
4637 (setq backend (intern (substring prefix 0 (1- (length prefix))))))
4639 (when (eq (caaar servers) backend)
4640 (setq possible (caar servers))
4641 (when (equal (cadaar servers) server)
4642 (setq found (caar servers))))
4644 (or (car (rassoc found gnus-server-alist))
4646 (car (rassoc possible gnus-server-alist))
4648 (list backend server))))))
4650 (defsubst gnus-secondary-method-p (method)
4651 "Return whether METHOD is a secondary select method."
4652 (let ((methods gnus-secondary-select-methods)
4653 (gmethod (gnus-server-get-method nil method)))
4655 (not (equal (gnus-server-get-method nil (car methods))
4657 (setq methods (cdr methods)))
4660 (defun gnus-group-foreign-p (group)
4661 "Say whether a group is foreign or not."
4662 (and (not (gnus-group-native-p group))
4663 (not (gnus-group-secondary-p group))))
4665 (defun gnus-group-native-p (group)
4666 "Say whether the group is native or not."
4667 (not (string-match ":" group)))
4669 (defun gnus-group-secondary-p (group)
4670 "Say whether the group is secondary or not."
4671 (gnus-secondary-method-p (gnus-find-method-for-group group)))
4673 (defun gnus-group-get-parameter (group &optional symbol)
4674 "Returns the group parameters for GROUP.
4675 If SYMBOL, return the value of that symbol in the group parameters."
4676 (let ((params (gnus-info-params (gnus-get-info group))))
4678 (gnus-group-parameter-value params symbol)
4681 (defun gnus-group-parameter-value (params symbol)
4682 "Return the value of SYMBOL in group PARAMS."
4683 (or (car (memq symbol params)) ; It's either a simple symbol
4684 (cdr (assq symbol params)))) ; or a cons.
4686 (defun gnus-group-add-parameter (group param)
4687 "Add parameter PARAM to GROUP."
4688 (let ((info (gnus-get-info group)))
4690 () ; This is a dead group. We just ignore it.
4691 ;; Cons the new param to the old one and update.
4692 (gnus-group-set-info (cons param (gnus-info-params info))
4695 (defun gnus-group-set-parameter (group name value)
4696 "Set parameter NAME to VALUE in GROUP."
4697 (let ((info (gnus-get-info group)))
4699 () ; This is a dead group. We just ignore it.
4700 (let ((old-params (gnus-info-params info))
4701 (new-params (list (cons name value))))
4703 (if (or (not (listp (car old-params)))
4704 (not (eq (caar old-params) name)))
4705 (setq new-params (append new-params (list (car old-params)))))
4706 (setq old-params (cdr old-params)))
4707 (gnus-group-set-info new-params group 'params)))))
4709 (defun gnus-group-add-score (group &optional score)
4710 "Add SCORE to the GROUP score.
4711 If SCORE is nil, add 1 to the score of GROUP."
4712 (let ((info (gnus-get-info group)))
4714 (gnus-info-set-score info (+ (gnus-info-score info) (or score 1))))))
4716 (defun gnus-summary-bubble-group ()
4717 "Increase the score of the current group.
4718 This is a handy function to add to `gnus-summary-exit-hook' to
4719 increase the score of each group you read."
4720 (gnus-group-add-score gnus-newsgroup-name))
4722 (defun gnus-group-set-info (info &optional method-only-group part)
4723 (let* ((entry (gnus-gethash
4724 (or method-only-group (gnus-info-group info))
4725 gnus-newsrc-hashtb))
4727 (info (if method-only-group (nth 2 entry) info))
4729 (when method-only-group
4731 (error "Trying to change non-existent group %s" method-only-group))
4732 ;; We have received parts of the actual group info - either the
4733 ;; select method or the group parameters. We first check
4734 ;; whether we have to extend the info, and if so, do that.
4735 (let ((len (length info))
4736 (total (if (eq part 'method) 5 6)))
4738 (setcdr (nthcdr (1- len) info)
4739 (make-list (- total len) nil)))
4740 ;; Then we enter the new info.
4741 (setcar (nthcdr (1- total) info) part-info)))
4743 ;; This is a new group, so we just create it.
4745 (set-buffer gnus-group-buffer)
4746 (setq method (gnus-info-method info))
4747 (when (gnus-server-equal method "native")
4750 ;; It's a foreign group...
4751 (gnus-group-make-group
4752 (gnus-group-real-name (gnus-info-group info))
4753 (if (stringp method) method
4754 (prin1-to-string (car method)))
4756 (nth 1 (gnus-info-method info))))
4757 ;; It's a native group.
4758 (gnus-group-make-group (gnus-info-group info)))
4759 (gnus-message 6 "Note: New group created")
4761 (gnus-gethash (gnus-group-prefixed-name
4762 (gnus-group-real-name (gnus-info-group info))
4763 (or (gnus-info-method info) gnus-select-method))
4764 gnus-newsrc-hashtb))))
4765 ;; Whether it was a new group or not, we now have the entry, so we
4766 ;; can do the update.
4769 (setcar (nthcdr 2 entry) info)
4770 (when (and (not (eq (car entry) t))
4771 (gnus-active (gnus-info-group info)))
4772 (setcar entry (length (gnus-list-of-unread-articles (car info))))))
4773 (error "No such group: %s" (gnus-info-group info)))))
4775 (defun gnus-group-set-method-info (group select-method)
4776 (gnus-group-set-info select-method group 'method))
4778 (defun gnus-group-set-params-info (group params)
4779 (gnus-group-set-info params group 'params))
4781 (defun gnus-group-update-group-line ()
4782 "Update the current line in the group buffer."
4783 (let* ((buffer-read-only nil)
4784 (group (gnus-group-group-name))
4785 (gnus-group-indentation (gnus-group-group-indentation))
4786 (entry (and group (gnus-gethash group gnus-newsrc-hashtb))))
4788 (not (gnus-ephemeral-group-p group))
4790 (concat "(gnus-group-set-info '"
4791 (prin1-to-string (nth 2 entry)) ")")))
4793 (gnus-group-insert-group-line-info group)
4795 (gnus-group-position-point)))
4797 (defun gnus-group-insert-group-line-info (group)
4798 "Insert GROUP on the current line."
4799 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
4803 ;; (Un)subscribed group.
4804 (setq info (nth 2 entry))
4805 (gnus-group-insert-group-line
4806 group (gnus-info-level info) (gnus-info-marks info)
4807 (or (car entry) t) (gnus-info-method info)))
4808 ;; This group is dead.
4809 (gnus-group-insert-group-line
4811 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
4813 (if (setq active (gnus-active group))
4814 (- (1+ (cdr active)) (car active)) 0)
4817 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
4818 gnus-tmp-marked number
4820 "Insert a group line in the group buffer."
4821 (let* ((gnus-tmp-active (gnus-active gnus-tmp-group))
4822 (gnus-tmp-number-total
4824 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
4826 (gnus-tmp-number-of-unread
4827 (if (numberp number) (int-to-string (max 0 number))
4829 (gnus-tmp-number-of-read
4830 (if (numberp number)
4831 (int-to-string (max 0 (- gnus-tmp-number-total number)))
4833 (gnus-tmp-subscribed
4834 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
4835 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
4836 ((= gnus-tmp-level gnus-level-zombie) ?Z)
4838 (gnus-tmp-qualified-group (gnus-group-real-name gnus-tmp-group))
4839 (gnus-tmp-newsgroup-description
4840 (if gnus-description-hashtb
4841 (or (gnus-gethash gnus-tmp-group gnus-description-hashtb) "")
4844 (if (member gnus-tmp-group gnus-moderated-list) ?m ? ))
4845 (gnus-tmp-moderated-string
4846 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
4848 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
4849 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
4850 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
4851 (gnus-tmp-news-method-string
4853 (format "(%s:%s)" (car gnus-tmp-method)
4854 (cadr gnus-tmp-method)) ""))
4855 (gnus-tmp-marked-mark
4856 (if (and (numberp number)
4858 (cdr (assq 'tick gnus-tmp-marked)))
4860 (gnus-tmp-process-marked
4861 (if (member gnus-tmp-group gnus-group-marked)
4862 gnus-process-mark ? ))
4864 (or (and gnus-use-grouplens
4865 (bbb-grouplens-group-p gnus-tmp-group))
4867 (buffer-read-only nil)
4868 header gnus-tmp-header) ; passed as parameter to user-funcs.
4870 (add-text-properties
4874 (eval gnus-group-line-format-spec))
4875 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
4876 gnus-unread ,(if (numberp number)
4877 (string-to-int gnus-tmp-number-of-unread)
4879 gnus-marked ,gnus-tmp-marked-mark
4880 gnus-indentation ,gnus-group-indentation
4881 gnus-level ,gnus-tmp-level))
4882 (when (inline (gnus-visual-p 'group-highlight 'highlight))
4884 (run-hooks 'gnus-group-update-hook)
4886 ;; Allow XEmacs to remove front-sticky text properties.
4887 (gnus-group-remove-excess-properties)))
4889 (defun gnus-group-update-group (group &optional visible-only)
4890 "Update all lines where GROUP appear.
4891 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
4894 (set-buffer gnus-group-buffer)
4895 ;; The buffer may be narrowed.
4898 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
4900 found buffer-read-only)
4901 ;; Enter the current status into the dribble buffer.
4902 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
4903 (if (and entry (not (gnus-ephemeral-group-p group)))
4905 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
4907 ;; Find all group instances. If topics are in use, each group
4908 ;; may be listed in more than once.
4909 (while (setq loc (text-property-any
4910 loc (point-max) 'gnus-group ident))
4913 (let ((gnus-group-indentation (gnus-group-group-indentation)))
4915 (gnus-group-insert-group-line-info group))
4916 (setq loc (1+ loc)))
4917 (unless (or found visible-only)
4918 ;; No such line in the buffer, find out where it's supposed to
4919 ;; go, and insert it there (or at the end of the buffer).
4920 (if gnus-goto-missing-group-function
4921 (funcall gnus-goto-missing-group-function group)
4922 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
4923 (while (and entry (car entry)
4927 (point-min) (point-max)
4928 'gnus-group (gnus-intern-safe
4929 (caar entry) gnus-active-hashtb)))))
4930 (setq entry (cdr entry)))
4931 (or entry (goto-char (point-max)))))
4932 ;; Finally insert the line.
4933 (let ((gnus-group-indentation (gnus-group-group-indentation)))
4934 (gnus-group-insert-group-line-info group)))
4935 (gnus-group-set-mode-line)))))
4937 (defun gnus-group-set-mode-line ()
4938 (when (memq 'group gnus-updated-mode-lines)
4939 (let* ((gformat (or gnus-group-mode-line-format-spec
4940 (setq gnus-group-mode-line-format-spec
4942 gnus-group-mode-line-format
4943 gnus-group-mode-line-format-alist))))
4944 (gnus-tmp-news-server (cadr gnus-select-method))
4945 (gnus-tmp-news-method (car gnus-select-method))
4947 gnus-tmp-header ;Dummy binding for user-defined formats
4948 ;; Get the resulting string.
4949 (mode-string (eval gformat)))
4950 ;; If the line is too long, we chop it off.
4951 (when (> (length mode-string) max-len)
4952 (setq mode-string (substring mode-string 0 (- max-len 4))))
4954 (setq mode-line-buffer-identification (list mode-string))
4955 (set-buffer-modified-p t)))))
4957 (defun gnus-group-group-name ()
4958 "Get the name of the newsgroup on the current line."
4959 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
4960 (and group (symbol-name group))))
4962 (defun gnus-group-group-level ()
4963 "Get the level of the newsgroup on the current line."
4964 (get-text-property (gnus-point-at-bol) 'gnus-level))
4966 (defun gnus-group-group-indentation ()
4967 "Get the indentation of the newsgroup on the current line."
4968 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
4969 (and gnus-group-indentation-function
4970 (funcall gnus-group-indentation-function))
4973 (defun gnus-group-group-unread ()
4974 "Get the number of unread articles of the newsgroup on the current line."
4975 (get-text-property (gnus-point-at-bol) 'gnus-unread))
4977 (defun gnus-group-search-forward (&optional backward all level first-too)
4978 "Find the next newsgroup with unread articles.
4979 If BACKWARD is non-nil, find the previous newsgroup instead.
4980 If ALL is non-nil, just find any newsgroup.
4981 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
4983 If FIRST-TOO, the current line is also eligible as a target."
4984 (let ((way (if backward -1 1))
4985 (low gnus-level-killed)
4988 (if (and backward (progn (beginning-of-line)) (bobp))
4990 (or first-too (forward-line way))
4998 (get-text-property (point) 'gnus-unread)))
4999 (and (numberp unread) (> unread 0)))
5000 (setq lev (get-text-property (point)
5002 (<= lev gnus-level-subscribed)))
5004 (and (setq lev (get-text-property (point)
5013 (zerop (forward-line way)))))
5015 (progn (gnus-group-position-point) t)
5016 (goto-char (or pos beg))
5019 ;;; Gnus group mode commands
5023 (defun gnus-group-mark-group (n &optional unmark no-advance)
5024 "Mark the current group."
5026 (let ((buffer-read-only nil)
5030 (setq group (gnus-group-group-name))
5034 (or (cdr (assq 'process gnus-group-mark-positions)) 2))
5039 (setq gnus-group-marked (delete group gnus-group-marked)))
5041 (setq gnus-group-marked
5042 (cons group (delete group gnus-group-marked))))
5044 (or no-advance (zerop (gnus-group-next-group 1))))
5046 (gnus-summary-position-point)
5049 (defun gnus-group-unmark-group (n)
5050 "Remove the mark from the current group."
5052 (gnus-group-mark-group n 'unmark)
5053 (gnus-group-position-point))
5055 (defun gnus-group-unmark-all-groups ()
5056 "Unmark all groups."
5058 (let ((groups gnus-group-marked))
5061 (gnus-group-remove-mark (pop groups)))))
5062 (gnus-group-position-point))
5064 (defun gnus-group-mark-region (unmark beg end)
5065 "Mark all groups between point and mark.
5066 If UNMARK, remove the mark instead."
5067 (interactive "P\nr")
5068 (let ((num (count-lines beg end)))
5071 (- num (gnus-group-mark-group num unmark)))))
5073 (defun gnus-group-mark-buffer (&optional unmark)
5074 "Mark all groups in the buffer.
5075 If UNMARK, remove the mark instead."
5077 (gnus-group-mark-region unmark (point-min) (point-max)))
5079 (defun gnus-group-mark-regexp (regexp)
5080 "Mark all groups that match some regexp."
5081 (interactive "sMark (regexp): ")
5082 (let ((alist (cdr gnus-newsrc-alist))
5085 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
5086 (gnus-group-set-mark group))))
5087 (gnus-group-position-point))
5089 (defun gnus-group-remove-mark (group)
5090 "Remove the process mark from GROUP and move point there.
5091 Return nil if the group isn't displayed."
5092 (if (gnus-group-goto-group group)
5094 (gnus-group-mark-group 1 'unmark t)
5096 (setq gnus-group-marked
5097 (delete group gnus-group-marked))
5100 (defun gnus-group-set-mark (group)
5101 "Set the process mark on GROUP."
5102 (if (gnus-group-goto-group group)
5104 (gnus-group-mark-group 1 nil t))
5105 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
5107 (defun gnus-group-universal-argument (arg &optional groups func)
5108 "Perform any command on all groups accoring to the process/prefix convention."
5110 (let ((groups (or groups (gnus-group-process-prefix arg)))
5112 (if (eq (setq func (or func
5115 (substitute-command-keys
5116 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
5119 (message "Undefined key")
5122 (gnus-group-remove-mark (setq group (pop groups)))
5123 (command-execute func))))
5124 (gnus-group-position-point))
5126 (defun gnus-group-process-prefix (n)
5127 "Return a list of groups to work on.
5128 Take into consideration N (the prefix) and the list of marked groups."
5131 (setq n (prefix-numeric-value n))
5132 ;; There is a prefix, so we return a list of the N next
5134 (let ((way (if (< n 0) -1 1))
5139 (setq group (gnus-group-group-name)))
5140 (setq groups (cons group groups))
5142 (gnus-group-next-group way)))
5144 ((and (boundp 'transient-mark-mode)
5147 ;; Work on the region between point and mark.
5148 (let ((max (max (point) (mark)))
5151 (goto-char (min (point) (mark)))
5154 (push (gnus-group-group-name) groups)
5155 (zerop (gnus-group-next-group 1))
5157 (nreverse groups))))
5159 ;; No prefix, but a list of marked articles.
5160 (reverse gnus-group-marked))
5162 ;; Neither marked articles or a prefix, so we return the
5164 (let ((group (gnus-group-group-name)))
5165 (and group (list group))))))
5167 ;; Selecting groups.
5169 (defun gnus-group-read-group (&optional all no-article group)
5170 "Read news in this newsgroup.
5171 If the prefix argument ALL is non-nil, already read articles become
5172 readable. IF ALL is a number, fetch this number of articles. If the
5173 optional argument NO-ARTICLE is non-nil, no article will be
5174 auto-selected upon group entry. If GROUP is non-nil, fetch that
5177 (let ((group (or group (gnus-group-group-name)))
5178 number active marked entry)
5179 (or group (error "No group on current line"))
5180 (setq marked (nth 3 (nth 2 (setq entry (gnus-gethash
5181 group gnus-newsrc-hashtb)))))
5182 ;; This group might be a dead group. In that case we have to get
5183 ;; the number of unread articles from `gnus-active-hashtb'.
5185 (cond ((numberp all) all)
5187 ((setq active (gnus-active group))
5188 (- (1+ (cdr active)) (car active)))))
5189 (gnus-summary-read-group
5190 group (or all (and (numberp number)
5191 (zerop (+ number (length (cdr (assq 'tick marked)))
5192 (length (cdr (assq 'dormant marked)))))))
5195 (defun gnus-group-select-group (&optional all)
5196 "Select this newsgroup.
5197 No article is selected automatically.
5198 If ALL is non-nil, already read articles become readable.
5199 If ALL is a number, fetch this number of articles."
5201 (gnus-group-read-group all t))
5203 (defun gnus-group-quick-select-group (&optional all)
5204 "Select the current group \"quickly\".
5205 This means that no highlighting or scoring will be performed."
5208 gnus-score-find-score-files-function
5209 gnus-apply-kill-hook
5210 gnus-summary-expunge-below)
5211 (gnus-group-read-group all t)))
5213 (defun gnus-group-visible-select-group (&optional all)
5214 "Select the current group without hiding any articles."
5216 (let ((gnus-inhibit-limiting t))
5217 (gnus-group-read-group all t)))
5220 (defun gnus-fetch-group (group)
5221 "Start Gnus if necessary and enter GROUP.
5222 Returns whether the fetching was successful or not."
5223 (interactive "sGroup name: ")
5224 (or (get-buffer gnus-group-buffer)
5226 (gnus-group-read-group nil nil group))
5228 ;; Enter a group that is not in the group buffer. Non-nil is returned
5229 ;; if selection was successful.
5230 (defun gnus-group-read-ephemeral-group
5231 (group method &optional activate quit-config)
5232 (let ((group (if (gnus-group-foreign-p group) group
5233 (gnus-group-prefixed-name group method))))
5236 `(t nil (,group ,gnus-level-default-subscribed nil nil ,method
5237 ((quit-config . ,(if quit-config quit-config
5238 (cons (current-buffer) 'summary))))))
5240 (set-buffer gnus-group-buffer)
5241 (or (gnus-check-server method)
5242 (error "Unable to contact server: %s" (gnus-status-message method)))
5243 (if activate (or (gnus-request-group group)
5244 (error "Couldn't request group")))
5246 (gnus-group-read-group t t group)
5250 (defun gnus-group-jump-to-group (group)
5251 "Jump to newsgroup GROUP."
5253 (list (completing-read
5254 "Group: " gnus-active-hashtb nil
5255 (memq gnus-select-method gnus-have-read-active-file))))
5257 (if (equal group "")
5258 (error "Empty group name"))
5260 (let ((b (text-property-any
5261 (point-min) (point-max)
5262 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
5263 (unless (gnus-ephemeral-group-p group)
5265 ;; Either go to the line in the group buffer...
5267 ;; ... or insert the line.
5270 (gnus-activate-group group)
5271 (error "%s error: %s" group (gnus-status-message group)))
5273 (gnus-group-update-group group)
5274 (goto-char (text-property-any
5275 (point-min) (point-max)
5276 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))
5277 ;; Adjust cursor point.
5278 (gnus-group-position-point)))
5280 (defun gnus-group-goto-group (group)
5281 "Goto to newsgroup GROUP."
5283 (let ((b (text-property-any (point-min) (point-max)
5284 'gnus-group (gnus-intern-safe
5285 group gnus-active-hashtb))))
5286 (and b (goto-char b)))))
5288 (defun gnus-group-next-group (n)
5289 "Go to next N'th newsgroup.
5290 If N is negative, search backward instead.
5291 Returns the difference between N and the number of skips actually
5294 (gnus-group-next-unread-group n t))
5296 (defun gnus-group-next-unread-group (n &optional all level)
5297 "Go to next N'th unread newsgroup.
5298 If N is negative, search backward instead.
5299 If ALL is non-nil, choose any newsgroup, unread or not.
5300 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
5301 such group can be found, the next group with a level higher than
5303 Returns the difference between N and the number of skips actually
5306 (let ((backward (< n 0))
5309 (gnus-group-search-forward
5310 backward (or (not gnus-group-goto-unread) all) level))
5312 (if (/= 0 n) (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
5313 (if level " on this level or higher" "")))
5316 (defun gnus-group-prev-group (n)
5317 "Go to previous N'th newsgroup.
5318 Returns the difference between N and the number of skips actually
5321 (gnus-group-next-unread-group (- n) t))
5323 (defun gnus-group-prev-unread-group (n)
5324 "Go to previous N'th unread newsgroup.
5325 Returns the difference between N and the number of skips actually
5328 (gnus-group-next-unread-group (- n)))
5330 (defun gnus-group-next-unread-group-same-level (n)
5331 "Go to next N'th unread newsgroup on the same level.
5332 If N is negative, search backward instead.
5333 Returns the difference between N and the number of skips actually
5336 (gnus-group-next-unread-group n t (gnus-group-group-level))
5337 (gnus-group-position-point))
5339 (defun gnus-group-prev-unread-group-same-level (n)
5340 "Go to next N'th unread newsgroup on the same level.
5341 Returns the difference between N and the number of skips actually
5344 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
5345 (gnus-group-position-point))
5347 (defun gnus-group-best-unread-group (&optional exclude-group)
5348 "Go to the group with the highest level.
5349 If EXCLUDE-GROUP, do not go to that group."
5351 (goto-char (point-min))
5354 (while (setq unread (get-text-property (point) 'gnus-unread))
5355 (if (and (numberp unread) (> unread 0))
5357 (if (and (get-text-property (point) 'gnus-level)
5358 (< (get-text-property (point) 'gnus-level) best)
5359 (or (not exclude-group)
5360 (not (equal exclude-group (gnus-group-group-name)))))
5362 (setq best (get-text-property (point) 'gnus-level))
5363 (setq best-point (point))))))
5365 (if best-point (goto-char best-point))
5366 (gnus-summary-position-point)
5367 (and best-point (gnus-group-group-name))))
5369 (defun gnus-group-first-unread-group ()
5370 "Go to the first group with unread articles."
5373 (let ((opoint (point))
5375 (goto-char (point-min))
5376 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
5377 (and (numberp unread) ; Not a topic.
5378 (not (zerop unread))) ; Has unread articles.
5379 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
5382 nil)) ; Not success.
5383 (gnus-group-position-point)))
5385 (defun gnus-group-enter-server-mode ()
5386 "Jump to the server buffer."
5388 (gnus-enter-server-buffer))
5390 (defun gnus-group-make-group (name &optional method address)
5391 "Add a new newsgroup.
5392 The user will be prompted for a NAME, for a select METHOD, and an
5396 (read-string "Group name: ")
5399 "Method: " (append gnus-valid-select-methods gnus-server-alist)
5401 (if (assoc method gnus-valid-select-methods)
5403 (if (memq 'prompt-address
5404 (assoc method gnus-valid-select-methods))
5405 (read-string "Address: ")
5407 (list method "")))))
5410 (set-buffer gnus-group-buffer)
5411 (let* ((meth (and method (if address (list (intern method) address)
5413 (nname (if method (gnus-group-prefixed-name name meth) name))
5415 (and (gnus-gethash nname gnus-newsrc-hashtb)
5416 (error "Group %s already exists" nname))
5417 (gnus-group-change-level
5418 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
5419 gnus-level-default-subscribed gnus-level-killed
5420 (and (gnus-group-group-name)
5421 (gnus-gethash (gnus-group-group-name)
5422 gnus-newsrc-hashtb))
5424 (gnus-set-active nname (cons 1 0))
5425 (or (gnus-ephemeral-group-p name)
5427 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")")))
5428 (gnus-group-insert-group-line-info nname)
5430 (when (assoc (symbol-name (car meth)) gnus-valid-select-methods)
5431 (require (car meth)))
5432 (gnus-check-server meth)
5433 (and (gnus-check-backend-function 'request-create-group nname)
5434 (gnus-request-create-group nname))
5437 (defun gnus-group-delete-group (group &optional force)
5438 "Delete the current group.
5439 If FORCE (the prefix) is non-nil, all the articles in the group will
5440 be deleted. This is \"deleted\" as in \"removed forever from the face
5441 of the Earth\". There is no undo."
5443 (list (gnus-group-group-name)
5444 current-prefix-arg))
5445 (or group (error "No group to rename"))
5446 (or (gnus-check-backend-function 'request-delete-group group)
5447 (error "This backend does not support group deletion"))
5449 (if (not (gnus-yes-or-no-p
5451 "Do you really want to delete %s%s? "
5452 group (if force " and all its contents" ""))))
5454 (gnus-message 6 "Deleting group %s..." group)
5455 (if (not (gnus-request-delete-group group force))
5457 (gnus-message 3 "Couldn't delete group %s" group)
5459 (gnus-message 6 "Deleting group %s...done" group)
5460 (gnus-group-goto-group group)
5461 (gnus-group-kill-group 1 t)
5462 (gnus-sethash group nil gnus-active-hashtb)
5464 (gnus-group-position-point)))
5466 (defun gnus-group-rename-group (group new-name)
5469 (gnus-group-group-name)
5471 (or (gnus-check-backend-function
5472 'request-rename-group (gnus-group-group-name))
5473 (error "This backend does not support renaming groups"))
5474 (read-string "New group name: "))))
5476 (or (gnus-check-backend-function 'request-rename-group group)
5477 (error "This backend does not support renaming groups"))
5479 (or group (error "No group to rename"))
5480 (and (string-match "^[ \t]*$" new-name)
5481 (error "Not a valid group name"))
5483 ;; We find the proper prefixed name.
5485 (gnus-group-prefixed-name
5486 (gnus-group-real-name new-name)
5487 (gnus-info-method (gnus-get-info group))))
5489 (gnus-message 6 "Renaming group %s to %s..." group new-name)
5491 (if (not (gnus-request-rename-group group new-name))
5493 (gnus-message 3 "Couldn't rename group %s to %s" group new-name)
5495 ;; We rename the group internally by killing it...
5496 (gnus-group-goto-group group)
5497 (gnus-group-kill-group)
5498 ;; ... changing its name ...
5499 (setcar (cdar gnus-list-of-killed-groups) new-name)
5500 ;; ... and then yanking it. Magic!
5501 (gnus-group-yank-group)
5502 (gnus-set-active new-name (gnus-active group))
5503 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
5505 (gnus-group-position-point)))
5507 (defun gnus-group-edit-group (group &optional part)
5508 "Edit the group on the current line."
5509 (interactive (list (gnus-group-group-name)))
5510 (let* ((part (or part 'info))
5511 (done-func `(lambda ()
5512 "Exit editing mode and update the information."
5514 (gnus-group-edit-group-done ',part ,group)))
5515 (winconf (current-window-configuration))
5517 (or group (error "No group on current line"))
5518 (or (setq info (gnus-get-info group))
5519 (error "Killed group; can't be edited"))
5520 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5521 (gnus-configure-windows 'edit-group)
5522 (gnus-add-current-to-buffer-list)
5524 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
5525 (use-local-map (copy-keymap emacs-lisp-mode-map))
5526 (local-set-key "\C-c\C-c" done-func)
5527 (make-local-variable 'gnus-prev-winconf)
5528 (setq gnus-prev-winconf winconf)
5533 ";; Type `C-c C-c' after editing the select method.\n\n")
5535 ";; Type `C-c C-c' after editing the group parameters.\n\n")
5537 ";; Type `C-c C-c' after editing the group info.\n\n")))
5540 (cond ((eq part 'method)
5541 (or (gnus-info-method info) "native"))
5543 (gnus-info-params info))
5547 (defun gnus-group-edit-group-method (group)
5548 "Edit the select method of GROUP."
5549 (interactive (list (gnus-group-group-name)))
5550 (gnus-group-edit-group group 'method))
5552 (defun gnus-group-edit-group-parameters (group)
5553 "Edit the group parameters of GROUP."
5554 (interactive (list (gnus-group-group-name)))
5555 (gnus-group-edit-group group 'params))
5557 (defun gnus-group-edit-group-done (part group)
5558 "Get info from buffer, update variables and jump to the group buffer."
5559 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5560 (goto-char (point-min))
5561 (let* ((form (read (current-buffer)))
5562 (winconf gnus-prev-winconf)
5563 (method (cond ((eq part 'info) (nth 4 form))
5564 ((eq part 'method) form)
5566 (info (cond ((eq part 'info) form)
5567 ((eq part 'method) (gnus-get-info group))
5570 (if (or (not method)
5572 gnus-select-method method))
5573 (gnus-group-real-name (car info))
5574 (gnus-group-prefixed-name
5575 (gnus-group-real-name (car info)) method))
5577 (when (and new-group
5578 (not (equal new-group group)))
5579 (when (gnus-group-goto-group group)
5580 (gnus-group-kill-group 1))
5581 (gnus-activate-group new-group))
5583 (if (and info new-group)
5585 (setq info (gnus-copy-sequence info))
5586 (setcar info new-group)
5587 (unless (gnus-server-equal method "native")
5588 (unless (nthcdr 3 info)
5589 (nconc info (list nil nil)))
5590 (unless (nthcdr 4 info)
5591 (nconc info (list nil)))
5592 (gnus-info-set-method info method))
5593 (gnus-group-set-info info))
5594 (gnus-group-set-info form (or new-group group) part))
5595 (kill-buffer (current-buffer))
5596 (and winconf (set-window-configuration winconf))
5597 (set-buffer gnus-group-buffer)
5598 (gnus-group-update-group (or new-group group))
5599 (gnus-group-position-point)))
5601 (defun gnus-group-make-help-group ()
5602 "Create the Gnus documentation group."
5604 (let ((path load-path)
5605 (name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
5607 (and (gnus-gethash name gnus-newsrc-hashtb)
5608 (error "Documentation group already exists"))
5610 (setq dir (file-name-as-directory (expand-file-name (pop path)))
5612 (when (or (file-exists-p (setq file (concat dir "gnus-tut.txt")))
5614 (setq file (concat (file-name-directory
5615 (directory-file-name dir))
5616 "etc/gnus-tut.txt"))))
5619 (message "Couldn't find doc group")
5620 (gnus-group-make-group
5621 (gnus-group-real-name name)
5622 (list 'nndoc "gnus-help"
5623 (list 'nndoc-address file)
5624 (list 'nndoc-article-type 'mbox)))))
5625 (gnus-group-position-point))
5627 (defun gnus-group-make-doc-group (file type)
5628 "Create a group that uses a single file as the source."
5630 (list (read-file-name "File name: ")
5631 (and current-prefix-arg 'ask)))
5632 (when (eq type 'ask)
5637 "%sFile type (mbox, babyl, digest, forward, mmfd, guess) [mbdfag]: "
5639 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
5640 ((= char ?b) 'babyl)
5641 ((= char ?d) 'digest)
5642 ((= char ?f) 'forward)
5644 (t (setq err (format "%c unknown. " char))
5647 (let* ((file (expand-file-name file))
5648 (name (gnus-generate-new-group-name
5649 (gnus-group-prefixed-name
5650 (file-name-nondirectory file) '(nndoc "")))))
5651 (gnus-group-make-group
5652 (gnus-group-real-name name)
5653 (list 'nndoc (file-name-nondirectory file)
5654 (list 'nndoc-address file)
5655 (list 'nndoc-article-type (or type 'guess))))
5657 (gnus-group-position-point)))
5659 (defun gnus-group-make-archive-group (&optional all)
5660 "Create the (ding) Gnus archive group of the most recent articles.
5661 Given a prefix, create a full group."
5663 (let ((group (gnus-group-prefixed-name
5664 (if all "ding.archives" "ding.recent") '(nndir ""))))
5665 (and (gnus-gethash group gnus-newsrc-hashtb)
5666 (error "Archive group already exists"))
5667 (gnus-group-make-group
5668 (gnus-group-real-name group)
5669 (list 'nndir (if all "hpc" "edu")
5670 (list 'nndir-directory
5671 (if all gnus-group-archive-directory
5672 gnus-group-recent-archive-directory)))))
5674 (gnus-group-position-point))
5676 (defun gnus-group-make-directory-group (dir)
5677 "Create an nndir group.
5678 The user will be prompted for a directory. The contents of this
5679 directory will be used as a newsgroup. The directory should contain
5680 mail messages or news articles in files that have numeric names."
5682 (list (read-file-name "Create group from directory: ")))
5683 (or (file-exists-p dir) (error "No such directory"))
5684 (or (file-directory-p dir) (error "Not a directory"))
5688 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
5690 (gnus-group-prefixed-name
5691 (concat (file-name-as-directory (directory-file-name dir))
5694 (setq ext (format "<%d>" (setq i (1+ i)))))
5695 (gnus-group-make-group
5696 (gnus-group-real-name group)
5697 (list 'nndir group (list 'nndir-directory dir))))
5699 (gnus-group-position-point))
5701 (defun gnus-group-make-kiboze-group (group address scores)
5702 "Create an nnkiboze group.
5703 The user will be prompted for a name, a regexp to match groups, and
5704 score file entries for articles to include in the group."
5707 (read-string "nnkiboze group name: ")
5708 (read-string "Source groups (regexp): ")
5709 (let ((headers (mapcar (lambda (group) (list group))
5710 '("subject" "from" "number" "date" "message-id"
5711 "references" "chars" "lines" "xref"
5712 "followup" "all" "body" "head")))
5713 scores header regexp regexps)
5714 (while (not (equal "" (setq header (completing-read
5715 "Match on header: " headers nil t))))
5717 (while (not (equal "" (setq regexp (read-string
5718 (format "Match on %s (string): "
5720 (setq regexps (cons (list regexp nil nil 'r) regexps)))
5721 (setq scores (cons (cons header regexps) scores)))
5723 (gnus-group-make-group group "nnkiboze" address)
5725 (gnus-set-work-buffer)
5726 (let (emacs-lisp-mode-hook)
5727 (pp scores (current-buffer)))
5728 (write-region (point-min) (point-max)
5729 (gnus-score-file-name (concat "nnkiboze:" group))))
5731 (gnus-group-position-point))
5733 (defun gnus-group-add-to-virtual (n vgroup)
5734 "Add the current group to a virtual group."
5736 (list current-prefix-arg
5737 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
5739 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
5740 (error "%s is not an nnvirtual group" vgroup))
5741 (let* ((groups (gnus-group-process-prefix n))
5742 (method (gnus-info-method (gnus-get-info vgroup))))
5743 (setcar (cdr method)
5745 (nth 1 method) "\\|"
5748 (gnus-group-remove-mark s)
5749 (concat "\\(^" (regexp-quote s) "$\\)"))
5751 (gnus-group-position-point))
5753 (defun gnus-group-make-empty-virtual (group)
5754 "Create a new, fresh, empty virtual group."
5755 (interactive "sCreate new, empty virtual group: ")
5756 (let* ((method (list 'nnvirtual "^$"))
5757 (pgroup (gnus-group-prefixed-name group method)))
5758 ;; Check whether it exists already.
5759 (and (gnus-gethash pgroup gnus-newsrc-hashtb)
5760 (error "Group %s already exists." pgroup))
5761 ;; Subscribe the new group after the group on the current line.
5762 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
5763 (gnus-group-update-group pgroup)
5765 (gnus-group-position-point)))
5767 (defun gnus-group-enter-directory (dir)
5768 "Enter an ephemeral nneething group."
5769 (interactive "DDirectory to read: ")
5770 (let* ((method (list 'nneething dir))
5771 (leaf (gnus-group-prefixed-name
5772 (file-name-nondirectory (directory-file-name dir))
5774 (name (gnus-generate-new-group-name leaf)))
5775 (let ((nneething-read-only t))
5776 (or (gnus-group-read-ephemeral-group
5778 (cons (current-buffer) (if (eq major-mode 'gnus-summary-mode)
5780 (error "Couldn't enter %s" dir)))))
5782 ;; Group sorting commands
5783 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
5785 (defun gnus-group-sort-groups (func &optional reverse)
5786 "Sort the group buffer according to FUNC.
5787 If REVERSE, reverse the sorting order."
5788 (interactive (list gnus-group-sort-function
5789 current-prefix-arg))
5791 ((not (listp func)) func)
5793 ((= 1 (length func)) (car func))
5795 ,(gnus-make-sort-function
5796 (reverse func)))))))
5797 ;; We peel off the dummy group from the alist.
5799 (when (equal (car (gnus-info-group gnus-newsrc-alist)) "dummy.group")
5800 (pop gnus-newsrc-alist))
5802 (setq gnus-newsrc-alist
5803 (sort gnus-newsrc-alist func))
5805 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
5806 ;; Regenerate the hash table.
5807 (gnus-make-hashtable-from-newsrc-alist)
5808 (gnus-group-list-groups))))
5810 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
5811 "Sort the group buffer alphabetically by group name.
5812 If REVERSE, sort in reverse order."
5814 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
5816 (defun gnus-group-sort-groups-by-unread (&optional reverse)
5817 "Sort the group buffer by number of unread articles.
5818 If REVERSE, sort in reverse order."
5820 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
5822 (defun gnus-group-sort-groups-by-level (&optional reverse)
5823 "Sort the group buffer by group level.
5824 If REVERSE, sort in reverse order."
5826 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
5828 (defun gnus-group-sort-groups-by-score (&optional reverse)
5829 "Sort the group buffer by group score.
5830 If REVERSE, sort in reverse order."
5832 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
5834 (defun gnus-group-sort-groups-by-rank (&optional reverse)
5835 "Sort the group buffer by group rank.
5836 If REVERSE, sort in reverse order."
5838 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
5840 (defun gnus-group-sort-groups-by-method (&optional reverse)
5841 "Sort the group buffer alphabetically by backend name.
5842 If REVERSE, sort in reverse order."
5844 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
5846 (defun gnus-group-sort-by-alphabet (info1 info2)
5847 "Sort alphabetically."
5848 (string< (gnus-info-group info1) (gnus-info-group info2)))
5850 (defun gnus-group-sort-by-unread (info1 info2)
5851 "Sort by number of unread articles."
5852 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
5853 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
5854 (< (or (and (numberp n1) n1) 0)
5855 (or (and (numberp n2) n2) 0))))
5857 (defun gnus-group-sort-by-level (info1 info2)
5859 (< (gnus-info-level info1) (gnus-info-level info2)))
5861 (defun gnus-group-sort-by-method (info1 info2)
5862 "Sort alphabetically by backend name."
5863 (string< (symbol-name (car (gnus-find-method-for-group
5864 (gnus-info-group info1) info1)))
5865 (symbol-name (car (gnus-find-method-for-group
5866 (gnus-info-group info2) info2)))))
5868 (defun gnus-group-sort-by-score (info1 info2)
5869 "Sort by group score."
5870 (< (gnus-info-score info1) (gnus-info-score info2)))
5872 (defun gnus-group-sort-by-rank (info1 info2)
5873 "Sort by level and score."
5874 (let ((level1 (gnus-info-level info1))
5875 (level2 (gnus-info-level info2)))
5876 (or (< level1 level2)
5877 (and (= level1 level2)
5878 (< (gnus-info-score info1) (gnus-info-score info2))))))
5880 ;; Group catching up.
5882 (defun gnus-group-clear-data (n)
5883 "Clear all marks and read ranges from the current group."
5885 (let ((groups (gnus-group-process-prefix n))
5887 (while (setq group (pop groups))
5888 (setq info (gnus-get-info group))
5889 (gnus-info-set-read info nil)
5890 (when (gnus-info-marks info)
5891 (gnus-info-set-marks info nil))
5892 (gnus-get-unread-articles-in-group info (gnus-active group) t)
5893 (when (gnus-group-goto-group group)
5894 (gnus-group-remove-mark group)
5895 (gnus-group-update-group-line)))))
5897 (defun gnus-group-catchup-current (&optional n all)
5898 "Mark all articles not marked as unread in current newsgroup as read.
5899 If prefix argument N is numeric, the ARG next newsgroups will be
5900 caught up. If ALL is non-nil, marked articles will also be marked as
5901 read. Cross references (Xref: header) of articles are ignored.
5902 The difference between N and actual number of newsgroups that were
5903 caught up is returned."
5905 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
5909 "Do you really want to mark all articles as read? "
5910 "Mark all unread articles as read? "))))
5912 (let ((groups (gnus-group-process-prefix n))
5915 ;; Virtual groups have to be given special treatment.
5916 (let ((method (gnus-find-method-for-group (car groups))))
5917 (if (eq 'nnvirtual (car method))
5918 (nnvirtual-catchup-group
5919 (gnus-group-real-name (car groups)) (nth 1 method) all)))
5920 (gnus-group-remove-mark (car groups))
5922 (gnus-group-goto-group (car groups))
5923 (gnus-group-catchup (car groups) all))
5924 (gnus-group-update-group-line)
5925 (setq ret (1+ ret)))
5926 (setq groups (cdr groups)))
5927 (gnus-group-next-unread-group 1)
5930 (defun gnus-group-catchup-current-all (&optional n)
5931 "Mark all articles in current newsgroup as read.
5932 Cross references (Xref: header) of articles are ignored."
5934 (gnus-group-catchup-current n 'all))
5936 (defun gnus-group-catchup (group &optional all)
5937 "Mark all articles in GROUP as read.
5938 If ALL is non-nil, all articles are marked as read.
5939 The return value is the number of articles that were marked as read,
5940 or nil if no action could be taken."
5941 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5943 ;; Do the updating only if the newsgroup isn't killed.
5944 (if (not (numberp (car entry)))
5945 (gnus-message 1 "Can't catch up; non-active group")
5946 ;; Do auto-expirable marks if that's required.
5947 (when (gnus-group-auto-expirable-p group)
5948 (gnus-add-marked-articles
5949 group 'expire (gnus-list-of-unread-articles group))
5951 (let ((marks (nth 3 (nth 2 entry))))
5952 (gnus-add-marked-articles
5953 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))
5954 (gnus-add-marked-articles
5955 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))))))
5957 (gnus-update-read-articles group nil)
5958 ;; Also nix out the lists of marks and dormants.
5960 (gnus-add-marked-articles group 'tick nil nil 'force)
5961 (gnus-add-marked-articles group 'dormant nil nil 'force))
5962 (run-hooks 'gnus-group-catchup-group-hook)
5965 (defun gnus-group-expire-articles (&optional n)
5966 "Expire all expirable articles in the current newsgroup."
5968 (let ((groups (gnus-group-process-prefix n))
5971 (error "No groups to expire"))
5972 (while (setq group (pop groups))
5973 (gnus-group-remove-mark group)
5974 (when (gnus-check-backend-function 'request-expire-articles group)
5975 (gnus-message 6 "Expiring articles in %s..." group)
5976 (let* ((info (gnus-get-info group))
5977 (expirable (if (gnus-group-total-expirable-p group)
5978 (cons nil (gnus-list-of-read-articles group))
5979 (assq 'expire (gnus-info-marks info))))
5980 (expiry-wait (gnus-group-get-parameter group 'expiry-wait)))
5984 (gnus-compress-sequence
5986 ;; We set the expiry variables to the groupp
5988 (let ((nnmail-expiry-wait-function nil)
5989 (nnmail-expiry-wait expiry-wait))
5990 (gnus-request-expire-articles
5991 (gnus-uncompress-sequence (cdr expirable)) group))
5992 ;; Just expire using the normal expiry values.
5993 (gnus-request-expire-articles
5994 (gnus-uncompress-sequence (cdr expirable)) group)))))
5995 (gnus-message 6 "Expiring articles in %s...done" group)))
5996 (gnus-group-position-point))))
5998 (defun gnus-group-expire-all-groups ()
5999 "Expire all expirable articles in all newsgroups."
6002 (gnus-message 5 "Expiring...")
6003 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
6004 (cdr gnus-newsrc-alist))))
6005 (gnus-group-expire-articles nil)))
6006 (gnus-group-position-point)
6007 (gnus-message 5 "Expiring...done"))
6009 (defun gnus-group-set-current-level (n level)
6010 "Set the level of the next N groups to LEVEL."
6015 (let ((s (read-string
6016 (format "Level (default %s): "
6017 (or (gnus-group-group-level)
6018 gnus-level-default-subscribed)))))
6019 (if (string-match "^\\s-*$" s)
6020 (int-to-string (or (gnus-group-group-level)
6021 gnus-level-default-subscribed))
6023 (or (and (>= level 1) (<= level gnus-level-killed))
6024 (error "Illegal level: %d" level))
6025 (let ((groups (gnus-group-process-prefix n))
6027 (while (setq group (pop groups))
6028 (gnus-group-remove-mark group)
6029 (gnus-message 6 "Changed level of %s from %d to %d"
6030 group (or (gnus-group-group-level) gnus-level-killed)
6032 (gnus-group-change-level
6033 group level (or (gnus-group-group-level) gnus-level-killed))
6034 (gnus-group-update-group-line)))
6035 (gnus-group-position-point))
6037 (defun gnus-group-unsubscribe-current-group (&optional n)
6038 "Toggle subscription of the current group.
6039 If given numerical prefix, toggle the N next groups."
6041 (let ((groups (gnus-group-process-prefix n))
6044 (setq group (car groups)
6045 groups (cdr groups))
6046 (gnus-group-remove-mark group)
6047 (gnus-group-unsubscribe-group
6048 group (if (<= (gnus-group-group-level) gnus-level-subscribed)
6049 gnus-level-default-unsubscribed
6050 gnus-level-default-subscribed) t)
6051 (gnus-group-update-group-line))
6052 (gnus-group-next-group 1)))
6054 (defun gnus-group-unsubscribe-group (group &optional level silent)
6055 "Toggle subscription to GROUP.
6056 Killed newsgroups are subscribed. If SILENT, don't try to update the
6059 (list (completing-read
6060 "Group: " gnus-active-hashtb nil
6061 (memq gnus-select-method gnus-have-read-active-file))))
6062 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
6064 ((string-match "^[ \t]$" group)
6065 (error "Empty group name"))
6067 ;; Toggle subscription flag.
6068 (gnus-group-change-level
6069 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
6070 gnus-level-subscribed)
6071 (1+ gnus-level-subscribed)
6072 gnus-level-default-subscribed)))
6074 (gnus-group-update-group group)))
6075 ((and (stringp group)
6076 (or (not (memq gnus-select-method gnus-have-read-active-file))
6077 (gnus-active group)))
6078 ;; Add new newsgroup.
6079 (gnus-group-change-level
6081 (if level level gnus-level-default-subscribed)
6082 (or (and (member group gnus-zombie-list)
6085 (and (gnus-group-group-name)
6086 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
6088 (gnus-group-update-group group)))
6089 (t (error "No such newsgroup: %s" group)))
6090 (gnus-group-position-point)))
6092 (defun gnus-group-transpose-groups (n)
6093 "Move the current newsgroup up N places.
6094 If given a negative prefix, move down instead. The difference between
6095 N and the number of steps taken is returned."
6097 (or (gnus-group-group-name)
6098 (error "No group on current line"))
6099 (gnus-group-kill-group 1)
6101 (forward-line (- n))
6102 (gnus-group-yank-group)
6103 (gnus-group-position-point)))
6105 (defun gnus-group-kill-all-zombies ()
6106 "Kill all zombie newsgroups."
6108 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
6109 (setq gnus-zombie-list nil)
6110 (gnus-group-list-groups))
6112 (defun gnus-group-kill-region (begin end)
6113 "Kill newsgroups in current region (excluding current point).
6114 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
6129 (beginning-of-line) ;Important when LINES < 1
6130 (gnus-group-kill-group lines)))
6132 (defun gnus-group-kill-group (&optional n discard)
6133 "Kill the next N groups.
6134 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
6135 However, only groups that were alive can be yanked; already killed
6136 groups or zombie groups can't be yanked.
6137 The return value is the name of the group that was killed, or a list
6140 (let ((buffer-read-only nil)
6141 (groups (gnus-group-process-prefix n))
6142 group entry level out)
6143 (if (< (length groups) 10)
6144 ;; This is faster when there are few groups.
6146 (push (setq group (pop groups)) out)
6147 (gnus-group-remove-mark group)
6148 (setq level (gnus-group-group-level))
6150 (when (and (not discard)
6151 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
6152 (push (cons (car entry) (nth 2 entry))
6153 gnus-list-of-killed-groups))
6154 (gnus-group-change-level
6155 (if entry entry group) gnus-level-killed (if entry nil level)))
6156 ;; If there are lots and lots of groups to be killed, we use
6157 ;; this thing instead.
6159 (setq groups (nreverse groups))
6161 (gnus-group-remove-mark (setq group (pop groups)))
6164 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
6165 (push (cons (car entry) (nth 2 entry))
6166 gnus-list-of-killed-groups)
6167 (setcdr (cdr entry) (cdddr entry)))
6168 ((member group gnus-zombie-list)
6169 (setq gnus-zombie-list (delete group gnus-zombie-list)))))
6170 (gnus-make-hashtable-from-newsrc-alist)))
6172 (gnus-group-position-point)
6173 (if (< (length out) 2) (car out) (nreverse out))))
6175 (defun gnus-group-yank-group (&optional arg)
6176 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
6177 inserting it before the current newsgroup. The numeric ARG specifies
6178 how many newsgroups are to be yanked. The name of the newsgroup yanked
6179 is returned, or (if several groups are yanked) a list of yanked groups
6182 (setq arg (or arg 1))
6183 (let (info group prev out)
6184 (while (>= (decf arg) 0)
6185 (if (not (setq info (pop gnus-list-of-killed-groups)))
6186 (error "No more newsgroups to yank"))
6187 (push (setq group (nth 1 info)) out)
6188 ;; Find which newsgroup to insert this one before - search
6189 ;; backward until something suitable is found. If there are no
6190 ;; other newsgroups in this buffer, just make this newsgroup the
6192 (setq prev (gnus-group-group-name))
6193 (gnus-group-change-level
6194 info (gnus-info-level (cdr info)) gnus-level-killed
6195 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
6197 (gnus-group-insert-group-line-info group))
6199 (gnus-group-position-point)
6200 (if (< (length out) 2) (car out) (nreverse out))))
6202 (defun gnus-group-kill-level (level)
6203 "Kill all groups that is on a certain LEVEL."
6204 (interactive "nKill all groups on level: ")
6206 ((= level gnus-level-zombie)
6207 (setq gnus-killed-list
6208 (nconc gnus-zombie-list gnus-killed-list))
6209 (setq gnus-zombie-list nil))
6210 ((and (< level gnus-level-zombie)
6212 (or gnus-expert-user
6215 "Do you really want to kill all groups on level %d? "
6217 (let* ((prev gnus-newsrc-alist)
6220 (if (= (gnus-info-level level) level)
6221 (setcdr prev (cdr alist))
6223 (setq alist (cdr alist)))
6224 (gnus-make-hashtable-from-newsrc-alist)
6225 (gnus-group-list-groups)))
6227 (error "Can't kill; illegal level: %d" level))))
6229 (defun gnus-group-list-all-groups (&optional arg)
6230 "List all newsgroups with level ARG or lower.
6231 Default is gnus-level-unsubscribed, which lists all subscribed and most
6232 unsubscribed groups."
6234 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
6236 ;; Redefine this to list ALL killed groups if prefix arg used.
6237 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
6238 (defun gnus-group-list-killed (&optional arg)
6239 "List all killed newsgroups in the group buffer.
6240 If ARG is non-nil, list ALL killed groups known to Gnus. This may
6241 entail asking the server for the groups."
6243 ;; Find all possible killed newsgroups if arg.
6245 ;; First make sure active file has been read.
6246 (unless gnus-have-read-active-file
6247 (let ((gnus-read-active-file t))
6248 (gnus-read-active-file)))
6249 (or gnus-killed-hashtb (gnus-make-hashtable-from-killed))
6250 ;; Go through all newsgroups that are known to Gnus - enlarge kill list
6254 (group (symbol-name sym)))
6255 (if (or (null group)
6256 (gnus-gethash group gnus-killed-hashtb)
6257 (gnus-gethash group gnus-newsrc-hashtb))
6259 (let ((do-sub (gnus-matches-options-n group)))
6260 (if (or (eq do-sub 'subscribe) (eq do-sub 'ignore))
6262 (setq groups (1+ groups))
6263 (setq gnus-killed-list
6264 (cons group gnus-killed-list))
6265 (gnus-sethash group group gnus-killed-hashtb))))))
6266 gnus-active-hashtb))
6267 (if (not gnus-killed-list)
6268 (gnus-message 6 "No killed groups")
6269 (let (gnus-group-list-mode)
6270 (funcall gnus-group-prepare-function
6271 gnus-level-killed t gnus-level-killed))
6272 (goto-char (point-min)))
6273 (gnus-group-position-point))
6275 (defun gnus-group-list-zombies ()
6276 "List all zombie newsgroups in the group buffer."
6278 (if (not gnus-zombie-list)
6279 (gnus-message 6 "No zombie groups")
6280 (let (gnus-group-list-mode)
6281 (funcall gnus-group-prepare-function
6282 gnus-level-zombie t gnus-level-zombie))
6283 (goto-char (point-min)))
6284 (gnus-group-position-point))
6286 (defun gnus-group-list-active ()
6287 "List all groups that are available from the server(s)."
6289 ;; First we make sure that we have really read the active file.
6290 (unless gnus-have-read-active-file
6291 (let ((gnus-read-active-file t))
6292 (gnus-read-active-file)))
6293 ;; Find all groups and sort them.
6299 (and (symbol-value sym)
6300 (setq list (cons (symbol-name sym) list))))
6304 (buffer-read-only nil))
6307 (gnus-group-insert-group-line-info (pop groups)))
6308 (goto-char (point-min))))
6310 (defun gnus-activate-all-groups (level)
6311 "Activate absolutely all groups."
6312 (interactive (list 7))
6313 (let ((gnus-activate-level level)
6314 (gnus-activate-foreign-newsgroups level))
6315 (gnus-group-get-new-news)))
6317 (defun gnus-group-get-new-news (&optional arg)
6318 "Get newly arrived articles.
6319 If ARG is a number, it specifies which levels you are interested in
6320 re-scanning. If ARG is non-nil and not a number, this will force
6321 \"hard\" re-reading of the active files from all servers."
6323 (run-hooks 'gnus-get-new-news-hook)
6324 ;; We might read in new NoCeM messages here.
6325 (when (and gnus-use-nocem
6327 (gnus-nocem-scan-groups))
6328 ;; If ARG is not a number, then we read the active file.
6329 (when (and arg (not (numberp arg)))
6330 (let ((gnus-read-active-file t))
6331 (gnus-read-active-file))
6334 (setq arg (gnus-group-default-level arg t))
6335 (if (and gnus-read-active-file (not arg))
6337 (gnus-read-active-file)
6338 (gnus-get-unread-articles arg))
6339 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
6340 (gnus-get-unread-articles arg)))
6341 (run-hooks 'gnus-after-getting-new-news-hook)
6342 (gnus-group-list-groups))
6344 (defun gnus-group-get-new-news-this-group (&optional n)
6345 "Check for newly arrived news in the current group (and the N-1 next groups).
6346 The difference between N and the number of newsgroup checked is returned.
6347 If N is negative, this group and the N-1 previous groups will be checked."
6349 (let* ((groups (gnus-group-process-prefix n))
6350 (ret (if (numberp n) (- n (length groups)) 0))
6353 (setq group (car groups)
6354 groups (cdr groups))
6355 (gnus-group-remove-mark group)
6356 (unless (gnus-get-new-news-in-group group)
6358 (gnus-message 3 "%s error: %s" group (gnus-status-message group))))
6359 (when gnus-goto-next-group-when-activating
6360 (gnus-group-next-unread-group 1 t))
6361 (gnus-summary-position-point)
6364 (defun gnus-get-new-news-in-group (group)
6365 (when (and group (gnus-activate-group group 'scan))
6366 (gnus-get-unread-articles-in-group
6367 (gnus-get-info group) (gnus-active group) t)
6368 (gnus-close-group group)
6369 (when (gnus-group-goto-group group)
6370 (gnus-group-update-group-line))
6373 (defun gnus-group-fetch-faq (group &optional faq-dir)
6374 "Fetch the FAQ for the current group."
6377 (gnus-group-real-name (gnus-group-group-name))
6378 (cond (current-prefix-arg
6380 "Faq dir: " (and (listp gnus-group-faq-directory)
6381 gnus-group-faq-directory))))))
6383 (setq faq-dir (if (listp gnus-group-faq-directory)
6384 (car gnus-group-faq-directory)
6385 gnus-group-faq-directory)))
6386 (or group (error "No group name given"))
6387 (let ((file (concat (file-name-as-directory faq-dir)
6388 (gnus-group-real-name group))))
6389 (if (not (file-exists-p file))
6390 (error "No such file: %s" file)
6393 (defun gnus-group-describe-group (force &optional group)
6394 "Display a description of the current newsgroup."
6395 (interactive (list current-prefix-arg (gnus-group-group-name)))
6396 (and force (setq gnus-description-hashtb nil))
6397 (let ((method (gnus-find-method-for-group group))
6399 (or group (error "No group name given"))
6400 (and (or (and gnus-description-hashtb
6401 ;; We check whether this group's method has been
6402 ;; queried for a description file.
6404 (gnus-group-prefixed-name "" method)
6405 gnus-description-hashtb))
6406 (setq desc (gnus-group-get-description group))
6407 (gnus-read-descriptions-file method))
6409 (or desc (gnus-gethash group gnus-description-hashtb)
6410 "No description available")))))
6412 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6413 (defun gnus-group-describe-all-groups (&optional force)
6414 "Pop up a buffer with descriptions of all newsgroups."
6416 (and force (setq gnus-description-hashtb nil))
6417 (if (not (or gnus-description-hashtb
6418 (gnus-read-all-descriptions-files)))
6419 (error "Couldn't request descriptions file"))
6420 (let ((buffer-read-only nil)
6426 (insert (format " *: %-20s %s\n" (symbol-name group)
6427 (symbol-value group)))
6428 (add-text-properties
6429 b (1+ b) (list 'gnus-group group
6430 'gnus-unread t 'gnus-marked nil
6431 'gnus-level (1+ gnus-level-subscribed))))
6432 gnus-description-hashtb)
6433 (goto-char (point-min))
6434 (gnus-group-position-point)))
6436 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
6437 (defun gnus-group-apropos (regexp &optional search-description)
6438 "List all newsgroups that have names that match a regexp."
6439 (interactive "sGnus apropos (regexp): ")
6441 (obuf (current-buffer))
6443 ;; Go through all newsgroups that are known to Gnus.
6446 (and (symbol-name group)
6447 (string-match regexp (symbol-name group))
6448 (setq groups (cons (symbol-name group) groups))))
6450 ;; Also go through all descriptions that are known to Gnus.
6451 (when search-description
6454 (and (string-match regexp (symbol-value group))
6455 (gnus-active (symbol-name group))
6456 (setq groups (cons (symbol-name group) groups))))
6457 gnus-description-hashtb))
6459 (gnus-message 3 "No groups matched \"%s\"." regexp)
6460 ;; Print out all the groups.
6462 (pop-to-buffer "*Gnus Help*")
6463 (buffer-disable-undo (current-buffer))
6465 (setq groups (sort groups 'string<))
6467 ;; Groups may be entered twice into the list of groups.
6468 (if (not (string= (car groups) prev))
6470 (insert (setq prev (car groups)) "\n")
6471 (if (and gnus-description-hashtb
6472 (setq des (gnus-gethash (car groups)
6473 gnus-description-hashtb)))
6474 (insert " " des "\n"))))
6475 (setq groups (cdr groups)))
6476 (goto-char (point-min))))
6477 (pop-to-buffer obuf)))
6479 (defun gnus-group-description-apropos (regexp)
6480 "List all newsgroups that have names or descriptions that match a regexp."
6481 (interactive "sGnus description apropos (regexp): ")
6482 (if (not (or gnus-description-hashtb
6483 (gnus-read-all-descriptions-files)))
6484 (error "Couldn't request descriptions file"))
6485 (gnus-group-apropos regexp t))
6487 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6488 (defun gnus-group-list-matching (level regexp &optional all lowest)
6489 "List all groups with unread articles that match REGEXP.
6490 If the prefix LEVEL is non-nil, it should be a number that says which
6491 level to cut off listing groups.
6492 If ALL, also list groups with no unread articles.
6493 If LOWEST, don't list groups with level lower than LOWEST."
6494 (interactive "P\nsList newsgroups matching: ")
6495 (gnus-group-prepare-flat (or level gnus-level-subscribed)
6496 all (or lowest 1) regexp)
6497 (goto-char (point-min))
6498 (gnus-group-position-point))
6500 (defun gnus-group-list-all-matching (level regexp &optional lowest)
6501 "List all groups that match REGEXP.
6502 If the prefix LEVEL is non-nil, it should be a number that says which
6503 level to cut off listing groups.
6504 If LOWEST, don't list groups with level lower than LOWEST."
6505 (interactive "P\nsList newsgroups matching: ")
6506 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
6508 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
6509 (defun gnus-group-save-newsrc (&optional force)
6510 "Save the Gnus startup files.
6511 If FORCE, force saving whether it is necessary or not."
6513 (gnus-save-newsrc-file force))
6515 (defun gnus-group-restart (&optional arg)
6516 "Force Gnus to read the .newsrc file."
6518 (when (gnus-yes-or-no-p
6519 (format "Are you sure you want to read %s? "
6520 gnus-current-startup-file))
6521 (gnus-save-newsrc-file)
6522 (gnus-setup-news 'force)
6523 (gnus-group-list-groups arg)))
6525 (defun gnus-group-read-init-file ()
6526 "Read the Gnus elisp init file."
6528 (gnus-read-init-file))
6530 (defun gnus-group-check-bogus-groups (&optional silent)
6531 "Check bogus newsgroups.
6532 If given a prefix, don't ask for confirmation before removing a bogus
6535 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
6536 (gnus-group-list-groups))
6538 (defun gnus-group-edit-global-kill (&optional article group)
6539 "Edit the global kill file.
6540 If GROUP, edit that local kill file instead."
6542 (setq gnus-current-kill-article article)
6543 (gnus-kill-file-edit-file group)
6546 (substitute-command-keys
6547 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
6548 (if group "local" "global")))))
6550 (defun gnus-group-edit-local-kill (article group)
6551 "Edit a local kill file."
6552 (interactive (list nil (gnus-group-group-name)))
6553 (gnus-group-edit-global-kill article group))
6555 (defun gnus-group-force-update ()
6556 "Update `.newsrc' file."
6558 (gnus-save-newsrc-file))
6560 (defun gnus-group-suspend ()
6561 "Suspend the current Gnus session.
6562 In fact, cleanup buffers except for group mode buffer.
6563 The hook gnus-suspend-gnus-hook is called before actually suspending."
6565 (run-hooks 'gnus-suspend-gnus-hook)
6566 ;; Kill Gnus buffers except for group mode buffer.
6567 (let ((group-buf (get-buffer gnus-group-buffer)))
6568 ;; Do this on a separate list in case the user does a ^G before we finish
6569 (let ((gnus-buffer-list
6570 (delq group-buf (delq gnus-dribble-buffer
6571 (append gnus-buffer-list nil)))))
6572 (while gnus-buffer-list
6573 (gnus-kill-buffer (car gnus-buffer-list))
6574 (setq gnus-buffer-list (cdr gnus-buffer-list))))
6577 (setq gnus-buffer-list (list group-buf))
6578 (bury-buffer group-buf)
6579 (delete-windows-on group-buf t)))))
6581 (defun gnus-group-clear-dribble ()
6582 "Clear all information from the dribble buffer."
6584 (gnus-dribble-clear)
6585 (gnus-message 7 "Cleared dribble buffer"))
6587 (defun gnus-group-exit ()
6588 "Quit reading news after updating .newsrc.eld and .newsrc.
6589 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6592 (or noninteractive ;For gnus-batch-kill
6593 (not (gnus-server-opened gnus-select-method)) ;NNTP connection closed
6594 (not gnus-interactive-exit) ;Without confirmation
6596 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
6597 (run-hooks 'gnus-exit-gnus-hook)
6598 ;; Offer to save data from non-quitted summary buffers.
6599 (gnus-offer-save-summaries)
6600 ;; Save the newsrc file(s).
6601 (gnus-save-newsrc-file)
6603 (gnus-close-backends)
6604 ;; Reset everything.
6606 ;; Allow the user to do things after cleaning up.
6607 (run-hooks 'gnus-after-exiting-gnus-hook)))
6609 (defun gnus-close-backends ()
6610 ;; Send a close request to all backends that support such a request.
6611 (let ((methods gnus-valid-select-methods)
6614 (if (fboundp (setq func (intern (concat (caar methods)
6615 "-request-close"))))
6617 (setq methods (cdr methods)))))
6619 (defun gnus-group-quit ()
6620 "Quit reading news without updating .newsrc.eld or .newsrc.
6621 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6623 (when (or noninteractive ;For gnus-batch-kill
6624 (zerop (buffer-size))
6625 (not (gnus-server-opened gnus-select-method))
6627 (not gnus-current-startup-file)
6629 (format "Quit reading news without saving %s? "
6630 (file-name-nondirectory gnus-current-startup-file))))
6631 (run-hooks 'gnus-exit-gnus-hook)
6632 (if gnus-use-full-window
6633 (delete-other-windows)
6634 (gnus-remove-some-windows))
6636 (gnus-close-backends)
6638 ;; Allow the user to do things after cleaning up.
6639 (run-hooks 'gnus-after-exiting-gnus-hook)))
6641 (defun gnus-offer-save-summaries ()
6642 "Offer to save all active summary buffers."
6644 (let ((buflist (buffer-list))
6646 ;; Go through all buffers and find all summaries.
6648 (and (setq bufname (buffer-name (car buflist)))
6649 (string-match "Summary" bufname)
6651 (set-buffer bufname)
6652 ;; We check that this is, indeed, a summary buffer.
6653 (and (eq major-mode 'gnus-summary-mode)
6654 ;; Also make sure this isn't bogus.
6655 gnus-newsgroup-prepared))
6656 (push bufname buffers))
6657 (setq buflist (cdr buflist)))
6658 ;; Go through all these summary buffers and offer to save them.
6661 "Update summary buffer %s? "
6662 (lambda (buf) (set-buffer buf) (gnus-summary-exit))
6665 (defun gnus-group-describe-briefly ()
6666 "Give a one line description of the group mode commands."
6668 (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")))
6670 (defun gnus-group-browse-foreign-server (method)
6671 "Browse a foreign news server.
6672 If called interactively, this function will ask for a select method
6673 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
6674 If not, METHOD should be a list where the first element is the method
6675 and the second element is the address."
6677 (list (let ((how (completing-read
6679 (append gnus-valid-select-methods gnus-server-alist)
6680 nil t (cons "nntp" 0))))
6681 ;; We either got a backend name or a virtual server name.
6682 ;; If the first, we also need an address.
6683 (if (assoc how gnus-valid-select-methods)
6685 ;; Suggested by mapjph@bath.ac.uk.
6688 (mapcar (lambda (server) (list server))
6689 gnus-secondary-servers)))
6690 ;; We got a server name, so we find the method.
6691 (gnus-server-to-method how)))))
6692 (gnus-browse-foreign-server method))
6696 ;;; Gnus summary mode
6699 (defvar gnus-summary-mode-map nil)
6701 (put 'gnus-summary-mode 'mode-class 'special)
6703 (unless gnus-summary-mode-map
6704 (setq gnus-summary-mode-map (make-keymap))
6705 (suppress-keymap gnus-summary-mode-map)
6707 ;; Non-orthogonal keys
6709 (gnus-define-keys gnus-summary-mode-map
6710 " " gnus-summary-next-page
6711 "\177" gnus-summary-prev-page
6712 [delete] gnus-summary-prev-page
6713 "\r" gnus-summary-scroll-up
6714 "n" gnus-summary-next-unread-article
6715 "p" gnus-summary-prev-unread-article
6716 "N" gnus-summary-next-article
6717 "P" gnus-summary-prev-article
6718 "\M-\C-n" gnus-summary-next-same-subject
6719 "\M-\C-p" gnus-summary-prev-same-subject
6720 "\M-n" gnus-summary-next-unread-subject
6721 "\M-p" gnus-summary-prev-unread-subject
6722 "." gnus-summary-first-unread-article
6723 "," gnus-summary-best-unread-article
6724 "\M-s" gnus-summary-search-article-forward
6725 "\M-r" gnus-summary-search-article-backward
6726 "<" gnus-summary-beginning-of-article
6727 ">" gnus-summary-end-of-article
6728 "j" gnus-summary-goto-article
6729 "^" gnus-summary-refer-parent-article
6730 "\M-^" gnus-summary-refer-article
6731 "u" gnus-summary-tick-article-forward
6732 "!" gnus-summary-tick-article-forward
6733 "U" gnus-summary-tick-article-backward
6734 "d" gnus-summary-mark-as-read-forward
6735 "D" gnus-summary-mark-as-read-backward
6736 "E" gnus-summary-mark-as-expirable
6737 "\M-u" gnus-summary-clear-mark-forward
6738 "\M-U" gnus-summary-clear-mark-backward
6739 "k" gnus-summary-kill-same-subject-and-select
6740 "\C-k" gnus-summary-kill-same-subject
6741 "\M-\C-k" gnus-summary-kill-thread
6742 "\M-\C-l" gnus-summary-lower-thread
6743 "e" gnus-summary-edit-article
6744 "#" gnus-summary-mark-as-processable
6745 "\M-#" gnus-summary-unmark-as-processable
6746 "\M-\C-t" gnus-summary-toggle-threads
6747 "\M-\C-s" gnus-summary-show-thread
6748 "\M-\C-h" gnus-summary-hide-thread
6749 "\M-\C-f" gnus-summary-next-thread
6750 "\M-\C-b" gnus-summary-prev-thread
6751 "\M-\C-u" gnus-summary-up-thread
6752 "\M-\C-d" gnus-summary-down-thread
6753 "&" gnus-summary-execute-command
6754 "c" gnus-summary-catchup-and-exit
6755 "\C-w" gnus-summary-mark-region-as-read
6756 "\C-t" gnus-summary-toggle-truncation
6757 "?" gnus-summary-mark-as-dormant
6758 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
6759 "\C-c\C-s\C-n" gnus-summary-sort-by-number
6760 "\C-c\C-s\C-a" gnus-summary-sort-by-author
6761 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
6762 "\C-c\C-s\C-d" gnus-summary-sort-by-date
6763 "\C-c\C-s\C-i" gnus-summary-sort-by-score
6764 "=" gnus-summary-expand-window
6765 "\C-x\C-s" gnus-summary-reselect-current-group
6766 "\M-g" gnus-summary-rescan-group
6767 "w" gnus-summary-stop-page-breaking
6768 "\C-c\C-r" gnus-summary-caesar-message
6769 "\M-t" gnus-summary-toggle-mime
6770 "f" gnus-summary-followup
6771 "F" gnus-summary-followup-with-original
6772 "C" gnus-summary-cancel-article
6773 "r" gnus-summary-reply
6774 "R" gnus-summary-reply-with-original
6775 "\C-c\C-f" gnus-summary-mail-forward
6776 "o" gnus-summary-save-article
6777 "\C-o" gnus-summary-save-article-mail
6778 "|" gnus-summary-pipe-output
6779 "\M-k" gnus-summary-edit-local-kill
6780 "\M-K" gnus-summary-edit-global-kill
6782 "\C-c\C-d" gnus-summary-describe-group
6783 "q" gnus-summary-exit
6784 "Q" gnus-summary-exit-no-update
6785 "\C-c\C-i" gnus-info-find-node
6786 gnus-mouse-2 gnus-mouse-pick-article
6787 "m" gnus-summary-mail-other-window
6788 "a" gnus-summary-post-news
6789 "x" gnus-summary-limit-to-unread
6790 "s" gnus-summary-isearch-article
6791 "t" gnus-article-hide-headers
6792 "g" gnus-summary-show-article
6793 "l" gnus-summary-goto-last-article
6794 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
6795 "\C-d" gnus-summary-enter-digest-group
6797 "*" gnus-cache-enter-article
6798 "\M-*" gnus-cache-remove-article
6799 "\M-&" gnus-summary-universal-argument
6800 "\C-l" gnus-recenter
6801 "I" gnus-summary-increase-score
6802 "L" gnus-summary-lower-score
6804 "V" gnus-summary-score-map
6805 "X" gnus-uu-extract-map
6806 "S" gnus-summary-send-map)
6808 ;; Sort of orthogonal keymap
6809 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
6810 "t" gnus-summary-tick-article-forward
6811 "!" gnus-summary-tick-article-forward
6812 "d" gnus-summary-mark-as-read-forward
6813 "r" gnus-summary-mark-as-read-forward
6814 "c" gnus-summary-clear-mark-forward
6815 " " gnus-summary-clear-mark-forward
6816 "e" gnus-summary-mark-as-expirable
6817 "x" gnus-summary-mark-as-expirable
6818 "?" gnus-summary-mark-as-dormant
6819 "b" gnus-summary-set-bookmark
6820 "B" gnus-summary-remove-bookmark
6821 "#" gnus-summary-mark-as-processable
6822 "\M-#" gnus-summary-unmark-as-processable
6823 "S" gnus-summary-limit-include-expunged
6824 "C" gnus-summary-catchup
6825 "H" gnus-summary-catchup-to-here
6826 "\C-c" gnus-summary-catchup-all
6827 "k" gnus-summary-kill-same-subject-and-select
6828 "K" gnus-summary-kill-same-subject
6829 "P" gnus-uu-mark-map)
6831 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mode-map)
6832 "c" gnus-summary-clear-above
6833 "u" gnus-summary-tick-above
6834 "m" gnus-summary-mark-above
6835 "k" gnus-summary-kill-below)
6837 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
6838 "/" gnus-summary-limit-to-subject
6839 "n" gnus-summary-limit-to-articles
6840 "w" gnus-summary-pop-limit
6841 "s" gnus-summary-limit-to-subject
6842 "a" gnus-summary-limit-to-author
6843 "u" gnus-summary-limit-to-unread
6844 "m" gnus-summary-limit-to-marks
6845 "v" gnus-summary-limit-to-score
6846 "D" gnus-summary-limit-include-dormant
6847 "d" gnus-summary-limit-exclude-dormant
6848 ;; "t" gnus-summary-limit-exclude-thread
6849 "E" gnus-summary-limit-include-expunged
6850 "c" gnus-summary-limit-exclude-childless-dormant
6851 "C" gnus-summary-limit-mark-excluded-as-read)
6853 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
6854 "n" gnus-summary-next-unread-article
6855 "p" gnus-summary-prev-unread-article
6856 "N" gnus-summary-next-article
6857 "P" gnus-summary-prev-article
6858 "\C-n" gnus-summary-next-same-subject
6859 "\C-p" gnus-summary-prev-same-subject
6860 "\M-n" gnus-summary-next-unread-subject
6861 "\M-p" gnus-summary-prev-unread-subject
6862 "f" gnus-summary-first-unread-article
6863 "b" gnus-summary-best-unread-article
6864 "j" gnus-summary-goto-article
6865 "g" gnus-summary-goto-subject
6866 "l" gnus-summary-goto-last-article
6867 "p" gnus-summary-pop-article)
6869 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
6870 "k" gnus-summary-kill-thread
6871 "l" gnus-summary-lower-thread
6872 "i" gnus-summary-raise-thread
6873 "T" gnus-summary-toggle-threads
6874 "t" gnus-summary-rethread-current
6875 "^" gnus-summary-reparent-thread
6876 "s" gnus-summary-show-thread
6877 "S" gnus-summary-show-all-threads
6878 "h" gnus-summary-hide-thread
6879 "H" gnus-summary-hide-all-threads
6880 "n" gnus-summary-next-thread
6881 "p" gnus-summary-prev-thread
6882 "u" gnus-summary-up-thread
6883 "o" gnus-summary-top-thread
6884 "d" gnus-summary-down-thread
6885 "#" gnus-uu-mark-thread
6886 "\M-#" gnus-uu-unmark-thread)
6888 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
6889 "c" gnus-summary-catchup-and-exit
6890 "C" gnus-summary-catchup-all-and-exit
6891 "E" gnus-summary-exit-no-update
6892 "Q" gnus-summary-exit
6893 "Z" gnus-summary-exit
6894 "n" gnus-summary-catchup-and-goto-next-group
6895 "R" gnus-summary-reselect-current-group
6896 "G" gnus-summary-rescan-group
6897 "N" gnus-summary-next-group
6898 "P" gnus-summary-prev-group)
6900 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
6901 " " gnus-summary-next-page
6902 "n" gnus-summary-next-page
6903 "\177" gnus-summary-prev-page
6904 [delete] gnus-summary-prev-page
6905 "p" gnus-summary-prev-page
6906 "\r" gnus-summary-scroll-up
6907 "<" gnus-summary-beginning-of-article
6908 ">" gnus-summary-end-of-article
6909 "b" gnus-summary-beginning-of-article
6910 "e" gnus-summary-end-of-article
6911 "^" gnus-summary-refer-parent-article
6912 "r" gnus-summary-refer-parent-article
6913 "R" gnus-summary-refer-references
6914 "g" gnus-summary-show-article
6915 "s" gnus-summary-isearch-article)
6917 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
6918 "b" gnus-article-add-buttons
6919 "B" gnus-article-add-buttons-to-head
6920 "o" gnus-article-treat-overstrike
6921 ;; "w" gnus-article-word-wrap
6922 "w" gnus-article-fill-cited-article
6923 "c" gnus-article-remove-cr
6924 "L" gnus-article-remove-trailing-blank-lines
6925 "q" gnus-article-de-quoted-unreadable
6926 "f" gnus-article-display-x-face
6927 "l" gnus-summary-stop-page-breaking
6928 "r" gnus-summary-caesar-message
6929 "t" gnus-article-hide-headers
6930 "v" gnus-summary-verbose-headers
6931 "m" gnus-summary-toggle-mime)
6933 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
6934 "a" gnus-article-hide
6935 "h" gnus-article-hide-headers
6936 "b" gnus-article-hide-boring-headers
6937 "s" gnus-article-hide-signature
6938 "c" gnus-article-hide-citation
6939 "p" gnus-article-hide-pgp
6940 "\C-c" gnus-article-hide-citation-maybe)
6942 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
6943 "a" gnus-article-highlight
6944 "h" gnus-article-highlight-headers
6945 "c" gnus-article-highlight-citation
6946 "s" gnus-article-highlight-signature)
6948 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
6949 "z" gnus-article-date-ut
6950 "u" gnus-article-date-ut
6951 "l" gnus-article-date-local
6952 "e" gnus-article-date-lapsed
6953 "o" gnus-article-date-original)
6955 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
6957 "f" gnus-summary-fetch-faq
6958 "d" gnus-summary-describe-group
6959 "h" gnus-summary-describe-briefly
6960 "i" gnus-info-find-node)
6962 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
6963 "e" gnus-summary-expire-articles
6964 "\M-\C-e" gnus-summary-expire-articles-now
6965 "\177" gnus-summary-delete-article
6966 [delete] gnus-summary-delete-article
6967 "m" gnus-summary-move-article
6968 "r" gnus-summary-respool-article
6969 "w" gnus-summary-edit-article
6970 "c" gnus-summary-copy-article
6971 "B" gnus-summary-crosspost-article
6972 "q" gnus-summary-respool-query
6973 "i" gnus-summary-import-article)
6975 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
6976 "o" gnus-summary-save-article
6977 "m" gnus-summary-save-article-mail
6978 "r" gnus-summary-save-article-rmail
6979 "f" gnus-summary-save-article-file
6980 "b" gnus-summary-save-article-body-file
6981 "h" gnus-summary-save-article-folder
6982 "v" gnus-summary-save-article-vm
6983 "p" gnus-summary-pipe-output
6984 "s" gnus-soup-add-article)
6989 (defun gnus-summary-mode (&optional group)
6990 "Major mode for reading articles.
6992 All normal editing commands are switched off.
6993 \\<gnus-summary-mode-map>
6994 Each line in this buffer represents one article. To read an
6995 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
6996 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
6999 You can also post articles and send mail from this buffer. To
7000 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
7001 of an article, type `\\[gnus-summary-reply]'.
7003 There are approx. one gazillion commands you can execute in this
7004 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
7006 The following commands are available:
7008 \\{gnus-summary-mode-map}"
7010 (when (and menu-bar-mode
7011 (gnus-visual-p 'summary-menu 'menu))
7012 (gnus-summary-make-menu-bar))
7013 (kill-all-local-variables)
7014 (let ((locals gnus-summary-local-variables))
7016 (if (consp (car locals))
7018 (make-local-variable (caar locals))
7019 (set (caar locals) (eval (cdar locals))))
7020 (make-local-variable (car locals))
7021 (set (car locals) nil))
7022 (setq locals (cdr locals))))
7023 (gnus-make-thread-indent-array)
7024 (gnus-simplify-mode-line)
7025 (setq major-mode 'gnus-summary-mode)
7026 (setq mode-name "Summary")
7027 (make-local-variable 'minor-mode-alist)
7028 (use-local-map gnus-summary-mode-map)
7029 (buffer-disable-undo (current-buffer))
7030 (setq buffer-read-only t) ;Disable modification
7031 (setq truncate-lines t)
7032 (setq selective-display t)
7033 (setq selective-display-ellipses t) ;Display `...'
7034 (setq buffer-display-table gnus-summary-display-table)
7035 (setq gnus-newsgroup-name group)
7036 (run-hooks 'gnus-summary-mode-hook))
7038 (defun gnus-summary-make-display-table ()
7039 ;; Change the display table. Odd characters have a tendency to mess
7040 ;; up nicely formatted displays - we make all possible glyphs
7041 ;; display only a single character.
7043 ;; We start from the standard display table, if any.
7044 (setq gnus-summary-display-table
7045 (or (copy-sequence standard-display-table)
7046 (make-display-table)))
7047 ;; Nix out all the control chars...
7049 (while (>= (setq i (1- i)) 0)
7050 (aset gnus-summary-display-table i [??])))
7051 ;; ... but not newline and cr, of course. (cr is necessary for the
7052 ;; selective display).
7053 (aset gnus-summary-display-table ?\n nil)
7054 (aset gnus-summary-display-table ?\r nil)
7055 ;; We nix out any glyphs over 126 that are not set already.
7057 (while (>= (setq i (1- i)) 127)
7058 ;; Only modify if the entry is nil.
7059 (or (aref gnus-summary-display-table i)
7060 (aset gnus-summary-display-table i [??])))))
7062 (defun gnus-summary-clear-local-variables ()
7063 (let ((locals gnus-summary-local-variables))
7065 (if (consp (car locals))
7066 (and (vectorp (caar locals))
7067 (set (caar locals) nil))
7068 (and (vectorp (car locals))
7069 (set (car locals) nil)))
7070 (setq locals (cdr locals)))))
7072 ;; Summary data functions.
7074 (defmacro gnus-data-number (data)
7077 (defmacro gnus-data-set-number (data number)
7078 `(setcar ,data ,number))
7080 (defmacro gnus-data-mark (data)
7083 (defmacro gnus-data-set-mark (data mark)
7084 `(setcar (nthcdr 1 ,data) ,mark))
7086 (defmacro gnus-data-pos (data)
7089 (defmacro gnus-data-set-pos (data pos)
7090 `(setcar (nthcdr 2 ,data) ,pos))
7092 (defmacro gnus-data-header (data)
7095 (defmacro gnus-data-level (data)
7098 (defmacro gnus-data-unread-p (data)
7099 `(= (nth 1 ,data) gnus-unread-mark))
7101 (defmacro gnus-data-pseudo-p (data)
7102 `(consp (nth 3 ,data)))
7104 (defmacro gnus-data-find (number)
7105 `(assq ,number gnus-newsgroup-data))
7107 (defmacro gnus-data-find-list (number &optional data)
7108 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
7109 (memq (assq ,number bdata)
7112 (defmacro gnus-data-make (number mark pos header level)
7113 `(list ,number ,mark ,pos ,header ,level))
7115 (defun gnus-data-enter (after-article number mark pos header level offset)
7116 (let ((data (gnus-data-find-list after-article)))
7117 (or data (error "No such article: %d" after-article))
7118 (setcdr data (cons (gnus-data-make number mark pos header level)
7120 (setq gnus-newsgroup-data-reverse nil)
7121 (gnus-data-update-list (cddr data) offset)))
7123 (defun gnus-data-enter-list (after-article list &optional offset)
7125 (let ((data (and after-article (gnus-data-find-list after-article)))
7127 (or data (not after-article) (error "No such article: %d" after-article))
7128 ;; Find the last element in the list to be spliced into the main
7131 (setq list (cdr list)))
7134 (setcdr list gnus-newsgroup-data)
7135 (setq gnus-newsgroup-data ilist)
7136 (and offset (gnus-data-update-list (cdr list) offset)))
7137 (setcdr list (cdr data))
7139 (and offset (gnus-data-update-list (cdr data) offset)))
7140 (setq gnus-newsgroup-data-reverse nil))))
7142 (defun gnus-data-remove (article &optional offset)
7143 (let ((data gnus-newsgroup-data))
7144 (if (= (gnus-data-number (car data)) article)
7145 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
7146 gnus-newsgroup-data-reverse nil)
7148 (and (= (gnus-data-number (cadr data)) article)
7150 (setcdr data (cddr data))
7151 (and offset (gnus-data-update-list (cdr data) offset))
7153 gnus-newsgroup-data-reverse nil)))
7154 (setq data (cdr data))))))
7156 (defmacro gnus-data-list (backward)
7158 (or gnus-newsgroup-data-reverse
7159 (setq gnus-newsgroup-data-reverse
7160 (reverse gnus-newsgroup-data)))
7161 gnus-newsgroup-data))
7163 (defun gnus-data-update-list (data offset)
7164 "Add OFFSET to the POS of all data entries in DATA."
7166 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
7167 (setq data (cdr data))))
7169 (defun gnus-data-compute-positions ()
7170 "Compute the positions of all articles."
7171 (let ((data gnus-newsgroup-data)
7174 (when (setq pos (text-property-any
7175 (point-min) (point-max)
7176 'gnus-number (gnus-data-number (car data))))
7177 (gnus-data-set-pos (car data) (+ pos 3)))
7178 (setq data (cdr data)))))
7180 (defun gnus-summary-article-pseudo-p (article)
7181 "Say whether this article is a pseudo article or not."
7182 (not (vectorp (gnus-data-header (gnus-data-find article)))))
7184 (defun gnus-article-parent-p (number)
7185 "Say whether this article is a parent or not."
7186 (let ((data (gnus-data-find-list number)))
7187 (and (cdr data) ; There has to be an article after...
7188 (< (gnus-data-level (car data)) ; And it has to have a higher level.
7189 (gnus-data-level (nth 1 data))))))
7191 (defun gnus-article-children (number)
7192 "Return a list of all children to NUMBER."
7193 (let* ((data (gnus-data-find-list number))
7194 (level (gnus-data-level (car data)))
7196 (setq data (cdr data))
7198 (= (gnus-data-level (car data)) (1+ level)))
7199 (push (gnus-data-number (car data)) children)
7200 (setq data (cdr data)))
7203 (defmacro gnus-summary-skip-intangible ()
7204 "If the current article is intangible, then jump to a different article."
7205 '(let ((to (get-text-property (point) 'gnus-intangible)))
7206 (and to (gnus-summary-goto-subject to))))
7208 (defmacro gnus-summary-article-intangible-p ()
7209 "Say whether this article is intangible or not."
7210 '(get-text-property (point) 'gnus-intangible))
7212 ;; Some summary mode macros.
7214 (defmacro gnus-summary-article-number ()
7215 "The article number of the article on the current line.
7216 If there isn's an article number here, then we return the current
7219 (gnus-summary-skip-intangible)
7220 (or (get-text-property (point) 'gnus-number)
7221 (gnus-summary-last-subject))))
7223 (defmacro gnus-summary-article-header (&optional number)
7224 `(gnus-data-header (gnus-data-find
7225 ,(or number '(gnus-summary-article-number)))))
7227 (defmacro gnus-summary-thread-level (&optional number)
7228 `(if (and (eq gnus-summary-make-false-root 'dummy)
7229 (get-text-property (point) 'gnus-intangible))
7231 (gnus-data-level (gnus-data-find
7232 ,(or number '(gnus-summary-article-number))))))
7234 (defmacro gnus-summary-article-mark (&optional number)
7235 `(gnus-data-mark (gnus-data-find
7236 ,(or number '(gnus-summary-article-number)))))
7238 (defmacro gnus-summary-article-pos (&optional number)
7239 `(gnus-data-pos (gnus-data-find
7240 ,(or number '(gnus-summary-article-number)))))
7242 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
7243 (defmacro gnus-summary-article-subject (&optional number)
7244 "Return current subject string or nil if nothing."
7247 `(gnus-data-header (assq ,number gnus-newsgroup-data))
7248 '(gnus-data-header (assq (gnus-summary-article-number)
7249 gnus-newsgroup-data)))))
7252 (mail-header-subject headers))))
7254 (defmacro gnus-summary-article-score (&optional number)
7255 "Return current article score."
7256 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
7257 gnus-newsgroup-scored))
7258 gnus-summary-default-score 0))
7260 (defun gnus-summary-article-children (&optional number)
7261 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
7262 (level (gnus-data-level (car data)))
7264 (while (and (setq data (cdr data))
7265 (> (setq l (gnus-data-level (car data))) level))
7266 (and (= (1+ level) l)
7267 (setq children (cons (gnus-data-number (car data))
7269 (nreverse children)))
7271 (defun gnus-summary-article-parent (&optional number)
7272 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
7273 (gnus-data-list t)))
7274 (level (gnus-data-level (car data))))
7276 () ; This is a root.
7277 ;; We search until we find an article with a level less than
7278 ;; this one. That function has to be the parent.
7279 (while (and (setq data (cdr data))
7280 (not (< (gnus-data-level (car data)) level))))
7281 (and data (gnus-data-number (car data))))))
7283 (defun gnus-unread-mark-p (mark)
7284 "Say whether MARK is the unread mark."
7285 (= mark gnus-unread-mark))
7287 (defun gnus-read-mark-p (mark)
7288 "Say whether MARK is one of the marks that mark as read.
7289 This is all marks except unread, ticked, dormant, and expirable."
7290 (not (or (= mark gnus-unread-mark)
7291 (= mark gnus-ticked-mark)
7292 (= mark gnus-dormant-mark)
7293 (= mark gnus-expirable-mark))))
7295 ;; Various summary mode internalish functions.
7297 (defun gnus-mouse-pick-article (e)
7300 (gnus-summary-next-page nil t))
7302 (defun gnus-summary-setup-buffer (group)
7303 "Initialize summary buffer."
7304 (let ((buffer (concat "*Summary " group "*")))
7305 (if (get-buffer buffer)
7308 (setq gnus-summary-buffer (current-buffer))
7309 (not gnus-newsgroup-prepared))
7310 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
7311 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
7312 (gnus-add-current-to-buffer-list)
7313 (gnus-summary-mode group)
7315 (gnus-carpal-setup-buffer 'summary))
7316 (unless gnus-single-article-buffer
7317 (make-local-variable 'gnus-article-buffer)
7318 (make-local-variable 'gnus-article-current)
7319 (make-local-variable 'gnus-original-article-buffer))
7320 (setq gnus-newsgroup-name group)
7323 (defun gnus-set-global-variables ()
7324 ;; Set the global equivalents of the summary buffer-local variables
7325 ;; to the latest values they had. These reflect the summary buffer
7326 ;; that was in action when the last article was fetched.
7327 (when (eq major-mode 'gnus-summary-mode)
7328 (setq gnus-summary-buffer (current-buffer))
7329 (let ((name gnus-newsgroup-name)
7330 (marked gnus-newsgroup-marked)
7331 (unread gnus-newsgroup-unreads)
7332 (headers gnus-current-headers)
7333 (data gnus-newsgroup-data)
7334 (summary gnus-summary-buffer)
7335 (article-buffer gnus-article-buffer)
7336 (original gnus-original-article-buffer)
7337 (gac gnus-article-current)
7338 (score-file gnus-current-score-file))
7340 (set-buffer gnus-group-buffer)
7341 (setq gnus-newsgroup-name name)
7342 (setq gnus-newsgroup-marked marked)
7343 (setq gnus-newsgroup-unreads unread)
7344 (setq gnus-current-headers headers)
7345 (setq gnus-newsgroup-data data)
7346 (setq gnus-article-current gac)
7347 (setq gnus-summary-buffer summary)
7348 (setq gnus-article-buffer article-buffer)
7349 (setq gnus-original-article-buffer original)
7350 (setq gnus-current-score-file score-file)))))
7352 (defun gnus-summary-last-article-p (&optional article)
7353 "Return whether ARTICLE is the last article in the buffer."
7354 (if (not (setq article (or article (gnus-summary-article-number))))
7355 t ; All non-existant numbers are the last article. :-)
7356 (cdr (gnus-data-find-list article))))
7358 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
7359 "Insert a dummy root in the summary buffer."
7361 (add-text-properties
7362 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
7363 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
7365 (defvar gnus-thread-indent-array nil)
7366 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
7367 (defun gnus-make-thread-indent-array ()
7369 (unless (and gnus-thread-indent-array
7370 (= gnus-thread-indent-level gnus-thread-indent-array-level))
7371 (setq gnus-thread-indent-array (make-vector 201 "")
7372 gnus-thread-indent-array-level gnus-thread-indent-level)
7374 (aset gnus-thread-indent-array n
7375 (make-string (* n gnus-thread-indent-level) ? ))
7378 (defun gnus-summary-insert-line
7379 (gnus-tmp-header gnus-tmp-level gnus-tmp-current gnus-tmp-unread
7380 gnus-tmp-replied gnus-tmp-expirable gnus-tmp-subject-or-nil
7381 &optional gnus-tmp-dummy gnus-tmp-score gnus-tmp-process)
7382 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
7383 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
7384 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
7385 (gnus-tmp-score-char
7386 (if (or (null gnus-summary-default-score)
7387 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
7388 gnus-summary-zcore-fuzz)) ?
7389 (if (< gnus-tmp-score gnus-summary-default-score)
7390 gnus-score-below-mark gnus-score-over-mark)))
7391 (gnus-tmp-replied (cond (gnus-tmp-process gnus-process-mark)
7392 ((memq gnus-tmp-current gnus-newsgroup-cached)
7394 (gnus-tmp-replied gnus-replied-mark)
7395 ((memq gnus-tmp-current gnus-newsgroup-saved)
7397 (t gnus-unread-mark)))
7398 (gnus-tmp-from (mail-header-from gnus-tmp-header))
7401 ((string-match "(.+)" gnus-tmp-from)
7402 (substring gnus-tmp-from
7403 (1+ (match-beginning 0)) (1- (match-end 0))))
7404 ((string-match "<[^>]+> *$" gnus-tmp-from)
7405 (let ((beg (match-beginning 0)))
7406 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
7407 (substring gnus-tmp-from (1+ (match-beginning 0))
7408 (1- (match-end 0))))
7409 (substring gnus-tmp-from 0 beg))))
7411 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
7412 (gnus-tmp-number (mail-header-number gnus-tmp-header))
7413 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
7414 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
7415 (buffer-read-only nil))
7416 (when (string= gnus-tmp-name "")
7417 (setq gnus-tmp-name gnus-tmp-from))
7418 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
7421 (progn (eval gnus-summary-line-format-spec) (point))
7422 'gnus-number gnus-tmp-number)
7423 (when (gnus-visual-p 'summary-highlight 'highlight)
7425 (run-hooks 'gnus-summary-update-hook)
7428 (defun gnus-summary-update-line (&optional dont-update)
7429 ;; Update summary line after change.
7430 (when (and gnus-summary-default-score
7431 (not gnus-summary-inhibit-highlight))
7432 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
7433 (article (gnus-summary-article-number))
7434 (score (gnus-summary-article-score article)))
7436 (if (and gnus-summary-mark-below
7437 (< (gnus-summary-article-score)
7438 gnus-summary-mark-below))
7439 ;; This article has a low score, so we mark it as read.
7440 (when (memq article gnus-newsgroup-unreads)
7441 (gnus-summary-mark-article-as-read gnus-low-score-mark))
7442 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
7443 ;; This article was previously marked as read on account
7444 ;; of a low score, but now it has risen, so we mark it as
7446 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
7447 (gnus-summary-update-mark
7448 (if (or (null gnus-summary-default-score)
7449 (<= (abs (- score gnus-summary-default-score))
7450 gnus-summary-zcore-fuzz)) ?
7451 (if (< score gnus-summary-default-score)
7452 gnus-score-below-mark gnus-score-over-mark)) 'score))
7453 ;; Do visual highlighting.
7454 (when (gnus-visual-p 'summary-highlight 'highlight)
7455 (run-hooks 'gnus-summary-update-hook)))))
7457 (defvar gnus-tmp-new-adopts nil)
7459 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
7460 ;; Sum up all elements (and sub-elements) in a list.
7462 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
7464 ((and (consp thread) (cdr thread))
7467 'gnus-summary-number-of-articles-in-thread (cdr thread))))
7470 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
7473 (when (and level (zerop level) gnus-tmp-new-adopts)
7476 'gnus-summary-number-of-articles-in-thread
7477 gnus-tmp-new-adopts))))
7479 (if (> number 1) gnus-not-empty-thread-mark
7480 gnus-empty-thread-mark)
7483 (defun gnus-summary-set-local-parameters (group)
7484 "Go through the local params of GROUP and set all variable specs in that list."
7485 (let ((params (gnus-info-params (gnus-get-info group)))
7488 (setq elem (car params)
7489 params (cdr params))
7490 (and (consp elem) ; Has to be a cons.
7491 (consp (cdr elem)) ; The cdr has to be a list.
7492 (symbolp (car elem)) ; Has to be a symbol in there.
7493 (not (memq (car elem)
7494 '(quit-config to-address to-list to-group)))
7495 (progn ; So we set it.
7496 (make-local-variable (car elem))
7497 (set (car elem) (eval (nth 1 elem))))))))
7499 (defun gnus-summary-read-group (group &optional show-all no-article
7500 kill-buffer no-display)
7501 "Start reading news in newsgroup GROUP.
7502 If SHOW-ALL is non-nil, already read articles are also listed.
7503 If NO-ARTICLE is non-nil, no article is selected initially.
7504 If NO-DISPLAY, don't generate a summary buffer."
7505 (gnus-message 5 "Retrieving newsgroup: %s..." group)
7506 (let* ((new-group (gnus-summary-setup-buffer group))
7507 (quit-config (gnus-group-quit-config group))
7508 (did-select (and new-group (gnus-select-newsgroup group show-all))))
7510 ;; This summary buffer exists already, so we just select it.
7512 (gnus-set-global-variables)
7514 (gnus-kill-or-deaden-summary kill-buffer))
7515 (gnus-configure-windows 'summary 'force)
7516 (gnus-set-mode-line 'summary)
7517 (gnus-summary-position-point)
7520 ;; We couldn't select this group.
7522 (when (and (eq major-mode 'gnus-summary-mode)
7523 (not (equal (current-buffer) kill-buffer)))
7524 (kill-buffer (current-buffer))
7525 (if (not quit-config)
7527 (set-buffer gnus-group-buffer)
7528 (gnus-group-jump-to-group group)
7529 (gnus-group-next-unread-group 1))
7530 (if (not (buffer-name (car quit-config)))
7531 (gnus-configure-windows 'group 'force)
7532 (set-buffer (car quit-config))
7533 (and (eq major-mode 'gnus-summary-mode)
7534 (gnus-set-global-variables))
7535 (gnus-configure-windows (cdr quit-config)))))
7536 (gnus-message 3 "Can't select group")
7538 ;; The user did a `C-g' while prompting for number of articles,
7539 ;; so we exit this group.
7540 ((eq did-select 'quit)
7541 (and (eq major-mode 'gnus-summary-mode)
7542 (not (equal (current-buffer) kill-buffer))
7543 (kill-buffer (current-buffer)))
7545 (gnus-kill-or-deaden-summary kill-buffer))
7546 (if (not quit-config)
7548 (set-buffer gnus-group-buffer)
7549 (gnus-group-jump-to-group group)
7550 (gnus-group-next-unread-group 1)
7551 (gnus-configure-windows 'group 'force))
7552 (if (not (buffer-name (car quit-config)))
7553 (gnus-configure-windows 'group 'force)
7554 (set-buffer (car quit-config))
7555 (and (eq major-mode 'gnus-summary-mode)
7556 (gnus-set-global-variables))
7557 (gnus-configure-windows (cdr quit-config))))
7558 ;; Finally signal the quit.
7560 ;; The group was successfully selected.
7562 (gnus-set-global-variables)
7563 ;; Save the active value in effect when the group was entered.
7564 (setq gnus-newsgroup-active
7566 (gnus-active gnus-newsgroup-name)))
7567 ;; You can change the summary buffer in some way with this hook.
7568 (run-hooks 'gnus-select-group-hook)
7569 ;; Set any local variables in the group parameters.
7570 (gnus-summary-set-local-parameters gnus-newsgroup-name)
7571 (gnus-update-format-specifications)
7572 ;; Do score processing.
7573 (when gnus-use-scoring
7574 (gnus-possibly-score-headers))
7575 ;; Check whether to fill in the gaps in the threads.
7576 (when gnus-build-sparse-threads
7577 (gnus-build-sparse-threads))
7578 ;; Find the initial limit.
7580 (let ((gnus-newsgroup-dormant nil))
7581 (gnus-summary-initial-limit show-all))
7582 (gnus-summary-initial-limit show-all))
7583 ;; Generate the summary buffer.
7585 (gnus-summary-prepare))
7586 (when gnus-use-trees
7587 (gnus-tree-open group)
7588 (setq gnus-summary-highlight-line-function
7589 'gnus-tree-highlight-article))
7590 ;; If the summary buffer is empty, but there are some low-scored
7591 ;; articles or some excluded dormants, we include these in the
7593 (when (and (zerop (buffer-size))
7595 (cond (gnus-newsgroup-dormant
7596 (gnus-summary-limit-include-dormant))
7597 ((and gnus-newsgroup-scored show-all)
7598 (gnus-summary-limit-include-expunged))))
7599 ;; Function `gnus-apply-kill-file' must be called in this hook.
7600 (run-hooks 'gnus-apply-kill-hook)
7601 (if (and (zerop (buffer-size))
7604 ;; This newsgroup is empty.
7605 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
7606 (gnus-message 6 "No unread news")
7608 (gnus-kill-or-deaden-summary kill-buffer))
7609 ;; Return nil from this function.
7611 ;; Hide conversation thread subtrees. We cannot do this in
7612 ;; gnus-summary-prepare-hook since kill processing may not
7613 ;; work with hidden articles.
7614 (and gnus-show-threads
7615 gnus-thread-hide-subtree
7616 (gnus-summary-hide-all-threads))
7617 ;; Show first unread article if requested.
7618 (if (and (not no-article)
7620 gnus-newsgroup-unreads
7621 gnus-auto-select-first)
7622 (if (eq gnus-auto-select-first 'best)
7623 (gnus-summary-best-unread-article)
7624 (gnus-summary-first-unread-article))
7625 ;; Don't select any articles, just move point to the first
7626 ;; article in the group.
7627 (goto-char (point-min))
7628 (gnus-summary-position-point)
7629 (gnus-set-mode-line 'summary)
7630 (gnus-configure-windows 'summary 'force))
7631 ;; If we are in async mode, we send some info to the backend.
7632 (when gnus-newsgroup-async
7633 (gnus-request-asynchronous gnus-newsgroup-name gnus-newsgroup-data))
7635 (gnus-kill-or-deaden-summary kill-buffer))
7636 (when (get-buffer-window gnus-group-buffer t)
7637 ;; Gotta use windows, because recenter does wierd stuff if
7638 ;; the current buffer ain't the displayed window.
7639 (let ((owin (selected-window)))
7640 (select-window (get-buffer-window gnus-group-buffer t))
7641 (when (gnus-group-goto-group group)
7643 (select-window owin))))
7644 ;; Mark this buffer as "prepared".
7645 (setq gnus-newsgroup-prepared t)
7648 (defun gnus-summary-prepare ()
7649 "Generate the summary buffer."
7650 (let ((buffer-read-only nil))
7652 (setq gnus-newsgroup-data nil
7653 gnus-newsgroup-data-reverse nil)
7654 (run-hooks 'gnus-summary-generate-hook)
7655 ;; Generate the buffer, either with threads or without.
7656 (when gnus-newsgroup-headers
7657 (gnus-summary-prepare-threads
7658 (if gnus-show-threads
7659 (gnus-sort-gathered-threads
7660 (funcall gnus-summary-thread-gathering-function
7662 (gnus-cut-threads (gnus-make-threads)))))
7663 ;; Unthreaded display.
7664 (gnus-sort-articles gnus-newsgroup-headers))))
7665 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
7666 ;; Call hooks for modifying summary buffer.
7667 (goto-char (point-min))
7668 (run-hooks 'gnus-summary-prepare-hook)))
7670 (defun gnus-gather-threads-by-subject (threads)
7671 "Gather threads by looking at Subject headers."
7672 (if (not gnus-summary-make-false-root)
7674 (let ((hashtb (gnus-make-hashtable 1023))
7677 subject hthread whole-subject)
7679 (setq whole-subject (mail-header-subject (caar threads)))
7682 ;; Truncate the subject.
7683 ((numberp gnus-summary-gather-subject-limit)
7684 (setq subject (gnus-simplify-subject-re whole-subject))
7685 (if (> (length subject) gnus-summary-gather-subject-limit)
7686 (substring subject 0 gnus-summary-gather-subject-limit)
7688 ;; Fuzzily simplify it.
7689 ((eq 'fuzzy gnus-summary-gather-subject-limit)
7690 (gnus-simplify-subject-fuzzy whole-subject))
7691 ;; Just remove the leading "Re:".
7693 (gnus-simplify-subject-re whole-subject))))
7695 (if (and gnus-summary-gather-exclude-subject
7696 (string-match gnus-summary-gather-exclude-subject
7698 () ; We don't want to do anything with this article.
7699 ;; We simplify the subject before looking it up in the
7702 (if (setq hthread (gnus-gethash subject hashtb))
7704 ;; We enter a dummy root into the thread, if we
7705 ;; haven't done that already.
7706 (unless (stringp (caar hthread))
7707 (setcar hthread (list whole-subject (car hthread))))
7708 ;; We add this new gathered thread to this gathered
7710 (setcdr (car hthread)
7711 (nconc (cdar hthread) (list (car threads))))
7712 ;; Remove it from the list of threads.
7713 (setcdr prev (cdr threads))
7714 (setq threads prev))
7715 ;; Enter this thread into the hash table.
7716 (gnus-sethash subject threads hashtb)))
7718 (setq threads (cdr threads)))
7721 (defun gnus-gather-threads-by-references (threads)
7722 "Gather threads by looking at References headers."
7723 (let ((idhashtb (gnus-make-hashtable 1023))
7724 (thhashtb (gnus-make-hashtable 1023))
7727 ids references id gthread gid entered)
7729 (when (setq references (mail-header-references (caar threads)))
7730 (setq id (mail-header-id (caar threads)))
7731 (setq ids (gnus-split-references references))
7734 (if (not (setq gid (gnus-gethash (car ids) idhashtb)))
7736 (gnus-sethash (car ids) id idhashtb)
7737 (gnus-sethash id threads thhashtb))
7738 (setq gthread (gnus-gethash gid thhashtb))
7740 ;; We enter a dummy root into the thread, if we
7741 ;; haven't done that already.
7742 (unless (stringp (caar gthread))
7743 (setcar gthread (list (mail-header-subject (caar gthread))
7745 ;; We add this new gathered thread to this gathered
7747 (setcdr (car gthread)
7748 (nconc (cdar gthread) (list (car threads)))))
7749 ;; Add it into the thread hash table.
7750 (gnus-sethash id gthread thhashtb)
7752 ;; Remove it from the list of threads.
7753 (setcdr prev (cdr threads))
7754 (setq threads prev))
7755 (setq ids (cdr ids))))
7757 (setq threads (cdr threads)))
7760 (defun gnus-sort-gathered-threads (threads)
7761 "Sort subtreads inside each gathered thread by article number."
7762 (let ((result threads))
7764 (when (stringp (caar threads))
7765 (setcdr (car threads)
7766 (sort (cdar threads) 'gnus-thread-sort-by-number)))
7767 (setq threads (cdr threads)))
7770 (defun gnus-make-threads ()
7771 "Go through the dependency hashtb and find the roots. Return all threads."
7775 (unless (car (symbol-value refs))
7776 ;; These threads do not refer back to any other articles,
7777 ;; so they're roots.
7778 (setq threads (append (cdr (symbol-value refs)) threads))))
7779 gnus-newsgroup-dependencies)
7782 (defun gnus-build-sparse-threads ()
7783 (let ((headers gnus-newsgroup-headers)
7784 (deps gnus-newsgroup-dependencies)
7785 header references generation relations
7786 cthread subject child end pthread relation)
7787 ;; First we create an alist of generations/relations, where
7788 ;; generations is how much we trust the ralation, and the relation
7790 (gnus-message 7 "Making sparse threads...")
7792 (nnheader-set-temp-buffer " *gnus sparse threads*")
7793 (while (setq header (pop headers))
7794 (when (and (setq references (mail-header-references header))
7795 (not (string= references "")))
7797 (setq child (mail-header-id header)
7798 subject (mail-header-subject header))
7800 (while (search-backward ">" nil t)
7801 (setq end (1+ (point)))
7802 (when (search-backward "<" nil t)
7803 (push (list (incf generation)
7804 child (setq child (buffer-substring (point) end))
7807 (push (list (1+ generation) child nil subject) relations)
7809 (kill-buffer (current-buffer)))
7810 ;; Sort over trustworthiness.
7811 (setq relations (sort relations (lambda (r1 r2) (< (car r1) (car r2)))))
7812 (while (setq relation (pop relations))
7813 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
7814 (unless (car (symbol-value cthread))
7815 ;; Make this article the parent of these threads.
7816 (setcar (symbol-value cthread)
7817 (vector gnus-reffed-article-number
7821 (or (caddr relation) "") 0 0 "")))
7822 (set cthread (list (vector gnus-reffed-article-number
7824 "" "" (cadr relation)
7825 (or (caddr relation) "") 0 0 ""))))
7826 (push gnus-reffed-article-number gnus-newsgroup-limit)
7827 (push gnus-reffed-article-number gnus-newsgroup-sparse)
7828 (push (cons gnus-reffed-article-number gnus-sparse-mark)
7829 gnus-newsgroup-reads)
7830 (decf gnus-reffed-article-number)
7831 ;; Make this new thread the child of its parent.
7832 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
7833 (setcdr (symbol-value pthread)
7834 (nconc (cdr (symbol-value pthread))
7835 (list (symbol-value cthread))))
7836 (set pthread (list nil (symbol-value cthread))))))
7837 (gnus-message 7 "Making sparse threads...done")))
7839 (defun gnus-build-old-threads ()
7840 ;; Look at all the articles that refer back to old articles, and
7841 ;; fetch the headers for the articles that aren't there. This will
7842 ;; build complete threads - if the roots haven't been expired by the
7847 (when (not (car (symbol-value refs)))
7848 (setq heads (cdr (symbol-value refs)))
7850 (if (memq (mail-header-number (caar heads))
7851 gnus-newsgroup-dormant)
7852 (setq heads (cdr heads))
7853 (setq id (symbol-name refs))
7854 (while (and (setq id (gnus-build-get-header id))
7855 (not (car (gnus-gethash
7856 id gnus-newsgroup-dependencies)))))
7857 (setq heads nil)))))
7858 gnus-newsgroup-dependencies)))
7860 (defun gnus-build-get-header (id)
7861 ;; Look through the buffer of NOV lines and find the header to
7862 ;; ID. Enter this line into the dependencies hash table, and return
7863 ;; the id of the parent article (if any).
7864 (let ((deps gnus-newsgroup-dependencies)
7868 (set-buffer nntp-server-buffer)
7869 (goto-char (point-min))
7870 (while (and (not found) (search-forward id nil t))
7872 (setq found (looking-at
7873 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
7874 (regexp-quote id))))
7875 (or found (beginning-of-line 2)))
7879 (setq header (gnus-nov-parse-line
7880 (read (current-buffer)) deps))
7881 (gnus-parent-id (mail-header-references header)))))
7883 (let ((number (mail-header-number header)))
7884 (push number gnus-newsgroup-limit)
7885 (push header gnus-newsgroup-headers)
7886 (if (memq number gnus-newsgroup-unselected)
7888 (push number gnus-newsgroup-unreads)
7889 (setq gnus-newsgroup-unselected
7890 (delq number gnus-newsgroup-unselected)))
7891 (push number gnus-newsgroup-ancient)))))))
7893 (defun gnus-summary-update-article (article &optional header)
7894 "Update ARTICLE in the summary buffer."
7895 (set-buffer gnus-summary-buffer)
7896 (let* ((header (or header (gnus-summary-article-header article)))
7897 (id (mail-header-id header))
7898 (data (gnus-data-find article))
7899 (thread (gnus-id-to-thread id))
7901 (gnus-id-to-thread (or (gnus-parent-id
7902 (mail-header-references header))
7904 (buffer-read-only nil)
7906 (number (mail-header-number header))
7911 (delq thread parent))
7912 (if (gnus-summary-insert-subject id header)
7913 ;; Set the (possibly) new article number in the data structure.
7914 (gnus-data-set-number data (gnus-id-to-article id))
7918 (defun gnus-rebuild-thread (id)
7919 "Rebuild the thread containing ID."
7920 (let ((buffer-read-only nil)
7921 current thread data)
7922 (if (not gnus-show-threads)
7923 (setq thread (list (car (gnus-id-to-thread id))))
7924 ;; Get the thread this article is part of.
7925 (setq thread (gnus-remove-thread id)))
7926 (setq current (save-excursion
7927 (and (zerop (forward-line -1))
7928 (gnus-summary-article-number))))
7929 ;; If this is a gathered thread, we have to go some re-gathering.
7930 (when (stringp (car thread))
7931 (let ((subject (car thread))
7933 (setq thread (cdr thread))
7935 (unless (memq (setq thr (gnus-id-to-thread
7937 (mail-header-id (caar thread)))))
7940 (setq thread (cdr thread)))
7941 ;; We now have all (unique) roots.
7942 (if (= (length roots) 1)
7943 ;; All the loose roots are now one solid root.
7944 (setq thread (car roots))
7945 (setq thread (cons subject (gnus-sort-threads roots))))))
7947 ;; We then insert this thread into the summary buffer.
7948 (let (gnus-newsgroup-data gnus-newsgroup-threads)
7949 (gnus-summary-prepare-threads (list thread))
7950 (setq data (nreverse gnus-newsgroup-data))
7951 (setq threads gnus-newsgroup-threads))
7952 ;; We splice the new data into the data structure.
7953 (gnus-data-enter-list current data)
7954 (gnus-data-compute-positions)
7955 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
7957 (defun gnus-id-to-thread (id)
7958 "Return the (sub-)thread where ID appears."
7959 (gnus-gethash id gnus-newsgroup-dependencies))
7961 (defun gnus-id-to-article (id)
7962 "Return the article number of ID."
7963 (let ((thread (gnus-id-to-thread id)))
7965 (mail-header-number (car thread)))))
7967 (defun gnus-id-to-header (id)
7968 "Return the article headers of ID."
7969 (car (gnus-id-to-thread id)))
7971 (defun gnus-article-displayed-root-p (article)
7972 "Say whether ARTICLE is a root(ish) article."
7973 (let ((level (gnus-summary-thread-level article))
7979 (null (setq particle (gnus-id-to-article
7981 (mail-header-references
7982 (gnus-summary-article-header article))))))
7983 (null (gnus-summary-thread-level particle)))))))
7985 (defun gnus-root-id (id)
7986 "Return the id of the root of the thread where ID appears."
7988 (while (and id (setq prev (car (gnus-gethash
7989 id gnus-newsgroup-dependencies))))
7991 id (gnus-parent-id (mail-header-references prev))))
7994 (defun gnus-remove-thread (id &optional dont-remove)
7995 "Remove the thread that has ID in it."
7996 (let ((dep gnus-newsgroup-dependencies)
7997 headers thread last-id)
7998 ;; First go up in this thread until we find the root.
7999 (setq last-id (gnus-root-id id))
8000 (setq headers (list (car (gnus-id-to-thread last-id))
8001 (caadr (gnus-id-to-thread last-id))))
8002 ;; We have now found the real root of this thread. It might have
8003 ;; been gathered into some loose thread, so we have to search
8004 ;; through the threads to find the thread we wanted.
8005 (let ((threads gnus-newsgroup-threads)
8008 (setq sub (car threads))
8009 (if (stringp (car sub))
8010 ;; This is a gathered threads, so we look at the roots
8011 ;; below it to find whether this article in in this
8014 (setq sub (cdr sub))
8016 (when (member (caar sub) headers)
8017 (setq thread (car threads)
8020 (setq sub (cdr sub))))
8021 ;; It's an ordinary thread, so we check it.
8022 (when (eq (car sub) (car headers))
8025 (setq threads (cdr threads)))
8026 ;; If this article is in no thread, then it's a root.
8029 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
8030 (setq thread (gnus-gethash last-id dep)))
8033 thread ; We return this thread.
8035 (if (stringp (car thread))
8037 ;; If we use dummy roots, then we have to remove the
8038 ;; dummy root as well.
8039 (when (eq gnus-summary-make-false-root 'dummy)
8042 (setq thread (cdr thread))
8044 (gnus-remove-thread-1 (car thread))
8045 (setq thread (cdr thread))))
8046 (gnus-remove-thread-1 thread))))))))
8048 (defun gnus-remove-thread-1 (thread)
8049 "Remove the thread THREAD recursively."
8050 (let ((number (mail-header-number (car thread)))
8052 (when (setq pos (text-property-any
8053 (point-min) (point-max) 'gnus-number number))
8056 (gnus-data-remove number))
8057 (setq thread (cdr thread))
8059 (gnus-remove-thread-1 (pop thread)))))
8061 (defun gnus-sort-threads (threads)
8063 (if (not gnus-thread-sort-functions)
8065 (let ((func (if (= 1 (length gnus-thread-sort-functions))
8066 (car gnus-thread-sort-functions)
8068 ,(gnus-make-sort-function
8069 (reverse gnus-thread-sort-functions))))))
8070 (gnus-message 7 "Sorting threads...")
8073 (gnus-message 7 "Sorting threads...done")))))
8075 (defun gnus-sort-articles (articles)
8077 (when gnus-article-sort-functions
8078 (let ((func (if (= 1 (length gnus-article-sort-functions))
8079 (car gnus-article-sort-functions)
8081 ,(gnus-make-sort-function
8082 (reverse gnus-article-sort-functions))))))
8083 (gnus-message 7 "Sorting articles...")
8085 (setq gnus-newsgroup-headers (sort articles func))
8086 (gnus-message 7 "Sorting articles...done")))))
8088 (defun gnus-make-sort-function (funs)
8089 "Return a composite sort condition based on the functions in FUNC."
8091 `(or (,(car funs) t1 t2)
8092 (and (not (,(car funs) t2 t1))
8093 ,(gnus-make-sort-function (cdr funs))))
8094 `(,(car funs) t1 t2)))
8096 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
8097 (defmacro gnus-thread-header (thread)
8098 ;; Return header of first article in THREAD.
8099 ;; Note that THREAD must never, ever be anything else than a variable -
8100 ;; using some other form will lead to serious barfage.
8101 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
8102 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
8103 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
8106 (defsubst gnus-article-sort-by-number (h1 h2)
8107 "Sort articles by article number."
8108 (< (mail-header-number h1)
8109 (mail-header-number h2)))
8111 (defun gnus-thread-sort-by-number (h1 h2)
8112 "Sort threads by root article number."
8113 (gnus-article-sort-by-number
8114 (gnus-thread-header h1) (gnus-thread-header h2)))
8116 (defsubst gnus-article-sort-by-author (h1 h2)
8117 "Sort articles by root author."
8119 (let ((extract (funcall
8120 gnus-extract-address-components
8121 (mail-header-from h1))))
8122 (or (car extract) (cdr extract)))
8123 (let ((extract (funcall
8124 gnus-extract-address-components
8125 (mail-header-from h2))))
8126 (or (car extract) (cdr extract)))))
8128 (defun gnus-thread-sort-by-author (h1 h2)
8129 "Sort threads by root author."
8130 (gnus-article-sort-by-author
8131 (gnus-thread-header h1) (gnus-thread-header h2)))
8133 (defsubst gnus-article-sort-by-subject (h1 h2)
8134 "Sort articles by root subject."
8136 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
8137 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
8139 (defun gnus-thread-sort-by-subject (h1 h2)
8140 "Sort threads by root subject."
8141 (gnus-article-sort-by-subject
8142 (gnus-thread-header h1) (gnus-thread-header h2)))
8144 (defsubst gnus-article-sort-by-date (h1 h2)
8145 "Sort articles by root article date."
8147 (gnus-sortable-date (mail-header-date h1))
8148 (gnus-sortable-date (mail-header-date h2))))
8150 (defun gnus-thread-sort-by-date (h1 h2)
8151 "Sort threads by root article date."
8152 (gnus-article-sort-by-date
8153 (gnus-thread-header h1) (gnus-thread-header h2)))
8155 (defsubst gnus-article-sort-by-score (h1 h2)
8156 "Sort articles by root article score.
8157 Unscored articles will be counted as having a score of zero."
8158 (> (or (cdr (assq (mail-header-number h1)
8159 gnus-newsgroup-scored))
8160 gnus-summary-default-score 0)
8161 (or (cdr (assq (mail-header-number h2)
8162 gnus-newsgroup-scored))
8163 gnus-summary-default-score 0)))
8165 (defun gnus-thread-sort-by-score (h1 h2)
8166 "Sort threads by root article score."
8167 (gnus-article-sort-by-score
8168 (gnus-thread-header h1) (gnus-thread-header h2)))
8170 (defun gnus-thread-sort-by-total-score (h1 h2)
8171 "Sort threads by the sum of all scores in the thread.
8172 Unscored articles will be counted as having a score of zero."
8173 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
8175 (defun gnus-thread-total-score (thread)
8176 ;; This function find the total score of THREAD.
8178 (if (stringp (car thread))
8179 (apply gnus-thread-score-function 0
8180 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
8181 (gnus-thread-total-score-1 thread))
8182 (gnus-thread-total-score-1 (list thread))))
8184 (defun gnus-thread-total-score-1 (root)
8185 ;; This function find the total score of the thread below ROOT.
8186 (setq root (car root))
8187 (apply gnus-thread-score-function
8188 (or (cdr (assq (mail-header-number root) gnus-newsgroup-scored))
8189 gnus-summary-default-score 0)
8190 (mapcar 'gnus-thread-total-score
8191 (cdr (gnus-gethash (mail-header-id root)
8192 gnus-newsgroup-dependencies)))))
8194 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8195 (defvar gnus-tmp-prev-subject nil)
8196 (defvar gnus-tmp-false-parent nil)
8197 (defvar gnus-tmp-root-expunged nil)
8198 (defvar gnus-tmp-dummy-line nil)
8200 (defun gnus-summary-prepare-threads (threads)
8201 "Prepare summary buffer from THREADS and indentation LEVEL.
8202 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
8203 or a straight list of headers."
8204 (gnus-message 7 "Generating summary...")
8206 (setq gnus-newsgroup-threads threads)
8209 (let ((gnus-tmp-level 0)
8210 (default-score (or gnus-summary-default-score 0))
8211 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
8212 thread number subject stack state gnus-tmp-gathered beg-match
8213 new-roots gnus-tmp-new-adopts thread-end
8214 gnus-tmp-header gnus-tmp-unread
8215 gnus-tmp-replied gnus-tmp-subject-or-nil
8216 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
8217 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
8218 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
8220 (setq gnus-tmp-prev-subject nil)
8222 (if (vectorp (car threads))
8223 ;; If this is a straight (sic) list of headers, then a
8224 ;; threaded summary display isn't required, so we just create
8225 ;; an unthreaded one.
8226 (gnus-summary-prepare-unthreaded threads)
8228 ;; Do the threaded display.
8230 (while (or threads stack gnus-tmp-new-adopts new-roots)
8232 (if (and (= gnus-tmp-level 0)
8233 (not (setq gnus-tmp-dummy-line nil))
8236 (not gnus-tmp-false-parent)
8237 (or gnus-tmp-new-adopts new-roots))
8238 (if gnus-tmp-new-adopts
8239 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
8240 thread (list (car gnus-tmp-new-adopts))
8241 gnus-tmp-header (caar thread)
8242 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
8244 (setq thread (list (car new-roots))
8245 gnus-tmp-header (caar thread)
8246 new-roots (cdr new-roots))))
8249 ;; If there are some threads, we do them before the
8250 ;; threads on the stack.
8251 (setq thread threads
8252 gnus-tmp-header (caar thread))
8253 ;; There were no current threads, so we pop something off
8255 (setq state (car stack)
8256 gnus-tmp-level (car state)
8259 gnus-tmp-header (caar thread))))
8261 (setq gnus-tmp-false-parent nil)
8262 (setq gnus-tmp-root-expunged nil)
8263 (setq thread-end nil)
8265 (if (stringp gnus-tmp-header)
8266 ;; The header is a dummy root.
8268 ((eq gnus-summary-make-false-root 'adopt)
8269 ;; We let the first article adopt the rest.
8270 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
8272 (setq gnus-tmp-gathered
8274 (lambda (h) (mail-header-number (car h)))
8277 (setq thread (cons (list (caar thread)
8280 (setq gnus-tmp-level -1
8281 gnus-tmp-false-parent t))
8282 ((eq gnus-summary-make-false-root 'empty)
8283 ;; We print adopted articles with empty subject fields.
8284 (setq gnus-tmp-gathered
8286 (lambda (h) (mail-header-number (car h)))
8289 (setq gnus-tmp-level -1))
8290 ((eq gnus-summary-make-false-root 'dummy)
8291 ;; We remember that we probably want to output a dummy
8293 (setq gnus-tmp-dummy-line gnus-tmp-header)
8294 (setq gnus-tmp-prev-subject gnus-tmp-header))
8296 ;; We do not make a root for the gathered
8297 ;; sub-threads at all.
8298 (setq gnus-tmp-level -1)))
8300 (setq number (mail-header-number gnus-tmp-header)
8301 subject (mail-header-subject gnus-tmp-header))
8304 ;; If the thread has changed subject, we might want to make
8305 ;; this subthread into a root.
8306 ((and (null gnus-thread-ignore-subject)
8307 (not (zerop gnus-tmp-level))
8308 gnus-tmp-prev-subject
8310 (gnus-subject-equal gnus-tmp-prev-subject subject))))
8311 (setq new-roots (nconc new-roots (list (car thread)))
8313 gnus-tmp-header nil))
8314 ;; If the article lies outside the current limit,
8315 ;; then we do not display it.
8316 ((and (not (memq number gnus-newsgroup-limit))
8317 (not gnus-tmp-dummy-line))
8318 (setq gnus-tmp-gathered
8320 (lambda (h) (mail-header-number (car h)))
8323 (setq gnus-tmp-new-adopts (if (cdar thread)
8324 (append gnus-tmp-new-adopts
8326 gnus-tmp-new-adopts)
8328 gnus-tmp-header nil)
8329 (when (zerop gnus-tmp-level)
8330 (setq gnus-tmp-root-expunged t)))
8331 ;; Perhaps this article is to be marked as read?
8332 ((and gnus-summary-mark-below
8333 (< (or (cdr (assq number gnus-newsgroup-scored))
8335 gnus-summary-mark-below)
8336 ;; Don't touch sparse articles.
8337 (not (memq number gnus-newsgroup-sparse)))
8338 (setq gnus-newsgroup-unreads
8339 (delq number gnus-newsgroup-unreads))
8340 (if gnus-newsgroup-auto-expire
8341 (push number gnus-newsgroup-expirable)
8342 (push (cons number gnus-low-score-mark)
8343 gnus-newsgroup-reads))))
8345 (when gnus-tmp-header
8346 ;; We may have an old dummy line to output before this
8348 (when gnus-tmp-dummy-line
8349 (gnus-summary-insert-dummy-line
8350 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
8351 (setq gnus-tmp-dummy-line nil))
8353 ;; Compute the mark.
8357 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8358 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8359 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8360 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8361 (t (or (cdr (assq number gnus-newsgroup-reads))
8362 gnus-ancient-mark))))
8364 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
8365 gnus-tmp-header gnus-tmp-level)
8366 gnus-newsgroup-data)
8368 ;; Actually insert the line.
8370 gnus-tmp-subject-or-nil
8372 ((and gnus-thread-ignore-subject
8373 gnus-tmp-prev-subject
8374 (not (inline (gnus-subject-equal
8375 gnus-tmp-prev-subject subject))))
8377 ((zerop gnus-tmp-level)
8378 (if (and (eq gnus-summary-make-false-root 'empty)
8379 (memq number gnus-tmp-gathered)
8380 gnus-tmp-prev-subject
8381 (inline (gnus-subject-equal
8382 gnus-tmp-prev-subject subject)))
8383 gnus-summary-same-subject
8385 (t gnus-summary-same-subject)))
8386 (if (and (eq gnus-summary-make-false-root 'adopt)
8387 (= gnus-tmp-level 1)
8388 (memq number gnus-tmp-gathered))
8389 (setq gnus-tmp-opening-bracket ?\<
8390 gnus-tmp-closing-bracket ?\>)
8391 (setq gnus-tmp-opening-bracket ?\[
8392 gnus-tmp-closing-bracket ?\]))
8394 gnus-tmp-indentation
8395 (aref gnus-thread-indent-array gnus-tmp-level)
8396 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
8397 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
8398 gnus-summary-default-score 0)
8400 (if (or (null gnus-summary-default-score)
8401 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
8402 gnus-summary-zcore-fuzz)) ?
8403 (if (< gnus-tmp-score gnus-summary-default-score)
8404 gnus-score-below-mark gnus-score-over-mark))
8406 (cond ((memq number gnus-newsgroup-processable)
8408 ((memq number gnus-newsgroup-cached)
8410 ((memq number gnus-newsgroup-replied)
8412 (t gnus-unread-mark))
8413 gnus-tmp-from (mail-header-from gnus-tmp-header)
8416 ((string-match "(.+)" gnus-tmp-from)
8417 (substring gnus-tmp-from
8418 (1+ (match-beginning 0)) (1- (match-end 0))))
8419 ((string-match "<[^>]+> *$" gnus-tmp-from)
8420 (setq beg-match (match-beginning 0))
8421 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
8422 (substring gnus-tmp-from (1+ (match-beginning 0))
8423 (1- (match-end 0))))
8424 (substring gnus-tmp-from 0 beg-match)))
8426 (when (string= gnus-tmp-name "")
8427 (setq gnus-tmp-name gnus-tmp-from))
8428 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
8431 (progn (eval gnus-summary-line-format-spec) (point))
8432 'gnus-number number)
8435 (run-hooks 'gnus-summary-update-hook)
8438 (setq gnus-tmp-prev-subject subject)))
8440 (when (nth 1 thread)
8441 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
8442 (incf gnus-tmp-level)
8443 (setq threads (if thread-end nil (cdar thread)))
8445 (setq gnus-tmp-level 0)))))
8446 (gnus-message 7 "Generating summary...done"))
8448 (defun gnus-summary-prepare-unthreaded (headers)
8449 "Generate an unthreaded summary buffer based on HEADERS."
8450 (let (header number mark)
8453 (setq header (car headers)
8454 headers (cdr headers)
8455 number (mail-header-number header))
8457 ;; We may have to root out some bad articles...
8458 (when (memq number gnus-newsgroup-limit)
8459 (when (and gnus-summary-mark-below
8460 (< (or (cdr (assq number gnus-newsgroup-scored))
8461 gnus-summary-default-score 0)
8462 gnus-summary-mark-below))
8463 (setq gnus-newsgroup-unreads
8464 (delq number gnus-newsgroup-unreads))
8465 (if gnus-newsgroup-auto-expire
8466 (push number gnus-newsgroup-expirable)
8467 (push (cons number gnus-low-score-mark)
8468 gnus-newsgroup-reads)))
8472 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8473 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8474 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8475 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8476 (t (or (cdr (assq number gnus-newsgroup-reads))
8477 gnus-ancient-mark))))
8478 (setq gnus-newsgroup-data
8479 (cons (gnus-data-make number mark (1+ (point)) header 0)
8480 gnus-newsgroup-data))
8481 (gnus-summary-insert-line
8482 header 0 nil mark (memq number gnus-newsgroup-replied)
8483 (memq number gnus-newsgroup-expirable)
8484 (mail-header-subject header) nil
8485 (cdr (assq number gnus-newsgroup-scored))
8486 (memq number gnus-newsgroup-processable))))))
8488 (defun gnus-select-newsgroup (group &optional read-all)
8489 "Select newsgroup GROUP.
8490 If READ-ALL is non-nil, all articles in the group are selected."
8491 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
8492 (info (nth 2 entry))
8493 articles fetched-articles cached)
8495 (or (gnus-check-server
8496 (setq gnus-current-select-method (gnus-find-method-for-group group)))
8497 (error "Couldn't open server"))
8499 (or (and entry (not (eq (car entry) t))) ; Either it's active...
8500 (gnus-activate-group group) ; Or we can activate it...
8501 (progn ; Or we bug out.
8502 (when (equal major-mode 'gnus-summary-mode)
8503 (kill-buffer (current-buffer)))
8504 (error "Couldn't request group %s: %s"
8505 group (gnus-status-message group))))
8507 (setq gnus-newsgroup-name group)
8508 (setq gnus-newsgroup-unselected nil)
8509 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
8511 (and gnus-asynchronous
8512 (gnus-check-backend-function
8513 'request-asynchronous gnus-newsgroup-name)
8514 (setq gnus-newsgroup-async
8515 (gnus-request-asynchronous gnus-newsgroup-name)))
8517 ;; Adjust and set lists of article marks.
8519 (gnus-adjust-marked-articles info))
8521 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8522 (when (gnus-virtual-group-p group)
8523 (setq cached gnus-newsgroup-cached))
8525 (setq gnus-newsgroup-unreads
8526 (gnus-set-difference
8527 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
8528 gnus-newsgroup-dormant))
8530 (setq gnus-newsgroup-processable nil)
8532 (setq articles (gnus-articles-to-read group read-all))
8536 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
8538 ((eq articles 0) nil)
8540 ;; Init the dependencies hash table.
8541 (setq gnus-newsgroup-dependencies
8542 (gnus-make-hashtable (length articles)))
8543 ;; Retrieve the headers and read them in.
8544 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8545 (setq gnus-newsgroup-headers
8547 (setq gnus-headers-retrieved-by
8548 (gnus-retrieve-headers
8549 articles gnus-newsgroup-name
8550 ;; We might want to fetch old headers, but
8551 ;; not if there is only 1 article.
8552 (and gnus-fetch-old-headers
8554 (not (eq gnus-fetch-old-headers 'some))
8555 (not (numberp gnus-fetch-old-headers)))
8556 (> (length articles) 1))))))
8557 (gnus-get-newsgroup-headers-xover articles)
8558 (gnus-get-newsgroup-headers)))
8559 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
8561 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8563 (setq gnus-newsgroup-cached cached))
8565 ;; Set the initial limit.
8566 (setq gnus-newsgroup-limit (copy-sequence articles))
8567 ;; Remove canceled articles from the list of unread articles.
8568 (setq gnus-newsgroup-unreads
8569 (gnus-set-sorted-intersection
8570 gnus-newsgroup-unreads
8571 (setq fetched-articles
8572 (mapcar (lambda (headers) (mail-header-number headers))
8573 gnus-newsgroup-headers))))
8574 ;; Removed marked articles that do not exist.
8575 (gnus-update-missing-marks
8576 (gnus-sorted-complement fetched-articles articles))
8577 ;; We might want to build some more threads first.
8578 (and gnus-fetch-old-headers
8579 (eq gnus-headers-retrieved-by 'nov)
8580 (gnus-build-old-threads))
8581 ;; Check whether auto-expire is to be done in this group.
8582 (setq gnus-newsgroup-auto-expire
8583 (gnus-group-auto-expirable-p group))
8584 ;; Set up the article buffer now, if necessary.
8585 (unless gnus-single-article-buffer
8586 (gnus-article-setup-buffer))
8587 ;; First and last article in this newsgroup.
8588 (and gnus-newsgroup-headers
8589 (setq gnus-newsgroup-begin
8590 (mail-header-number (car gnus-newsgroup-headers)))
8591 (setq gnus-newsgroup-end
8593 (gnus-last-element gnus-newsgroup-headers))))
8594 (setq gnus-reffed-article-number -1)
8595 ;; GROUP is successfully selected.
8596 (or gnus-newsgroup-headers t)))))
8598 (defun gnus-articles-to-read (group read-all)
8599 ;; Find out what articles the user wants to read.
8601 ;; Select all articles if `read-all' is non-nil, or if there
8602 ;; are no unread articles.
8604 (and (zerop (length gnus-newsgroup-marked))
8605 (zerop (length gnus-newsgroup-unreads))))
8606 (gnus-uncompress-range (gnus-active group))
8607 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
8608 (copy-sequence gnus-newsgroup-unreads))
8610 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
8611 (scored (length scored-list))
8612 (number (length articles))
8613 (marked (+ (length gnus-newsgroup-marked)
8614 (length gnus-newsgroup-dormant)))
8622 ((and (or (<= scored marked) (= scored number))
8623 (numberp gnus-large-newsgroup)
8624 (> number gnus-large-newsgroup))
8628 "How many articles from %s (default %d): "
8629 gnus-newsgroup-name number))))
8630 (if (string-match "^[ \t]*$" input) number input)))
8631 ((and (> scored marked) (< scored number))
8634 (format "%s %s (%d scored, %d total): "
8635 "How many articles from"
8636 group scored number))))
8637 (if (string-match "^[ \t]*$" input)
8641 (setq select (if (stringp select) (string-to-number select) select))
8642 (if (or (null select) (zerop select))
8644 (if (and (not (zerop scored)) (<= (abs select) scored))
8646 (setq articles (sort scored-list '<))
8647 (setq number (length articles)))
8648 (setq articles (copy-sequence articles)))
8650 (if (< (abs select) number)
8652 ;; Select the N oldest articles.
8653 (setcdr (nthcdr (1- (abs select)) articles) nil)
8654 ;; Select the N most recent articles.
8655 (setq articles (nthcdr (- number select) articles))))
8656 (setq gnus-newsgroup-unselected
8657 (gnus-sorted-intersection
8658 gnus-newsgroup-unreads
8659 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
8662 (defun gnus-killed-articles (killed articles)
8665 (if (inline (gnus-member-of-range (car articles) killed))
8666 (setq out (cons (car articles) out)))
8667 (setq articles (cdr articles)))
8670 (defun gnus-uncompress-marks (marks)
8671 "Uncompress the mark ranges in MARKS."
8672 (let ((uncompressed '(score bookmark))
8675 (if (memq (caar marks) uncompressed)
8676 (push (car marks) out)
8677 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
8678 (setq marks (cdr marks)))
8681 (defun gnus-adjust-marked-articles (info)
8682 "Set all article lists and remove all marks that are no longer legal."
8683 (let* ((marked-lists (gnus-info-marks info))
8684 (active (gnus-active (gnus-info-group info)))
8687 (types gnus-article-mark-lists)
8688 (uncompressed '(score bookmark))
8689 marks var articles article mark)
8692 (setq marks (pop marked-lists))
8693 (set (setq var (intern (format "gnus-newsgroup-%s"
8694 (car (rassq (setq mark (car marks))
8696 (if (memq (car marks) uncompressed) (cdr marks)
8697 (gnus-uncompress-range (cdr marks))))
8699 (setq articles (symbol-value var))
8701 ;; All articles have to be subsets of the active articles.
8703 ;; Adjust "simple" lists.
8704 ((memq mark '(tick dormant expirable reply killed save))
8706 (when (or (< (setq article (pop articles)) min) (> article max))
8707 (set var (delq article (symbol-value var))))))
8709 ((memq mark '(score bookmark))
8711 (when (or (< (car (setq article (pop articles))) min)
8712 (> (car article) max))
8713 (set var (delq article (symbol-value var))))))))))
8715 (defun gnus-update-missing-marks (missing)
8716 "Go through the list of MISSING articles and remove them mark lists."
8718 (let ((types gnus-article-mark-lists)
8720 ;; Go through all types.
8722 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
8723 (when (symbol-value var)
8724 ;; This list has articles. So we delete all missing articles
8728 (set var (delq (pop m) (symbol-value var)))))))))
8730 (defun gnus-update-marks ()
8731 "Enter the various lists of marked articles into the newsgroup info list."
8732 (let ((types gnus-article-mark-lists)
8733 (info (gnus-get-info gnus-newsgroup-name))
8734 (uncompressed '(score bookmark killed))
8735 type list newmarked symbol)
8737 ;; Add all marks lists that are non-nil to the list of marks lists.
8739 (setq type (pop types))
8740 (when (setq list (symbol-value
8742 (intern (format "gnus-newsgroup-%s"
8744 (push (cons (cdr type)
8745 (if (memq (cdr type) uncompressed) list
8746 (gnus-compress-sequence (set symbol (sort list '<)) t)))
8749 ;; Enter these new marks into the info of the group.
8751 (setcar (nthcdr 3 info) newmarked)
8752 ;; Add the marks lists to the end of the info.
8754 (setcdr (nthcdr 2 info) (list newmarked))))
8756 ;; Cut off the end of the info if there's nothing else there.
8760 (when (nthcdr (decf i) info)
8761 (setcdr (nthcdr i info) nil)))))))
8763 (defun gnus-add-marked-articles (group type articles &optional info force)
8764 ;; Add ARTICLES of TYPE to the info of GROUP.
8765 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
8766 ;; add, but replace marked articles of TYPE with ARTICLES.
8767 (let ((info (or info (gnus-get-info group)))
8768 (uncompressed '(score bookmark killed))
8771 (and (not (setq marked (nthcdr 3 info)))
8773 (setcdr (nthcdr 2 info)
8774 (list (list (cons type (gnus-compress-sequence
8776 (and (not (setq m (assq type (car marked))))
8779 (cons (cons type (gnus-compress-sequence articles t) )
8783 (setcar (nthcdr 3 info)
8784 (delq (assq type (car marked)) (car marked)))
8785 (setcdr m (gnus-compress-sequence articles t)))
8786 (setcdr m (gnus-compress-sequence
8787 (sort (nconc (gnus-uncompress-range (cdr m))
8788 (copy-sequence articles)) '<) t))))))
8790 (defun gnus-set-mode-line (where)
8791 "This function sets the mode line of the article or summary buffers.
8792 If WHERE is `summary', the summary mode line format will be used."
8793 ;; Is this mode line one we keep updated?
8794 (when (memq where gnus-updated-mode-lines)
8797 ;; We evaluate this in the summary buffer since these
8798 ;; variables are buffer-local to that buffer.
8799 (set-buffer gnus-summary-buffer)
8800 ;; We bind all these variables that are used in the `eval' form
8802 (let* ((mformat (symbol-value
8804 (format "gnus-%s-mode-line-format-spec" where))))
8805 (gnus-tmp-group-name gnus-newsgroup-name)
8806 (gnus-tmp-article-number (or gnus-current-article 0))
8807 (gnus-tmp-unread gnus-newsgroup-unreads)
8808 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
8809 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
8810 (gnus-tmp-unread-and-unselected
8811 (cond ((and (zerop gnus-tmp-unread-and-unticked)
8812 (zerop gnus-tmp-unselected)) "")
8813 ((zerop gnus-tmp-unselected)
8814 (format "{%d more}" gnus-tmp-unread-and-unticked))
8815 (t (format "{%d(+%d) more}"
8816 gnus-tmp-unread-and-unticked
8817 gnus-tmp-unselected))))
8819 (if (and gnus-current-headers
8820 (vectorp gnus-current-headers))
8821 (mail-header-subject gnus-current-headers) ""))
8823 gnus-tmp-header);; passed as argument to any user-format-funcs
8824 (setq mode-string (eval mformat))
8825 (setq max-len (max 4 (if gnus-mode-non-string-length
8827 gnus-mode-non-string-length)
8828 (length mode-string))))
8829 ;; We might have to chop a bit of the string off...
8830 (when (> (length mode-string) max-len)
8832 (concat (gnus-truncate-string mode-string (- max-len 3))
8834 ;; Pad the mode string a bit.
8835 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
8836 ;; Update the mode line.
8837 (setq mode-line-buffer-identification (list mode-string))
8838 (set-buffer-modified-p t))))
8840 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
8841 "Go through the HEADERS list and add all Xrefs to a hash table.
8842 The resulting hash table is returned, or nil if no Xrefs were found."
8843 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
8844 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
8845 (xref-hashtb (make-vector 63 0))
8846 start group entry number xrefs header)
8848 (setq header (pop headers))
8849 (when (and (setq xrefs (mail-header-xref header))
8850 (not (memq (setq number (mail-header-number header))
8853 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
8854 (setq start (match-end 0))
8855 (setq group (if prefix
8856 (concat prefix (substring xrefs (match-beginning 1)
8858 (substring xrefs (match-beginning 1) (match-end 1))))
8860 (string-to-int (substring xrefs (match-beginning 2)
8862 (if (setq entry (gnus-gethash group xref-hashtb))
8863 (setcdr entry (cons number (cdr entry)))
8864 (gnus-sethash group (cons number nil) xref-hashtb)))))
8865 (and start xref-hashtb)))
8867 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
8868 "Look through all the headers and mark the Xrefs as read."
8869 (let ((virtual (gnus-virtual-group-p from-newsgroup))
8870 name entry info xref-hashtb idlist method nth4)
8872 (set-buffer gnus-group-buffer)
8873 (when (setq xref-hashtb
8874 (gnus-create-xref-hashtb from-newsgroup headers unreads))
8877 (unless (string= from-newsgroup (setq name (symbol-name group)))
8878 (setq idlist (symbol-value group))
8879 ;; Dead groups are not updated.
8881 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
8883 (if (stringp (setq nth4 (gnus-info-method info)))
8884 (setq nth4 (gnus-server-to-method nth4))))
8885 ;; Only do the xrefs if the group has the same
8886 ;; select method as the group we have just read.
8887 (or (gnus-methods-equal-p
8888 nth4 (gnus-find-method-for-group from-newsgroup))
8890 (equal nth4 (setq method (gnus-find-method-for-group
8892 (and (equal (car nth4) (car method))
8893 (equal (nth 1 nth4) (nth 1 method))))
8894 gnus-use-cross-reference
8895 (or (not (eq gnus-use-cross-reference t))
8897 ;; Only do cross-references on subscribed
8898 ;; groups, if that is what is wanted.
8899 (<= (gnus-info-level info) gnus-level-subscribed))
8900 (gnus-group-make-articles-read name idlist))))
8903 (defun gnus-group-make-articles-read (group articles)
8905 (entry (gnus-gethash group gnus-newsrc-hashtb))
8906 (info (nth 2 entry))
8907 (active (gnus-active group))
8909 ;; First peel off all illegal article numbers.
8911 (let ((ids articles)
8915 (if (and first (> id (cdr active)))
8917 ;; We'll end up in this situation in one particular
8918 ;; obscure situation. If you re-scan a group and get
8919 ;; a new article that is cross-posted to a different
8920 ;; group that has not been re-scanned, you might get
8921 ;; crossposted article that has a higher number than
8922 ;; Gnus believes possible. So we re-activate this
8923 ;; group as well. This might mean doing the
8924 ;; crossposting thingy will *increase* the number
8925 ;; of articles in some groups. Tsk, tsk.
8926 (setq active (or (gnus-activate-group group) active))))
8927 (if (or (> id (cdr active))
8928 (< id (car active)))
8929 (setq articles (delq id articles)))
8930 (setq ids (cdr ids)))))
8931 ;; If the read list is nil, we init it.
8933 (null (gnus-info-read info))
8935 (gnus-info-set-read info (cons 1 (1- (car active)))))
8936 ;; Then we add the read articles to the range.
8941 (gnus-info-read info) (setq articles (sort articles '<)))))
8942 ;; Then we have to re-compute how many unread
8943 ;; articles there are in this group.
8948 (setq num (- (1+ (cdr active)) (car active))))
8949 ((not (listp (cdr range)))
8950 (setq num (- (cdr active) (- (1+ (cdr range))
8954 (if (numberp (car range))
8956 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
8957 (setq range (cdr range)))
8958 (setq num (- (cdr active) num))))
8959 ;; Update the number of unread articles.
8961 ;; Update the group buffer.
8962 (gnus-group-update-group group t)))))
8964 (defun gnus-methods-equal-p (m1 m2)
8965 (let ((m1 (or m1 gnus-select-method))
8966 (m2 (or m2 gnus-select-method)))
8968 (and (eq (car m1) (car m2))
8969 (or (not (memq 'address (assoc (symbol-name (car m1))
8970 gnus-valid-select-methods)))
8971 (equal (nth 1 m1) (nth 1 m2)))))))
8973 (defsubst gnus-header-value ()
8974 (buffer-substring (match-end 0) (gnus-point-at-eol)))
8976 (defvar gnus-newsgroup-none-id 0)
8978 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
8979 (let ((cur nntp-server-buffer)
8982 (save-excursion (set-buffer gnus-summary-buffer)
8983 gnus-newsgroup-dependencies)))
8984 headers id id-dep ref-dep end ref)
8986 (set-buffer nntp-server-buffer)
8987 (let ((case-fold-search t)
8988 in-reply-to header p lines)
8989 (goto-char (point-min))
8990 ;; Search to the beginning of the next header. Error messages
8991 ;; do not begin with 2 or 3.
8992 (while (re-search-forward "^[23][0-9]+ " nil t)
8995 ;; This implementation of this function, with nine
8996 ;; search-forwards instead of the one re-search-forward and
8997 ;; a case (which basically was the old function) is actually
8998 ;; about twice as fast, even though it looks messier. You
8999 ;; can't have everything, I guess. Speed and elegance
9000 ;; doesn't always go hand in hand.
9009 (narrow-to-region (point)
9010 (or (and (search-forward "\n.\n" nil t)
9016 (if (search-forward "\nsubject: " nil t)
9017 (gnus-header-value) "(none)"))
9021 (if (search-forward "\nfrom: " nil t)
9022 (gnus-header-value) "(nobody)"))
9026 (if (search-forward "\ndate: " nil t)
9027 (gnus-header-value) ""))
9031 (if (search-forward "\nmessage-id: " nil t)
9032 (setq id (gnus-header-value))
9033 ;; If there was no message-id, we just fake one to make
9034 ;; subsequent routines simpler.
9035 (setq id (concat "none+"
9037 (setq gnus-newsgroup-none-id
9038 (1+ gnus-newsgroup-none-id)))))))
9042 (if (search-forward "\nreferences: " nil t)
9045 (setq end (match-end 0))
9051 (search-backward ">" end t)
9054 (search-backward "<" end t)
9056 ;; Get the references from the in-reply-to header if there
9057 ;; were no references and the in-reply-to header looks
9059 (if (and (search-forward "\nin-reply-to: " nil t)
9060 (setq in-reply-to (gnus-header-value))
9061 (string-match "<[^>]+>" in-reply-to))
9062 (setq ref (substring in-reply-to (match-beginning 0)
9070 (if (search-forward "\nlines: " nil t)
9071 (if (numberp (setq lines (read cur)))
9077 (and (search-forward "\nxref: " nil t)
9078 (gnus-header-value)))))
9079 ;; We do the threading while we read the headers. The
9080 ;; message-id and the last reference are both entered into
9081 ;; the same hash table. Some tippy-toeing around has to be
9082 ;; done in case an article has arrived before the article
9083 ;; which it refers to.
9084 (if (boundp (setq id-dep (intern id dependencies)))
9085 (if (and (car (symbol-value id-dep))
9087 ;; An article with this Message-ID has already
9088 ;; been seen, so we ignore this one, except we add
9089 ;; any additional Xrefs (in case the two articles
9090 ;; came from different servers).
9092 (mail-header-set-xref
9093 (car (symbol-value id-dep))
9094 (concat (or (mail-header-xref
9095 (car (symbol-value id-dep))) "")
9096 (or (mail-header-xref header) "")))
9098 (setcar (symbol-value id-dep) header))
9099 (set id-dep (list header)))
9101 (if (boundp (setq ref-dep (intern ref dependencies)))
9102 (setcdr (symbol-value ref-dep)
9103 (nconc (cdr (symbol-value ref-dep))
9104 (list (symbol-value id-dep))))
9105 (set ref-dep (list nil (symbol-value id-dep))))
9106 (setq headers (cons header headers)))
9107 (goto-char (point-max))
9109 (nreverse headers)))))
9111 ;; The following macros and functions were written by Felix Lee
9112 ;; <flee@cse.psu.edu>.
9114 (defmacro gnus-nov-read-integer ()
9116 (if (= (following-char) ?\t)
9118 (let ((num (condition-case nil (read buffer) (error nil))))
9119 (if (numberp num) num 0)))
9120 (or (eobp) (forward-char 1))))
9122 (defmacro gnus-nov-skip-field ()
9123 '(search-forward "\t" eol 'move))
9125 (defmacro gnus-nov-field ()
9126 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
9128 ;; Goes through the xover lines and returns a list of vectors
9129 (defun gnus-get-newsgroup-headers-xover (sequence &optional force-new)
9130 "Parse the news overview data in the server buffer, and return a
9131 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
9132 ;; Get the Xref when the users reads the articles since most/some
9133 ;; NNTP servers do not include Xrefs when using XOVER.
9134 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
9135 (let ((cur nntp-server-buffer)
9136 (dependencies gnus-newsgroup-dependencies)
9137 number headers header)
9139 (set-buffer nntp-server-buffer)
9140 ;; Allow the user to mangle the headers before parsing them.
9141 (run-hooks 'gnus-parse-headers-hook)
9142 ;; Allow the user to mangle the headers before parsing them.
9143 (run-hooks 'gnus-parse-headers-hook)
9144 (goto-char (point-min))
9145 (while (and sequence (not (eobp)))
9146 (setq number (read cur))
9147 (while (and sequence (< (car sequence) number))
9148 (setq sequence (cdr sequence)))
9150 (eq number (car sequence))
9152 (setq sequence (cdr sequence))
9154 (inline (gnus-nov-parse-line
9155 number dependencies force-new)))
9156 (setq headers (cons header headers)))))
9158 (setq headers (nreverse headers)))
9161 ;; This function has to be called with point after the article number
9162 ;; on the beginning of the line.
9163 (defun gnus-nov-parse-line (number dependencies &optional force-new)
9165 (eol (gnus-point-at-eol))
9166 (buffer (current-buffer))
9167 header ref id id-dep ref-dep)
9169 ;; overview: [num subject from date id refs chars lines misc]
9170 (narrow-to-region (point) eol)
9171 (or (eobp) (forward-char))
9177 (gnus-nov-field) ; subject
9178 (gnus-nov-field) ; from
9179 (gnus-nov-field) ; date
9180 (setq id (or (gnus-nov-field)
9183 (setq none (1+ none)))))) ; id
9186 (let ((beg (point)))
9187 (search-forward "\t" eol)
9188 (if (search-backward ">" beg t)
9192 (search-backward "<" beg t)))
9194 (gnus-nov-field)) ; refs
9195 (gnus-nov-read-integer) ; chars
9196 (gnus-nov-read-integer) ; lines
9197 (if (= (following-char) ?\n)
9199 (gnus-nov-field)) ; misc
9203 (gnus-message 4 "Strange nov line")
9209 ;; We build the thread tree.
9211 (if (boundp (setq id-dep (intern id dependencies)))
9212 (if (and (car (symbol-value id-dep))
9214 ;; An article with this Message-ID has already been seen,
9215 ;; so we ignore this one, except we add any additional
9216 ;; Xrefs (in case the two articles came from different
9219 (mail-header-set-xref
9220 (car (symbol-value id-dep))
9221 (concat (or (mail-header-xref
9222 (car (symbol-value id-dep))) "")
9223 (or (mail-header-xref header) "")))
9225 (setcar (symbol-value id-dep) header))
9226 (set id-dep (list header))))
9229 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
9230 (setcdr (symbol-value ref-dep)
9231 (nconc (cdr (symbol-value ref-dep))
9232 (list (symbol-value id-dep))))
9233 (set ref-dep (list nil (symbol-value id-dep))))))
9236 (defun gnus-article-get-xrefs ()
9237 "Fill in the Xref value in `gnus-current-headers', if necessary.
9238 This is meant to be called in `gnus-article-internal-prepare-hook'."
9239 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
9240 gnus-current-headers)))
9241 (or (not gnus-use-cross-reference)
9243 (and (mail-header-xref headers)
9244 (not (string= (mail-header-xref headers) "")))
9245 (let ((case-fold-search t)
9248 (nnheader-narrow-to-headers)
9249 (goto-char (point-min))
9250 (if (or (and (eq (downcase (following-char)) ?x)
9251 (looking-at "Xref:"))
9252 (search-forward "\nXref:" nil t))
9254 (goto-char (1+ (match-end 0)))
9255 (setq xref (buffer-substring (point)
9256 (progn (end-of-line) (point))))
9257 (mail-header-set-xref headers xref))))))))
9259 (defun gnus-summary-insert-subject (id &optional old-header)
9260 "Find article ID and insert the summary line for that article."
9261 (let ((header (gnus-read-header id))
9262 (number (and (numberp id) id))
9265 ;; Rebuild the thread that this article is part of and go to the
9266 ;; article we have fetched.
9268 (when (setq pos (text-property-any
9269 (point-min) (point-max) 'gnus-number
9270 (mail-header-number old-header)))
9273 (gnus-data-remove (mail-header-number old-header))))
9274 (gnus-rebuild-thread (mail-header-id header))
9275 (gnus-summary-goto-subject (setq number (mail-header-number header))))
9276 (when (and (numberp number)
9278 ;; We have to update the boundaries even if we can't fetch the
9279 ;; article if ID is a number -- so that the next `P' or `N'
9280 ;; command will fetch the previous (or next) article even
9281 ;; if the one we tried to fetch this time has been canceled.
9282 (and (> number gnus-newsgroup-end)
9283 (setq gnus-newsgroup-end number))
9284 (and (< number gnus-newsgroup-begin)
9285 (setq gnus-newsgroup-begin number))
9286 (setq gnus-newsgroup-unselected
9287 (delq number gnus-newsgroup-unselected)))
9288 ;; Report back a success?
9289 (and header (mail-header-number header))))
9291 (defun gnus-summary-work-articles (n)
9292 "Return a list of articles to be worked upon. The prefix argument,
9293 the list of process marked articles, and the current article will be
9294 taken into consideration."
9296 ((and n (numberp n))
9297 ;; A numerical prefix has been given.
9298 (let ((backward (< n 0))
9304 (push (setq article (gnus-summary-article-number))
9307 (gnus-summary-find-prev nil article)
9308 (gnus-summary-find-next nil article)))
9310 (nreverse articles)))
9311 ((and (boundp 'transient-mark-mode)
9314 ;; Work on the region between point and mark.
9315 (let ((max (max (point) (mark)))
9318 (goto-char (min (point) (mark)))
9321 (push (setq article (gnus-summary-article-number)) articles)
9322 (gnus-summary-find-next nil article)
9324 (nreverse articles))))
9325 (gnus-newsgroup-processable
9326 ;; There are process-marked articles present.
9327 (reverse gnus-newsgroup-processable))
9329 ;; Just return the current article.
9330 (list (gnus-summary-article-number)))))
9332 (defun gnus-summary-search-group (&optional backward use-level)
9333 "Search for next unread newsgroup.
9334 If optional argument BACKWARD is non-nil, search backward instead."
9336 (set-buffer gnus-group-buffer)
9337 (if (gnus-group-search-forward
9338 backward nil (if use-level (gnus-group-group-level) nil))
9339 (gnus-group-group-name))))
9341 (defun gnus-summary-best-group (&optional exclude-group)
9342 "Find the name of the best unread group.
9343 If EXCLUDE-GROUP, do not go to this group."
9345 (set-buffer gnus-group-buffer)
9347 (gnus-group-best-unread-group exclude-group))))
9349 (defun gnus-summary-find-next (&optional unread article backward)
9350 (if backward (gnus-summary-find-prev)
9351 (let* ((article (or article (gnus-summary-article-number)))
9352 (arts (gnus-data-find-list article))
9354 (when (or (not gnus-summary-check-current)
9356 (not (gnus-data-unread-p (car arts))))
9357 (setq arts (cdr arts)))
9362 (when (gnus-data-unread-p (car arts))
9363 (setq result (car arts)
9365 (setq arts (cdr arts)))
9368 (goto-char (gnus-data-pos result))
9369 (gnus-data-number result)))))
9371 (defun gnus-summary-find-prev (&optional unread article)
9372 (let* ((article (or article (gnus-summary-article-number)))
9373 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
9375 (when (or (not gnus-summary-check-current)
9377 (not (gnus-data-unread-p (car arts))))
9378 (setq arts (cdr arts)))
9383 (and (gnus-data-unread-p (car arts))
9384 (setq result (car arts)
9386 (setq arts (cdr arts)))
9390 (goto-char (gnus-data-pos result))
9391 (gnus-data-number result)))))
9393 (defun gnus-summary-find-subject (subject &optional unread backward article)
9394 (let* ((simp-subject (gnus-simplify-subject-fully subject))
9395 (article (or article (gnus-summary-article-number)))
9396 (articles (gnus-data-list backward))
9397 (arts (gnus-data-find-list article articles))
9399 (when (or (not gnus-summary-check-current)
9401 (not (gnus-data-unread-p (car arts))))
9402 (setq arts (cdr arts)))
9404 (and (or (not unread)
9405 (gnus-data-unread-p (car arts)))
9406 (vectorp (gnus-data-header (car arts)))
9408 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
9409 (setq result (car arts)
9411 (setq arts (cdr arts)))
9413 (goto-char (gnus-data-pos result))
9414 (gnus-data-number result))))
9416 (defun gnus-summary-search-forward (&optional unread subject backward)
9417 "Search forward for an article.
9418 If UNREAD, look for unread articles. If SUBJECT, look for
9419 articles with that subject. If BACKWARD, search backward instead."
9420 (cond (subject (gnus-summary-find-subject subject unread backward))
9421 (backward (gnus-summary-find-prev unread))
9422 (t (gnus-summary-find-next unread))))
9424 (defun gnus-recenter (&optional n)
9425 "Center point in window and redisplay frame.
9426 Also do horizontal recentering."
9428 (when (and gnus-auto-center-summary
9429 (not (eq gnus-auto-center-summary 'vertical)))
9430 (gnus-horizontal-recenter))
9433 (defun gnus-summary-recenter ()
9434 "Center point in the summary window.
9435 If `gnus-auto-center-summary' is nil, or the article buffer isn't
9436 displayed, no centering will be performed."
9437 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
9438 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
9439 (let* ((top (cond ((< (window-height) 4) 0)
9440 ((< (window-height) 7) 1)
9442 (height (1- (window-height)))
9443 (bottom (save-excursion (goto-char (point-max))
9444 (forward-line (- height))
9446 (window (get-buffer-window (current-buffer))))
9447 ;; The user has to want it.
9448 (when gnus-auto-center-summary
9449 (when (get-buffer-window gnus-article-buffer)
9450 ;; Only do recentering when the article buffer is displayed,
9451 ;; Set the window start to either `bottom', which is the biggest
9452 ;; possible valid number, or the second line from the top,
9453 ;; whichever is the least.
9455 window (min bottom (save-excursion
9456 (forward-line (- top)) (point)))))
9457 ;; Do horizontal recentering while we're at it.
9458 (when (and (get-buffer-window (current-buffer) t)
9459 (not (eq gnus-auto-center-summary 'vertical)))
9460 (let ((selected (selected-window)))
9461 (select-window (get-buffer-window (current-buffer) t))
9462 (gnus-summary-position-point)
9463 (gnus-horizontal-recenter)
9464 (select-window selected))))))
9466 (defun gnus-horizontal-recenter ()
9467 "Recenter the current buffer horizontally."
9468 (if (< (current-column) (/ (window-width) 2))
9469 (set-window-hscroll (get-buffer-window (current-buffer) t) 0)
9470 (let* ((orig (point))
9471 (end (window-end (get-buffer-window (current-buffer) t)))
9473 ;; Find the longest line currently displayed in the window.
9474 (goto-char (window-start))
9475 (while (and (not (eobp))
9478 (setq max (max max (current-column)))
9481 ;; Scroll horizontally to center (sort of) the point.
9482 (if (> max (window-width))
9484 (get-buffer-window (current-buffer) t)
9485 (min (- (current-column) (/ (window-width) 3))
9486 (+ 2 (- max (window-width)))))
9487 (set-window-hscroll (get-buffer-window (current-buffer) t) 0))
9490 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
9491 (defun gnus-short-group-name (group &optional levels)
9492 "Collapse GROUP name LEVELS."
9499 (while (string-match "\\." group skip)
9500 (setq skip (match-end 0)
9503 (if (string-match ":" group)
9504 (setq foreign (substring group 0 (match-end 0))
9505 group (substring group (match-end 0))))
9507 (if (and (string-match "\\." group)
9508 (> levels (- gnus-group-uncollapsed-levels 1)))
9509 (setq name (concat name (substring group 0 1))
9510 group (substring group (match-end 0))
9512 name (concat name "."))
9513 (setq name (concat foreign name group)
9517 (defun gnus-summary-jump-to-group (newsgroup)
9518 "Move point to NEWSGROUP in group mode buffer."
9519 ;; Keep update point of group mode buffer if visible.
9520 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
9521 (save-window-excursion
9522 ;; Take care of tree window mode.
9523 (if (get-buffer-window gnus-group-buffer)
9524 (pop-to-buffer gnus-group-buffer))
9525 (gnus-group-jump-to-group newsgroup))
9527 ;; Take care of tree window mode.
9528 (if (get-buffer-window gnus-group-buffer)
9529 (pop-to-buffer gnus-group-buffer)
9530 (set-buffer gnus-group-buffer))
9531 (gnus-group-jump-to-group newsgroup))))
9533 ;; This function returns a list of article numbers based on the
9534 ;; difference between the ranges of read articles in this group and
9535 ;; the range of active articles.
9536 (defun gnus-list-of-unread-articles (group)
9537 (let* ((read (gnus-info-read (gnus-get-info group)))
9538 (active (gnus-active group))
9541 ;; If none are read, then all are unread.
9543 (setq first (car active))
9544 ;; If the range of read articles is a single range, then the
9545 ;; first unread article is the article after the last read
9546 ;; article. Sounds logical, doesn't it?
9547 (if (not (listp (cdr read)))
9548 (setq first (1+ (cdr read)))
9549 ;; `read' is a list of ranges.
9550 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
9555 (while (< first nlast)
9556 (setq unread (cons first unread))
9557 (setq first (1+ first))))
9558 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
9559 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
9560 (setq read (cdr read)))))
9561 ;; And add the last unread articles.
9562 (while (<= first last)
9563 (setq unread (cons first unread))
9564 (setq first (1+ first)))
9565 ;; Return the list of unread articles.
9568 (defun gnus-list-of-read-articles (group)
9569 "Return a list of unread, unticked and non-dormant articles."
9570 (let* ((info (gnus-get-info group))
9571 (marked (gnus-info-marks info))
9572 (active (gnus-active group)))
9574 (gnus-set-difference
9575 (gnus-sorted-complement
9576 (gnus-uncompress-range active)
9577 (gnus-list-of-unread-articles group))
9579 (gnus-uncompress-range (cdr (assq 'dormant marked)))
9580 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
9582 ;; Various summary commands
9584 (defun gnus-summary-universal-argument (arg)
9585 "Perform any operation on all articles that are process/prefixed."
9587 (gnus-set-global-variables)
9588 (let ((articles (gnus-summary-work-articles arg))
9595 (substitute-command-keys
9596 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
9600 (message "Undefined key")
9604 (gnus-summary-goto-subject (setq article (pop articles)))
9605 (command-execute func)
9606 (gnus-summary-remove-process-mark article)))))
9607 (gnus-summary-position-point))
9609 (defun gnus-summary-toggle-truncation (&optional arg)
9610 "Toggle truncation of summary lines.
9611 With arg, turn line truncation on iff arg is positive."
9613 (setq truncate-lines
9614 (if (null arg) (not truncate-lines)
9615 (> (prefix-numeric-value arg) 0)))
9618 (defun gnus-summary-reselect-current-group (&optional all rescan)
9619 "Exit and then reselect the current newsgroup.
9620 The prefix argument ALL means to select all articles."
9622 (gnus-set-global-variables)
9623 (let ((current-subject (gnus-summary-article-number))
9624 (group gnus-newsgroup-name))
9625 (setq gnus-newsgroup-begin nil)
9627 ;; We have to adjust the point of group mode buffer because the
9628 ;; current point was moved to the next unread newsgroup by
9630 (gnus-summary-jump-to-group group)
9633 (gnus-group-get-new-news-this-group 1)))
9634 (gnus-group-read-group all t)
9635 (gnus-summary-goto-subject current-subject)))
9637 (defun gnus-summary-rescan-group (&optional all)
9638 "Exit the newsgroup, ask for new articles, and select the newsgroup."
9640 (gnus-summary-reselect-current-group all t))
9642 (defun gnus-summary-update-info ()
9643 (let* ((group gnus-newsgroup-name))
9644 (when gnus-newsgroup-kill-headers
9645 (setq gnus-newsgroup-killed
9646 (gnus-compress-sequence
9648 (gnus-set-sorted-intersection
9649 (gnus-uncompress-range gnus-newsgroup-killed)
9650 (setq gnus-newsgroup-unselected
9651 (sort gnus-newsgroup-unselected '<)))
9652 (setq gnus-newsgroup-unreads
9653 (sort gnus-newsgroup-unreads '<))) t)))
9654 (unless (listp (cdr gnus-newsgroup-killed))
9655 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
9656 (let ((headers gnus-newsgroup-headers))
9657 (run-hooks 'gnus-exit-group-hook)
9658 (unless gnus-save-score
9659 (setq gnus-newsgroup-scored nil))
9660 ;; Set the new ranges of read articles.
9661 (gnus-update-read-articles
9662 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
9663 ;; Set the current article marks.
9665 ;; Do the cross-ref thing.
9666 (when gnus-use-cross-reference
9667 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
9668 ;; Do adaptive scoring, and possibly save score files.
9669 (when gnus-newsgroup-adaptive
9670 (gnus-score-adaptive))
9671 (when gnus-use-scoring
9673 ;; Do not switch windows but change the buffer to work.
9674 (set-buffer gnus-group-buffer)
9675 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
9676 (gnus-group-update-group group)))))
9678 (defun gnus-summary-exit (&optional temporary)
9679 "Exit reading current newsgroup, and then return to group selection mode.
9680 gnus-exit-group-hook is called with no arguments if that value is non-nil."
9682 (gnus-set-global-variables)
9683 (gnus-kill-save-kill-buffer)
9684 (let* ((group gnus-newsgroup-name)
9685 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
9687 (buf (current-buffer)))
9689 (run-hooks 'gnus-summary-prepare-exit-hook))
9690 ;; If we have several article buffers, we kill them at exit.
9691 (unless gnus-single-article-buffer
9692 (gnus-kill-buffer gnus-article-buffer)
9693 (gnus-kill-buffer gnus-original-article-buffer)
9694 (setq gnus-article-current nil))
9695 (when gnus-use-cache
9696 (gnus-cache-possibly-remove-articles)
9697 (gnus-cache-save-buffers))
9698 (when gnus-use-trees
9699 (gnus-tree-close group))
9700 ;; Make all changes in this group permanent.
9702 (gnus-summary-update-info))
9703 (gnus-close-group group)
9704 ;; Make sure where I was, and go to next newsgroup.
9705 (set-buffer gnus-group-buffer)
9707 (gnus-group-jump-to-group group)
9708 (gnus-group-next-unread-group 1))
9709 (run-hooks 'gnus-summary-exit-hook)
9710 (unless gnus-single-article-buffer
9711 (setq gnus-article-current nil))
9714 ;; If we have several article buffers, we kill them at exit.
9715 (unless gnus-single-article-buffer
9716 (gnus-kill-buffer gnus-article-buffer)
9717 (gnus-kill-buffer gnus-original-article-buffer)
9718 (setq gnus-article-current nil))
9720 (if (not gnus-kill-summary-on-exit)
9721 (gnus-deaden-summary)
9722 ;; We set all buffer-local variables to nil. It is unclear why
9723 ;; this is needed, but if we don't, buffer-local variables are
9724 ;; not garbage-collected, it seems. This would the lead to en
9725 ;; ever-growing Emacs.
9726 (gnus-summary-clear-local-variables)
9727 (when (get-buffer gnus-article-buffer)
9728 (bury-buffer gnus-article-buffer))
9729 ;; We clear the global counterparts of the buffer-local
9730 ;; variables as well, just to be on the safe side.
9731 (gnus-configure-windows 'group 'force)
9732 (gnus-summary-clear-local-variables)
9733 ;; Return to group mode buffer.
9734 (if (eq mode 'gnus-summary-mode)
9735 (gnus-kill-buffer buf)))
9736 (setq gnus-current-select-method gnus-select-method)
9737 (pop-to-buffer gnus-group-buffer)
9738 ;; Clear the current group name.
9739 (if (not quit-config)
9741 (gnus-group-jump-to-group group)
9742 (gnus-group-next-unread-group 1)
9743 (gnus-configure-windows 'group 'force))
9744 (if (not (buffer-name (car quit-config)))
9745 (gnus-configure-windows 'group 'force)
9746 (set-buffer (car quit-config))
9747 (and (eq major-mode 'gnus-summary-mode)
9748 (gnus-set-global-variables))
9749 (gnus-configure-windows (cdr quit-config))))
9751 (setq gnus-newsgroup-name nil)))))
9753 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
9754 (defun gnus-summary-exit-no-update (&optional no-questions)
9755 "Quit reading current newsgroup without updating read article info."
9757 (gnus-set-global-variables)
9758 (let* ((group gnus-newsgroup-name)
9759 (quit-config (gnus-group-quit-config group)))
9760 (when (or no-questions
9762 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
9763 ;; If we have several article buffers, we kill them at exit.
9764 (unless gnus-single-article-buffer
9765 (gnus-kill-buffer gnus-article-buffer)
9766 (gnus-kill-buffer gnus-original-article-buffer)
9767 (setq gnus-article-current nil))
9768 (if (not gnus-kill-summary-on-exit)
9769 (gnus-deaden-summary)
9770 (gnus-close-group group)
9771 (gnus-summary-clear-local-variables)
9772 (set-buffer gnus-group-buffer)
9773 (gnus-summary-clear-local-variables)
9774 (when (get-buffer gnus-summary-buffer)
9775 (kill-buffer gnus-summary-buffer)))
9776 (unless gnus-single-article-buffer
9777 (setq gnus-article-current nil))
9778 (when gnus-use-trees
9779 (gnus-tree-close group))
9780 (when (get-buffer gnus-article-buffer)
9781 (bury-buffer gnus-article-buffer))
9782 ;; Return to the group buffer.
9783 (gnus-configure-windows 'group 'force)
9784 ;; Clear the current group name.
9785 (setq gnus-newsgroup-name nil)
9786 (when (equal (gnus-group-group-name) group)
9787 (gnus-group-next-unread-group 1))
9789 (if (not (buffer-name (car quit-config)))
9790 (gnus-configure-windows 'group 'force)
9791 (set-buffer (car quit-config))
9792 (when (eq major-mode 'gnus-summary-mode)
9793 (gnus-set-global-variables))
9794 (gnus-configure-windows (cdr quit-config)))))))
9798 (defvar gnus-dead-summary-mode-map nil)
9800 (if gnus-dead-summary-mode-map
9802 (setq gnus-dead-summary-mode-map (make-keymap))
9803 (suppress-keymap gnus-dead-summary-mode-map)
9804 (substitute-key-definition
9805 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
9806 (let ((keys '("\C-d" "\r" "\177")))
9808 (define-key gnus-dead-summary-mode-map
9809 (pop keys) 'gnus-summary-wake-up-the-dead))))
9811 (defvar gnus-dead-summary-mode nil
9812 "Minor mode for Gnus summary buffers.")
9814 (defun gnus-dead-summary-mode (&optional arg)
9815 "Minor mode for Gnus summary buffers."
9817 (when (eq major-mode 'gnus-summary-mode)
9818 (make-local-variable 'gnus-dead-summary-mode)
9819 (setq gnus-dead-summary-mode
9820 (if (null arg) (not gnus-dead-summary-mode)
9821 (> (prefix-numeric-value arg) 0)))
9822 (when gnus-dead-summary-mode
9823 (unless (assq 'gnus-dead-summary-mode minor-mode-alist)
9824 (push '(gnus-dead-summary-mode " Dead") minor-mode-alist))
9825 (unless (assq 'gnus-dead-summary-mode minor-mode-map-alist)
9826 (push (cons 'gnus-dead-summary-mode gnus-dead-summary-mode-map)
9827 minor-mode-map-alist)))))
9829 (defun gnus-deaden-summary ()
9830 "Make the current summary buffer into a dead summary buffer."
9831 ;; Kill any previous dead summary buffer.
9832 (when (and gnus-dead-summary
9833 (buffer-name gnus-dead-summary))
9835 (set-buffer gnus-dead-summary)
9836 (when gnus-dead-summary-mode
9837 (kill-buffer (current-buffer)))))
9838 ;; Make this the current dead summary.
9839 (setq gnus-dead-summary (current-buffer))
9840 (gnus-dead-summary-mode 1)
9841 (let ((name (buffer-name)))
9842 (when (string-match "Summary" name)
9844 (concat (substring name 0 (match-beginning 0)) "Dead "
9845 (substring name (match-beginning 0))) t))))
9847 (defun gnus-kill-or-deaden-summary (buffer)
9848 "Kill or deaden the summary BUFFER."
9849 (cond (gnus-kill-summary-on-exit
9850 (when (and gnus-use-trees
9851 (and (get-buffer buffer)
9852 (buffer-name (get-buffer buffer))))
9854 (set-buffer (get-buffer buffer))
9855 (gnus-tree-close gnus-newsgroup-name)))
9856 (gnus-kill-buffer buffer))
9857 ((and (get-buffer buffer)
9858 (buffer-name (get-buffer buffer)))
9861 (gnus-deaden-summary)))))
9863 (defun gnus-summary-wake-up-the-dead (&rest args)
9864 "Wake up the dead summary buffer."
9866 (gnus-dead-summary-mode -1)
9867 (let ((name (buffer-name)))
9868 (when (string-match "Dead " name)
9870 (concat (substring name 0 (match-beginning 0))
9871 (substring name (match-end 0))) t)))
9872 (gnus-message 3 "This dead summary is now alive again"))
9874 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
9875 (defun gnus-summary-fetch-faq (&optional faq-dir)
9876 "Fetch the FAQ for the current group.
9877 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
9881 (if current-prefix-arg
9883 "Faq dir: " (and (listp gnus-group-faq-directory)
9884 gnus-group-faq-directory)))))
9885 (let (gnus-faq-buffer)
9886 (and (setq gnus-faq-buffer
9887 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
9888 (gnus-configure-windows 'summary-faq))))
9890 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
9891 (defun gnus-summary-describe-group (&optional force)
9892 "Describe the current newsgroup."
9894 (gnus-group-describe-group force gnus-newsgroup-name))
9896 (defun gnus-summary-describe-briefly ()
9897 "Describe summary mode commands briefly."
9900 (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")))
9902 ;; Walking around group mode buffer from summary mode.
9904 (defun gnus-summary-next-group (&optional no-article target-group backward)
9905 "Exit current newsgroup and then select next unread newsgroup.
9906 If prefix argument NO-ARTICLE is non-nil, no article is selected
9907 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
9908 previous group instead."
9910 (gnus-set-global-variables)
9911 (let ((current-group gnus-newsgroup-name)
9912 (current-buffer (current-buffer))
9914 ;; First we semi-exit this group to update Xrefs and all variables.
9915 ;; We can't do a real exit, because the window conf must remain
9916 ;; the same in case the user is prompted for info, and we don't
9917 ;; want the window conf to change before that...
9918 (gnus-summary-exit t)
9919 (while (not entered)
9920 ;; Then we find what group we are supposed to enter.
9921 (set-buffer gnus-group-buffer)
9922 (gnus-group-jump-to-group current-group)
9925 (if (eq gnus-keep-same-level 'best)
9926 (gnus-summary-best-group gnus-newsgroup-name)
9927 (gnus-summary-search-group backward gnus-keep-same-level))))
9928 (if (not target-group)
9929 ;; There are no further groups, so we return to the group
9932 (gnus-message 5 "Returning to the group buffer")
9934 (set-buffer current-buffer)
9935 (gnus-summary-exit))
9936 ;; We try to enter the target group.
9937 (gnus-group-jump-to-group target-group)
9938 (let ((unreads (gnus-group-group-unread)))
9939 (if (and (or (eq t unreads)
9940 (and unreads (not (zerop unreads))))
9941 (gnus-summary-read-group
9942 target-group nil no-article current-buffer))
9944 (setq current-group target-group
9945 target-group nil)))))))
9947 (defun gnus-summary-prev-group (&optional no-article)
9948 "Exit current newsgroup and then select previous unread newsgroup.
9949 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
9951 (gnus-summary-next-group no-article nil t))
9953 ;; Walking around summary lines.
9955 (defun gnus-summary-first-subject (&optional unread)
9956 "Go to the first unread subject.
9957 If UNREAD is non-nil, go to the first unread article.
9958 Returns the article selected or nil if there are no unread articles."
9963 ((null gnus-newsgroup-data)
9964 (gnus-message 3 "No articles in the group")
9966 ;; Pick the first article.
9968 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
9969 (gnus-data-number (car gnus-newsgroup-data)))
9970 ;; No unread articles.
9971 ((null gnus-newsgroup-unreads)
9972 (gnus-message 3 "No more unread articles")
9974 ;; Find the first unread article.
9976 (let ((data gnus-newsgroup-data))
9978 (not (gnus-data-unread-p (car data))))
9979 (setq data (cdr data)))
9982 (goto-char (gnus-data-pos (car data)))
9983 (gnus-data-number (car data)))))))
9984 (gnus-summary-position-point)))
9986 (defun gnus-summary-next-subject (n &optional unread dont-display)
9987 "Go to next N'th summary line.
9988 If N is negative, go to the previous N'th subject line.
9989 If UNREAD is non-nil, only unread articles are selected.
9990 The difference between N and the actual number of steps taken is
9993 (let ((backward (< n 0))
9997 (gnus-summary-find-prev unread)
9998 (gnus-summary-find-next unread)))
10000 (if (/= 0 n) (gnus-message 7 "No more%s articles"
10001 (if unread " unread" "")))
10002 (unless dont-display
10003 (gnus-summary-recenter)
10004 (gnus-summary-position-point))
10007 (defun gnus-summary-next-unread-subject (n)
10008 "Go to next N'th unread summary line."
10010 (gnus-summary-next-subject n t))
10012 (defun gnus-summary-prev-subject (n &optional unread)
10013 "Go to previous N'th summary line.
10014 If optional argument UNREAD is non-nil, only unread article is selected."
10016 (gnus-summary-next-subject (- n) unread))
10018 (defun gnus-summary-prev-unread-subject (n)
10019 "Go to previous N'th unread summary line."
10021 (gnus-summary-next-subject (- n) t))
10023 (defun gnus-summary-goto-subject (article &optional force silent)
10024 "Go the subject line of ARTICLE.
10025 If FORCE, also allow jumping to articles not currently shown."
10027 (data (gnus-data-find article)))
10028 ;; We read in the article if we have to.
10031 (gnus-summary-insert-subject article)
10032 (setq data (gnus-data-find article)))
10037 (gnus-message 3 "Can't find article %d" article))
10039 (goto-char (gnus-data-pos data))
10042 ;; Walking around summary lines with displaying articles.
10044 (defun gnus-summary-expand-window (&optional arg)
10045 "Make the summary buffer take up the entire Emacs frame.
10046 Given a prefix, will force an `article' buffer configuration."
10048 (gnus-set-global-variables)
10050 (gnus-configure-windows 'article 'force)
10051 (gnus-configure-windows 'summary 'force)))
10053 (defun gnus-summary-display-article (article &optional all-header)
10054 "Display ARTICLE in article buffer."
10055 (gnus-set-global-variables)
10059 (if gnus-summary-display-article-function
10060 (funcall gnus-summary-display-article-function article all-header)
10061 (gnus-article-prepare article all-header))
10062 (run-hooks 'gnus-select-article-hook)
10063 (gnus-summary-recenter)
10064 (gnus-summary-goto-subject article)
10065 (when gnus-use-trees
10066 (gnus-possibly-generate-tree article)
10067 (gnus-highlight-selected-tree article))
10068 ;; Successfully display article.
10069 (gnus-article-set-window-start
10070 (cdr (assq article gnus-newsgroup-bookmarks)))
10073 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
10074 "Select the current article.
10075 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
10076 non-nil, the article will be re-fetched even if it already present in
10077 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
10079 (let ((article (or article (gnus-summary-article-number)))
10080 (all-headers (not (not all-headers))) ;Must be T or NIL.
10081 gnus-summary-display-article-function
10084 (gnus-summary-article-pseudo-p article)
10085 (error "This is a pseudo-article."))
10088 (set-buffer gnus-summary-buffer)
10089 (if (or (and gnus-single-article-buffer
10090 (or (null gnus-current-article)
10091 (null gnus-article-current)
10092 (null (get-buffer gnus-article-buffer))
10093 (not (eq article (cdr gnus-article-current)))
10094 (not (equal (car gnus-article-current)
10095 gnus-newsgroup-name))))
10096 (and (not gnus-single-article-buffer)
10097 (or (null gnus-current-article)
10098 (not (eq gnus-current-article article))))
10100 ;; The requested article is different from the current article.
10102 (gnus-summary-display-article article all-headers)
10103 (setq did article))
10104 (if (or all-headers gnus-show-all-headers)
10105 (gnus-article-show-all-headers))
10108 (gnus-article-set-window-start
10109 (cdr (assq article gnus-newsgroup-bookmarks)))))))
10111 (defun gnus-summary-set-current-mark (&optional current-mark)
10112 "Obsolete function."
10115 (defun gnus-summary-next-article (&optional unread subject backward push)
10116 "Select the next article.
10117 If UNREAD, only unread articles are selected.
10118 If SUBJECT, only articles with SUBJECT are selected.
10119 If BACKWARD, the previous article is selected instead of the next."
10121 (gnus-set-global-variables)
10123 ;; Is there such an article?
10124 ((and (gnus-summary-search-forward unread subject backward)
10125 (or (gnus-summary-display-article (gnus-summary-article-number))
10126 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
10127 (gnus-summary-position-point))
10128 ;; If not, we try the first unread, if that is wanted.
10130 gnus-auto-select-same
10131 (or (gnus-summary-first-unread-article)
10132 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
10133 (gnus-summary-position-point)
10134 (gnus-message 6 "Wrapped"))
10135 ;; Try to get next/previous article not displayed in this group.
10136 ((and gnus-auto-extend-newsgroup
10137 (not unread) (not subject))
10138 (gnus-summary-goto-article
10139 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
10141 ;; Go to next/previous group.
10143 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
10144 (gnus-summary-jump-to-group gnus-newsgroup-name))
10145 (let ((cmd last-command-char)
10147 (if (eq gnus-keep-same-level 'best)
10148 (gnus-summary-best-group gnus-newsgroup-name)
10149 (gnus-summary-search-group backward gnus-keep-same-level))))
10150 ;; For some reason, the group window gets selected. We change
10152 (select-window (get-buffer-window (current-buffer)))
10153 ;; Select next unread newsgroup automagically.
10155 ((not gnus-auto-select-next)
10156 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
10157 ((or (eq gnus-auto-select-next 'quietly)
10158 (and (eq gnus-auto-select-next 'slightly-quietly)
10160 (and (eq gnus-auto-select-next 'almost-quietly)
10161 (gnus-summary-last-article-p)))
10163 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
10164 (gnus-summary-exit)
10165 (gnus-message 7 "No more%s articles (%s)..."
10166 (if unread " unread" "")
10167 (if group (concat "selecting " group)
10169 (gnus-summary-next-group nil group backward)))
10171 (gnus-summary-walk-group-buffer
10172 gnus-newsgroup-name cmd unread backward)))))))
10174 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward)
10175 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
10176 (?\C-p (gnus-group-prev-unread-group 1))))
10177 keve key group ended)
10179 (set-buffer gnus-group-buffer)
10180 (gnus-summary-jump-to-group from-group)
10182 (if (eq gnus-keep-same-level 'best)
10183 (gnus-summary-best-group gnus-newsgroup-name)
10184 (gnus-summary-search-group backward gnus-keep-same-level))))
10187 5 "No more%s articles%s" (if unread " unread" "")
10189 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
10190 (format " (Type %s for %s [%s])"
10191 (single-key-description cmd) group
10192 (car (gnus-gethash group gnus-newsrc-hashtb)))
10193 (format " (Type %s to exit %s)"
10194 (single-key-description cmd)
10195 gnus-newsgroup-name)))
10196 ;; Confirm auto selection.
10197 (setq key (car (setq keve (gnus-read-event-char))))
10200 ((assq key keystrokes)
10201 (let ((obuf (current-buffer)))
10202 (switch-to-buffer gnus-group-buffer)
10204 (gnus-group-jump-to-group group))
10205 (eval (cadr (assq key keystrokes)))
10206 (setq group (gnus-group-group-name))
10207 (switch-to-buffer obuf))
10210 (if (or (not group)
10211 (gnus-ephemeral-group-p gnus-newsgroup-name))
10212 (gnus-summary-exit)
10213 (gnus-summary-next-group nil group backward)))
10215 (push (cdr keve) unread-command-events))))))
10217 (defun gnus-read-event-char ()
10218 "Get the next event."
10219 (let ((event (read-event)))
10220 (cons (and (numberp event) event) event)))
10222 (defun gnus-summary-next-unread-article ()
10223 "Select unread article after current one."
10225 (gnus-summary-next-article t (and gnus-auto-select-same
10226 (gnus-summary-article-subject))))
10228 (defun gnus-summary-prev-article (&optional unread subject)
10229 "Select the article after the current one.
10230 If UNREAD is non-nil, only unread articles are selected."
10232 (gnus-summary-next-article unread subject t))
10234 (defun gnus-summary-prev-unread-article ()
10235 "Select unred article before current one."
10237 (gnus-summary-prev-article t (and gnus-auto-select-same
10238 (gnus-summary-article-subject))))
10240 (defun gnus-summary-next-page (&optional lines circular)
10241 "Show next page of the selected article.
10242 If at the end of the current article, select the next article.
10243 LINES says how many lines should be scrolled up.
10245 If CIRCULAR is non-nil, go to the start of the article instead of
10246 selecting the next article when reaching the end of the current
10249 (setq gnus-summary-buffer (current-buffer))
10250 (gnus-set-global-variables)
10251 (let ((article (gnus-summary-article-number))
10253 (gnus-configure-windows 'article)
10254 (if (or (null gnus-current-article)
10255 (null gnus-article-current)
10256 (/= article (cdr gnus-article-current))
10257 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10258 ;; Selected subject is different from current article's.
10259 (gnus-summary-display-article article)
10260 (gnus-eval-in-buffer-window
10261 gnus-article-buffer
10262 (setq endp (gnus-article-next-page lines)))
10265 (gnus-summary-beginning-of-article))
10267 (gnus-message 3 "End of message"))
10269 (if (and (eq gnus-summary-goto-unread 'never)
10270 (not (gnus-summary-last-article-p article)))
10271 (gnus-summary-next-article)
10272 (gnus-summary-next-unread-article))))))
10273 (gnus-summary-recenter)
10274 (gnus-summary-position-point)))
10276 (defun gnus-summary-prev-page (&optional lines)
10277 "Show previous page of selected article.
10278 Argument LINES specifies lines to be scrolled down."
10280 (gnus-set-global-variables)
10281 (let ((article (gnus-summary-article-number)))
10282 (gnus-configure-windows 'article)
10283 (if (or (null gnus-current-article)
10284 (null gnus-article-current)
10285 (/= article (cdr gnus-article-current))
10286 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10287 ;; Selected subject is different from current article's.
10288 (gnus-summary-display-article article)
10289 (gnus-summary-recenter)
10290 (gnus-eval-in-buffer-window gnus-article-buffer
10291 (gnus-article-prev-page lines))))
10292 (gnus-summary-position-point))
10294 (defun gnus-summary-scroll-up (lines)
10295 "Scroll up (or down) one line current article.
10296 Argument LINES specifies lines to be scrolled up (or down if negative)."
10298 (gnus-set-global-variables)
10299 (gnus-configure-windows 'article)
10300 (gnus-summary-show-thread)
10301 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
10302 (gnus-eval-in-buffer-window
10303 gnus-article-buffer
10305 (if (gnus-article-next-page lines)
10306 (gnus-message 3 "End of message")))
10308 (gnus-article-prev-page (- lines))))))
10309 (gnus-summary-recenter)
10310 (gnus-summary-position-point))
10312 (defun gnus-summary-next-same-subject ()
10313 "Select next article which has the same subject as current one."
10315 (gnus-set-global-variables)
10316 (gnus-summary-next-article nil (gnus-summary-article-subject)))
10318 (defun gnus-summary-prev-same-subject ()
10319 "Select previous article which has the same subject as current one."
10321 (gnus-set-global-variables)
10322 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
10324 (defun gnus-summary-next-unread-same-subject ()
10325 "Select next unread article which has the same subject as current one."
10327 (gnus-set-global-variables)
10328 (gnus-summary-next-article t (gnus-summary-article-subject)))
10330 (defun gnus-summary-prev-unread-same-subject ()
10331 "Select previous unread article which has the same subject as current one."
10333 (gnus-set-global-variables)
10334 (gnus-summary-prev-article t (gnus-summary-article-subject)))
10336 (defun gnus-summary-first-unread-article ()
10337 "Select the first unread article.
10338 Return nil if there are no unread articles."
10340 (gnus-set-global-variables)
10342 (if (gnus-summary-first-subject t)
10344 (gnus-summary-show-thread)
10345 (gnus-summary-first-subject t)
10346 (gnus-summary-display-article (gnus-summary-article-number))))
10347 (gnus-summary-position-point)))
10349 (defun gnus-summary-best-unread-article ()
10350 "Select the unread article with the highest score."
10352 (gnus-set-global-variables)
10353 (let ((best -1000000)
10354 (data gnus-newsgroup-data)
10357 (and (gnus-data-unread-p (car data))
10359 (gnus-summary-article-score (gnus-data-number (car data))))
10362 article (gnus-data-number (car data))))
10363 (setq data (cdr data)))
10365 (gnus-summary-goto-article article)
10366 (error "No unread articles"))
10367 (gnus-summary-position-point)))
10369 (defun gnus-summary-last-subject ()
10370 "Go to the last displayed subject line in the group."
10371 (let ((article (gnus-data-number (car (gnus-data-list t)))))
10373 (gnus-summary-goto-subject article))))
10375 (defun gnus-summary-goto-article (article &optional all-headers force)
10376 "Fetch ARTICLE and display it if it exists.
10377 If ALL-HEADERS is non-nil, no header lines are hidden."
10383 (mapcar (lambda (number) (list (int-to-string number)))
10384 gnus-newsgroup-limit)))
10388 (if (gnus-summary-goto-subject article force)
10389 (gnus-summary-display-article article all-headers)
10390 (gnus-message 4 "Couldn't go to article %s" article) nil)
10391 (gnus-summary-position-point)))
10393 (defun gnus-summary-goto-last-article ()
10394 "Go to the previously read article."
10397 (and gnus-last-article
10398 (gnus-summary-goto-article gnus-last-article))
10399 (gnus-summary-position-point)))
10401 (defun gnus-summary-pop-article (number)
10402 "Pop one article off the history and go to the previous.
10403 NUMBER articles will be popped off."
10406 (setq gnus-newsgroup-history
10407 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
10409 (gnus-summary-goto-article (car to))
10410 (error "Article history empty")))
10411 (gnus-summary-position-point))
10413 ;; Summary commands and functions for limiting the summary buffer.
10415 (defun gnus-summary-limit-to-articles (n)
10416 "Limit the summary buffer to the next N articles.
10417 If not given a prefix, use the process marked articles instead."
10419 (gnus-set-global-variables)
10421 (let ((articles (gnus-summary-work-articles n)))
10422 (setq gnus-newsgroup-processable nil)
10423 (gnus-summary-limit articles))
10424 (gnus-summary-position-point)))
10426 (defun gnus-summary-pop-limit (&optional total)
10427 "Restore the previous limit.
10428 If given a prefix, remove all limits."
10430 (gnus-set-global-variables)
10432 (setq gnus-newsgroup-limits
10433 (list (mapcar (lambda (h) (mail-header-number h))
10434 gnus-newsgroup-headers))))
10435 (unless gnus-newsgroup-limits
10436 (error "No limit to pop"))
10438 (gnus-summary-limit nil 'pop)
10439 (gnus-summary-position-point)))
10441 (defun gnus-summary-limit-to-subject (subject &optional header)
10442 "Limit the summary buffer to articles that have subjects that match a regexp."
10443 (interactive "sRegexp: ")
10445 (setq header "subject"))
10446 (when (not (equal "" subject))
10448 (let ((articles (gnus-summary-find-matching
10449 (or header "subject") subject 'all)))
10450 (or articles (error "Found no matches for \"%s\"" subject))
10451 (gnus-summary-limit articles))
10452 (gnus-summary-position-point))))
10454 (defun gnus-summary-limit-to-author (from)
10455 "Limit the summary buffer to articles that have authors that match a regexp."
10456 (interactive "sRegexp: ")
10457 (gnus-summary-limit-to-subject from "from"))
10459 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10461 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10463 (defun gnus-summary-limit-to-unread (&optional all)
10464 "Limit the summary buffer to articles that are not marked as read.
10465 If ALL is non-nil, limit strictly to unread articles."
10468 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
10469 (gnus-summary-limit-to-marks
10470 ;; Concat all the marks that say that an article is read and have
10472 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
10473 gnus-killed-mark gnus-kill-file-mark
10474 gnus-low-score-mark gnus-expirable-mark
10475 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark)
10478 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10479 (make-obsolete 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10481 (defun gnus-summary-limit-to-marks (marks &optional reverse)
10482 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
10483 If REVERSE, limit the summary buffer to articles that are not marked
10484 with MARKS. MARKS can either be a string of marks or a list of marks.
10485 Returns how many articles were removed."
10486 (interactive "sMarks: ")
10487 (gnus-set-global-variables)
10489 (let ((data gnus-newsgroup-data)
10490 (marks (if (listp marks) marks
10491 (append marks nil))) ; Transform to list.
10494 (and (if reverse (not (memq (gnus-data-mark (car data)) marks))
10495 (memq (gnus-data-mark (car data)) marks))
10496 (setq articles (cons (gnus-data-number (car data)) articles)))
10497 (setq data (cdr data)))
10498 (gnus-summary-limit articles))
10499 (gnus-summary-position-point)))
10501 (defun gnus-summary-limit-to-score (&optional score)
10502 "Limit to articles with score at or above SCORE."
10504 (gnus-set-global-variables)
10505 (setq score (if score
10506 (prefix-numeric-value score)
10507 (or gnus-summary-default-score 0)))
10508 (let ((data gnus-newsgroup-data)
10511 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
10513 (push (gnus-data-number (car data)) articles))
10514 (setq data (cdr data)))
10516 (gnus-summary-limit articles)
10517 (gnus-summary-position-point))))
10519 (defun gnus-summary-limit-include-dormant ()
10520 "Display all the hidden articles that are marked as dormant."
10522 (gnus-set-global-variables)
10523 (or gnus-newsgroup-dormant
10524 (error "There are no dormant articles in this group"))
10526 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
10527 (gnus-summary-position-point)))
10529 (defun gnus-summary-limit-exclude-dormant ()
10530 "Hide all dormant articles."
10532 (gnus-set-global-variables)
10534 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
10535 (gnus-summary-position-point)))
10537 (defun gnus-summary-limit-exclude-childless-dormant ()
10538 "Hide all dormant articles that have no children."
10540 (gnus-set-global-variables)
10541 (let ((data (gnus-data-list t))
10542 articles d children)
10543 ;; Find all articles that are either not dormant or have
10545 (while (setq d (pop data))
10546 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
10547 (and (setq children
10548 (gnus-article-children (gnus-data-number d)))
10551 (when (memq (car children) articles)
10556 (push (gnus-data-number d) articles)))
10557 ;; Do the limiting.
10559 (gnus-summary-limit articles)
10560 (gnus-summary-position-point))))
10562 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
10563 "Mark all unread excluded articles as read.
10564 If ALL, mark even excluded ticked and dormants as read."
10566 (let ((articles (gnus-sorted-complement
10568 (mapcar (lambda (h) (mail-header-number h))
10569 gnus-newsgroup-headers)
10571 (sort gnus-newsgroup-limit '<)))
10573 (setq gnus-newsgroup-unreads nil)
10575 (setq gnus-newsgroup-dormant nil
10576 gnus-newsgroup-marked nil
10577 gnus-newsgroup-reads
10579 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
10580 gnus-newsgroup-reads))
10581 (while (setq article (pop articles))
10582 (unless (or (memq article gnus-newsgroup-dormant)
10583 (memq article gnus-newsgroup-marked))
10584 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
10586 (defun gnus-summary-limit (articles &optional pop)
10588 ;; We pop the previous limit off the stack and use that.
10589 (setq articles (car gnus-newsgroup-limits)
10590 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
10591 ;; We use the new limit, so we push the old limit on the stack.
10592 (setq gnus-newsgroup-limits
10593 (cons gnus-newsgroup-limit gnus-newsgroup-limits)))
10595 (setq gnus-newsgroup-limit articles)
10596 (let ((total (length gnus-newsgroup-data))
10597 (data (gnus-data-find-list (gnus-summary-article-number)))
10599 ;; This will do all the work of generating the new summary buffer
10600 ;; according to the new limit.
10601 (gnus-summary-prepare)
10602 ;; Hide any threads, possibly.
10603 (and gnus-show-threads
10604 gnus-thread-hide-subtree
10605 (gnus-summary-hide-all-threads))
10606 ;; Try to return to the article you were at, or one in the
10609 ;; We try to find some article after the current one.
10611 (and (gnus-summary-goto-subject
10612 (gnus-data-number (car data)) nil t)
10615 (setq data (cdr data))))
10617 ;; If there is no data, that means that we were after the last
10618 ;; article. The same goes when we can't find any articles
10619 ;; after the current one.
10621 (goto-char (point-max))
10622 (gnus-summary-find-prev)))
10623 ;; We return how many articles were removed from the summary
10624 ;; buffer as a result of the new limit.
10625 (- total (length gnus-newsgroup-data))))
10627 (defsubst gnus-cut-thread (thread)
10628 "Go forwards in the thread until we find an article that we want to display."
10629 (when (eq gnus-fetch-old-headers 'some)
10630 ;; Deal with old-fetched headers.
10632 (memq (mail-header-number (car thread))
10633 gnus-newsgroup-ancient)
10634 (<= (length (cdr thread)) 1))
10635 (setq thread (cadr thread))))
10636 ;; Deal with sparse threads.
10637 (when (or (eq gnus-build-sparse-threads 'some)
10638 (eq gnus-build-sparse-threads 'more))
10640 (memq (mail-header-number (car thread)) gnus-newsgroup-sparse)
10641 (= (length (cdr thread)) 1))
10642 (setq thread (cadr thread))))
10645 (defun gnus-cut-threads (threads)
10646 "Cut off all uninteresting articles from the beginning of threads."
10647 (when (or (eq gnus-fetch-old-headers 'some)
10648 (eq gnus-build-sparse-threads 'some)
10649 (eq gnus-build-sparse-threads 'more))
10650 (let ((th threads))
10652 (setcar th (gnus-cut-thread (car th)))
10653 (setq th (cdr th)))))
10654 ;; Remove nixed out threads.
10655 (delq nil threads))
10657 (defun gnus-summary-initial-limit (&optional show-if-empty)
10658 "Figure out what the initial limit is supposed to be on group entry.
10659 This entails weeding out unwanted dormants, low-scored articles,
10660 fetch-old-headers verbiage, and so on."
10661 ;; Most groups have nothing to remove.
10662 (if (or gnus-inhibit-limiting
10663 (and (null gnus-newsgroup-dormant)
10664 (not (eq gnus-fetch-old-headers 'some))
10665 (null gnus-summary-expunge-below)
10666 (not (eq gnus-build-sparse-threads 'some))
10667 (not (eq gnus-build-sparse-threads 'more))
10668 (null gnus-thread-expunge-below)
10669 (not gnus-use-nocem)))
10671 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10672 (setq gnus-newsgroup-limit nil)
10675 (unless (car (symbol-value node))
10676 ;; These threads have no parents -- they are roots.
10677 (let ((nodes (cdr (symbol-value node)))
10680 (if (and gnus-thread-expunge-below
10681 (< (gnus-thread-total-score (car nodes))
10682 gnus-thread-expunge-below))
10683 (gnus-expunge-thread (pop nodes))
10684 (setq thread (pop nodes))
10685 (gnus-summary-limit-children thread))))))
10686 gnus-newsgroup-dependencies)
10687 ;; If this limitation resulted in an empty group, we might
10688 ;; pop the previous limit and use it instead.
10689 (when (and (not gnus-newsgroup-limit)
10691 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
10692 gnus-newsgroup-limit))
10694 (defun gnus-summary-limit-children (thread)
10695 "Return 1 if this subthread is visible and 0 if it is not."
10696 ;; First we get the number of visible children to this thread. This
10697 ;; is done by recursing down the thread using this function, so this
10698 ;; will really go down to a leaf article first, before slowly
10699 ;; working its way up towards the root.
10703 (apply '+ (mapcar 'gnus-summary-limit-children
10706 (number (mail-header-number (car thread)))
10709 ;; If this article is dormant and has absolutely no visible
10710 ;; children, then this article isn't visible.
10711 (and (memq number gnus-newsgroup-dormant)
10713 ;; If this is a "fetch-old-headered" and there is only one
10714 ;; visible child (or less), then we don't want this article.
10715 (and (eq gnus-fetch-old-headers 'some)
10716 (memq number gnus-newsgroup-ancient)
10718 ;; If this is a sparsely inserted article with no children,
10719 ;; we don't want it.
10720 (and (eq gnus-build-sparse-threads 'some)
10721 (memq number gnus-newsgroup-sparse)
10723 ;; If we use expunging, and this article is really
10724 ;; low-scored, then we don't want this article.
10725 (when (and gnus-summary-expunge-below
10727 (or (cdr (assq number gnus-newsgroup-scored))
10728 gnus-summary-default-score))
10729 gnus-summary-expunge-below))
10730 ;; We increase the expunge-tally here, but that has
10731 ;; nothing to do with the limits, really.
10732 (incf gnus-newsgroup-expunged-tally)
10733 ;; We also mark as read here, if that's wanted.
10734 (when (and gnus-summary-mark-below
10735 (< score gnus-summary-mark-below))
10736 (setq gnus-newsgroup-unreads
10737 (delq number gnus-newsgroup-unreads))
10738 (if gnus-newsgroup-auto-expire
10739 (push number gnus-newsgroup-expirable)
10740 (push (cons number gnus-low-score-mark)
10741 gnus-newsgroup-reads)))
10743 (and gnus-use-nocem
10744 (gnus-nocem-unwanted-article-p (mail-header-id (car thread)))))
10745 ;; Nope, invisible article.
10747 ;; Ok, this article is to be visible, so we add it to the limit
10749 (setq gnus-newsgroup-limit (cons number gnus-newsgroup-limit))
10752 (defun gnus-expunge-thread (thread)
10753 "Mark all articles in THREAD as read."
10754 (let* ((number (mail-header-number (car thread))))
10755 (incf gnus-newsgroup-expunged-tally)
10756 ;; We also mark as read here, if that's wanted.
10757 (setq gnus-newsgroup-unreads
10758 (delq number gnus-newsgroup-unreads))
10759 (if gnus-newsgroup-auto-expire
10760 (push number gnus-newsgroup-expirable)
10761 (push (cons number gnus-low-score-mark)
10762 gnus-newsgroup-reads)))
10763 ;; Go recursively through all subthreads.
10764 (mapcar 'gnus-expunge-thread (cdr thread)))
10766 ;; Summary article oriented commands
10768 (defun gnus-summary-refer-parent-article (n)
10769 "Refer parent article N times.
10770 The difference between N and the number of articles fetched is returned."
10772 (gnus-set-global-variables)
10776 (let* ((header (gnus-summary-article-header))
10778 ;; If we try to find the parent of the currently
10779 ;; displayed article, then we take a look at the actual
10780 ;; References header, since this is slightly more
10781 ;; reliable than the References field we got from the
10783 (if (and (eq (mail-header-number header)
10784 (cdr gnus-article-current))
10785 (equal gnus-newsgroup-name
10786 (car gnus-article-current)))
10788 (set-buffer gnus-original-article-buffer)
10789 (nnheader-narrow-to-headers)
10791 (mail-fetch-field "references")
10793 ;; It's not the current article, so we take a bet on
10794 ;; the value we got from the server.
10795 (mail-header-references header))))
10796 (if (setq ref (or ref (mail-header-references header)))
10797 (or (gnus-summary-refer-article (gnus-parent-id ref))
10798 (gnus-message 1 "Couldn't find parent"))
10799 (gnus-message 1 "No references in article %d"
10800 (gnus-summary-article-number))
10803 (gnus-summary-position-point)
10806 (defun gnus-summary-refer-references ()
10807 "Fetch all articles mentioned in the References header.
10808 Return how many articles were fetched."
10810 (gnus-set-global-variables)
10811 (let ((ref (mail-header-references (gnus-summary-article-header)))
10812 (current (gnus-summary-article-number))
10814 ;; For each Message-ID in the References header...
10815 (while (string-match "<[^>]*>" ref)
10817 ;; ... fetch that article.
10818 (gnus-summary-refer-article
10819 (prog1 (match-string 0 ref)
10820 (setq ref (substring ref (match-end 0))))))
10821 (gnus-summary-goto-subject current)
10822 (gnus-summary-position-point)
10825 (defun gnus-summary-refer-article (message-id)
10826 "Fetch an article specified by MESSAGE-ID."
10827 (interactive "sMessage-ID: ")
10828 (when (and (stringp message-id)
10829 (not (zerop (length message-id))))
10830 ;; Construct the correct Message-ID if necessary.
10831 ;; Suggested by tale@pawl.rpi.edu.
10832 (unless (string-match "^<" message-id)
10833 (setq message-id (concat "<" message-id)))
10834 (unless (string-match ">$" message-id)
10835 (setq message-id (concat message-id ">")))
10836 (let ((header (car (gnus-gethash message-id
10837 gnus-newsgroup-dependencies))))
10839 ;; The article is present in the buffer, to we just go to it.
10840 (gnus-summary-goto-article (mail-header-number header) nil t)
10841 ;; We fetch the article
10842 (let ((gnus-override-method gnus-refer-article-method)
10844 ;; Start the special refer-article method, if necessary.
10845 (when gnus-refer-article-method
10846 (gnus-check-server gnus-refer-article-method))
10847 ;; Fetch the header, and display the article.
10848 (if (setq number (gnus-summary-insert-subject message-id))
10849 (gnus-summary-select-article nil nil nil number)
10850 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
10852 (defun gnus-summary-enter-digest-group (&optional force)
10853 "Enter a digest group based on the current article."
10855 (gnus-set-global-variables)
10856 (gnus-summary-select-article)
10857 (let ((name (format "%s-%d"
10858 (gnus-group-prefixed-name
10859 gnus-newsgroup-name (list 'nndoc ""))
10860 gnus-current-article))
10861 (ogroup gnus-newsgroup-name)
10862 (case-fold-search t)
10863 (buf (current-buffer))
10866 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
10867 (insert-buffer-substring gnus-original-article-buffer)
10869 (goto-char (point-min))
10870 (or (search-forward "\n\n" nil t) (point)))
10871 (goto-char (point-min))
10872 (delete-matching-lines "^\\(Path\\):\\|^From ")
10875 (if (gnus-group-read-ephemeral-group
10876 name `(nndoc ,name (nndoc-address
10878 (nndoc-article-type ,(if force 'digest 'guess))) t)
10879 ;; Make all postings to this group go to the parent group.
10880 (nconc (gnus-info-params (gnus-get-info name))
10881 (list (cons 'to-group ogroup)))
10882 ;; Couldn't select this doc group.
10883 (switch-to-buffer buf)
10884 (gnus-set-global-variables)
10885 (gnus-configure-windows 'summary)
10886 (gnus-message 3 "Article couldn't be entered?"))
10887 (kill-buffer dig))))
10889 (defun gnus-summary-isearch-article (&optional regexp-p)
10890 "Do incremental search forward on the current article.
10891 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
10893 (gnus-set-global-variables)
10894 (gnus-summary-select-article)
10895 (gnus-configure-windows 'article)
10896 (gnus-eval-in-buffer-window
10897 gnus-article-buffer
10898 (goto-char (point-min))
10899 (isearch-forward regexp-p)))
10901 (defun gnus-summary-search-article-forward (regexp &optional backward)
10902 "Search for an article containing REGEXP forward.
10903 If BACKWARD, search backward instead."
10906 (format "Search article %s (regexp%s): "
10907 (if current-prefix-arg "backward" "forward")
10908 (if gnus-last-search-regexp
10909 (concat ", default " gnus-last-search-regexp)
10911 current-prefix-arg))
10912 (gnus-set-global-variables)
10913 (if (string-equal regexp "")
10914 (setq regexp (or gnus-last-search-regexp ""))
10915 (setq gnus-last-search-regexp regexp))
10916 (if (gnus-summary-search-article regexp backward)
10917 (gnus-article-set-window-start
10918 (cdr (assq (gnus-summary-article-number) gnus-newsgroup-bookmarks)))
10919 (error "Search failed: \"%s\"" regexp)))
10921 (defun gnus-summary-search-article-backward (regexp)
10922 "Search for an article containing REGEXP backward."
10925 (format "Search article backward (regexp%s): "
10926 (if gnus-last-search-regexp
10927 (concat ", default " gnus-last-search-regexp)
10929 (gnus-summary-search-article-forward regexp 'backward))
10931 (defun gnus-summary-search-article (regexp &optional backward)
10932 "Search for an article containing REGEXP.
10933 Optional argument BACKWARD means do search for backward.
10934 gnus-select-article-hook is not called during the search."
10935 (let ((gnus-select-article-hook nil) ;Disable hook.
10936 (gnus-mark-article-hook nil) ;Inhibit marking as read.
10939 (function re-search-backward) (function re-search-forward)))
10942 ;; Hidden thread subtrees must be searched for ,too.
10943 (gnus-summary-show-all-threads)
10944 ;; First of all, search current article.
10945 ;; We don't want to read article again from NNTP server nor reset
10947 (gnus-summary-select-article)
10948 (gnus-message 9 "Searching article: %d..." gnus-current-article)
10949 (setq last gnus-current-article)
10950 (gnus-eval-in-buffer-window
10951 gnus-article-buffer
10954 ;; Begin search from current point.
10955 (setq found (funcall re-search regexp nil t))))
10956 ;; Then search next articles.
10957 (while (and (not found)
10958 (gnus-summary-display-article
10959 (if backward (gnus-summary-find-prev)
10960 (gnus-summary-find-next))))
10961 (gnus-message 9 "Searching article: %d..." gnus-current-article)
10962 (gnus-eval-in-buffer-window
10963 gnus-article-buffer
10966 (goto-char (if backward (point-max) (point-min)))
10967 (setq found (funcall re-search regexp nil t)))))
10969 ;; Adjust article pointer.
10970 (or (eq last gnus-current-article)
10971 (setq gnus-last-article last))
10972 ;; Return T if found such article.
10975 (defun gnus-summary-find-matching (header regexp &optional backward unread
10977 "Return a list of all articles that match REGEXP on HEADER.
10978 The search stars on the current article and goes forwards unless
10979 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
10980 If UNREAD is non-nil, only unread articles will
10981 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
10982 in the comparisons."
10983 (let ((data (if (eq backward 'all) gnus-newsgroup-data
10984 (gnus-data-find-list
10985 (gnus-summary-article-number) (gnus-data-list backward))))
10986 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
10987 (case-fold-search (not not-case-fold))
10989 (or (fboundp (intern (concat "mail-header-" header)))
10990 (error "%s is not a valid header" header))
10992 (setq d (car data))
10993 (and (or (not unread) ; We want all articles...
10994 (gnus-data-unread-p d)) ; Or just unreads.
10995 (vectorp (gnus-data-header d)) ; It's not a pseudo.
10996 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
10997 (setq articles (cons (gnus-data-number d) articles))) ; Success!
10998 (setq data (cdr data)))
10999 (nreverse articles)))
11001 (defun gnus-summary-execute-command (header regexp command &optional backward)
11002 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
11003 If HEADER is an empty string (or nil), the match is done on the entire
11004 article. If BACKWARD (the prefix) is non-nil, search backward instead."
11006 (list (let ((completion-ignore-case t))
11009 (mapcar (lambda (string) (list string))
11010 '("Number" "Subject" "From" "Lines" "Date"
11011 "Message-ID" "Xref" "References" "Body"))
11012 nil 'require-match))
11013 (read-string "Regexp: ")
11014 (read-key-sequence "Command: ")
11015 current-prefix-arg))
11016 (when (equal header "Body")
11018 (gnus-set-global-variables)
11019 ;; Hidden thread subtrees must be searched as well.
11020 (gnus-summary-show-all-threads)
11021 ;; We don't want to change current point nor window configuration.
11023 (save-window-excursion
11024 (gnus-message 6 "Executing %s..." (key-description command))
11025 ;; We'd like to execute COMMAND interactively so as to give arguments.
11026 (gnus-execute header regexp
11027 `(lambda () (call-interactively ',(key-binding command)))
11029 (gnus-message 6 "Executing %s...done" (key-description command)))))
11031 (defun gnus-summary-beginning-of-article ()
11032 "Scroll the article back to the beginning."
11034 (gnus-set-global-variables)
11035 (gnus-summary-select-article)
11036 (gnus-configure-windows 'article)
11037 (gnus-eval-in-buffer-window
11038 gnus-article-buffer
11040 (goto-char (point-min))
11041 (and gnus-break-pages (gnus-narrow-to-page))))
11043 (defun gnus-summary-end-of-article ()
11044 "Scroll to the end of the article."
11046 (gnus-set-global-variables)
11047 (gnus-summary-select-article)
11048 (gnus-configure-windows 'article)
11049 (gnus-eval-in-buffer-window
11050 gnus-article-buffer
11052 (goto-char (point-max))
11054 (and gnus-break-pages (gnus-narrow-to-page))))
11056 (defun gnus-summary-show-article (&optional arg)
11057 "Force re-fetching of the current article.
11058 If ARG (the prefix) is non-nil, show the raw article without any
11059 article massaging functions being run."
11061 (gnus-set-global-variables)
11063 ;; Select the article the normal way.
11064 (gnus-summary-select-article nil 'force)
11065 ;; Bind the article treatment functions to nil.
11066 (let ((gnus-have-all-headers t)
11067 gnus-article-display-hook
11068 gnus-article-prepare-hook
11070 (gnus-summary-select-article nil 'force)))
11071 ; (gnus-configure-windows 'article)
11072 (gnus-summary-position-point))
11074 (defun gnus-summary-verbose-headers (&optional arg)
11075 "Toggle permanent full header display.
11076 If ARG is a positive number, turn header display on.
11077 If ARG is a negative number, turn header display off."
11079 (gnus-set-global-variables)
11080 (gnus-summary-toggle-header arg)
11081 (setq gnus-show-all-headers
11082 (cond ((or (not (numberp arg))
11084 (not gnus-show-all-headers))
11088 (defun gnus-summary-toggle-header (&optional arg)
11089 "Show the headers if they are hidden, or hide them if they are shown.
11090 If ARG is a positive number, show the entire header.
11091 If ARG is a negative number, hide the unwanted header lines."
11093 (gnus-set-global-variables)
11095 (set-buffer gnus-article-buffer)
11096 (let* ((buffer-read-only nil)
11097 (inhibit-point-motion-hooks t)
11098 (hidden (text-property-any
11099 (goto-char (point-min)) (search-forward "\n\n")
11102 (goto-char (point-min))
11103 (when (search-forward "\n\n" nil t)
11104 (delete-region (point-min) (1- (point))))
11105 (goto-char (point-min))
11107 (set-buffer gnus-original-article-buffer)
11108 (goto-char (point-min))
11109 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
11110 (insert-buffer-substring gnus-original-article-buffer 1 e)
11111 (let ((gnus-inhibit-hiding t))
11112 (run-hooks 'gnus-article-display-hook))
11113 (if (or (not hidden) (and (numberp arg) (< arg 0)))
11114 (gnus-article-hide-headers)))))
11116 (defun gnus-summary-show-all-headers ()
11117 "Make all header lines visible."
11119 (gnus-set-global-variables)
11120 (gnus-article-show-all-headers))
11122 (defun gnus-summary-toggle-mime (&optional arg)
11123 "Toggle MIME processing.
11124 If ARG is a positive number, turn MIME processing on."
11126 (gnus-set-global-variables)
11127 (setq gnus-show-mime
11128 (if (null arg) (not gnus-show-mime)
11129 (> (prefix-numeric-value arg) 0)))
11130 (gnus-summary-select-article t 'force))
11132 (defun gnus-summary-caesar-message (&optional arg)
11133 "Caesar rotate the current article by 13.
11134 The numerical prefix specifies how manu places to rotate each letter
11137 (gnus-set-global-variables)
11138 (gnus-summary-select-article)
11139 (let ((mail-header-separator ""))
11140 (gnus-eval-in-buffer-window
11141 gnus-article-buffer
11144 (let ((start (window-start)))
11145 (news-caesar-buffer-body arg)
11146 (set-window-start (get-buffer-window (current-buffer)) start))))))
11148 (defun gnus-summary-stop-page-breaking ()
11149 "Stop page breaking in the current article."
11151 (gnus-set-global-variables)
11152 (gnus-summary-select-article)
11153 (gnus-eval-in-buffer-window gnus-article-buffer (widen)))
11155 (defun gnus-summary-move-article (&optional n to-newsgroup select-method action)
11156 "Move the current article to a different newsgroup.
11157 If N is a positive number, move the N next articles.
11158 If N is a negative number, move the N previous articles.
11159 If N is nil and any articles have been marked with the process mark,
11160 move those articles instead.
11161 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11162 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
11163 re-spool using this method.
11165 For this function to work, both the current newsgroup and the
11166 newsgroup that you want to move to have to support the `request-move'
11167 and `request-accept' functions."
11169 (unless action (setq action 'move))
11170 (gnus-set-global-variables)
11171 ;; Check whether the source group supports the required functions.
11172 (cond ((and (eq action 'move)
11173 (not (gnus-check-backend-function
11174 'request-move-article gnus-newsgroup-name)))
11175 (error "The current group does not support article moving"))
11176 ((and (eq action 'crosspost)
11177 (not (gnus-check-backend-function
11178 'request-replace-article gnus-newsgroup-name)))
11179 (error "The current group does not support article editing")))
11180 (let ((articles (gnus-summary-work-articles n))
11181 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
11182 (names '((move "move" "Moving")
11183 (copy "copy" "Copying")
11184 (crosspost "crosspost" "Crossposting")))
11185 (copy-buf (save-excursion
11186 (nnheader-set-temp-buffer " *copy article*")))
11187 art-group to-method new-xref article to-groups)
11188 (unless (assq action names)
11189 (error "Unknown action %s" action))
11190 ;; Read the newsgroup name.
11191 (when (and (not to-newsgroup)
11192 (not select-method))
11194 (gnus-read-move-group-name
11195 (cadr (assq action names))
11196 gnus-current-move-group articles prefix))
11197 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
11198 (setq to-method (if select-method (list select-method "")
11199 (gnus-find-method-for-group to-newsgroup)))
11200 ;;(when (equal to-newsgroup gnus-newsgroup-name)
11201 ;;(error "Can't %s to the same group you're already in" action))
11202 ;; Check the method we are to move this article to...
11203 (or (gnus-check-backend-function 'request-accept-article (car to-method))
11204 (error "%s does not support article copying" (car to-method)))
11205 (or (gnus-check-server to-method)
11206 (error "Can't open server %s" (car to-method)))
11207 (gnus-message 6 "%s to %s: %s..."
11208 (caddr (assq action names))
11209 (or select-method to-newsgroup) articles)
11211 (setq article (pop articles))
11215 ;; Move the article.
11217 (gnus-request-move-article
11218 article ; Article to move
11219 gnus-newsgroup-name ; From newsgrouo
11220 (nth 1 (gnus-find-method-for-group
11221 gnus-newsgroup-name)) ; Server
11222 (list 'gnus-request-accept-article
11224 (list 'quote select-method)
11226 (not articles)) ; Accept form
11227 (not articles))) ; Only save nov last time
11228 ;; Copy the article.
11231 (set-buffer copy-buf)
11232 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11233 (gnus-request-accept-article
11234 (if select-method select-method to-newsgroup)
11236 ;; Crosspost the article.
11237 ((eq action 'crosspost)
11238 (let ((xref (mail-header-xref (gnus-summary-article-header article))))
11239 (setq new-xref (concat gnus-newsgroup-name ":" article))
11240 (if (and xref (not (string= xref "")))
11242 (when (string-match "^Xref: " xref)
11243 (setq xref (substring xref (match-end 0))))
11244 (setq new-xref (concat xref " " new-xref)))
11245 (setq new-xref (concat (system-name) " " new-xref)))
11247 (set-buffer copy-buf)
11248 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11249 (nnheader-replace-header "xref" new-xref)
11250 (gnus-request-accept-article
11251 (if select-method select-method to-newsgroup)
11252 (not articles)))))))
11253 (if (not art-group)
11254 (gnus-message 1 "Couldn't %s article %s"
11255 (cadr (assq action names)) article)
11258 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
11260 (gnus-group-prefixed-name
11262 (if select-method (list select-method "")
11263 (gnus-find-method-for-group to-newsgroup)))
11264 gnus-newsrc-hashtb)))
11265 (info (nth 2 entry))
11266 (to-group (gnus-info-group info)))
11267 ;; Update the group that has been moved to.
11269 (memq action '(move copy)))
11270 (unless (member to-group to-groups)
11271 (push to-group to-groups))
11273 (unless (memq article gnus-newsgroup-unreads)
11274 (gnus-info-set-read
11275 info (gnus-add-to-range (gnus-info-read info)
11276 (list (cdr art-group)))))
11278 ;; Copy any marks over to the new group.
11279 (let ((marks gnus-article-mark-lists)
11280 (to-article (cdr art-group)))
11282 ;; See whether the article is to be put in the cache.
11283 (when gnus-use-cache
11284 (gnus-cache-possibly-enter-article
11285 to-group to-article
11286 (let ((header (copy-sequence
11287 (gnus-summary-article-header article))))
11288 (mail-header-set-number header to-article)
11290 (memq article gnus-newsgroup-marked)
11291 (memq article gnus-newsgroup-dormant)
11292 (memq article gnus-newsgroup-unreads)))
11295 (when (memq article (symbol-value
11296 (intern (format "gnus-newsgroup-%s"
11298 ;; If the other group is the same as this group,
11299 ;; then we have to add the mark to the list.
11300 (when (equal to-group gnus-newsgroup-name)
11301 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
11304 (intern (format "gnus-newsgroup-%s"
11306 ;; Copy mark to other group.
11307 (gnus-add-marked-articles
11308 to-group (cdar marks) (list to-article) info))
11309 (setq marks (cdr marks)))))
11311 ;; Update the Xref header in this article to point to
11312 ;; the new crossposted article we have just created.
11313 (when (eq action 'crosspost)
11315 (set-buffer copy-buf)
11316 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11317 (nnheader-replace-header
11318 "xref" (concat new-xref " " (gnus-group-prefixed-name
11319 (car art-group) to-method)
11320 ":" (cdr art-group)))
11321 (gnus-request-replace-article
11322 article gnus-newsgroup-name (current-buffer)))))
11324 (gnus-summary-goto-subject article)
11325 (when (eq action 'move)
11326 (gnus-summary-mark-article article gnus-canceled-mark)))
11327 (gnus-summary-remove-process-mark article))
11328 ;; Re-activate all groups that have been moved to.
11330 (gnus-activate-group (pop to-groups)))
11332 (gnus-kill-buffer copy-buf)
11333 (gnus-summary-position-point)
11334 (gnus-set-mode-line 'summary)))
11336 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
11337 "Move the current article to a different newsgroup.
11338 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11339 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
11340 re-spool using this method."
11342 (gnus-summary-move-article n nil select-method 'copy))
11344 (defun gnus-summary-crosspost-article (&optional n)
11345 "Crosspost the current article to some other group."
11347 (gnus-summary-move-article n nil nil 'crosspost))
11349 (defun gnus-summary-respool-article (&optional n respool-method)
11350 "Respool the current article.
11351 The article will be squeezed through the mail spooling process again,
11352 which means that it will be put in some mail newsgroup or other
11353 depending on `nnmail-split-methods'.
11354 If N is a positive number, respool the N next articles.
11355 If N is a negative number, respool the N previous articles.
11356 If N is nil and any articles have been marked with the process mark,
11357 respool those articles instead.
11359 Respooling can be done both from mail groups and \"real\" newsgroups.
11360 In the former case, the articles in question will be moved from the
11361 current group into whatever groups they are destined to. In the
11362 latter case, they will be copied into the relevant groups."
11364 (gnus-set-global-variables)
11365 (let ((respool-methods (gnus-methods-using 'respool))
11367 (symbol-name (car (gnus-find-method-for-group gnus-newsgroup-name)))))
11368 (unless respool-method
11369 (setq respool-method
11371 "What method do you want to use when respooling? "
11372 respool-methods nil t (cons methname 0))))
11373 (unless (string= respool-method "")
11374 (if (assoc (symbol-name
11375 (car (gnus-find-method-for-group gnus-newsgroup-name)))
11377 (gnus-summary-move-article n nil (intern respool-method))
11378 (gnus-summary-copy-article n nil (intern respool-method))))))
11380 (defun gnus-summary-import-article (file)
11381 "Import a random file into a mail newsgroup."
11382 (interactive "fImport file: ")
11383 (gnus-set-global-variables)
11384 (let ((group gnus-newsgroup-name)
11385 (now (current-time))
11387 (or (gnus-check-backend-function 'request-accept-article group)
11388 (error "%s does not support article importing" group))
11389 (or (file-readable-p file)
11390 (not (file-regular-p file))
11391 (error "Can't read %s" file))
11393 (set-buffer (get-buffer-create " *import file*"))
11394 (buffer-disable-undo (current-buffer))
11396 (insert-file-contents file)
11397 (goto-char (point-min))
11398 (unless (nnheader-article-p)
11399 ;; This doesn't look like an article, so we fudge some headers.
11400 (setq atts (file-attributes file)
11401 lines (count-lines (point-min) (point-max)))
11402 (insert "From: " (read-string "From: ") "\n"
11403 "Subject: " (read-string "Subject: ") "\n"
11404 "Date: " (timezone-make-date-arpa-standard
11405 (current-time-string (nth 5 atts))
11406 (current-time-zone now)
11407 (current-time-zone now)) "\n"
11408 "Message-ID: " (gnus-inews-message-id) "\n"
11409 "Lines: " (int-to-string lines) "\n"
11410 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
11411 (gnus-request-accept-article group t)
11412 (kill-buffer (current-buffer)))))
11414 (defun gnus-summary-expire-articles ()
11415 "Expire all articles that are marked as expirable in the current group."
11417 (gnus-set-global-variables)
11418 (when (gnus-check-backend-function
11419 'request-expire-articles gnus-newsgroup-name)
11420 ;; This backend supports expiry.
11421 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
11422 (expirable (if total
11423 (gnus-list-of-read-articles gnus-newsgroup-name)
11424 (setq gnus-newsgroup-expirable
11425 (sort gnus-newsgroup-expirable '<))))
11426 (expiry-wait (gnus-group-get-parameter
11427 gnus-newsgroup-name 'expiry-wait))
11430 ;; There are expirable articles in this group, so we run them
11431 ;; through the expiry process.
11432 (gnus-message 6 "Expiring articles...")
11433 ;; The list of articles that weren't expired is returned.
11435 (let ((nnmail-expiry-wait-function nil)
11436 (nnmail-expiry-wait expiry-wait))
11437 (setq es (gnus-request-expire-articles
11438 expirable gnus-newsgroup-name)))
11439 (setq es (gnus-request-expire-articles
11440 expirable gnus-newsgroup-name)))
11441 (or total (setq gnus-newsgroup-expirable es))
11442 ;; We go through the old list of expirable, and mark all
11443 ;; really expired articles as nonexistent.
11444 (unless (eq es expirable) ;If nothing was expired, we don't mark.
11445 (let ((gnus-use-cache nil))
11447 (unless (memq (car expirable) es)
11448 (when (gnus-data-find (car expirable))
11449 (gnus-summary-mark-article
11450 (car expirable) gnus-canceled-mark)))
11451 (setq expirable (cdr expirable)))))
11452 (gnus-message 6 "Expiring articles...done")))))
11454 (defun gnus-summary-expire-articles-now ()
11455 "Expunge all expirable articles in the current group.
11456 This means that *all* articles that are marked as expirable will be
11457 deleted forever, right now."
11459 (gnus-set-global-variables)
11460 (or gnus-expert-user
11462 "Are you really, really, really sure you want to expunge? ")
11464 (let ((nnmail-expiry-wait 'immediate)
11465 (nnmail-expiry-wait-function nil))
11466 (gnus-summary-expire-articles)))
11468 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
11469 (defun gnus-summary-delete-article (&optional n)
11470 "Delete the N next (mail) articles.
11471 This command actually deletes articles. This is not a marking
11472 command. The article will disappear forever from your life, never to
11474 If N is negative, delete backwards.
11475 If N is nil and articles have been marked with the process mark,
11476 delete these instead."
11478 (gnus-set-global-variables)
11479 (or (gnus-check-backend-function 'request-expire-articles
11480 gnus-newsgroup-name)
11481 (error "The current newsgroup does not support article deletion."))
11482 ;; Compute the list of articles to delete.
11483 (let ((articles (gnus-summary-work-articles n))
11485 (if (and gnus-novice-user
11486 (not (gnus-y-or-n-p
11487 (format "Do you really want to delete %s forever? "
11488 (if (> (length articles) 1) "these articles"
11489 "this article")))))
11491 ;; Delete the articles.
11492 (setq not-deleted (gnus-request-expire-articles
11493 articles gnus-newsgroup-name 'force))
11495 (gnus-summary-remove-process-mark (car articles))
11496 ;; The backend might not have been able to delete the article
11498 (or (memq (car articles) not-deleted)
11499 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
11500 (setq articles (cdr articles))))
11501 (gnus-summary-position-point)
11502 (gnus-set-mode-line 'summary)
11505 (defun gnus-summary-edit-article (&optional force)
11506 "Enter into a buffer and edit the current article.
11507 This will have permanent effect only in mail groups.
11508 If FORCE is non-nil, allow editing of articles even in read-only
11512 (set-buffer gnus-summary-buffer)
11513 (gnus-set-global-variables)
11514 (when (and (not force)
11515 (gnus-group-read-only-p))
11516 (error "The current newsgroup does not support article editing."))
11517 (gnus-summary-select-article t nil t)
11518 (gnus-configure-windows 'article)
11519 (select-window (get-buffer-window gnus-article-buffer))
11520 (gnus-message 6 "C-c C-c to end edits")
11521 (setq buffer-read-only nil)
11523 (use-local-map (copy-keymap (current-local-map)))
11524 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
11525 (buffer-enable-undo)
11527 (goto-char (point-min))
11528 (search-forward "\n\n" nil t)))
11530 (defun gnus-summary-edit-article-done ()
11531 "Make edits to the current article permanent."
11533 (if (gnus-group-read-only-p)
11535 (gnus-summary-edit-article-postpone)
11537 1 "The current newsgroup does not support article editing.")
11539 (let ((buf (format "%s" (buffer-string))))
11542 (if (not (gnus-request-replace-article
11543 (cdr gnus-article-current) (car gnus-article-current)
11545 (error "Couldn't replace article.")
11546 (gnus-article-mode)
11547 (use-local-map gnus-article-mode-map)
11548 (setq buffer-read-only t)
11549 (buffer-disable-undo (current-buffer))
11550 (gnus-configure-windows 'summary)
11551 (gnus-summary-update-article (cdr gnus-article-current))
11552 (when gnus-use-cache
11553 (gnus-cache-update-article
11554 (cdr gnus-article-current) (car gnus-article-current))))
11555 (run-hooks 'gnus-article-display-hook)
11556 (and (gnus-visual-p 'summary-highlight 'highlight)
11557 (run-hooks 'gnus-visual-mark-article-hook)))))
11559 (defun gnus-summary-edit-article-postpone ()
11560 "Postpone changes to the current article."
11562 (gnus-article-mode)
11563 (use-local-map gnus-article-mode-map)
11564 (setq buffer-read-only t)
11565 (buffer-disable-undo (current-buffer))
11566 (gnus-configure-windows 'summary)
11567 (and (gnus-visual-p 'summary-highlight 'highlight)
11568 (run-hooks 'gnus-visual-mark-article-hook)))
11570 (defun gnus-summary-respool-query ()
11571 "Query where the respool algorithm would put this article."
11573 (gnus-set-global-variables)
11574 (gnus-summary-select-article)
11576 (set-buffer gnus-article-buffer)
11578 (goto-char (point-min))
11579 (search-forward "\n\n")
11580 (narrow-to-region (point-min) (point))
11581 (pp-eval-expression
11582 (list 'quote (mapcar 'car (nnmail-article-group 'identity)))))))
11584 ;; Summary score commands.
11586 ;; Suggested by boubaker@cenatls.cena.dgac.fr.
11588 (defun gnus-summary-raise-score (n)
11589 "Raise the score of the current article by N."
11591 (gnus-set-global-variables)
11592 (gnus-summary-set-score (+ (gnus-summary-article-score) n)))
11594 (defun gnus-summary-set-score (n)
11595 "Set the score of the current article to N."
11597 (gnus-set-global-variables)
11599 (gnus-summary-show-thread)
11600 (let ((buffer-read-only nil))
11602 (gnus-summary-update-mark
11603 (if (= n (or gnus-summary-default-score 0)) ?
11604 (if (< n (or gnus-summary-default-score 0))
11605 gnus-score-below-mark gnus-score-over-mark)) 'score))
11606 (let* ((article (gnus-summary-article-number))
11607 (score (assq article gnus-newsgroup-scored)))
11608 (if score (setcdr score n)
11609 (setq gnus-newsgroup-scored
11610 (cons (cons article n) gnus-newsgroup-scored))))
11611 (gnus-summary-update-line)))
11613 (defun gnus-summary-current-score ()
11614 "Return the score of the current article."
11616 (gnus-set-global-variables)
11617 (message "%s" (gnus-summary-article-score)))
11619 ;; Summary marking commands.
11621 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
11622 "Mark articles which has the same subject as read, and then select the next.
11623 If UNMARK is positive, remove any kind of mark.
11624 If UNMARK is negative, tick articles."
11626 (gnus-set-global-variables)
11628 (setq unmark (prefix-numeric-value unmark)))
11630 (gnus-summary-mark-same-subject
11631 (gnus-summary-article-subject) unmark)))
11632 ;; Select next unread article. If auto-select-same mode, should
11633 ;; select the first unread article.
11634 (gnus-summary-next-article t (and gnus-auto-select-same
11635 (gnus-summary-article-subject)))
11636 (gnus-message 7 "%d article%s marked as %s"
11637 count (if (= count 1) " is" "s are")
11638 (if unmark "unread" "read"))))
11640 (defun gnus-summary-kill-same-subject (&optional unmark)
11641 "Mark articles which has the same subject as read.
11642 If UNMARK is positive, remove any kind of mark.
11643 If UNMARK is negative, tick articles."
11645 (gnus-set-global-variables)
11647 (setq unmark (prefix-numeric-value unmark)))
11649 (gnus-summary-mark-same-subject
11650 (gnus-summary-article-subject) unmark)))
11651 ;; If marked as read, go to next unread subject.
11653 ;; Go to next unread subject.
11654 (gnus-summary-next-subject 1 t))
11655 (gnus-message 7 "%d articles are marked as %s"
11656 count (if unmark "unread" "read"))))
11658 (defun gnus-summary-mark-same-subject (subject &optional unmark)
11659 "Mark articles with same SUBJECT as read, and return marked number.
11660 If optional argument UNMARK is positive, remove any kinds of marks.
11661 If optional argument UNMARK is negative, mark articles as unread instead."
11665 ((null unmark) ; Mark as read.
11668 (gnus-summary-mark-article-as-read gnus-killed-mark)
11669 (gnus-summary-show-thread) t)
11670 (gnus-summary-find-subject subject))
11671 (setq count (1+ count))))
11672 ((> unmark 0) ; Tick.
11675 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
11676 (gnus-summary-show-thread) t)
11677 (gnus-summary-find-subject subject))
11678 (setq count (1+ count))))
11679 (t ; Mark as unread.
11682 (gnus-summary-mark-article-as-unread gnus-unread-mark)
11683 (gnus-summary-show-thread) t)
11684 (gnus-summary-find-subject subject))
11685 (setq count (1+ count)))))
11686 (gnus-set-mode-line 'summary)
11687 ;; Return the number of marked articles.
11690 (defun gnus-summary-mark-as-processable (n &optional unmark)
11691 "Set the process mark on the next N articles.
11692 If N is negative, mark backward instead. If UNMARK is non-nil, remove
11693 the process mark instead. The difference between N and the actual
11694 number of articles marked is returned."
11696 (gnus-set-global-variables)
11697 (let ((backward (< n 0))
11702 (gnus-summary-remove-process-mark
11703 (gnus-summary-article-number))
11704 (gnus-summary-set-process-mark (gnus-summary-article-number)))
11705 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
11707 (if (/= 0 n) (gnus-message 7 "No more articles"))
11708 (gnus-summary-recenter)
11709 (gnus-summary-position-point)
11712 (defun gnus-summary-unmark-as-processable (n)
11713 "Remove the process mark from the next N articles.
11714 If N is negative, mark backward instead. The difference between N and
11715 the actual number of articles marked is returned."
11717 (gnus-set-global-variables)
11718 (gnus-summary-mark-as-processable n t))
11720 (defun gnus-summary-unmark-all-processable ()
11721 "Remove the process mark from all articles."
11723 (gnus-set-global-variables)
11725 (while gnus-newsgroup-processable
11726 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
11727 (gnus-summary-position-point))
11729 (defun gnus-summary-mark-as-expirable (n)
11730 "Mark N articles forward as expirable.
11731 If N is negative, mark backward instead. The difference between N and
11732 the actual number of articles marked is returned."
11734 (gnus-set-global-variables)
11735 (gnus-summary-mark-forward n gnus-expirable-mark))
11737 (defun gnus-summary-mark-article-as-replied (article)
11738 "Mark ARTICLE replied and update the summary line."
11739 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
11740 (let ((buffer-read-only nil))
11741 (when (gnus-summary-goto-subject article)
11742 (gnus-summary-update-secondary-mark article))))
11744 (defun gnus-summary-set-bookmark (article)
11745 "Set a bookmark in current article."
11746 (interactive (list (gnus-summary-article-number)))
11747 (gnus-set-global-variables)
11748 (if (or (not (get-buffer gnus-article-buffer))
11749 (not gnus-current-article)
11750 (not gnus-article-current)
11751 (not (equal gnus-newsgroup-name (car gnus-article-current))))
11752 (error "No current article selected"))
11753 ;; Remove old bookmark, if one exists.
11754 (let ((old (assq article gnus-newsgroup-bookmarks)))
11755 (if old (setq gnus-newsgroup-bookmarks
11756 (delq old gnus-newsgroup-bookmarks))))
11757 ;; Set the new bookmark, which is on the form
11758 ;; (article-number . line-number-in-body).
11759 (setq gnus-newsgroup-bookmarks
11763 (set-buffer gnus-article-buffer)
11767 (goto-char (point-min))
11768 (search-forward "\n\n" nil t)
11771 gnus-newsgroup-bookmarks))
11772 (gnus-message 6 "A bookmark has been added to the current article."))
11774 (defun gnus-summary-remove-bookmark (article)
11775 "Remove the bookmark from the current article."
11776 (interactive (list (gnus-summary-article-number)))
11777 (gnus-set-global-variables)
11778 ;; Remove old bookmark, if one exists.
11779 (let ((old (assq article gnus-newsgroup-bookmarks)))
11782 (setq gnus-newsgroup-bookmarks
11783 (delq old gnus-newsgroup-bookmarks))
11784 (gnus-message 6 "Removed bookmark."))
11785 (gnus-message 6 "No bookmark in current article."))))
11787 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11788 (defun gnus-summary-mark-as-dormant (n)
11789 "Mark N articles forward as dormant.
11790 If N is negative, mark backward instead. The difference between N and
11791 the actual number of articles marked is returned."
11793 (gnus-set-global-variables)
11794 (gnus-summary-mark-forward n gnus-dormant-mark))
11796 (defun gnus-summary-set-process-mark (article)
11797 "Set the process mark on ARTICLE and update the summary line."
11798 (setq gnus-newsgroup-processable
11800 (delq article gnus-newsgroup-processable)))
11801 (when (gnus-summary-goto-subject article)
11802 (gnus-summary-show-thread)
11803 (gnus-summary-update-secondary-mark article)))
11805 (defun gnus-summary-remove-process-mark (article)
11806 "Remove the process mark from ARTICLE and update the summary line."
11807 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
11808 (when (gnus-summary-goto-subject article)
11809 (gnus-summary-show-thread)
11810 (gnus-summary-update-secondary-mark article)))
11812 (defun gnus-summary-set-saved-mark (article)
11813 "Set the process mark on ARTICLE and update the summary line."
11814 (push article gnus-newsgroup-saved)
11815 (when (gnus-summary-goto-subject article)
11816 (gnus-summary-update-secondary-mark article)))
11818 (defun gnus-summary-mark-forward (n &optional mark no-expire)
11819 "Mark N articles as read forwards.
11820 If N is negative, mark backwards instead.
11821 Mark with MARK. If MARK is ? , ?! or ??, articles will be
11823 The difference between N and the actual number of articles marked is
11826 (gnus-set-global-variables)
11827 (let ((backward (< n 0))
11828 (gnus-summary-goto-unread
11829 (and gnus-summary-goto-unread
11830 (not (eq gnus-summary-goto-unread 'never))
11831 (not (memq mark (list gnus-unread-mark
11832 gnus-ticked-mark gnus-dormant-mark)))))
11834 (mark (or mark gnus-del-mark)))
11835 (while (and (> n 0)
11836 (gnus-summary-mark-article nil mark no-expire)
11837 (zerop (gnus-summary-next-subject
11839 (and gnus-summary-goto-unread
11840 (not (eq gnus-summary-goto-unread 'never)))
11843 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11844 (gnus-summary-recenter)
11845 (gnus-summary-position-point)
11846 (gnus-set-mode-line 'summary)
11849 (defun gnus-summary-mark-article-as-read (mark)
11850 "Mark the current article quickly as read with MARK."
11851 (let ((article (gnus-summary-article-number)))
11852 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11853 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11854 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11855 (setq gnus-newsgroup-reads
11856 (cons (cons article mark) gnus-newsgroup-reads))
11857 ;; Possibly remove from cache, if that is used.
11858 (and gnus-use-cache (gnus-cache-enter-remove-article article))
11859 ;; Allow the backend to change the mark.
11860 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
11861 ;; Check for auto-expiry.
11862 (when (and gnus-newsgroup-auto-expire
11863 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
11864 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
11865 (= mark gnus-ancient-mark)
11866 (= mark gnus-read-mark) (= mark gnus-souped-mark)))
11867 (setq mark gnus-expirable-mark)
11868 (push article gnus-newsgroup-expirable))
11869 ;; Set the mark in the buffer.
11870 (gnus-summary-update-mark mark 'unread)
11873 (defun gnus-summary-mark-article-as-unread (mark)
11874 "Mark the current article quickly as unread with MARK."
11875 (let ((article (gnus-summary-article-number)))
11876 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11877 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11878 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
11879 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
11880 (cond ((= mark gnus-ticked-mark)
11881 (push article gnus-newsgroup-marked))
11882 ((= mark gnus-dormant-mark)
11883 (push article gnus-newsgroup-dormant))
11885 (push article gnus-newsgroup-unreads)))
11886 (setq gnus-newsgroup-reads
11887 (delq (assq article gnus-newsgroup-reads)
11888 gnus-newsgroup-reads))
11890 ;; See whether the article is to be put in the cache.
11891 (and gnus-use-cache
11892 (vectorp (gnus-summary-article-header article))
11894 (gnus-cache-possibly-enter-article
11895 gnus-newsgroup-name article
11896 (gnus-summary-article-header article)
11897 (= mark gnus-ticked-mark)
11898 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11901 (gnus-summary-update-mark mark 'unread)
11904 (defun gnus-summary-mark-article (&optional article mark no-expire)
11905 "Mark ARTICLE with MARK. MARK can be any character.
11906 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
11907 `??' (dormant) and `?E' (expirable).
11908 If MARK is nil, then the default character `?D' is used.
11909 If ARTICLE is nil, then the article on the current line will be
11911 ;; The mark might be a string.
11912 (and (stringp mark)
11913 (setq mark (aref mark 0)))
11914 ;; If no mark is given, then we check auto-expiring.
11915 (and (not no-expire)
11916 gnus-newsgroup-auto-expire
11918 (and (numberp mark)
11919 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
11920 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
11921 (= mark gnus-read-mark) (= mark gnus-souped-mark))))
11922 (setq mark gnus-expirable-mark))
11923 (let* ((mark (or mark gnus-del-mark))
11924 (article (or article (gnus-summary-article-number))))
11925 (or article (error "No article on current line"))
11926 (if (or (= mark gnus-unread-mark)
11927 (= mark gnus-ticked-mark)
11928 (= mark gnus-dormant-mark))
11929 (gnus-mark-article-as-unread article mark)
11930 (gnus-mark-article-as-read article mark))
11932 ;; See whether the article is to be put in the cache.
11933 (and gnus-use-cache
11934 (not (= mark gnus-canceled-mark))
11935 (vectorp (gnus-summary-article-header article))
11937 (gnus-cache-possibly-enter-article
11938 gnus-newsgroup-name article
11939 (gnus-summary-article-header article)
11940 (= mark gnus-ticked-mark)
11941 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11943 (if (gnus-summary-goto-subject article nil t)
11944 (let ((buffer-read-only nil))
11945 (gnus-summary-show-thread)
11947 (gnus-summary-update-mark mark 'unread)
11950 (defun gnus-summary-update-secondary-mark (article)
11951 "Update the secondary (read, process, cache) mark."
11952 (gnus-summary-update-mark
11953 (cond ((memq article gnus-newsgroup-processable)
11955 ((memq article gnus-newsgroup-cached)
11957 ((memq article gnus-newsgroup-replied)
11959 ((memq article gnus-newsgroup-saved)
11961 (t gnus-unread-mark))
11963 (when (gnus-visual-p 'summary-highlight 'highlight)
11964 (run-hooks 'gnus-summary-update-hook))
11967 (defun gnus-summary-update-mark (mark type)
11968 (beginning-of-line)
11969 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
11970 (buffer-read-only nil))
11972 ;; Go to the right position on the line.
11973 (forward-char forward)
11974 ;; Replace the old mark with the new mark.
11975 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
11976 ;; Optionally update the marks by some user rule.
11977 (when (eq type 'unread)
11978 (gnus-data-set-mark
11979 (gnus-data-find (gnus-summary-article-number)) mark)
11980 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
11982 (defun gnus-mark-article-as-read (article &optional mark)
11983 "Enter ARTICLE in the pertinent lists and remove it from others."
11984 ;; Make the article expirable.
11985 (let ((mark (or mark gnus-del-mark)))
11986 (if (= mark gnus-expirable-mark)
11987 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
11988 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
11989 ;; Remove from unread and marked lists.
11990 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11991 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11992 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11993 (push (cons article mark) gnus-newsgroup-reads)
11994 ;; Possibly remove from cache, if that is used.
11995 (when gnus-use-cache
11996 (gnus-cache-enter-remove-article article))))
11998 (defun gnus-mark-article-as-unread (article &optional mark)
11999 "Enter ARTICLE in the pertinent lists and remove it from others."
12000 (let ((mark (or mark gnus-ticked-mark)))
12001 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12002 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12003 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
12004 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12005 (cond ((= mark gnus-ticked-mark)
12006 (push article gnus-newsgroup-marked))
12007 ((= mark gnus-dormant-mark)
12008 (push article gnus-newsgroup-dormant))
12010 (push article gnus-newsgroup-unreads)))
12011 (setq gnus-newsgroup-reads
12012 (delq (assq article gnus-newsgroup-reads)
12013 gnus-newsgroup-reads))))
12015 (defalias 'gnus-summary-mark-as-unread-forward
12016 'gnus-summary-tick-article-forward)
12017 (make-obsolete 'gnus-summary-mark-as-unread-forward
12018 'gnus-summary-tick-article-forward)
12019 (defun gnus-summary-tick-article-forward (n)
12020 "Tick N articles forwards.
12021 If N is negative, tick backwards instead.
12022 The difference between N and the number of articles ticked is returned."
12024 (gnus-summary-mark-forward n gnus-ticked-mark))
12026 (defalias 'gnus-summary-mark-as-unread-backward
12027 'gnus-summary-tick-article-backward)
12028 (make-obsolete 'gnus-summary-mark-as-unread-backward
12029 'gnus-summary-tick-article-backward)
12030 (defun gnus-summary-tick-article-backward (n)
12031 "Tick N articles backwards.
12032 The difference between N and the number of articles ticked is returned."
12034 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
12036 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
12037 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
12038 (defun gnus-summary-tick-article (&optional article clear-mark)
12039 "Mark current article as unread.
12040 Optional 1st argument ARTICLE specifies article number to be marked as unread.
12041 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
12043 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
12044 gnus-ticked-mark)))
12046 (defun gnus-summary-mark-as-read-forward (n)
12047 "Mark N articles as read forwards.
12048 If N is negative, mark backwards instead.
12049 The difference between N and the actual number of articles marked is
12052 (gnus-summary-mark-forward n gnus-del-mark t))
12054 (defun gnus-summary-mark-as-read-backward (n)
12055 "Mark the N articles as read backwards.
12056 The difference between N and the actual number of articles marked is
12059 (gnus-summary-mark-forward (- n) gnus-del-mark t))
12061 (defun gnus-summary-mark-as-read (&optional article mark)
12062 "Mark current article as read.
12063 ARTICLE specifies the article to be marked as read.
12064 MARK specifies a string to be inserted at the beginning of the line."
12065 (gnus-summary-mark-article article mark))
12067 (defun gnus-summary-clear-mark-forward (n)
12068 "Clear marks from N articles forward.
12069 If N is negative, clear backward instead.
12070 The difference between N and the number of marks cleared is returned."
12072 (gnus-summary-mark-forward n gnus-unread-mark))
12074 (defun gnus-summary-clear-mark-backward (n)
12075 "Clear marks from N articles backward.
12076 The difference between N and the number of marks cleared is returned."
12078 (gnus-summary-mark-forward (- n) gnus-unread-mark))
12080 (defun gnus-summary-mark-unread-as-read ()
12081 "Intended to be used by `gnus-summary-mark-article-hook'."
12082 (when (memq gnus-current-article gnus-newsgroup-unreads)
12083 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
12085 (defun gnus-summary-mark-read-and-unread-as-read ()
12086 "Intended to be used by `gnus-summary-mark-article-hook'."
12087 (let ((mark (gnus-summary-article-mark)))
12088 (when (or (gnus-unread-mark-p mark)
12089 (gnus-read-mark-p mark))
12090 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
12092 (defun gnus-summary-mark-region-as-read (point mark all)
12093 "Mark all unread articles between point and mark as read.
12094 If given a prefix, mark all articles between point and mark as read,
12095 even ticked and dormant ones."
12096 (interactive "r\nP")
12100 (beginning-of-line)
12105 (memq (setq article (gnus-summary-article-number))
12106 gnus-newsgroup-unreads))
12107 (gnus-summary-mark-article article gnus-del-mark))
12109 (gnus-summary-find-next))))))
12111 (defun gnus-summary-mark-below (score mark)
12112 "Mark articles with score less than SCORE with MARK."
12113 (interactive "P\ncMark: ")
12114 (gnus-set-global-variables)
12115 (setq score (if score
12116 (prefix-numeric-value score)
12117 (or gnus-summary-default-score 0)))
12119 (set-buffer gnus-summary-buffer)
12120 (goto-char (point-min))
12123 (and (< (gnus-summary-article-score) score)
12124 (gnus-summary-mark-article nil mark))
12125 (gnus-summary-find-next)))))
12127 (defun gnus-summary-kill-below (&optional score)
12128 "Mark articles with score below SCORE as read."
12130 (gnus-set-global-variables)
12131 (gnus-summary-mark-below score gnus-killed-mark))
12133 (defun gnus-summary-clear-above (&optional score)
12134 "Clear all marks from articles with score above SCORE."
12136 (gnus-set-global-variables)
12137 (gnus-summary-mark-above score gnus-unread-mark))
12139 (defun gnus-summary-tick-above (&optional score)
12140 "Tick all articles with score above SCORE."
12142 (gnus-set-global-variables)
12143 (gnus-summary-mark-above score gnus-ticked-mark))
12145 (defun gnus-summary-mark-above (score mark)
12146 "Mark articles with score over SCORE with MARK."
12147 (interactive "P\ncMark: ")
12148 (gnus-set-global-variables)
12149 (setq score (if score
12150 (prefix-numeric-value score)
12151 (or gnus-summary-default-score 0)))
12153 (set-buffer gnus-summary-buffer)
12154 (goto-char (point-min))
12156 (if (> (gnus-summary-article-score) score)
12157 (gnus-summary-mark-article nil mark))
12159 (gnus-summary-find-next)))))
12161 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
12162 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
12163 (defun gnus-summary-limit-include-expunged ()
12164 "Display all the hidden articles that were expunged for low scores."
12166 (gnus-set-global-variables)
12167 (let ((buffer-read-only nil))
12168 (let ((scored gnus-newsgroup-scored)
12171 (or (gnus-summary-goto-subject (caar scored))
12172 (and (setq h (gnus-summary-article-header (caar scored)))
12173 (< (cdar scored) gnus-summary-expunge-below)
12174 (setq headers (cons h headers))))
12175 (setq scored (cdr scored)))
12176 (or headers (error "No expunged articles hidden."))
12177 (goto-char (point-min))
12178 (gnus-summary-prepare-unthreaded (nreverse headers)))
12179 (goto-char (point-min))
12180 (gnus-summary-position-point)))
12182 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
12183 "Mark all articles not marked as unread in this newsgroup as read.
12184 If prefix argument ALL is non-nil, all articles are marked as read.
12185 If QUIETLY is non-nil, no questions will be asked.
12186 If TO-HERE is non-nil, it should be a point in the buffer. All
12187 articles before this point will be marked as read.
12188 The number of articles marked as read is returned."
12190 (gnus-set-global-variables)
12193 (not gnus-interactive-catchup) ;Without confirmation?
12197 "Mark absolutely all articles as read? "
12198 "Mark all unread articles as read? ")))
12200 (not gnus-newsgroup-adaptive)
12201 (not gnus-newsgroup-auto-expire))
12204 (setq gnus-newsgroup-marked nil
12205 gnus-newsgroup-dormant nil))
12206 (setq gnus-newsgroup-unreads nil))
12207 ;; We actually mark all articles as canceled, which we
12208 ;; have to do when using auto-expiry or adaptive scoring.
12209 (gnus-summary-show-all-threads)
12210 (if (gnus-summary-first-subject (not all))
12212 (if to-here (< (point) to-here) t)
12213 (gnus-summary-mark-article-as-read gnus-catchup-mark)
12214 (gnus-summary-find-next (not all)))))
12216 (setq gnus-newsgroup-unreads nil))
12217 (gnus-set-mode-line 'summary)))
12218 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
12219 (if (and (not to-here) (eq 'nnvirtual (car method)))
12220 (nnvirtual-catchup-group
12221 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
12222 (gnus-summary-position-point)))
12224 (defun gnus-summary-catchup-to-here (&optional all)
12225 "Mark all unticked articles before the current one as read.
12226 If ALL is non-nil, also mark ticked and dormant articles as read."
12228 (gnus-set-global-variables)
12230 (let ((beg (point)))
12231 ;; We check that there are unread articles.
12232 (when (or all (gnus-summary-find-prev))
12233 (gnus-summary-catchup all t beg))))
12234 (gnus-summary-position-point))
12236 (defun gnus-summary-catchup-all (&optional quietly)
12237 "Mark all articles in this newsgroup as read."
12239 (gnus-set-global-variables)
12240 (gnus-summary-catchup t quietly))
12242 (defun gnus-summary-catchup-and-exit (&optional all quietly)
12243 "Mark all articles not marked as unread in this newsgroup as read, then exit.
12244 If prefix argument ALL is non-nil, all articles are marked as read."
12246 (gnus-set-global-variables)
12247 (gnus-summary-catchup all quietly nil 'fast)
12248 ;; Select next newsgroup or exit.
12249 (if (eq gnus-auto-select-next 'quietly)
12250 (gnus-summary-next-group nil)
12251 (gnus-summary-exit)))
12253 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
12254 "Mark all articles in this newsgroup as read, and then exit."
12256 (gnus-set-global-variables)
12257 (gnus-summary-catchup-and-exit t quietly))
12259 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
12260 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
12261 "Mark all articles in this group as read and select the next group.
12262 If given a prefix, mark all articles, unread as well as ticked, as
12265 (gnus-set-global-variables)
12267 (gnus-summary-catchup all))
12268 (gnus-summary-next-article t nil nil t))
12270 ;; Thread-based commands.
12272 (defun gnus-summary-articles-in-thread (&optional article)
12273 "Return a list of all articles in the current thread.
12274 If ARTICLE is non-nil, return all articles in the thread that starts
12275 with that article."
12276 (let* ((article (or article (gnus-summary-article-number)))
12277 (data (gnus-data-find-list article))
12278 (top-level (gnus-data-level (car data)))
12280 (cond ((null gnus-thread-operation-ignore-subject)
12281 (gnus-simplify-subject-re
12282 (mail-header-subject (gnus-data-header (car data)))))
12283 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
12284 (gnus-simplify-subject-fuzzy
12285 (mail-header-subject (gnus-data-header (car data)))))
12289 () ; This article doesn't exist.
12291 (and (or (not top-subject)
12292 (string= top-subject
12293 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
12294 (gnus-simplify-subject-fuzzy
12295 (mail-header-subject
12296 (gnus-data-header (car data))))
12297 (gnus-simplify-subject-re
12298 (mail-header-subject
12299 (gnus-data-header (car data)))))))
12300 (setq articles (cons (gnus-data-number (car data)) articles)))
12301 (if (and (setq data (cdr data))
12302 (> (gnus-data-level (car data)) top-level))
12305 ;; Return the list of articles.
12306 (nreverse articles))))
12308 (defun gnus-summary-rethread-current ()
12309 "Rethread the thread the current article is part of."
12311 (gnus-set-global-variables)
12312 (let* ((gnus-show-threads t)
12313 (article (gnus-summary-article-number))
12314 (id (mail-header-id (gnus-summary-article-header)))
12315 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
12317 (error "No article on the current line"))
12318 (gnus-rebuild-thread id)
12319 (gnus-summary-goto-subject article)))
12321 (defun gnus-summary-reparent-thread ()
12322 "Make current article child of the marked (or previous) article.
12324 Note that the re-threading will only work if `gnus-thread-ignore-subject'
12325 is non-nil or the Subject: of both articles are the same."
12327 (or (not (gnus-group-read-only-p))
12328 (error "The current newsgroup does not support article editing."))
12329 (or (<= (length gnus-newsgroup-processable) 1)
12330 (error "No more than one article may be marked."))
12331 (save-window-excursion
12332 (let ((gnus-article-buffer " *reparent*")
12333 (current-article (gnus-summary-article-number))
12334 ; first grab the marked article, otherwise one line up.
12335 (parent-article (if (not (null gnus-newsgroup-processable))
12336 (car gnus-newsgroup-processable)
12338 (if (eq (forward-line -1) 0)
12339 (gnus-summary-article-number)
12340 (error "Beginning of summary buffer."))))))
12341 (or (not (eq current-article parent-article))
12342 (error "An article may not be self-referential."))
12343 (let ((message-id (mail-header-id
12344 (gnus-summary-article-header parent-article))))
12345 (or (and message-id (not (equal message-id "")))
12346 (error "No message-id in desired parent."))
12347 (gnus-summary-select-article t t nil current-article)
12348 (set-buffer gnus-article-buffer)
12349 (setq buffer-read-only nil)
12350 (let ((buf (format "%s" (buffer-string))))
12353 (goto-char (point-min))
12354 (if (search-forward-regexp "^References: " nil t)
12355 (insert message-id " " )
12356 (insert "References: " message-id "\n"))
12357 (or (gnus-request-replace-article current-article
12358 (car gnus-article-current)
12359 gnus-article-buffer)
12360 (error "Couldn't replace article."))
12361 (set-buffer gnus-summary-buffer)
12362 (gnus-summary-unmark-all-processable)
12363 (gnus-summary-rethread-current)
12364 (message "Article %d is now the child of article %d."
12365 current-article parent-article)))))
12367 (defun gnus-summary-toggle-threads (&optional arg)
12368 "Toggle showing conversation threads.
12369 If ARG is positive number, turn showing conversation threads on."
12371 (gnus-set-global-variables)
12372 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
12373 (setq gnus-show-threads
12374 (if (null arg) (not gnus-show-threads)
12375 (> (prefix-numeric-value arg) 0)))
12376 (gnus-summary-prepare)
12377 (gnus-summary-goto-subject current)
12378 (gnus-summary-position-point)))
12380 (defun gnus-summary-show-all-threads ()
12381 "Show all threads."
12383 (gnus-set-global-variables)
12385 (let ((buffer-read-only nil))
12386 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
12387 (gnus-summary-position-point))
12389 (defun gnus-summary-show-thread ()
12390 "Show thread subtrees.
12391 Returns nil if no thread was there to be shown."
12393 (gnus-set-global-variables)
12394 (let ((buffer-read-only nil)
12396 ;; first goto end then to beg, to have point at beg after let
12397 (end (progn (end-of-line) (point)))
12398 (beg (progn (beginning-of-line) (point))))
12400 ;; Any hidden lines here?
12401 (search-forward "\r" end t)
12402 (subst-char-in-region beg end ?\^M ?\n t)
12404 (gnus-summary-position-point))))
12406 (defun gnus-summary-hide-all-threads ()
12407 "Hide all thread subtrees."
12409 (gnus-set-global-variables)
12411 (goto-char (point-min))
12412 (gnus-summary-hide-thread)
12413 (while (zerop (gnus-summary-next-thread 1 t))
12414 (gnus-summary-hide-thread)))
12415 (gnus-summary-position-point))
12417 (defun gnus-summary-hide-thread ()
12418 "Hide thread subtrees.
12419 Returns nil if no threads were there to be hidden."
12421 (gnus-set-global-variables)
12422 (let ((buffer-read-only nil)
12424 (article (gnus-summary-article-number)))
12426 ;; Go forward until either the buffer ends or the subthread
12428 (when (and (not (eobp))
12429 (or (zerop (gnus-summary-next-thread 1 t))
12430 (goto-char (point-max))))
12432 (if (and (> (point) start)
12433 (search-backward "\n" start t))
12435 (subst-char-in-region start (point) ?\n ?\^M)
12436 (gnus-summary-goto-subject article))
12439 ;;(gnus-summary-position-point)
12442 (defun gnus-summary-go-to-next-thread (&optional previous)
12443 "Go to the same level (or less) next thread.
12444 If PREVIOUS is non-nil, go to previous thread instead.
12445 Return the article number moved to, or nil if moving was impossible."
12446 (let ((level (gnus-summary-thread-level))
12447 (way (if previous -1 1))
12450 (while (and (not (eobp))
12451 (< level (gnus-summary-thread-level)))
12452 (forward-line way))
12459 (gnus-summary-article-number)
12460 (goto-char beg)))))
12462 (defun gnus-summary-go-to-next-thread-old (&optional previous)
12463 "Go to the same level (or less) next thread.
12464 If PREVIOUS is non-nil, go to previous thread instead.
12465 Return the article number moved to, or nil if moving was impossible."
12466 (if (and (eq gnus-summary-make-false-root 'dummy)
12467 (gnus-summary-article-intangible-p))
12468 (let ((beg (point)))
12469 (while (and (zerop (forward-line 1))
12470 (not (gnus-summary-article-intangible-p))
12471 (not (zerop (save-excursion
12472 (gnus-summary-thread-level))))))
12478 (let* ((level (gnus-summary-thread-level))
12479 (article (gnus-summary-article-number))
12480 (data (cdr (gnus-data-find-list article (gnus-data-list previous))))
12483 (if (<= (gnus-data-level (car data)) level)
12484 (setq oart (gnus-data-number (car data))
12486 (setq data (cdr data))))
12488 (gnus-summary-goto-subject oart)))))
12490 (defun gnus-summary-next-thread (n &optional silent)
12491 "Go to the same level next N'th thread.
12492 If N is negative, search backward instead.
12493 Returns the difference between N and the number of skips actually
12496 If SILENT, don't output messages."
12498 (gnus-set-global-variables)
12499 (let ((backward (< n 0))
12502 (while (and (> n 0)
12503 (gnus-summary-go-to-next-thread backward))
12506 (gnus-summary-position-point))
12507 (when (and (not silent) (/= 0 n))
12508 (gnus-message 7 "No more threads"))
12511 (defun gnus-summary-prev-thread (n)
12512 "Go to the same level previous N'th thread.
12513 Returns the difference between N and the number of skips actually
12516 (gnus-set-global-variables)
12517 (gnus-summary-next-thread (- n)))
12519 (defun gnus-summary-go-down-thread ()
12520 "Go down one level in the current thread."
12521 (let ((children (gnus-summary-article-children)))
12523 (gnus-summary-goto-subject (car children)))))
12525 (defun gnus-summary-go-up-thread ()
12526 "Go up one level in the current thread."
12527 (let ((parent (gnus-summary-article-parent)))
12529 (gnus-summary-goto-subject parent))))
12531 (defun gnus-summary-down-thread (n)
12532 "Go down thread N steps.
12533 If N is negative, go up instead.
12534 Returns the difference between N and how many steps down that were
12537 (gnus-set-global-variables)
12540 (while (and (> n 0)
12541 (if up (gnus-summary-go-up-thread)
12542 (gnus-summary-go-down-thread)))
12544 (gnus-summary-position-point)
12545 (if (/= 0 n) (gnus-message 7 "Can't go further"))
12548 (defun gnus-summary-up-thread (n)
12549 "Go up thread N steps.
12550 If N is negative, go up instead.
12551 Returns the difference between N and how many steps down that were
12554 (gnus-set-global-variables)
12555 (gnus-summary-down-thread (- n)))
12557 (defun gnus-summary-top-thread ()
12558 "Go to the top of the thread."
12560 (gnus-set-global-variables)
12561 (while (gnus-summary-go-up-thread))
12562 (gnus-summary-article-number))
12564 (defun gnus-summary-kill-thread (&optional unmark)
12565 "Mark articles under current thread as read.
12566 If the prefix argument is positive, remove any kinds of marks.
12567 If the prefix argument is negative, tick articles instead."
12569 (gnus-set-global-variables)
12571 (setq unmark (prefix-numeric-value unmark)))
12572 (let ((articles (gnus-summary-articles-in-thread)))
12574 ;; Expand the thread.
12575 (gnus-summary-show-thread)
12576 ;; Mark all the articles.
12578 (gnus-summary-goto-subject (car articles))
12579 (cond ((null unmark)
12580 (gnus-summary-mark-article-as-read gnus-killed-mark))
12582 (gnus-summary-mark-article-as-unread gnus-unread-mark))
12584 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
12585 (setq articles (cdr articles))))
12586 ;; Hide killed subtrees.
12588 gnus-thread-hide-killed
12589 (gnus-summary-hide-thread))
12590 ;; If marked as read, go to next unread subject.
12592 ;; Go to next unread subject.
12593 (gnus-summary-next-subject 1 t)))
12594 (gnus-set-mode-line 'summary))
12596 ;; Summary sorting commands
12598 (defun gnus-summary-sort-by-number (&optional reverse)
12599 "Sort summary buffer by article number.
12600 Argument REVERSE means reverse order."
12602 (gnus-summary-sort 'number reverse))
12604 (defun gnus-summary-sort-by-author (&optional reverse)
12605 "Sort summary buffer by author name alphabetically.
12606 If case-fold-search is non-nil, case of letters is ignored.
12607 Argument REVERSE means reverse order."
12609 (gnus-summary-sort 'author reverse))
12611 (defun gnus-summary-sort-by-subject (&optional reverse)
12612 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
12613 If case-fold-search is non-nil, case of letters is ignored.
12614 Argument REVERSE means reverse order."
12616 (gnus-summary-sort 'subject reverse))
12618 (defun gnus-summary-sort-by-date (&optional reverse)
12619 "Sort summary buffer by date.
12620 Argument REVERSE means reverse order."
12622 (gnus-summary-sort 'date reverse))
12624 (defun gnus-summary-sort-by-score (&optional reverse)
12625 "Sort summary buffer by score.
12626 Argument REVERSE means reverse order."
12628 (gnus-summary-sort 'score reverse))
12630 (defun gnus-summary-sort (predicate reverse)
12631 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
12632 (gnus-set-global-variables)
12633 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
12634 (article (intern (format "gnus-article-sort-by-%s" predicate)))
12635 (gnus-thread-sort-functions
12640 (,thread t2 t1)))))
12641 (gnus-article-sort-functions
12646 (,article t2 t1)))))
12648 (gnus-summary-prepare-hook nil))
12649 ;; We do the sorting by regenerating the threads.
12650 (gnus-summary-prepare)
12651 ;; Hide subthreads if needed.
12652 (when (and gnus-show-threads gnus-thread-hide-subtree)
12653 (gnus-summary-hide-all-threads)))
12654 ;; If in async mode, we send some info to the backend.
12655 (when gnus-newsgroup-async
12656 (gnus-request-asynchronous
12657 gnus-newsgroup-name gnus-newsgroup-data)))
12659 (defun gnus-sortable-date (date)
12660 "Make sortable string by string-lessp from DATE.
12661 Timezone package is used."
12662 (let* ((date (timezone-fix-time date nil nil)) ;[Y M D H M S]
12663 (year (aref date 0))
12664 (month (aref date 1))
12665 (day (aref date 2)))
12666 (timezone-make-sortable-date
12668 (timezone-make-time-string
12669 (aref date 3) (aref date 4) (aref date 5)))))
12671 ;; Summary saving commands.
12673 (defun gnus-summary-save-article (&optional n not-saved)
12674 "Save the current article using the default saver function.
12675 If N is a positive number, save the N next articles.
12676 If N is a negative number, save the N previous articles.
12677 If N is nil and any articles have been marked with the process mark,
12678 save those articles instead.
12679 The variable `gnus-default-article-saver' specifies the saver function."
12681 (gnus-set-global-variables)
12682 (let ((articles (gnus-summary-work-articles n))
12683 file header article)
12685 (setq header (gnus-summary-article-header
12686 (setq article (pop articles))))
12687 (if (not (vectorp header))
12688 ;; This is a pseudo-article.
12689 (if (assq 'name header)
12690 (gnus-copy-file (cdr (assq 'name header)))
12691 (gnus-message 1 "Article %d is unsaveable" article))
12692 ;; This is a real article.
12693 (save-window-excursion
12694 (gnus-summary-select-article t nil nil article))
12695 (unless gnus-save-all-headers
12696 ;; Remove headers accoring to `gnus-saved-headers'.
12697 (let ((gnus-visible-headers
12698 (or gnus-saved-headers gnus-visible-headers)))
12699 (gnus-article-hide-headers nil t)))
12700 ;; Remove any X-Gnus lines.
12702 (set-buffer gnus-article-buffer)
12704 (let ((buffer-read-only nil))
12705 (nnheader-narrow-to-headers)
12706 (while (re-search-forward "^X-Gnus" nil t)
12707 (gnus-delete-line)))))
12708 (save-window-excursion
12709 (if (not gnus-default-article-saver)
12710 (error "No default saver is defined.")
12711 (setq file (funcall
12712 gnus-default-article-saver
12714 ((not gnus-prompt-before-saving)
12716 ((eq gnus-prompt-before-saving 'always)
12719 (gnus-summary-remove-process-mark article)
12721 (gnus-summary-set-saved-mark article))))
12722 (gnus-summary-position-point)
12725 (defun gnus-summary-pipe-output (&optional arg)
12726 "Pipe the current article to a subprocess.
12727 If N is a positive number, pipe the N next articles.
12728 If N is a negative number, pipe the N previous articles.
12729 If N is nil and any articles have been marked with the process mark,
12730 pipe those articles instead."
12732 (gnus-set-global-variables)
12733 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
12734 (gnus-summary-save-article arg t))
12735 (gnus-configure-windows 'pipe))
12737 (defun gnus-summary-save-article-mail (&optional arg)
12738 "Append the current article to an mail file.
12739 If N is a positive number, save the N next articles.
12740 If N is a negative number, save the N previous articles.
12741 If N is nil and any articles have been marked with the process mark,
12742 save those articles instead."
12744 (gnus-set-global-variables)
12745 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
12746 (gnus-summary-save-article arg)))
12748 (defun gnus-summary-save-article-rmail (&optional arg)
12749 "Append the current article to an rmail file.
12750 If N is a positive number, save the N next articles.
12751 If N is a negative number, save the N previous articles.
12752 If N is nil and any articles have been marked with the process mark,
12753 save those articles instead."
12755 (gnus-set-global-variables)
12756 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
12757 (gnus-summary-save-article arg)))
12759 (defun gnus-summary-save-article-file (&optional arg)
12760 "Append the current article to a file.
12761 If N is a positive number, save the N next articles.
12762 If N is a negative number, save the N previous articles.
12763 If N is nil and any articles have been marked with the process mark,
12764 save those articles instead."
12766 (gnus-set-global-variables)
12767 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
12768 (gnus-summary-save-article arg)))
12770 (defun gnus-summary-save-article-body-file (&optional arg)
12771 "Append the current article body to a file.
12772 If N is a positive number, save the N next articles.
12773 If N is a negative number, save the N previous articles.
12774 If N is nil and any articles have been marked with the process mark,
12775 save those articles instead."
12777 (gnus-set-global-variables)
12778 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
12779 (gnus-summary-save-article arg)))
12781 (defun gnus-get-split-value (methods)
12782 "Return a value based on the split METHODS."
12783 (let (split-name method result match)
12786 (set-buffer gnus-original-article-buffer)
12788 (nnheader-narrow-to-headers)
12790 (goto-char (point-min))
12791 (setq method (pop methods))
12792 (setq match (car method))
12795 ;; Regular expression.
12797 (re-search-forward match nil t)
12799 ((gnus-functionp match)
12803 (setq result (funcall match gnus-newsgroup-name))))
12808 (setq result (eval match)))))
12809 (setq split-name (append (cdr method) split-name))
12810 (cond ((stringp result)
12811 (push result split-name))
12813 (setq split-name (append result split-name)))))))))
12816 (defun gnus-read-move-group-name (prompt default articles prefix)
12817 "Read a group name."
12818 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
12820 (format "Where do you want to %s %s? "
12822 (if (> (length articles) 1)
12823 (format "these %d articles" (length articles))
12831 (format "(default %s) " default)
12833 gnus-active-hashtb nil nil prefix))
12834 ((= 1 (length split-name))
12835 (completing-read prom gnus-active-hashtb
12836 nil nil (cons (car split-name) 0)))
12839 prom (mapcar (lambda (el) (list el)) (nreverse split-name)))))))
12842 (if (or (string= to-newsgroup "")
12843 (string= to-newsgroup prefix))
12844 (setq to-newsgroup (or default "")))
12845 (or (gnus-active to-newsgroup)
12846 (gnus-activate-group to-newsgroup)
12847 (error "No such group: %s" to-newsgroup)))
12850 (defun gnus-read-save-file-name (prompt default-name)
12851 (let* ((split-name (gnus-get-split-value gnus-split-methods))
12853 ;; Let the split methods have their say.
12855 ;; No split name was found.
12858 (concat prompt " (default "
12859 (file-name-nondirectory default-name) ") ")
12860 (file-name-directory default-name)
12862 ;; A single split name was found
12863 ((= 1 (length split-name))
12865 (concat prompt " (default " (car split-name) ") ")
12866 gnus-article-save-directory
12867 (concat gnus-article-save-directory (car split-name))))
12868 ;; A list of splits was found.
12870 (setq split-name (mapcar (lambda (el) (list el))
12871 (nreverse split-name)))
12872 (let ((result (completing-read
12873 (concat prompt " ") split-name nil nil)))
12874 (concat gnus-article-save-directory
12875 (if (string= result "")
12878 ;; If we have read a directory, we append the default file name.
12879 (when (file-directory-p file)
12880 (setq file (concat (file-name-as-directory file)
12881 (file-name-nondirectory default-name))))
12882 ;; Possibly translate some charaters.
12883 (nnheader-translate-file-chars file)))
12885 (defun gnus-article-archive-name (group)
12886 "Return the first instance of an \"Archive-name\" in the current buffer."
12887 (let ((case-fold-search t))
12888 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
12889 (match-string 1))))
12891 (defun gnus-summary-save-in-rmail (&optional filename)
12892 "Append this article to Rmail file.
12893 Optional argument FILENAME specifies file name.
12894 Directory to save to is default to `gnus-article-save-directory' which
12895 is initialized from the SAVEDIR environment variable."
12897 (gnus-set-global-variables)
12898 (let ((default-name
12899 (funcall gnus-rmail-save-name gnus-newsgroup-name
12900 gnus-current-headers gnus-newsgroup-last-rmail)))
12902 (cond ((eq filename 'default)
12904 (filename filename)
12905 (t (gnus-read-save-file-name
12906 "Save in rmail file:" default-name))))
12907 (gnus-make-directory (file-name-directory filename))
12908 (gnus-eval-in-buffer-window
12909 gnus-original-article-buffer
12913 (gnus-output-to-rmail filename))))
12914 ;; Remember the directory name to save articles
12915 (setq gnus-newsgroup-last-rmail filename)))
12917 (defun gnus-summary-save-in-mail (&optional filename)
12918 "Append this article to Unix mail file.
12919 Optional argument FILENAME specifies file name.
12920 Directory to save to is default to `gnus-article-save-directory' which
12921 is initialized from the SAVEDIR environment variable."
12923 (gnus-set-global-variables)
12924 (let ((default-name
12925 (funcall gnus-mail-save-name gnus-newsgroup-name
12926 gnus-current-headers gnus-newsgroup-last-mail)))
12928 (cond ((eq filename 'default)
12930 (filename filename)
12931 (t (gnus-read-save-file-name
12932 "Save in Unix mail file:" default-name))))
12934 (expand-file-name filename
12936 (file-name-directory default-name))))
12937 (gnus-make-directory (file-name-directory filename))
12938 (gnus-eval-in-buffer-window
12939 gnus-original-article-buffer
12943 (if (and (file-readable-p filename) (mail-file-babyl-p filename))
12944 (gnus-output-to-rmail filename)
12945 (let ((mail-use-rfc822 t))
12946 (rmail-output filename 1 t t))))))
12947 ;; Remember the directory name to save articles.
12948 (setq gnus-newsgroup-last-mail filename)))
12950 (defun gnus-summary-save-in-file (&optional filename)
12951 "Append this article to file.
12952 Optional argument FILENAME specifies file name.
12953 Directory to save to is default to `gnus-article-save-directory' which
12954 is initialized from the SAVEDIR environment variable."
12956 (gnus-set-global-variables)
12957 (let ((default-name
12958 (funcall gnus-file-save-name gnus-newsgroup-name
12959 gnus-current-headers gnus-newsgroup-last-file)))
12961 (cond ((eq filename 'default)
12963 (filename filename)
12964 (t (gnus-read-save-file-name
12965 "Save in file:" default-name))))
12966 (gnus-make-directory (file-name-directory filename))
12967 (gnus-eval-in-buffer-window
12968 gnus-original-article-buffer
12972 (gnus-output-to-file filename))))
12973 ;; Remember the directory name to save articles.
12974 (setq gnus-newsgroup-last-file filename)))
12976 (defun gnus-summary-save-body-in-file (&optional filename)
12977 "Append this article body to a file.
12978 Optional argument FILENAME specifies file name.
12979 The directory to save in defaults to `gnus-article-save-directory' which
12980 is initialized from the SAVEDIR environment variable."
12982 (gnus-set-global-variables)
12983 (let ((default-name
12984 (funcall gnus-file-save-name gnus-newsgroup-name
12985 gnus-current-headers gnus-newsgroup-last-file)))
12987 (cond ((eq filename 'default)
12989 (filename filename)
12990 (t (gnus-read-save-file-name
12991 "Save body in file:" default-name))))
12992 (gnus-make-directory (file-name-directory filename))
12993 (gnus-eval-in-buffer-window
12994 gnus-article-buffer
12998 (goto-char (point-min))
12999 (and (search-forward "\n\n" nil t)
13000 (narrow-to-region (point) (point-max)))
13001 (gnus-output-to-file filename))))
13002 ;; Remember the directory name to save articles.
13003 (setq gnus-newsgroup-last-file filename)))
13005 (defun gnus-summary-save-in-pipe (&optional command)
13006 "Pipe this article to subprocess."
13008 (gnus-set-global-variables)
13010 (cond ((eq command 'default)
13011 gnus-last-shell-command)
13013 (t (read-string "Shell command on article: "
13014 gnus-last-shell-command))))
13015 (if (string-equal command "")
13016 (setq command gnus-last-shell-command))
13017 (gnus-eval-in-buffer-window
13018 gnus-article-buffer
13021 (shell-command-on-region (point-min) (point-max) command nil)))
13022 (setq gnus-last-shell-command command))
13024 ;; Summary extract commands
13026 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
13027 (let ((buffer-read-only nil)
13028 (article (gnus-summary-article-number))
13030 (or (gnus-summary-goto-subject article)
13031 (error (format "No such article: %d" article)))
13032 (gnus-summary-position-point)
13033 ;; If all commands are to be bunched up on one line, we collect
13035 (if gnus-view-pseudos-separately
13037 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
13040 (setq action (cdr (assq 'action (car ps))))
13041 (setq files (list (cdr (assq 'name (car ps)))))
13042 (while (and ps (cdr ps)
13043 (string= (or action "1")
13044 (or (cdr (assq 'action (cadr ps))) "2")))
13045 (setq files (cons (cdr (assq 'name (cadr ps))) files))
13046 (setcdr ps (cddr ps)))
13049 (if (not (string-match "%s" action))
13050 (setq files (cons " " files)))
13051 (setq files (cons " " files))
13052 (and (assq 'execute (car ps))
13053 (setcdr (assq 'execute (car ps))
13054 (funcall (if (string-match "%s" action)
13057 (mapconcat (lambda (f) f) files " ")))))
13058 (setq ps (cdr ps)))))
13059 (if (and gnus-view-pseudos (not not-view))
13061 (and (assq 'execute (car pslist))
13062 (gnus-execute-command (cdr (assq 'execute (car pslist)))
13063 (eq gnus-view-pseudos 'not-confirm)))
13064 (setq pslist (cdr pslist)))
13067 (setq after-article (or (cdr (assq 'article (car pslist)))
13068 (gnus-summary-article-number)))
13069 (gnus-summary-goto-subject after-article)
13072 (insert " " (file-name-nondirectory
13073 (cdr (assq 'name (car pslist))))
13074 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
13076 (forward-line -1) ; back to `b'
13077 (add-text-properties
13078 b e (list 'gnus-number gnus-reffed-article-number
13079 gnus-mouse-face-prop gnus-mouse-face))
13081 after-article gnus-reffed-article-number
13082 gnus-unread-mark b (car pslist) 0 (- e b))
13083 (push gnus-reffed-article-number gnus-newsgroup-unreads)
13084 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
13085 (setq pslist (cdr pslist)))))))
13087 (defun gnus-pseudos< (p1 p2)
13088 (let ((c1 (cdr (assq 'action p1)))
13089 (c2 (cdr (assq 'action p2))))
13090 (and c1 c2 (string< c1 c2))))
13092 (defun gnus-request-pseudo-article (props)
13093 (cond ((assq 'execute props)
13094 (gnus-execute-command (cdr (assq 'execute props)))))
13095 (let ((gnus-current-article (gnus-summary-article-number)))
13096 (run-hooks 'gnus-mark-article-hook)))
13098 (defun gnus-execute-command (command &optional automatic)
13100 (gnus-article-setup-buffer)
13101 (set-buffer gnus-article-buffer)
13102 (let ((command (if automatic command (read-string "Command: " command)))
13103 (buffer-read-only nil))
13105 (insert "$ " command "\n\n")
13106 (if gnus-view-pseudo-asynchronously
13107 (start-process "gnus-execute" nil "sh" "-c" command)
13108 (call-process "sh" nil t nil "-c" command)))))
13110 (defun gnus-copy-file (file &optional to)
13113 (list (read-file-name "Copy file: " default-directory)
13114 (read-file-name "Copy file to: " default-directory)))
13115 (gnus-set-global-variables)
13116 (or to (setq to (read-file-name "Copy file to: " default-directory)))
13117 (and (file-directory-p to)
13118 (setq to (concat (file-name-as-directory to)
13119 (file-name-nondirectory file))))
13120 (copy-file file to))
13122 ;; Summary kill commands.
13124 (defun gnus-summary-edit-global-kill (article)
13125 "Edit the \"global\" kill file."
13126 (interactive (list (gnus-summary-article-number)))
13127 (gnus-set-global-variables)
13128 (gnus-group-edit-global-kill article))
13130 (defun gnus-summary-edit-local-kill ()
13131 "Edit a local kill file applied to the current newsgroup."
13133 (gnus-set-global-variables)
13134 (setq gnus-current-headers (gnus-summary-article-header))
13135 (gnus-set-global-variables)
13136 (gnus-group-edit-local-kill
13137 (gnus-summary-article-number) gnus-newsgroup-name))
13141 ;;; Gnus article mode
13144 (put 'gnus-article-mode 'mode-class 'special)
13146 (if gnus-article-mode-map
13148 (setq gnus-article-mode-map (make-keymap))
13149 (suppress-keymap gnus-article-mode-map)
13151 (gnus-define-keys gnus-article-mode-map
13152 " " gnus-article-goto-next-page
13153 "\177" gnus-article-goto-prev-page
13154 [delete] gnus-article-goto-prev-page
13155 "\C-c^" gnus-article-refer-article
13156 "h" gnus-article-show-summary
13157 "s" gnus-article-show-summary
13158 "\C-c\C-m" gnus-article-mail
13159 "?" gnus-article-describe-briefly
13160 gnus-mouse-2 gnus-article-push-button
13161 "\r" gnus-article-press-button
13162 "\t" gnus-article-next-button
13163 "\M-\t" gnus-article-prev-button
13164 "\C-c\C-b" gnus-bug)
13166 (substitute-key-definition
13167 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map))
13169 (defun gnus-article-mode ()
13170 "Major mode for displaying an article.
13172 All normal editing commands are switched off.
13174 The following commands are available:
13176 \\<gnus-article-mode-map>
13177 \\[gnus-article-next-page]\t Scroll the article one page forwards
13178 \\[gnus-article-prev-page]\t Scroll the article one page backwards
13179 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
13180 \\[gnus-article-show-summary]\t Display the summary buffer
13181 \\[gnus-article-mail]\t Send a reply to the address near point
13182 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
13183 \\[gnus-info-find-node]\t Go to the Gnus info node"
13185 (when (and menu-bar-mode
13186 (gnus-visual-p 'article-menu 'menu))
13187 (gnus-article-make-menu-bar))
13188 (kill-all-local-variables)
13189 (gnus-simplify-mode-line)
13190 (setq mode-name "Article")
13191 (setq major-mode 'gnus-article-mode)
13192 (make-local-variable 'minor-mode-alist)
13193 (or (assq 'gnus-show-mime minor-mode-alist)
13194 (setq minor-mode-alist
13195 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
13196 (use-local-map gnus-article-mode-map)
13197 (make-local-variable 'page-delimiter)
13198 (setq page-delimiter gnus-page-delimiter)
13199 (buffer-disable-undo (current-buffer))
13200 (setq buffer-read-only t) ;Disable modification
13201 (run-hooks 'gnus-article-mode-hook))
13203 (defun gnus-article-setup-buffer ()
13204 "Initialize the article buffer."
13205 (let* ((name (if gnus-single-article-buffer "*Article*"
13206 (concat "*Article " gnus-newsgroup-name "*")))
13208 (progn (string-match "\\*Article" name)
13209 (concat " *Original Article"
13210 (substring name (match-end 0))))))
13211 (setq gnus-article-buffer name)
13212 (setq gnus-original-article-buffer original)
13213 ;; This might be a variable local to the summary buffer.
13214 (unless gnus-single-article-buffer
13216 (set-buffer gnus-summary-buffer)
13217 (setq gnus-article-buffer name)
13218 (setq gnus-original-article-buffer original)
13219 (gnus-set-global-variables))
13220 (make-local-variable 'gnus-summary-buffer))
13221 ;; Init original article buffer.
13223 (set-buffer (get-buffer-create gnus-original-article-buffer))
13224 (buffer-disable-undo (current-buffer))
13225 (setq major-mode 'gnus-original-article-mode)
13226 (make-local-variable 'gnus-original-article))
13227 (if (get-buffer name)
13230 (buffer-disable-undo (current-buffer))
13231 (setq buffer-read-only t)
13232 (gnus-add-current-to-buffer-list)
13233 (or (eq major-mode 'gnus-article-mode)
13234 (gnus-article-mode))
13237 (set-buffer (get-buffer-create name))
13238 (gnus-add-current-to-buffer-list)
13239 (gnus-article-mode)
13240 (current-buffer)))))
13242 ;; Set article window start at LINE, where LINE is the number of lines
13243 ;; from the head of the article.
13244 (defun gnus-article-set-window-start (&optional line)
13246 (get-buffer-window gnus-article-buffer)
13248 (set-buffer gnus-article-buffer)
13249 (goto-char (point-min))
13252 (gnus-message 6 "Moved to bookmark")
13253 (search-forward "\n\n" nil t)
13254 (forward-line line)
13257 (defun gnus-kill-all-overlays ()
13258 "Delete all overlays in the current buffer."
13259 (when (fboundp 'overlay-lists)
13260 (let* ((overlayss (overlay-lists))
13261 (buffer-read-only nil)
13262 (overlays (nconc (car overlayss) (cdr overlayss))))
13264 (delete-overlay (pop overlays))))))
13266 (defun gnus-request-article-this-buffer (article group)
13267 "Get an article and insert it into this buffer."
13268 (let (do-update-line)
13272 (gnus-kill-all-overlays)
13273 (setq group (or group gnus-newsgroup-name))
13275 ;; Open server if it has closed.
13276 (gnus-check-server (gnus-find-method-for-group group))
13278 ;; Using `gnus-request-article' directly will insert the article into
13279 ;; `nntp-server-buffer' - so we'll save some time by not having to
13280 ;; copy it from the server buffer into the article buffer.
13282 ;; We only request an article by message-id when we do not have the
13283 ;; headers for it, so we'll have to get those.
13284 (when (stringp article)
13285 (let ((gnus-override-method gnus-refer-article-method))
13286 (gnus-read-header article)))
13288 ;; If the article number is negative, that means that this article
13289 ;; doesn't belong in this newsgroup (possibly), so we find its
13290 ;; message-id and request it by id instead of number.
13291 (when (and (numberp article)
13292 gnus-summary-buffer
13293 (get-buffer gnus-summary-buffer)
13294 (buffer-name (get-buffer gnus-summary-buffer)))
13296 (set-buffer gnus-summary-buffer)
13297 (let ((header (gnus-summary-article-header article)))
13300 ((memq article gnus-newsgroup-sparse)
13301 ;; This is a sparse gap article.
13302 (setq do-update-line article)
13303 (setq article (mail-header-id header))
13304 (let ((gnus-override-method gnus-refer-article-method))
13305 (gnus-read-header article)))
13307 ;; It's a real article.
13308 (setq article (mail-header-id header)))
13310 ;; It is an extracted pseudo-article.
13311 (setq article 'pseudo)
13312 (gnus-request-pseudo-article header))))
13314 (let ((method (gnus-find-method-for-group
13315 gnus-newsgroup-name)))
13316 (if (not (eq (car method) 'nneething))
13318 (let ((dir (concat (file-name-as-directory (nth 1 method))
13319 (mail-header-subject header))))
13320 (if (file-directory-p dir)
13322 (setq article 'nneething)
13323 (gnus-group-enter-directory dir)))))))))
13326 ;; We first check `gnus-original-article-buffer'.
13327 ((and (get-buffer gnus-original-article-buffer)
13329 (set-buffer gnus-original-article-buffer)
13330 (and (equal (car gnus-original-article) group)
13331 (eq (cdr gnus-original-article) article))))
13332 (insert-buffer-substring gnus-original-article-buffer)
13334 ;; Check the backlog.
13335 ((and gnus-keep-backlog
13336 (gnus-backlog-request-article group article (current-buffer)))
13338 ;; Check the cache.
13339 ((and gnus-use-cache
13341 (gnus-cache-request-article article group))
13343 ;; Get the article and put into the article buffer.
13344 ((or (stringp article) (numberp article))
13345 (let ((gnus-override-method
13346 (and (stringp article) gnus-refer-article-method))
13347 (buffer-read-only nil))
13349 (gnus-kill-all-overlays)
13350 (if (gnus-request-article article group (current-buffer))
13352 (and gnus-keep-backlog
13353 (gnus-backlog-enter-article
13354 group article (current-buffer)))
13356 ;; It was a pseudo.
13359 ;; Take the article from the original article buffer
13360 ;; and place it in the buffer it's supposed to be in.
13361 (when (and (get-buffer gnus-article-buffer)
13362 (equal (buffer-name (current-buffer))
13363 (buffer-name (get-buffer gnus-article-buffer))))
13365 (if (get-buffer gnus-original-article-buffer)
13366 (set-buffer (get-buffer gnus-original-article-buffer))
13367 (set-buffer (get-buffer-create gnus-original-article-buffer))
13368 (buffer-disable-undo (current-buffer))
13369 (setq major-mode 'gnus-original-article-mode)
13370 (setq buffer-read-only t)
13371 (gnus-add-current-to-buffer-list))
13372 (setq gnus-original-article (cons group article))
13373 (let (buffer-read-only)
13375 (insert-buffer-substring gnus-article-buffer))))
13377 ;; Update sparse articles.
13378 (when do-update-line
13380 (set-buffer gnus-summary-buffer)
13381 (gnus-summary-update-article do-update-line)
13382 (gnus-summary-goto-subject do-update-line)
13383 (set-window-point (get-buffer-window (current-buffer) t)
13386 (defun gnus-read-header (id &optional header)
13387 "Read the headers of article ID and enter them into the Gnus system."
13388 (let ((group gnus-newsgroup-name)
13390 ;; First we check to see whether the header in question is already
13393 ;; This is a Message-ID.
13394 (setq header (or header (gnus-id-to-header id)))
13395 ;; This is an article number.
13396 (setq header (or header (gnus-summary-article-header id))))
13398 (not (memq (mail-header-number header) gnus-newsgroup-sparse)))
13399 ;; We have found the header.
13401 ;; We have to really fetch the header to this article.
13403 (if (gnus-check-backend-function 'request-head group)
13404 (gnus-request-head id group)
13405 (gnus-request-article id group)))
13407 (set-buffer nntp-server-buffer)
13408 (and (search-forward "\n\n" nil t)
13409 (delete-region (1- (point)) (point-max)))
13410 (goto-char (point-max))
13412 (goto-char (point-min))
13416 ((cdr where) (cdr where))
13417 (header (mail-header-number header))
13418 (t gnus-reffed-article-number))
13420 (insert " Article retrieved.\n"))
13422 ; (memq (mail-header-number header) gnus-newsgroup-sparse))
13423 ; (setcar (gnus-id-to-thread id) nil))
13424 (if (not (setq header (car (gnus-get-newsgroup-headers))))
13425 () ; Malformed head.
13426 (unless (memq (mail-header-number header) gnus-newsgroup-sparse)
13427 (if (and (stringp id)
13428 (not (string= (gnus-group-real-name group)
13430 ;; If we fetched by Message-ID and the article came
13431 ;; from a different group, we fudge some bogus article
13432 ;; numbers for this article.
13433 (mail-header-set-number header gnus-reffed-article-number))
13434 (decf gnus-reffed-article-number)
13435 (push header gnus-newsgroup-headers)
13436 (setq gnus-current-headers header)
13437 (push (mail-header-number header) gnus-newsgroup-limit))
13440 (defun gnus-article-prepare (article &optional all-headers header)
13441 "Prepare ARTICLE in article mode buffer.
13442 ARTICLE should either be an article number or a Message-ID.
13443 If ARTICLE is an id, HEADER should be the article headers.
13444 If ALL-HEADERS is non-nil, no headers are hidden."
13446 ;; Make sure we start in a summary buffer.
13447 (unless (eq major-mode 'gnus-summary-mode)
13448 (set-buffer gnus-summary-buffer))
13449 (setq gnus-summary-buffer (current-buffer))
13450 ;; Make sure the connection to the server is alive.
13451 (unless (gnus-server-opened
13452 (gnus-find-method-for-group gnus-newsgroup-name))
13453 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
13454 (gnus-request-group gnus-newsgroup-name t))
13455 (let* ((article (if header (mail-header-number header) article))
13456 (summary-buffer (current-buffer))
13457 (internal-hook gnus-article-internal-prepare-hook)
13458 (group gnus-newsgroup-name)
13461 (gnus-article-setup-buffer)
13462 (set-buffer gnus-article-buffer)
13463 ;; Deactivate active regions.
13464 (when (and (boundp 'transient-mark-mode)
13465 transient-mark-mode)
13466 (setq mark-active nil))
13467 (if (not (setq result (let ((buffer-read-only nil))
13468 (gnus-request-article-this-buffer
13470 ;; There is no such article.
13472 (when (and (numberp article)
13473 (not (memq article gnus-newsgroup-sparse)))
13474 (setq gnus-article-current
13475 (cons gnus-newsgroup-name article))
13476 (set-buffer gnus-summary-buffer)
13477 (setq gnus-current-article article)
13478 (gnus-summary-mark-article article gnus-canceled-mark))
13479 (unless (memq article gnus-newsgroup-sparse)
13481 1 "No such article (may have expired or been canceled)")
13484 (if (or (eq result 'pseudo) (eq result 'nneething))
13487 (set-buffer summary-buffer)
13488 (setq gnus-last-article gnus-current-article
13489 gnus-newsgroup-history (cons gnus-current-article
13490 gnus-newsgroup-history)
13491 gnus-current-article 0
13492 gnus-current-headers nil
13493 gnus-article-current nil)
13494 (if (eq result 'nneething)
13495 (gnus-configure-windows 'summary)
13496 (gnus-configure-windows 'article))
13497 (gnus-set-global-variables))
13498 (gnus-set-mode-line 'article))
13499 ;; The result from the `request' was an actual article -
13500 ;; or at least some text that is now displayed in the
13502 (if (and (numberp article)
13503 (not (eq article gnus-current-article)))
13504 ;; Seems like a new article has been selected.
13505 ;; `gnus-current-article' must be an article number.
13507 (set-buffer summary-buffer)
13508 (setq gnus-last-article gnus-current-article
13509 gnus-newsgroup-history (cons gnus-current-article
13510 gnus-newsgroup-history)
13511 gnus-current-article article
13512 gnus-current-headers
13513 (gnus-summary-article-header gnus-current-article)
13514 gnus-article-current
13515 (cons gnus-newsgroup-name gnus-current-article))
13516 (unless (vectorp gnus-current-headers)
13517 (setq gnus-current-headers nil))
13518 (gnus-summary-show-thread)
13519 (run-hooks 'gnus-mark-article-hook)
13520 (gnus-set-mode-line 'summary)
13521 (and (gnus-visual-p 'article-highlight 'highlight)
13522 (run-hooks 'gnus-visual-mark-article-hook))
13523 ;; Set the global newsgroup variables here.
13524 ;; Suggested by Jim Sisolak
13525 ;; <sisolak@trans4.neep.wisc.edu>.
13526 (gnus-set-global-variables)
13527 (setq gnus-have-all-headers
13528 (or all-headers gnus-show-all-headers))
13529 (and gnus-use-cache
13530 (vectorp (gnus-summary-article-header article))
13531 (gnus-cache-possibly-enter-article
13533 (gnus-summary-article-header article)
13534 (memq article gnus-newsgroup-marked)
13535 (memq article gnus-newsgroup-dormant)
13536 (memq article gnus-newsgroup-unreads)))))
13537 ;; Hooks for getting information from the article.
13538 ;; This hook must be called before being narrowed.
13539 (let (buffer-read-only)
13540 (run-hooks 'internal-hook)
13541 (run-hooks 'gnus-article-prepare-hook)
13542 ;; Decode MIME message.
13544 (if (or (not gnus-strict-mime)
13545 (gnus-fetch-field "Mime-Version"))
13546 (funcall gnus-show-mime-method)
13547 (funcall gnus-decode-encoded-word-method)))
13548 ;; Perform the article display hooks.
13549 (run-hooks 'gnus-article-display-hook))
13551 (goto-char (point-min))
13552 (and gnus-break-pages (gnus-narrow-to-page))
13553 (gnus-set-mode-line 'article)
13554 (gnus-configure-windows 'article)
13555 (goto-char (point-min))
13558 (defun gnus-article-show-all-headers ()
13559 "Show all article headers in article mode buffer."
13561 (gnus-article-setup-buffer)
13562 (set-buffer gnus-article-buffer)
13563 (let ((buffer-read-only nil))
13564 (gnus-unhide-text (point-min) (point-max)))))
13566 (defun gnus-article-hide-headers-if-wanted ()
13567 "Hide unwanted headers if `gnus-have-all-headers' is nil.
13568 Provided for backwards compatibility."
13569 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers)
13570 gnus-inhibit-hiding
13571 (gnus-article-hide-headers)))
13573 (defun gnus-article-hide-headers (&optional arg delete)
13574 "Toggle whether to hide unwanted headers and possibly sort them as well.
13575 If given a negative prefix, always show; if given a positive prefix,
13578 (unless (gnus-article-check-hidden-text 'headers arg)
13579 ;; This function might be inhibited.
13580 (unless gnus-inhibit-hiding
13582 (set-buffer gnus-article-buffer)
13584 (let ((buffer-read-only nil)
13585 (props (nconc (list 'gnus-type 'headers)
13586 gnus-hidden-properties))
13587 (ignored (when (not (stringp gnus-visible-headers))
13588 (cond ((stringp gnus-ignored-headers)
13589 gnus-ignored-headers)
13590 ((listp gnus-ignored-headers)
13591 (mapconcat 'identity gnus-ignored-headers
13594 (cond ((stringp gnus-visible-headers)
13595 gnus-visible-headers)
13596 ((and gnus-visible-headers
13597 (listp gnus-visible-headers))
13598 (mapconcat 'identity gnus-visible-headers "\\|"))))
13600 ;; First we narrow to just the headers.
13602 (goto-char (point-min))
13603 ;; Hide any "From " lines at the beginning of (mail) articles.
13604 (while (looking-at "From ")
13607 (gnus-hide-text (point-min) (point) props))
13608 ;; Then treat the rest of the header lines.
13611 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
13612 ;; Then we use the two regular expressions
13613 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
13614 ;; select which header lines is to remain visible in the
13616 (goto-char (point-min))
13617 (while (re-search-forward "^[^ \t]*:" nil t)
13618 (beginning-of-line)
13619 ;; We add the headers we want to keep to a list and delete
13620 ;; them from the buffer.
13621 (if (or (and visible (looking-at visible))
13622 (and ignored (not (looking-at ignored))))
13624 (push (buffer-substring
13628 ;; Be sure to get multi-line headers...
13629 (re-search-forward "^[^ \t]*:" nil t)
13630 (beginning-of-line)
13633 (delete-region beg (point)))
13635 ;; Sort the headers that we want to display.
13636 (setq want-list (sort want-list 'gnus-article-header-less))
13637 (goto-char (point-min))
13639 (insert (pop want-list)))
13640 ;; We make the unwanted headers invisible.
13642 (delete-region (point-min) (point-max))
13643 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
13644 (gnus-hide-text-type (point) (point-max) 'headers))))))))
13646 (defsubst gnus-article-header-rank (header)
13647 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
13648 (let ((list gnus-sorted-header-list)
13651 (when (string-match (car list) header)
13653 (setq list (cdr list))
13657 (defun gnus-article-header-less (h1 h2)
13658 "Say whether string H1 is \"less\" than string H2."
13659 (< (gnus-article-header-rank h1)
13660 (gnus-article-header-rank h2)))
13662 (defun gnus-article-hide-boring-headers (&optional arg)
13663 "Toggle hiding of headers that aren't very interesting.
13664 If given a negative prefix, always show; if given a positive prefix,
13667 (unless (gnus-article-check-hidden-text 'boring-headers arg)
13669 (set-buffer gnus-article-buffer)
13671 (let ((buffer-read-only nil)
13672 (list gnus-boring-article-headers)
13673 (inhibit-point-motion-hooks t)
13675 (nnheader-narrow-to-headers)
13677 (setq elem (pop list))
13678 (goto-char (point-min))
13680 ;; Hide empty headers.
13682 (while (re-search-forward "^[^:]+:[ \t]\n[^ \t]" nil t)
13684 (gnus-hide-text-type
13685 (progn (beginning-of-line) (point))
13688 (if (re-search-forward "^[^ \t]" nil t)
13689 (match-beginning 0)
13692 ;; Hide boring Newsgroups header.
13693 ((eq elem 'newsgroups)
13694 (when (equal (mail-fetch-field "newsgroups")
13695 (gnus-group-real-name gnus-newsgroup-name))
13696 (gnus-article-hide-header "newsgroups")))
13697 ((eq elem 'followup-to)
13698 (when (equal (mail-fetch-field "followup-to")
13699 (mail-fetch-field "newsgroups"))
13700 (gnus-article-hide-header "followup-to")))
13701 ((eq elem 'reply-to)
13702 (let ((from (mail-fetch-field "from"))
13703 (reply-to (mail-fetch-field "reply-to")))
13707 (nth 1 (mail-extract-address-components from))
13708 (nth 1 (mail-extract-address-components reply-to))))
13709 (gnus-article-hide-header "reply-to"))))
13711 (let ((date (mail-fetch-field "date")))
13713 (< (gnus-days-between date (current-time-string))
13715 (gnus-article-hide-header "date")))))))))))
13717 (defun gnus-article-hide-header (header)
13719 (goto-char (point-min))
13720 (when (re-search-forward (concat "^" header ":") nil t)
13721 (gnus-hide-text-type
13722 (progn (beginning-of-line) (point))
13725 (if (re-search-forward "^[^ \t]" nil t)
13726 (match-beginning 0)
13728 'boring-headers))))
13730 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
13731 (defun gnus-article-treat-overstrike ()
13732 "Translate overstrikes into bold text."
13735 (set-buffer gnus-article-buffer)
13736 (let ((buffer-read-only nil))
13737 (while (search-forward "\b" nil t)
13738 (let ((next (following-char))
13739 (previous (char-after (- (point) 2))))
13740 (cond ((eq next previous)
13741 (put-text-property (- (point) 2) (point) 'invisible t)
13742 (put-text-property (point) (1+ (point)) 'face 'bold))
13744 (put-text-property (1- (point)) (1+ (point)) 'invisible t)
13746 (- (point) 2) (1- (point)) 'face 'underline))
13748 (put-text-property (- (point) 2) (point) 'invisible t)
13750 (point) (1+ (point)) 'face 'underline))))))))
13752 (defun gnus-article-word-wrap ()
13753 "Format too long lines."
13756 (set-buffer gnus-article-buffer)
13757 (let ((buffer-read-only nil))
13759 (goto-char (point-min))
13760 (search-forward "\n\n" nil t)
13762 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
13763 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
13764 (adaptive-fill-mode t))
13765 (while (not (eobp))
13766 (and (>= (current-column) (min fill-column (window-width)))
13767 (/= (preceding-char) ?:)
13768 (fill-paragraph nil))
13769 (end-of-line 2))))))
13771 (defun gnus-article-remove-cr ()
13772 "Remove carriage returns from an article."
13775 (set-buffer gnus-article-buffer)
13776 (let ((buffer-read-only nil))
13777 (goto-char (point-min))
13778 (while (search-forward "\r" nil t)
13779 (replace-match "" t t)))))
13781 (defun gnus-article-remove-trailing-blank-lines ()
13782 "Remove all trailing blank lines from the article."
13785 (set-buffer gnus-article-buffer)
13786 (let ((buffer-read-only nil))
13787 (goto-char (point-max))
13791 (while (looking-at "^[ \t]*$")
13796 (defun gnus-article-display-x-face (&optional force)
13797 "Look for an X-Face header and display it if present."
13798 (interactive (list 'force))
13800 (set-buffer gnus-article-buffer)
13801 ;; Delete the old process, if any.
13802 (when (process-status "gnus-x-face")
13803 (delete-process "gnus-x-face"))
13804 (let ((inhibit-point-motion-hooks t)
13805 (case-fold-search nil)
13808 (nnheader-narrow-to-headers)
13809 (setq from (mail-fetch-field "from"))
13810 (goto-char (point-min))
13811 (when (and gnus-article-x-face-command
13813 ;; Check whether this face is censored.
13814 (not gnus-article-x-face-too-ugly)
13815 (and gnus-article-x-face-too-ugly from
13816 (not (string-match gnus-article-x-face-too-ugly
13818 ;; Has to be present.
13819 (re-search-forward "^X-Face: " nil t))
13820 ;; We now have the area of the buffer where the X-Face is stored.
13821 (let ((beg (point))
13822 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
13823 ;; We display the face.
13824 (if (symbolp gnus-article-x-face-command)
13825 ;; The command is a lisp function, so we call it.
13826 (if (gnus-functionp gnus-article-x-face-command)
13827 (funcall gnus-article-x-face-command beg end)
13828 (error "%s is not a function" gnus-article-x-face-command))
13829 ;; The command is a string, so we interpret the command
13830 ;; as a, well, command, and fork it off.
13831 (let ((process-connection-type nil))
13832 (process-kill-without-query
13834 "gnus-x-face" nil "sh" "-c" gnus-article-x-face-command))
13835 (process-send-region "gnus-x-face" beg end)
13836 (process-send-eof "gnus-x-face")))))))))
13838 (defun gnus-headers-decode-quoted-printable ()
13839 "Hack to remove QP encoding from headers."
13840 (let ((case-fold-search t)
13841 (inhibit-point-motion-hooks t)
13843 (goto-char (point-min))
13844 (while (re-search-forward "=\\?iso-8859-1\\?q\\?\\([^?\t\n]*\\)\\?=" nil t)
13845 (setq string (match-string 1))
13846 (narrow-to-region (match-beginning 0) (match-end 0))
13847 (delete-region (point-min) (point-max))
13849 (gnus-mime-decode-quoted-printable (goto-char (point-min)) (point-max))
13850 (subst-char-in-region (point-min) (point-max) ?_ ? )
13852 (goto-char (point-min)))))
13854 (defun gnus-article-de-quoted-unreadable (&optional force)
13855 "Do a naive translation of a quoted-printable-encoded article.
13856 This is in no way, shape or form meant as a replacement for real MIME
13857 processing, but is simply a stop-gap measure until MIME support is
13859 If FORCE, decode the article whether it is marked as quoted-printable
13861 (interactive (list 'force))
13863 (set-buffer gnus-article-buffer)
13864 (let ((case-fold-search t)
13865 (buffer-read-only nil)
13866 (type (gnus-fetch-field "content-transfer-encoding")))
13868 (and type (string-match "quoted-printable" type)))
13869 (gnus-headers-decode-quoted-printable)
13870 (goto-char (point-min))
13871 (search-forward "\n\n" nil 'move)
13872 (gnus-mime-decode-quoted-printable (point) (point-max))))))
13874 (defun gnus-mime-decode-quoted-printable (from to)
13875 "Decode Quoted-Printable in the region between FROM and TO."
13877 (while (search-forward "=" to t)
13878 (cond ((eq (following-char) ?\n)
13881 ((looking-at "[0-9A-F][0-9A-F]")
13883 (insert (hexl-hex-string-to-integer
13884 (buffer-substring (point) (+ 2 (point)))))
13888 ((gnus-message 3 "Malformed MIME quoted-printable message")))))
13890 (defun gnus-article-hide-pgp (&optional arg)
13891 "Toggle hiding of any PGP headers and signatures in the current article.
13892 If given a negative prefix, always show; if given a positive prefix,
13895 (unless (gnus-article-check-hidden-text 'pgp arg)
13897 (set-buffer gnus-article-buffer)
13898 (let ((props (nconc (list 'gnus-type 'pgp) gnus-hidden-properties))
13899 buffer-read-only beg end)
13901 (goto-char (point-min))
13902 ;; Hide the "header".
13903 (and (search-forward "\n-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
13904 (gnus-hide-text (match-beginning 0) (match-end 0) props))
13906 ;; Hide the actual signature.
13907 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
13908 (setq end (1+ (match-beginning 0)))
13911 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
13913 ;; Perhaps we shouldn't hide to the end of the buffer
13914 ;; if there is no end to the signature?
13917 ;; Hide "- " PGP quotation markers.
13918 (when (and beg end)
13919 (narrow-to-region beg end)
13920 (goto-char (point-min))
13921 (while (re-search-forward "^- " nil t)
13922 (gnus-hide-text (match-beginning 0) (match-end 0) props))
13925 (defun gnus-article-hide-signature (&optional arg)
13926 "Hide the signature in the current article.
13927 If given a negative prefix, always show; if given a positive prefix,
13930 (unless (gnus-article-check-hidden-text 'signature arg)
13932 (set-buffer gnus-article-buffer)
13934 (let ((buffer-read-only nil))
13935 (when (gnus-narrow-to-signature)
13936 (gnus-hide-text-type (point-min) (point-max) 'signature)))))))
13938 (defun gnus-article-strip-leading-blank-lines ()
13939 "Remove all blank lines from the beginning of the article."
13942 (set-buffer gnus-article-buffer)
13943 (let (buffer-read-only)
13944 (goto-char (point-min))
13945 (when (search-forward "\n\n" nil t)
13946 (while (looking-at "[ \t]$")
13947 (gnus-delete-line))))))
13949 (defun gnus-narrow-to-signature ()
13950 "Narrow to the signature."
13952 (goto-char (point-max))
13953 (when (re-search-backward gnus-signature-separator nil t)
13955 (when (or (null gnus-signature-limit)
13956 (and (numberp gnus-signature-limit)
13957 (< (- (point-max) (point)) gnus-signature-limit))
13958 (and (gnus-functionp gnus-signature-limit)
13959 (funcall gnus-signature-limit))
13960 (and (stringp gnus-signature-limit)
13961 (not (re-search-forward gnus-signature-limit nil t))))
13962 (narrow-to-region (point) (point-max))
13965 (defun gnus-article-check-hidden-text (type arg)
13966 "Return nil if hiding is necessary."
13968 (set-buffer gnus-article-buffer)
13969 (let ((hide (gnus-article-hidden-text-p type)))
13970 (cond ((or (and (null arg) (eq hide 'hidden))
13971 (and arg (< 0 (prefix-numeric-value arg))))
13972 (gnus-article-show-hidden-text type))
13974 (gnus-article-show-hidden-text type t))
13977 (defun gnus-article-hidden-text-p (type)
13978 "Say whether the current buffer contains hidden text of type TYPE."
13979 (let ((pos (text-property-any (point-min) (point-max) 'gnus-type type)))
13981 (if (get-text-property pos 'invisible)
13985 (defun gnus-article-hide (&optional arg force)
13986 "Hide all the gruft in the current article.
13987 This means that PGP stuff, signatures, cited text and (some)
13988 headers will be hidden.
13989 If given a prefix, show the hidden text instead."
13990 (interactive (list current-prefix-arg 'force))
13991 (gnus-article-hide-headers arg)
13992 (gnus-article-hide-pgp arg)
13993 (gnus-article-hide-citation-maybe arg force)
13994 (gnus-article-hide-signature arg))
13996 (defun gnus-article-show-hidden-text (type &optional hide)
13997 "Show all hidden text of type TYPE.
13998 If HIDE, hide the text instead."
14000 (set-buffer gnus-article-buffer)
14001 (let ((buffer-read-only nil)
14002 (inhibit-point-motion-hooks t)
14004 (while (gnus-goto-char (text-property-any
14005 beg (point-max) 'gnus-type type))
14009 (gnus-hide-text beg (point) gnus-hidden-properties)
14010 (gnus-unhide-text beg (point)))
14011 (setq beg (point)))
14014 (defvar gnus-article-time-units
14015 `((year . ,(* 365.25 24 60 60))
14016 (week . ,(* 7 24 60 60))
14017 (day . ,(* 24 60 60))
14018 (hour . ,(* 60 60))
14021 "Mapping from time units to seconds.")
14023 (defun gnus-article-date-ut (&optional type highlight)
14024 "Convert DATE date to universal time in the current article.
14025 If TYPE is `local', convert to local time; if it is `lapsed', output
14026 how much time has lapsed since DATE."
14027 (interactive (list 'ut t))
14028 (let* ((header (or gnus-current-headers
14029 (gnus-summary-article-header) ""))
14030 (date (and (vectorp header) (mail-header-date header)))
14031 (date-regexp "^Date: \\|^X-Sent: ")
14032 (now (current-time))
14033 (inhibit-point-motion-hooks t))
14034 (when (and date (not (string= date "")))
14036 (set-buffer gnus-article-buffer)
14038 (nnheader-narrow-to-headers)
14039 (let ((buffer-read-only nil))
14040 ;; Delete any old Date headers.
14041 (if (zerop (nnheader-remove-header date-regexp t))
14042 (beginning-of-line)
14043 (goto-char (point-max)))
14046 ;; Convert to the local timezone. We have to slap a
14047 ;; `condition-case' round the calls to the timezone
14048 ;; functions since they aren't particularly resistant to
14051 (concat "Date: " (condition-case ()
14052 (timezone-make-date-arpa-standard date)
14055 ;; Convert to Universal Time.
14059 (timezone-make-date-arpa-standard date nil "UT")
14062 ;; Get the original date from the article.
14063 ((eq type 'original)
14064 (concat "Date: " date "\n"))
14065 ;; Do an X-Sent lapsed format.
14067 ;; If the date is seriously mangled, the timezone
14068 ;; functions are liable to bug out, so we condition-case
14069 ;; the entire thing.
14074 (timezone-make-date-arpa-standard
14075 (current-time-string now)
14076 (current-time-zone now) "UT"))
14078 (timezone-make-date-arpa-standard
14081 (real-sec (+ (* (float (car real-time)) 65536)
14083 (sec (abs real-sec))
14089 ;; This is a bit convoluted, but basically we go
14090 ;; through the time units for years, weeks, etc,
14091 ;; and divide things to see whether that results
14092 ;; in positive answers.
14095 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
14096 ;; The (remaining) seconds are too few to
14097 ;; be divided into this time unit.
14099 ;; It's big enough, so we output it.
14100 (setq sec (- sec (* num (cdr unit))))
14102 (concat (if prev ", " "") (int-to-string
14104 " " (symbol-name (car unit))
14105 (if (> num 1) "s" ""))
14107 gnus-article-time-units "")
14108 ;; If dates are odd, then it might appear like the
14109 ;; article was sent in the future.
14112 " in the future\n")))))
14114 (error "Unknown conversion type: %s" type)))))
14115 ;; Do highlighting.
14116 (when (and highlight (gnus-visual-p 'article-highlight 'highlight))
14117 (gnus-article-highlight-headers)))))))
14119 (defun gnus-article-date-local (&optional highlight)
14120 "Convert the current article date to the local timezone."
14121 (interactive (list t))
14122 (gnus-article-date-ut 'local highlight))
14124 (defun gnus-article-date-original (&optional highlight)
14125 "Convert the current article date to what it was originally.
14126 This is only useful if you have used some other date conversion
14127 function and want to see what the date was before converting."
14128 (interactive (list t))
14129 (gnus-article-date-ut 'original highlight))
14131 (defun gnus-article-date-lapsed (&optional highlight)
14132 "Convert the current article date to time lapsed since it was sent."
14133 (interactive (list t))
14134 (gnus-article-date-ut 'lapsed highlight))
14136 (defun gnus-article-maybe-highlight ()
14137 "Do some article highlighting if `gnus-visual' is non-nil."
14138 (if (gnus-visual-p 'article-highlight 'highlight)
14139 (gnus-article-highlight-some)))
14143 (defun gnus-output-to-rmail (file-name)
14144 "Append the current article to an Rmail file named FILE-NAME."
14146 ;; Most of these codes are borrowed from rmailout.el.
14147 (setq file-name (expand-file-name file-name))
14148 (setq rmail-default-rmail-file file-name)
14149 (let ((artbuf (current-buffer))
14150 (tmpbuf (get-buffer-create " *Gnus-output*")))
14152 (or (get-file-buffer file-name)
14153 (file-exists-p file-name)
14154 (if (gnus-yes-or-no-p
14155 (concat "\"" file-name "\" does not exist, create it? "))
14156 (let ((file-buffer (create-file-buffer file-name)))
14158 (set-buffer file-buffer)
14159 (rmail-insert-rmail-file-header)
14160 (let ((require-final-newline nil))
14161 (write-region (point-min) (point-max) file-name t 1)))
14162 (kill-buffer file-buffer))
14163 (error "Output file does not exist")))
14164 (set-buffer tmpbuf)
14165 (buffer-disable-undo (current-buffer))
14167 (insert-buffer-substring artbuf)
14168 (gnus-convert-article-to-rmail)
14169 ;; Decide whether to append to a file or to an Emacs buffer.
14170 (let ((outbuf (get-file-buffer file-name)))
14172 (append-to-file (point-min) (point-max) file-name)
14173 ;; File has been visited, in buffer OUTBUF.
14174 (set-buffer outbuf)
14175 (let ((buffer-read-only nil)
14176 (msg (and (boundp 'rmail-current-message)
14177 (symbol-value 'rmail-current-message))))
14178 ;; If MSG is non-nil, buffer is in RMAIL mode.
14181 (narrow-to-region (point-max) (point-max))))
14182 (insert-buffer-substring tmpbuf)
14185 (goto-char (point-min))
14187 (search-backward "\^_")
14188 (narrow-to-region (point) (point-max))
14189 (goto-char (1+ (point-min)))
14190 (rmail-count-new-messages t)
14191 (rmail-show-message msg)))))))
14192 (kill-buffer tmpbuf)))
14194 (defun gnus-output-to-file (file-name)
14195 "Append the current article to a file named FILE-NAME."
14196 (setq file-name (expand-file-name file-name))
14197 (let ((artbuf (current-buffer))
14198 (tmpbuf (get-buffer-create " *Gnus-output*")))
14200 (set-buffer tmpbuf)
14201 (buffer-disable-undo (current-buffer))
14203 (insert-buffer-substring artbuf)
14204 ;; Append newline at end of the buffer as separator, and then
14205 ;; save it to file.
14206 (goto-char (point-max))
14208 (append-to-file (point-min) (point-max) file-name))
14209 (kill-buffer tmpbuf)))
14211 (defun gnus-convert-article-to-rmail ()
14212 "Convert article in current buffer to Rmail message format."
14213 (let ((buffer-read-only nil))
14214 ;; Convert article directly into Babyl format.
14215 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
14216 (goto-char (point-min))
14217 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
14218 (while (search-forward "\n\^_" nil t) ;single char
14219 (replace-match "\n^_" t t)) ;2 chars: "^" and "_"
14220 (goto-char (point-max))
14223 (defun gnus-narrow-to-page (&optional arg)
14224 "Narrow the article buffer to a page.
14225 If given a numerical ARG, move forward ARG pages."
14227 (setq arg (if arg (prefix-numeric-value arg) 0))
14229 (set-buffer gnus-article-buffer)
14230 (goto-char (point-min))
14232 (when (gnus-visual-p 'page-marker)
14233 (let ((buffer-read-only nil))
14234 (gnus-remove-text-with-property 'gnus-prev)
14235 (gnus-remove-text-with-property 'gnus-next)))
14238 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
14240 (re-search-forward page-delimiter nil 'move arg)))
14241 (goto-char (match-end 0)))
14244 (if (re-search-forward page-delimiter nil 'move)
14245 (match-beginning 0)
14247 (when (and (gnus-visual-p 'page-marker)
14248 (not (= (point-min) 1)))
14250 (goto-char (point-min))
14251 (gnus-insert-prev-page-button)))
14252 (when (and (gnus-visual-p 'page-marker)
14253 (not (= (1- (point-max)) (buffer-size))))
14255 (goto-char (point-max))
14256 (gnus-insert-next-page-button)))))
14258 ;; Article mode commands
14260 (defun gnus-article-goto-next-page ()
14261 "Show the next page of the article."
14263 (when (gnus-article-next-page)
14264 (gnus-article-read-summary-keys nil ?n)))
14266 (defun gnus-article-goto-prev-page ()
14267 "Show the next page of the article."
14269 (if (bobp) (gnus-article-read-summary-keys nil ?n)
14270 (gnus-article-prev-page nil)))
14272 (defun gnus-article-next-page (&optional lines)
14273 "Show the next page of the current article.
14274 If end of article, return non-nil. Otherwise return nil.
14275 Argument LINES specifies lines to be scrolled up."
14277 (move-to-window-line -1)
14278 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
14279 (if (save-excursion
14281 (and (pos-visible-in-window-p) ;Not continuation line.
14283 ;; Nothing in this page.
14284 (if (or (not gnus-break-pages)
14287 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
14289 (gnus-narrow-to-page 1) ;Go to next page.
14291 ;; More in this page.
14295 ;; Long lines may cause an end-of-buffer error.
14296 (goto-char (point-max))))
14297 (move-to-window-line 0)
14300 (defun gnus-article-prev-page (&optional lines)
14301 "Show previous page of current article.
14302 Argument LINES specifies lines to be scrolled down."
14304 (move-to-window-line 0)
14305 (if (and gnus-break-pages
14307 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
14309 (gnus-narrow-to-page -1) ;Go to previous page.
14310 (goto-char (point-max))
14314 (scroll-down lines)
14316 (move-to-window-line 0))))
14318 (defun gnus-article-refer-article ()
14319 "Read article specified by message-id around point."
14321 (let ((point (point)))
14322 (search-forward ">" nil t) ;Move point to end of "<....>".
14323 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
14324 (let ((message-id (match-string 1)))
14326 (set-buffer gnus-summary-buffer)
14327 (gnus-summary-refer-article message-id))
14328 (goto-char (point))
14329 (error "No references around point"))))
14331 (defun gnus-article-show-summary ()
14332 "Reconfigure windows to show summary buffer."
14334 (gnus-configure-windows 'article)
14335 (gnus-summary-goto-subject gnus-current-article))
14337 (defun gnus-article-describe-briefly ()
14338 "Describe article mode commands briefly."
14341 (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")))
14343 (defun gnus-article-summary-command ()
14344 "Execute the last keystroke in the summary buffer."
14346 (let ((obuf (current-buffer))
14347 (owin (current-window-configuration))
14349 (switch-to-buffer gnus-summary-buffer 'norecord)
14350 (setq func (lookup-key (current-local-map) (this-command-keys)))
14351 (call-interactively func)
14353 (set-window-configuration owin)
14354 (set-window-point (get-buffer-window (current-buffer)) (point))))
14356 (defun gnus-article-summary-command-nosave ()
14357 "Execute the last keystroke in the summary buffer."
14360 (pop-to-buffer gnus-summary-buffer 'norecord)
14361 (setq func (lookup-key (current-local-map) (this-command-keys)))
14362 (call-interactively func)))
14364 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
14365 "Read a summary buffer key sequence and execute it from the article buffer."
14368 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
14369 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
14373 (set-buffer gnus-summary-buffer)
14374 (push (or key last-command-event) unread-command-events)
14375 (setq keys (read-key-sequence nil)))
14378 (if (member keys nosaves)
14380 (pop-to-buffer gnus-summary-buffer 'norecord)
14381 (if (setq func (lookup-key (current-local-map) keys))
14382 (call-interactively func)
14384 (let ((obuf (current-buffer))
14385 (owin (current-window-configuration))
14388 (if not-restore-window
14389 (pop-to-buffer gnus-summary-buffer 'norecord)
14390 (switch-to-buffer gnus-summary-buffer 'norecord))
14391 (setq in-buffer (current-buffer))
14392 (if (setq func (lookup-key (current-local-map) keys))
14393 (call-interactively func)
14395 (when (eq in-buffer (current-buffer))
14397 (unless not-restore-window
14398 (set-window-configuration owin))
14399 (set-window-point (get-buffer-window (current-buffer)) opoint))))))
14403 ;;; Kill file handling.
14407 (defalias 'gnus-batch-kill 'gnus-batch-score)
14409 (defun gnus-batch-score ()
14410 "Run batched scoring.
14411 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
14412 Newsgroups is a list of strings in Bnews format. If you want to score
14413 the comp hierarchy, you'd say \"comp.all\". If you would not like to
14414 score the alt hierarchy, you'd say \"!alt.all\"."
14417 (gnus-newsrc-parse-options
14418 (apply (function concat)
14419 (mapcar (lambda (g) (concat g " "))
14420 command-line-args-left))))
14421 (gnus-expert-user t)
14422 (nnmail-spool-file nil)
14423 (gnus-use-dribble-file nil)
14424 (yes (car yes-and-no))
14425 (no (cdr yes-and-no))
14427 ;; Disable verbose message.
14428 gnus-novice-user gnus-large-newsgroup)
14429 ;; Eat all arguments.
14430 (setq command-line-args-left nil)
14433 ;; Apply kills to specified newsgroups in command line arguments.
14434 (setq newsrc (cdr gnus-newsrc-alist))
14436 (setq group (caar newsrc))
14437 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
14438 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed)
14440 (or (eq (car entry) t)
14441 (not (zerop (car entry)))))
14442 (if yes (string-match yes group) t)
14443 (or (null no) (not (string-match no group))))
14445 (gnus-summary-read-group group nil t nil t)
14446 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
14447 (gnus-summary-exit))))
14448 (setq newsrc (cdr newsrc)))
14450 (switch-to-buffer gnus-group-buffer)
14451 (gnus-group-save-newsrc)))
14453 (defun gnus-apply-kill-file ()
14454 "Apply a kill file to the current newsgroup.
14455 Returns the number of articles marked as read."
14456 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
14457 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14458 (gnus-apply-kill-file-internal)
14461 (defun gnus-kill-save-kill-buffer ()
14462 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14463 (when (get-file-buffer file)
14465 (set-buffer (get-file-buffer file))
14466 (and (buffer-modified-p) (save-buffer))
14467 (kill-buffer (current-buffer))))))
14469 (defvar gnus-kill-file-name "KILL"
14470 "Suffix of the kill files.")
14472 (defun gnus-newsgroup-kill-file (newsgroup)
14473 "Return the name of a kill file name for NEWSGROUP.
14474 If NEWSGROUP is nil, return the global kill file name instead."
14476 ;; The global KILL file is placed at top of the directory.
14477 ((or (null newsgroup)
14478 (string-equal newsgroup ""))
14479 (expand-file-name gnus-kill-file-name
14480 (or gnus-kill-files-directory "~/News")))
14481 ;; Append ".KILL" to newsgroup name.
14482 ((gnus-use-long-file-name 'not-kill)
14483 (expand-file-name (concat (gnus-newsgroup-savable-name newsgroup)
14484 "." gnus-kill-file-name)
14485 (or gnus-kill-files-directory "~/News")))
14486 ;; Place "KILL" under the hierarchical directory.
14488 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
14489 "/" gnus-kill-file-name)
14490 (or gnus-kill-files-directory "~/News")))))
14497 (defvar gnus-dribble-ignore nil)
14498 (defvar gnus-dribble-eval-file nil)
14500 (defun gnus-dribble-file-name ()
14501 "Return the dribble file for the current .newsrc."
14503 (if gnus-dribble-directory
14504 (concat (file-name-as-directory gnus-dribble-directory)
14505 (file-name-nondirectory gnus-current-startup-file))
14506 gnus-current-startup-file)
14509 (defun gnus-dribble-enter (string)
14510 "Enter STRING into the dribble buffer."
14511 (if (and (not gnus-dribble-ignore)
14512 gnus-dribble-buffer
14513 (buffer-name gnus-dribble-buffer))
14514 (let ((obuf (current-buffer)))
14515 (set-buffer gnus-dribble-buffer)
14516 (insert string "\n")
14517 (set-window-point (get-buffer-window (current-buffer)) (point-max))
14518 (set-buffer obuf))))
14520 (defun gnus-dribble-read-file ()
14521 "Read the dribble file from disk."
14522 (let ((dribble-file (gnus-dribble-file-name)))
14524 (set-buffer (setq gnus-dribble-buffer
14526 (file-name-nondirectory dribble-file))))
14527 (gnus-add-current-to-buffer-list)
14529 (setq buffer-file-name dribble-file)
14531 (buffer-disable-undo (current-buffer))
14532 (bury-buffer (current-buffer))
14533 (set-buffer-modified-p nil)
14534 (let ((auto (make-auto-save-file-name))
14535 (gnus-dribble-ignore t))
14536 (when (or (file-exists-p auto) (file-exists-p dribble-file))
14537 ;; Load whichever file is newest -- the auto save file
14538 ;; or the "real" file.
14539 (if (file-newer-than-file-p auto dribble-file)
14540 (insert-file-contents auto)
14541 (insert-file-contents dribble-file))
14542 (unless (zerop (buffer-size))
14543 (set-buffer-modified-p t))
14544 ;; Set the file modes to reflect the .newsrc file modes.
14546 (when (file-exists-p gnus-current-startup-file)
14547 (set-file-modes dribble-file
14548 (file-modes gnus-current-startup-file)))
14549 ;; Possibly eval the file later.
14550 (when (gnus-y-or-n-p
14551 "Auto-save file exists. Do you want to read it? ")
14552 (setq gnus-dribble-eval-file t)))))))
14554 (defun gnus-dribble-eval-file ()
14555 (if (not gnus-dribble-eval-file)
14557 (setq gnus-dribble-eval-file nil)
14559 (let ((gnus-dribble-ignore t))
14560 (set-buffer gnus-dribble-buffer)
14561 (eval-buffer (current-buffer))))))
14563 (defun gnus-dribble-delete-file ()
14564 (if (file-exists-p (gnus-dribble-file-name))
14565 (delete-file (gnus-dribble-file-name)))
14566 (if gnus-dribble-buffer
14568 (set-buffer gnus-dribble-buffer)
14569 (let ((auto (make-auto-save-file-name)))
14570 (if (file-exists-p auto)
14571 (delete-file auto))
14573 (set-buffer-modified-p nil)))))
14575 (defun gnus-dribble-save ()
14576 (if (and gnus-dribble-buffer
14577 (buffer-name gnus-dribble-buffer))
14579 (set-buffer gnus-dribble-buffer)
14582 (defun gnus-dribble-clear ()
14584 (if (gnus-buffer-exists-p gnus-dribble-buffer)
14586 (set-buffer gnus-dribble-buffer)
14588 (set-buffer-modified-p nil)
14589 (setq buffer-saved-size (buffer-size))))))
14593 ;;; Server Communication
14596 (defun gnus-start-news-server (&optional confirm)
14597 "Open a method for getting news.
14598 If CONFIRM is non-nil, the user will be asked for an NNTP server."
14600 (if gnus-current-select-method
14601 ;; Stream is already opened.
14603 ;; Open NNTP server.
14604 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
14607 ;; Read server name with completion.
14608 (setq gnus-nntp-server
14609 (completing-read "NNTP server: "
14610 (mapcar (lambda (server) (list server))
14611 (cons (list gnus-nntp-server)
14612 gnus-secondary-servers))
14613 nil nil gnus-nntp-server))))
14615 (if (and gnus-nntp-server
14616 (stringp gnus-nntp-server)
14617 (not (string= gnus-nntp-server "")))
14618 (setq gnus-select-method
14619 (cond ((or (string= gnus-nntp-server "")
14620 (string= gnus-nntp-server "::"))
14621 (list 'nnspool (system-name)))
14622 ((string-match "^:" gnus-nntp-server)
14623 (list 'nnmh gnus-nntp-server
14624 (list 'nnmh-directory
14625 (file-name-as-directory
14627 (concat "~/" (substring
14628 gnus-nntp-server 1)))))
14629 (list 'nnmh-get-new-mail nil)))
14631 (list 'nntp gnus-nntp-server)))))
14633 (setq how (car gnus-select-method))
14634 (cond ((eq how 'nnspool)
14636 (gnus-message 5 "Looking up local news spool..."))
14639 (gnus-message 5 "Looking up mh spool..."))
14642 (setq gnus-current-select-method gnus-select-method)
14643 (run-hooks 'gnus-open-server-hook)
14645 ;; gnus-open-server-hook might have opened it
14646 (gnus-server-opened gnus-select-method)
14647 (gnus-open-server gnus-select-method)
14650 "%s (%s) open error: '%s'. Continue? "
14651 (car gnus-select-method) (cadr gnus-select-method)
14652 (gnus-status-message gnus-select-method)))
14654 (gnus-message 1 "Couldn't open server on %s"
14655 (nth 1 gnus-select-method))
14659 (defun gnus-check-group (group)
14660 "Try to make sure that the server where GROUP exists is alive."
14661 (let ((method (gnus-find-method-for-group group)))
14662 (or (gnus-server-opened method)
14663 (gnus-open-server method))))
14665 (defun gnus-check-server (&optional method silent)
14666 "Check whether the connection to METHOD is down.
14667 If METHOD is nil, use `gnus-select-method'.
14668 If it is down, start it up (again)."
14669 (let ((method (or method gnus-select-method)))
14670 ;; Transform virtual server names into select methods.
14671 (when (stringp method)
14672 (setq method (gnus-server-to-method method)))
14673 (if (gnus-server-opened method)
14674 ;; The stream is already opened.
14676 ;; Open the server.
14678 (gnus-message 5 "Opening %s server%s..." (car method)
14679 (if (equal (nth 1 method) "") ""
14680 (format " on %s" (nth 1 method)))))
14681 (run-hooks 'gnus-open-server-hook)
14683 (gnus-open-server method)
14687 (defun gnus-get-function (method function)
14688 "Return a function symbol based on METHOD and FUNCTION."
14689 ;; Translate server names into methods.
14691 (error "Attempted use of a nil select method"))
14692 (when (stringp method)
14693 (setq method (gnus-server-to-method method)))
14694 (let ((func (intern (format "%s-%s" (car method) function))))
14695 ;; If the functions isn't bound, we require the backend in
14697 (unless (fboundp func)
14698 (require (car method))
14699 (unless (fboundp func)
14700 ;; This backend doesn't implement this function.
14701 (error "No such function: %s" func)))
14706 ;;; Interface functions to the backends.
14709 (defun gnus-open-server (method)
14710 "Open a connection to METHOD."
14711 (when (stringp method)
14712 (setq method (gnus-server-to-method method)))
14713 (let ((elem (assoc method gnus-opened-servers)))
14714 ;; If this method was previously denied, we just return nil.
14715 (if (eq (nth 1 elem) 'denied)
14717 (gnus-message 1 "Denied server")
14719 ;; Open the server.
14721 (funcall (gnus-get-function method 'open-server)
14722 (nth 1 method) (nthcdr 2 method))))
14723 ;; If this hasn't been opened before, we add it to the list.
14725 (setq elem (list method nil)
14726 gnus-opened-servers (cons elem gnus-opened-servers)))
14727 ;; Set the status of this server.
14728 (setcar (cdr elem) (if result 'ok 'denied))
14729 ;; Return the result from the "open" call.
14732 (defun gnus-close-server (method)
14733 "Close the connection to METHOD."
14734 (when (stringp method)
14735 (setq method (gnus-server-to-method method)))
14736 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
14738 (defun gnus-request-list (method)
14739 "Request the active file from METHOD."
14740 (when (stringp method)
14741 (setq method (gnus-server-to-method method)))
14742 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
14744 (defun gnus-request-list-newsgroups (method)
14745 "Request the newsgroups file from METHOD."
14746 (when (stringp method)
14747 (setq method (gnus-server-to-method method)))
14748 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
14750 (defun gnus-request-newgroups (date method)
14751 "Request all new groups since DATE from METHOD."
14752 (when (stringp method)
14753 (setq method (gnus-server-to-method method)))
14754 (funcall (gnus-get-function method 'request-newgroups)
14755 date (nth 1 method)))
14757 (defun gnus-server-opened (method)
14758 "Check whether a connection to METHOD has been opened."
14759 (when (stringp method)
14760 (setq method (gnus-server-to-method method)))
14761 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
14763 (defun gnus-status-message (method)
14764 "Return the status message from METHOD.
14765 If METHOD is a string, it is interpreted as a group name. The method
14766 this group uses will be queried."
14767 (let ((method (if (stringp method) (gnus-find-method-for-group method)
14769 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
14771 (defun gnus-request-group (group &optional dont-check method)
14772 "Request GROUP. If DONT-CHECK, no information is required."
14773 (let ((method (or method (gnus-find-method-for-group group))))
14774 (when (stringp method)
14775 (setq method (gnus-server-to-method method)))
14776 (funcall (gnus-get-function method 'request-group)
14777 (gnus-group-real-name group) (nth 1 method) dont-check)))
14779 (defun gnus-request-asynchronous (group &optional articles)
14780 "Request that GROUP behave asynchronously.
14781 ARTICLES is the `data' of the group."
14782 (let ((method (gnus-find-method-for-group group)))
14783 (funcall (gnus-get-function method 'request-asynchronous)
14784 (gnus-group-real-name group) (nth 1 method) articles)))
14786 (defun gnus-list-active-group (group)
14787 "Request active information on GROUP."
14788 (let ((method (gnus-find-method-for-group group))
14789 (func 'list-active-group))
14790 (when (gnus-check-backend-function func group)
14791 (funcall (gnus-get-function method func)
14792 (gnus-group-real-name group) (nth 1 method)))))
14794 (defun gnus-request-group-description (group)
14795 "Request a description of GROUP."
14796 (let ((method (gnus-find-method-for-group group))
14797 (func 'request-group-description))
14798 (when (gnus-check-backend-function func group)
14799 (funcall (gnus-get-function method func)
14800 (gnus-group-real-name group) (nth 1 method)))))
14802 (defun gnus-close-group (group)
14803 "Request the GROUP be closed."
14804 (let ((method (gnus-find-method-for-group group)))
14805 (funcall (gnus-get-function method 'close-group)
14806 (gnus-group-real-name group) (nth 1 method))))
14808 (defun gnus-retrieve-headers (articles group &optional fetch-old)
14809 "Request headers for ARTICLES in GROUP.
14810 If FETCH-OLD, retrieve all headers (or some subset thereof) in the group."
14811 (let ((method (gnus-find-method-for-group group)))
14812 (if (and gnus-use-cache (numberp (car articles)))
14813 (gnus-cache-retrieve-headers articles group fetch-old)
14814 (funcall (gnus-get-function method 'retrieve-headers)
14815 articles (gnus-group-real-name group) (nth 1 method)
14818 (defun gnus-retrieve-groups (groups method)
14819 "Request active information on GROUPS from METHOD."
14820 (when (stringp method)
14821 (setq method (gnus-server-to-method method)))
14822 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method)))
14824 (defun gnus-request-type (group &optional article)
14825 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
14826 (let ((method (gnus-find-method-for-group group)))
14827 (if (not (gnus-check-backend-function 'request-type (car method)))
14829 (funcall (gnus-get-function method 'request-type)
14830 (gnus-group-real-name group) article))))
14832 (defun gnus-request-update-mark (group article mark)
14833 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
14834 (let ((method (gnus-find-method-for-group group)))
14835 (if (not (gnus-check-backend-function 'request-update-mark (car method)))
14837 (funcall (gnus-get-function method 'request-update-mark)
14838 (gnus-group-real-name group) article mark))))
14840 (defun gnus-request-article (article group &optional buffer)
14841 "Request the ARTICLE in GROUP.
14842 ARTICLE can either be an article number or an article Message-ID.
14843 If BUFFER, insert the article in that group."
14844 (let ((method (gnus-find-method-for-group group)))
14845 (funcall (gnus-get-function method 'request-article)
14846 article (gnus-group-real-name group) (nth 1 method) buffer)))
14848 (defun gnus-request-head (article group)
14849 "Request the head of ARTICLE in GROUP."
14850 (let ((method (gnus-find-method-for-group group)))
14851 (funcall (gnus-get-function method 'request-head)
14852 article (gnus-group-real-name group) (nth 1 method))))
14854 (defun gnus-request-body (article group)
14855 "Request the body of ARTICLE in GROUP."
14856 (let ((method (gnus-find-method-for-group group)))
14857 (funcall (gnus-get-function method 'request-body)
14858 article (gnus-group-real-name group) (nth 1 method))))
14860 (defun gnus-request-post (method)
14861 "Post the current buffer using METHOD."
14862 (when (stringp method)
14863 (setq method (gnus-server-to-method method)))
14864 (funcall (gnus-get-function method 'request-post) (nth 1 method)))
14866 (defun gnus-request-scan (group method)
14867 "Request a SCAN being performed in GROUP from METHOD.
14868 If GROUP is nil, all groups on METHOD are scanned."
14869 (let ((method (if group (gnus-find-method-for-group group) method)))
14870 (funcall (gnus-get-function method 'request-scan)
14871 (and group (gnus-group-real-name group)) (nth 1 method))))
14873 (defsubst gnus-request-update-info (info method)
14874 "Request that METHOD update INFO."
14875 (when (stringp method)
14876 (setq method (gnus-server-to-method method)))
14877 (when (gnus-check-backend-function 'request-update-info (car method))
14878 (funcall (gnus-get-function method 'request-update-info)
14879 (gnus-group-real-name (gnus-info-group info))
14880 info (nth 1 method))))
14882 (defun gnus-request-expire-articles (articles group &optional force)
14883 (let ((method (gnus-find-method-for-group group)))
14884 (funcall (gnus-get-function method 'request-expire-articles)
14885 articles (gnus-group-real-name group) (nth 1 method)
14888 (defun gnus-request-move-article
14889 (article group server accept-function &optional last)
14890 (let ((method (gnus-find-method-for-group group)))
14891 (funcall (gnus-get-function method 'request-move-article)
14892 article (gnus-group-real-name group)
14893 (nth 1 method) accept-function last)))
14895 (defun gnus-request-accept-article (group &optional last method)
14896 ;; Make sure there's a newline at the end of the article.
14897 (when (stringp method)
14898 (setq method (gnus-server-to-method method)))
14899 (goto-char (point-max))
14902 (let ((func (if (symbolp group) group
14903 (car (or method (gnus-find-method-for-group group))))))
14904 (funcall (intern (format "%s-request-accept-article" func))
14905 (if (stringp group) (gnus-group-real-name group) group)
14908 (defun gnus-request-replace-article (article group buffer)
14909 (let ((func (car (gnus-find-method-for-group group))))
14910 (funcall (intern (format "%s-request-replace-article" func))
14911 article (gnus-group-real-name group) buffer)))
14913 (defun gnus-request-associate-buffer (group)
14914 (let ((method (gnus-find-method-for-group group)))
14915 (funcall (gnus-get-function method 'request-associate-buffer)
14916 (gnus-group-real-name group))))
14918 (defun gnus-request-restore-buffer (article group)
14919 "Request a new buffer restored to the state of ARTICLE."
14920 (let ((method (gnus-find-method-for-group group)))
14921 (funcall (gnus-get-function method 'request-restore-buffer)
14922 article (gnus-group-real-name group) (nth 1 method))))
14924 (defun gnus-request-create-group (group &optional method)
14925 (when (stringp method)
14926 (setq method (gnus-server-to-method method)))
14927 (let ((method (or method (gnus-find-method-for-group group))))
14928 (funcall (gnus-get-function method 'request-create-group)
14929 (gnus-group-real-name group) (nth 1 method))))
14931 (defun gnus-request-delete-group (group &optional force)
14932 (let ((method (gnus-find-method-for-group group)))
14933 (funcall (gnus-get-function method 'request-delete-group)
14934 (gnus-group-real-name group) force (nth 1 method))))
14936 (defun gnus-request-rename-group (group new-name)
14937 (let ((method (gnus-find-method-for-group group)))
14938 (funcall (gnus-get-function method 'request-rename-group)
14939 (gnus-group-real-name group)
14940 (gnus-group-real-name new-name) (nth 1 method))))
14942 (defun gnus-member-of-valid (symbol group)
14943 "Find out if GROUP has SYMBOL as part of its \"valid\" spec."
14944 (memq symbol (assoc
14945 (symbol-name (car (gnus-find-method-for-group group)))
14946 gnus-valid-select-methods)))
14948 (defun gnus-method-option-p (method option)
14949 "Return non-nil if select METHOD has OPTION as a parameter."
14950 (when (stringp method)
14951 (setq method (gnus-server-to-method method)))
14952 (memq option (assoc (format "%s" (car method))
14953 gnus-valid-select-methods)))
14955 (defun gnus-server-extend-method (group method)
14956 ;; This function "extends" a virtual server. If the server is
14957 ;; "hello", and the select method is ("hello" (my-var "something"))
14958 ;; in the group "alt.alt", this will result in a new virtual server
14959 ;; called "hello+alt.alt".
14961 (gnus-copy-sequence
14962 (if (equal (car method) "native") gnus-select-method
14963 (cdr (assoc (car method) gnus-server-alist))))))
14964 (setcar (cdr entry) (concat (nth 1 entry) "+" group))
14965 (nconc entry (cdr method))))
14967 (defun gnus-find-method-for-group (group &optional info)
14968 "Find the select method that GROUP uses."
14969 (or gnus-override-method
14971 gnus-select-method)
14972 (let ((info (or info (gnus-get-info group)))
14975 (not (setq method (gnus-info-method info)))
14976 (equal method "native"))
14979 (cond ((stringp method)
14980 (gnus-server-to-method method))
14981 ((stringp (car method))
14982 (gnus-server-extend-method group method))
14985 (if (equal (cadr method) "")
14987 (gnus-server-add-address method))))))
14989 (defun gnus-check-backend-function (func group)
14990 "Check whether GROUP supports function FUNC."
14991 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
14993 (fboundp (intern (format "%s-%s" method func)))))
14995 (defun gnus-methods-using (feature)
14996 "Find all methods that have FEATURE."
14997 (let ((valids gnus-valid-select-methods)
15000 (if (memq feature (car valids))
15001 (setq outs (cons (car valids) outs)))
15002 (setq valids (cdr valids)))
15007 ;;; Active & Newsrc File Handling
15010 (defun gnus-setup-news (&optional rawfile level dont-connect)
15011 "Setup news information.
15012 If RAWFILE is non-nil, the .newsrc file will also be read.
15013 If LEVEL is non-nil, the news will be set up at level LEVEL."
15014 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile)))))
15017 ;; Clear some variables to re-initialize news information.
15018 (setq gnus-newsrc-alist nil
15019 gnus-active-hashtb nil)
15020 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
15021 (gnus-read-newsrc-file rawfile))
15023 (when (and (not (assoc "archive" gnus-server-alist))
15024 gnus-message-archive-method)
15025 (push (cons "archive" gnus-message-archive-method)
15026 gnus-server-alist))
15028 ;; If we don't read the complete active file, we fill in the
15030 (if (or (null gnus-read-active-file)
15031 (eq gnus-read-active-file 'some))
15032 (gnus-update-active-hashtb-from-killed))
15034 ;; Read the active file and create `gnus-active-hashtb'.
15035 ;; If `gnus-read-active-file' is nil, then we just create an empty
15036 ;; hash table. The partial filling out of the hash table will be
15037 ;; done in `gnus-get-unread-articles'.
15038 (and gnus-read-active-file
15040 (gnus-read-active-file))
15042 (or gnus-active-hashtb
15043 (setq gnus-active-hashtb (make-vector 4095 0)))
15045 ;; Initialize the cache.
15046 (when gnus-use-cache
15049 ;; Possibly eval the dribble file.
15050 (and init (or gnus-use-dribble-file gnus-slave) (gnus-dribble-eval-file))
15052 (gnus-update-format-specifications)
15054 ;; See whether we need to read the description file.
15055 (if (and (string-match "%[-,0-9]*D" gnus-group-line-format)
15056 (not gnus-description-hashtb)
15058 gnus-read-active-file)
15059 (gnus-read-all-descriptions-files))
15061 ;; Find new newsgroups and treat them.
15062 (if (and init gnus-check-new-newsgroups (not level)
15063 (gnus-check-server gnus-select-method))
15064 (gnus-find-new-newsgroups))
15066 ;; We might read in new NoCeM messages here.
15067 (when gnus-use-nocem
15068 (gnus-nocem-scan-groups))
15070 ;; Find the number of unread articles in each non-dead group.
15071 (let ((gnus-read-active-file (and (not level) gnus-read-active-file)))
15072 (gnus-get-unread-articles level))
15074 (if (and init gnus-check-bogus-newsgroups
15075 gnus-read-active-file (not level)
15076 (gnus-server-opened gnus-select-method))
15077 (gnus-check-bogus-newsgroups))))
15079 (defun gnus-find-new-newsgroups (&optional arg)
15080 "Search for new newsgroups and add them.
15081 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
15082 The `-n' option line from .newsrc is respected.
15083 If ARG (the prefix), use the `ask-server' method to query
15084 the server for new groups."
15086 (let ((check (if (or (and arg (not (listp gnus-check-new-newsgroups)))
15087 (null gnus-read-active-file)
15088 (eq gnus-read-active-file 'some))
15089 'ask-server gnus-check-new-newsgroups)))
15090 (unless (gnus-check-first-time-used)
15091 (if (or (consp check)
15092 (eq check 'ask-server))
15093 ;; Ask the server for new groups.
15094 (gnus-ask-server-for-new-groups)
15095 ;; Go through the active hashtb and look for new groups.
15097 group new-newsgroups)
15098 (gnus-message 5 "Looking for new newsgroups...")
15099 (unless gnus-have-read-active-file
15100 (gnus-read-active-file))
15101 (setq gnus-newsrc-last-checked-date (current-time-string))
15102 (unless gnus-killed-hashtb
15103 (gnus-make-hashtable-from-killed))
15104 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
15105 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
15108 (if (or (null (setq group (symbol-name sym)))
15110 (null (symbol-value sym))
15111 (gnus-gethash group gnus-killed-hashtb)
15112 (gnus-gethash group gnus-newsrc-hashtb))
15114 (let ((do-sub (gnus-matches-options-n group)))
15116 ((eq do-sub 'subscribe)
15117 (setq groups (1+ groups))
15118 (gnus-sethash group group gnus-killed-hashtb)
15119 (funcall gnus-subscribe-options-newsgroup-method group))
15120 ((eq do-sub 'ignore)
15123 (setq groups (1+ groups))
15124 (gnus-sethash group group gnus-killed-hashtb)
15125 (if gnus-subscribe-hierarchical-interactive
15126 (setq new-newsgroups (cons group new-newsgroups))
15127 (funcall gnus-subscribe-newsgroup-method group)))))))
15128 gnus-active-hashtb)
15129 (when new-newsgroups
15130 (gnus-subscribe-hierarchical-interactive new-newsgroups))
15131 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
15133 (gnus-message 6 "%d new newsgroup%s arrived."
15134 groups (if (> groups 1) "s have" " has"))
15135 (gnus-message 6 "No new newsgroups.")))))))
15137 (defun gnus-matches-options-n (group)
15138 ;; Returns `subscribe' if the group is to be unconditionally
15139 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
15140 ;; no match for the group.
15142 ;; First we check the two user variables.
15144 ((and gnus-options-subscribe
15145 (string-match gnus-options-subscribe group))
15147 ((and gnus-auto-subscribed-groups
15148 (string-match gnus-auto-subscribed-groups group))
15150 ((and gnus-options-not-subscribe
15151 (string-match gnus-options-not-subscribe group))
15153 ;; Then we go through the list that was retrieved from the .newsrc
15154 ;; file. This list has elements on the form
15155 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
15156 ;; is in the reverse order of the options line) is returned.
15158 (let ((regs gnus-newsrc-options-n))
15160 (not (string-match (caar regs) group)))
15161 (setq regs (cdr regs)))
15162 (and regs (cdar regs))))))
15164 (defun gnus-ask-server-for-new-groups ()
15165 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
15166 (methods (cons gnus-select-method
15168 (when gnus-message-archive-method
15171 (and (consp gnus-check-new-newsgroups)
15172 gnus-check-new-newsgroups)
15173 gnus-secondary-select-methods))))
15175 (new-date (current-time-string))
15176 group new-newsgroups got-new method hashtb
15177 gnus-override-subscribe-method)
15178 ;; Go through both primary and secondary select methods and
15179 ;; request new newsgroups.
15180 (while (setq method (gnus-server-get-method nil (pop methods)))
15181 (setq new-newsgroups nil)
15182 (setq gnus-override-subscribe-method method)
15183 (when (and (gnus-check-server method)
15184 (gnus-request-newgroups date method))
15187 (setq hashtb (gnus-make-hashtable 100))
15188 (set-buffer nntp-server-buffer)
15189 ;; Enter all the new groups into a hashtable.
15190 (gnus-active-to-gnus-format method hashtb 'ignore)))
15191 ;; Now all new groups from `method' are in `hashtb'.
15193 (lambda (group-sym)
15194 (if (or (null (setq group (symbol-name group-sym)))
15195 (null (symbol-value group-sym))
15196 (gnus-gethash group gnus-newsrc-hashtb)
15197 (member group gnus-zombie-list)
15198 (member group gnus-killed-list))
15199 ;; The group is already known.
15201 ;; Make this group active.
15202 (when (symbol-value group-sym)
15203 (gnus-set-active group (symbol-value group-sym)))
15204 ;; Check whether we want it or not.
15205 (let ((do-sub (gnus-matches-options-n group)))
15207 ((eq do-sub 'subscribe)
15209 (gnus-sethash group group gnus-killed-hashtb)
15210 (funcall gnus-subscribe-options-newsgroup-method group))
15211 ((eq do-sub 'ignore)
15215 (gnus-sethash group group gnus-killed-hashtb)
15216 (if gnus-subscribe-hierarchical-interactive
15217 (push group new-newsgroups)
15218 (funcall gnus-subscribe-newsgroup-method group)))))))
15220 (when new-newsgroups
15221 (gnus-subscribe-hierarchical-interactive new-newsgroups)))
15222 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
15224 (gnus-message 6 "%d new newsgroup%s arrived."
15225 groups (if (> groups 1) "s have" " has")))
15226 (and got-new (setq gnus-newsrc-last-checked-date new-date))
15229 (defun gnus-check-first-time-used ()
15230 (if (or (> (length gnus-newsrc-alist) 1)
15231 (file-exists-p gnus-startup-file)
15232 (file-exists-p (concat gnus-startup-file ".el"))
15233 (file-exists-p (concat gnus-startup-file ".eld")))
15235 (gnus-message 6 "First time user; subscribing you to default groups")
15236 (unless gnus-have-read-active-file
15237 (gnus-read-active-file))
15238 (setq gnus-newsrc-last-checked-date (current-time-string))
15239 (let ((groups gnus-default-subscribed-newsgroups)
15243 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
15246 (if (null (setq group (symbol-name sym)))
15248 (let ((do-sub (gnus-matches-options-n group)))
15250 ((eq do-sub 'subscribe)
15251 (gnus-sethash group group gnus-killed-hashtb)
15252 (funcall gnus-subscribe-options-newsgroup-method group))
15253 ((eq do-sub 'ignore)
15256 (setq gnus-killed-list (cons group gnus-killed-list)))))))
15257 gnus-active-hashtb)
15259 (if (gnus-active (car groups))
15260 (gnus-group-change-level
15261 (car groups) gnus-level-default-subscribed gnus-level-killed))
15262 (setq groups (cdr groups)))
15263 (gnus-group-make-help-group)
15264 (and gnus-novice-user
15265 (gnus-message 7 "`A k' to list killed groups"))))))
15267 (defun gnus-subscribe-group (group previous &optional method)
15268 (gnus-group-change-level
15270 (list t group gnus-level-default-subscribed nil nil method)
15272 gnus-level-default-subscribed gnus-level-killed previous t))
15274 ;; `gnus-group-change-level' is the fundamental function for changing
15275 ;; subscription levels of newsgroups. This might mean just changing
15276 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
15277 ;; again, which subscribes/unsubscribes a group, which is equally
15278 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
15279 ;; from 8-9 to 1-7 means that you remove the group from the list of
15280 ;; killed (or zombie) groups and add them to the (kinda) subscribed
15281 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
15282 ;; which is trivial.
15283 ;; ENTRY can either be a string (newsgroup name) or a list (if
15284 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
15285 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
15287 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
15288 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
15290 (defun gnus-group-change-level (entry level &optional oldlevel
15291 previous fromkilled)
15292 (let (group info active num)
15293 ;; Glean what info we can from the arguments
15295 (if fromkilled (setq group (nth 1 entry))
15296 (setq group (car (nth 2 entry))))
15297 (setq group entry))
15298 (if (and (stringp entry)
15300 (< oldlevel gnus-level-zombie))
15301 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
15302 (if (and (not oldlevel)
15304 (setq oldlevel (gnus-info-level (nth 2 entry)))
15305 (setq oldlevel (or oldlevel 9)))
15306 (if (stringp previous)
15307 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
15309 (if (and (>= oldlevel gnus-level-zombie)
15310 (gnus-gethash group gnus-newsrc-hashtb))
15311 ;; We are trying to subscribe a group that is already
15315 (or (gnus-ephemeral-group-p group)
15316 (gnus-dribble-enter
15317 (format "(gnus-group-change-level %S %S %S %S %S)"
15318 group level oldlevel (car (nth 2 previous)) fromkilled)))
15320 ;; Then we remove the newgroup from any old structures, if needed.
15321 ;; If the group was killed, we remove it from the killed or zombie
15322 ;; list. If not, and it is in fact going to be killed, we remove
15323 ;; it from the newsrc hash table and assoc.
15325 ((>= oldlevel gnus-level-zombie)
15326 (if (= oldlevel gnus-level-zombie)
15327 (setq gnus-zombie-list (delete group gnus-zombie-list))
15328 (setq gnus-killed-list (delete group gnus-killed-list))))
15330 (if (and (>= level gnus-level-zombie)
15333 (gnus-sethash (car (nth 2 entry)) nil gnus-newsrc-hashtb)
15335 (setcdr (gnus-gethash (car (nth 3 entry))
15336 gnus-newsrc-hashtb)
15338 (setcdr (cdr entry) (cdddr entry))))))
15340 ;; Finally we enter (if needed) the list where it is supposed to
15341 ;; go, and change the subscription level. If it is to be killed,
15342 ;; we enter it into the killed or zombie list.
15344 ((>= level gnus-level-zombie)
15345 ;; Remove from the hash table.
15346 (gnus-sethash group nil gnus-newsrc-hashtb)
15347 ;; We do not enter foreign groups into the list of dead
15349 (unless (gnus-group-foreign-p group)
15350 (if (= level gnus-level-zombie)
15351 (setq gnus-zombie-list (cons group gnus-zombie-list))
15352 (setq gnus-killed-list (cons group gnus-killed-list)))))
15354 ;; If the list is to be entered into the newsrc assoc, and
15355 ;; it was killed, we have to create an entry in the newsrc
15356 ;; hashtb format and fix the pointers in the newsrc assoc.
15357 (if (< oldlevel gnus-level-zombie)
15358 ;; It was alive, and it is going to stay alive, so we
15359 ;; just change the level and don't change any pointers or
15360 ;; hash table entries.
15361 (setcar (cdaddr entry) level)
15363 (setq info (cdr entry)
15365 (setq active (gnus-active group))
15367 (if active (- (1+ (cdr active)) (car active)) t))
15368 ;; Check whether the group is foreign. If so, the
15369 ;; foreign select method has to be entered into the
15371 (let ((method (or gnus-override-subscribe-method
15372 (gnus-group-method group))))
15373 (if (eq method gnus-select-method)
15374 (setq info (list group level nil))
15375 (setq info (list group level nil nil method)))))
15378 (let ((p gnus-newsrc-alist))
15382 (setq entry (cons info (cddr previous)))
15385 (setcdr (cdr previous) entry)
15386 (gnus-sethash group (cons num (cdr previous))
15387 gnus-newsrc-hashtb))
15388 (setcdr previous entry)
15389 (gnus-sethash group (cons num previous)
15390 gnus-newsrc-hashtb))
15392 (setcdr (gnus-gethash (caadr entry) gnus-newsrc-hashtb) entry)))))
15393 (when gnus-group-change-level-function
15394 (funcall gnus-group-change-level-function group level oldlevel)))))
15396 (defun gnus-kill-newsgroup (newsgroup)
15397 "Obsolete function. Kills a newsgroup."
15398 (gnus-group-change-level
15399 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed))
15401 (defun gnus-check-bogus-newsgroups (&optional confirm)
15402 "Remove bogus newsgroups.
15403 If CONFIRM is non-nil, the user has to confirm the deletion of every
15405 (let ((newsrc (cdr gnus-newsrc-alist))
15406 bogus group entry info)
15407 (gnus-message 5 "Checking bogus newsgroups...")
15408 (unless gnus-have-read-active-file
15409 (gnus-read-active-file))
15410 (when (member gnus-select-method gnus-have-read-active-file)
15411 ;; Find all bogus newsgroup that are subscribed.
15413 (setq info (pop newsrc)
15414 group (gnus-info-group info))
15415 (unless (or (gnus-active group) ; Active
15416 (gnus-info-method info) ; Foreign
15418 (not (gnus-y-or-n-p
15419 (format "Remove bogus newsgroup: %s " group)))))
15420 ;; Found a bogus newsgroup.
15421 (push group bogus)))
15422 ;; Remove all bogus subscribed groups by first killing them, and
15423 ;; then removing them from the list of killed groups.
15425 (when (setq entry (gnus-gethash (setq group (pop bogus))
15426 gnus-newsrc-hashtb))
15427 (gnus-group-change-level entry gnus-level-killed)
15428 (setq gnus-killed-list (delete group gnus-killed-list))))
15429 ;; Then we remove all bogus groups from the list of killed and
15430 ;; zombie groups. They are are removed without confirmation.
15431 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
15434 (setq killed (symbol-value (car dead-lists)))
15436 (unless (gnus-active (setq group (pop killed)))
15437 ;; The group is bogus.
15438 ;; !!!Slow as hell.
15439 (set (car dead-lists)
15440 (delete group (symbol-value (car dead-lists))))))
15441 (setq dead-lists (cdr dead-lists))))
15442 (gnus-message 5 "Checking bogus newsgroups...done"))))
15444 (defun gnus-check-duplicate-killed-groups ()
15445 "Remove duplicates from the list of killed groups."
15447 (let ((killed gnus-killed-list))
15449 (gnus-message 9 "%d" (length killed))
15450 (setcdr killed (delete (car killed) (cdr killed)))
15451 (setq killed (cdr killed)))))
15453 ;; We want to inline a function from gnus-cache, so we cheat here:
15456 (require 'gnus-cache))
15458 (defun gnus-get-unread-articles-in-group (info active &optional update)
15460 ;; Allow the backend to update the info in the group.
15462 (gnus-request-update-info
15463 info (gnus-find-method-for-group (gnus-info-group info))))
15464 (gnus-activate-group (gnus-info-group info)))
15465 (let* ((range (gnus-info-read info))
15467 ;; If a cache is present, we may have to alter the active info.
15468 (when (and gnus-use-cache info)
15469 (inline (gnus-cache-possibly-alter-active
15470 (gnus-info-group info) active)))
15471 ;; Modify the list of read articles according to what articles
15472 ;; are available; then tally the unread articles and add the
15473 ;; number to the group hash table entry.
15475 ((zerop (cdr active))
15478 (setq num (- (1+ (cdr active)) (car active))))
15479 ((not (listp (cdr range)))
15480 ;; Fix a single (num . num) range according to the
15481 ;; active hash table.
15482 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
15483 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
15484 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
15485 ;; Compute number of unread articles.
15486 (setq num (max 0 (- (cdr active) (- (1+ (cdr range)) (car range))))))
15488 ;; The read list is a list of ranges. Fix them according to
15489 ;; the active hash table.
15490 ;; First peel off any elements that are below the lower
15492 (while (and (cdr range)
15494 (or (and (atom (cadr range)) (cadr range))
15496 (if (numberp (car range))
15499 (or (and (numberp (cadr range))
15502 (setcdr (car range)
15503 (or (and (numberp (nth 1 range)) (nth 1 range))
15505 (setcdr range (cddr range)))
15506 ;; Adjust the first element to be the same as the lower limit.
15507 (if (and (not (atom (car range)))
15508 (< (cdar range) (car active)))
15509 (setcdr (car range) (1- (car active))))
15510 ;; Then we want to peel off any elements that are higher
15511 ;; than the upper active limit.
15512 (let ((srange range))
15513 ;; Go past all legal elements.
15514 (while (and (cdr srange)
15515 (<= (or (and (atom (cadr srange))
15517 (caadr srange)) (cdr active)))
15518 (setq srange (cdr srange)))
15520 ;; Nuke all remaining illegal elements.
15521 (setcdr srange nil))
15523 ;; Adjust the final element.
15524 (if (and (not (atom (car srange)))
15525 (> (cdar srange) (cdr active)))
15526 (setcdr (car srange) (cdr active))))
15527 ;; Compute the number of unread articles.
15529 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
15531 (or (and (atom (car range)) (car range))
15533 (setq range (cdr range)))
15534 (setq num (max 0 (- (cdr active) num)))))
15535 ;; Set the number of unread articles.
15537 (setcar (gnus-gethash (gnus-info-group info) gnus-newsrc-hashtb) num))
15540 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
15541 ;; and compute how many unread articles there are in each group.
15542 (defun gnus-get-unread-articles (&optional level)
15543 (let* ((newsrc (cdr gnus-newsrc-alist))
15544 (level (or level gnus-activate-level (1+ gnus-level-subscribed)))
15547 (cond ((and gnus-activate-foreign-newsgroups
15548 (not (numberp gnus-activate-foreign-newsgroups)))
15549 (1+ gnus-level-subscribed))
15550 ((numberp gnus-activate-foreign-newsgroups)
15551 gnus-activate-foreign-newsgroups)
15554 info group active method)
15555 (gnus-message 5 "Checking new news...")
15558 (setq active (gnus-active (setq group (gnus-info-group
15559 (setq info (pop newsrc))))))
15561 ;; Check newsgroups. If the user doesn't want to check them, or
15562 ;; they can't be checked (for instance, if the news server can't
15563 ;; be reached) we just set the number of unread articles in this
15564 ;; newsgroup to t. This means that Gnus thinks that there are
15565 ;; unread articles, but it has no idea how many.
15566 (if (and (setq method (gnus-info-method info))
15567 (not (gnus-server-equal
15569 (setq method (gnus-server-get-method nil method))))
15570 (not (gnus-secondary-method-p method)))
15571 ;; These groups are foreign. Check the level.
15572 (when (<= (gnus-info-level info) foreign-level)
15573 (setq active (gnus-activate-group group 'scan))
15574 (gnus-close-group group))
15576 ;; These groups are native or secondary.
15577 (when (and (<= (gnus-info-level info) level)
15578 (not gnus-read-active-file))
15579 (setq active (gnus-activate-group group 'scan))
15580 (gnus-close-group group)))
15583 (inline (gnus-get-unread-articles-in-group
15586 (fboundp (intern (concat (symbol-name (car method))
15587 "-request-scan"))))))
15588 ;; The group couldn't be reached, so we nix out the number of
15589 ;; unread articles and stuff.
15590 (gnus-set-active group nil)
15591 (setcar (gnus-gethash group gnus-newsrc-hashtb) t)))
15593 (gnus-message 5 "Checking new news...done")))
15595 ;; Create a hash table out of the newsrc alist. The `car's of the
15596 ;; alist elements are used as keys.
15597 (defun gnus-make-hashtable-from-newsrc-alist ()
15598 (let ((alist gnus-newsrc-alist)
15599 (ohashtb gnus-newsrc-hashtb)
15601 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
15603 (setq prev (setq gnus-newsrc-alist
15604 (if (equal (caar gnus-newsrc-alist)
15607 (cons (list "dummy.group" 0 nil) alist)))))
15611 (cons (and ohashtb (car (gnus-gethash (caar alist) ohashtb)))
15613 gnus-newsrc-hashtb)
15615 alist (cdr alist)))))
15617 (defun gnus-make-hashtable-from-killed ()
15618 "Create a hash table from the killed and zombie lists."
15619 (let ((lists '(gnus-killed-list gnus-zombie-list))
15621 (setq gnus-killed-hashtb
15622 (gnus-make-hashtable
15623 (+ (length gnus-killed-list) (length gnus-zombie-list))))
15624 (while (setq list (symbol-value (pop lists)))
15626 (gnus-sethash (car list) (pop list) gnus-killed-hashtb)))))
15628 (defun gnus-activate-group (group &optional scan)
15629 ;; Check whether a group has been activated or not.
15630 ;; If SCAN, request a scan of that group as well.
15631 (let ((method (gnus-find-method-for-group group))
15633 (and (gnus-check-server method)
15634 ;; We escape all bugs and quit here to make it possible to
15635 ;; continue if a group is so out-there that it reports bugs
15639 (gnus-check-backend-function 'request-scan (car method))
15640 (gnus-request-scan group method))
15643 (gnus-request-group group)
15647 (set-buffer nntp-server-buffer)
15648 (goto-char (point-min))
15649 ;; Parse the result we got from `gnus-request-group'.
15650 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
15652 (goto-char (match-beginning 1))
15654 group (setq active (cons (read (current-buffer))
15655 (read (current-buffer)))))
15656 ;; Return the new active info.
15659 (defun gnus-update-read-articles (group unread)
15660 "Update the list of read and ticked articles in GROUP using the
15661 UNREAD and TICKED lists.
15662 Note: UNSELECTED has to be sorted over `<'.
15663 Returns whether the updating was successful."
15664 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
15665 (entry (gnus-gethash group gnus-newsrc-hashtb))
15666 (info (nth 2 entry))
15668 (unread (sort (copy-sequence unread) '<))
15670 (if (or (not info) (not active))
15671 ;; There is no info on this group if it was, in fact,
15672 ;; killed. Gnus stores no information on killed groups, so
15673 ;; there's nothing to be done.
15674 ;; One could store the information somewhere temporarily,
15675 ;; perhaps... Hmmm...
15677 ;; Remove any negative articles numbers.
15678 (while (and unread (< (car unread) 0))
15679 (setq unread (cdr unread)))
15680 ;; Remove any expired article numbers
15681 (while (and unread (< (car unread) (car active)))
15682 (setq unread (cdr unread)))
15683 ;; Compute the ranges of read articles by looking at the list of
15684 ;; unread articles.
15686 (if (/= (car unread) prev)
15687 (setq read (cons (if (= prev (1- (car unread))) prev
15688 (cons prev (1- (car unread)))) read)))
15689 (setq prev (1+ (car unread)))
15690 (setq unread (cdr unread)))
15691 (when (<= prev (cdr active))
15692 (setq read (cons (cons prev (cdr active)) read)))
15693 ;; Enter this list into the group info.
15694 (gnus-info-set-read
15695 info (if (> (length read) 1) (nreverse read) read))
15696 ;; Set the number of unread articles in gnus-newsrc-hashtb.
15697 (gnus-get-unread-articles-in-group info (gnus-active group))
15700 (defun gnus-make-articles-unread (group articles)
15701 "Mark ARTICLES in GROUP as unread."
15702 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
15703 (gnus-gethash (gnus-group-real-name group)
15704 gnus-newsrc-hashtb))))
15705 (ranges (gnus-info-read info))
15708 (when (gnus-member-of-range
15709 (setq article (pop articles)) ranges)
15710 (setq news (cons article news))))
15712 (gnus-info-set-read
15713 info (gnus-remove-from-range (gnus-info-read info) (nreverse news)))
15714 (gnus-group-update-group group t))))
15716 ;; Enter all dead groups into the hashtb.
15717 (defun gnus-update-active-hashtb-from-killed ()
15718 (let ((hashtb (setq gnus-active-hashtb (make-vector 4095 0)))
15719 (lists (list gnus-killed-list gnus-zombie-list))
15722 (setq killed (car lists))
15724 (gnus-sethash (car killed) nil hashtb)
15725 (setq killed (cdr killed)))
15726 (setq lists (cdr lists)))))
15728 ;; Get the active file(s) from the backend(s).
15729 (defun gnus-read-active-file ()
15730 (gnus-group-set-mode-line)
15733 (if (gnus-check-server gnus-select-method)
15734 ;; The native server is available.
15735 (cons gnus-select-method gnus-secondary-select-methods)
15736 ;; The native server is down, so we just do the
15738 gnus-secondary-select-methods)
15739 ;; Also read from the archive server.
15740 (when gnus-message-archive-method
15741 (list "archive"))))
15743 (setq gnus-have-read-active-file nil)
15745 (set-buffer nntp-server-buffer)
15747 (let* ((method (if (stringp (car methods))
15748 (gnus-server-get-method nil (car methods))
15750 (where (nth 1 method))
15751 (mesg (format "Reading active file%s via %s..."
15752 (if (and where (not (zerop (length where))))
15753 (concat " from " where) "")
15755 (gnus-message 5 mesg)
15756 (when (gnus-check-server method)
15757 ;; Request that the backend scan its incoming messages.
15758 (and (gnus-check-backend-function 'request-scan (car method))
15759 (gnus-request-scan nil method))
15761 ((and (eq gnus-read-active-file 'some)
15762 (gnus-check-backend-function 'retrieve-groups (car method)))
15763 (let ((newsrc (cdr gnus-newsrc-alist))
15764 (gmethod (if (stringp method)
15765 (gnus-server-get-method nil method)
15768 (while (setq info (pop newsrc))
15769 (when (gnus-server-equal
15770 (gnus-find-method-for-group
15771 (gnus-info-group info) info)
15773 (push (gnus-group-real-name (gnus-info-group info))
15776 (gnus-check-server method)
15777 (setq list-type (gnus-retrieve-groups groups method))
15781 1 "Cannot read partial active file from %s server."
15785 ((eq list-type 'active)
15786 (gnus-active-to-gnus-format method gnus-active-hashtb))
15788 (gnus-groups-to-gnus-format method gnus-active-hashtb))))))
15790 (if (not (gnus-request-list method))
15792 (unless (equal method gnus-message-archive-method)
15793 (gnus-message 1 "Cannot read active file from %s server."
15796 (gnus-active-to-gnus-format method)
15797 ;; We mark this active file as read.
15798 (push method gnus-have-read-active-file)
15799 (gnus-message 5 "%sdone" mesg))))))
15800 (setq methods (cdr methods))))))
15802 ;; Read an active file and place the results in `gnus-active-hashtb'.
15803 (defun gnus-active-to-gnus-format (&optional method hashtb ignore-errors)
15805 (setq method gnus-select-method))
15806 (let ((cur (current-buffer))
15808 (if (and gnus-active-hashtb
15809 (not (equal method gnus-select-method)))
15811 (setq gnus-active-hashtb
15812 (if (equal method gnus-select-method)
15813 (gnus-make-hashtable
15814 (count-lines (point-min) (point-max)))
15815 (gnus-make-hashtable 4096)))))))
15816 ;; Delete unnecessary lines.
15817 (goto-char (point-min))
15818 (while (search-forward "\nto." nil t)
15819 (delete-region (1+ (match-beginning 0))
15820 (progn (forward-line 1) (point))))
15821 (or (string= gnus-ignored-newsgroups "")
15823 (goto-char (point-min))
15824 (delete-matching-lines gnus-ignored-newsgroups)))
15825 ;; Make the group names readable as a lisp expression even if they
15826 ;; contain special characters.
15827 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
15828 (goto-char (point-max))
15829 (while (re-search-backward "[][';?()#]" nil t)
15831 ;; If these are groups from a foreign select method, we insert the
15832 ;; group prefix in front of the group names.
15833 (and method (not (gnus-server-equal
15834 (gnus-server-get-method nil method)
15835 (gnus-server-get-method nil gnus-select-method)))
15836 (let ((prefix (gnus-group-prefixed-name "" method)))
15837 (goto-char (point-min))
15838 (while (and (not (eobp))
15839 (progn (insert prefix)
15840 (zerop (forward-line 1)))))))
15841 ;; Store the active file in a hash table.
15842 (goto-char (point-min))
15843 (if (string-match "%[oO]" gnus-group-line-format)
15844 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
15845 ;; If we want information on moderated groups, we use this
15847 (let* ((mod-hashtb (make-vector 7 0))
15848 (m (intern "m" mod-hashtb))
15850 (while (not (eobp))
15851 (condition-case nil
15853 (narrow-to-region (point) (gnus-point-at-eol))
15854 (setq group (let ((obarray hashtb)) (read cur)))
15855 (if (and (numberp (setq max (read cur)))
15856 (numberp (setq min (read cur)))
15858 (skip-chars-forward " \t")
15860 (or (= (following-char) ?=)
15861 (= (following-char) ?x)
15862 (= (following-char) ?j)))))
15863 (set group (cons min max))
15865 ;; Enter moderated groups into a list.
15866 (if (eq (let ((obarray mod-hashtb)) (read cur)) m)
15867 (setq gnus-moderated-list
15868 (cons (symbol-name group) gnus-moderated-list))))
15875 ;; And if we do not care about moderation, we use this loop,
15876 ;; which is faster.
15877 (let (group max min)
15878 (while (not (eobp))
15881 (narrow-to-region (point) (gnus-point-at-eol))
15882 ;; group gets set to a symbol interned in the hash table
15883 ;; (what a hack!!) - jwz
15884 (setq group (let ((obarray hashtb)) (read cur)))
15885 (if (and (numberp (setq max (read cur)))
15886 (numberp (setq min (read cur)))
15888 (skip-chars-forward " \t")
15890 (or (= (following-char) ?=)
15891 (= (following-char) ?x)
15892 (= (following-char) ?j)))))
15893 (set group (cons min max))
15901 (gnus-message 3 "Warning - illegal active: %s"
15903 (gnus-point-at-bol) (gnus-point-at-eol)))))))
15905 (forward-line 1))))))
15907 (defun gnus-groups-to-gnus-format (method &optional hashtb)
15908 ;; Parse a "groups" active file.
15909 (let ((cur (current-buffer))
15911 (if (and method gnus-active-hashtb)
15913 (setq gnus-active-hashtb
15914 (gnus-make-hashtable
15915 (count-lines (point-min) (point-max)))))))
15916 (prefix (and method
15917 (not (gnus-server-equal
15918 (gnus-server-get-method nil method)
15919 (gnus-server-get-method nil gnus-select-method)))
15920 (gnus-group-prefixed-name "" method))))
15922 (goto-char (point-min))
15923 ;; We split this into to separate loops, one with the prefix
15924 ;; and one without to speed the reading up somewhat.
15926 (let (min max opoint group)
15927 (while (not (eobp))
15930 (read cur) (read cur)
15931 (setq min (read cur)
15934 (skip-chars-forward " \t")
15937 (set (let ((obarray hashtb)) (read cur))
15939 (error (and group (symbolp group) (set group nil))))
15941 (let (min max group)
15942 (while (not (eobp))
15944 (if (= (following-char) ?2)
15946 (read cur) (read cur)
15947 (setq min (read cur)
15949 (set (setq group (let ((obarray hashtb)) (read cur)))
15951 (error (and group (symbolp group) (set group nil))))
15952 (forward-line 1))))))
15954 (defun gnus-read-newsrc-file (&optional force)
15955 "Read startup file.
15956 If FORCE is non-nil, the .newsrc file is read."
15957 ;; Reset variables that might be defined in the .newsrc.eld file.
15958 (let ((variables gnus-variable-list))
15960 (set (car variables) nil)
15961 (setq variables (cdr variables))))
15962 (let* ((newsrc-file gnus-current-startup-file)
15963 (quick-file (concat newsrc-file ".el")))
15965 ;; We always load the .newsrc.eld file. If always contains
15966 ;; much information that can not be gotten from the .newsrc
15967 ;; file (ticked articles, killed groups, foreign methods, etc.)
15968 (gnus-read-newsrc-el-file quick-file)
15970 (if (and (file-exists-p gnus-current-startup-file)
15972 (and (file-newer-than-file-p newsrc-file quick-file)
15973 (file-newer-than-file-p newsrc-file
15974 (concat quick-file "d")))
15975 (not gnus-newsrc-alist)))
15976 ;; We read the .newsrc file. Note that if there if a
15977 ;; .newsrc.eld file exists, it has already been read, and
15978 ;; the `gnus-newsrc-hashtb' has been created. While reading
15979 ;; the .newsrc file, Gnus will only use the information it
15980 ;; can find there for changing the data already read -
15981 ;; ie. reading the .newsrc file will not trash the data
15982 ;; already read (except for read articles).
15984 (gnus-message 5 "Reading %s..." newsrc-file)
15985 (set-buffer (find-file-noselect newsrc-file))
15986 (buffer-disable-undo (current-buffer))
15987 (gnus-newsrc-to-gnus-format)
15988 (kill-buffer (current-buffer))
15989 (gnus-message 5 "Reading %s...done" newsrc-file)))
15991 ;; Read any slave files.
15993 (gnus-master-read-slave-newsrc)))))
15995 (defun gnus-read-newsrc-el-file (file)
15996 (let ((ding-file (concat file "d")))
15997 ;; We always, always read the .eld file.
15998 (gnus-message 5 "Reading %s..." ding-file)
15999 (let (gnus-newsrc-assoc)
16000 (condition-case nil
16001 (load ding-file t t t)
16003 (gnus-message 1 "Error in %s" ding-file)
16005 (when gnus-newsrc-assoc
16006 (setq gnus-newsrc-alist gnus-newsrc-assoc)))
16007 (gnus-make-hashtable-from-newsrc-alist)
16008 (when (file-newer-than-file-p file ding-file)
16009 ;; Old format quick file
16010 (gnus-message 5 "Reading %s..." file)
16011 ;; The .el file is newer than the .eld file, so we read that one
16013 (gnus-read-old-newsrc-el-file file))))
16015 ;; Parse the old-style quick startup file
16016 (defun gnus-read-old-newsrc-el-file (file)
16017 (let (newsrc killed marked group m info)
16019 (let ((gnus-killed-assoc nil)
16020 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc)
16022 (condition-case nil
16025 (setq newsrc gnus-newsrc-assoc
16026 killed gnus-killed-assoc
16027 marked gnus-marked-assoc)))
16028 (setq gnus-newsrc-alist nil)
16029 (while (setq info (gnus-get-info (setq group (pop newsrc))))
16032 (gnus-info-set-read info (cddr group))
16033 (gnus-info-set-level
16034 info (if (nth 1 group) gnus-level-default-subscribed
16035 gnus-level-default-unsubscribed))
16036 (setq gnus-newsrc-alist (cons info gnus-newsrc-alist)))
16039 (if (nth 1 group) gnus-level-default-subscribed
16040 gnus-level-default-unsubscribed)
16042 gnus-newsrc-alist))
16043 ;; Copy marks into info.
16044 (when (setq m (assoc (car group) marked))
16045 (unless (nthcdr 3 info)
16046 (nconc info (list nil)))
16047 (gnus-info-set-marks
16048 info (list (cons 'tick (gnus-compress-sequence
16049 (sort (cdr m) '<) t))))))
16050 (setq newsrc killed)
16052 (setcar newsrc (caar newsrc))
16053 (setq newsrc (cdr newsrc)))
16054 (setq gnus-killed-list killed))
16055 ;; The .el file version of this variable does not begin with
16056 ;; "options", while the .eld version does, so we just add it if it
16059 gnus-newsrc-options
16061 (and (not (string-match "^ *options" gnus-newsrc-options))
16062 (setq gnus-newsrc-options (concat "options " gnus-newsrc-options)))
16063 (and (not (string-match "\n$" gnus-newsrc-options))
16064 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n")))
16065 ;; Finally, if we read some options lines, we parse them.
16066 (or (string= gnus-newsrc-options "")
16067 (gnus-newsrc-parse-options gnus-newsrc-options))))
16069 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))
16070 (gnus-make-hashtable-from-newsrc-alist)))
16072 (defun gnus-make-newsrc-file (file)
16073 "Make server dependent file name by catenating FILE and server host name."
16074 (let* ((file (expand-file-name file nil))
16075 (real-file (concat file "-" (nth 1 gnus-select-method))))
16076 (if (or (file-exists-p real-file)
16077 (file-exists-p (concat real-file ".el"))
16078 (file-exists-p (concat real-file ".eld")))
16081 (defun gnus-newsrc-to-gnus-format ()
16082 (setq gnus-newsrc-options "")
16083 (setq gnus-newsrc-options-n nil)
16085 (or gnus-active-hashtb
16086 (setq gnus-active-hashtb (make-vector 4095 0)))
16087 (let ((buf (current-buffer))
16088 (already-read (> (length gnus-newsrc-alist) 1))
16089 group subscribed options-symbol newsrc Options-symbol
16091 (goto-char (point-min))
16092 ;; We intern the symbol `options' in the active hashtb so that we
16093 ;; can `eq' against it later.
16094 (set (setq options-symbol (intern "options" gnus-active-hashtb)) nil)
16095 (set (setq Options-symbol (intern "Options" gnus-active-hashtb)) nil)
16097 (while (not (eobp))
16098 ;; We first read the first word on the line by narrowing and
16099 ;; then reading into `gnus-active-hashtb'. Most groups will
16100 ;; already exist in that hashtb, so this will save some string
16104 (progn (skip-chars-forward "^ \t!:\n") (point)))
16105 (goto-char (point-min))
16107 (and (/= (point-min) (point-max))
16108 (let ((obarray gnus-active-hashtb)) (read buf))))
16110 ;; Now, the symbol we have read is either `options' or a group
16111 ;; name. If it is an options line, we just add it to a string.
16113 ((or (eq symbol options-symbol)
16114 (eq symbol Options-symbol))
16115 (setq gnus-newsrc-options
16116 ;; This concating is quite inefficient, but since our
16117 ;; thorough studies show that approx 99.37% of all
16118 ;; .newsrc files only contain a single options line, we
16119 ;; don't give a damn, frankly, my dear.
16120 (concat gnus-newsrc-options
16122 (gnus-point-at-bol)
16123 ;; Options may continue on the next line.
16124 (or (and (re-search-forward "^[^ \t]" nil 'move)
16125 (progn (beginning-of-line) (point)))
16129 ;; Group names can be just numbers.
16130 (when (numberp symbol)
16131 (setq symbol (intern (int-to-string symbol) gnus-active-hashtb)))
16132 (or (boundp symbol) (set symbol nil))
16133 ;; It was a group name.
16134 (setq subscribed (= (following-char) ?:)
16135 group (symbol-name symbol)
16138 ;; If the line ends here, this is clearly a buggy line, so
16139 ;; we put point a the beginning of line and let the cond
16140 ;; below do the error handling.
16141 (beginning-of-line)
16142 ;; We skip to the beginning of the ranges.
16143 (skip-chars-forward "!: \t"))
16144 ;; We are now at the beginning of the list of read articles.
16145 ;; We read them range by range.
16148 ((looking-at "[0-9]+")
16149 ;; We narrow and read a number instead of buffer-substring/
16150 ;; string-to-int because it's faster. narrow/widen is
16151 ;; faster than save-restriction/narrow, and save-restriction
16152 ;; produces a garbage object.
16154 (narrow-to-region (match-beginning 0) (match-end 0))
16157 ;; If the next character is a dash, then this is a range.
16158 (if (= (following-char) ?-)
16160 ;; We read the upper bound of the range.
16162 (if (not (looking-at "[0-9]+"))
16163 ;; This is a buggy line, by we pretend that
16164 ;; it's kinda OK. Perhaps the user should be
16166 (setq reads (cons num1 reads))
16171 (narrow-to-region (match-beginning 0)
16176 ;; It was just a simple number, so we add it to the
16178 (setq reads (cons num1 reads)))
16179 ;; If the next char in ?\n, then we have reached the end
16180 ;; of the line and return nil.
16181 (/= (following-char) ?\n))
16182 ((= (following-char) ?\n)
16183 ;; End of line, so we end.
16186 ;; Not numbers and not eol, so this might be a buggy
16189 ;; If it was eob instead of ?\n, we allow it.
16191 ;; The line was buggy.
16193 (gnus-message 3 "Mangled line: %s"
16194 (buffer-substring (gnus-point-at-bol)
16195 (gnus-point-at-eol)))
16199 ;; Skip past ", ". Spaces are illegal in these ranges, but
16200 ;; we allow them, because it's a common mistake to put a
16201 ;; space after the comma.
16202 (skip-chars-forward ", "))
16204 ;; We have already read .newsrc.eld, so we gently update the
16205 ;; data in the hash table with the information we have just
16208 (let ((info (gnus-get-info group))
16211 ;; There is an entry for this file in the alist.
16213 (gnus-info-set-read info (nreverse reads))
16214 ;; We update the level very gently. In fact, we
16215 ;; only change it if there's been a status change
16216 ;; from subscribed to unsubscribed, or vice versa.
16217 (setq level (gnus-info-level info))
16218 (cond ((and (<= level gnus-level-subscribed)
16220 (setq level (if reads
16221 gnus-level-default-unsubscribed
16222 (1+ gnus-level-default-unsubscribed))))
16223 ((and (> level gnus-level-subscribed) subscribed)
16224 (setq level gnus-level-default-subscribed)))
16225 (gnus-info-set-level info level))
16226 ;; This is a new group.
16227 (setq info (list group
16229 gnus-level-default-subscribed
16231 (1+ gnus-level-subscribed)
16232 gnus-level-default-unsubscribed))
16233 (nreverse reads))))
16234 (setq newsrc (cons info newsrc))))))
16237 (setq newsrc (nreverse newsrc))
16239 (if (not already-read)
16241 ;; We now have two newsrc lists - `newsrc', which is what we
16242 ;; have read from .newsrc, and `gnus-newsrc-alist', which is
16243 ;; what we've read from .newsrc.eld. We have to merge these
16244 ;; lists. We do this by "attaching" any (foreign) groups in the
16245 ;; gnus-newsrc-alist to the (native) group that precedes them.
16246 (let ((rc (cdr gnus-newsrc-alist))
16247 (prev gnus-newsrc-alist)
16250 (or (null (nth 4 (car rc))) ; It's a native group.
16251 (assoc (caar rc) newsrc) ; It's already in the alist.
16252 (if (setq entry (assoc (caar prev) newsrc))
16253 (setcdr (setq mentry (memq entry newsrc))
16254 (cons (car rc) (cdr mentry)))
16255 (setq newsrc (cons (car rc) newsrc))))
16259 (setq gnus-newsrc-alist newsrc)
16260 ;; We make the newsrc hashtb.
16261 (gnus-make-hashtable-from-newsrc-alist)
16263 ;; Finally, if we read some options lines, we parse them.
16264 (or (string= gnus-newsrc-options "")
16265 (gnus-newsrc-parse-options gnus-newsrc-options))))
16267 ;; Parse options lines to find "options -n !all rec.all" and stuff.
16268 ;; The return value will be a list on the form
16269 ;; ((regexp1 . ignore)
16270 ;; (regexp2 . subscribe)...)
16271 ;; When handling new newsgroups, groups that match a `ignore' regexp
16272 ;; will be ignored, and groups that match a `subscribe' regexp will be
16273 ;; subscribed. A line like
16274 ;; options -n !all rec.all
16275 ;; will lead to a list that looks like
16276 ;; (("^rec\\..+" . subscribe)
16277 ;; ("^.+" . ignore))
16278 ;; So all "rec.*" groups will be subscribed, while all the other
16279 ;; groups will be ignored. Note that "options -n !all rec.all" is very
16280 ;; different from "options -n rec.all !all".
16281 (defun gnus-newsrc-parse-options (options)
16284 (gnus-set-work-buffer)
16285 (insert (regexp-quote options))
16286 ;; First we treat all continuation lines.
16287 (goto-char (point-min))
16288 (while (re-search-forward "\n[ \t]+" nil t)
16289 (replace-match " " t t))
16290 ;; Then we transform all "all"s into ".+"s.
16291 (goto-char (point-min))
16292 (while (re-search-forward "\\ball\\b" nil t)
16293 (replace-match ".+" t t))
16294 (goto-char (point-min))
16295 ;; We remove all other options than the "-n" ones.
16296 (while (re-search-forward "[ \t]-[^n][^-]*" nil t)
16297 (replace-match " ")
16299 (goto-char (point-min))
16301 ;; We are only interested in "options -n" lines - we
16302 ;; ignore the other option lines.
16303 (while (re-search-forward "[ \t]-n" nil t)
16305 (or (save-excursion
16306 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t)
16308 (gnus-point-at-eol)))
16309 ;; Search for all "words"...
16310 (while (re-search-forward "[^ \t,\n]+" eol t)
16311 (if (= (char-after (match-beginning 0)) ?!)
16312 ;; If the word begins with a bang (!), this is a "not"
16313 ;; spec. We put this spec (minus the bang) and the
16314 ;; symbol `ignore' into the list.
16315 (setq out (cons (cons (concat
16316 "^" (buffer-substring
16317 (1+ (match-beginning 0))
16320 ;; There was no bang, so this is a "yes" spec.
16321 (setq out (cons (cons (concat "^" (match-string 0))
16322 'subscribe) out)))))
16324 (setq gnus-newsrc-options-n out))))
16326 (defun gnus-save-newsrc-file (&optional force)
16327 "Save .newsrc file."
16328 ;; Note: We cannot save .newsrc file if all newsgroups are removed
16329 ;; from the variable gnus-newsrc-alist.
16330 (when (and (or gnus-newsrc-alist gnus-killed-list)
16331 gnus-current-startup-file)
16333 (if (and (or gnus-use-dribble-file gnus-slave)
16335 (or (not gnus-dribble-buffer)
16336 (not (buffer-name gnus-dribble-buffer))
16337 (zerop (save-excursion
16338 (set-buffer gnus-dribble-buffer)
16340 (gnus-message 4 "(No changes need to be saved)")
16341 (run-hooks 'gnus-save-newsrc-hook)
16343 (gnus-slave-save-newsrc)
16345 (when gnus-save-newsrc-file
16346 (gnus-message 5 "Saving %s..." gnus-current-startup-file)
16347 (gnus-gnus-to-newsrc-format)
16348 (gnus-message 5 "Saving %s...done" gnus-current-startup-file))
16349 ;; Save .newsrc.eld.
16350 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
16351 (make-local-variable 'version-control)
16352 (setq version-control 'never)
16353 (setq buffer-file-name
16354 (concat gnus-current-startup-file ".eld"))
16355 (gnus-add-current-to-buffer-list)
16356 (buffer-disable-undo (current-buffer))
16358 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file)
16359 (gnus-gnus-to-quick-newsrc-format)
16360 (run-hooks 'gnus-save-quick-newsrc-hook)
16362 (kill-buffer (current-buffer))
16364 5 "Saving %s.eld...done" gnus-current-startup-file))
16365 (gnus-dribble-delete-file)))))
16367 (defun gnus-gnus-to-quick-newsrc-format ()
16368 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
16369 (insert ";; Gnus startup file.\n")
16370 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
16371 (insert ";; to read .newsrc.\n")
16372 (insert "(setq gnus-newsrc-file-version "
16373 (prin1-to-string gnus-version) ")\n")
16375 (if gnus-save-killed-list gnus-variable-list
16376 ;; Remove the `gnus-killed-list' from the list of variables
16377 ;; to be saved, if required.
16378 (delq 'gnus-killed-list (copy-sequence gnus-variable-list))))
16379 ;; Peel off the "dummy" group.
16380 (gnus-newsrc-alist (cdr gnus-newsrc-alist))
16382 ;; Insert the variables into the file.
16384 (when (and (boundp (setq variable (pop variables)))
16385 (symbol-value variable))
16386 (insert "(setq " (symbol-name variable) " '")
16387 (prin1 (symbol-value variable) (current-buffer))
16390 (defun gnus-gnus-to-newsrc-format ()
16391 ;; Generate and save the .newsrc file.
16393 (set-buffer (create-file-buffer gnus-current-startup-file))
16394 (let ((newsrc (cdr gnus-newsrc-alist))
16395 (standard-output (current-buffer))
16396 info ranges range method)
16397 (setq buffer-file-name gnus-current-startup-file)
16398 (buffer-disable-undo (current-buffer))
16401 (if gnus-newsrc-options (insert gnus-newsrc-options))
16402 ;; Write subscribed and unsubscribed.
16403 (while (setq info (pop newsrc))
16404 ;; Don't write foreign groups to .newsrc.
16405 (when (or (null (setq method (gnus-info-method info)))
16406 (equal method "native")
16407 (gnus-server-equal method gnus-select-method))
16408 (insert (gnus-info-group info)
16409 (if (> (gnus-info-level info) gnus-level-subscribed)
16411 (when (setq ranges (gnus-info-read info))
16413 (if (not (listp (cdr ranges)))
16414 (if (= (car ranges) (cdr ranges))
16415 (princ (car ranges))
16416 (princ (car ranges))
16418 (princ (cdr ranges)))
16419 (while (setq range (pop ranges))
16420 (if (or (atom range) (= (car range) (cdr range)))
16421 (princ (or (and (atom range) range) (car range)))
16422 (princ (car range))
16424 (princ (cdr range)))
16425 (if ranges (insert ",")))))
16427 (make-local-variable 'version-control)
16428 (setq version-control 'never)
16429 ;; It has been reported that sometime the modtime on the .newsrc
16430 ;; file seems to be off. We really do want to overwrite it, so
16431 ;; we clear the modtime here before saving. It's a bit odd,
16433 ;; sometimes the modtime clear isn't sufficient. most brute force:
16434 ;; delete the silly thing entirely first. but this fails to provide
16435 ;; such niceties as .newsrc~ creation.
16436 (if gnus-modtime-botch
16437 (delete-file gnus-startup-file)
16438 (clear-visited-file-modtime))
16439 (run-hooks 'gnus-save-standard-newsrc-hook)
16441 (kill-buffer (current-buffer)))))
16445 ;;; Slave functions.
16448 (defun gnus-slave-save-newsrc ()
16450 (set-buffer gnus-dribble-buffer)
16452 (make-temp-name (concat gnus-current-startup-file "-slave-"))))
16453 (write-region (point-min) (point-max) slave-name nil 'nomesg))))
16455 (defun gnus-master-read-slave-newsrc ()
16458 (file-name-directory gnus-current-startup-file)
16462 (file-name-nondirectory gnus-current-startup-file)
16466 (if (not slave-files)
16467 () ; There are no slave files to read.
16468 (gnus-message 7 "Reading slave newsrcs...")
16470 (set-buffer (get-buffer-create " *gnus slave*"))
16471 (buffer-disable-undo (current-buffer))
16473 (sort (mapcar (lambda (file)
16474 (list (nth 5 (file-attributes file)) file))
16477 (or (< (caar f1) (caar f2))
16478 (< (nth 1 (car f1)) (nth 1 (car f2)))))))
16481 (setq file (nth 1 (car slave-files)))
16482 (insert-file-contents file)
16483 (if (condition-case ()
16485 (eval-buffer (current-buffer))
16488 (gnus-message 3 "Possible error in %s" file)
16492 (or gnus-slave ; Slaves shouldn't delete these files.
16496 (setq slave-files (cdr slave-files))))
16497 (gnus-message 7 "Reading slave newsrcs...done"))))
16501 ;;; Group description.
16504 (defun gnus-read-all-descriptions-files ()
16505 (let ((methods (cons gnus-select-method
16507 (when gnus-message-archive-method
16509 gnus-secondary-select-methods))))
16511 (gnus-read-descriptions-file (car methods))
16512 (setq methods (cdr methods)))
16515 (defun gnus-read-descriptions-file (&optional method)
16516 (let ((method (or method gnus-select-method)))
16517 (when (stringp method)
16518 (setq method (gnus-server-to-method method)))
16519 ;; We create the hashtable whether we manage to read the desc file
16520 ;; to avoid trying to re-read after a failed read.
16521 (or gnus-description-hashtb
16522 (setq gnus-description-hashtb
16523 (gnus-make-hashtable (length gnus-active-hashtb))))
16524 ;; Mark this method's desc file as read.
16525 (gnus-sethash (gnus-group-prefixed-name "" method) "Has read"
16526 gnus-description-hashtb)
16528 (gnus-message 5 "Reading descriptions file via %s..." (car method))
16530 ((not (gnus-check-server method))
16531 (gnus-message 1 "Couldn't open server")
16533 ((not (gnus-request-list-newsgroups method))
16534 (gnus-message 1 "Couldn't read newsgroups descriptions")
16540 (set-buffer nntp-server-buffer)
16541 (goto-char (point-min))
16542 (if (or (search-forward "\n.\n" nil t)
16543 (goto-char (point-max)))
16545 (beginning-of-line)
16546 (narrow-to-region (point-min) (point))))
16547 (goto-char (point-min))
16548 (while (not (eobp))
16549 ;; If we get an error, we set group to 0, which is not a
16553 (let ((obarray gnus-description-hashtb))
16554 ;; Group is set to a symbol interned in this
16556 (read nntp-server-buffer))
16558 (skip-chars-forward " \t")
16559 ;; ... which leads to this line being effectively ignored.
16560 (and (symbolp group)
16561 (set group (buffer-substring
16562 (point) (progn (end-of-line) (point)))))
16563 (forward-line 1))))
16564 (gnus-message 5 "Reading descriptions file...done")
16567 (defun gnus-group-get-description (group)
16568 "Get the description of a group by sending XGTITLE to the server."
16569 (when (gnus-request-group-description group)
16571 (set-buffer nntp-server-buffer)
16572 (goto-char (point-min))
16573 (when (looking-at "[^ \t]+[ \t]+\\(.*\\)")
16574 (match-string 1)))))
16578 ;;; Buffering of read articles.
16581 (defvar gnus-backlog-buffer " *Gnus Backlog*")
16582 (defvar gnus-backlog-articles nil)
16583 (defvar gnus-backlog-hashtb nil)
16585 (defun gnus-backlog-buffer ()
16586 "Return the backlog buffer."
16587 (or (get-buffer gnus-backlog-buffer)
16589 (set-buffer (get-buffer-create gnus-backlog-buffer))
16590 (buffer-disable-undo (current-buffer))
16591 (setq buffer-read-only t)
16592 (gnus-add-current-to-buffer-list)
16593 (get-buffer gnus-backlog-buffer))))
16595 (defun gnus-backlog-setup ()
16596 "Initialize backlog variables."
16597 (unless gnus-backlog-hashtb
16598 (setq gnus-backlog-hashtb (make-vector 1023 0))))
16600 (gnus-add-shutdown 'gnus-backlog-shutdown 'gnus)
16602 (defun gnus-backlog-shutdown ()
16603 "Clear all backlog variables and buffers."
16604 (when (get-buffer gnus-backlog-buffer)
16605 (kill-buffer gnus-backlog-buffer))
16606 (setq gnus-backlog-hashtb nil
16607 gnus-backlog-articles nil))
16609 (defun gnus-backlog-enter-article (group number buffer)
16610 (gnus-backlog-setup)
16611 (let ((ident (intern (concat group ":" (int-to-string number))
16612 gnus-backlog-hashtb))
16614 (if (memq ident gnus-backlog-articles)
16615 () ; It's already kept.
16616 ;; Remove the oldest article, if necessary.
16617 (and (numberp gnus-keep-backlog)
16618 (>= (length gnus-backlog-articles) gnus-keep-backlog)
16619 (gnus-backlog-remove-oldest-article))
16620 (setq gnus-backlog-articles (cons ident gnus-backlog-articles))
16621 ;; Insert the new article.
16623 (set-buffer (gnus-backlog-buffer))
16624 (let (buffer-read-only)
16625 (goto-char (point-max))
16626 (or (bolp) (insert "\n"))
16628 (insert-buffer-substring buffer)
16629 ;; Tag the beginning of the article with the ident.
16630 (put-text-property b (1+ b) 'gnus-backlog ident))))))
16632 (defun gnus-backlog-remove-oldest-article ()
16634 (set-buffer (gnus-backlog-buffer))
16635 (goto-char (point-min))
16636 (if (zerop (buffer-size))
16637 () ; The buffer is empty.
16638 (let ((ident (get-text-property (point) 'gnus-backlog))
16640 ;; Remove the ident from the list of articles.
16642 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
16643 ;; Delete the article itself.
16645 (point) (next-single-property-change
16646 (1+ (point)) 'gnus-backlog nil (point-max)))))))
16648 (defun gnus-backlog-request-article (group number buffer)
16649 (when (numberp number)
16650 (gnus-backlog-setup)
16651 (let ((ident (intern (concat group ":" (int-to-string number))
16652 gnus-backlog-hashtb))
16654 (when (memq ident gnus-backlog-articles)
16655 ;; It was in the backlog.
16657 (set-buffer (gnus-backlog-buffer))
16658 (if (not (setq beg (text-property-any
16659 (point-min) (point-max) 'gnus-backlog
16661 ;; It wasn't in the backlog after all.
16663 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
16664 ;; Find the end (i. e., the beginning of the next article).
16666 (next-single-property-change
16667 (1+ beg) 'gnus-backlog (current-buffer) (point-max)))))
16668 (let ((buffer-read-only nil))
16670 (insert-buffer-substring gnus-backlog-buffer beg end)
16673 ;; Allow redefinition of Gnus functions.
16675 (gnus-ems-redefine)
16679 ;;; gnus.el ends here